$num_moves = count($FENarray) - 1; // remove one for initpos loadGame(); // sets up board using last entry in ".T_HISTORY." table (chessdb.inc.php) FENtomoves(); // creates movesArray from FENarray (chessutils.inc.php) // find out if it's the current player's turn $FENitems = explode(' ', $FENarray[$num_moves]); $curTurn = $colorArray[$FENitems[1]]; // convert w -> white, b -> black $isPlayersTurn = $curTurn == $_SESSION['player']['p_color'] ? true : false; //*/ //****************************************************************************** // save incoming information //****************************************************************************** checkDatabase(); // check the database data against the current FEN to make sure the game is ended properly (chessdb.inc.php) processMessages(); // processes the messages (undo, resign, etc) (chessdb.inc.php) // are we undoing ? if ($undoing && 0 < $num_moves) { call("UNDO REQUEST"); // just remove the last FEN entered into the history table $query = "\n\t\tSELECT MAX(h_time)\n\t\tFROM " . T_HISTORY . "\n\t\tWHERE h_game_id = '{$_SESSION['game_id']}'\n\t"; $max_time = $mysql->fetch_value($query, __LINE__, __FILE__); $query = "\n\t\tDELETE FROM " . T_HISTORY . "\n\t\tWHERE h_game_id = '{$_SESSION['game_id']}'\n\t\t\tAND h_time = '{$max_time}'\n\t\tLIMIT 1\n\t"; $mysql->query($query, __LINE__, __FILE__); if (!DEBUG) { header("Location: ./chess.php"); } } elseif (isset($_POST['promotion']) && '' != $_POST['promotion'] && false != $_POST['promoting']) {
$app->response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'); $app->response->headers->set('Cache-Control', 'post-check=0, pre-check=0'); $app->response->headers->set('Pragma', 'no-cache'); $app->notFound(function () use($app) { $output['code'] = 404; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages']['60038']; $app->halt($output['code'], json_encode($output)); }); class ResourceNotFoundException extends Exception { } class AuthenticateFailedException extends Exception { } $db = checkDatabase(); if ($db === False) { // Database is not available $app->map('/api/(:path+)', function () use($app) { $output['code'] = 500; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages']['90003']; $app->response->setStatus($output['code']); $app->response->setBody(json_encode($output)); })->via('DELETE', 'GET', 'POST'); $app->run(); } if (updateDatabase($db) == False) { // Failed to update database // TODO should run una tantum $app->map('/api/(:path+)', function () use($app) {
function __construct() { error_reporting(E_ALL); session_start(); // check for PHP version $req = '5.0.0'; if (version_compare($req, phpversion(), '>=')) { die('PHP Version ' . $req . ' or higher is required'); } // as it crashes between this and load of the config // we need to have all debug info // FIXME if (!file_exists('.install.php')) { include_once 'kernel/constants.php'; include_once 'kernel/config.class.php'; include_once 'kernel/language.class.php'; $config = new CConfig(); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0); define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING)); include_once 'kernel/help.class.php'; include_once 'kernel/users.class.php'; include_once 'kernel/news.class.php'; include_once 'kernel/polls.class.php'; include_once 'kernel/exception.class.php'; include_once 'kernel/database.class.php'; define('TBL_PAGES', TBL_PREFIX . 'pages'); $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/webmastermail', 0); error_reporting($config->getConfigByNameType('general/errorreporting', TYPE_INT)); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0); $dbType = $config->getConfigByNameType('general/databasetype', TYPE_STRING); $dbclass = new CDatabase(); $database = $dbclass->load($dbType, $config, 'site.config.php'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/host', 'localhost'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/user', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/password', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/name', 0); $host = $config->getConfigByNameType('database/host', TYPE_STRING); $user = $config->getConfigByNameType('database/user', TYPE_STRING); $password = $config->getConfigByNameType('database/password', TYPE_STRING); $dbname = $config->getConfigByNameType('database/name', TYPE_STRING); $database->connect($host, $user, $password, $dbname); // TODO $tables = array(); if (checkDatabase($database, $tables)) { // Database seems to be OK $config->addConfigByFileName('site.config.php', TYPE_BOOL, 'user/activatemail', 0); $lang = new CLang(); $user = new CUser($database, $config->getConfigByNameType('user/activatemail', TYPE_BOOL), $lang); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('contentlanguage', $user, 'contentlanguage', 'site.config.php'), 'general/contentlanguage', TYPE_STRING, DEFAULT_CONTENT_LANG); $contentLang = $config->getConfigByNameType('general/contentlanguage', TYPE_STRING); $news = new CNews($database, $lang, $contentLang); $poll = new CPoll($database, $config, $lang); $this->help = new CHelp($database, $config, $lang); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/httplink'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/sitename'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/description'); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timezone', $user, 'timezone', 'site.config.php'), 'general/timezone', TYPE_FLOAT, 0); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timeformat', $user, 'timeformat', 'site.config.php'), 'general/timeformat', TYPE_STRING, ''); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('uilanguage', $user, 'uilanguage', 'site.config.php'), 'general/uilanguage', TYPE_STRING, STANDARD_LANGUAGE); $lang->update($config->getConfigByNameType('general/uilanguage', TYPE_STRING)); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('theme', $user, 'theme', 'site.config.php'), 'general/theme', TYPE_STRING, 'moderngray'); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('threaded', $user, 'threaded', 'site.config.php'), 'news/threaded', TYPE_BOOL, YES); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('headlines', $user, 'headlines', 'site.config.php'), 'news/headlines', TYPE_INT, 5); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('postsonpage', $user, 'postsonpage', 'site.config.php'), 'news/postsonpage', TYPE_INT, 10); $config->addConfigByList('YAPCAS_USER', array($user), 'user/email', TYPE_STRING); $config->addConfigByList('YAPCAS_USER', array($user), 'user/name', TYPE_STRING, 'anonymous'); $this->loadtheme($config->getConfigByNameType('general/theme', TYPE_STRING)); $this->config = $config; $this->news = $news; $this->config = $config; $this->poll = $poll; $this->lang = $lang; $this->user = $user; $this->database = $database; $this->BBCTags = array('b', 'u', 'i', 'quote'); global $theme, $config, $news, $poll, $user, $lang, $database; $config = $this->config; $news = $this->news; $config = $this->config; $poll = $this->poll; $lang = $this->lang; $user = $this->user; $database = $this->database; $theme = $this; } } else { if (file_exists('site.config.php')) { include_once 'kernel/config.class.php'; $config = new config(); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0); define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING)); define('TBL_PAGES', TBL_PREFIX . 'pages'); $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0); //error_reporting ($config->getConfigByNameType('general/errorreporting',TYPE_INT)); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0); loaddbclass($config->getConfigByNameType('general/databasetype', TYPE_STRING)); $database = new database($config, 'site.config.php'); $database->connect(); // FIXME $tables = array(); if (checkDatabase($database, $tables)) { // site is configured but the installscript exists??? echo 'DELETE install.php and than reload this page'; exit; } else { header('Location: install.php'); } } else { header('Location: install.php'); } } }
$block1->contentTitle(" "); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n \t<pre>"; include "../docs/copying.txt"; echo "</pre>\n \t</td></tr>"; } elseif ($step == 2) { $myError = null; $blockPage->itemBreadcrumbs("<a href='../installation/{$script}?step=1'>License</a>"); $blockPage->itemBreadcrumbs("Check DB"); $blockPage->closeBreadcrumbs(); $block1->heading("Checking Database..."); $block1->openContent(); $block1->contentTitle("Database Requirements..."); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n We are currently checking the database to see if it needs to be updated... <br /><br /><b>Please wait...</b><br />\n \t</td></tr>"; flush(); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>"; if (checkDatabase($myError)) { echo "<br />Database looks <font style='color: green'>good</font>. We are continuing the conversion...<br /><br />"; echo "<br />Continue on to <a href='../installation/{$script}?step=3&redirect=true'>Step 3</a>.<br /><br /><b>MAKE SURE SETTINGS.PHP IS WRITEABLE!!!</b><Br /><br />"; } else { echo "<fieldset><legend style='font-weight: bold;font-size: large;padding: 5px;color: #ff3300'>"; echo "Error...</legend>"; echo "Sorry we could not upgrade your database at this time.. you will have to reinstall or do a manual upgrade..."; if (!empty($myError)) { echo "<pre>{$myError}</pre>"; } echo "</fieldset>"; } echo "</td></tr>"; } elseif ($step == 3) { $myError = null; $blockPage->itemBreadcrumbs("<a href='../installation/{$script}?step=1'>License</a>");
** Primaerer Skript-Ablauf wird hier geregelt. Es sollten keine Aenderungen mehr ** ** vorgenommen werden. Nachtraegliche Skripte koennen jedoch noch eingebunden ** ** werden. ** ** ** ***************************************************************************************/ // Lade Konfigurationen, Datenbank-Funktionen und allgemeine Funktionen include "./config.php"; include "./sql.php"; include "./classes.php"; include "./functions.php"; // Starten der PHP-Session, falls nicht bereits geschehen @session_start(); // Stelle Verbindung zur Datenbank her connect_DB(); // Informationen zum angeforderten Template global $page; $page = toSaferValue(@$_GET["page"]); $page = str_replace("..", "", $page); if (!file_exists("./temp/" . $page . ".php")) { $page = "home"; } // Ueberpruefe auf erfolgreiche Installation $page = checkDatabase($page); // Ueberpruefen der Templates auf Berechtigungen $page = checkPermission($page); // Einbinden von Header, Content und Footer include "./temp/head.php"; include "./temp/" . $page . ".php"; include "./temp/footer.php"; // Schliesse Verbindung zur Datenbank close_DB();
function __construct() { error_reporting(E_ALL); // as it crashes between this and load of the config // we need to have all debug info // FIXME if (!file_exists('.install.php')) { include 'kernel/config.class.php'; $config = new config(); $lang = new lang(); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0); define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING)); define('TBL_PAGES', TBL_PREFIX . 'pages'); include 'kernel/help.class.php'; include 'kernel/error.class.php'; // This should not be in the release include 'kernel/users.class.php'; include 'kernel/news.class.php'; include 'kernel/polls.class.php'; $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/webmastermail', 0); error_reporting($config->getConfigByNameType('general/errorreporting', TYPE_INT)); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0); loaddbclass($config->getConfigByNameType('general/databasetype', TYPE_STRING)); $database = new database($config, 'site.config.php'); $database->connect(); // TODO $tables = array(); if (checkDatabase($database, $tables)) { // Database seems to be OK $config->addConfigByFileName('site.config.php', TYPE_BOOL, 'user/activatemail', 0); $user = new user($database, $config->getConfigByNameType('user/activatemail', TYPE_BOOL), $lang); $news = new news($database, $user, $config, $lang); $poll = new polls($database, $config, $lang); $this->help = new help($database, $config, $lang); $config->addConfigByFileName('site.config.php', TYPE_FLOAT, 'general/servertimezone'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/httplink'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/sitename'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/description'); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timezone', $user, 'timezone', 'site.config.php'), 'general/timezone', TYPE_FLOAT, 1); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timeformat', $user, 'timeformat', 'site.config.php'), 'general/timeformat', TYPE_STRING, ''); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('language', $user, 'language', 'site.config.php'), 'general/language', TYPE_STRING, STANDARD_LANGUAGE); $lang->updatelang($config->getConfigByNameType('general/language', TYPE_STRING)); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('theme', $user, 'theme', 'site.config.php'), 'general/theme', TYPE_STRING, 'moderngray'); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('threaded', $user, 'threaded', 'site.config.php'), 'news/threaded', TYPE_BOOL, YES); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('langcode', $user, 'langcode', 'site.config.php'), 'general/langcode', TYPE_STRING); $config->addConfigByList('YAPCAS_USER', array($user), 'user/email', TYPE_STRING); $config->addConfigByList('YAPCAS_USER', array($user), 'user/name', TYPE_STRING, 'anonymous'); $this->loadtheme($config->getConfigByNameType('general/theme', TYPE_STRING)); $this->config = $config; $this->news = $news; $this->config = $config; $this->poll = $poll; $this->lang = $lang; $this->user = $user; $this->database = $database; global $theme, $config, $news, $poll, $user, $lang, $database; $config = $this->config; $news = $this->news; $config = $this->config; $poll = $this->poll; $lang = $this->lang; $user = $this->user; $database = $this->database; $theme = $this; } } else { if (file_exists('site.config.php')) { include 'kernel/config.class.php'; $config = new config(); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0); define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING)); define('TBL_PAGES', TBL_PREFIX . 'pages'); $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0); //error_reporting ($config->getConfigByNameType('general/errorreporting',TYPE_INT)); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0); loaddbclass($config->getConfigByNameType('general/databasetype', TYPE_STRING)); $database = new database($config, 'site.config.php'); $database->connect(); // FIXME $tables = array(); if (checkDatabase($database, $tables)) { // site is configured but the installscript exists??? echo 'DELETE install.php and than reload this page'; exit; } else { header('Location: install.php'); } } else { header('Location: install.php'); } } }
function upgrade2_4() { include "../languages/help_en.php"; $setTitle = "PhpCollab Upgrade"; $blank = "true"; include "../themes/" . THEME . "/block.class.php"; include '../themes/' . THEME . '/header.php'; //Get this file.. $script = "upgrade.php"; $step = getParameter('step'); if (empty($step)) { $step = 1; } // Create new block and start the breadcrumbs $blockPage = new block(); $blockPage->openBreadcrumbs(); $blockPage->itemBreadcrumbs("<a href='../installation/{$script}'>Upgrade</a>"); //Content block $block1 = new block(); if ($step == 1) { $blockPage->itemBreadcrumbs("License"); $blockPage->closeBreadcrumbs(); $block1->heading("License"); $block1->openContent(); $block1->contentTitle(" "); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n \t<pre>"; include "../docs/copying.txt"; echo "</pre>\n \t</td></tr>"; } elseif ($step == 2) { $myError = null; $blockPage->itemBreadcrumbs("<a href='../installation/{$script}?step=1'>License</a>"); $blockPage->itemBreadcrumbs("Check DB"); $blockPage->closeBreadcrumbs(); $block1->heading("Checking Database..."); $block1->openContent(); $block1->contentTitle("Database Requirements..."); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n We are currently checking the database to see if it needs to be updated... <br /><br /><b>Please wait...</b><br />\n \t</td></tr>"; flush(); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>"; if (checkDatabase($myError)) { echo "<br />Database looks <font style='color: green'>good</font>. We are continuing the conversion...<br /><br />"; echo "<br />Continue on to <a href='../installation/{$script}?step=3&redirect=true'>Step 3</a>.<br /><br /><b>MAKE SURE SETTINGS.PHP IS WRITEABLE!!!</b><Br /><br />"; } else { echo "<fieldset><legend style='font-weight: bold;font-size: large;padding: 5px;color: #ff3300'>"; echo "Error...</legend>"; echo "Sorry we could not upgrade your database at this time.. you will have to reinstall or do a manual upgrade..."; if (!empty($myError)) { echo "<pre>{$myError}</pre>"; } echo "</fieldset>"; } echo "</td></tr>"; } elseif ($step == 3) { $myError = null; $blockPage->itemBreadcrumbs("<a href='../installation/{$script}?step=1'>License</a>"); $blockPage->itemBreadcrumbs("<a href='../installation/{$script}?step=2'>Check DB</a>"); $blockPage->itemBreadcrumbs("Conversion"); $blockPage->closeBreadcrumbs(); $block1->heading("Conversion and update"); $block1->openContent(); $block1->contentTitle("Checking Settings.php..."); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n We are making sure that settings.php is writeable, we can not continue if it's not writeable. <br /><br /><b>Please wait...</b><br />\n \t</td></tr>"; flush(); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>"; //TODO: Check file $settingsFile = dirname(realpath(__FILE__)) . "/../includes/settings.php"; unset($goon); $goon = false; clearstatcache(); if (!is_writable($settingsFile)) { echo "<fieldset><legend style='font-weight: bold;font-size: large;padding: 5px;color: #ff3300'>"; echo "Error...</legend>"; echo "Your settings file is not writeable. You need to either <b>chmod 666</b> the file or <b>chmod o+w</b> the file. Hit refresh to recheck."; if (!empty($myError)) { echo "<pre>{$myError}</pre>"; } echo "</fieldset>"; } else { echo "<br />Okay your settings.php file looks good, we are going to continue.<br />"; $goon = true; } echo "<br /></td></tr>"; if ($goon) { //Next $block1->contentTitle("Converting..."); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>\n We are now upgrading your database and writting the config file. <br /><br /><b>Please wait...</b><br />\n \t</td></tr>"; flush(); echo "<tr class='odd'><td valign='top' class='leftvalue'> </td><td>"; if (convertDB()) { echo "<br />Writting out new settings file..."; rewriteConfig($settingsFile, '2.5'); //Reload the Config so we can use the root include $settingsFile; echo "<b> done</b><br /><br />"; echo "<br /><B>Congratulations... if there was no error writting the file, you are done.<br />Click <a href=\"../\">here</a> to login."; echo "<br><B>MAKE SURE TO DELETE UPGRADE.PHP!"; echo "</td></tr>"; echo "<h3>If you are upgrading from 2.4 to the latest version, please re-run this upgrade script to perform additi</h3>"; } } } $block1->closeContent(); $stepNext = $step + 1; if ($step < "2") { echo "<form name='license' action='../installation/{$script}?step=2&redirect=true' method='post'><center><a href=\"javascript:document.license.submit();\"><br /><b>Step {$stepNext}</b></a><br /><br /></center></form><br/>"; } $footerDev = "false"; include '../themes/' . THEME . '/footer.php'; //FOR DEBUG **** exit; // ----------------------- }
<?php $config = (require __DIR__ . '/config.php'); foreach ($config['databases'] as $databaseKey => $databaseData) { if (isset($databaseData['create']) && $databaseData['create'] === false) { continue; } createDatabase($databaseData['host'], $databaseData['dbname']); checkDatabase($databaseData['host'], $databaseData['dbname']); if (isset($databaseData['isadmin']) && $databaseData['isadmin']) { createAdmin($databaseData['host'], $databaseData['user'], $databaseData['password']); } elseif (isset($databaseData['user'])) { // create user } } function createDatabase($host, $dbname) { $url = 'http://' . $host . '/' . $dbname; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PUT, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // führe die Aktion aus und gebe die Daten an den Browser weiter curl_exec($ch); // schließe den cURL-Handle und gebe die Systemresourcen frei curl_close($ch); } function createAdmin($host, $user, $password) { $url = $host . '/_config/admins/' . $user;
function getLoginState() { global $databasename; global $tableprefix; if (checkDatabase("test") != "test") { @mysql_free_result($result); return "Installations-Modus\n"; } if (isset($_SESSION["gbm_sessid"])) { $result = mysql_query("SELECT * FROM " . $databasename . "." . $tableprefix . "sessions WHERE sessionhash = '" . $_SESSION["gbm_sessid"] . "' LIMIT 1"); while ($row = @mysql_fetch_assoc($result)) { if ($row["islogin"] == 1) { @mysql_free_result($result); return "<a href=\"index.php?page=administration\">Administration</a> | <a href=\"index.php?page=scripts/logout\">Abmelden</a>\n"; } else { @mysql_free_result($result); return "<a href=\"index.php?page=login\">Anmelden</a>\n"; } } @mysql_free_result($result); } return "<a href=\"index.php?page=login\">Anmelden</a>\n"; }