Ejemplo n.º 1
0
$mode = isset($_POST['mode']) ? $_POST['mode'] : '';
if ($mode == 'restore1') {
    if (isset($_POST['textarea']) && !empty($_POST['textarea'])) {
        $source = trim($_POST['textarea']);
        $_SESSION['textarea'] = $source . "\n";
    } else {
        $source = file_get_contents($_FILES['sqlfile']['tmp_name']);
    }
    import_sql($source);
    header('Location: index.php?r=9&a=93');
    exit;
} elseif ($mode == 'restore2') {
    $path = $modx->config['snapshot_path'] . $_POST['filename'];
    if (file_exists($path)) {
        $source = file_get_contents($path);
        import_sql($source);
        if (headers_sent()) {
            echo "<script>document.location.href='index.php?r=9&a=93';</script>\n";
        } else {
            header("Location: index.php?r=9&a=93");
        }
    }
    exit;
} elseif ($mode == 'backup') {
    $tables = isset($_POST['chk']) ? $_POST['chk'] : '';
    if (!is_array($tables)) {
        $modx->webAlertAndQuit("Please select a valid table from the list below.");
    }
    /*
     * Code taken from Ralph A. Dahlgren MySQLdumper Snippet - Etomite 0.6 - 2004-09-27
     * Modified by Raymond 3-Jan-2005
Ejemplo n.º 2
0
 case 4:
     //开始导入数据库文件 1
     define('IN_WZ', true);
     import_sql(1);
     echo '4';
     break;
 case 5:
     //开始导入数据库文件 2
     define('IN_WZ', true);
     import_sql(2);
     echo '5';
     break;
 case 6:
     //开始导入数据库文件 3
     define('IN_WZ', true);
     import_sql(3);
     echo '6';
     break;
 case 7:
     //开始初始化数据
     define('IN_WZ', true);
     $db = (include WWW_ROOT . 'configs/mysql_config.php');
     $db = $db['default'];
     $link = mysql_connect($db['dbhost'], $db['username'], $db['password']) or die('Not connected : ' . mysql_error());
     $version = mysql_get_server_info();
     mysql_query("SET NAMES '{$dbcharset}'", $link);
     if ($version > '5.0') {
         mysql_query("SET sql_mode=''");
     }
     mysql_select_db($db['dbname']);
     //插入管理员账号
Ejemplo n.º 3
0
         }
     }
     if ($queries == 0) {
         return false;
     }
     return true;
 }
 $mysql = new mysqli($sql, $sql_u, $sql_p, $db);
 if ($mysql->connect_errno) {
     die('Could not connect: ' . $mysql->connect_error);
 }
 $i = 1;
 $fNum = $_GET['sql'];
 if (is_numeric($fNum) && $fNum >= 0 && $fNum <= $_SESSION['fileCount']) {
     $file = "./SQL/" . $_SESSION['files'][$fNum];
     echo import_sql($file);
 } elseif ($fNum == "rename") {
     if (defined("DB_PREFIX")) {
         $tables = array();
         $rows = mysql_query("SHOW TABLES FROM {$db}");
         while ($row = mysql_fetch_array($rows)) {
             $tables[] = $row[0];
         }
         //Append and Rename all tables in a database
         foreach ($tables as $table) {
             $sql = 'RENAME TABLE ' . $table . ' TO ' . DB_PREFIX . $table;
             mysql_query($sql);
         }
     }
 } elseif ($fNum == "lock") {
     $fp = fopen("install.lock", 'w');
Ejemplo n.º 4
0
<?php

/* don't allow this page to be requested directly from browser */
if (!defined('QA_VERSION')) {
    header('Location: /');
    exit;
}
/* function for theme */
if (qa_opt('ra_installed') != true) {
    /* add some option when theme init first time */
    //create table for builder
    qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^builder (' . 'name VARCHAR (64) UNIQUE NOT NULL,' . 'content LONGTEXT' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8;');
    import_sql(DUDE_THEME_DIR . '/demo/builder_demo.sql');
    ra_opt('shortcodes', array('widget', 'ra_widget'));
    ra_opt('ra_installed', true);
    // update db, so that this code will not execute every time
}