function dump_database($next_ver) { global $db, $err, $prefix; include_once ROOT_PATH . 'admin/includes/cls_sql_dump.php'; require_once ROOT_PATH . 'upgrade/packages/' . $next_ver . '/dump_table.php'; /* 备份表为空时不作备份,返回真 */ if (empty($temp)) { return true; } @set_time_limit(300); $dump = new cls_sql_dump($db); $run_log = ROOT_PATH . 'data/sqldata/run.log'; $sql_file_name = $next_ver; $max_size = '2048'; $vol = 1; /* 变量验证 */ $allow_max_size = intval(@ini_get('upload_max_filesize')); //单位M if ($allow_max_size > 0 && $max_size > $allow_max_size * 1024) { $max_size = $allow_max_size * 1024; //单位K } if ($max_size > 0) { $dump->max_size = $max_size * 1024; } $tables = array(); foreach ($temp as $table) { $tables[$prefix . $table] = -1; } $dump->put_tables_list($run_log, $tables); /* 开始备份 */ $tables = $dump->dump_table($run_log, $vol); if ($tables === false) { $err->add($dump->errorMsg()); return false; } if (@file_put_contents(ROOT_PATH . 'data/sqldata/' . $sql_file_name . '.sql', $dump->dump_sql)) { return true; } else { return false; } }
$dump->max_size = $max_size * 1024; } /* 获取要备份数据列表 */ $type = empty($_POST['type']) ? '' : trim($_POST['type']); $tables = array(); switch ($type) { case 'full': $except = array($ecs->prefix . 'sessions', $ecs->prefix . 'sessions_data'); $temp = $db->GetCol("SHOW TABLES LIKE '" . mysql_like_quote($ecs->prefix) . "%'"); foreach ($temp as $table) { if (in_array($table, $except)) { continue; } $tables[$table] = -1; } $dump->put_tables_list($run_log, $tables); break; case 'stand': $temp = array('admin_user', 'area_region', 'article', 'article_cat', 'attribute', 'brand', 'cart', 'category', 'comment', 'goods', 'goods_attr', 'goods_cat', 'goods_gallery', 'goods_type', 'group_goods', 'link_goods', 'member_price', 'order_action', 'order_goods', 'order_info', 'payment', 'region', 'shipping', 'shipping_area', 'shop_config', 'user_address', 'user_bonus', 'user_rank', 'users', 'virtual_card'); foreach ($temp as $table) { $tables[$ecs->prefix . $table] = -1; } $dump->put_tables_list($run_log, $tables); break; case 'min': $temp = array('attribute', 'brand', 'cart', 'category', 'goods', 'goods_attr', 'goods_cat', 'goods_gallery', 'goods_type', 'group_goods', 'link_goods', 'member_price', 'order_action', 'order_goods', 'order_info', 'shop_config', 'user_address', 'user_bonus', 'user_rank', 'users', 'virtual_card'); foreach ($temp as $table) { $tables[$ecs->prefix . $table] = -1; } $dump->put_tables_list($run_log, $tables); break;