コード例 #1
0
ファイル: Leaderboard.php プロジェクト: SIT-Decoders/Aurora
 public static function updateContestRankings($code)
 {
     $query = "select * from contest where code = '{$code}'";
     $contest = DB::findOneFromQuery($query);
     $query = "select runs.tid as tid, teamname, problems.score, submittime as time,\n\t\t\t(select count(rid) from runs r where tid = runs.tid and pid = runs.pid and result != 'AC'\n\t\t\tand result is not NULL and submittime < runs.submittime) as penalty\n\t\t\tfrom runs, teams, problems, contest\n\t\t\twhere\n\t\t\tteams.status = 'Normal' and runs.tid = teams.tid and problems.pid = runs.pid and\n\t\t\truns.pid in (select pid from problems where pgroup ='{$code}') and result = 'AC' group by runs.tid, runs.pid";
     $res = DB::findAllFromQuery($query);
     foreach ($res as $row) {
         if (isset($rank[$row['tid']])) {
             $rank[$row['tid']]['time'] += $row['time'] - $contest['starttime'];
             $rank[$row['tid']]['score'] += $row['score'];
             $rank[$row['tid']]['penalty'] += $row['penalty'];
             $rank[$row['tid']]['solved']++;
         } else {
             $rank[$row['tid']]['teamname'] = $row['teamname'];
             $rank[$row['tid']]['time'] = $row['time'] - $contest['starttime'];
             $rank[$row['tid']]['score'] = $row['score'];
             $rank[$row['tid']]['penalty'] = $row['penalty'];
             $rank[$row['tid']]['solved'] = 1;
         }
     }
     usort($rank, "self::cmp");
     $rankTableJSON = json_encode($rank);
     DB::query("UPDATE contest SET ranktable = '{$rankTableJSON}' WHERE code = '{$code}'");
 }
コード例 #2
0
ファイル: functions.php プロジェクト: siddharthasahu/hackbase
function getOrderedImageUrls($uid)
{
    $query = "select * from orders where deleted = 0 and fk_user_id = {$uid}";
    $res = DB::findAllFromQuery($query);
    $img = array();
    foreach ($res as $index => $value) {
        if ($value['type'] == "general") {
            $path = GENERAL_PATH;
            $url = GENERAL_URL;
        } else {
            if ($value['type'] == "premium") {
                $path = PREMIUM_PATH;
                $url = PREMIUM_URL;
            }
        }
        if (file_exists($path . "/" . $value['category'] . "/" . $value['name'])) {
            $img[$index] = $url . "/" . $value['category'] . "/" . $value['name'];
        } else {
            $img[$index] = NOTFOUND_URL;
        }
    }
    return $img;
}
コード例 #3
0
ファイル: rank_old.php プロジェクト: SIT-Decoders/Aurora
        $query = "select \n                r.pid as pid, \n                min(submittime) as time, \n                score, \n                (select count(pid) from runs where tid = {$row['tid']} and pid = problems.pid and submittime < r.submittime and runs.access != 'deleted' and result != 'AC') as penalty \n                from runs r, problems where \n                r.access != 'deleted' and \n                tid = {$row['tid']} and \n                problems.pid in ({$row['pids']}) and \n                result = 'AC' and \n                r.pid = problems.pid \n                group by pid";
        $result = DB::findAllFromQuery($query);
        foreach ($result as $val) {
            if ($val['time'] > $rank[$row['tid']]['time']) {
                $rank[$row['tid']]['time'] = $val['time'];
            }
            $rank[$row['tid']]['score'] += $val['score'];
            $rank[$row['tid']]['penalty'] += $val['penalty'];
        }
    }
    usort($rank, "cmp");
    $i = 1;
    echo "<table class='table table-hover'><tr><th>Rank</th><th>Temaname</th><th>Time</th><th>Penalty</th><th>Score</th><th>Solved</th><th>Final Time</th></tr>";
    foreach ($rank as $val) {
        $val['time'] -= $contest['starttime'];
        $finaltime = $val['time'] + $val['penalty'] * 20 * 60;
        $val['time'] = timeformating($val['time']);
        $finaltime = timeformating($finaltime);
        echo "<tr><td>{$i}</td><td><a href='" . SITE_URL . "/teams/{$val['teamname']}'>{$val['teamname']}</a></td><td>{$val['time']}</td><td>{$val['penalty']}</td><td>{$val['score']}</td><td>{$val['solved']}</td><td>{$finaltime}</td></tr>";
        $i++;
    }
    echo "</table>";
} else {
    echo "<h1>Select a Contest</h1>\n        <div class='row'>";
    $query = "select * from contest";
    $res = DB::findAllFromQuery($query);
    foreach ($res as $row) {
        echo "<div class='span2'><a href='" . SITE_URL . "/rank/{$row['code']}'>{$row['name']}</a></div>";
    }
    echo "</div>";
}
コード例 #4
0
ファイル: components.php プロジェクト: SIT-Decoders/Aurora
function latestsubs()
{
    echo "<h4>Latest Submissions</h4><table class='table table-condensed'><tr><th>RID</th><th>Team</th><th>Problem</th><th>Result</th></tr >";
    $query = "SELECT rid, (select teamname from teams where tid = runs.tid) as tname, (select name from problems where pid = runs.pid) as pname,(select code from problems where pid = runs.pid) as pcode, result FROM runs order by rid desc limit 0, 5";
    $res = DB::findAllFromQuery($query);
    //echo $query;
    foreach ($res as $row) {
        echo "<tr><td><a href='" . SITE_URL . "/viewsolution/{$row['rid']}'>{$row['rid']}</a></td><td><a href='" . SITE_URL . "/teams/{$row['tname']}'>{$row['tname']}</a></td><td><a href='" . SITE_URL . "/problems/{$row['pcode']}'>{$row['pname']}</a></td><td>{$row['result']}</td></tr>";
    }
    echo "</table>";
}
コード例 #5
0
ファイル: submissions.php プロジェクト: SIT-Decoders/Aurora
        }
        $select = "Select *";
        if (isset($_SESSION['loggedin']) && $_SESSION['team']['status'] == 'Admin') {
            $query = "from runs where pid not in (SELECT pid FROM problems WHERE status='Deleted') order by rid desc";
        } else {
            $query = "from runs where access!='deleted' AND pid not in (SELECT pid FROM problems WHERE status='Deleted') order by rid desc";
        }
        $result = DB::findAllWithCount($select, $query, $page, 25);
        $data = $result['data'];
        $team = array();
        $t = DB::findAllFromQuery("select tid, teamname from teams");
        foreach ($t as $row) {
            $team[$row['tid']] = $row['teamname'];
        }
        $probname = array();
        $probcode = array();
        $p = DB::findAllFromQuery("Select pid, name, code from problems");
        foreach ($p as $row) {
            $probname[$row['pid']] = $row['name'];
            $probcode[$row['pid']] = $row['code'];
        }
        echo "<table class='table table-hover'><tr><th>Run ID</ht><th>Team</th><th>Problem</th><th>Language</th><th>Time</th><th>Result</th><th>Options</th></tr>";
        foreach ($data as $row) {
            echo "<tr" . ($row['result'] == "AC" ? " class='success'>" : ">") . "<td>" . ($row['access'] == 'public' || isset($_SESSION['loggedin']) && ($_SESSION['team']['status'] == "Admin" || $_SESSION['team']['id'] == $row['tid']) ? "<a href='" . SITE_URL . "/viewsolution/{$row['rid']}'>{$row['rid']}</a>" : "{$row['rid']}") . "</td><td><a href='" . SITE_URL . "/teams/" . $team[$row['tid']] . "'>" . $team[$row['tid']] . "</a></td><td><a href='" . SITE_URL . "/problems/" . $probcode[$row['pid']] . "'>" . $probname[$row['pid']] . "</a></td><td>{$row['language']}</td><td>{$row['time']}</td><td>{$row['result']}</td><td>" . ($row['access'] == 'public' || isset($_SESSION['loggedin']) && ($_SESSION['team']['status'] == "Admin" || $_SESSION['team']['id'] == $row['tid']) ? "<a class='btn btn-primary' href='" . SITE_URL . "/viewsolution/{$row['rid']}'>Code</a>" : "") . "</td></tr>";
        }
        echo "</table>";
        pagination($result['noofpages'], SITE_URL . "/submissions", $page, 10);
    }
} else {
    echo "<br/><br/><br/><div style='padding: 10px;'><h1>Lockdown Mode :(</h1>This feature is now offline as Judge is in Lockdown mode.</div><br/><br/><br/>";
}
コード例 #6
0
ファイル: admin.php プロジェクト: siddharthasahu/hackbase
if ($_SESSION['id'] != 2) {
    echo "<!--";
}
?>
<li><a href="admin.php">Admin</a></li><?php 
if ($_SESSION['id'] != 2) {
    echo "-->";
}
?>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>

    <div class="container">

      <div class="starter-template">
        <h1>Entries</h1>
        <?php 
$res = DB::findAllFromQuery("select * from dairy where userid='" . $_SESSION['id'] . "'");
foreach ($res as $value) {
    echo "<p>" . $value['content'] . "</p>";
}
?>
      </div>

    </div><!-- /.container -->

  </body>
</html>
コード例 #7
0
ファイル: pdf.php プロジェクト: SIT-Decoders/Aurora
    ?>
/jquery.js"></script>
            <script type="text/javascript" src="<?php 
    echo JS_URL;
    ?>
/bootstrap.js"></script> 
            <script type="text/javascript" src="<?php 
    echo JS_URL;
    ?>
/plugin.js"></script>
        </head>
        <body>
            <div class='container'>
                <?php 
    $pgroup = addslashes($_GET['code']);
    $res = DB::findAllFromQuery("Select * from problems where pgroup = '{$pgroup}'");
    $i = 1;
    foreach ($res as $result) {
        echo "<div style='page-break-after: " . ($i++ == count($res) ? "auto" : "always") . "; text-align: justify;'><center><h3>{$result['name']}</h3></center>";
        $statement = stripslashes($result["statement"]);
        $statement = preg_replace("/\n/", "<br>", $statement);
        $statement = preg_replace("/<image \\/>/", "<img src='data:image/jpeg;base64,{$result['image']}' />", $statement);
        echo " {$statement}<br/>\n                   <b>Time Limit :</b> {$result['timelimit']} Second(s)<br/><b>Score :</b> {$result['score']} Point(s)<br/><b>Input File Limit :</b> {$result['maxfilesize']} Bytes<br/><b>Languages Allowed :</b> {$result['languages']}</div>";
    }
    ?>
            </div>
        </body>
    </html>
    <?php 
} else {
    $_SESSION['msg'] = "Access Denied: You need to be administrator to access that page.";
コード例 #8
0
ファイル: process.php プロジェクト: SIT-Decoders/Aurora
 } else {
     if (isset($_POST['rejudge'])) {
         $query = "select * from admin where variable ='mode' or variable ='endtime' or variable='ip' or variable ='port'";
         $check = DB::findAllFromQuery($query);
         $admin = array();
         foreach ($check as $row) {
             $admin[$row['variable']] = $row['value'];
         }
         if (isset($_POST['filter'])) {
             $sql = "select rid from runs where result='{$_POST['filter']}' and access != 'deleted'";
             if (isset($_POST['tid'])) {
                 $sql .= "and tid={$_POST['tid']}";
             } else {
                 $sql .= "and pid={$_POST['pid']}";
             }
             $res = DB::findAllFromQuery($sql);
             $rids = array();
             foreach ($res as $row) {
                 array_push($rids, $row['rid']);
             }
             $query = "update runs set result = NULL, time = NULL where rid in (" . implode(',', $rids) . ")";
         } else {
             $query = "update runs set result = NULL, time = NULL where ";
             if (isset($_POST['rid'])) {
                 $query .= "rid = " . addslashes($_POST['rid']);
             }
             if (isset($_POST['tid']) && isset($_POST['rid'])) {
                 $query .= " and tid=" . addslashes($_POST['tid']);
             } else {
                 if (isset($_POST['tid'])) {
                     $query .= "tid=" . addslashes($_POST['tid']);
コード例 #9
0
function getArrayOfRIDsToBeDeleted($contestID)
{
    $query = "SELECT rid from runs WHERE pid IN(SELECT pid FROM problems WHERE pgroup='{$contestID}')";
    return DB::findAllFromQuery($query);
}
コード例 #10
0
                <div class="alert alert-danger" style="margin-top: 20px;">
                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                    <center><?php 
    echo $_SESSION['msg'];
    unset($_SESSION['msg']);
    ?>
</center>
                </div>
                <?php 
}
?>
            <div class='col-md-offset-3 col-md-6'>
                <div class='wrap-box'>
                    <h2>Leader Board</h2>
                    <div style='padding: 10px;'>
                        <table class='table table-hover'>
                          <tr class='success'><th>Teamname</th><th>Level</th><th>Score</th></tr>
                                    <?php 
$users = DB::findAllFromQuery("select * from users where access=1 order by level desc, score desc");
foreach ($users as $user) {
    echo "<tr><td>{$user['teamname']}</td><td>{$user['level']}</td><td>{$user['score']}</td></tr>";
}
?>
                        </table>
                    </div>
                </div>
            </div>

        </div>
    </body>
</html>
コード例 #11
0
ファイル: process.php プロジェクト: siddharthasahu/hackbase
         $mcqans .= ",";
     }
     DB::update('users', array('mcq_answer' => $mcqans), "id = " . $_SESSION['team']['id']);
 } else {
     if (isset($_POST['mcqans'])) {
         $ans = $_POST;
         $question = DB::findOneFromQuery("select count(id) as total from mcq");
         unset($ans['save']);
         $mcqans = "";
         for ($i = 1; $i <= $question['total']; $i++) {
             if (isset($ans[$i])) {
                 $mcqans .= $ans[$i];
             }
             $mcqans .= ",";
         }
         $correct = DB::findAllFromQuery("select correct from mcq");
         $user = DB::findOneFromQuery("select cheat from users where id = " . $_SESSION['team']['id']);
         $i = 1;
         $score = 0;
         foreach ($correct as $val) {
             if (isset($ans[$i]) && $ans[$i] == $val['correct']) {
                 $score += 4 * $user['cheat'];
             } else {
                 if (isset($ans[$i]) && $ans[$i] != $val['correct']) {
                     $score -= 1;
                 }
             }
             $i++;
         }
         $_SESSION['team']['score'] = $score;
         DB::update('users', array('mcq_answer' => $mcqans, 'score' => $score, 'level' => 1), "id = " . $_SESSION['team']['id']);
コード例 #12
0
ファイル: mcq.php プロジェクト: siddharthasahu/hackbase
$ans = explode(',', $user['mcq_answer']);
if ($user['mcq_starttime'] == 0) {
    $starttime = time();
    DB::update('users', array('mcq_starttime' => $starttime), "id = " . $_SESSION['team']['id']);
} else {
    $starttime = $user['mcq_starttime'];
}
?>
<div class="col-md-12">
    <div class="wrap-box">
        <h2>MCQ Questions</h2>
        <div class='row'>
            <div class='col-md-8' style='padding-left: 30px;'>
                <form id='answers'>
                    <?php 
$mcq = DB::findAllFromQuery("Select * from mcq");
$i = 0;
foreach ($mcq as $question) {
    echo "<b>Q{$question['id']}. {$question['question']}</b><br/><br/>" . "<label style='font-weight: normal; display: block; cursor: pointer;'><input type='radio' name='{$question['id']}' class='mcq-radio' value='1' " . (isset($ans[$i]) && $ans[$i] == 1 ? "checked" : "") . "> {$question['a']}</label><br>" . "<label style='font-weight: normal; display: block; cursor: pointer;'><input type='radio' name='{$question['id']}' class='mcq-radio' value='2' " . (isset($ans[$i]) && $ans[$i] == 2 ? "checked" : "") . "> {$question['b']}</label><br>" . "<label style='font-weight: normal; display: block; cursor: pointer;'><input type='radio' name='{$question['id']}' class='mcq-radio' value='3' " . (isset($ans[$i]) && $ans[$i] == 3 ? "checked" : "") . "> {$question['c']}</label><br>" . "<label style='font-weight: normal; display: block; cursor: pointer;'><input type='radio' name='{$question['id']}' class='mcq-radio' value='4' " . (isset($ans[$i]) && $ans[$i] == 4 ? "checked" : "") . "> {$question['d']}</label><br>" . "<a class='btn btn-primary uncheck' id='uncheck-{$question['id']}'>Uncheck</a><hr/>";
    $i++;
}
?>
 
                </form>
            </div>
            <div class='col-md-4'  style='padding-right: 30px;'>

                <div style='position: fixed; width: 300px;'>
                    <div id='timer'></div>
                    <table class='table table-bordered' style='text-align: center;'>
                        <?php