コード例 #1
0
ファイル: fixDb.php プロジェクト: eBrute/wonitor
ini_set('display_startup_errors', 1);
require_once 'dbUtil.php';
function info($stringy)
{
    echo 'Info: ' . $stringy . '<br \\>';
}
function warning($string)
{
    echo 'Warning: ' . $string . '<br \\>';
}
function error($string)
{
    die('Error: ' . $string);
}
// rounds.sqlite3
if (databaseExists($wonitorDb)) {
    try {
        $db = openDB($wonitorDb);
        $query = 'SELECT COUNT(1) as count FROM rounds WHERE averageSkill<0';
        $numentries = $db->query($query, PDO::FETCH_NUM)->fetchAll(PDO::FETCH_COLUMN, 0)[0];
        if ($numentries != 0) {
            info('Found rounds with negative averageSkil. Will set them to 0 now.');
            $query = 'UPDATE rounds SET averageSkill=0 WHERE averageSkill<0';
            $db->query($query, PDO::FETCH_NUM);
        }
        closeDB($db);
    } catch (PDOException $e) {
        warning($e->getMessage());
    }
}
echo 'All done.';
コード例 #2
0
ファイル: index.php プロジェクト: JCEyras/house
  </head>
  <body>

        <?php 
include 'configuration.php';
include 'common.php';
if ($_GET['install']) {
    include 'model/schema.php';
    set_time_limit(0);
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, 'mysql');
    $mysqli->set_charset("utf8");
    header('Content-Type: text/html;charset=utf-8');
    try {
        echo 'Pinging ' . PROJECT_DB . ' Database ... <br />';
        echo '<hr />';
        if (!databaseExists(PROJECT_DB)) {
            echo PROJECT_DB . ' does not exist ...<br />';
            echo 'Creating ' . PROJECT_DB . '... <br />';
            sqlImport('install.sql');
            echo PROJECT_DB . " created successfully.<br />";
        } else {
            echo PROJECT_DB . ' already exists. <br />';
        }
    } catch (Exception $e) {
        echo 'Exception caught: ' . $e->getMessage() . "<br />";
    }
} else {
    echo '<p><a href="index.php?install=1">Create ' . PROJECT_DB . '</a></p>';
}
?>
 <!-- /php -->
コード例 #3
0
}
// Assert that the next-to-last version does not yet exist.
$lvToFreeze = $lvs[count($lvs) - 2];
print "Asserting that version {$lvToFreeze->name} does not exist.\n";
$dbName = $locDbPrefix . $lvToFreeze->getDbName();
if (databaseExists($dbName)) {
    die("ERROR: Database {$dbName} for version {$lvToFreeze->name} " . "should not exist.\n");
}
if (!$lvToFreeze->freezeTimestamp) {
    die("ERROR: Version {$lvToFreeze->name} should have a freeze date\n");
}
// Assert that the last version is the new current version.
$currentLv = $lvs[count($lvs) - 1];
print "Asserting that version {$currentLv->name} does not exist.\n";
$dbName = $locDbPrefix . $currentLv->getDbName();
if (databaseExists($dbName)) {
    die("ERROR: Database {$dbName} for version {$currentLv->name} " . "should not exist.\n");
}
if ($currentLv->freezeTimestamp) {
    die("ERROR: Version {$currentLv->name} should not have a freeze date\n");
}
// Now create a database for $lvToFreeze and copy the relevant tables there.
$dbName = $locDbPrefix . $lvToFreeze->getDbName();
print "Creating database {$dbName}\n";
db_execute("create database {$dbName}");
$fileName = tempnam(Config::get('global.tempDir'), 'freeze_');
print "Dumping tables to {$fileName}\n";
$tablesToDump = "ConstraintMap Inflection Lexem ModelDescription ModelType Model ParticipleModel Transform InflectedForm";
$parts = db_splitDsn();
$mysql = sprintf("mysqldump -h %s -u %s --password='******' %s %s > %s", $parts['host'], $parts['user'], $parts['password'], $parts['database'], $tablesToDump, $fileName);
OS::executeAndAssert($mysql);
コード例 #4
0
ファイル: troubleshooting.php プロジェクト: eBrute/wonitor
        error('Wonitor database is not writable. Check permissions. User <b>' . `whoami` . '</b> should have write access.');
    }
    try {
        $db = openDB($wonitorDb);
        $query = 'SELECT COUNT(1) as count FROM rounds WHERE averageSkill<0';
        $numentries = $db->query($query, PDO::FETCH_NUM)->fetchAll(PDO::FETCH_COLUMN, 0)[0];
        closeDB($db);
        if ($numentries != 0) {
            warning('Found rounds with negative averageSkil. Click <a href="./fixDb.php">here</a> to fix them.');
        }
    } catch (PDOException $e) {
        warning($e->getMessage());
    }
}
// ns2plus.sqlite3
if (!databaseExists($ns2plusDb)) {
    info('No NS2+ database found (./data/ns2plus.sqlite3). It will be created as soon as the first round stats are recieved. But only if the game server is running ns2+ and is configured to send it.');
} else {
    info('NS2+ database found (./data/ns2plus.sqlite3).');
    try {
        $db = openDB($ns2plusDb);
        $query = 'SELECT COUNT(1) as numentries FROM RoundInfo';
        $numentries = $db->query($query, PDO::FETCH_NUM)->fetchAll(PDO::FETCH_COLUMN, 0)[0];
        closeDB($db);
        info('NS2+ database query successful. ' . $numentries . ' entries on record.');
    } catch (PDOException $e) {
        warning($e->getMessage());
    }
    if (is_writable('./data/ns2plus.sqlite3')) {
        info('NS2+ database database is writable.');
    } else {