Exemple #1
0
    }
    $action = "modifybackups";
}
if ($action == "restorebackup") {
    ob_start();
    @ob_implicit_flush(0);
    if (preg_match("/\\.gz\$/i", $file)) {
        readgzfile(ROOT_PATH . DATABASE_DIR . "/" . $file);
    } else {
        readfile(ROOT_PATH . DATABASE_DIR . "/" . $file);
    }
    $contents = ob_get_contents();
    ob_end_clean();
    $error_log = array();
    if (!empty($contents)) {
        $split_file = split_sql_dump($contents);
        foreach ($split_file as $sql) {
            $sql = trim($sql);
            if (!empty($sql) and $sql[0] != "#") {
                @set_time_limit(1200);
                if (!$site_db->query($sql)) {
                    $error_log[] = $sql;
                }
            }
        }
    }
    if (!empty($error_log)) {
        $msg = "<p><b>" . $lang['backup_restore_error'] . "</b></p>";
        $msg .= "<ol>";
        foreach ($error_log as $val) {
            $msg .= sprintf("<li>%s</li>", $val);
Exemple #2
0
 $error_msg = "";
 include ROOT_PATH . 'includes/db_' . strtolower($db_servertype) . '.php';
 $site_db = new Db($db_host, $db_user, $db_password, $db_name);
 if (!$site_db->connection) {
     $error_log[] = "No connection to database!";
 }
 //$site_db->no_error = 1;
 include ROOT_PATH . 'includes/db_utils.php';
 $db_file = ROOT_PATH . DATABASE_DIR . "/default/" . strtolower($db_servertype) . "_default.sql";
 $cont = @fread(@fopen($db_file, 'r'), @filesize($db_file));
 if (empty($cont)) {
     $error_log[] = "Could not load: " . $db_file;
 }
 if (empty($error_log)) {
     $cont = preg_replace('/4images_/', $table_prefix, $cont);
     $pieces = split_sql_dump($cont);
     for ($i = 0; $i < sizeof($pieces); $i++) {
         $sql = trim($pieces[$i]);
         if (!empty($sql) and $sql[0] != "#") {
             if (!$site_db->query($sql)) {
                 $error_log[] = $sql;
             }
         }
     }
     include ROOT_PATH . 'includes/security_utils.php';
     $admin_pass_hashed = salted_hash($admin_password);
     $current_time = time();
     $sql = "UPDATE " . $table_prefix . "users\n              SET user_name = '{$admin_user}', user_password = '******', user_joindate = {$current_time}, user_lastaction = {$current_time}, user_lastvisit = {$current_time}\n              WHERE user_name = 'admin'";
     if (!$site_db->query($sql)) {
         $error_log[] = $sql;
     }