📄 reportgame.php
字号:
<?php$report = new report;class report { function report() { global $DB, $output, $CONF; global $HTTP_POST_VARS, $HTTP_GET_VARS; $action = $HTTP_GET_VARS['code']; if ($action == 0) //show the form $this->displayForm(); if ($action == 1) $this->reportGame(); } function displayForm() { global $output; $output .= "<form action = \"index.php?action=report&code=1\" method = \"post\">\n"; $output .= "Winner : <input type = \"text\" name = \"Winner\"><BR><BR><BR>\n"; $output .= "Loser : <input type = \"text\" name = \"Loser\"><BR>\n"; $output .= "<input type = \"submit\" name = \"submit\" value = \"submit\"<BR>\n"; } function reportGame() { global $output, $DB, $CONF; global $HTTP_POST_VARS, $HTTP_GET_VARS; $DB2 = new sql_driver; $DB2->param['sql_database'] = $CONF['database']; $DB2->param['sql_user'] = $CONF['login'] ; $DB2->param['sql_pass'] = $CONF['password']; $DB2->param['sql_host'] = $CONF['host_name']; $DB2->connect(); $DB->query("select rung from users where name = '{$HTTP_POST_VARS['Winner']}';"); $winner_row = $DB->getRow(); $winner_rung = $winner_row['rung']; $DB->query("select rung from users where name = '{$HTTP_POST_VARS['Loser']}';"); $loser_row = $DB->getRow(); $loser_rung = $loser_row['rung']; $loser_new_rung = floor(($winner_rung + $loser_rung)/2); if ($winner_rung > $loser_rung) //rank changes { $DB->query("select name, rung from users WHERE rung >= $loser_new_rung AND rung < $winner_rung order by rung DESC;"); for ($i = $winner_rung -1; $i >= $loser_new_rung; $i--) { $row = $DB->getRow(); $newRung = $i + 1; $DB2->query("update users set rung = $newRung where rung = $i"); } $DB2->query("update users set rung = $loser_new_rung where name = '{$HTTP_POST_VARS['Winner']}'"); $output .= "match recorded {$HTTP_POST_VARS['Winner']}'s new rung is $loser_new_rung"; } $DB2->disconnect(); } }?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -