Example #1
0
function Initialize()
{
    global $errors, $t, $C, $template;
    // Already initialized
    if (!empty($C['db_username'])) {
        $t->assign('mode', 'done');
        echo $t->parse($template);
    } else {
        // Form submitted
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $connection = TestDBConnection();
            if (!$connection) {
                $t->assign_by_ref('errors', $errors);
                $t->assign_by_ref('request', $_REQUEST);
                $t->assign('mode', 'getdb');
                echo $t->parse($template);
            } else {
                // Create database tables and setup initial login
                FileWrite("{$GLOBALS['BASE_DIR']}/data/.htaccess", "deny from all");
                CreateTables();
                WriteConfig($_REQUEST);
                RecompileTemplates();
                // Display initialization finished screen
                $t->assign('control_panel', "http://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['REQUEST_URI']) . "/index.php");
                $t->assign('mode', 'login');
                echo $t->parse($template);
            }
        } else {
            // Run pre-initialization tests
            ServerTest();
            FilesTest();
            DirectoriesTest();
            TemplatesTest();
            if (is_dir('../utilities')) {
                $errors[] = 'For security purposes, the utilities directory must be removed';
            }
            if (count($errors)) {
                // Display failed test information
                $t->assign('mode', 'errors');
                $t->assign_by_ref('errors', $errors);
                echo $t->parse($template);
            } else {
                $_REQUEST['db_hostname'] = 'localhost';
                $t->assign_by_ref('request', $_REQUEST);
                $t->assign_by_ref('errors', $errors);
                $t->assign('mode', 'getdb');
                echo $t->parse($template);
            }
        }
    }
}
Example #2
0
function TestDatabase()
{
    $sql = new mysql();
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: Zabbix server daemon creating database\n";
        $sql->CREATE_DATABASE("zabbix");
        CreateTables();
    }
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: Zabbix server daemon creating database FAILED\n";
        die;
    }
    if (TablesCount() < 73) {
        CreateTables();
    }
    echo "Starting......: Zabbix server daemon database success\n";
    UpdateAdmin();
}
Example #3
0
function TestDatabase()
{
    $sql = new mysql();
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: " . date("H:i:s") . " Zabbix server daemon creating database\n";
        $sql->CREATE_DATABASE("zabbix");
        CreateTables();
    }
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: " . date("H:i:s") . " Zabbix server daemon creating database FAILED\n";
        die;
    }
    $TablesCount = TablesCount();
    echo "Starting......: " . date("H:i:s") . " Zabbix server {$TablesCount} tables\n";
    if ($TablesCount < 66) {
        CreateTables();
    }
    echo "Starting......: " . date("H:i:s") . " Zabbix server daemon database success\n";
    UpdateAdmin();
}
ignore_user_abort(1);
switch (@$_GET["action"]) {
    case 'analyze':
        CommonHeader('Scanning directory ' . $audio_path);
        CreateTables();
        AnalyzeDirectory();
        break;
    case 'create':
        CommonHeader('Creating empty database');
        CreateTables();
        echo xml_gen::p('done');
        break;
    case 'import':
        CommonHeader('Importing sample data');
        echo xml_gen::p('Please wait while importing demo.mysql.sample_data.sql - 97k lines.');
        CreateTables();
        ImportSampleData();
        echo xml_gen::p('done');
        break;
    case 'genres':
        CommonHeader('Genre Distribution');
        Summary();
        GenreReport();
        break;
    case 'artists':
        CommonHeader('Genre Distribution');
        Summary();
        ArtistReport();
        break;
    case 'formats':
        CommonHeader('Format/Encoder Distribution');
function UpdateWorkshopDatabase()
{
    global $dbfields, $pubfiles, $tb;
    // Get current column list if we haven't loaded it yet
    if (!count($dbfields)) {
        // Create table if it's not existing
        $tables = array("{$tb['prefix']}{$tb['pubfiles']}" => array("settings" => array("ENGINE=InnoDB", "DEFAULT CHARSET=latin1", "AUTO_INCREMENT=1"), "fields" => array('db_updated' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')));
        CreateTables($tables);
        $dbfields = GetTableColumns("{$tb['prefix']}{$tb['pubfiles']}");
    }
    $result = do_mysql_query("SELECT * FROM `{$tb['prefix']}{$tb['pubfiles']}`");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $pubfiles[$row['publishedfileid']] = $row;
    }
    $json_pubfiles = GetWorkshopPages();
    file_put_contents("{$cachepath}/workshop.json", $json_pubfiles);
    foreach ($json_pubfiles as $pubfile) {
        foreach ($pubfile as $key => $val) {
            CheckDatabaseField($key, $val);
            if (isset($pubfiles[$pubfile['publishedfileid']])) {
                UpdateDatabaseRow($pubfile['publishedfileid'], $key, $val);
            }
        }
        if (!isset($pubfiles[$pubfile['publishedfileid']])) {
            AddDatabaseRow($pubfile);
        }
    }
}