diff --git a/uoj/1/app/controllers/add_contest.php b/uoj/1/app/controllers/add_contest.php
index 2f90a84..381ab70 100644
--- a/uoj/1/app/controllers/add_contest.php
+++ b/uoj/1/app/controllers/add_contest.php
@@ -39,9 +39,9 @@
$esc_name = $_POST['name'];
$esc_name = $purifier->purify($esc_name);
- $esc_name = mysql_real_escape_string($esc_name);
+ $esc_name = DB::escape($esc_name);
- mysql_query("insert into contests (name, start_time, last_min, status) values ('$esc_name', '$start_time_str', ${_POST['last_min']}, 'unfinished')");
+ DB::query("insert into contests (name, start_time, last_min, status) values ('$esc_name', '$start_time_str', ${_POST['last_min']}, 'unfinished')");
};
$time_form->succ_href="/contests";
$time_form->runAtServer();
@@ -53,4 +53,4 @@
$time_form->printHTML();
?>
-
+
\ No newline at end of file
diff --git a/uoj/1/app/controllers/change_user_info.php b/uoj/1/app/controllers/change_user_info.php
index 6bdb389..477754b 100644
--- a/uoj/1/app/controllers/change_user_info.php
+++ b/uoj/1/app/controllers/change_user_info.php
@@ -29,7 +29,7 @@
{
return "失败:无效电子邮箱。";
}
- $esc_email = mysql_real_escape_string($email);
+ $esc_email = DB::escape($email);
DB::update("update user_info set email = '$esc_email' where username = '{$myUser['username']}'");
if ($_POST['Qtag'])
@@ -39,7 +39,7 @@
{
return "失败:无效QQ。";
}
- $esc_qq = mysql_real_escape_string($qq);
+ $esc_qq = DB::escape($qq);
DB::update("update user_info set qq = '$esc_qq' where username = '{$myUser['username']}'");
}
else
@@ -47,7 +47,7 @@
if ($_POST['sex'] == "U" || $_POST['sex'] == 'M' || $_POST['sex'] == 'F')
{
$sex = $_POST['sex'];
- $esc_sex = mysql_real_escape_string($sex);
+ $esc_sex = DB::escape($sex);
DB::update("update user_info set sex = '$esc_sex' where username = '{$myUser['username']}'");
}
diff --git a/uoj/1/app/controllers/click_zan.php b/uoj/1/app/controllers/click_zan.php
index 45403f8..3b3058f 100644
--- a/uoj/1/app/controllers/click_zan.php
+++ b/uoj/1/app/controllers/click_zan.php
@@ -39,26 +39,26 @@
$cur = queryZanVal($id, $type, $myUser);
if ($cur != $delta) {
- $row = mysql_fetch_array(mysql_query("select zan from $table_name where id = $id"));
+ $row = DB::selectFirst("select zan from $table_name where id = $id");
if ($row == null) {
die('
failed
');
}
$cur += $delta;
if ($cur == 0) {
- mysql_query("delete from click_zans where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
+ DB::query("delete from click_zans where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
} else if ($cur != $delta) {
- mysql_query("update click_zans set val = '$cur' where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
+ DB::query("update click_zans set val = '$cur' where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
} else {
- mysql_query("insert into click_zans (username, type, target_id, val) values ('{$myUser['username']}', '$type', $id, $cur)");
+ DB::query("insert into click_zans (username, type, target_id, val) values ('{$myUser['username']}', '$type', $id, $cur)");
}
$cnt = $row['zan'] + $delta;
- mysql_query("update $table_name set zan = $cnt where id = $id");
+ DB::query("update $table_name set zan = $cnt where id = $id");
} else {
- $row = mysql_fetch_array(mysql_query("select zan from $table_name where id = $id"));
+ $row = DB::selectFirst("select zan from $table_name where id = $id");
if ($row == null) {
die('failed
');
}
$cnt = $row['zan'];
}
?>
-= getClickZanBlock($type, $id, $cnt, $cur) ?>
+= getClickZanBlock($type, $id, $cnt, $cur) ?>
\ No newline at end of file
diff --git a/uoj/1/app/controllers/contest_inside.php b/uoj/1/app/controllers/contest_inside.php
index ee54acd..fce485d 100644
--- a/uoj/1/app/controllers/contest_inside.php
+++ b/uoj/1/app/controllers/contest_inside.php
@@ -18,9 +18,9 @@
}
if (isset($_POST['check_notice'])) {
- $result = mysql_query("select * from contests_notice where contest_id = '${contest['id']}' order by time desc limit 1");
+ $result = DB::query("select * from contests_notice where contest_id = '${contest['id']}' order by time desc limit 1");
try {
- while ($row = mysql_fetch_array($result)) {
+ while ($row = DB::fetch($result)) {
if (new DateTime($row['time']) > new DateTime($_POST['last_time'])) {
die(json_encode(array('msg' => $row['title'] . ' : ' . $row['content'], 'time' => UOJTime::$time_now_str)));
}
@@ -44,18 +44,18 @@
$problems = array();
$prob_pos = array();
$n_problems = 0;
- $result = mysql_query("select problem_id from contests_problems where contest_id = ${contest['id']} order by problem_id");
- while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ $result = DB::query("select problem_id from contests_problems where contest_id = ${contest['id']} order by problem_id");
+ while ($row = DB::fetch($result, MYSQLI_NUM)) {
$prob_pos[$problems[] = (int)$row[0]] = $n_problems++;
}
$data = array();
if ($contest['cur_progress'] < CONTEST_FINISHED) {
- $result = mysql_query("select id, submit_time, submitter, problem_id, score from submissions where contest_id = {$contest['id']} and score is not null order by id");
+ $result = DB::query("select id, submit_time, submitter, problem_id, score from submissions where contest_id = {$contest['id']} and score is not null order by id");
} else {
- $result = mysql_query("select submission_id, date_add('{$contest['start_time_str']}', interval penalty second), submitter, problem_id, score from contests_submissions where contest_id = {$contest['id']}");
+ $result = DB::query("select submission_id, date_add('{$contest['start_time_str']}', interval penalty second), submitter, problem_id, score from contests_submissions where contest_id = {$contest['id']}");
}
- while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ while ($row = DB::fetch($result, MYSQLI_NUM)) {
$row[0] = (int)$row[0];
$row[3] = $prob_pos[$row[3]];
$row[4] = (int)$row[4];
@@ -63,8 +63,8 @@
}
$people = array();
- $result = mysql_query("select username, user_rating from contests_registrants where contest_id = {$contest['id']} and has_participated = 1");
- while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ $result = DB::query("select username, user_rating from contests_registrants where contest_id = {$contest['id']} and has_participated = 1");
+ while ($row = DB::fetch($result, MYSQLI_NUM)) {
$row[1] = (int)$row[1];
$people[] = $row;
}
@@ -137,8 +137,8 @@
$start_test_form = new UOJForm('start_test');
$start_test_form->handle = function() {
global $contest;
- $result = mysql_query("select id, problem_id, content from submissions where contest_id = {$contest['id']}");
- while ($submission = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ $result = DB::query("select id, problem_id, content from submissions where contest_id = {$contest['id']}");
+ while ($submission = DB::fetch($result, MYSQLI_ASSOC)) {
if (!isset($contest['extra_config']["problem_{$submission['problem_id']}"])) {
$content = json_decode($submission['content'], true);
if (isset($content['final_test_config'])) {
@@ -148,11 +148,11 @@
if (isset($content['first_test_config'])) {
unset($content['first_test_config']);
}
- $esc_content = mysql_real_escape_string(json_encode($content));
+ $esc_content = DB::escape(json_encode($content));
DB::update("update submissions set judge_time = NULL, result = '', score = NULL, status = 'Waiting Rejudge', content = '$esc_content' where id = {$submission['id']}");
}
}
- mysql_query("update contests set status = 'testing' where id = {$contest['id']}");
+ DB::query("update contests set status = 'testing' where id = {$contest['id']}");
};
$start_test_form->submit_button_config['class_str'] = 'btn btn-danger btn-block';
$start_test_form->submit_button_config['smart_confirm'] = '';
@@ -202,10 +202,10 @@ EOD;
EOD;
}
sendSystemMsg($user['username'], 'Rating变化通知', $content);
- mysql_query("update user_info set rating = {$ratings[$i]} where username = '{$standings[$i][2][0]}'");
- mysql_query("update contests_registrants set rank = {$standings[$i][3]} where contest_id = {$contest['id']} and username = '{$standings[$i][2][0]}'");
+ DB::query("update user_info set rating = {$ratings[$i]} where username = '{$standings[$i][2][0]}'");
+ DB::query("update contests_registrants set rank = {$standings[$i][3]} where contest_id = {$contest['id']} and username = '{$standings[$i][2][0]}'");
}
- mysql_query("update contests set status = 'finished' where id = {$contest['id']}");
+ DB::query("update contests set status = 'finished' where id = {$contest['id']}");
};
$publish_result_form->submit_button_config['class_str'] = 'btn btn-danger btn-block';
$publish_result_form->submit_button_config['smart_confirm'] = '';
@@ -412,7 +412,7 @@ EOD;
global $contest;
$title = DB::escape($_POST['title']);
$content = DB::escape($_POST['content']);
- mysql_query("insert into contests_notice (contest_id, title, content, time) values ('{$contest['id']}', '$title', '$content', now())");
+ DB::query("insert into contests_notice (contest_id, title, content, time) values ('{$contest['id']}', '$title', '$content', now())");
};
$post_notice->runAtServer();
@@ -520,4 +520,4 @@ EOD;
-
+
\ No newline at end of file
diff --git a/uoj/1/app/controllers/contest_manage.php b/uoj/1/app/controllers/contest_manage.php
index 9e07c9a..3949efd 100644
--- a/uoj/1/app/controllers/contest_manage.php
+++ b/uoj/1/app/controllers/contest_manage.php
@@ -60,9 +60,9 @@
function($type, $username) {
global $contest;
if ($type == '+') {
- mysql_query("insert into contests_permissions (contest_id, username) values (${contest['id']}, '$username')");
+ DB::query("insert into contests_permissions (contest_id, username) values (${contest['id']}, '$username')");
} else if ($type == '-') {
- mysql_query("delete from contests_permissions where contest_id = ${contest['id']} and username = '$username'");
+ DB::query("delete from contests_permissions where contest_id = ${contest['id']} and username = '$username'");
}
}
);
@@ -205,7 +205,7 @@
', '', $row_id, ' | ', '', getUserLink($row['username']), ' | ', '';
}
@@ -227,7 +227,7 @@
', '', $problem['id'], ' | ', '', getProblemLink($problem), ' ', "[$problem_config_str]", ' | ', '';
@@ -259,4 +259,4 @@
-
+
\ No newline at end of file
diff --git a/uoj/1/app/controllers/contest_members.php b/uoj/1/app/controllers/contest_members.php
index 4a4407f..6de75e2 100644
--- a/uoj/1/app/controllers/contest_members.php
+++ b/uoj/1/app/controllers/contest_members.php
@@ -16,7 +16,7 @@
$unregister_form = new UOJForm('unregister');
$unregister_form->handle = function() {
global $myUser, $contest;
- mysql_query("delete from contests_registrants where username = '{$myUser['username']}' and contest_id = {$contest['id']}");
+ DB::query("delete from contests_registrants where username = '{$myUser['username']}' and contest_id = {$contest['id']}");
updateContestPlayerNum($contest);
};
$unregister_form->submit_button_config['class_str'] = 'btn btn-danger btn-xs';
@@ -108,4 +108,4 @@
)
);
?>
-
+
\ No newline at end of file
diff --git a/uoj/1/app/controllers/contest_registration.php b/uoj/1/app/controllers/contest_registration.php
index 5206019..99c1a16 100644
--- a/uoj/1/app/controllers/contest_registration.php
+++ b/uoj/1/app/controllers/contest_registration.php
@@ -14,7 +14,7 @@
$register_form = new UOJForm('register');
$register_form->handle = function() {
global $myUser, $contest;
- mysql_query("insert into contests_registrants (username, user_rating, contest_id, has_participated) values ('{$myUser['username']}', {$myUser['rating']}, {$contest['id']}, 0)");
+ DB::query("insert into contests_registrants (username, user_rating, contest_id, has_participated) values ('{$myUser['username']}', {$myUser['rating']}, {$contest['id']}, 0)");
updateContestPlayerNum($contest);
};
$register_form->submit_button_config['class_str'] = 'btn btn-primary';
diff --git a/uoj/1/app/controllers/download.php b/uoj/1/app/controllers/download.php
index bf44d94..9ddf720 100644
--- a/uoj/1/app/controllers/download.php
+++ b/uoj/1/app/controllers/download.php
@@ -8,8 +8,8 @@
$visible = isProblemVisibleToUser($problem, $myUser);
if (!$visible && $myUser != null) {
- $result = mysql_query("select contest_id from contests_problems where problem_id = {$_GET['id']}");
- while (list($contest_id) = mysql_fetch_array($result, MYSQL_NUM)) {
+ $result = DB::query("select contest_id from contests_problems where problem_id = {$_GET['id']}");
+ while (list($contest_id) = DB::fetch($result, MYSQLI_NUM)) {
$contest = queryContest($contest_id);
genMoreContestInfo($contest);
if ($contest['cur_progress'] != CONTEST_NOT_STARTED && hasRegistered($myUser, $contest) && queryContestProblemRank($contest, $problem)) {
@@ -44,4 +44,4 @@
header("X-Sendfile: $file_name");
header("Content-type: $mimetype");
header("Content-Disposition: attachment; filename=$download_name");
-?>
+?>
\ No newline at end of file
diff --git a/uoj/1/app/controllers/hack.php b/uoj/1/app/controllers/hack.php
index 29fc0ac..27ff28e 100644
--- a/uoj/1/app/controllers/hack.php
+++ b/uoj/1/app/controllers/hack.php
@@ -23,7 +23,7 @@
$delete_form = new UOJForm('delete');
$delete_form->handle = function() {
global $hack;
- mysql_query("delete from hacks where id = {$hack['id']}");
+ DB::query("delete from hacks where id = {$hack['id']}");
};
$delete_form->submit_button_config['class_str'] = 'btn btn-danger';
$delete_form->submit_button_config['text'] = '删除此Hack';
diff --git a/uoj/1/app/controllers/judge/submit.php b/uoj/1/app/controllers/judge/submit.php
index 3016ed8..480bf79 100644
--- a/uoj/1/app/controllers/judge/submit.php
+++ b/uoj/1/app/controllers/judge/submit.php
@@ -42,7 +42,7 @@
$content['first_test_config'] = $content['config'];
$content['config'] = $content['final_test_config'];
unset($content['final_test_config']);
- $esc_content = mysql_real_escape_string(json_encode($content));
+ $esc_content = DB::escape(json_encode($content));
DB::update("update submissions set status = 'Judged, Waiting', content = '$esc_content' where id = ${_POST['id']}");
}
@@ -77,11 +77,11 @@
$ok = DB::update("update hacks set success = {$result['score']}, details = '$esc_details' where id = {$_POST['id']}");
if ($ok) {
- list($hack_input) = mysql_fetch_array(mysql_query("select input from hacks where id = {$_POST['id']}"), MYSQL_NUM);
+ list($hack_input) = DB::fetch(DB::query("select input from hacks where id = {$_POST['id']}"), MYSQLI_NUM);
unlink(UOJContext::storagePath().$hack_input);
if ($result['score']) {
- list($problem_id) = mysql_fetch_array(mysql_query("select problem_id from hacks where id = ${_POST['id']}"), MYSQL_NUM);
+ list($problem_id) = DB::selectFirst("select problem_id from hacks where id = ${_POST['id']}", MYSQLI_NUM);
if (validateUploadedFile('hack_input') && validateUploadedFile('std_output')) {
svnAddExtraTest(queryProblemBrief($problem_id), $_FILES["hack_input"]["tmp_name"], $_FILES["std_output"]["tmp_name"]);
} else {
@@ -209,4 +209,4 @@
}
echo json_encode($submission);
-?>
+?>
\ No newline at end of file
diff --git a/uoj/1/app/controllers/problem.php b/uoj/1/app/controllers/problem.php
index f5c1ecb..8544a9b 100644
--- a/uoj/1/app/controllers/problem.php
+++ b/uoj/1/app/controllers/problem.php
@@ -110,9 +110,9 @@
$result_json = json_encode($result);
if ($is_in_contest) {
- mysql_query("insert into submissions (problem_id, contest_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, ${contest['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', 0)");
+ DB::query("insert into submissions (problem_id, contest_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, ${contest['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', 0)");
} else {
- mysql_query("insert into submissions (problem_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', {$problem['is_hidden']})");
+ DB::query("insert into submissions (problem_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', {$problem['is_hidden']})");
}
}
function handleCustomTestUpload($zip_file_name, $content, $tot_size) {
@@ -262,4 +262,4 @@ $('#contest-countdown').countdown(= $contest['end_time']->getTimestamp() - UOJ
-
+
\ No newline at end of file
diff --git a/uoj/1/app/controllers/problem_data_manage.php b/uoj/1/app/controllers/problem_data_manage.php
index c84b2d4..c6fadba 100644
--- a/uoj/1/app/controllers/problem_data_manage.php
+++ b/uoj/1/app/controllers/problem_data_manage.php
@@ -526,7 +526,7 @@ EOD
}
$hackable = $problem['hackable'] ? 1 : 0;
- mysql_query("update problems set hackable = $hackable where id = ${problem['id']}");
+ DB::query("update problems set hackable = $hackable where id = ${problem['id']}");
};
$hackable_form->submit_button_config['class_str'] = 'btn btn-warning btn-block';
$hackable_form->submit_button_config['text'] = $problem['hackable'] ? '禁止使用hack' : '允许使用hack';
@@ -598,7 +598,7 @@ EOD
$config['view_all_details_type'] = $_POST['view_all_details_type'];
$config['view_details_type'] = $_POST['view_details_type'];
$esc_config = DB::escape(json_encode($config));
- mysql_query("update problems set extra_config = '$esc_config' where id = '{$problem['id']}'");
+ DB::query("update problems set extra_config = '$esc_config' where id = '{$problem['id']}'");
};
$view_type_form->submit_button_config['class_str'] = 'btn btn-warning btn-block top-buffer-sm';
diff --git a/uoj/1/app/controllers/problem_managers_manage.php b/uoj/1/app/controllers/problem_managers_manage.php
index 970e930..1cd9bb1 100644
--- a/uoj/1/app/controllers/problem_managers_manage.php
+++ b/uoj/1/app/controllers/problem_managers_manage.php
@@ -19,9 +19,9 @@
function($type, $username) {
global $problem;
if ($type == '+') {
- mysql_query("insert into problems_permissions (problem_id, username) values (${problem['id']}, '$username')");
+ DB::query("insert into problems_permissions (problem_id, username) values (${problem['id']}, '$username')");
} else if ($type == '-') {
- mysql_query("delete from problems_permissions where problem_id = ${problem['id']} and username = '$username'");
+ DB::query("delete from problems_permissions where problem_id = ${problem['id']} and username = '$username'");
}
},
function() {
@@ -51,8 +51,8 @@
', '', $row_id, ' | ', '', getUserLink($row['username']), ' | ', '';
}
diff --git a/uoj/1/app/controllers/problem_set.php b/uoj/1/app/controllers/problem_set.php
index 583ad39..e18716e 100644
--- a/uoj/1/app/controllers/problem_set.php
+++ b/uoj/1/app/controllers/problem_set.php
@@ -6,9 +6,9 @@
if (isSuperUser($myUser)) {
$new_problem_form = new UOJForm('new_problem');
$new_problem_form->handle = function() {
- mysql_query("insert into problems (title, is_hidden, submission_requirement) values ('New Problem', 1, '{}')");
- $id = mysql_insert_id();
- mysql_query("insert into problems_contents (id, statement, statement_md) values ($id, '', '')");
+ DB::query("insert into problems (title, is_hidden, submission_requirement) values ('New Problem', 1, '{}')");
+ $id = DB::insert_id();
+ DB::query("insert into problems_contents (id, statement, statement_md) values ($id, '', '')");
svnNewProblem($id);
};
$new_problem_form->submit_button_config['align'] = 'right';
diff --git a/uoj/1/app/controllers/problem_statistics.php b/uoj/1/app/controllers/problem_statistics.php
index 3c4a724..b6acce9 100644
--- a/uoj/1/app/controllers/problem_statistics.php
+++ b/uoj/1/app/controllers/problem_statistics.php
@@ -21,7 +21,7 @@
$is_res_empty = true;
$has_score_0 = false;
$has_score_100 = false;
- while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ while ($row = DB::fetch($result, MYSQLI_NUM)) {
if ($row[0] == 0) {
$has_score_0 = true;
} else if ($row[0] == 100) {
diff --git a/uoj/1/app/controllers/register.php b/uoj/1/app/controllers/register.php
index c637fe1..dc0ac69 100644
--- a/uoj/1/app/controllers/register.php
+++ b/uoj/1/app/controllers/register.php
@@ -35,9 +35,9 @@
$svn_pw = uojRandString(10);
if (!DB::selectCount("SELECT COUNT(*) FROM user_info"))
- mysql_query("insert into user_info (username, email, password, svn_password, register_time, usergroup) values ('$username', '$esc_email', '$password', '$svn_pw', now(), 'S')");
+ DB::query("insert into user_info (username, email, password, svn_password, register_time, usergroup) values ('$username', '$esc_email', '$password', '$svn_pw', now(), 'S')");
else
- mysql_query("insert into user_info (username, email, password, svn_password, register_time) values ('$username', '$esc_email', '$password', '$svn_pw', now())");
+ DB::query("insert into user_info (username, email, password, svn_password, register_time) values ('$username', '$esc_email', '$password', '$svn_pw', now())");
return "欢迎你!" . $username . ",你已成功注册。";
}
diff --git a/uoj/1/app/controllers/submissions_list.php b/uoj/1/app/controllers/submissions_list.php
index dca32da..990f4a2 100644
--- a/uoj/1/app/controllers/submissions_list.php
+++ b/uoj/1/app/controllers/submissions_list.php
@@ -19,7 +19,7 @@
$conds[] = "score <= $q_max_score";
}
if ($q_language != null) {
- $conds[] = sprintf("language = '%s'", mysql_real_escape_string($q_language));
+ $conds[] = sprintf("language = '%s'", DB::escape($q_language));
}
$html_esc_q_language = htmlspecialchars($q_language);
diff --git a/uoj/1/app/controllers/super_manage.php b/uoj/1/app/controllers/super_manage.php
index 035c43c..8d57052 100644
--- a/uoj/1/app/controllers/super_manage.php
+++ b/uoj/1/app/controllers/super_manage.php
@@ -74,7 +74,7 @@
$blog_link_contests->handle = function() {
$blog_id = $_POST['blog_id'];
$contest_id = $_POST['contest_id'];
- $str = mysql_fetch_array(mysql_query("select * from contests where id='${contest_id}'"));
+ $str = DB::selectFirst(("select * from contests where id='${contest_id}'"));
$all_config = json_decode($str['extra_config'], true);
$config = $all_config['links'];
@@ -97,8 +97,8 @@
$all_config['links'] = $config;
$str = json_encode($all_config);
- $str = mysql_real_escape_string($str);
- mysql_query("update contests set extra_config='${str}' where id='${contest_id}'");
+ $str = DB::escape($str);
+ DB::query("update contests set extra_config='${str}' where id='${contest_id}'");
};
$blog_link_contests->runAtServer();
diff --git a/uoj/1/app/controllers/user_info.php b/uoj/1/app/controllers/user_info.php
index f4c6cb6..d6b2147 100644
--- a/uoj/1/app/controllers/user_info.php
+++ b/uoj/1/app/controllers/user_info.php
@@ -107,10 +107,10 @@
var rating_data = [[
connect_errno;
+ echo '========================\n';
+ }
if (!$uojMySQL) {
- echo 'There is something wrong with database >_<.... ' . mysql_error();
+ echo 'There is something wrong with database >_<.... ' . mysqli_error($uojMySQL);
die();
}
- mysql_select_db(UOJConfig::$data['database']['database']);
}
public static function escape($str) {
- return mysql_real_escape_string($str);
+ global $uojMySQL;
+ return mysqli_real_escape_string($uojMySQL, $str);
}
- public static function fetch($r, $opt = MYSQL_ASSOC) {
- return mysql_fetch_array($r, $opt);
+ public static function fetch($r, $opt = MYSQLI_ASSOC) {
+ global $uojMySQL;
+ return mysqli_fetch_array($r, $opt);
}
public static function query($q) {
- return mysql_query($q);
+ global $uojMySQL;
+ return mysqli_query($uojMySQL, $q);
}
public static function update($q) {
- return mysql_query($q);
+ global $uojMySQL;
+ return mysqli_query($uojMySQL, $q);
}
public static function insert($q) {
- return mysql_query($q);
+ global $uojMySQL;
+ return mysqli_query($uojMySQL, $q);
}
public static function insert_id() {
- return mysql_insert_id();
+ global $uojMySQL;
+ return mysqli_insert_id($uojMySQL);
}
public static function delete($q) {
- return mysql_query($q);
+ global $uojMySQL;
+ return mysqli_query($uojMySQL, $q);
}
public static function select($q) {
- return mysql_query($q);
+ global $uojMySQL;
+ return mysqli_query($uojMySQL, $q);
}
- public static function selectAll($q, $opt = MYSQL_ASSOC) {
+ public static function selectAll($q, $opt = MYSQLI_ASSOC) {
+ global $uojMySQL;
$res = array();
- $qr = mysql_query($q);
- while ($row = mysql_fetch_array($qr, $opt)) {
+ $qr = mysqli_query($uojMySQL, $q);
+ while ($row = mysqli_fetch_array($qr, $opt)) {
$res[] = $row;
}
return $res;
}
- public static function selectFirst($q, $opt = MYSQL_ASSOC) {
- return mysql_fetch_array(mysql_query($q), $opt);
+ public static function selectFirst($q, $opt = MYSQLI_ASSOC) {
+ global $uojMySQL;
+ return mysqli_fetch_array(mysqli_query($uojMySQL, $q), $opt);
}
public static function selectCount($q) {
- list($cnt) = mysql_fetch_array(mysql_query($q), MYSQL_NUM);
+ global $uojMySQL;
+ list($cnt) = mysqli_fetch_array(mysqli_query($uojMySQL, $q), MYSQLI_NUM);
return $cnt;
}
public static function checkTableExists($name) {
+ global $uojMySQL;
return DB::query("select 1 from $name") !== false;
}
public static function num_rows() {
- return mysql_num_rows();
+ global $uojMySQL;
+ return mysqli_num_rows($uojMySQL);
}
public static function affected_rows() {
- return mysql_affected_rows();
+ global $uojMySQL;
+ return mysqli_affected_rows($uojMySQL);
}
-}
+}
\ No newline at end of file
diff --git a/uoj/1/app/vendor/phpmailer/docs/extending.html b/uoj/1/app/vendor/phpmailer/docs/extending.html
index ec2b851..4126846 100644
--- a/uoj/1/app/vendor/phpmailer/docs/extending.html
+++ b/uoj/1/app/vendor/phpmailer/docs/extending.html
@@ -23,12 +23,11 @@ $mail->FromName = 'List manager';
$mail->Host = 'smtp1.example.com;smtp2.example.com';
$mail->Mailer = 'smtp';
-@mysqli_connect('localhost','root','password');
-@mysqli_select_db("my_company");
+@$mm = new mysqli('localhost','root','password', 'my_company');
$query = "SELECT full_name, email, photo FROM employee";
-$result = @mysqli_query($query);
+$result = @mysqli_query($mm, $query);
-while ($row = mysqli_fetch_assoc($result))
+while ($row = mysqli_fetch_assoc($mm, $result))
{
// HTML body
$body = "Hello <font size=\"4\">" . $row['full_name'] . "</font>, <p>";
@@ -126,4 +125,4 @@ if(!$mail->send())
echo 'Message was sent successfully';