} </style> <div id="rank" class="container_12"> <?php if ($config['mode'] == 'blind_contest' && inTime() && !isAdmin()) { ?> <div class="grid_12" align="center"> <h1>จะมีการจัดอันดับเมื่อการแข่งขันจบ</h1> </div> <?php } else { $query = 'select * from `latest` where (`user_id`) in (select `user_id` from `user` where `level` = 1) order by `user_id` asc, `task_id` asc;'; $sql->prepare($query); $sql->execute(); $sql->bind_result($latest_id, $user_id, $task_id, $score, $timeused, $text); $a = newSqli(); $b = $a->stmt_init(); $cnt = -1; $old_id = -1; $info = array(array()); while ($sql->fetch()) { if ($user_id != $old_id) { $old_id = $user_id; $cnt++; $info[$cnt] = user($user_id); $info[$cnt]['score'] = 0; $info[$cnt]['timeused'] = 0; $info[$cnt]['task'] = array(); } $task = task($task_id); if ($task['see'] == 1) {
function task($task_id) { global $task_loaded; if (!isset($task_loaded[$task_id])) { $query = 'select `task_id`, `name`, `name_short`, `score`, `time_limit`, `mem_limit`, `see` from `task` where `task_id` = ?;'; $mysqli = newSqli(); $sql = $mysqli->stmt_init(); $sql->prepare($query); $sql->bind_param('i', $task_id); $sql->execute(); $sql->bind_result($task_id, $name, $name_short, $score, $time_limit, $mem_limit, $see); if ($sql->fetch()) { $task_loaded[$task_id] = array('success' => true, 'task_id' => $task_id, 'name' => $name, 'name_short' => $name_short, 'link' => $link, 'score' => $score, 'time_limit' => $time_limit, 'mem_limit' => $mem_limit, 'see' => $see); } else { $task_loaded[$task_id] = array('success' => false); } } return $task_loaded[$task_id]; }
<?php include 'config.php'; $query = 'select * from `best`;'; $sql->prepare($query); $sql->execute(); $sql->bind_result($best_id, $user_id, $task_id, $score, $timeused, $text); $insert = newSqli(); $a = $insert->stmt_init(); $cnt = 0; while ($sql->fetch()) { echo 'user_id : ' . $user_id . ' score : ' . $score . ' '; if (abs($score - 100) < 0.0001) { $query = 'select * from `pass` where `user_id` = ? and `task_id` = ?;'; $a->prepare($query); $a->bind_param('ii', $user_id, $task_id); $a->execute(); if ($a->fetch()) { echo 'exists'; } else { $query = 'insert into `pass` (`pass_id`, `user_id`, `task_id`) values (NULL, ?, ?);'; $a->prepare($query); $a->bind_param('ii', $user_id, $task_id); $a->execute(); $cnt++; echo 'accepted'; } } echo '<br>'; } echo 'Finished ' . $cnt . ' rows';