parent
7f50a261eb
commit
3d7bda9331
@ -0,0 +1,41 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
||||
<classpathentry kind="lib" path="lib/jinput.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/lwjgl_util.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/slick-util.jar" sourcepath="lib/slick-util-src.zip"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/jogg-0.0.7.jar"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/jorbis-0.0.15.jar"> |
||||
<attributes> |
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Sector-game/lib"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="lib" path="lib/jdom-2.0.3.jar" sourcepath="lib/jdom-2.0.3-sources.zip"/> |
||||
<classpathentry kind="lib" path="lib/httpclient-4.2.2.jar" sourcepath="lib/httpcomponents-client-4.2.2-src.zip"/> |
||||
<classpathentry kind="lib" path="lib/httpcore-4.2.2.jar" sourcepath="lib/httpcomponents-client-4.2.2-src.zip"/> |
||||
<classpathentry kind="lib" path="lib/commons-io-2.4.jar" sourcepath="lib/commons-io-2.4-src.zip"/> |
||||
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/> |
||||
<classpathentry kind="output" path="bin"/> |
||||
</classpath> |
@ -0,0 +1,2 @@ |
||||
/bin/ |
||||
*~ |
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>Sector-game</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,11 @@ |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 |
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve |
||||
org.eclipse.jdt.core.compiler.compliance=1.6 |
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate |
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate |
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate |
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
||||
org.eclipse.jdt.core.compiler.source=1.6 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,390 @@ |
||||
<?php |
||||
class DbUtil{ |
||||
public static function registerNewUser($name, $password, $email = "", $country = ""){ |
||||
$name = mysql_real_escape_string($name); |
||||
$password = mysql_real_escape_string($password); |
||||
$country = mysql_real_escape_string($country); |
||||
$email = mysql_real_escape_string($email); |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_USERS` WHERE `name` = '$name';"); |
||||
$rows=0; |
||||
list($rows) = mysql_fetch_row($result); |
||||
if($rows != 0){ |
||||
XmlGen::error_exit("REGISTRATION_FAILED","Entered name is already taken."); |
||||
} |
||||
|
||||
$uid = ""; |
||||
while(true){ |
||||
$uid = "U-".Util::uniqueString(12); |
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_USERS` WHERE `uid` = '$uid' AND `removed` = '0';"); |
||||
$row = mysql_fetch_row($result); |
||||
if($row[0] == 0) break; |
||||
} |
||||
|
||||
$time = time(); |
||||
|
||||
self::query(" |
||||
INSERT |
||||
INTO `SECTOR_USERS` |
||||
(`uid`,`name`,`password`,`email`,`reg_time`,`country`) |
||||
VALUES |
||||
('$uid','$name','$password','$email','$time','$country'); |
||||
"); |
||||
|
||||
self::refreshLogin($uid); |
||||
|
||||
exit(); |
||||
} |
||||
/* |
||||
$_REQUEST["uid"], |
||||
$_REQUEST["name"], |
||||
$_REQUEST["password"], |
||||
$_REQUEST["email"], |
||||
$_REQUEST["country"] |
||||
*/ |
||||
|
||||
public static function deleteProfile($uid){ |
||||
|
||||
$u = mysql_real_escape_string($uid); |
||||
self::query("UPDATE `SECTOR_USERS` SET `removed`='1' WHERE `uid` = '$u' LIMIT 1;"); |
||||
self::query("UPDATE `SECTOR_SCORES` SET `removed`='1' WHERE `uid` = '$u';"); |
||||
|
||||
// self::query("DELETE FROM `SECTOR_USERS` WHERE `uid` = '$u' LIMIT 1;"); |
||||
// self::query("DELETE FROM `SECTOR_SCORES` WHERE `uid` = '$u';"); |
||||
|
||||
echo XmlGen::deleteMessage(); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
|
||||
|
||||
public static function modifyProfile($uid,$name,$password,$email,$country){ |
||||
|
||||
if($name == null && $password == null && $email == null && $country == null){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Nothing to change."); |
||||
} |
||||
|
||||
$n = mysql_real_escape_string($name); |
||||
$u = mysql_real_escape_string($uid); |
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_USERS` WHERE `name` = '$n' AND `uid` != '$u';"); |
||||
$rows=0; |
||||
list($rows) = mysql_fetch_row($result); |
||||
if($rows != 0){ |
||||
XmlGen::error_exit("NAME_NOT_UNIQUE"); |
||||
} |
||||
|
||||
|
||||
$sql = ""; |
||||
|
||||
if($name != null){ |
||||
$sql .= ",`name` = '".mysql_real_escape_string($name)."'"; |
||||
} |
||||
|
||||
if($password != null){ |
||||
$sql .= ",`password` = '".mysql_real_escape_string($password)."'"; |
||||
} |
||||
|
||||
if($email == null) $email = ""; |
||||
|
||||
$sql .= ",`email` = '".mysql_real_escape_string($email)."'"; |
||||
|
||||
|
||||
if($country == null) $country = ""; |
||||
|
||||
$sql .= ",`country` = '".mysql_real_escape_string($country)."'"; |
||||
|
||||
|
||||
$sql = substr($sql,1); |
||||
|
||||
self::query(" |
||||
UPDATE `SECTOR_USERS` |
||||
SET $sql |
||||
WHERE `uid` = '$uid' |
||||
LIMIT 1; |
||||
"); |
||||
|
||||
self::refreshLogin($uid); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function logIn($name, $passwordHash){ |
||||
$name = mysql_real_escape_string(trim($name)); |
||||
|
||||
$result = self::query("SELECT `uid`,`password` FROM `SECTOR_USERS` WHERE `name` = '$name' AND `removed` = '0';"); |
||||
|
||||
if(mysql_num_rows($result) == 0){ |
||||
XmlGen::error_exit("LOGIN_FAILED","Bad name or password."); |
||||
} |
||||
|
||||
$row = mysql_fetch_assoc($result); |
||||
$dbPwd = $row['password']; |
||||
$uid = $row['uid']; |
||||
|
||||
// double hash with ugly salt! |
||||
if( Util::calcSecureHash($name,$dbPwd) != $passwordHash){ |
||||
XmlGen::error_exit("LOGIN_FAILED","Bad name or password."); |
||||
} |
||||
|
||||
self::refreshLogin($uid); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function isTokenValid($uid, $token){ |
||||
$uid = mysql_real_escape_string($uid); |
||||
$result = self::query("SELECT `auth_token` FROM `SECTOR_USERS` WHERE `uid` = '$uid' AND `removed` = '0';"); |
||||
|
||||
if(mysql_num_rows($result) == 0){ |
||||
return false; // bad UID |
||||
} |
||||
|
||||
$row = mysql_fetch_array($result); |
||||
return $row[0] == $token; |
||||
} |
||||
|
||||
public static function getInfo(){ |
||||
|
||||
$result = self::query("SELECT * FROM `SECTOR_INFO`;"); |
||||
|
||||
$entries = array(); |
||||
|
||||
while($row = mysql_fetch_row($result)){ |
||||
$entries[$row[0]] = $row[1]; |
||||
} |
||||
|
||||
$version = $entries['VERSION_NUMBER']+0; |
||||
|
||||
if($_REQUEST["VERSION"]<=$version){ |
||||
// only publicly available releases are counted, |
||||
// not prepared ones with higher version number |
||||
|
||||
// add to counter. |
||||
$midnight = strtotime('midnight'); |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_COUNTER` WHERE `date` = '$midnight';"); |
||||
$row = mysql_fetch_array($result); |
||||
if($row[0] == 0){ |
||||
self::query("INSERT INTO `SECTOR_COUNTER`(`date`,`visits`) VALUES ('$midnight','1');"); |
||||
}else{ |
||||
self::query("UPDATE `SECTOR_COUNTER` SET `visits`=`visits`+1 WHERE `date` = '$midnight' LIMIT 1;"); |
||||
} |
||||
} |
||||
|
||||
echo XmlGen::infoTable($entries); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function getUsers(){ |
||||
|
||||
$result = self::query("SELECT `name`,`reg_time`,`country` FROM `SECTOR_USERS` WHERE `removed` = '0';"); |
||||
|
||||
$entries = array(); |
||||
|
||||
while($row = mysql_fetch_array($result)){ |
||||
$entries[] = $row; |
||||
} |
||||
|
||||
echo XmlGen::userList($entries); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
|
||||
public static function getLevels(){ |
||||
|
||||
$result = self::query("SELECT `value` FROM `SECTOR_INFO` WHERE `key` = 'LEVELS_PATH';"); |
||||
$row = mysql_fetch_array($result); |
||||
$path = $row[0]; |
||||
|
||||
|
||||
$result = self::query("SELECT `lid`,`title`,`filename`,`checksum`,`time` FROM `SECTOR_LEVELS` WHERE `removed` = '0';"); |
||||
|
||||
$entries = array(); |
||||
|
||||
while($row = mysql_fetch_array($result)){ |
||||
$row[2] = $path.$row[2]; |
||||
$entries[] = $row; |
||||
} |
||||
|
||||
echo XmlGen::levelList($entries); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function getLevelScores($lid, $changeFlag = null, $lastRecord = null){ |
||||
$lid = mysql_real_escape_string($lid); |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_LEVELS` WHERE `lid` = '$lid' AND `removed` = '0';"); |
||||
$row = mysql_fetch_array($result); |
||||
$cnt = $row[0]; |
||||
|
||||
if($cnt==0) XmlGen::error_exit("NO_SUCH_LEVEL","No level with matching ID was found."); |
||||
|
||||
$result = self::query(" |
||||
SELECT |
||||
`SECTOR_USERS`.`name` AS `username`, |
||||
`SECTOR_SCORES`.`uid`, |
||||
`SECTOR_SCORES`.`time`, |
||||
`SECTOR_SCORES`.`score` |
||||
FROM `SECTOR_SCORES` JOIN `SECTOR_USERS` |
||||
WHERE |
||||
(`SECTOR_SCORES`.`uid` = `SECTOR_USERS`.`uid`) |
||||
AND (`lid`='$lid') |
||||
AND (`SECTOR_SCORES`.`removed` = '0') |
||||
ORDER BY `score` DESC, `time` DESC; |
||||
"); |
||||
|
||||
// username, uid, time, score |
||||
$entries = array(); |
||||
|
||||
while($row = mysql_fetch_array($result)){ |
||||
$entries[] = $row; |
||||
} |
||||
|
||||
echo XmlGen::scoreList($lid, $entries, $changeFlag, $lastRecord); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function submitScore($uid, $lid, $score){ |
||||
$lid = mysql_real_escape_string($lid); |
||||
$uid = mysql_real_escape_string($uid); |
||||
$score = $score+0; |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_LEVELS` WHERE `lid` = '$lid' AND `removed` = '0';"); |
||||
$row = mysql_fetch_array($result); |
||||
$cnt = $row[0]; |
||||
|
||||
if($cnt==0) XmlGen::error_exit("NO_SUCH_LEVEL","No level with matching ID was found."); |
||||
|
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_SCORES` WHERE `lid` = '$lid' AND `uid` = '$uid';"); |
||||
$row = mysql_fetch_array($result); |
||||
$cnt = $row[0]; |
||||
|
||||
$time = time(); |
||||
|
||||
$change = "false"; |
||||
$lastRecord = "-1"; |
||||
|
||||
if($cnt==0){ |
||||
// INSERT |
||||
self::query("INSERT INTO `SECTOR_SCORES`(`uid`,`lid`,`time`,`score`) VALUES ('$uid','$lid','$time','$score');"); |
||||
$change = "true"; |
||||
}else{ |
||||
$result = self::query("SELECT `score` FROM `SECTOR_SCORES` WHERE `lid` = '$lid' AND `uid` = '$uid';"); |
||||
$row = mysql_fetch_array($result); |
||||
$scoreOld = $row[0]; |
||||
|
||||
$lastRecord = "$scoreOld"; |
||||
if($scoreOld > $score){ |
||||
|
||||
}else{ |
||||
// UPDATE |
||||
self::query("UPDATE `SECTOR_SCORES` SET `time`='$time', `score`='$score' WHERE `lid` = '$lid' AND `uid` = '$uid' LIMIT 1;"); |
||||
if($scoreOld != $score) $change = "true"; |
||||
} |
||||
} |
||||
|
||||
self::getLevelScores($lid, $change, $lastRecord); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function refreshLogin($uid){ |
||||
$token = Util::uniqueString(20); |
||||
|
||||
self::query(" |
||||
UPDATE `SECTOR_USERS` |
||||
SET `auth_token` = '$token' |
||||
WHERE `uid` = '$uid' |
||||
LIMIT 1; |
||||
"); |
||||
|
||||
$result = self::query("SELECT `name`,`email`,`reg_time`,`country` FROM `SECTOR_USERS` WHERE `uid` = '$uid';"); |
||||
|
||||
$row = mysql_fetch_assoc($result); |
||||
|
||||
$name = $row["name"]; |
||||
$email = $row["email"]; |
||||
$reg_time = $row["reg_time"]; |
||||
$country = $row["country"]; |
||||
|
||||
echo XmlGen::sessionInfo($uid, $token, $name, $email, $reg_time, $country); |
||||
} |
||||
|
||||
|
||||
|
||||
public static function addLevel($title, $filename){ |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_LEVELS` WHERE `filename` = '".mysql_real_escape_string($filename)."';"); |
||||
$row = mysql_fetch_array($result); |
||||
$cnt = $row[0]; |
||||
|
||||
if($cnt>0) XmlGen::error_exit("LEVEL_ALREADY_ADDED"); |
||||
|
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_LEVELS` WHERE `title` = '".mysql_real_escape_string($title)."';"); |
||||
$row = mysql_fetch_array($result); |
||||
$cnt = $row[0]; |
||||
|
||||
if($cnt>0) XmlGen::error_exit("LEVEL_NAME_NOT_UNIQUE"); |
||||
|
||||
$result = self::query("SELECT `value` FROM `SECTOR_INFO` WHERE `key` = 'LEVELS_PATH_RELATIVE_TO_SERVER';"); |
||||
$row = mysql_fetch_array($result); |
||||
$path = $row[0]; |
||||
|
||||
$result = self::query("SELECT `value` FROM `SECTOR_INFO` WHERE `key` = 'LEVELS_PATH';"); |
||||
$row = mysql_fetch_array($result); |
||||
$apath = $row[0]; |
||||
|
||||
$fpath = $path.$filename; |
||||
|
||||
|
||||
if(!file_exists($fpath)){ |
||||
XmlGen::error_exit("FILE_NOT_FOUND","Level file does not exist: ".$fpath); |
||||
} |
||||
|
||||
if(substr($filename,strlen($filename)-4) != ".xml"){ |
||||
XmlGen::error_exit("BAD_FILE_FORMAT", "Level file must be XML: ".$fpath); |
||||
} |
||||
|
||||
|
||||
// generate a LID |
||||
$lid = ""; |
||||
while(true){ |
||||
$lid = "L-".Util::uniqueString(9); |
||||
$result = self::query("SELECT COUNT(*) FROM `SECTOR_LEVELS` WHERE `lid` = '$lid';"); |
||||
$row = mysql_fetch_row($result); |
||||
if($row[0] == 0) break; |
||||
} |
||||
|
||||
|
||||
$hash = md5_file($fpath); |
||||
|
||||
$title = mysql_real_escape_string($title); |
||||
$filename = mysql_real_escape_string($filename); |
||||
|
||||
$time = time(); |
||||
|
||||
|
||||
self::query(" |
||||
INSERT |
||||
INTO `SECTOR_LEVELS` |
||||
(`lid`,`title`,`filename`,`checksum`,`time`) |
||||
VALUES |
||||
('$lid','$title','$filename','$hash','$time'); |
||||
"); |
||||
|
||||
echo XmlGen::levelAddedInfo($lid, $title, $apath.$filename, $hash, $time); |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
public static function query($q){ |
||||
$res = mysql_query($q) or die(XmlGen::error("INTERNAL_ERROR", "DbError: ".mysql_error())); |
||||
return $res; |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
<?php |
||||
|
||||
# Class for easier XML generation |
||||
class SimpleDocument extends DOMDocument{ |
||||
private $rootNode = null; |
||||
public function __construct($rootName='xml', $attribs = array()){ |
||||
parent::__construct('1.0', 'UTF-8'); |
||||
$rootElement = $this->createElement($rootName, $attribs); |
||||
|
||||
$this->rootNode = $this->appendChild($rootElement); |
||||
} |
||||
|
||||
public function createAttribute($name, $value){ |
||||
$a = parent::createAttribute($name); |
||||
$a->value = $value; |
||||
return $a; |
||||
} |
||||
|
||||
public function createElement($name='element', $attribs = null, $inner=''){ |
||||
$elem = parent::createElement($name,$inner); |
||||
|
||||
if($attribs != null){ |
||||
foreach($attribs as $key => $value){ |
||||
$a = $this->createAttribute($key, $value); |
||||
$elem->appendChild($a); |
||||
} |
||||
} |
||||
|
||||
return $elem; |
||||
} |
||||
|
||||
public function appendChildToRoot(DOMElement $element){ |
||||
return $this->rootNode->appendChild($element); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
<?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); |
||||
} |
||||
} |
@ -0,0 +1,207 @@ |
||||
<?php |
||||
|
||||
global $ERR; |
||||
|
||||
# XML generator |
||||
class XmlGen{ |
||||
|
||||
public static function sendHeaders(){ |
||||
header("content-type: application/xml; charset=UTF-8"); |
||||
header("Cache-Control: no-cache, must-revalidate"); |
||||
} |
||||
|
||||
public static function hashCode($hash){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("hash"); |
||||
$doc->appendChildToRoot( $doc->createElement("hash", null, $hash) ); |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function deleteMessage(){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("status"); |
||||
$doc->appendChildToRoot( $doc->createElement("msg", null, "Profile deleted.") ); |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function infoTable($info){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("info"); |
||||
foreach($info as $k => $v){ |
||||
$eElem = $doc->createElement("entry"); |
||||
$enode = $doc->appendChildToRoot($eElem); |
||||
|
||||
$enode->appendChild($doc->createElement("key", null, $k)); |
||||
$enode->appendChild($doc->createElement("value", null, $v)); |
||||
} |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function userList($users){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("users"); |
||||
foreach($users as $u){ |
||||
$userElem = $doc->createElement("user"); |
||||
$unode = $doc->appendChildToRoot($userElem); |
||||
|
||||
$unode->appendChild($doc->createElement("name", null, $u[0])); |
||||
$unode->appendChild($doc->createElement("reg_time", null, $u[1])); |
||||
$unode->appendChild($doc->createElement("country", null, $u[2])); |
||||
} |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function levelList($data){ // `lid`,`title`,`filename`,`checksum`,`time` |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("levels"); |
||||
foreach($data as $l){ |
||||
$level = $doc->createElement("level"); |
||||
|
||||
$lnode = $doc->appendChildToRoot($level); |
||||
$lnode->appendChild($doc->createElement("lid", null, $l[0])); |
||||
$lnode->appendChild($doc->createElement("title", null, $l[1])); |
||||
$lnode->appendChild($doc->createElement("url", null, $l[2])); |
||||
$lnode->appendChild($doc->createElement("checksum", null, $l[3])); |
||||
$lnode->appendChild($doc->createElement("created", null, $l[4])); |
||||
} |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function scoreList($lid, $data, $changeFlag=null, $lastRecord=null){ // username, uid, time, score |
||||
self::sendHeaders(); |
||||
$attrs = array(); |
||||
if($changeFlag!=null) $attrs["score_improved"] = $changeFlag; |
||||
if($changeFlag!=null) $attrs["last_score"] = $lastRecord; |
||||
$doc = new SimpleDocument("scores", $attrs); |
||||
foreach($data as $l){ |
||||
$level = $doc->createElement("score"); |
||||
|
||||
$lnode = $doc->appendChildToRoot($level); |
||||
$lnode->appendChild($doc->createElement("uid", null, $l[1])); |
||||
$lnode->appendChild($doc->createElement("name", null, $l[0])); |
||||
$lnode->appendChild($doc->createElement("time", null, $l[2])); |
||||
$lnode->appendChild($doc->createElement("score", null, $l[3])); |
||||
} |
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function levelAddedInfo($lid, $title, $url, $hash, $time){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("level"); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("lid", null, $lid) ); |
||||
$doc->appendChildToRoot( $doc->createElement("title", null, $title) ); |
||||
$doc->appendChildToRoot( $doc->createElement("url", null, $url) ); |
||||
$doc->appendChildToRoot( $doc->createElement("checksum", null, $hash) ); |
||||
$doc->appendChildToRoot( $doc->createElement("created", null, $time) ); |
||||
|
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function sessionInfo($uid, $token, $name=null, $email=null, $reg_time=null, $country=null){ |
||||
self::sendHeaders(); |
||||
$doc = new SimpleDocument("session"); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("uid", null, $uid) ); |
||||
$doc->appendChildToRoot( $doc->createElement("auth_token", null, $token) ); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("name", null, $name) ); |
||||
$doc->appendChildToRoot( $doc->createElement("email", null, $email) ); |
||||
$doc->appendChildToRoot( $doc->createElement("reg_time", null, $reg_time) ); |
||||
$doc->appendChildToRoot( $doc->createElement("country", null, $country) ); |
||||
|
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function error($error, $msg=""){ |
||||
self::sendHeaders(); |
||||
global $ERR; |
||||
$e = $ERR[$error]; |
||||
$doc = new SimpleDocument("error"); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("code", null, $e[0]) ); |
||||
$doc->appendChildToRoot( $doc->createElement("message", null, $e[1]) ); |
||||
$doc->appendChildToRoot( $doc->createElement("cause", null, $msg) ); |
||||
|
||||
return $doc->saveXML(); |
||||
} |
||||
|
||||
public static function error_exit($error, $msg=""){ |
||||
self::sendHeaders(); |
||||
global $ERR; |
||||
$e = $ERR[$error]; |
||||
$doc = new SimpleDocument("error"); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("code", null, $e[0]) ); |
||||
$doc->appendChildToRoot( $doc->createElement("message", null, $e[1]) ); |
||||
$doc->appendChildToRoot( $doc->createElement("cause", null, $msg) ); |
||||
|
||||
echo $doc->saveXML(); |
||||
exit(); |
||||
} |
||||
|
||||
|
||||
|
||||
public static function hacking_exit(){ |
||||
|
||||
srand(round(time()/7200)); |
||||
|
||||
if(rand(0,10)==0){ |
||||
$full_url_path = "http://".$_SERVER['HTTP_HOST'].preg_replace("#/[^/]*\.php$#simU", "/", $_SERVER["PHP_SELF"])."nothingHere.txt"; |
||||
|
||||
$ch = curl_init(); |
||||
$timeout = 5; |
||||
curl_setopt($ch, CURLOPT_URL, $full_url_path); |
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
||||
echo curl_exec($ch); |
||||
curl_close($ch); |
||||
|
||||
/* echo "<HTML> |
||||
<HEAD> |
||||
<TITLE>404 Not Found</TITLE> |
||||
</HEAD> |
||||
<BODY> |
||||
<H1>Not Found</H1> |
||||
The requested document was not found on this server. |
||||
<P> |
||||
<HR> |
||||
<ADDRESS> |
||||
Web Server at ".$_SERVER['SERVER_NAME']." |
||||
</ADDRESS> |
||||
</BODY> |
||||
</HTML>";*/ |
||||
|
||||
exit(); |
||||
} |
||||
|
||||
self::sendHeaders(); |
||||
|
||||
$doc = new SimpleDocument("error"); |
||||
|
||||
$msgs = array( |
||||
15 => "Internal server error.", |
||||
"Database connection timed out.", |
||||
"Service temporarily overloaded.", |
||||
"Service temporarily not available.", |
||||
"Operation not permitted.", |
||||
"Session has expired.", |
||||
"Brandwidth limit reached, aborting.", |
||||
"Access denied.", |
||||
"Unauthorised server access.", |
||||
"Invalid command exception.", |
||||
"Operation aborted.", |
||||
"Bad database entry format.", |
||||
); |
||||
|
||||
|
||||
$e = rand(15,15+count($msgs)-1); |
||||
|
||||
$doc->appendChildToRoot( $doc->createElement("code", null, $e) ); |
||||
$doc->appendChildToRoot( $doc->createElement("message", null, $msgs[$e]) ); |
||||
$doc->appendChildToRoot( $doc->createElement("cause", null, "") ); |
||||
|
||||
echo $doc->saveXML(); |
||||
exit(); |
||||
} |
||||
} |
@ -0,0 +1,75 @@ |
||||
<?php |
||||
|
||||
// DUMP OF MYSQL DATABASE FOR SECTOR |
||||
|
||||
/* |
||||
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; |
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `SECTOR_INFO` ( |
||||
`key` varchar(30) NOT NULL COMMENT 'Property key', |
||||
`value` text NOT NULL COMMENT 'Property value (text)', |
||||
PRIMARY KEY (`key`) |
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Information for Sector, eg. Info about updates, messages etc'; |
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO `SECTOR_INFO` (`key`, `value`) VALUES |
||||
('LEVELS_PATH', 'http://www.ondrovo.com/sector/api/levels/'), |
||||
('VERSION', 'Alpha 14'), |
||||
('VERSION_NUMBER', '14'), |
||||
('LEVELS_PATH_RELATIVE_TO_SERVER', 'levels/'); |
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `SECTOR_LEVELS` ( |
||||
`lid` varchar(20) NOT NULL COMMENT 'Level id', |
||||
`title` varchar(120) NOT NULL COMMENT 'Level title (shown is game)', |
||||
`filename` varchar(100) NOT NULL COMMENT 'File name in storage', |
||||
`checksum` varchar(100) NOT NULL COMMENT 'hashcode of the file', |
||||
`time` int(12) unsigned NOT NULL COMMENT 'time of creation', |
||||
PRIMARY KEY (`lid`), |
||||
UNIQUE KEY `title` (`title`) |
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table of official sector levels'; |
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO `SECTOR_LEVELS` (`lid`, `title`, `filename`, `checksum`, `time`) VALUES |
||||
('L-i5dvKm6Fv', 'Demo level', 'alpha14test.xml', 'b9d8db8da9c2ca54e78bf8d2a8a2dc6c', 1356545440); |
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `SECTOR_SCORES` ( |
||||
`id` int(12) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entry ID', |
||||
`uid` varchar(20) NOT NULL COMMENT 'User ID', |
||||
`lid` varchar(20) NOT NULL COMMENT 'Level ID', |
||||
`time` int(12) NOT NULL COMMENT 'Time when this score has been made', |
||||
`score` int(12) NOT NULL COMMENT 'Highest score for player/level', |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table of SECTOR highscores'; |
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `SECTOR_USERS` ( |
||||
`uid` varchar(20) NOT NULL COMMENT 'User ID', |
||||
`name` varchar(50) NOT NULL COMMENT 'User''s nickname', |
||||
`password` varchar(80) NOT NULL COMMENT 'User''s password', |
||||
`auth_token` varchar(120) NOT NULL COMMENT 'Authentication code used to make communication more secure.', |
||||
`email` varchar(120) NOT NULL COMMENT 'Email for password recovery', |
||||
`reg_time` int(12) NOT NULL COMMENT 'Registration timestamp (for stats)', |
||||
`country` varchar(120) NOT NULL DEFAULT '' COMMENT 'Country for stats', |
||||
PRIMARY KEY (`uid`), |
||||
UNIQUE KEY `uname` (`name`) |
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table of SECTOR''s registered users'; |
||||
|
||||
|
||||
*/ |
@ -0,0 +1,423 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<level> |
||||
|
||||
<info> |
||||
<title>Alpha 14 test level</title> |
||||
<subtitle>Challenge level with bosses</subtitle> |
||||
<author>MightyPork</author> |
||||
<minv>14</minv> |
||||
</info> |
||||
|
||||
|
||||
|
||||
<config> |
||||
<money>40000</money> |
||||
<building>NORMAL</building> |
||||
</config> |
||||
|
||||
|
||||
|
||||
|
||||
<discoveries> |
||||
<all level="max" /> |
||||
<discovery name="cannon" level="0" /> |
||||
</discoveries> |
||||
|
||||
|
||||
<ship> |
||||
<dim x="9" y="9" /> |
||||
<sys energy="4" shield="2" /> |
||||
<struct> |
||||
<row> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
<piece id="w_cannon" level="3" rotate="0" health="1.5" trigger="BTN_DOWN:0" /> |
||||
<piece id="w_emp" level="1" rotate="0" health="3.0" trigger="BTN_DOWN:1" /> |
||||
<piece id="w_cannon" level="3" rotate="0" health="1.5" trigger="BTN_DOWN:0" /> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
</row> |
||||
<row> |
||||
<null /> |
||||
<null /> |
||||
<piece id="w_laser" level="3" rotate="0" health="2.0" trigger="BTN_DOWN:0" /> |
||||
<piece id="bs_triangle" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="180" health="1.5" /> |
||||
<piece id="bs_triangle" level="1" rotate="0" health="1.5" /> |
||||
<piece id="w_laser" level="3" rotate="0" health="2.0" trigger="BTN_DOWN:0" /> |
||||
<null /> |
||||
<null /> |
||||
</row> |
||||
<row> |
||||
<null /> |
||||
<piece id="w_plasma" level="2" rotate="0" health="4.0" trigger="BTN_DOWN:0" /> |
||||
<piece id="bs_triangle" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bs_corner1" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_corner1" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_triangle" level="1" rotate="0" health="1.5" /> |
||||
<piece id="w_plasma" level="2" rotate="0" health="4.0" trigger="BTN_DOWN:0" /> |
||||
<null /> |
||||
</row> |
||||
<row> |
||||
<piece id="w_plasma" level="2" rotate="0" health="4.0" trigger="BTN_DOWN:0" /> |
||||
<piece id="bw_triangle" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bw_triangle" level="1" rotate="0" health="1.5" /> |
||||
<piece id="w_plasma" level="2" rotate="0" health="4.0" trigger="BTN_DOWN:0" /> |
||||
</row> |
||||
<row> |
||||
<piece id="bw_triangle" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bw_triangle" level="1" rotate="0" health="1.5" /> |
||||
</row> |
||||
<row> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="90" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
</row> |
||||
<row> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bw_triangle" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bs_triangle" level="1" rotate="180" health="1.5" /> |
||||
<piece id="bs_corner1" level="1" rotate="180" health="1.5" /> |
||||
<piece id="bb_cube" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_corner1" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bs_triangle" level="1" rotate="270" health="1.5" /> |
||||
<piece id="bw_triangle" level="1" rotate="180" health="1.5" /> |
||||
<piece id="bw_cube" level="1" rotate="0" health="1.5" /> |
||||
</row> |
||||
<row> |
||||
<piece id="bw_triangle" level="1" rotate="270" health="1.5" /> |
||||
<null /> |
||||
<null /> |
||||
<piece id="bs_triangle" level="1" rotate="180" health="1.5" /> |
||||
<piece id="bs_side1" level="1" rotate="0" health="1.5" /> |
||||
<piece id="bs_triangle" level="1" rotate="270" health="1.5" /> |
||||
<null /> |
||||
<null /> |
||||
<piece id="bw_triangle" level="1" rotate="180" health="1.5" /> |
||||
</row> |
||||
<row> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
<piece id="engine_ion" level="3" rotate="0" health="4.0" /> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
<null /> |
||||
</row> |
||||
</struct> |
||||
</ship> |
||||
|
||||
|
||||
<sequence> |
||||
|
||||
<rockshift coord="0;-1" /> |
||||
|
||||
<rockgen id="rocks" > |
||||
<type num="-1" /> |
||||
<size range="2-8" /> |
||||
<speed num="3" /> |
||||
<rarity num="10" /> |
||||
<x range="-30-30" /> |
||||
<z range="100-120" /> |
||||
</rockgen> |
||||
|
||||
<pause t="2" /> |
||||
<msg str="Welcome to Sector!" t="3" /> |
||||
<msg str="Level by MightyPork" t="1" /> |
||||
<msg str="" t="1" /> |
||||
<msg str="Enjoy!" t="1.5" /> |
||||
|
||||
<pause t="5" /> |
||||
|
||||
<shipgen id="mines" > |
||||
<entity str="mine" /> |
||||
<rarity num="60" /> |
||||
<x range="-10-10" /> |
||||
<z range="100-120" /> |
||||
</shipgen> |
||||
|
||||
<shipgen id="fighters" > |
||||
<entity str="fighter" /> |
||||
<rarity num="110" /> |
||||
<size range="0.5-1" /> |
||||
<x range="-5-5" /> |
||||
<z range="100-120" /> |
||||
<wave str="annoyers" /> |
||||
</shipgen> |
||||
|
||||
<shipgen id="birds" > |
||||
<entity str="bird" /> |
||||
<rarity num="150" /> |
||||
<size range="0.5-1" /> |
||||
<x range="-15:15" /> |
||||
<z range="100-120" /> |
||||
<wave str="annoyers" /> |
||||
</shipgen> |
||||
|
||||
|
||||
<pause t="5" /> |
||||
|
||||
<cycle> |
||||
|
||||
|
||||
<!-- cleanup --> |
||||
<disable gen="birds" /> |
||||
<disable gen="fighters" /> |
||||
<wait for="annoyers" /> |
||||
|
||||
|
||||
|
||||
<!-- SNAKEY --> |
||||
<msg str="Snakey!" t="4"/> |
||||
|
||||
<spawn> |
||||
<entity str="snake" /> |
||||
<x range="-20:20" /> |
||||
<z range="100:110"/> |
||||
<wave str="boss" /> |
||||
<count range="5-7" /> |
||||
<dist num="2" /> |
||||
<variant range="0-5" /> |
||||
<uniform bool="true" /> |
||||
<artifact bool="true" /> |
||||
<formation str="snake" /> |
||||
</spawn> |
||||
|
||||
<wait for="boss" /> |
||||
|
||||
<!-- /SNAKEY --> |
||||
|
||||
|
||||
|
||||
<!-- SNAKEY --> |
||||
<msg str="And snake again!" t="4"/> |
||||
|
||||
<spawn> |
||||
<entity str="snake" /> |
||||
<x range="-20:20" /> |
||||
<z range="100:110"/> |
||||
<wave str="boss" /> |
||||
<count range="5-7" /> |
||||
<dist num="2" /> |
||||
<variant range="0-5" /> |
||||
<uniform bool="true" /> |
||||
<artifact bool="true" /> |
||||
<formation str="snake" /> |
||||
</spawn> |
||||
|
||||
<wait for="boss" /> |
||||
|
||||
<!-- /SNAKEY --> |
||||
|
||||
|
||||
|
||||
<!-- BURGERS --> |
||||
<pause t="3" /> |
||||
<enable gen="birds" /> |
||||
<enable gen="fighters" /> |
||||
|
||||
<spawn> |
||||
<entity str="burger" /> |
||||
<driver str="burger_zone" /> |
||||
<x num="0" /> |
||||
<z num="100" /> |
||||
<count num="10" /> |
||||
<formation str="line" /> |
||||
<uniform bool="true" /> |
||||
<dist num="3" /> |
||||
<wave str="annoyers" /> |
||||
</spawn> |
||||
|
||||
<pause t="3" /> |
||||
|
||||
<disable gen="birds" /> |
||||
<disable gen="fighters" /> |
||||
<wait for="annoyers" /> |
||||
<!-- /BURGERS --> |
||||
|
||||
|
||||
|
||||
|
||||
<!-- Getting ready for SHARK --> |
||||
<disable gen="birds" /> |
||||
<disable gen="fighters" /> |
||||
<disable gen="mines" /> |
||||
|
||||
<msg str="Better reload your shield!" t="3" /> |
||||
<wait for="annoyers" /> |
||||
<disable gen="rocks" /> |
||||
<pause t="10" /> |
||||
|
||||
|
||||
|
||||
|
||||
<!-- SHARK --> |
||||
<msg str="* Sushi Time *" t="2" /> |
||||
<msg str="" t="1" /> |
||||
<msg str="Want some seafood?" t="3" /> |
||||
<msg str="It's all yours!" t="2" /> |
||||
<pause t="3" /> |
||||
|
||||
<spawn> |
||||
<entity str="shark" /> |
||||
<driver str="shark" /> |
||||
<x num="0" /> |
||||
<z num="110" /> |
||||
<count num="1" /> |
||||
<artifact bool="true" /> |
||||
<wave str="boss" /> |
||||
<health num="2" /> |
||||
</spawn> |
||||
|
||||
<wait for="boss" /> |
||||
<!-- /SHARK --> |
||||
|
||||
|
||||
<!-- Reload shield in some rocks. --> |
||||
<enable gen="rocks" /> |
||||
<pause t="6" /> |
||||
<disable gen="rocks" /> |
||||
<pause t="8" /> |
||||
|
||||
|
||||
|
||||
<!-- FALCONS --> |
||||
<msg str="Falcons, oh man!" t="3"/> |
||||
|
||||
<spawn> |
||||
<entity str="falcon" /> |
||||
<driver str="falcon" /> |
||||
<x range="-10:10" /> |
||||
<z num="110" /> |
||||
<count num="3" /> |
||||
<wave str="boss" /> |
||||
<formation str="row" /> |
||||
<dist num="2.5" /> |
||||
</spawn> |
||||
|
||||
<wait for="boss" /> |
||||
<!-- /FALCONS --> |
||||
|
||||
<enable gen="rocks" /> |
||||
<msg str="" t="3"/> |
||||
<msg str="Ever played" t="1"/> |
||||
<msg str="MINESWEEPER?" t="3"/> |
||||
<wait t="10" /> |
||||
|
||||
<disable gen="rocks" /> |
||||
<pause t="7" /> |
||||
<msg str="WATCH OUT!" t="1.5"/> |
||||
<pause t="4" /> |
||||
|
||||
<rockshift coord="0;-2.5" /> |
||||
<repeat i="12"> |
||||
|
||||
<spawn> |
||||
<entity str="mine" /> |
||||
<scale num="1.3" /> |
||||
<x num="0" /> |
||||
<z range="110" /> |
||||
<count num="15" /> |
||||
<wave str="mines" /> |
||||
<formation str="row" /> |
||||
<dist num="1.5" /> |
||||
</spawn> |
||||
|
||||
<pause t="0.08" /> |
||||
<rockshift coord="-0.3;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="-0.6;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="-0.8;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="-0.6;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="-0.3;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0;-2.5" /> |
||||
<pause t="0.08" /> |
||||
|
||||
<spawn> |
||||
<entity str="mine" /> |
||||
<scale num="1.3" /> |
||||
<x num="0" /> |
||||
<z range="110" /> |
||||
<count num="15" /> |
||||
<wave str="mines" /> |
||||
<formation str="row" /> |
||||
<dist num="1.5" /> |
||||
</spawn> |
||||
|
||||
<rockshift coord="0.3;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0.6;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0.8;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0.6;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0.3;-2.5" /> |
||||
<pause t="0.08" /> |
||||
<rockshift coord="0;-2.5" /> |
||||
|
||||
</repeat> |
||||
|
||||
<wait for="mines" /> |
||||
<msg str="Wasn't this fun?" t="3"/> |
||||
<rockshift coord="0;-1" /> |
||||
<enable gen="rocks" /> |
||||
|
||||
|
||||
<!-- a bit of rocks & annoyers --> |
||||
<msg str="Relax..." t="1.5"/> |
||||
<msg str="You're almost there..." t="3"/> |
||||
<pause t="10" /> |
||||
|
||||
<enable gen="birds" /> |
||||
<enable gen="fighters" /> |
||||
<enable gen="mines" /> |
||||
<pause t="10" /> |
||||
<disable gen="birds" /> |
||||
<disable gen="fighters" /> |
||||
<disable gen="mines" /> |
||||
|
||||
<msg str="Congratulations!" t="3" /> |
||||
<msg str="" t="2" /> |
||||
|
||||
<msg str="Welcome to the" t="2" /> |
||||
<msg str="End of level!" t="3" /> |
||||
|
||||
<msg str="" t="2" /> |
||||
<msg str="[repeat all]" t="1" /> |
||||
|
||||
<pause t="14" /> |
||||
|
||||
</cycle> |
||||
|
||||
</sequence> |
||||
|
||||
</level> |
@ -0,0 +1,22 @@ |
||||
<?php |
||||
|
||||
define("SQL_HOST","localhost"); |
||||
define("SQL_DBNAME","tridni_net_main"); |
||||
define("SQL_USERNAME","tridni_net_main"); |
||||
define("SQL_PASSWORD","ondra"); |
||||
|
||||
mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD); |
||||
|
||||
mysql_set_charset("utf8"); |
||||
|
||||
mysql_select_db(SQL_DBNAME); |
||||
|
||||
mysql_query( |
||||
"SET NAMES 'utf8' COLLATE 'utf8_general_ci';". |
||||
"SET CHARACTER SET utf8;". |
||||
"SET character_set_client = utf8;". |
||||
"SET character_set_connection = utf8;". |
||||
"SET character_set_results = utf8;" |
||||
); |
||||
|
||||
?> |
@ -0,0 +1,281 @@ |
||||
<?php |
||||
|
||||
# Error codes and messages |
||||
$ERR = array( |
||||
"NO_COMMAND" => array(0, "No command received."), |
||||
"INVALID_COMMAND" => array(1, "Invalid command requested."), |
||||
"INTERNAL_ERROR" => array(2, "Internal server error."), |
||||
"INCOMPLETE_COMMAND" => array(3, "Incomplete command received"), |
||||
"REGISTRATION_FAILED" => array(4, "Registration failed."), |
||||
"LOGIN_FAILED" => array(5, "Login failed."), |
||||
"INVALID_TOKEN" => array(6, "Authentication failed."), |
||||
"FILE_NOT_FOUND" => array(7, "File does not exist."), |
||||
"BAD_FILE_FORMAT" => array(8, "Bad file format."), |
||||
"LEVEL_ALREADY_ADDED" => array(9, "Level file is already registered to the Global Leaderboard."), |
||||
"LEVEL_NAME_NOT_UNIQUE" => array(10, "Title already used by other level."), |
||||
"NO_SUCH_LEVEL" => array(11, "No such level exists."), |
||||
"HACKING_DETECTED" => array(12, "Access denied."), |
||||
); |
||||
|
||||
define("CFG_FAKE_ERROR_FOR_HACKERS",true); |
||||
|
||||
|
||||
|
||||
require_once("mysql.php"); |
||||
|
||||
require_once("class.SimpleDocument.php"); |
||||
require_once("class.XmlGen.php"); |
||||
require_once("class.DbUtil.php"); |
||||
require_once("class.Util.php"); |
||||
|
||||
|
||||
|
||||
if(isset($_REQUEST["cmd"]) && ($_REQUEST["cmd"]=="ADD_LEVEL")){}else{ //||$_REQUEST["cmd"]=="HASH" |
||||
|
||||
// Check if the request came from a genuine Sector game |
||||
$headers = apache_request_headers(); |
||||
|
||||
if( |
||||
$headers["User-Agent"] != "Sector/HttpHelper" |
||||
or !isset($headers["X-SECTOR-VERSION"]) |
||||
or isset($headers["Cookie"]) |
||||
or isset($headers["Accept-Encoding"]) |
||||
or isset($headers["Accept-Language"]) |
||||
or isset($headers["Accept-Charset"]) |
||||
or isset($headers["Accept"]) |
||||
){ |
||||
if(CFG_FAKE_ERROR_FOR_HACKERS){ |
||||
XmlGen::hacking_exit(); |
||||
}else{ |
||||
XmlGen::error_exit("HACKING_DETECTED","Unauthorized server access."); |
||||
} |
||||
} |
||||
|
||||
$_REQUEST["VERSION"] = $headers["X-SECTOR-VERSION"]+0; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!isset($_REQUEST["cmd"])){ |
||||
XmlGen::error_exit("NO_COMMAND"); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
switch($_REQUEST["cmd"]){ |
||||
|
||||
case "REGISTER": |
||||
// check if name and password exist |
||||
if(!isset($_REQUEST["name"]) || !isset($_REQUEST["password"])){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Missing 'name' or 'password'."); |
||||
} |
||||
|
||||
// trim, null -> "" |
||||
if(!isset($_REQUEST["email"])) $_REQUEST["email"] = ""; |
||||
if(!isset($_REQUEST["country"])) $_REQUEST["country"] = ""; |
||||
|
||||
$name = trim($_REQUEST["name"]); |
||||
$email = trim($_REQUEST["email"]); |
||||
$password = trim($_REQUEST["password"]); |
||||
$country = trim($_REQUEST["country"]); |
||||
|
||||
// check name and password length |
||||
if(strlen($_REQUEST["name"])==0 || strlen($_REQUEST["password"])==0){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Zero-length 'name' or 'password'."); |
||||
} |
||||
|
||||
// register and return uid+auth_token |
||||
DbUtil::registerNewUser( |
||||
$name, |
||||
$password, |
||||
$email, |
||||
$country |
||||
); |
||||
|
||||
exit(); |
||||
|
||||
|
||||
|
||||
case "EDIT_PROFILE": |
||||
// check if name and password exist |
||||
if(!isset($_REQUEST["uid"]) || !isset($_REQUEST["auth_token"])){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Missing 'uid' or 'auth_token'."); |
||||
} |
||||
|
||||
if(!DbUtil::isTokenValid($_REQUEST["uid"], $_REQUEST["auth_token"])){ |
||||
XmlGen::error_exit("INVALID_TOKEN"); |
||||
} |
||||
|
||||
// replace not set variables with nulls |
||||
if(!isset($_REQUEST["email"])) $_REQUEST["email"] = ""; |
||||
if(!isset($_REQUEST["country"])) $_REQUEST["country"] = ""; |
||||
if(!isset($_REQUEST["name"])) $_REQUEST["name"] = null; |
||||
if(!isset($_REQUEST["password"])) $_REQUEST["password"] = null; |
||||
|
||||
$uid = $_REQUEST["uid"]; |
||||
$name = Util::trimNullSafe($_REQUEST["name"]); |
||||
$email = trim($_REQUEST["email"]); |
||||
$password = Util::trimNullSafe($_REQUEST["password"]); |
||||
$country = trim($_REQUEST["country"]); |
||||
|
||||
// register and return uid+auth_token |
||||
DbUtil::modifyProfile( |
||||
$uid, |
||||
$name, |
||||
$password, |
||||
$email, |
||||
$country |
||||
); |
||||
|
||||
exit(); |
||||
|
||||
|
||||
|
||||
case "DELETE_PROFILE": |
||||
// check if name and password exist |
||||
if(!isset($_REQUEST["uid"]) || !isset($_REQUEST["auth_token"])){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Missing 'uid' or 'auth_token'."); |
||||
} |
||||
|
||||
if(!DbUtil::isTokenValid($_REQUEST["uid"], $_REQUEST["auth_token"])){ |
||||
XmlGen::error_exit("INVALID_TOKEN"); |
||||
} |
||||
|
||||
$uid = $_REQUEST["uid"]; |
||||
|
||||
// register and return uid+auth_token |
||||
DbUtil::deleteProfile( |
||||
$uid |
||||
); |
||||
|
||||
exit(); |
||||
|
||||
|
||||
case "ADD_LEVEL": |
||||
// check if name and password exist |
||||
if(!isset($_REQUEST["title"]) || !isset($_REQUEST["filename"])){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Missing 'title' or 'filename'."); |
||||
} |
||||
|
||||
$title = trim($_REQUEST["title"]); |
||||
$file = trim($_REQUEST["filename"]); |
||||
|
||||
DbUtil::addLevel( |
||||
$title, |
||||
$file |
||||
); |
||||
|
||||
exit(); |
||||
|
||||
|
||||
|
||||
case "GET_LEVELS": |
||||
DbUtil::getLevels(); |
||||
exit(); |
||||
|
||||
|
||||
|
||||
case "GET_SCORES": |
||||
if(!isset($_REQUEST["lid"])){ |
||||
XmlGen::error_exit("INCOMPLETE_COMMAND","Missing 'lid'."); |
||||
} |
||||
|
||||
DbUtil::getLevelScores($_REQUEST["lid"]); |
||||
|
||||
exit(); |
||||
|
||||
|
||||
|
||||