function hs_install() { global $CONFIG, $thisplugin, $lang_plugin_highslide_install; require 'plugins/highslide/include/init.inc.php'; if ($_POST['submit'] == $lang_plugin_highslide_install['button_install']) { if (!isset($CONFIG['highslide_enable'])) { require 'include/sql_parse.php'; $query = "INSERT INTO " . $CONFIG['TABLE_CONFIG'] . " VALUES ('highslide_enable', '1');"; cpg_db_query($query); // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Put default setting $db_schema = $thisplugin->fullpath . '/basic.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } } return true; } else { return 1; } }
function newsletter_install() { global $CONFIG, $newsletter_installation, $thisplugin, $USER_DATA, $lang_plugin_newsletter; // Create the super cage $superCage = Inspekt::makeSuperCage(); $newsletter_installation = 1; require 'include/sql_parse.php'; // Perform the database changes $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = preg_replace('/ADMIN_EMAIL/', $CONFIG['gallery_admin_email'], $sql_query); $sql_query = preg_replace('/ADMIN_USERNAME/', $USER_DATA['user_name'], $sql_query); $sql_query = preg_replace('/COPPERMINE_SITE_NAME/', $CONFIG['gallery_name'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Set the plugin config defaults $plugin_config_defaults = array('plugin_newsletter_guest_subscriptions' => '0', 'plugin_newsletter_salutation_for_guests' => 'Dear subscriber,', 'plugin_newsletter_from_email' => $CONFIG['gallery_admin_email'], 'plugin_newsletter_from_name' => $USER_DATA['user_name'], 'plugin_newsletter_mails_per_page' => '1', 'plugin_newsletter_page_refresh_delay' => '10', 'plugin_newsletter_admin_menu_links' => '1', 'plugin_newsletter_visitor_menu_links' => '2', 'plugin_newsletter_retries' => '2', 'plugin_newsletter_default_on_register' => '0'); foreach ($plugin_config_defaults as $key => $value) { if (!$CONFIG[$key]) { $CONFIG[$key] = $value; } } if ($superCage->post->keyExists('submit')) { newsletter_configuration_submit(); return true; } else { return 1; } }
function update_history_install() { $superCage = Inspekt::makeSuperCage(); global $CONFIG, $lang_plugin_update_history_config, $thisplugin; require 'plugins/update_history/include/init.inc.php'; if ($superCage->post->getAlnum('submit') == $lang_plugin_update_history_config['button_install']) { require 'include/sql_parse.php'; //if(!isset($CONFIG['fex_enable'])) { // $query="INSERT INTO ".$CONFIG['TABLE_CONFIG']." VALUES ('fex_enable', '1');"; // cpg_db_query($query); // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Put default setting $db_schema = $thisplugin->fullpath . '/basic.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } //} return true; } else { return 1; } }
function avmaker_configure($stop = true) { global $errors, $CONFIG; require 'include/sql_parse.php'; $db_update = 'plugins/avmaker/sql/basic.sql'; $sql_query = fread(fopen($db_update, 'r'), filesize($db_update)); // Update table prefix $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); ?> <h2>Performing Database Updates<h2> <table class="maintable"> <?php foreach ($sql_query as $q) { echo "<tr><td class='debug_text' style='color: black;'>\r\n\t\t{$q}\r\n\t\t</td>"; if (mysql_query($q)) { echo "<td class='debug_text' style='color: green;'>OK</td></tr>"; } else { echo "<td class='debug_text' style='color: black;'>Already Done</td></tr>"; } } echo "</table>"; if ($stop) { echo <<<EOT <form action="{$_SERVER['REQUEST_URI']}" method="post"> <input type="submit" value="Go!" name="submit" /> </form> EOT; } }
function social_bookmarks_install() { global $CONFIG, $social_bookmarks_installation, $thisplugin, $USER_DATA, $lang_plugin_social_bookmarks; // Create the super cage $superCage = Inspekt::makeSuperCage(); $social_bookmarks_installation = 1; require 'include/sql_parse.php'; // Perform the database changes $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Set the plugin config defaults $plugin_config_defaults = array('plugin_social_bookmarks_position' => '2', 'plugin_social_bookmarks_visibility' => '2', 'plugin_social_bookmarks_greyout' => '0', 'plugin_social_bookmarks_layout' => '2', 'plugin_social_bookmarks_columns' => '5', 'plugin_social_bookmarks_smart_language' => '1', 'plugin_social_bookmarks_admin_menu' => '0'); foreach ($plugin_config_defaults as $key => $value) { if (!$CONFIG[$key]) { $CONFIG[$key] = $value; } } if ($superCage->post->keyExists('submit')) { social_bookmarks_configuration_submit(); return true; } else { return 1; } }
function final_extract_install() { global $CONFIG, $lang_plugin_final_extract, $lang_plugin_final_extract_config, $thisplugin; require 'plugins/final_extract/configuration.php'; require 'include/sql_parse.php'; if (!isset($CONFIG['fex_enable'])) { $query = "INSERT INTO " . $CONFIG['TABLE_CONFIG'] . " VALUES ('fex_enable', '1');"; cpg_db_query($query); // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Put default setting $db_schema = $thisplugin->fullpath . '/basic.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } } return true; }
function external_edit_install() { global $CONFIG, $thisplugin; require 'include/sql_parse.php'; // Perform the database changes $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } return true; }
function captcha_install() { global $CONFIG, $lang_plugin_captcha; require 'plugins/captcha/include/init.inc.php'; require 'include/sql_parse.php'; // create table $db_schema = 'plugins/captcha/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } return true; }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page('数据库初始化成功,请使用【member@teamtoy.net】和【' . $password . '】<a href="/" target="new">登入并添加用户</a>'); exit; } else { info_page(db_error()); exit; } }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page(__('DATABASE_INIT_FINISHED', $password)); exit; } else { info_page(db_error()); exit; } }
function potd_install() { global $CONFIG, $thisplugin, $lang_plugin_potd_config; require 'plugins/potd/include/init.inc.php'; if ($_POST['submit'] == $lang_plugin_potd_config['button_done']) { require 'include/sql_parse.php'; $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } return true; } else { return 1; } }
function copperad_install() { global $CONFIG, $lang_plugin_copperad, $lang_plugin_copperad_config, $thisplugin; require 'plugins/copper_ad/include/init.inc.php'; if ($_POST['submit'] == $lang_plugin_copperad_config['button_install']) { if (!isset($CONFIG['cpa_enable'])) { require 'include/sql_parse.php'; $query = "INSERT INTO " . $CONFIG['TABLE_CONFIG'] . " VALUES ('cpa_enable', '1');"; cpg_db_query($query); // Copy needed file and ADV directory ===If you can't CHMODE you gallery then comment these line 40~46 and after installation copy "banner.php.sample" and "bannermgr.php.sample" to your gallery root and remove ".sample" extention. copy($thisplugin->fullpath . "/banner.php.sample", "banner.php") or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); copy($thisplugin->fullpath . "/bannermgr.php.sample", "bannermgr.php") or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); mkdir('adv') or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); mkdir('adv/pic') or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); mkdir('adv/flash') or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); copy($thisplugin->fullpath . "/adv/pic/copperad.jpg", "adv/pic/copperad.jpg") or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); copy($thisplugin->fullpath . "/adv/flash/copperad.swf", "adv/flash/copperad.swf") or cpg_die(ERROR, $lang_plugin_copperad_config['permission'], __FILE__, __LINE__); // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } // Put default setting $db_schema = $thisplugin->fullpath . '/basic.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } } return true; } else { return 1; } }
function multi_install() { global $CONFIG, $thisplugin; if (isset($_POST['langs'])) { require 'include/sql_parse.php'; $langStr = implode(',', $_POST['langs']); // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); $sql_query[] = "REPLACE INTO {$CONFIG['TABLE_CONFIG']} (name, value) VALUES ('mod_active_lang', '{$langStr}')"; foreach ($sql_query as $q) { cpg_db_query($q); } return true; } else { return 1; } }
} } if (!empty($_POST['write_files'])) { $_SESSION['in_arrowchat'] = 1; if ($_SESSION['db_type'] == 1) { $db = new QuickMSDB($_SESSION['db_host'], $_SESSION['db_username'], $_SESSION['db_password'], $_SESSION['db_name'], false, false); $dbms_schema = 'schemas/mssql_schema.sql'; } else { $db = new QuickDB($_SESSION['db_host'], $_SESSION['db_username'], $_SESSION['db_password'], $_SESSION['db_name'], false, false); $dbms_schema = 'schemas/mysql_schema.sql'; } $remove_remarks = "remove_remarks"; $delimiter = ";"; $sql_query = @file_get_contents($dbms_schema); $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter); foreach ($sql_query as $sql) { $db->execute($sql); } require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "includes" . DIRECTORY_SEPARATOR . "db_initial_values.php"; foreach ($sql_ary as $sql) { $db->execute($sql); } write_config_file(); $rename = write_functions_file(); update_config_file(); $success = true; } if (!$success) { $next = array('0' => 'Install', '1' => 'onClick="document.forms[\'final_form\'].submit();"'); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "layout" . DIRECTORY_SEPARATOR . "pages_final_confirm.php";
/** * Table Add * * This only supports input from the array format of db_tools or create_schema_files. */ function table_add($table_name, $table_data = array()) { global $dbms, $user; // Multicall if (is_array($table_name)) { foreach ($table_name as $params) { call_user_func_array(array($this, 'table_add'), $params); } return; } /** * $table_data can be empty when uninstalling a mod and table_remove was used, but no 2rd argument was given. * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 2rd argument) and skip this to prevent an error */ if (empty($table_data)) { return; } $this->get_table_name($table_name); $this->umil_start('TABLE_ADD', $table_name); if ($this->table_exists($table_name)) { return $this->umil_end('TABLE_ALREADY_EXISTS', $table_name); } if (!is_array($table_data)) { return $this->umil_end('NO_TABLE_DATA'); } if (!function_exists('get_available_dbms')) { global $phpbb_root_path, $phpEx; include "{$phpbb_root_path}includes/functions_install.{$phpEx}"; } if (method_exists($this->db_tools, 'sql_create_table')) { // Added in 3.0.5 $this->db_tools->sql_create_table($table_name, $table_data); } else { $available_dbms = get_available_dbms($dbms); $sql_query = $this->create_table_sql($table_name, $table_data); $sql_query = split_sql_file($sql_query, $available_dbms[$dbms]['DELIM']); foreach ($sql_query as $sql) { $this->db->sql_query($sql); } } return $this->umil_end(); }
function createAdmin() { global $config, $language; if (!isset($config['admin_username']) || $config['admin_username'] == '') { $GLOBALS['error'] = $language['no_admin_username']; return false; } if (!isset($config['admin_password']) || $config['admin_password'] == '') { $GLOBALS['error'] = $language['no_admin_password']; return false; } if (!isset($config['admin_email']) || $config['admin_email'] == '') { $GLOBALS['error'] = $language['no_admin_email']; return false; } // Insert the admin account $sql_query = "INSERT INTO {$config['db_prefix']}users " . "(user_group, user_active, user_name, user_password, user_lastvisit, " . " user_regdate, user_group_list, user_email, user_profile1, user_profile2, user_profile3, " . " user_profile4, user_profile5, user_profile6, user_actkey ) " . "VALUES " . "(1, 'YES', '{$config['admin_username']}', " . " md5('{$config['admin_password']}'), NOW(), NOW(), '', " . " '{$config['admin_email']}', '', '', '', '', '', '', '');\n"; // Set gallery admin mail $sql_query .= "REPLACE INTO CPG_config VALUES ('gallery_admin_email', '{$config['admin_email']}');\n"; // Update table prefix $sql_query = preg_replace('/CPG_/', $config['db_prefix'], $sql_query); require_once 'include/sql_parse.php'; $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); // Get a connection with the db. if (!checkSqlConnection()) { return false; } foreach ($sql_query as $q) { if (!mysql_query($q, $GLOBALS['mysql_connection'])) { $GLOBALS['error'] = $language['mysql_error'] . mysql_error($GLOBALS['mysql_connection']) . ' ' . $language['on_q'] . " '{$q}'"; return false; } } return true; }
/** * Compile the correct schema filename (as per create_schema_files) and * load it into the database. */ protected function load_schema_from_file($directory) { $schema = $this->dbms['SCHEMA']; if ($this->config['dbms'] == 'mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); $row = $sth->fetch(PDO::FETCH_ASSOC); if (version_compare($row['version'], '4.1.3', '>=')) { $schema .= '_41'; } else { $schema .= '_40'; } } $filename = $directory . $schema . '_schema.sql'; $queries = file_get_contents($filename); $sql = phpbb_remove_comments($queries); $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) { $this->pdo->exec($query); } }
function setBackup() { global $dbname, $dbh; global $PARAM, $SUBS, $MSG, $MONTHS; if (!is_dir(getAdmSetting('BACKUP_DIR'))) { MkDir(getAdmSetting('BACKUP_DIR'), 0777); } if ($PARAM['upload'] == 1) { global $bckFile, $bckFile_name; if ($bckFile_name == '') { $SUBS['ERROR'] = $MSG[20108]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } else { if (!($UPLOAD = @file($bckFile))) { setLogAndStatus("Reading", $bckFile, 0, "setBackup()", 'READ_UPLOAD'); } $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; $upload = '## ' . $MSG[20109] . date(' d F Y H:i:s') . "\n"; $upload .= "## {$MSG['20110']} {$bckFile_name}\n"; $upload .= join('', $UPLOAD); if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", $filename, 0, "setBackup()", 'OPEN_FILE'); } fwrite($fp, $upload); fclose($fp); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20050"; printPage('_admin_done.htmlt'); return; } } //export database backup if ($PARAM['export'] == 1) { $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", 0, $filename, "setBackup()", 'OPEN_FILE'); } //write comments if any if ($PARAM['bckComments'] != '') { $comments = '##' . ereg_replace("\n", "\n##", $PARAM['bckComments']) . "\n"; fwrite($fp, $comments); } if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 0, $dbname, "setBackup()", 'LIST_TABLES'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $fields = db_list_fields($dbname, $table, $dbh); $columns = db_num_fields($fields); $tablelist = ''; for ($j = 0; $j < $columns; $j++) { if ($columns - $j == 1) { $tablelist .= db_field_name($fields, $j); } else { $tablelist .= db_field_name($fields, $j) . ','; } } $schema = "REPLACE INTO {$table} ({$tablelist}) VALUES ("; $query = "SELECT * FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'SELECT_TABLES'); while ($row = db_fetch_row($result)) { $schema_insert = ''; for ($j = 0; $j < $columns; $j++) { if (!isset($row[$j])) { $schema_insert .= ' NULL,'; } else { $schema_insert .= ' ' . dbQuote($row[$j]) . ','; } } $schema_insert = $schema . ereg_replace(',$', '', $schema_insert); $schema_insert .= ");\r\n"; fwrite($fp, $schema_insert); } $i++; } fclose($fp); // the ZIP thing -------------------- $fp = fopen($filename, "rb"); $data = fread($fp, filesize($filename)); fclose($fp); $name = array(baseName($filename)); $data = array($data); $content = makezip($name, $data); $fp = fopen('./zip/' . basename($filename) . '.ZIP', "wb"); fputs($fp, $content); fclose($fp); // the ZIP thing -------------------- $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20052"; printPage('_admin_done.htmlt'); return; } //prepare for import or delete $backups = opendir(getAdmSetting('BACKUP_DIR')); while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $BCKUPS[eregi_replace('[^a-z0-9]', '_', $file)] = getAdmSetting('BACKUP_DIR') . "/{$file}"; } } closedir($backups); reset($PARAM); while (list($k, $v) = each($PARAM)) { if (ereg('^bck_(.*)$', $k, $R)) { $BACKUPS[] = $R[1]; } } reset($PARAM); //delete backups if ($PARAM['delete'] == 1) { if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } for ($i = 0; $i < count($BACKUPS); $i++) { if (!@unlink($BCKUPS[$BACKUPS[$i]])) { setLogAndStatus("Deleting", $BCKUPS[$BACKUPS[$i]], "setBackup()", 'DEL_BACKUP'); } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20054"; printPage('_admin_done.htmlt'); return; } //import database backup if ($PARAM['import'] == 1) { if (count($BACKUPS) > 1) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20053"; printPage('_admin_done.htmlt'); return; } if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } //get backup file $file = fread(fopen($BCKUPS[$BACKUPS[0]], 'r'), filesize($BCKUPS[$BACKUPS[0]])); ////---- [Mrasnika's] Edition 21.03.2002 split_sql_file($BACKUP, $file); //reset tables if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 1, $dbname, "databaseBackup()", 'LIST_TABLES_2'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $query = "DELETE FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'RESET_TABLES'); $i++; } //fill tables while (list($k, $query) = each($BACKUP)) { if (!ereg('^#', $query)) { if (!($result = db_query($query, $dbh))) { setLogAndStatus($query, db_errno($dbh), db_error($dbh), "databaseBackup()", 'RESTORE_DB'); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20055"; printPage('_admin_done.htmlt'); return; } } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20056"; printPage('_admin_done.htmlt'); return; } $backups = opendir(getAdmSetting('BACKUP_DIR')); $last = 0; while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $date = stat(getAdmSetting('BACKUP_DIR') . "/{$file}"); if ($last < $date[9]) { $month = intval(date('m')); $SUBS['LAST'] = $MSG[20051] . date(' d ', $date[9]) . $MONTHS[$month] . date(' Y H.i.s', $date[9]); } $SUBS['SIZE'] = sprintf('%0.2f KB', $date[7] / 1024); $SUBS['NAME'] = eregi_replace('_', ':', $file); $SUBS['CHECK'] = eregi_replace('[^a-z0-9]', '_', $file); //checkbox name $SUBS['WHERE'] = getAdmSetting('BACKUP_DIR') . "/{$file}"; if (!($BACKUP = @file(getAdmSetting('BACKUP_DIR') . "/{$file}"))) { setLogAndStatus("Reading", 0, getAdmSetting('BACKUP_DIR') . "/{$file}", "setBackup()", 'READ_FILE'); } $comments = ''; //get comments from the beginning of the file for ($i = 0; $i < count($BACKUP); $i++) { if (eregi('^##(.*)$', $BACKUP[$i], $R)) { $comments .= $R[1]; } } if ($comments != '') { $SUBS['COMMENTS'] = ' ' . ereg_replace("\n", '<BR> ', htmlEncode($comments)); $SUBS['COMMENTS'] = ereg_replace('<BR> $', '', $SUBS['COMMENTS']); } else { $SUBS['COMMENTS'] = ''; } $SUBS['BACKUPS'] .= fileParse('_admin_backup_row.htmlt'); } } closedir($backups); if ($PARAM['err'] != '') { $SUBS['ERROR'] = $MSG[$PARAM['err']]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } printPage('_admin_backup.htmlt'); }
/** * Parse sql * * @param array $sql_query */ function parse_sql(&$sql_query) { global $dbms, $table_prefix; if (!function_exists('get_available_dbms')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/functions_install.' . $phpEx; } static $available_dbms; if (!isset($available_dbms)) { $available_dbms = get_available_dbms($dbms); } $remove_remarks = $available_dbms[$dbms]['COMMENTS']; $delimiter = $available_dbms[$dbms]['DELIM']; if (sizeof($sql_query) == 1) { // do some splitting here $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); $remove_remarks($sql_query[0]); $sql_query = split_sql_file($sql_query[0], $delimiter); } else { $query_count = sizeof($sql_query); for ($i = 0; $i < $query_count; $i++) { $sql_query[$i] = preg_replace('#phpbb_#i', $table_prefix, $sql_query[$i]); $remove_remarks($sql_query[$i]); } } //return $sql_query; }
function update_tables() { global $errors, $CONFIG; $superCage = Inspekt::makeSuperCage(); $possibilities = array('REDIRECT_URL', 'PHP_SELF', 'SCRIPT_URL', 'SCRIPT_NAME', 'SCRIPT_FILENAME'); foreach ($possibilities as $test) { if ($matches = $superCage->server->getMatched($test, '/([^\\/]+\\.php)$/')) { $CPG_PHP_SELF = $matches[1]; break; } } //$CPG_PHP_SELF = $_SERVER['PHP_SELF']; $gallery_dir = strtr(dirname($CPG_PHP_SELF), '\\', '/'); //$gallery_url_prefix = 'http://' . $_SERVER['HTTP_HOST'] . $gallery_dir . (substr($gallery_dir, -1) == '/' ? '' : '/'); $gallery_url_prefix = 'http://' . $superCage->server->getRaw('HTTP_HOST') . $gallery_dir . (substr($gallery_dir, -1) == '/' ? '' : '/'); $db_update = 'sql/update.sql'; $sql_query = fread(fopen($db_update, 'r'), filesize($db_update)); // Update table prefix $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); ?> <h2>Performing Database Updates<h2> <table class="maintable"> <?php foreach ($sql_query as $q) { echo "<tr><td class='tableb'>{$q}</td>"; /** * Determining if the Alter Table actually made a change * to properly reflect it's status on the update page. */ if (strpos(strtolower($q), 'alter table') !== false) { $query = explode(" ", $q); //var_dump($query); $result = mysql_query("DESCRIBE " . $query[2]); while ($row = mysql_fetch_row($result)) { $description[] = $row; } $result = @mysql_query($q); $affected = mysql_affected_rows(); $warnings = mysql_query('SHOW WARNINGS'); $result = mysql_query("DESCRIBE " . $query[2]); while ($row = mysql_fetch_row($result)) { $description2[] = $row; } if ($description == $description2) { $affected = 0; } } else { $result = @mysql_query($q); $affected = mysql_affected_rows(); $warnings = mysql_query('SHOW WARNINGS;'); } if ($result && $affected) { echo "<td class='updatesOK'>OK</td>"; } else { echo "<td class='updatesFail'>Already Done</td>"; } //if (isset($_REQUEST['debug'])) { if ($superCage->get->keyExists('debug')) { echo "<tr><td class='tablef'>"; if ($affected > -1) { echo "Rows Affected: " . $affected . "<br />"; } if ($warnings) { while ($warning = mysql_fetch_row($warnings)) { echo "{$warning[0]} ({$warning[1]}) {$warning[2]}<br />"; } } echo "</td><td class='tableh2_compact'>MySQL Said</td></tr>"; } } echo "</table>"; }
function imageflow_install() { global $CONFIG, $thisplugin; require 'include/sql_parse.php'; // create table $db_schema = $thisplugin->fullpath . '/schema.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); echo $sqlquery; foreach ($sql_query as $q) { cpg_db_query($q); } // insert default values $db_schema = $thisplugin->fullpath . '/basic.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { cpg_db_query($q); } return true; }
/** * Compile the correct schema filename (as per create_schema_files) and * load it into the database. */ protected function load_schema_from_file($directory, \phpbb\db\driver\driver_interface $db) { $schema = $this->dbms['SCHEMA']; if ($this->config['dbms'] == 'phpbb\\db\\driver\\mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); $row = $sth->fetch(PDO::FETCH_ASSOC); if (version_compare($row['version'], '4.1.3', '>=')) { $schema .= '_41'; } else { $schema .= '_40'; } } $filename = $directory . $schema . '_schema.sql'; if (file_exists($filename)) { $queries = file_get_contents($filename); $sql = phpbb_remove_comments($queries); $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) { $this->pdo->exec($query); } } // Ok we have the db info go ahead and work on building the table if (file_exists($directory . 'schema.json')) { $db_table_schema = file_get_contents($directory . 'schema.json'); $db_table_schema = json_decode($db_table_schema, true); } else { global $phpbb_root_path, $phpEx, $table_prefix; $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); $classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $db = new \phpbb\db\driver\sqlite(); $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); $db_table_schema = $schema_generator->get_schema(); } $db_tools = new \phpbb\db\tools($db, true); foreach ($db_table_schema as $table_name => $table_data) { $queries = $db_tools->sql_create_table($table_name, $table_data); foreach ($queries as $query) { if ($query === 'begin') { $this->pdo->beginTransaction(); } else { if ($query === 'commit') { $this->pdo->commit(); } else { $this->pdo->exec($query); } } } } }
function create_tables() { global $errors, $DFLT; //$PHP_SELF = $_SERVER['PHP_SELF']; $gallery_dir = strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'); $gallery_url_prefix = 'http://' . $_SERVER['HTTP_HOST'] . $gallery_dir . (substr($gallery_dir, -1) == '/' ? '' : '/'); $db_schema = "{$DFLT['sql_d']}/schema.sql"; $db_basic = "{$DFLT['sql_d']}/basic.sql"; if (($sch_open = fopen($db_schema, 'r')) === FALSE) { $errors .= "<hr /><br />The file '{$db_schema}' could not be found. Check that you have uploaded all Coppermine files to your server<br /><br />"; return; } else { $sql_query = fread($sch_open, filesize($db_schema)); if (($bas_open = fopen($db_basic, 'r')) === FALSE) { $errors .= "<hr /><br />The file '{$db_basic}' could not be found. Check that you have uploaded all Coppermine files to your server<br /><br />"; return; } else { $sql_query .= fread($bas_open, filesize($db_basic)); } } // Insert the admin account $sql_query .= "INSERT INTO CPG_users (user_id, user_group, user_active, user_name, user_password, user_lastvisit, user_regdate, user_group_list, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_actkey ) VALUES (1, 1, 'YES', '{$_POST['admin_username']}', md5('{$_POST['admin_password']}'), NOW(), NOW(), '', '{$_POST['admin_email']}', '', '', '', '', '', '', '');\n"; // Set configuration values for image package $sql_query .= "REPLACE INTO CPG_config VALUES ('thumb_method', '{$_POST['thumb_method']}');\n"; $sql_query .= "REPLACE INTO CPG_config VALUES ('impath', '{$_POST['impath']}');\n"; $sql_query .= "REPLACE INTO CPG_config VALUES ('ecards_more_pic_target', '{$gallery_url_prefix}');\n"; $sql_query .= "REPLACE INTO CPG_config VALUES ('gallery_admin_email', '{$_POST['admin_email']}');\n"; // Enable silly_safe_mode if test has shown that it is not configured properly if (test_silly_safe_mode() == TRUE) { $sql_query .= "REPLACE INTO CPG_config VALUES ('silly_safe_mode', '1');\n"; } // Test write permissions for main dir if (!is_writable('.')) { $sql_query .= "REPLACE INTO CPG_config VALUES ('default_dir_mode', '0777');\n"; $sql_query .= "REPLACE INTO CPG_config VALUES ('default_file_mode', '0666');\n"; } // Update table prefix $sql_query = preg_replace('/CPG_/', $_POST['table_prefix'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { if (!mysql_query($q)) { $errors .= "mySQL Error: " . mysql_error() . " on query '{$q}'<br /><br />"; return; } } }
function update_tables() { global $errors, $CONFIG, $lang_update_php, $lang_common, $LINEBREAK, $help; global $update_icon, $ok_icon, $already_done_icon, $error_icon, $file_system_icon; $loopCounter = 0; $cellStyle = ''; $superCage = Inspekt::makeSuperCage(); $db_update = 'sql/update.sql'; $sql_query = fread(fopen($db_update, 'r'), filesize($db_update)); // Update table prefix $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); $sql_query = array_map('trim', $sql_query); echo <<<EOT <tr> <td class="tableh1" colspan="2"> {$update_icon}{$lang_update_php['performing_database_updates']}{$help} </td> </tr> EOT; foreach ($sql_query as $q) { $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $loopCounter++; echo '<tr>' . $LINEBREAK . ' <td width="80%" class="' . $cellStyle . '">' . $q; /** * Determining if the Alter Table actually made a change * to properly reflect it's status on the update page. */ if (strpos(strtolower($q), 'alter table') !== false) { $query = explode(' ', $q); $result = mysql_query("DESCRIBE " . $query[2]); $description = array(); while ($row = mysql_fetch_row($result)) { $description[] = $row; } $result = @mysql_query($q); $affected = mysql_affected_rows(); $warnings = mysql_query('SHOW WARNINGS'); $result = mysql_query("DESCRIBE " . $query[2]); $description2 = array(); while ($row = mysql_fetch_row($result)) { $description2[] = $row; } if ($description == $description2) { $affected = 0; } } else { $result = @mysql_query($q); $affected = mysql_affected_rows(); $warnings = mysql_query('SHOW WARNINGS;'); } if ($superCage->get->keyExists('debug')) { echo '<hr />Debug output:<br />'; if ($affected > -1) { echo "Rows Affected: " . $affected . ". "; } if ($warnings) { while ($warning = mysql_fetch_row($warnings)) { if ($warning[0] != '') { $warning_text = 'MySQL said: '; } else { $warning_text = ''; } echo $warning_text . '<tt class="code">' . $warning[0] . ' (' . $warning[1] . ') ' . $warning[2] . '</tt><br />'; } } } echo '</td>' . $LINEBREAK; // end the table cell that contains the output if ($result && $affected) { echo ' <td width="20%" class="' . $cellStyle . ' updatesOK">' . $ok_icon . $lang_common['ok'] . '</td>' . $LINEBREAK; } else { echo ' <td width="20%" class="' . $cellStyle . ' updatesFail">' . $already_done_icon . $lang_update_php['already_done'] . '</td>' . $LINEBREAK; } echo '</tr>' . $LINEBREAK; } // end foreach loop // Check password encryption and perform the conversion if applicable $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $loopCounter++; echo <<<EOT <tr> <td class="{$cellStyle}"> {$lang_update_php['password_encryption']}: </td> EOT; $CONFIG['enable_encrypted_passwords'] = cpg_get_config_value('enable_encrypted_passwords'); if ($CONFIG['enable_encrypted_passwords'] != '1') { echo <<<EOT <td class="{$cellStyle} updatesOK"> {$ok_icon}{$lang_common['ok']} </td> </tr> EOT; $result = mysql_query("update {$CONFIG['TABLE_PREFIX']}users set user_password=md5(user_password);"); if ($CONFIG['enable_encrypted_passwords'] === '0') { $result = mysql_query("update {$CONFIG['TABLE_PREFIX']}config set value = '1' WHERE name = 'enable_encrypted_passwords'"); } else { $result = mysql_query("INSERT INTO {$CONFIG['TABLE_PREFIX']}config ( `name` , `value` ) VALUES ('enable_encrypted_passwords', '1')"); } } else { echo <<<EOT <td class="{$cellStyle} updatesFail"> {$already_done_icon}{$lang_update_php['already_done']} </td> </tr> EOT; } // Check album password encryption and perform the conversion if applicable $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $loopCounter++; echo <<<EOT <tr> <td class="{$cellStyle}"> {$lang_update_php['alb_password_encryption']}: </td> EOT; $CONFIG['enable_encrypted_alb_passwords'] = cpg_get_config_value('enable_encrypted_alb_passwords'); if ($CONFIG['enable_encrypted_alb_passwords'] != 1) { echo <<<EOT <td class="{$cellStyle} updatesOK"> {$ok_icon}{$lang_common['ok']} </td> </tr> EOT; // Encrypt the album password but only for those albums which have a password assigned. $result = mysql_query("update {$CONFIG['TABLE_PREFIX']}albums set alb_password=md5(alb_password) WHERE alb_password IS NOT NULL AND alb_password != '';"); if ($CONFIG['enable_encrypted_alb_passwords'] != NULL) { $result = mysql_query("update {$CONFIG['TABLE_PREFIX']}config set value = 1 WHERE name = 'enable_encrypted_alb_passwords'"); } else { $result = mysql_query("INSERT INTO {$CONFIG['TABLE_PREFIX']}config ( `name` , `value` ) VALUES ('enable_encrypted_alb_passwords', '1')"); } } else { echo <<<EOT <td class="{$cellStyle} updatesFail"> {$already_done_icon}{$lang_update_php['already_done']} </td> </tr> EOT; } // Check category tree modifications $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $loopCounter++; echo <<<EOT <tr> <td class="{$cellStyle}"> {$lang_update_php['category_tree']}: </td> EOT; if (check_rebuild_tree()) { echo <<<EOT <td class="{$cellStyle} updatesOK"> {$ok_icon}{$lang_common['ok']} </td> </tr> EOT; } else { echo <<<EOT <td class="{$cellStyle} updatesFail"> {$already_done_icon}{$lang_update_php['already_done']} </td> </tr> EOT; } }
function run_dumpfile() { global $CONF, $FDAT, $conn, $default_data_files, $install, $skip_html; # connect to database based on # connect data given in form if ($_POST["update_user"] != '' || $_POST["update_passwd"] != '') { # veakontroll : juurde error $conn = 0; dbconnect(1, $_POST["update_user"], $_POST["update_passwd"], $CONF["db"]); } elseif ($CONF["user"] != '' || $CONF["passwd"] != '') { $conn = 0; dbconnect(1, $CONF["user"], $CONF["passwd"], $CONF["db"]); } else { print "<font color=red>Error: DB user name and password were empty!</font><br />"; exit; } # if dump-file is given, upload it $uploadfile = $_FILES["data_file"]; if ($uploadfile["name"] != '') { $default_data_files = array(); array_push($default_data_files, $uploadfile["tmp_name"]); # $filename = $uploadfile["name"]; } foreach ($default_data_files as $file) { if ($uploadfile["name"] != '') { $filename = $uploadfile["name"]; } else { $filename = $file; } if (file_exists($file)) { if ($fd = fopen($file, "r")) { $sql = fread($fd, filesize($file)); fclose($fd); } else { echo "<font color=red>Can't open data file \"<b>" . $filename . "</b>\" - access denied</font><br />"; $error = 1; } } else { echo "<font color=red>Can't open data file \"<b>" . $filename . "</b>\" - not found</font><br />"; $error = 1; } ############ # if there is smth in file if ($sql) { $pieces = split_sql_file($sql, ';'); // now $sql is an array of all sql directives to launch $i = 1; if (!$skip_html) { # display HTML output echo "Running SQL file '" . $file . "'...<br>"; echo "<script>document.getElementById('listing').scrollTop = document.getElementById('listing').scrollHeight - 500;</script>"; flush(); usleep(500000); } # if display HTML output foreach ($pieces as $query) { if (!$skip_html) { # display HTML output if ($i % 1000 == 0 || $i == 1) { flush(); usleep(500000); $tbl_is_begun = 1; } # print 1 dot for each 10 queries - only for install if ($i % 10 == 0 && $install) { print ". "; flush(); } } # if display HTML output $sth = new SQL($query); if ($sth->error) { print "<font color=red>Error: " . $sth->error . "</font><br>"; $error = 1; } $i++; } // if( ! $skip_html) { # display HTML output // } # if display HTML output } # if sql ################# # if update, find php-script file name and run it if (!$install) { $script_filename = substr($filename, 0, -4) . ".php"; $error = run_scriptfile($script_filename); } } # foreach return $error; }
function annotate_page_start() { global $CONFIG, $lang_meta_album_names, $valid_meta_albums; require_once './plugins/annotate/init.inc.php'; $annotate_init_array = annotate_initialize(); $lang_plugin_annotate = $annotate_init_array['language']; $annotate_icon_array = $annotate_init_array['icon']; $superCage = Inspekt::MakeSuperCage(); $note = $superCage->get->keyExists('note') ? $superCage->get->getRaw('note') : $superCage->cookie->getRaw($CONFIG['cookie_name'] . 'note'); $lang_meta_album_names['lastnotes'] = $lang_plugin_annotate['lastnotes']; $lang_meta_album_names['shownotes'] = $lang_plugin_annotate['shownotes'] . " '{$note}'"; $valid_meta_albums[] = 'lastnotes'; $valid_meta_albums[] = 'shownotes'; $superCage = Inspekt::makeSuperCage(); if ($superCage->get->getAlpha('plugin') == "annotate" && $superCage->get->keyExists('delete_orphans')) { global $CONFIG; require_once './plugins/annotate/init.inc.php'; $annotate_init_array = annotate_initialize(); $lang_plugin_annotate = $annotate_init_array['language']; $annotate_icon_array = $annotate_init_array['icon']; load_template(); pageheader($lang_plugin_annotate['delete_orphaned_entries']); if (version_compare(cpg_phpinfo_mysql_version(), '4.1', '>=')) { // we can use subqueries here cpg_db_query("DELETE FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate WHERE pid NOT IN (SELECT pid FROM {$CONFIG['TABLE_PICTURES']})"); } else { $result = cpg_db_query("SELECT pid FROM {$CONFIG['TABLE_PICTURES']}"); $pids = array(); while ($row = mysql_fetch_row($result)) { $pids[] = $row[0]; } $pids = implode(",", $pids); mysql_free_result($result); // cpg_db_query can cause browser to crash if debug output is enabled mysql_query("DELETE FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate WHERE pid NOT IN ({$pids})"); } $count = mysql_affected_rows(); if ($count == 1) { $count_output = $lang_plugin_annotate['1_orphaned_entry_deleted']; } else { $count_output = sprintf($lang_plugin_annotate['x_orphaned_entries_deleted'], $count); } starttable('-1', $annotate_icon_array['delete'] . $lang_plugin_annotate['delete_orphaned_entries']); echo <<<EOT <tr> <td class="tableb"> {$count_output} </td> </tr> EOT; endtable(); pagefooter(); exit; } if ($superCage->get->getAlpha('plugin') == "annotate" && $superCage->get->keyExists('import')) { global $CONFIG; require_once './plugins/annotate/init.inc.php'; $annotate_init_array = annotate_initialize(); $lang_plugin_annotate = $annotate_init_array['language']; $annotate_icon_array = $annotate_init_array['icon']; load_template(); pageheader($lang_plugin_annotate['import']); starttable('-1', $annotate_icon_array['import'] . $lang_plugin_annotate['import']); if ($superCage->get->keyExists('do') && $CONFIG['plugin_annotate_import'] != "1") { if (!mysql_query("SELECT user_time FROM {$CONFIG['TABLE_PREFIX']}notes")) { cpg_db_query("INSERT INTO {$CONFIG['TABLE_PREFIX']}plugin_annotate (pid, posx, posy, width, height, note, user_id, user_time) \n SELECT pid, posx, posy, width, height, note, user_id, UNIX_TIMESTAMP() FROM {$CONFIG['TABLE_PREFIX']}notes"); } else { cpg_db_query("INSERT INTO {$CONFIG['TABLE_PREFIX']}plugin_annotate (pid, posx, posy, width, height, note, user_id, user_time) \n SELECT pid, posx, posy, width, height, note, user_id, user_time FROM {$CONFIG['TABLE_PREFIX']}notes"); } echo '<tr><td class="tableb">' . sprintf($lang_plugin_annotate['import_success'], mysql_affected_rows()) . '</td></tr>'; cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} (name, value) VALUES ('plugin_annotate_import', '1')"); } else { $notes_to_import = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PREFIX']}notes"), 0); if (!$notes_to_import) { echo '<tr><td class="tableb">' . sprintf($lang_plugin_annotate['import_found'], $notes_to_import) . '</td></tr>'; } elseif ($CONFIG['plugin_annotate_import'] == "1") { echo '<tr><td class="tableb">' . $lang_plugin_annotate['imported_already'] . '</td></tr>'; } else { echo '<tr><td class="tableb">' . sprintf($lang_plugin_annotate['import_found'], $notes_to_import) . ' <a href="index.php?plugin=annotate&import&do" class="admin_menu">' . $lang_plugin_annotate['import'] . '</a></td></tr>'; } } endtable(); pagefooter(); exit; } if ($superCage->get->getAlpha('plugin') == "annotate" && $superCage->get->keyExists('update_database')) { global $CONFIG; require_once './plugins/annotate/init.inc.php'; $annotate_init_array = annotate_initialize(); $lang_plugin_annotate = $annotate_init_array['language']; $annotate_icon_array = $annotate_init_array['icon']; load_template(); pageheader($lang_plugin_annotate['update_database']); require 'include/sql_parse.php'; $db_schema = './plugins/annotate/update.sql'; $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema)); $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $q) { @mysql_query($q); } starttable('-1', $annotate_icon_array['update_database'] . $lang_plugin_annotate['update_database']); echo <<<EOT <tr> <td class="tableb"> {$lang_plugin_annotate['update_database_success']} </td> </tr> EOT; endtable(); pagefooter(); exit; } if ($superCage->get->getAlpha('plugin') == "annotate" && $superCage->get->keyExists('manage')) { if (!GALLERY_ADMIN_MODE) { return; } global $CONFIG; require_once './plugins/annotate/init.inc.php'; $annotate_init_array = annotate_initialize(); $lang_plugin_annotate = $annotate_init_array['language']; $annotate_icon_array = $annotate_init_array['icon']; load_template(); if ($superCage->post->keyExists('submit')) { if (!checkFormToken()) { global $lang_errors; cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } if ($superCage->get->keyExists('batch_rename')) { if (strlen($superCage->post->getRaw('note_new')) < 1) { header("Location: index.php?plugin=annotate&manage&batch_rename&status=0¬e_old=" . $superCage->post->getRaw('note_old') . "¬e_new=" . $superCage->post->getRaw('note_new')); } else { cpg_db_query("UPDATE {$CONFIG['TABLE_PREFIX']}plugin_annotate SET note = '" . addslashes(addslashes($superCage->post->getRaw('note_new'))) . "' WHERE note = '" . addslashes(addslashes($superCage->post->getRaw('note_old'))) . "'"); header("Location: index.php?plugin=annotate&manage&batch_rename&status=1¬e_old=" . $superCage->post->getRaw('note_old') . "¬e_new=" . $superCage->post->getRaw('note_new')); } } if ($superCage->get->keyExists('batch_delete')) { cpg_db_query("DELETE FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate WHERE note = '" . addslashes(addslashes($superCage->post->getRaw('note_old'))) . "'"); header("Location: index.php?plugin=annotate&manage&batch_delete&status=1¬e_old=" . $superCage->post->getRaw('note_old')); } } pageheader($lang_plugin_annotate['manage']); if ($superCage->get->keyExists('batch_rename')) { starttable("100%", $lang_plugin_annotate['batch_rename']); } elseif ($superCage->get->keyExists('batch_delete')) { starttable("100%", $lang_plugin_annotate['batch_delete']); } else { starttable("100%", $lang_plugin_annotate['manage']); } if ($superCage->post->keyExists('sure')) { if ($superCage->get->keyExists('batch_rename')) { global $lang_common; $note_new = $superCage->post->getRaw('note_new'); if (strlen($note_new) < 1) { echo '<tr><td class="tableb">' . $lang_plugin_annotate['note_empty'] . ' <a href="javascript:history.back();">' . $lang_common['back'] . '</a></td></tr>'; endtable(); pagefooter(); die; } list($timestamp, $form_token) = getFormToken(); echo ' <tr><td class="tableb"> <form method="post" action="index.php?plugin=annotate&manage&batch_rename"> ' . sprintf($lang_plugin_annotate['sure_rename'], $superCage->post->getRaw('note_old'), $note_new) . ' <input type="hidden" name="note_old" class="textinput" value="' . $superCage->post->getRaw('note_old') . '" readonly="readonly"> <input type="hidden" name="note_new" class="textinput" value="' . $note_new . '" readonly="readonly"> <input type="hidden" name="form_token" value="' . $form_token . '" /> <input type="hidden" name="timestamp" value="' . $timestamp . '" /> <input type="submit" name="submit" class="button" value="' . $lang_common['go'] . '"> <a href="javascript:history.back();">' . $lang_common['back'] . '</a> </form> </td></tr> '; } if ($superCage->get->keyExists('batch_delete')) { global $lang_common; list($timestamp, $form_token) = getFormToken(); echo ' <tr><td class="tableb"> <form method="post" action="index.php?plugin=annotate&manage&batch_delete"> ' . sprintf($lang_plugin_annotate['sure_delete'], $superCage->post->getRaw('note_old')) . ' <input type="hidden" name="note_old" class="textinput" value="' . $superCage->post->getRaw('note_old') . '" readonly="readonly"> <input type="hidden" name="form_token" value="' . $form_token . '" /> <input type="hidden" name="timestamp" value="' . $timestamp . '" /> <input type="submit" name="submit" class="button" value="' . $lang_common['go'] . '"> <a href="javascript:history.back();">' . $lang_common['back'] . '</a> </form> </td></tr> '; } } if (!$superCage->post->keyExists('note_old')) { if ($superCage->get->keyExists('status')) { if ($superCage->get->keyExists('batch_rename')) { if ($superCage->get->getInt('status') == 1) { echo '<tr><td class="tableb">' . sprintf($lang_plugin_annotate['rename_success'], $superCage->get->getRaw('note_old'), $superCage->get->getRaw('note_new')) . ' </td></tr>'; } if ($superCage->get->getInt('status') == 0) { echo '<tr><td class="tableb">"' . sprintf($lang_plugin_annotate['rename_fail'], $superCage->get->getRaw('note_old'), $superCage->get->getRaw('note_new')) . '. ' . $lang_plugin_annotate['note_empty'] . '</td></tr>'; } } if ($superCage->get->keyExists('batch_delete') && $superCage->get->getInt('status') == 1) { echo '<tr><td class="tableb">' . sprintf($lang_plugin_annotate['delete_success'], $superCage->get->getRaw('note_old'), $superCage->get->getRaw('note_new')) . ' </td></tr>'; } } if ($superCage->get->keyExists('note')) { if ($superCage->get->keyExists('batch_rename')) { global $lang_common; echo ' <tr><td class="tableb"> <form method="post"> <input type="text" name="note_old" size="40" class="textinput" value="' . $superCage->get->getRaw('note') . '" readonly="readonly"> ' . $lang_plugin_annotate['rename_to'] . ' <input type="text" name="note_new" size="40" class="textinput" id="note_new"> <input type="submit" name="sure" class="button" value="' . $lang_common['go'] . '"> </form> <script type="text/javascript"> document.getElementById("note_new").select(); </script> </td></tr> '; } if ($superCage->get->keyExists('batch_delete')) { global $lang_common; echo ' <tr><td class="tableb"> <form method="post"> ' . $lang_common['delete'] . ' <input type="text" name="note_old" class="textinput" value="' . $superCage->get->getRaw('note') . '" readonly="readonly"> <input type="submit" name="sure" class="button" value="' . $lang_common['go'] . '"> </form> </td></tr> '; } } $result = cpg_db_query("SELECT DISTINCT(note) FROM {$CONFIG['TABLE_PREFIX']}plugin_annotate ORDER BY note"); if (mysql_num_rows($result)) { $person_array = array(); while ($row = mysql_fetch_assoc($result)) { $person_array[] = stripslashes($row['note']); } echo '<tr><td class="tableb" align="left">'; for ($i = 0; $i < count($person_array); $i++) { $note = str_replace(array("#", "&"), array("%23", "%26"), $person_array[$i]); echo "\n <a href=\"index.php?plugin=annotate&manage&batch_delete&note={$note}\" title=\"{$lang_plugin_annotate['batch_delete']}\"><img src=\"images/icons/delete.png\" border=\"0\" /></a>\n <a href=\"index.php?plugin=annotate&manage&batch_rename&note={$note}\" title=\"{$lang_plugin_annotate['batch_rename']}\"><img src=\"images/icons/edit.png\" border=\"0\" /></a>\n {$person_array[$i]}<br />\n "; } echo '</td></tr>'; } mysql_free_result($result); } endtable(); pagefooter(); exit; } }
for ($i = 0; $i < sizeof($sql_query); $i++) { if (trim($sql_query[$i]) != '') { if (!($result = $db->sql_query($sql_query[$i]))) { $error = $db->sql_error(); page_header($lang['Install'], ''); page_error($lang['Installer_Error'], $lang['Install_db_error'] . '<br />' . $error['message']); page_footer(); exit; } } } // Ok tables have been built, let's fill in the basic information $sql_query = @fread(@fopen($dbms_basic, 'r'), @filesize($dbms_basic)); $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query); $sql_query = $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter_basic); for ($i = 0; $i < sizeof($sql_query); $i++) { if (trim($sql_query[$i]) != '') { if (!($result = $db->sql_query($sql_query[$i]))) { $error = $db->sql_error(); page_header($lang['Install'], ''); page_error($lang['Installer_Error'], $lang['Install_db_error'] . '<br />' . $error['message']); page_footer(); exit; } } } } // Ok at this point they have entered their admin password, let's go // ahead and create the admin account with some basic default information // that they can customize later, and write out the config file. After
foreach ($mysql_access_host_array as $mysql_access_host) { $db_root->query('GRANT ALL PRIVILEGES ON `' . $db_root->escape(str_replace('`', '', $mysql_database)) . "`.* TO '" . $db_root->escape($mysql_unpriv_user) . "'@'" . $db_root->escape($mysql_access_host) . "' IDENTIFIED BY 'password'"); $db_root->query("SET PASSWORD FOR '" . $db_root->escape($mysql_unpriv_user) . "'@'" . $db_root->escape($mysql_access_host) . "' = PASSWORD('" . $db_root->escape($mysql_unpriv_pass) . "')"); } $db_root->query('FLUSH PRIVILEGES;'); $mysql_access_host = implode(',', $mysql_access_host_array); status_message('green', 'OK'); //now a new database and the new syscp-unprivileged-mysql-account have been created and we can fill it now with the data. status_message('begin', $lng['install']['testing_new_db']); $db = new db($mysql_host, $mysql_unpriv_user, $mysql_unpriv_pass, $mysql_database); status_message('green', 'OK'); status_message('begin', $lng['install']['importing_data']); $db_schema = './syscp.sql'; $sql_query = @file_get_contents($db_schema, 'r'); $sql_query = remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); for ($i = 0; $i < sizeof($sql_query); ++$i) { if (trim($sql_query[$i]) != '') { $result = $db->query($sql_query[$i]); } } status_message('green', 'OK'); status_message('begin', 'System Servername...'); if (validate_ip($_SERVER['SERVER_NAME'], true) !== false) { status_message('red', $lng['install']['servername_should_be_fqdn']); } else { status_message('green', 'OK'); } //now let's change the settings in our settings-table status_message('begin', $lng['install']['changing_data']); $db->query('UPDATE `' . TABLE_PANEL_SETTINGS . "` SET `value` = 'admin@" . $db->escape($servername) . "' WHERE `settinggroup` = 'panel' AND `varname` = 'adminmail'");
/** * Load the contents of the schema into the database and then alter it based on what has been input during the installation */ function load_schema($mode, $sub) { global $db, $lang, $template, $phpbb_root_path, $phpEx; $this->page_title = $lang['STAGE_CREATE_TABLE']; $s_hidden_fields = ''; // Obtain any submitted data $data = $this->get_submitted_data(); if ($data['dbms'] == '') { // Someone's been silly and tried calling this page direct // So we send them back to the start to do it again properly $this->p_master->redirect("index.$phpEx?mode=install"); } // HTTP_HOST is having the correct browser url in most cases... $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER'); // HTTP HOST can carry a port number... if (strpos($server_name, ':') !== false) { $server_name = substr($server_name, 0, strpos($server_name, ':')); } $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name; // Try to come up with the best solution for cookie domain... if (strpos($cookie_domain, 'www.') === 0) { $cookie_domain = str_replace('www.', '.', $cookie_domain); } // If we get here and the extension isn't loaded it should be safe to just go ahead and load it $available_dbms = get_available_dbms($data['dbms']); if (!isset($available_dbms[$data['dbms']])) { // Someone's been silly and tried providing a non-existant dbms $this->p_master->redirect("index.$phpEx?mode=install"); } $dbms = $available_dbms[$data['dbms']]['DRIVER']; // Load the appropriate database class if not already loaded include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); // Instantiate the database $db = new $sql_db(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. $db->sql_return_on_error(true); // If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;) if ($data['dbms'] == 'mysql') { if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) { $available_dbms[$data['dbms']]['SCHEMA'] .= '_41'; } else { $available_dbms[$data['dbms']]['SCHEMA'] .= '_40'; } } // Ok we have the db info go ahead and read in the relevant schema // and work on building the table $dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql'; // How should we treat this schema? $remove_remarks = $available_dbms[$data['dbms']]['COMMENTS']; $delimiter = $available_dbms[$data['dbms']]['DELIM']; $sql_query = @file_get_contents($dbms_schema); $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter); foreach ($sql_query as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } unset($sql_query); // Ok tables have been built, let's fill in the basic information $sql_query = file_get_contents('schemas/schema_data.sql'); // Deal with any special comments switch ($data['dbms']) { case 'mssql': case 'mssql_odbc': $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query); break; case 'postgres': $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query); break; } // Change prefix $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); // Change language strings... $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query); // Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } unset($sql_query); $current_time = time(); $user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; if ($data['script_path'] !== '/') { // Adjust destination path (no trailing slash) if (substr($data['script_path'], -1) == '/') { $data['script_path'] = substr($data['script_path'], 0, -1); } $data['script_path'] = str_replace(array('../', './'), '', $data['script_path']); if ($data['script_path'][0] != '/') { $data['script_path'] = '/' . $data['script_path']; } } // Set default config and post data, this applies to all DB's $sql_ary = array( 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) VALUES ('board_startdate', '$current_time')", 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['img_imagick']) . "' WHERE config_name = 'img_imagick'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_name']) . "' WHERE config_name = 'server_name'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_port']) . "' WHERE config_name = 'server_port'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['board_email1']) . "' WHERE config_name = 'board_email'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['board_email1']) . "' WHERE config_name = 'board_contact'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($cookie_domain) . "' WHERE config_name = 'cookie_domain'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "' WHERE config_name = 'default_dateformat'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['email_enable']) . "' WHERE config_name = 'email_enable'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "' WHERE config_name = 'smtp_delivery'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_host']) . "' WHERE config_name = 'smtp_host'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "' WHERE config_name = 'smtp_auth_method'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_user']) . "' WHERE config_name = 'smtp_username'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "' WHERE config_name = 'smtp_password'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "' WHERE config_name = 'cookie_secure'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "' WHERE config_name = 'force_server_vars'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['script_path']) . "' WHERE config_name = 'script_path'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_protocol']) . "' WHERE config_name = 'server_protocol'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['admin_name']) . "' WHERE config_name = 'newest_username'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . md5(mt_rand()) . "' WHERE config_name = 'avatar_salt'", 'UPDATE ' . $data['table_prefix'] . "users SET username = '******'admin_name']) . "', user_password='******'admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . $db->sql_escape(phpbb_email_hash($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "' WHERE username = '******'", 'UPDATE ' . $data['table_prefix'] . "moderator_cache SET username = '******'admin_name']) . "' WHERE username = '******'", 'UPDATE ' . $data['table_prefix'] . "forums SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' WHERE forum_last_poster_name = 'Admin'", 'UPDATE ' . $data['table_prefix'] . "topics SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' WHERE topic_first_poster_name = 'Admin' OR topic_last_poster_name = 'Admin'", 'UPDATE ' . $data['table_prefix'] . "users SET user_regdate = $current_time", 'UPDATE ' . $data['table_prefix'] . "posts SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'", 'UPDATE ' . $data['table_prefix'] . "topics SET topic_time = $current_time, topic_last_post_time = $current_time", 'UPDATE ' . $data['table_prefix'] . "forums SET forum_last_post_time = $current_time", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "' WHERE config_name = 'dbms_version'", ); if (@extension_loaded('gd') || can_load_dll('gd')) { $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = 'phpbb_captcha_gd' WHERE config_name = 'captcha_plugin'"; $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '1' WHERE config_name = 'captcha_gd'"; } $ref = substr($referer, strpos($referer, '://') + 3); if (!(stripos($ref, $server_name) === 0)) { $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '0' WHERE config_name = 'referer_validation'"; } // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. $cookie_name = 'phpbb3_'; $rand_str = md5(mt_rand()); $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); $rand_str = substr($rand_str, 0, 5); $cookie_name .= strtolower($rand_str); $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($cookie_name) . "' WHERE config_name = 'cookie_name'"; foreach ($sql_ary as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } $submit = $lang['NEXT_STEP']; $url = $this->p_master->module_url . "?mode=$mode&sub=final"; $template->assign_vars(array( 'BODY' => $lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $submit, 'S_HIDDEN' => build_hidden_fields($data), 'U_ACTION' => $url, )); }
function parse_sql_queries($sql_text) { //split in array of sql strings $sql_instructions = array(); split_sql_file($sql_instructions, $sql_text); //execute the sql instructions $count = count($sql_instructions); for ($i = 0; $i < $count; $i++) { $this_sql_query = $sql_instructions[$i]['query']; //UTF8 fix see #5678 if (strpos(strtolower($this_sql_query), 'create table') === false) { iDatabase::query($this_sql_query); } else { //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1); $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; iDatabase::query($this_sql_query); } } }