function initDataBaseConnection() { require_once './lib/class/AJAXChatMySQLiDataBase.php'; require_once './lib/class/AJAXChatMySQLDataBase.php'; require_once './lib/class/AJAXChatMySQLiQuery.php'; require_once './lib/class/AJAXChatMySQLQuery.php'; require_once './lib/class/AJAXChatDataBase.php'; // Create a new database object: global $db; $config = initConfig(); $db = new AJAXChatDataBase($config['dbConnection']); // Use a new database connection if no existing is given: if (!$config['dbConnection']['link']) { // Connect to the database server: $db->connect($config['dbConnection']); if ($db->error()) { echo $db->getError(); die; } // Select the database: $db->select($config['dbConnection']['name']); if ($db->error()) { echo $db->getError(); die; } } // Unset the dbConnection array for safety purposes: unset($config['dbConnection']); }
$dh = opendir('../data/' . $db_type); while (($file = readdir($dh)) !== false) { if ($file != "." && $file != "..") { $list[] = $file; } } echo json_encode(array('status' => 1, 'list' => $list)); } else { if ($act == 'insert') { $sql = "../data/" . $db_type . "/wst_" . $_POST['table'] . ".sql"; $sql = file_get_contents($sql); runquery($sql, $db_prefix); if (intval($_POST['isFinish']) == 1) { $sql = 'UPDATE ' . $db_prefix . 'staffs SET loginName="' . $admin_name . '",loginPwd="' . md5($admin_password . "9365") . '" WHERE staffId=1'; runquery($sql, $db_prefix); initConfig($db_host, $db_user, $db_pass, $db_prefix, $db_name); if (!file_exists(INSTALL_ROOT . "/Apps/Common/Conf/config.php")) { echo json_encode(array('status' => -1, 'msg' => '无法创建配置文件,请检查Apps/Common/Conf目录是否有写入权限!')); exit; } $counter_file = INSTALL_PATH . '/install.ok'; $fopen = fopen($counter_file, 'wb'); fputs($fopen, date('Y-m-d H:i:s')); fclose($fopen); if (file_exists(INSTALL_PATH . '/install.ok')) { echo json_encode(array('status' => 1)); exit; } else { echo json_encode(array('status' => -1, 'msg' => '无法创建配置文件,请检查Install目录是否有写入权限!')); exit; }
function convert($test, $template) { $TESTPLAN = array(); $OUTPUT = ""; $test["phases"] = isset($test["phases"]) ? $test["phases"] : array(); foreach ($test["phases"] as $phase) { $TESTPLAN[] = phase($phase, $output); if ($output) { ob_start(); var_dump($output); $OUTPUT .= ob_get_contents(); ob_end_clean(); $OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT); } } foreach ($test["tests"] as $phase) { $TESTPLAN[] = phase($phase, $output); if ($output) { ob_start(); var_dump($output); $OUTPUT .= ob_get_contents(); ob_end_clean(); $OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT); } } $replacements = array("%DSN%" => clientSetup($test), "%DESCRIPTION%" => description($test), "%INITCONFIG%" => initConfig($test), "%URLTYPE%" => $test["type"], "%TESTPLAN%" => join("\n\n", $TESTPLAN), "%OUTPUT%" => rtrim($OUTPUT)); return makeTest($replacements, $template); }