/** * 升级 * * @param resource $con 数据库连接 * @param string $dbname 数据库名 * @param integer $dbVersion 数据库版本 * @param integer $step 升级步骤 * @param string $dbprefix 数据库表前缀 * @return array array($result, $info, $target) * $result 创建结果 * $info 出错信息 * $target 出错目标 */ function upgrade($con, $dbname, $dbprefix = '', $dbVersion = null, $step = 1) { global $_CFG; if (!isset($dbVersion)) { $dbVersion = getDBVersion($con, $dbname, $dbprefix); } $step = isset($step) ? $step : 1; mysql_query('USE ' . $dbname, $con); mysql_query('SET NAMES UTF8;', $con); $result = 0; $info = ''; if (isset($_CFG['upgradeMap'][$dbVersion])) { $upgradeClazz = $_CFG['upgradeMap'][$dbVersion]; require 'upgrade/' . $upgradeClazz . '.php'; $upgradeObj = new $upgradeClazz($con, $dbname, $dbprefix, $dbprefix); list($result, $info, $nstep) = $upgradeObj->upgrade($step); if (1 == $step) { $info = $_CFG['upgradeMsg'][$dbVersion] . "\n" . $info; } $step = $nstep; if (0 == $step) { $dbVersion++; } } else { $result = 2; } return array($result, $info, $dbVersion, $step); }
$viewDir = dirname(__FILE__) . '/views/' . $lang . '/'; if (!is_dir($viewDir)) { $viewDir = dirname(__FILE__) . '/views/zh_cn/'; } switch ($action) { case CHECK: $viewFile = $viewDir . 'check.php'; $requirements = getRequirements(); $dirRights = getDirRights($paths); renderFile($viewFile, array('requirements' => $requirements, 'dirRights' => $dirRights, 'checkResult' => getCheckResult($requirements, $dirRights))); break; case BACKUP: $viewFile = $viewDir . 'upgrade.php'; list($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix) = getDBConfig(CONFIG_FILE); list($result, $info, $target, $con) = getDBCon($dbhost, $port, $dbuser, $dbpwd); $version = getDBVersion($con, $dbname, $dbprefix); if ($_CFG['version'] == $_CFG['versionMap'][$version]) { @mysql_close($con); header('Location: index.php?action=upgraded'); } if (isset($_GET['download'])) { if (!$result) { $dumpSql = backupDB($con, $dbname, $dbprefix); $compressSql = gzencode($dumpSql, 9); header('Content-type:application/text'); header('Content-Disposition:attachment;filename=bugfree.sql.gz'); echo $compressSql; break; } } renderFile($viewFile, array('version' => $version));
} else { if ($user->getLevel() == "2") { if (isset($_POST["id_account"])) { $id_account_current = $_POST["id_account"]; } else { $id_account_current = "1"; } } else { $id_account_current = $user->getIdAccount(); } $_SESSION["id_account_current"] = $id_account_current; } $cache_enabled = $config->getDefault("crawler.cache.type", "") != ""; ini_set('mongo.native_long', 0); //$isEnterprise = ($config->get("application.enterprise") == '1'); $db_version = getDBVersion($config); if (!empty($db_version)) { if (!isset($_SESSION["source_types"])) { $plugins_available = $config->getDefault("plugins.available", ""); $aplugins_available = array_map('trim', explode(',', $plugins_available)); $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_select($mg, "plugins"); $stmt->setQuery(array("type" => "cnx")); $stmt->setSort(array("name" => 1)); $count = $stmt->execute(); if ($count > 0) { $cursor = $stmt->getCursor(); while ($cursor->hasNext()) { $rs = $cursor->getNext(); $id = $rs["id"];