3D spaceshooter with online scoreboard, online demos, ship building. Now entirely defunct, but might be resurrected
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sector/php-server/class.Util.php

38 lines
1000 B

<?php
class Util{
// this needs name for salt.
public static function calcSecureHash($name, $password){
// !!! When changing this, it must also be changed in the client piece!
return sha1( $name."S^1edT@R+ kN0w9e".md5( "troe(l01".$password."d*G -? df lo%iUq" )."myL!tT1e(P)0nNY" );
}
public static function uniqueString($len){
$scale = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$token = "";
for($i=0;$i<$len;$i++){
$token .= substr($scale, rand(0, strlen($scale)-1), 1);
}
return $token;
}
public static function remoteFileExists($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
$result = curl_exec($curl);
$ret = false;
if ($result !== false) {
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
$ret = true;
}
}
curl_close($curl);
return $ret;
}
public static function trimNullSafe($string){
if($string == null) return null;
return trim($string);
}
}