public static function getDaoImpl($linkConfig) { if (empty(self::$daoImpl)) { self::$daoImpl = new ms_new_mysql($linkConfig['db']['dbhost'], $linkConfig['db']['dbuser'], $linkConfig['db']['dbpw'], $linkConfig['db']['dbname'], $linkConfig['db']['tablepre'], $linkConfig['db']['dbcharset'], $linkConfig['db']['pconnect']); } return self::$daoImpl; }
<?php require_once "db.class.php"; $dbObj = new ms_new_mysql("210.43.79.196", "root", "123456", "judge", "", "utf-8", "0"); $LANG = array("GCC" => 1, "G++" => 2, "Pascal" => 3, "Java" => 4, "Python" => 5); $pid = $_POST['pid']; $language = $LANG[$_POST['language']]; $code = $_POST['code']; if (get_magic_quotes_gpc()) { $code = stripslashes($code); } $code = mysql_real_escape_string($code); //echo '<pre>'.$code.'</pre>'; $user_id = 07; $len = strlen($code); $ip = $_SERVER['REMOTE_ADDR']; if ($len > 65536) { echo "Code too long!<br>"; exit(0); } $tableName = "solution"; $info = array("problem_id" => $pid, "user_id" => $user_id, "in_date" => date("Y-m-d h:i:s"), "language" => $language, "ip" => $ip, "code_length" => $len); $dbObj->insert($tableName, $info); $tableName = "source_code"; $info = array("solution_id" => $dbObj->insertId(), "source" => $code); $dbObj->insert($tableName, $info); $statusURI = strstr($_SERVER['REQUEST_URI'], "submit", true) . "status.php"; header("Location: {$statusURI}");
<?php require_once "db.class.php"; $dbObj = new ms_new_mysql("210.43.79.196", "root", "123456", "judge", "", "utf-8", "0"); $sql = "SELECT * FROM `solution` WHERE problem_id>= 1000 ORDER BY `solution_id` DESC LIMIT 20"; $res = $dbObj->query($sql); $rows_cnt = mysql_num_rows($res); //echo '<pre>'.print_r(mysql_fetch_array($res)).'</pre>'; $RESULT = array(0 => "Accepted", 1 => "Presentation Error", 2 => "Time Limit Exceeded", 3 => "Memory Limit Exceeded", 4 => "Wrong Answer", 5 => "Runtime Error", 6 => "Output Limit Exceeded", 7 => "Complie Error", 8 => "System Error", 9 => "Security Error", 10 => "Unknown Error", 11 => "Waiting", 12 => "Running"); $LANG = array(1 => "GCC", 2 => "G++", 3 => "Pascal", 4 => "Java", 5 => "Python"); $view_status = array(); for ($i = 0; $i < $rows_cnt; $i++) { $row = mysql_fetch_array($res); $view_status[$i][0] = $row['solution_id']; $view_status[$i][1] = $row['problem_id']; $view_status[$i][2] = $row['user_id']; $view_status[$i][3] = $RESULT[$row['result']]; $view_status[$i][4] = $row['time']; $view_status[$i][5] = $row['memory']; $view_status[$i][6] = $LANG[$row['language']]; $view_status[$i][7] = '<a href=viewcode.php?sid=' . $row['solution_id'] . '>' . $row['code_length'] . '</a>'; $view_status[$i][8] = $row['in_date']; } ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>AcmSuperX</title>