diff options
-rw-r--r-- | app.php | 2 | ||||
-rw-r--r-- | do.php | 4 | ||||
-rw-r--r-- | globe.php | 4 | ||||
-rw-r--r-- | includes/datas.php | 4 | ||||
-rw-r--r-- | includes/mapoftheday.php | 2 | ||||
-rw-r--r-- | includes/maps.php | 6 | ||||
-rw-r--r-- | includes/sqlEmbedded.php | 7 | ||||
-rw-r--r-- | includes/sqli.php | 10 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | pages/achievements.php | 2 | ||||
-rw-r--r-- | pages/admin.php | 2 | ||||
-rw-r--r-- | pages/challenge.php | 2 | ||||
-rw-r--r-- | pages/challengelist.php | 2 | ||||
-rw-r--r-- | pages/cp.php | 2 | ||||
-rw-r--r-- | pages/feedback.php | 2 | ||||
-rw-r--r-- | pages/gallery.php | 2 | ||||
-rw-r--r-- | pages/home.php | 2 | ||||
-rw-r--r-- | pages/leaderboard.php | 2 | ||||
-rw-r--r-- | pages/login.php | 2 | ||||
-rw-r--r-- | pages/massemail.php | 4 | ||||
-rw-r--r-- | pages/memberlist.php | 2 | ||||
-rw-r--r-- | pages/tutorial.php | 2 |
22 files changed, 34 insertions, 35 deletions
@@ -1,7 +1,7 @@ <?PHP
include "includes/maps.php";
-include "includes/db.inc.php";
+include "includes/sqlEmbedded.php";
include "includes/mapoftheday.php";
include "includes/datas.php";
@@ -2,7 +2,7 @@ session_start();
include "includes/maps.php";
-include "includes/db.inc.php";
+include "includes/sqlEmbedded.php";
include "includes/datas.php";
//FirePHP stuff - TODO: Delete
@@ -373,7 +373,7 @@ die(json_encode($json)); function isCurrentMap($mapID) {
// TODO: change methodology
- include_once('./includes/db.inc.php');
+ include_once('./includes/sqlEmbedded.php');
$sql = "SELECT maps.ID
FROM `mapOfTheDay`
LEFT JOIN `maps` ON maps.ID = `mapID`
@@ -5,7 +5,7 @@ if (!session_id()) //session_regenerate_id();
//Database login:
-//include_once 'db.inc.php';
+//include_once 'sqlEmbedded.php';
//TODO: CONFIRM THIS DOMAIN BEFORE TRANSFER
//$mydomain = "http://www.mazetd.4xg.net/";
@@ -62,7 +62,7 @@ function sql_clean($string) { function CookieLogin() {
global $accepted;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$userID = $_COOKIE['userID'];
$auth = $_COOKIE['auth'];
diff --git a/includes/datas.php b/includes/datas.php index ef978c8..690b83a 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -2,7 +2,7 @@ // For interaction with the SQL database. // -include_once('db.inc.php'); +include_once('sqlEmbedded.php'); //FirePHP stuff - TODO: Delete //require_once('includes/FirePHPCore/FirePHP.class.php'); @@ -506,7 +506,7 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) { function isChallengeMap($mapID) { - include_once('./includes/db.inc.php'); + include_once('./includes/sqlEmbedded.php'); $sql = "SELECT ID FROM `maps` WHERE diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php index a8042c7..3a472ba 100644 --- a/includes/mapoftheday.php +++ b/includes/mapoftheday.php @@ -1 +1 @@ -<?php
include_once('maps.php');
include_once('db.inc.php');
include_once('championPoints.php');
define('MAP_EXPIRE_TIME_NORMAL', 1); //Days that non-weekly maps should last. Changing this won't
//really work without changes to generateNewMapsOfTheDay()..
define('MAP_EXPIRE_TIME_WEEKLY', 2); //Days that a weekly map should last
/**
* Returns the Map Of The Day with the given type (index). Generates new maps if necessary.
*/
function mapOfTheDay($type = 1)
{
$map = getMapOfTheDayInternal($type);
if($map == null)
{
//Map doesn't exist, so we generate the maps and try again
generateNewMapsOfTheDay();
$map = getMapOfTheDayInternal($type);
}
return $map;
}
/**
* Returns the map of the day of the given type, or null if not found.
* Do not call outside of mapoftheday.php
*/
function getMapOfTheDayInternal($type)
{
if ($type <= 4)
$expire = MAP_EXPIRE_TIME_NORMAL;
else if ($type <= 8)
$expire = MAP_EXPIRE_TIME_WEEKLY;
$sql = "
SELECT maps.ID, maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapType` = $type
AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire
AND mapID = maps.ID
";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0)
{
return null;
}
//A map was found, so return it
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
/**
* Generates all the new maps for the day. Includes a critical section so maps aren't generated more
* than once per day.
*/
function generateNewMapsOfTheDay()
{
ignore_user_abort(true);
$lock = acquireMotdLock();
try
{
//Double check that there is no simple map for today. Since that was done outside of the lock, it's possible
//two threads could reach this point at the same time.
$map = getMapOfTheDayInternal(1);
if($map != null)
{
releaseMotdLock($lock);
return;
}
//The rest of the code in the try{} can be assumed to only be run once a day
//Generate the maps
generateMapAndAddToDB(1);
generateMapAndAddToDB(2);
generateMapAndAddToDB(3);
generateMapAndAddToDB(4);
//The weekly maps might not need to be generated tonight. Check if it does first
$weeklyMap = getMapOfTheDayInternal(5);
if($weeklyMap == null)
{
generateMapAndAddToDB(5);
}
//Update the player-statistics
addChampionPointsForYesterdaysMaps();
} catch (Exception $exc) { /* Ignore... :| */ }
//try/catch above is necessary to make sure an exception doesn't prevent us from releasing the lock!
releaseMotdLock($lock);
}
/**
* Generates a single map of the given type, and adds its info to the DB
*/
function generateMapAndAddToDB($type)
{
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1)
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0);
break;
case 3: //Hard
$map = getRandomComplexMap();
break;
case 4: //Full random map
$map = getRandomSpecialMap();
break;
case 5:
$map = getRandomWeeklyMap();
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on inserting map");
}
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on insert into mapOfTheDay");
}
// Track statistics for yesterday's map of this type
//TODO: Tracking of statistics can be done all at once, no need to do it for each maptype
trackMOTDstats($type);
}
/**
* The file locked in order to create serialize map-creations, since our DB doesn't support transactions...
*/
define('FILE_MOTD_LOCK', './motdLockFile');
/**
* Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads
* creating and inserting the maps into the database at the same time, which has happened
*/
function acquireMotdLock()
{
$fileHandle = fopen(FILE_MOTD_LOCK, 'a+');
flock($fileHandle, LOCK_EX);
return $fileHandle;
}
/**
* Releases the lock acquired from acquireMotdLock
*/
function releaseMotdLock($fileHandle)
{
if($fileHandle)
flock($fileHandle, LOCK_UN);
}
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function getRandomComplexMap() {
$random = weight(0, 0, 0, 0, 0, 0, 0, 1);
switch ($random) {
case 0:
$map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2));
break;
case 1:
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath = insertPoint($reversePath, 'abc');
$reversePath = insertPoint($reversePath, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 7;
$myparams['walls'] = 12;
$myparams['name'] = 'Reverse Order';
$map = GenerateShapedMap($reversePath, $myparams);
break;
}
return $map;
}
function getRandomSpecialMap() {
//This can be used to add additional weight to certain maps that we like.
$random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$shape = array();
$params = array();
switch ($random) {
//=====================================
case 0:
//Thirty
$map = GenerateMap(
18, 14, 20, //width, height, rocks
weight(30), //Walls
weight(1), //Checkpoints
weight(1), //Teleports
'Thirty'
);
break;
//=====================================
case 1:
//Simple
$map = GenerateMap(
18, 9, 7, //width, height, rocks
weight(15, 16, 17), //Walls
weight(0), //Checkpoints
weight(0), //Teleports
'Finite'
);
break;
//=====================================
case 2:
//ABC's
$map = GenerateMap(
19, 11, 12, //width, height, rocks
weight(20, 21, 22, 22, 23), //Walls
weight(3), //Checkpoints
weight(0), //Teleports
"ABC's "
);
break;
//=====================================
case 3:
//Tele Madness
$map = GenerateMap(
17, 12, 10, //width, height, rocks
weight(17, 18), //Walls
weight(1), //Checkpoints
weight(5), //Teleports
'Teleport Madness'
);
break;
//=====================================
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5, //width, height, rocks
weight(16, 17, 18), //Walls
weight(1, 2, 2, 2, 3, 3), //Checkpoints
weight(0), //Teleports
'Rocky Maze'
);
break;
//=====================================
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12, //width, height, rocks
weight(17, 18, 19), //Walls
weight(2, 2, 2, 3, 3), //Checkpoints
weight(3, 3, 3, 4), //Teleports
'Side to Side'
);
break;
//=====================================
case 6:
//Ultimate's Random map:
//Create shape
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
//Insert points
$shape = insertPoint($shape, "sfabcr", $target = '?');
$shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?');
//Set params
$params['rockchance'] = 10;
$params['walls'] = weight(21, 20, 22, 20, 21);
$params['name'] = 'Ultimate Random';
//Put it all together.
$map = GenerateShapedMap($shape, $params);
break;
//=====================================
//=====================================
case 7:
//Dual map
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapa = insertPoint($dualmapa, 'abc');
$dualmapb = insertPoint($dualmapb, 'abc');
$dualmap = array_merge($dualmapa, $dualmapb);
$dualmap = insertPoint($dualmap, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = weight(20, 20, 21, 21, 22, 23);
$myparams['name'] = 'Seeing Double';
$map = GenerateShapedMap($dualmap, $myparams);
break;
//=====================================
//=====================================
case 8:
//Centralized
$myshape[] = "ooooooooooooooooooo";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o???????fos???????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "ooooooooooooooooooo";
$myshape = insertPoint($myshape, "abc", $target = '?');
$myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?');
$myparams['rockchance'] = 7;
$myparams['walls'] = weight(17, 18, 19, 18, 17);
$myparams['name'] = 'Centralized';
$map = GenerateShapedMap($myshape, $myparams);
break;
//=====================================
//=====================================
case 9:
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'Xo??????????????ox';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths = insertPoint($dualingPaths, 'abc');
$dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 9;
$myparams['walls'] = 13;
$myparams['name'] = 'Dualing paths';
$map = GenerateShapedMap($dualingPaths, $myparams);
break;
//=====================================
//=====================================
case 10:
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited = insertPoint($unlimited, 'abc');
$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = 999;
$myparams['name'] = 'Unlimited';
$map = GenerateShapedMap($unlimited, $myparams);
break;
//=====================================
}
return $map;
}
function getRandomWeeklyMap() {
// TEST MAP...
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex = insertPoint($ultraComplex, 'abcde');
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, 'tumnghij');
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 3;
$myparams['rockchance'] = 12;
$myparams['walls'] = 50;
$myparams['name'] = 'Ultra Complex';
$map = GenerateShapedMap($ultraComplex, $myparams);
return $map;
}
?>
\ No newline at end of file +<?php
include_once('maps.php');
include_once('sqlEmbedded.php');
include_once('championPoints.php');
define('MAP_EXPIRE_TIME_NORMAL', 1); //Days that non-weekly maps should last. Changing this won't
//really work without changes to generateNewMapsOfTheDay()..
define('MAP_EXPIRE_TIME_WEEKLY', 2); //Days that a weekly map should last
/**
* Returns the Map Of The Day with the given type (index). Generates new maps if necessary.
*/
function mapOfTheDay($type = 1)
{
$map = getMapOfTheDayInternal($type);
if($map == null)
{
//Map doesn't exist, so we generate the maps and try again
generateNewMapsOfTheDay();
$map = getMapOfTheDayInternal($type);
}
return $map;
}
/**
* Returns the map of the day of the given type, or null if not found.
* Do not call outside of mapoftheday.php
*/
function getMapOfTheDayInternal($type)
{
if ($type <= 4)
$expire = MAP_EXPIRE_TIME_NORMAL;
else if ($type <= 8)
$expire = MAP_EXPIRE_TIME_WEEKLY;
$sql = "
SELECT maps.ID, maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapType` = $type
AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire
AND mapID = maps.ID
";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0)
{
return null;
}
//A map was found, so return it
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
/**
* Generates all the new maps for the day. Includes a critical section so maps aren't generated more
* than once per day.
*/
function generateNewMapsOfTheDay()
{
ignore_user_abort(true);
$lock = acquireMotdLock();
try
{
//Double check that there is no simple map for today. Since that was done outside of the lock, it's possible
//two threads could reach this point at the same time.
$map = getMapOfTheDayInternal(1);
if($map != null)
{
releaseMotdLock($lock);
return;
}
//The rest of the code in the try{} can be assumed to only be run once a day
//Generate the maps
generateMapAndAddToDB(1);
generateMapAndAddToDB(2);
generateMapAndAddToDB(3);
generateMapAndAddToDB(4);
//The weekly maps might not need to be generated tonight. Check if it does first
$weeklyMap = getMapOfTheDayInternal(5);
if($weeklyMap == null)
{
generateMapAndAddToDB(5);
}
//Update the player-statistics
addChampionPointsForYesterdaysMaps();
} catch (Exception $exc) { /* Ignore... :| */ }
//try/catch above is necessary to make sure an exception doesn't prevent us from releasing the lock!
releaseMotdLock($lock);
}
/**
* Generates a single map of the given type, and adds its info to the DB
*/
function generateMapAndAddToDB($type)
{
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1)
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0);
break;
case 3: //Hard
$map = getRandomComplexMap();
break;
case 4: //Full random map
$map = getRandomSpecialMap();
break;
case 5:
$map = getRandomWeeklyMap();
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on inserting map");
}
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on insert into mapOfTheDay");
}
// Track statistics for yesterday's map of this type
//TODO: Tracking of statistics can be done all at once, no need to do it for each maptype
trackMOTDstats($type);
}
/**
* The file locked in order to create serialize map-creations, since our DB doesn't support transactions...
*/
define('FILE_MOTD_LOCK', './motdLockFile');
/**
* Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads
* creating and inserting the maps into the database at the same time, which has happened
*/
function acquireMotdLock()
{
$fileHandle = fopen(FILE_MOTD_LOCK, 'a+');
flock($fileHandle, LOCK_EX);
return $fileHandle;
}
/**
* Releases the lock acquired from acquireMotdLock
*/
function releaseMotdLock($fileHandle)
{
if($fileHandle)
flock($fileHandle, LOCK_UN);
}
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function getRandomComplexMap() {
$random = weight(0, 0, 0, 0, 0, 0, 0, 1);
switch ($random) {
case 0:
$map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2));
break;
case 1:
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath = insertPoint($reversePath, 'abc');
$reversePath = insertPoint($reversePath, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 7;
$myparams['walls'] = 12;
$myparams['name'] = 'Reverse Order';
$map = GenerateShapedMap($reversePath, $myparams);
break;
}
return $map;
}
function getRandomSpecialMap() {
//This can be used to add additional weight to certain maps that we like.
$random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$shape = array();
$params = array();
switch ($random) {
//=====================================
case 0:
//Thirty
$map = GenerateMap(
18, 14, 20, //width, height, rocks
weight(30), //Walls
weight(1), //Checkpoints
weight(1), //Teleports
'Thirty'
);
break;
//=====================================
case 1:
//Simple
$map = GenerateMap(
18, 9, 7, //width, height, rocks
weight(15, 16, 17), //Walls
weight(0), //Checkpoints
weight(0), //Teleports
'Finite'
);
break;
//=====================================
case 2:
//ABC's
$map = GenerateMap(
19, 11, 12, //width, height, rocks
weight(20, 21, 22, 22, 23), //Walls
weight(3), //Checkpoints
weight(0), //Teleports
"ABC's "
);
break;
//=====================================
case 3:
//Tele Madness
$map = GenerateMap(
17, 12, 10, //width, height, rocks
weight(17, 18), //Walls
weight(1), //Checkpoints
weight(5), //Teleports
'Teleport Madness'
);
break;
//=====================================
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5, //width, height, rocks
weight(16, 17, 18), //Walls
weight(1, 2, 2, 2, 3, 3), //Checkpoints
weight(0), //Teleports
'Rocky Maze'
);
break;
//=====================================
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12, //width, height, rocks
weight(17, 18, 19), //Walls
weight(2, 2, 2, 3, 3), //Checkpoints
weight(3, 3, 3, 4), //Teleports
'Side to Side'
);
break;
//=====================================
case 6:
//Ultimate's Random map:
//Create shape
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
//Insert points
$shape = insertPoint($shape, "sfabcr", $target = '?');
$shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?');
//Set params
$params['rockchance'] = 10;
$params['walls'] = weight(21, 20, 22, 20, 21);
$params['name'] = 'Ultimate Random';
//Put it all together.
$map = GenerateShapedMap($shape, $params);
break;
//=====================================
//=====================================
case 7:
//Dual map
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapa = insertPoint($dualmapa, 'abc');
$dualmapb = insertPoint($dualmapb, 'abc');
$dualmap = array_merge($dualmapa, $dualmapb);
$dualmap = insertPoint($dualmap, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = weight(20, 20, 21, 21, 22, 23);
$myparams['name'] = 'Seeing Double';
$map = GenerateShapedMap($dualmap, $myparams);
break;
//=====================================
//=====================================
case 8:
//Centralized
$myshape[] = "ooooooooooooooooooo";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o???????fos???????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "ooooooooooooooooooo";
$myshape = insertPoint($myshape, "abc", $target = '?');
$myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?');
$myparams['rockchance'] = 7;
$myparams['walls'] = weight(17, 18, 19, 18, 17);
$myparams['name'] = 'Centralized';
$map = GenerateShapedMap($myshape, $myparams);
break;
//=====================================
//=====================================
case 9:
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'Xo??????????????ox';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths = insertPoint($dualingPaths, 'abc');
$dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 9;
$myparams['walls'] = 13;
$myparams['name'] = 'Dualing paths';
$map = GenerateShapedMap($dualingPaths, $myparams);
break;
//=====================================
//=====================================
case 10:
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited = insertPoint($unlimited, 'abc');
$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = 999;
$myparams['name'] = 'Unlimited';
$map = GenerateShapedMap($unlimited, $myparams);
break;
//=====================================
}
return $map;
}
function getRandomWeeklyMap() {
// TEST MAP...
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex = insertPoint($ultraComplex, 'abcde');
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, 'tumnghij');
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 3;
$myparams['rockchance'] = 12;
$myparams['walls'] = 50;
$myparams['name'] = 'Ultra Complex';
$map = GenerateShapedMap($ultraComplex, $myparams);
return $map;
}
?>
\ No newline at end of file diff --git a/includes/maps.php b/includes/maps.php index 6a831c8..03bcd81 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -769,7 +769,7 @@ function formSolution($solution) { //Returns the best solution.
function getSolution($userID, $mapID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `solution`, `moves`
FROM `solutions`
WHERE `userID` = '$userID' AND
@@ -782,7 +782,7 @@ function getSolution($userID, $mapID) { }
function getChallengeSolution($userID, $challengeID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `solution`, `moves`
FROM `challengeSolutions`
WHERE `userID` = '$userID' AND
@@ -795,7 +795,7 @@ function getChallengeSolution($userID, $challengeID) { }
function getMapCode($mapID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `code`
FROM `maps`
WHERE `ID` = '$mapID'
diff --git a/includes/sqlEmbedded.php b/includes/sqlEmbedded.php new file mode 100644 index 0000000..b7a32b5 --- /dev/null +++ b/includes/sqlEmbedded.php @@ -0,0 +1,7 @@ +<?php +include_once('db.inc.php'); + +global $mysqlid; +$mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database."); +@mysql_select_db($db_name, $mysqlid) or die("Invalid database."); +?> diff --git a/includes/sqli.php b/includes/sqli.php index 0974380..d19069b 100644 --- a/includes/sqli.php +++ b/includes/sqli.php @@ -1,12 +1,4 @@ <?php
-
-//global $mysqlid;
-$db_host = "db2894.perfora.net";
-$db_user = "dbo362854667";
-$db_name = "db362854667";
-$db_pass = "mazes4me";
-// $mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database.");
-// @mysql_select_db($db_name, $mysqlid) or die("Invalid database.");
-
+include_once('db.inc.php');
$mysqli = mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die("Failed to connect to database");
?>
\ No newline at end of file @@ -27,7 +27,7 @@ if (isset($_SESSION['accepted']) AND $_SESSION['accepted'] == 1) //TODO: We could store this data in the session
if ($accepted) {
$userID = $_SESSION['userID'];
- include_once ('./includes/db.inc.php');
+ include_once ('./includes/sqlEmbedded.php');
$sql = "
SELECT
userData.wallColor,
diff --git a/pages/achievements.php b/pages/achievements.php index ac7aded..1bb2195 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -7,7 +7,7 @@ htmlHeader(array('profile'), 'Pathery Achievements'); <?php
topbar($Links);
-include_once('./includes/db.inc.php');
+include_once('./includes/sqlEmbedded.php');
include_once('./includes/datas.php');
//Get UserID
diff --git a/pages/admin.php b/pages/admin.php index afac6c4..afc6418 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -9,7 +9,7 @@ topbar($Links); include_once('./includes/datas.php');
include_once('./includes/maps.php');
include_once('./includes/mapoftheday.php');
-include_once('./includes/db.inc.php');
+include_once('./includes/sqlEmbedded.php');
include_once('./includes/championPoints.php');
if ($_GET['applyall'] == 'true') {
diff --git a/pages/challenge.php b/pages/challenge.php index 8d312d1..35c9525 100644 --- a/pages/challenge.php +++ b/pages/challenge.php @@ -6,7 +6,7 @@ htmlHeader( include_once ('./includes/maps.php');
include_once ('./includes/mapoftheday.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
//Get custom wall colors;
diff --git a/pages/challengelist.php b/pages/challengelist.php index a6a4ade..ca9fe46 100644 --- a/pages/challengelist.php +++ b/pages/challengelist.php @@ -6,7 +6,7 @@ htmlHeader( include_once ('./includes/maps.php'); include_once ('./includes/mapoftheday.php'); -include_once ('./includes/db.inc.php'); +include_once ('./includes/sqlEmbedded.php'); include_once ('./includes/datas.php'); include_once ('./includes/mapclass.php'); diff --git a/pages/cp.php b/pages/cp.php index 06ec0e8..a807200 100644 --- a/pages/cp.php +++ b/pages/cp.php @@ -9,7 +9,7 @@ htmlHeader(); topbar($Links);
include('./includes/maps.php');
-include_once('./includes/db.inc.php');
+include_once('./includes/sqlEmbedded.php');
function validatename($name) {
if (strlen($name) < 1)
diff --git a/pages/feedback.php b/pages/feedback.php index 33c3e1d..e971f12 100644 --- a/pages/feedback.php +++ b/pages/feedback.php @@ -10,7 +10,7 @@ if (isset($_POST['regarding']) AND isset($_SESSION['accepted'])) { if (!is_int($userID))
return;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$sql = "SELECT `email` FROM `users`
WHERE `ID` = '$userID'";
$result = mysql_query($sql);
diff --git a/pages/gallery.php b/pages/gallery.php index f8e1b9d..525c73a 100644 --- a/pages/gallery.php +++ b/pages/gallery.php @@ -1,7 +1,7 @@ <?PHP htmlHeader(array(), '', '', array('scores')); -include_once ('./includes/db.inc.php'); +include_once ('./includes/sqlEmbedded.php'); if ($accepted) { $userID = $_SESSION['userID']; diff --git a/pages/home.php b/pages/home.php index 37a94c3..d5ba45f 100644 --- a/pages/home.php +++ b/pages/home.php @@ -2,7 +2,7 @@ include_once ('./includes/maps.php');
include_once ('./includes/mapoftheday.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
htmlHeader(
diff --git a/pages/leaderboard.php b/pages/leaderboard.php index 9f40d8b..292de60 100644 --- a/pages/leaderboard.php +++ b/pages/leaderboard.php @@ -11,7 +11,7 @@ include('./includes/maps.php'); //include('./includes/mapoftheday.php');
include('./includes/datas.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
function day_diff($date1, $date2) {
$current = $date1;
diff --git a/pages/login.php b/pages/login.php index 92b71fd..9358d89 100644 --- a/pages/login.php +++ b/pages/login.php @@ -48,7 +48,7 @@ try { $claimedid = $openid->__get('identity');
//I know just where to put this stuff!
- require './includes/db.inc.php';
+ require './includes/sqlEmbedded.php';
//Unless I already have this information...
//* Modify this to WHERE `email`
//$sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName` FROM `users` WHERE `email` = '$email'";
diff --git a/pages/massemail.php b/pages/massemail.php index a861500..d45588b 100644 --- a/pages/massemail.php +++ b/pages/massemail.php @@ -6,7 +6,7 @@ htmlHeader(); topbar($Links);
include('./includes/datas.php');
-include('./includes/db.inc.php');
+include('./includes/sqlEmbedded.php');
if (isset($_POST['massemail']) AND isset($_SESSION['accepted'])) {
@@ -22,7 +22,7 @@ if (isset($_POST['massemail']) AND isset($_SESSION['accepted'])) { if (!is_int($userID))
return;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$sql = "SELECT `email` FROM `users`
WHERE `ID` = '$userID'";
$result = mysql_query($sql);
diff --git a/pages/memberlist.php b/pages/memberlist.php index 22d88b4..3baf456 100644 --- a/pages/memberlist.php +++ b/pages/memberlist.php @@ -13,7 +13,7 @@ htmlHeader( topbar($Links);
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
diff --git a/pages/tutorial.php b/pages/tutorial.php index 4d2446f..5208a57 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -13,7 +13,7 @@ topbar($Links); //TODO: Turn this into a function?
if ($accepted) {
- include_once ('./includes/db.inc.php');
+ include_once ('./includes/sqlEmbedded.php');
$userID = $_SESSION['userID'];
$sql = "
|