/** * Online judge: only tell whether the source file is correct */ function online_judge($files, $post) { //Hidden form field set? if (!isset($post['st'])) { echo "{ 'error':'Submission source invalid' }"; return; } if (!$this->check_file($files)) { echo "{ 'error':'File not allowed' }"; return; } if (parent::parse_output_file($files, $this->md)) { echo "{ 'correct':'yes','message':'Submission Correct!' }"; } else { echo "{ 'correct':'no','message':'Submission incorrect!' }"; } //Delete the uploads unlink($files['output_file']['tmp_name']); }
/** * Intelligent function to validate files */ function online_judge($files, $post) { //Check for expiry of submission time if ($this->timed_out()) { echo "{ 'error':'Submission time expired!' }"; return; } //Is submission from superuser? $su = false; if ($this->user_data['user_type'] == 'su') { $su = true; } //Hidden form field set? if (!isset($post['st'])) { echo "{ 'error':'Submission source invalid' }"; return; } //Submissions over? // if(!$this->downloads_over()) // { // echo "{ 'submission_over':'Your chances are over, Lets meet next time!' }"; // return; // } if (!parent::check_files($files)) { echo "{ 'error':'Files not allowed' }"; return; } //Only upload for non ~su~ users if (!$su) { if (!parent::upload_submissions($files, $this->md)) { echo "{ 'error':'Unable to upload files' }"; return; } } if (parent::parse_output_file($files, $this->md)) { echo "{ 'correct':'yes','message':'Submission Correct!' }"; } else { echo "{ 'correct':'no','message':'Submission incorrect!' }"; } //Update user details in match table but first check the user type so that we only update for a registered user if (!$su) { parent::update_user_details($this->md); } //Delete the uploads unlink($files['output_file']['tmp_name']); unlink($files['source_file']['tmp_name']); }