Added full source code

This commit is contained in:
Emmanuel BENOîT 2016-01-10 11:01:49 +01:00
commit 33f8586698
1377 changed files with 123808 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<?php
class page_handler {
public function handle($input) {
$this->output = "about";
}
}
?>

View file

@ -0,0 +1,158 @@
<?php
class page_handler {
var $needsAuth = true;
var $ajax = array();
private function getCount() {
list($total) = dbFetchArray($this->db->query('SELECT COUNT(*) FROM b6_planet_pics'));
list($rated) = dbFetchArray($this->db->query("SELECT COUNT(*) FROM b6_planet_votes WHERE account = {$_SESSION['userid']}"));
$this->data['total'] = $total;
$this->data['rated'] = $rated;
}
private function getRandomUnrated() {
$user = $_SESSION['userid'];
$q = $this->db->query(
"SELECT * FROM b6_planet_pics WHERE id NOT IN (SELECT picture FROM b6_planet_votes WHERE account = $user) ORDER BY RANDOM()"
);
if (! dbCount($q)) {
return 0;
}
$data = dbFetchHash($q);
return $data;
}
private function storeRating($id, $rating) {
if ($rating < 1 || $rating > 5) {
return;
}
$q = $this->db->query("SELECT id FROM b6_planet_pics WHERE id = $id");
if (! dbCount($q)) {
return;
}
$user = $_SESSION['userid'];
$q = $this->db->query("SELECT account FROM b6_planet_votes WHERE picture = $id AND account = $user");
if (dbCount($q)) {
return;
}
$this->db->query("INSERT INTO b6_planet_votes (account, picture, vote) VALUES ($user, $id, $rating)");
$this->db->query("UPDATE credits SET credits_obtained = credits_obtained + 120 WHERE account = $user");
}
private function doRatings() {
$pd = $this->getRandomUnrated();
if (! $pd) {
$this->data = array(
'page' => 'nu'
);
} else {
$this->data = array(
'page' => 'vp',
'pic' => $pd,
'cr' => null,
'ar' => null,
'nv' => null
);
}
}
private function getPlanet($id) {
$q = $this->db->query("SELECT * FROM b6_planet_pics WHERE id = $id");
if (! dbCount($q)) {
$this->doRatings();
return;
}
$pd = dbFetchHash($q);
$user = $_SESSION['userid'];
$q = $this->db->query("SELECT vote FROM b6_planet_votes WHERE picture = $id AND account = $user");
if (! dbCount($q)) {
$this->data = array(
'page' => 'vp',
'pic' => $pd,
'cr' => null,
'ar' => null,
'nv' => null
);
return;
}
list($cr) = dbFetchArray($q);
$q = $this->db->query("SELECT AVG(vote), COUNT(*) FROM b6_planet_votes WHERE picture = $id");
list($ar, $nv) = dbFetchArray($q);
$this->data = array(
'page' => 'vp',
'pic' => $pd,
'cr' => $cr,
'ar' => sprintf("%.2f", $ar),
'nv' => $nv
);
}
private function topRatings() {
$q = $this->db->query("SELECT COUNT(*) AS votes FROM b6_planet_votes GROUP BY picture");
if (!dbCount($q)) {
$this->data = array(
'page' => 'nt'
);
return;
}
$sum = 0;
while ($r = dbFetchArray($q)) {
$sum += $r[0];
}
$sum /= dbCount($q);
$q = $this->db->query("SELECT picture, AVG(vote) AS rating, COUNT(*) AS votes FROM b6_planet_votes "
. "GROUP BY picture ORDER BY rating DESC, votes DESC, picture");
if (!dbCount($q)) {
$this->data = array(
'page' => 'nt'
);
} else {
$this->data = array(
'page' => 'tt',
'pics' => array()
);
while ($r = dbFetchHash($q)) {
if ($r['votes'] >= $sum) {
array_push($this->data['pics'], $r);
}
if (count($this->data['pics']) >= 50) {
break;
}
}
}
}
public function handle($input) {
$this->db = $this->game->getDBAccess();
$this->output = 'b6pp';
$command = $input['c'];
if ($command == 'v') {
$id = (int) $input['id'];
$this->getPlanet($id);
} elseif ($command == 'r') {
$id = (int) $input['id'];
$r = (int) $input['r'];
$this->storeRating($id, $r);
$this->doRatings();
} elseif ($command == 't') {
$this->topRatings();
} else {
$this->doRatings();
}
$this->getCount();
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = true;
var $ajax = array();
function handle($input) {
$this->output = "confirm";
}
}
?>

View file

@ -0,0 +1,17 @@
<?php
class page_handler {
var $needsAuth = true;
var $ajax = array();
private function getCredits() {
return dbFetchHash($this->game->getDBAccess()->query("SELECT resources_used, credits_obtained FROM credits WHERE account = {$_SESSION['userid']}"));
}
public function handle($input) {
$this->output = "contrib";
$this->data = $this->getCredits();
}
}
?>

View file

@ -0,0 +1,128 @@
<?php
class page_handler {
function checkUsername($n) {
$this->data['username'] = $n;
if (strlen($n) > 15) {
return 1;
}
if (preg_match('/[^A-Za-z0-9_\.\-\+@\/'."'".' ]/', $n)) {
return 2;
}
if (trim($n) != $n) {
return 3;
}
if (preg_match('/\s\s+/', $n)) {
return 4;
}
if (strlen($n) < 2) {
return 5;
}
if (!preg_match('/[A-Za-z]/', $n)) {
return 6;
}
$q = dbQuery("SELECT id FROM account WHERE LOWER(name)='" . addslashes(strtolower($n)) . "'");
if (dbCount($q)) {
return 7;
}
return 0;
}
function checkMailAddr($a) {
return preg_match(
'/^[A-Za-z0-9_\.\-\+]+@([A-Za-z0-9_\.\-\+]+)+\.[A-Za-z]{2,6}/',
$a
);
}
function checkMail($a1, $a2) {
$this->data['mail'] = $a1;
if ($a1 != $a2)
return 1;
if (!$this->checkMailAddr($a1))
return 2;
$this->data['mail2'] = $a1;
$q = dbQuery("SELECT id,status FROM account WHERE LOWER(email) = LOWER('$a1')");
if (!dbCount($q)) {
return 0;
}
list($id,$status) = dbFetchArray($q);
if ($status == 'KICKED') {
dbQuery("INSERT INTO banned_attempt (ip_addr) VALUES ('{$_SERVER['REMOTE_ADDR']}')");
tracking::$data['bat'] = true;
tracking::$data['uid'] = $id;
return -1;
} else {
return 3;
}
return 0;
}
function checkPassword($np, $cp) {
if ($np != $cp)
return 1;
elseif (strlen($np) < 4)
return 2;
elseif (strlen($np) > 64)
return 3;
elseif (strtolower($np) == strtolower($this->data['username']))
return 4;
return 0;
}
function checkLanguage($l) {
$pLang = array('en');
if (!in_array($l, $pLang)) {
$l = 'en';
}
$this->data['lang'] = $l;
tracking::$data['language'] = $l;
}
private function checkPlanetName($name) {
$game = config::getDefaultGame();
$this->data['planetname'] = $name;
return $game->getLib()->call('checkPlanetName', $name);
}
function checkData($in) {
$this->data = array();
$this->data['err1'] = $this->checkUsername($in['username']);
$this->data['err2'] = $this->checkMail($in['email'], $in['email2']);
$this->data['err3'] = $this->checkPassword($in['password'], $in['password2']);
$this->data['err4'] = $this->checkPlanetName($in['planet']);
$this->checkLanguage($in['lang']);
return (!($this->data['err1']||$this->data['err2']||$this->data['err3']||$this->data['err4']));
}
function handle($input) {
if ($_SESSION['authok']) {
$this->output = "index";
} elseif (!tracking::$data['readDisclaimer']) {
tracking::$data['readDisclaimer'] = true;
$this->output = "disclaimer";
$this->data = true;
} elseif (tracking::$data['bat']) {
$this->output = "kicked";
} elseif ($input['create'] == "") {
$this->output = "create";
$this->data = array();
} elseif (!$this->checkData($input)) {
if (tracking::$data['bat']) {
$this->output = "kicked";
} else {
$this->output = "create";
}
} else {
$vLib = $this->game->getLib('main/account');
$this->data['success'] = $vLib->call('createAccount', $this->data['username'],
$input['password'], strtolower($this->data['mail']), $this->data['lang'],
$this->data['planetname']);
$this->output = "created";
}
}
}
?>

View file

@ -0,0 +1,11 @@
<?php
class page_handler {
public function handle($input) {
$this->output = "credits";
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$this->output = "index";
}
}
?>

View file

@ -0,0 +1,13 @@
<?php
class page_handler {
function handle($input) {
tracking::$data['readDisclaimer'] = true;
$this->output = "disclaimer";
$this->data = false;
}
}
?>

View file

@ -0,0 +1,26 @@
<?php
class page_handler {
var $needsAuth = true;
var $ajax = array();
function handle($input) {
$this->lib = $this->game->getLib("main/paypal");
$this->data = array();
if ($input['doit'] == 1) {
$this->data['pid'] = $this->lib->call('newTicket', $_SESSION['userid']);
logText("PAYPAL: generated ticket {$this->data['pid']} for account #{$_SESSION['userid']}", LOG_INFO);
$this->data['doit'] = true;
} else {
$this->data['selfContrib'] = $this->lib->call('getUserContributions', $_SESSION['userid']);
$this->data['hist'] = $this->lib->call('getUserHistory', $_SESSION['userid']);
$this->data['totalContrib'] = $this->lib->call('getTotalContributions');
$this->data['totalMonth'] = $this->lib->call('getMonthContributions');
}
$this->output = "donate";
}
}
?>

View file

@ -0,0 +1,242 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
var $engines = array('page', 'css', 'js', 'xml');
function accountPage(&$input) {
foreach (config::getGames() as $game) {
if ($game->name == 'main') {
continue;
}
$status = $game->status();
if ($status == 'FINISHED') {
continue;
}
$lib = $game->getLib();
$pid = $lib->call('doesUserPlay', $_SESSION['userid']);
if (!is_null($pid)) {
$a2[$game->name] = $lib->call('getPlayerStatus', $pid);
array_unshift($a2[$game->name], $game->text);
array_push($a2[$game->name], $status);
if ($status == 'ENDING') {
array_push($a2[$game->name], $game->lastTick());
} elseif ($status == 'READY') {
array_push($a2[$game->name], $game->firstTick());
}
} elseif ($status != 'PRE') {
$a1[$game->name] = array(
$game->text, $lib->call('getPlayerCount'),
$status,
$status != 'VICTORY' && $lib->call('canJoin')
);
if ($status == 'ENDING') {
array_push($a1[$game->name], $game->lastTick());
} elseif ($status == 'READY') {
array_push($a1[$game->name], $game->firstTick());
}
}
}
if ($input['sw'] != "") {
$_SESSION['show_unregistered'] = !$_SESSION['show_unregistered'];
}
// Get the quit timestamp
$quit = $this->aLib->call('getQuitCountdown', $_SESSION['userid']);
// Get data regarding vacation mode
if (is_null($quit)) {
$vacation = $this->vLib->call('getStatus', $_SESSION['userid']);
if (is_null($vacation)) {
$vacation = array(
"status" => 'VAC',
"vac_start" => null,
"vac_credits" => 1
);
}
$vacation['can_set'] = ($vacation['status'] != 'VAC') && is_null($vacation['vac_start'])
&& $this->vLib->call('canSet', $_SESSION['userid']);
} else {
$vacation = null;
}
$this->data = array(
"other" => $a1,
"play" => $a2,
"vac" => $vacation,
"quit" => $quit,
"leech" => $this->aLib->call('isLeech', $_SESSION['userid'])
);
$this->output = "account";
}
function exitVacation(&$input) {
if ($this->vLib->call('isOnVacation', $_SESSION['userid'])) {
$this->output = "vac_leave";
} else {
$this->accountPage($input);
}
}
function actualExitVacation(&$input) {
if (!$input['cancel'] && $this->vLib->call('isOnVacation', $_SESSION['userid'])) {
$this->vLib->call('leave', $_SESSION['userid']);
}
$this->accountPage($input);
}
function startVacation(&$input) {
if ($this->vLib->call('canSet', $_SESSION['userid'])) {
$this->output = "vac_start";
} else {
$this->accountPage($input);
}
}
function actualStartVacation(&$input) {
if (!$input['cancel'] && $this->vLib->call('canSet', $_SESSION['userid'])) {
$this->vLib->call('setStart', $_SESSION['userid']);
}
$this->accountPage($input);
}
function cancelStart(&$input) {
$vacation = $this->vLib->call('getStatus', $_SESSION['userid']);
if (is_null($vacation['vac_start'])) {
$this->accountPage($input);
} else {
$this->output = "vac_cancel";
}
}
function actualCancelStart(&$input) {
if (!$input['cancel']) {
$vacation = $this->vLib->call('getStatus', $_SESSION['userid']);
if (!is_null($vacation['vac_start'])) {
$this->vLib->call('resetStart', $_SESSION['userid']);
}
}
$this->accountPage($input);
}
function closeAccount($input) {
$quit = $this->aLib->call('getQuitCountdown', $_SESSION['userid']);
if (!is_null($quit)) {
$this->accountPage($input);
} else {
$this->data = array();
$this->output = "quit_confirm";
}
}
function actualCloseAccount($input) {
// FIXME: SQL query in handler
$q = dbQuery("SELECT password FROM account WHERE id={$_SESSION['userid']} AND quit_ts IS NULL");
if ($input['cancel'] || !($q && dbCount($q) == 1)) {
$this->accountPage($input);
} else {
list($rPass) = dbFetchArray($q);
$this->data = array(
"ePass" => ($input['q_pass'] != $rPass),
);
if ($this->data['ePass']) {
$this->data['reason'] = $input['q_reason'];
$this->output = "quit_confirm";
logText("main/confirm_quit: Account {$_SESSION['userid']} provided wrong password", LOG_WARNING);
} else {
$this->aLib->call('setQuitCountdown', $_SESSION['userid'], $input['q_reason']);
$this->accountPage($input);
}
}
}
function cancelClose($input) {
$quit = $this->aLib->call('getQuitCountdown', $_SESSION['userid']);
if (is_null($quit)) {
$this->accountPage($input);
} else {
$this->data = array();
$this->output = "back_confirm";
}
}
function actualCancelClose($input) {
$quit = $this->aLib->call('getQuitCountdown', $_SESSION['userid']);
if (!$input['cancel'] && !is_null($quit)) {
$this->aLib->call('cancelQuitCountdown', $_SESSION['userid']);
}
$this->accountPage($input);
}
function loggedIn(&$input) {
$this->main = $this->game->getLib();
$this->vLib = $this->game->getLib("main/vacation");
$this->aLib = $this->game->getLib("main/account");
if ($input['evm'] == 1) {
$this->exitVacation($input);
} else if ($input['evmc'] == 1) {
$this->actualExitVacation($input);
} else if ($input['svm'] == 1) {
$this->startVacation($input);
} else if ($input['svmc'] == 1) {
$this->actualStartVacation($input);
} else if ($input['cvms'] == 1) {
$this->cancelStart($input);
} else if ($input['cvmsc'] == 1) {
$this->actualCancelStart($input);
} else if ($input['rq'] == 1) {
$this->closeAccount($input);
} else if ($input['rqc'] == 1) {
$this->actualCloseAccount($input);
} else if ($input['crq'] == 1) {
$this->cancelClose($input);
} else if ($input['crqc'] == 1) {
$this->actualCancelClose($input);
} else {
$this->accountPage($input);
}
}
function xml($input) {
if (!$_SESSION['authok']) {
return null;
}
$data = new data_node('Games');
foreach (config::getGames() as $game) {
if ($game->name == 'main') {
continue;
}
$lib = $game->getLib();
$pid = $lib->call('doesUserPlay', $_SESSION['userid']);
if (!is_null($pid)) {
$node = new data_leaf('Game', utf8_encode($game->text));
$node->setAttribute('version', $game->version->id);
$node->setAttribute('path', $game->name);
$data->addContents($node);
}
}
return $data;
}
function handle($input) {
if ($_SESSION['authok']) {
$this->loggedIn($input);
} else {
$this->output = "index";
}
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$this->output = "index";
}
}
?>

View file

@ -0,0 +1,172 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function makeLinksList() {
$categories = $this->lib->call('getCategories');
for ($i=0;$i<count($categories);$i++) {
$categories[$i]['links'] = $this->lib->call('getLinks', $categories[$i]['id']);
}
$this->data = array(
"mode" => 0,
"data" => $categories
);
}
function handleBrokenReport($account, $link, $confirm) {
// Get existing reports
$reports = $this->lib->call('getBrokenReports');
$myReports = array();
foreach ($reports as $r) {
if ($r['reported_by'] == $account) {
array_push($myReports, $r['link']);
}
}
if (is_null($link) || $link == "") {
// No link reported yet, get the list
$links = array();
$categories = $this->lib->call('getCategories');
foreach ($categories as $cat) {
$clinks = $this->lib->call('getLinks', $cat['id']);
foreach ($clinks as $lnk) {
if (in_array($lnk['id'], $myReports)) {
continue;
}
$links[$lnk['id']] = utf8entities($cat['title'] . " -> " . $lnk['title']);
}
}
$this->data = array(
"mode" => 1,
"data" => $links
);
} elseif ($confirm == '') {
// A link has been reported, but the report hasn't been confirmed yet
$lk = $this->lib->call('getLink', (int)$link);
if (is_null($lk) || in_array((int)$link, $myReports)) {
return;
}
$cat = $this->lib->call('getCategory', $lk['category']);
$lk['long_title'] = utf8entities($cat['title'] . " -> " . $lk['title']);
$this->data = array(
"mode" => 2,
"data" => $lk
);
} else {
// A link has been reported and the user confirmed
$lk = $this->lib->call('getLink', (int)$link);
if (is_null($lk) || in_array((int)$link, $myReports)) {
return;
}
$cat = $this->lib->call('getCategory', $lk['category']);
$lk['long_title'] = utf8entities($cat['title'] . " -> " . $lk['title']);
$this->lib->call('reportBroken', (int)$link, $account);
$this->data = array(
"mode" => 3,
"data" => $lk
);
}
}
function handleSubmission(&$input) {
$sl = (int)$input['sl'];
if ($sl == 1) {
// Initialise the form
$this->data = array(
"mode" => 4,
"data" => array(
"url" => "http://",
"title" => "",
"desc" => "",
"err" => 0
)
);
} elseif ($sl == 2) {
// Check submitted data
$title = preg_replace('/\s+/', ' ', trim($input['title']));
$desc = preg_replace('/\s+/', ' ', trim($input['desc']));
$url = trim($input['url']);
// Check title
if (strlen($title) < 5) {
$error = 1;
} elseif (strlen($title) > 64) {
$error = 2;
// Check description
} elseif ($desc != "" && strlen($desc) < 10) {
$error = 3;
// Check URL
} elseif (!preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/.*)?$/i', $url, $m)) {
$error = 4;
} else {
list($junk, $proto, $hostname, $port) = $m;
if (!preg_match('/^\d+\.\d+\.\d+\.\d+$/', $hostname)) {
$ip = gethostbyname($hostname);
if ($ip === $hostname) {
$error = 5;
} else {
$error = 0;
}
} else {
$error = 0;
}
}
// If there was no error, check whether this user already submitted the link
if ($error == 0 && !$this->lib->call('checkSubmission', $url, $_SESSION['userid'])) {
$error = 6;
}
// Generate output
if ($error) {
$this->data = array(
"mode" => 4,
"data" => array(
"url" => $url,
"title" => $title,
"desc" => $desc,
"err" => $error
)
);
} else {
$this->lib->call('submitLink', $url, $title, $desc == "" ? null : $desc, $_SESSION['userid']);
$this->data = array(
"mode" => 5,
"data" => $url
);
}
}
}
function handle($input) {
$this->lib = $this->game->getLib('main/links');
if (is_array($_SESSION) && !is_null($_SESSION['userid'])) {
$account = $_SESSION['userid'];
if (!is_null($input['rbl']) && is_null($input['cancel'])) {
$this->handleBrokenReport($account, $input['id'], $input['confirm']);
} elseif (!is_null($input['sl']) && is_null($input['cancel'])) {
$this->handleSubmission($input);
}
}
if (is_null($this->data)) {
$this->makeLinksList();
}
$this->output = "links";
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$this->output = "login";
}
}
?>

View file

@ -0,0 +1,17 @@
<?php
class page_handler
{
var $needsAuth = false;
var $ajax = array();
function handle($input) {
if (!is_null($_SESSION) && !is_null($_SESSION['userid'])) {
l::notice("Player '{$_SESSION['login']}' (#{$_SESSION['userid']}) logged out");
}
session::kill();
$this->output = "logout";
}
}
?>

View file

@ -0,0 +1,18 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
if ($_SESSION['userid']) {
$this->output = "index";
return;
}
$this->output = "lostpass";
$this->data = $this->game->action('lostPassword', $input['u'], $input['m'], $input['c']);
}
}
?>

View file

@ -0,0 +1,18 @@
<?php
class page_handler {
var $engines = array('xml');
function xml($input) {
$data = new data_leaf('MacWidget', config::getParam('widgetURL'));
$data->setAttribute('latest', config::getParam('latestWidget'));
$data->setAttribute('oldestOk', config::getParam('oldestWidget'));
return $data;
}
}
?>

View file

@ -0,0 +1,95 @@
<?php
class page_handler {
var $noTracking = true;
var $needsAuth = false;
var $ajax = array();
var $lang = null;
var $version = null;
var $page = null;
var $searchText = "";
function pageNotFound() {
$this->page = null;
$this->output = "manual";
}
function getFirstPage() {
$fPage = $this->lib->call('getFirstPage', $this->lang);
if (is_null($fPage)) {
$this->pageNotFound();
return;
}
$this->page = $this->lib->call('getPage', $fPage);
if (is_null($this->page)) {
$this->pageNotFound();
return;
}
$this->output = "manual";
}
function getPage($name) {
$secId = $this->lib->call('getSectionId', $this->lang, $name);
if (is_null($secId)) {
$this->pageNotFound();
return;
}
$pageId = $this->lib->call('getPageId', $secId);
if (is_null($pageId)) {
$this->pageNotFound();
return;
}
$this->page = $this->lib->call('getPage', $pageId);
if (is_null($this->page)) {
$this->pageNotFound();
return;
}
$this->output = "manual";
}
function getSearchPage($text) {
$this->searchText = $text;
if (is_array(tracking::$data['man_search']) && tracking::$data['man_search']['text'] != $text) {
tracking::$data['man_search'] = null;
}
if (!is_array(tracking::$data['man_search'])) {
tracking::$data['man_search'] = array(
"text" => $text,
"results" => $this->lib->call('search', $text, $this->lang)
);
}
$this->data = tracking::$data['man_search'];
$this->output = "manual_search";
}
function handle($input) {
$game = config::getDefaultGame();
$this->lib = $game->getLib('main/manual');
$this->lang = getLanguage();
if ($input['ss'] != '') {
$this->getSearchPage($input['ss']);
} else {
if ($input['p'] != '') {
$p = preg_replace('/[^A-Za-z0-9_\-]/', '', $input['p']);
$this->getPage($p);
} else {
$this->getFirstPage();
}
if (is_array(tracking::$data['man_search'])) {
$this->searchText = tracking::$data['man_search']['text'];
} else {
$this->searchText = "";
}
}
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$this->output = "notfound";
}
}
?>

View file

@ -0,0 +1,18 @@
<?php
class page_handler {
public $engines = array('page');
public $noTracking = true;
public function handle($input) {
$key = strtolower($input['k']);
if (!$key || strlen($key) != 32 || preg_match('/[^a-z0-9]/', $key)) {
$this->data = "X";
} else {
$this->data = "Key is $key";
}
$this->output = "pcheck";
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = true;
function handle($input) {
$this->output = "play";
$this->data = $this->game->action('joinGame', $_SESSION['userid'], $input['g'], is_null($input['c']), $input['p'], $input['n']);
}
}
?>

View file

@ -0,0 +1,45 @@
<?php
class page_handler {
var $noTracking = true;
function handleIPN(&$input) {
$lid = $this->lib->call('logIPN', $input);
$ticket = $input['item_number'];
if ($input['payment_status'] == 'Completed') {
if ($input['mc_currency'] == 'EUR') {
$cash = $input['mc_gross'];
} else {
$cash = $input['settle_amount'];
}
$cash = (float) $cash;
if ($cash == 0) {
logText("PAYPAL: could not retrieve the amount (log ID #$lid)", LOG_WARNING);
return;
}
$this->lib->call('addDonation', $ticket, $cash);
logText("PAYPAL: accepted donation ($cash euros, log ID #$lid)", LOG_INFO);
} elseif ($input['payment_status'] == 'Failed' || $input['payment_status'] == 'Denied') {
$this->lib->call('cancelDonation', $ticket);
logText("PAYPAL: received cancelled donation :( (log ID #$lid)", LOG_INFO);
} else {
logText("PAYPAL: ignoring IPN with status '{$input['payment_status']}' (log ID #$lid)", LOG_INFO);
}
}
function handle($input) {
$this->lib = $this->game->getLib("main/paypal");
logText("PAYPAL: handling incoming IPN from {$_SERVER['REMOTE_ADDR']}", LOG_INFO);
if ($this->lib->call('checkIPN')) {
$this->handleIPN($input);
}
$this->output = "ppipn";
}
}
?>

View file

@ -0,0 +1,54 @@
<?php
class page_handler {
var $noTracking = true;
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$gTexts = $gList = array();
foreach (config::getGames() as $id => $d) {
if ($id == 'main' || $d->status() == 'PRE') {
continue;
}
$gTexts[$id] = $d->text;
array_push($gList, $id);
}
if ($input['t'] != '') {
tracking::$data['rkGame'] = $input['g'];
}
if (is_null(tracking::$data['rkGame']) || !in_array(tracking::$data['rkGame'], $gList)) {
tracking::$data['rkGame'] = $gList[0];
}
$game = config::getGame(tracking::$data['rkGame']);
$lib = $game->getLib('main/rankings');
$rkTypes = array_values($lib->call('getTypes'));
$lang = getLanguage();
$rkText = array();
foreach ($rkTypes as $id) {
$rkText[$id] = $lib->call('getText', $id, $lang);
}
if ($input['t'] != '') {
tracking::$data['rkType'] = $input['t'];
}
if (is_null(tracking::$data['rkType']) || !in_array(tracking::$data['rkType'], $rkTypes)) {
tracking::$data['rkType'] = $rkTypes[0];
}
$cType = tracking::$data['rkType'];
$this->output = "rankings";
$this->data = array(
"games" => $gTexts,
"cGame" => tracking::$data['rkGame'],
"types" => $rkText,
"cType" => $cType,
"rankings" => $lib->call('getAll', $cType)
);
}
}
?>

View file

@ -0,0 +1,12 @@
<?php
class page_handler {
var $needsAuth = false;
var $ajax = array();
function handle($input) {
$this->output = "login";
}
}
?>

View file

@ -0,0 +1,55 @@
<?php
class page_handler {
static private $screenshots = array(
"b5" => array(
'title' => 'Beta 5',
'pics' => array(
'ov' => 'Overview',
'planets' => 'Planet list',
'planet' => 'Individual planet page',
'fleets' => 'Fleets management',
'research' => 'Research',
'money' => 'Money',
'map' => 'Maps',
'messages' => 'Messages',
'ranking' => 'Rankings',
'allies' => 'Trusted allies',
'market' => 'Marketplace',
'manual' => 'In-game manual'
)
),
"b4" => array(
'title' => 'Beta 4',
'pics' => array(
'ov' => 'Overview',
'planets' => 'Planet list',
'fleets' => 'Fleets management',
'money' => 'Money',
'map' => 'Maps',
'ticks' => 'Ticks',
'ranking' => 'Rankings'
)
),
);
public function handle($input) {
$this->data = array(
'list' => self::$screenshots
);
if ($input['c'] && array_key_exists($input['c'], self::$screenshots)) {
$cat = self::$screenshots[$input['c']];
$this->data['category'] = $input['c'];
if ($input['s'] && array_key_exists($input['s'], $cat['pics'])) {
$this->data['picture'] = $input['s'];
}
}
$this->output = "screenshots";
}
}
?>

View file

@ -0,0 +1,115 @@
<?php
class page_handler {
var $needsAuth = true;
function checkMail($a) {
return preg_match(
'/^[A-Za-z0-9_\.\-\+]+@([A-Za-z0-9_\.\-\+]+)+\.[A-Za-z]{2,6}/',
$a
);
}
function checkPassword($op, $np, $cp) {
$q = dbQuery("SELECT password FROM account WHERE id=".$_SESSION['userid']);
if (!$q) {
$this->passError = 1;
return;
}
list($rop) = dbFetchArray($q);
if ($rop != $op) {
$this->passError = 2;
} elseif ($np != $cp) {
$this->passError = 3;
} elseif (strlen($np) < 4) {
$this->passError = 4;
} elseif (strlen($np) > 64) {
$this->passError = 5;
} elseif ($np == $_SESSION['login']) {
$this->passError = 6;
} else {
$p = addslashes($np);
$op = addslashes($rop);
$q = dbQuery("UPDATE account SET password='$p' WHERE id=".$_SESSION['userid']);
dbQuery(
"INSERT INTO pass_change (account, old_pass, new_pass) "
. "VALUES({$_SESSION['userid']}, '$op', '$p')"
);
if (!$q) {
$this->passError = 1;
}
}
}
function checkFormData($input) {
$pLang = array('fr', 'en');
if (in_array($input['lang'], $pLang)) {
prefs::set('main/language', $input['lang']);
}
$pCol = array('red','green','blue','yellow','grey','purple');
if (in_array($input['col'], $pCol)) {
prefs::set('main/colour', $input['col']);
}
if (preg_match('/^[0-4]$/', $input['fs'])) {
prefs::set('main/font_size', $input['fs']);
}
if ($this->checkMail($input['mail'])) {
dbQuery("UPDATE account SET email='".$input['mail']."' WHERE id=".$_SESSION['userid']);
} else {
$this->mailError = preg_replace('/"/', '&quot;', $input['mail']);
}
if (preg_match('/^[1-5]0$/', $input['tpp'])) {
prefs::set('main/forums_ntopics', $input['tpp']);
}
if (preg_match('/^[1-5]0$/', $input['mpp'])) {
prefs::set('main/forums_nitems', $input['mpp']);
}
prefs::set('main/smileys', ($input['gsm'] == "1")?"1":"0");
prefs::set('main/forum_code', ($input['gft'] == "1")?"1":"0");
prefs::set('main/forums_threaded', ($input['fdm'] == "1")?"1":"0");
prefs::set('main/forums_reversed', ($input['fmo'] == "1")?"1":"0");
prefs::set('main/forums_sig', $input['fsig']);
if ($input['opass'] != "") {
$this->checkPassword($input['opass'], $input['npass'], $input['cpass']);
}
}
function handle($input) {
if ($input['col'] != "") {
$this->checkFormData($input);
}
$q = dbQuery("SELECT email FROM account WHERE id=".$_SESSION['userid']);
list($email) = dbFetchArray($q);
$fs = prefs::get('main/font_size', 2);
$col = prefs::get('main/colour', 'red');
$tpp = prefs::get('main/forums_ntopics', 20);
$mpp = prefs::get('main/forums_nitems', 20);
$this->data = array(
"lang" => getLanguage(),
"mail" => $email,
"col" => $col,
"fs" => $fs,
"err1" => $this->mailError,
"err2" => $this->passError,
"tpp" => $tpp,
"mpp" => $mpp,
"gsm" => (prefs::get('main/smileys', 1) == 1),
"gft" => (prefs::get('main/forum_code', 1) == 1),
"fdm" => (prefs::get('main/forums_threaded', 1) == 1),
"fmo" => (prefs::get('main/forums_reversed', 1) == 1),
"fsig" => prefs::get('main/forums_sig', "")
);
$this->output = "settings";
}
}
?>