Beispiel #1
0
 function write_rejudge_all()
 {
     if (Authentication::is_admin() and $this->entity->submitable()) {
         $this->write_block_begin('Rejudge submissions');
         $this->write_form_begin($this->nav_script(null) . $this->entity->path() . "?rejudge_all=1", 'post');
         $this->write_form_end('Rejudge all submissions for this entity');
         $this->write_block_end();
     }
 }
Beispiel #2
0
function is_allowed_file($subm, $entity, $user, $dir, $filename)
{
    if (strpos($dir, '..') !== false) {
        return false;
        // security
    }
    if (!$user->is_admin && !$subm->is_made_by($user)) {
        return false;
        // other user's submission
    }
    if ($dir == 'code') {
        // the file send by the user
        return array(true, $subm->code_filename($filename));
    } else {
        if ($dir == 'out') {
            $ext = pathinfo($filename, PATHINFO_EXTENSION);
            $base = pathinfo($filename, PATHINFO_FILENAME);
            if ($filename == 'compiler.err') {
                $ok = $entity->show_compile_errors() || Authentication::is_admin();
            } else {
                if ($ext == 'err') {
                    $ok = $entity->show_runtime_errors_for($base) || Authentication::is_admin();
                } else {
                    if ($ext == 'out' || $ext == 'diff') {
                        $ok = $entity->show_input_output_for($base) || Authentication::is_admin();
                    } else {
                        $ok = false;
                    }
                }
            }
            if ($ok) {
                return array(true, $subm->output_filename($filename));
            }
        } else {
            if ($dir == 'in') {
                $ext = pathinfo($filename, PATHINFO_EXTENSION);
                $base = pathinfo($filename, PATHINFO_FILENAME);
                if ($ext == 'desc') {
                    $ok = true;
                } else {
                    if ($ext == 'in' || $ext == 'out') {
                        $ok = $entity->show_input_output_for($base) || Authentication::is_admin();
                    } else {
                        $ok = false;
                    }
                }
                if ($ok) {
                    return array(false, $subm->input_filename($filename));
                }
            }
        }
    }
    return false;
    // unknown file
}
Beispiel #3
0
 function write_body()
 {
     if (Authentication::is_admin()) {
         $this->write_error_log();
     }
     if ($this->entity->submitable()) {
         $this->write_submitable_page();
     } else {
         $this->write_overview_page();
     }
 }
Beispiel #4
0
 function write_tabbar()
 {
     // documentation.php paths are not the same as entity paths
     $is_doc = Util::current_script_is('documentation.php');
     if (Authentication::current_user()) {
         $this->write_tabbar_link('index.php', 'Courses', !$is_doc);
     } else {
         $this->write_tabbar_link('login.php', 'Log in', !$is_doc);
     }
     if (Authentication::is_admin()) {
         $this->write_tabbar_link('admin_submissions.php', 'Latest submissions', !$is_doc);
         $this->write_tabbar_link('admin_results.php', 'Results table', !$is_doc);
         $this->write_tabbar_link('admin_print.php', 'Print submissions', !$is_doc);
         $this->write_tabbar_link('admin_user.php', 'Users', !$is_doc);
         $this->write_tabbar_link('admin_judge_daemons.php', 'Judges', !$is_doc);
         $this->write_tabbar_link('admin_view_log.php', 'Error log', !$is_doc);
     }
     $this->write_tabbar_link('documentation.php', 'Documentation', $is_doc);
 }
<?php

require_once '../lib/bootstrap.inc';
// -----------------------------------------------------------------------------
// Ajax utility: return newest submissions
// -----------------------------------------------------------------------------
if (Authentication::current_user() == false) {
    echo '{"logout":"true"}';
} else {
    if (Authentication::is_admin() and isset($_GET['entity']) and isset($_GET['submissionid'])) {
        try {
            // get entity
            $entity = Entity::get($_GET['entity'], false, true);
            $submissions = $entity->submissions_after($_GET['submissionid']);
            $arr = array();
            foreach ($submissions as $s) {
                $arr[] = $s->submissionid;
            }
            echo '{"new_ids":' . json_encode($arr) . '}';
        } catch (NotFoundException $e) {
            exit;
        }
    } else {
        die("You have no rights to view this submission");
    }
}