3D spaceshooter with online scoreboard, online demos, ship building. Now entirely defunct, but might be resurrected

class.Util.php 1000B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class Util{
  3. // this needs name for salt.
  4. public static function calcSecureHash($name, $password){
  5. // !!! When changing this, it must also be changed in the client piece!
  6. return sha1( $name."S^1edT@R+ kN0w9e".md5( "troe(l01".$password."d*G -? df lo%iUq" )."myL!tT1e(P)0nNY" );
  7. }
  8. public static function uniqueString($len){
  9. $scale = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  10. $token = "";
  11. for($i=0;$i<$len;$i++){
  12. $token .= substr($scale, rand(0, strlen($scale)-1), 1);
  13. }
  14. return $token;
  15. }
  16. public static function remoteFileExists($url) {
  17. $curl = curl_init($url);
  18. curl_setopt($curl, CURLOPT_NOBODY, true);
  19. $result = curl_exec($curl);
  20. $ret = false;
  21. if ($result !== false) {
  22. $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  23. if ($statusCode == 200) {
  24. $ret = true;
  25. }
  26. }
  27. curl_close($curl);
  28. return $ret;
  29. }
  30. public static function trimNullSafe($string){
  31. if($string == null) return null;
  32. return trim($string);
  33. }
  34. }