Ejemplo n.º 1
0
 check_authz_json('all');
 /* 取得参数 */
 include_once ROOT_PATH . 'includes/cls_json.php';
 $json = new JSON();
 $config = $json->decode($_POST['JSON']);
 /* 测试连接数据库 */
 $sdb = new cls_mysql($config->host, $config->user, $config->pass, $config->db);
 /* 检查必需的表是否存在 */
 $sprefix = $config->prefix;
 $config->path = rtrim(str_replace('\\', '/', $config->path), '/');
 // 把斜线替换为反斜线,去掉结尾的反斜线
 include_once ROOT_PATH . 'includes/modules/convert/' . $config->code . '.php';
 $convert = new $config->code($sdb, $sprefix, $config->path);
 $required_table_list = $convert->required_tables();
 $sql = "SHOW TABLES";
 $table_list = $sdb->getCol($sql);
 $diff_arr = array_diff($required_table_list, $table_list);
 if ($diff_arr) {
     make_json_error(sprintf($_LANG['table_error'], join(',', $table_list)));
 }
 /* 检查源目录是否存在,是否可读 */
 $dir_list = $convert->required_dirs();
 foreach ($dir_list as $dir) {
     $cur_dir = $config->path . $dir;
     if (!file_exists($cur_dir) || !is_dir($cur_dir)) {
         make_json_error(sprintf($_LANG['dir_error'], $cur_dir));
     }
     if (file_mode_info($cur_dir) & 1 != 1) {
         make_json_error(sprintf($_LANG['dir_not_readable'], $cur_dir));
     }
     $res = check_files_readable($cur_dir);