} // Step 4: Now the user has authenticated, do something with the permanent token and secret we received function verify_credentials($tmhOAuth) { $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token']; $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret']; $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials')); if ($code == 200) { echo $tmhOAuth->response['response']; } else { outputError($tmhOAuth); } } /* Auth Flow */ if (isset($_REQUEST['wipe'])) { // Logging out wipe(); return; } if (isset($_REQUEST['start'])) { // Let's start the OAuth dance request_token($tmhOAuth); } elseif (isset($_REQUEST['oauth_verifier'])) { access_token($tmhOAuth); } elseif (isset($_SESSION['access_token'])) { // Some credentials already stored in this browser session. verify_credentials($tmhOAuth); } else { // User's not logged in. echo json_encode(array('loggedin' => false)); }
function compare($task, $case, $style) { echo 'Comparing task : ' . $task['name_short'] . ' case : ' . $case . "\n"; rm('grader_result.txt'); wipe('grader_path.txt'); if ($style == 'ruby') { $handle = fopen('grader_path.txt', 'w'); $path = 'ev/' . $task['name_short'] . '/' . $case . '.sol'; fwrite($handle, $path); $check = 'ev/' . $task['name_short'] . '/check.rb'; if (!file_exists($check)) { error('Check file (ruby) not found! task : ' . $task['name_short'] . ' case : ' . $case); } $command = 'ruby ' . $check; exec($command); } else { if ($style == 'cpp') { $path = 'ev/' . $task['name_short'] . '/'; $judge = $path . 'check.out'; if (!file_exists($judge)) { //COMPILE if (!file_exists($path . 'check.cpp')) { error('Check file (cpp) not found! task : ' . $task['name_short'] . ' case : ' . $case); } $command = 'g++ -O3 ' . $path . 'check.cpp -o ' . $judge . ' -lm'; exec($command); } $command = $judge . ' ' . $path . $case . '.sol'; exec($command); } } $grader_result = 'grader_result.txt'; if (!file_exists($grader_result)) { error('Grader result not fonud! task : ' . $task['name_short'] . ' case : ' . $case); } $handle = fopen($grader_result, 'r'); $line = fgets($handle); if (trim($line) == 'P') { return 'P'; } else { return '-'; } }