From 5a6cec7307141a01bbeace9e82911f9a87832ea1 Mon Sep 17 00:00:00 2001 From: Swapnil Agarwal Date: Wed, 26 Jun 2013 15:53:44 +0530 Subject: [PATCH 1/2] Contests can now be run for a predefined period --- admin/index.php | 6 ++++-- admin/update.php | 8 ++++++-- index.php | 15 +++++++++++---- install.php | 7 ++++--- solve.php | 6 ++++-- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/admin/index.php b/admin/index.php index 2926007..82bd168 100644 --- a/admin/index.php +++ b/admin/index.php @@ -14,6 +14,7 @@ else include('header.php'); connectdb(); + date_default_timezone_set('Asia/Kolkata'); ?>
  • Admin Panel
  • Users
  • @@ -43,13 +44,14 @@
    Name of event:
    - /> Accept submissions
    + Start (dd/mm/yy hh:mm:ss):
    + End (dd/mm/yy hh:mm:ss):

    Languages

    /> C
    /> C++
    diff --git a/admin/update.php b/admin/update.php index f1f42c5..75a19eb 100644 --- a/admin/update.php +++ b/admin/update.php @@ -8,6 +8,7 @@ */ include('../functions.php'); connectdb(); + date_default_timezone_set('Asia/Kolkata'); if(isset($_POST['action'])){ if($_POST['action']=='email') { // update the admin email @@ -39,12 +40,15 @@ if(trim($_POST['name']) == "") header("Location: index.php?derror=1"); else { - if($_POST['accept']=='on') $accept=1; else $accept=0; + list($day, $month, $year, $hour, $minute) = split('[/ :]', $_POST['start']); + $start=mktime($hour, $minute,0, $month, $day, $year); + list($day, $month, $year, $hour, $minute) = split('[/ :]', $_POST['end']); + $end=mktime($hour, $minute,0, $month, $day, $year); if($_POST['c']=='on') $c=1; else $c=0; if($_POST['cpp']=='on') $cpp=1; else $cpp=0; if($_POST['java']=='on') $java=1; else $java=0; if($_POST['python']=='on') $python=1; else $python=0; - mysql_query("UPDATE prefs SET name='".mysql_real_escape_string($_POST['name'])."', accept=$accept, c=$c, cpp=$cpp, java=$java, python=$python"); + mysql_query("UPDATE prefs SET name='".mysql_real_escape_string($_POST['name'])."', start=$start, end=$end, c=$c, cpp=$cpp, java=$java, python=$python"); header("Location: index.php?changed=1"); } } else if($_POST['action']=='addproblem') { diff --git a/index.php b/index.php index ddbc4d9..e392d71 100644 --- a/index.php +++ b/index.php @@ -29,10 +29,16 @@ if(isset($_GET['success'])) echo("
    \nCongratulations! You have solved the problem successfully.\n
    "); ?> - Below is a list of available problems for you to solve.

    -
    "); if($status['status'] == 0) echo("
    \nYou have been banned. You cannot submit a solution.\n
    "); + if($accept['start']>time()) + header('location:index.php'); ?>

    Submit Solution

    "/>
    Type your program below:


    - "); + time() and $status['status'] == 1) echo(""); else echo(""); ?> You are allowed to use any of the following languages: From 9d47a0343d2d782447fba66c26226867c7e652cc Mon Sep 17 00:00:00 2001 From: Swapnil Agarwal Date: Wed, 26 Jun 2013 19:29:40 +0530 Subject: [PATCH 2/2] TimeZone changed to UTC --- admin/index.php | 6 +++--- admin/update.php | 2 +- install.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/index.php b/admin/index.php index 82bd168..6acebe1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -14,7 +14,7 @@ else include('header.php'); connectdb(); - date_default_timezone_set('Asia/Kolkata'); + date_default_timezone_set('UTC'); ?>
  • Admin Panel
  • Users
  • @@ -50,8 +50,8 @@ ?> Name of event:
    - Start (dd/mm/yy hh:mm:ss):
    - End (dd/mm/yy hh:mm:ss):
    + Start Time in UTC (dd/mm/yy hh:mm:ss):
    + End Time in UTC (dd/mm/yy hh:mm:ss):

    Languages

    /> C
    /> C++
    diff --git a/admin/update.php b/admin/update.php index 75a19eb..a07c916 100644 --- a/admin/update.php +++ b/admin/update.php @@ -8,7 +8,7 @@ */ include('../functions.php'); connectdb(); - date_default_timezone_set('Asia/Kolkata'); + date_default_timezone_set('UTC'); if(isset($_POST['action'])){ if($_POST['action']=='email') { // update the admin email diff --git a/install.php b/install.php index 6f68b26..d895dd0 100644 --- a/install.php +++ b/install.php @@ -37,7 +37,7 @@ )"); // fill it with default preferences mysql_query("INSERT INTO `prefs` (`name`, `start`, 'end', `c`, `cpp`, `java`, `python`, `forumla`) VALUES -('Codejudge', 01/01/70 05:30:00, 01/01/70 05:30:00, 1, 1, 1,'\$score = \$points / \$attempts')"); +('Codejudge', 01/01/70 00:00:00, 01/01/70 00:00:00, 1, 1, 1,'\$score = \$points / \$attempts')"); // create the problems table mysql_query("CREATE TABLE IF NOT EXISTS `problems` ( `sl` int(11) NOT NULL AUTO_INCREMENT,