Exemple #1
0
function InitializeTables()
{
    global $DB;
    $tables = GetDBTables();
    foreach ($tables as $table) {
        $create = GetDBCreate($table);
        $DB->Update($create);
    }
    $password = RandomPassword();
    $DB->Update('DELETE FROM `tbx_administrator` WHERE `username`=?', array('administrator'));
    $DB->Update('INSERT INTO `tbx_administrator` VALUES (?,?,?,?,?,?)', array('administrator', sha1($password), 'webmaster@' . preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']), 'Administrator', 'Superuser', 0));
    $DB->Update('DELETE FROM `tbx_user_level` WHERE `name` IN (?,?)', array('Guest', 'Standard'));
    $DB->Update('INSERT INTO `tbx_user_level` VALUES (NULL,?,0,0,1,0)', array('Guest'));
    $DB->Update('INSERT INTO `tbx_user_level` VALUES (NULL,?,0,0,0,1)', array('Standard'));
    return $password;
}
Exemple #2
0
if (strpos($database_xml, 'Clip URL/Embed Code') === false) {
    $database_xml = preg_replace('~<!-- START tbx_video_clip -->.*?<!-- END tbx_video_clip -->~msi', "<!-- START tbx_video_clip -->\n" . "  <table>\n" . "    <name>tbx_video_clip</name>\n" . "    <naming>\n" . "      <type>video-clip</type>\n" . "      <textLower>video clip</textLower>\n" . "      <textLowerPlural>video clips</textLowerPlural>\n" . "      <textUpper>Video Clip</textUpper>\n" . "      <textUpperPlural>Video Clips</textUpperPlural>\n" . "      <function>VideoClip</function>\n" . "    </naming>\n" . "    <columns>\n" . "      <column>\n" . "        <name>clip_id</name>\n" . "        <definition>INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT</definition>\n" . "        <default>null</default>\n" . "        <admin>\n" . "          <search>false</search>\n" . "          <sort>false</sort>\n" . "        </admin>\n" . "      </column>\n" . "      <column>\n" . "        <name>video_id</name>\n" . "        <definition>INT UNSIGNED NOT NULL</definition>\n" . "        <admin>\n" . "          <search>false</search>\n" . "          <sort>false</sort>\n" . "        </admin>\n" . "      </column>\n" . "      <column>\n" . "        <name>type</name>\n" . "        <definition>ENUM('URL','Embed')</definition>\n" . "        <default>URL</default>\n" . "        <admin>\n" . "          <search>false</search>\n" . "          <sort>false</sort>\n" . "        </admin>\n" . "      </column>\n" . "      <column>\n" . "        <name>clip</name>\n" . "        <definition>TEXT</definition>\n" . "        <label>Clip URL/Embed Code</label>\n" . "        <admin>\n" . "          <search>true</search>\n" . "          <sort>false</sort>\n" . "        </admin>\n" . "      </column>\n" . "      <column>\n" . "        <name>filesize</name>\n" . "        <definition>INT UNSIGNED NOT NULL</definition>\n" . "        <default>0</default>\n" . "        <admin>\n" . "          <search>false</search>\n" . "          <sort>false</sort>\n" . "        </admin>\n" . "      </column>\n" . "      <index>\n" . "        <column>video_id</column>\n" . "      </index>\n" . "      <primaryKey>clip_id</primaryKey>\n" . "    </columns>\n" . "  </table>\n" . "  <!-- END tbx_video_clip -->", $database_xml);
}
$database_xml = str_replace("<definition>ENUM('Pending','Active','Disabled') NOT NULL</definition>", "<definition>ENUM('Pending','Scheduled','Active','Disabled') NOT NULL</definition>", $database_xml);
$database_xml = str_replace('<autocomplete>#Pending,Active,Disabled</autocomplete>', '<autocomplete>#Pending,Scheduled,Active,Disabled</autocomplete>', $database_xml);
file_put_contents(INCLUDES_DIR . '/database.xml', $database_xml);
// Force a reload of the schema
$schema = GetDBSchema(true);
#### Update database.xml ==========================================================================================================
#### Create database tables =======================================================================================================
// Create tbx_imported if doesn't already exist
$DB->Update(GetDBCreate('tbx_imported'));
// Create tbx_thumb_queue if doesn't already exist
$DB->Update(GetDBCreate('tbx_thumb_queue'));
// Create tbx_search_term_new if doesn't already exist
$DB->Update(GetDBCreate('tbx_search_term_new'));
#### Create database tables =======================================================================================================
#### Update database ==============================================================================================================
// Prepare for new QueueProcessor stats format
$stats = ThumbQueue::LoadStats();
if (!isset($stats[ThumbQueue::STAT_PROCESSED_ITEMS])) {
    Cache_MySQL::Remove('thumb-queue-stats');
}
// Prepare for new QueueProcessor stats format
$stats = ConversionQueue::LoadStats();
if (!isset($stats[ConversionQueue::STAT_PROCESSED_ITEMS])) {
    Cache_MySQL::Remove('conversion-queue-stats');
}
// Update sponsor video counts
if ($DB->QuerySingleColumn('SELECT MAX(`videos`) FROM `tbx_sponsor`') == 0) {
    UpdateSponsorStats();