fwrite($socket, $input . "\n"); fwrite($socket, $lang . "\n"); $status = fgets($socket); $contents = ""; while (!feof($socket)) { $contents = $contents . fgets($socket); } if ($status == 0) { // oops! compile error $query = "UPDATE solve SET status=1 WHERE (username='******'username'] . "' AND problem_id='" . $_POST['id'] . "')"; mysql_query($query); $_SESSION['cerror'] = trim($contents); header("Location: solve.php?cerror=1&id=" . $_POST['id']); } else { if ($status == 1) { if (trim($contents) == trim(treat($fields['output']))) { // holla! problem solved $query = "SELECT `points` FROM `problems` WHERE `sl`=" . $_POST['id']; $result = mysql_query($query); $row = mysql_fetch_array($result); $points = $row['points']; include 'admin/formula.php'; $query = "UPDATE users SET score = score + " . $score . " WHERE username = '******'username'] . "'"; mysql_query($query); $query = "UPDATE solve SET score=" . $score . ", status=2 WHERE (username='******'username'] . "' AND problem_id='" . $_POST['id'] . "')"; mysql_query($query); header("Location: index.php?success=1"); } else { // duh! wrong output $query = "UPDATE solve SET status=1 WHERE (username='******'username'] . "' AND problem_id='" . $_POST['id'] . "')"; mysql_query($query);
$res = str_replace(" ", " ", $res); } while ($o != $res); $nr = trim($nr); $nr = str_replace("<li> ", "<li>", $nr); $nr = str_replace("<dd> ", "<dd>", $nr); $nr = str_replace("\n<", "<", $nr); $nr = str_replace("\r", "", $nr); $nr = str_replace("\n", " ", $nr); do { $o = $nr; $nr = str_replace(" ", " ", $nr); } while ($o != $nr); # $arr = array ( 'li' ) ; # foreach ( $arr AS $a ) $nr = str_replace ( "<$a>" , "<$a> " , $nr ) ; # Indicator color $col = 'red'; if ($res == $nr) { $col = 'green'; } # $nr = str_replace ( '</' , "\n</" , $xml ) ; print "<tr><th bgcolor='{$col}'>" . treat($t->name) . "</th>"; print "<td>" . treat($res) . "</td>"; print "<td>" . treat($nr) . "</td>"; print "<td>" . treat($t->input) . "</td>"; print "<td>" . treat($xml) . "</td>"; $cnt++; if ($cnt > 40) { break; } } print "</table>";