Пример #1
0
 function WT_contest_status_string($c)
 {
     $cnt = WT_spawn_new_contest_container();
     $cnt->ReNewOneStatus($c);
     $c = $cnt->ContestById($c['id']);
     if ($c['status'] == 0) {
         if ($c['settings']['autostart']) {
             $date = $c['settings']['autostart.date'];
             $time = $c['settings']['autostart.time'];
             $y = preg_replace('/^([0-9]+)\\-([0-9]+)\\-([0-9]+)$/', '\\1', $date);
             $m = preg_replace('/^([0-9]+)\\-([0-9]+)\\-([0-9]+)$/', '\\2', $date);
             $d = preg_replace('/^([0-9]+)\\-([0-9]+)\\-([0-9]+)$/', '\\3', $date);
             $h = preg_replace('/^([0-9]+)\\:([0-9]+)$/', '\\1', $time);
             $min = preg_replace('/^([0-9]+)\\:([0-9]+)$/', '\\2', $time);
             $deadline = mktime($h, $min, 0, $m, $d, $y, 0);
             return 'Ожидание ' . Timer($deadline - time());
         } else {
             return 'Остановлен';
         }
     }
     if ($c['status'] == 2) {
         return 'Завершен';
     }
     if ($c['settings']['duration']) {
         // TODO: Add time formation here
         return 'Осталось ' . Timer($c['settings']['timestamp'] + $c['settings']['duration'] * 60 - time());
     }
     return ' ';
 }
Пример #2
0
 function UpdateCompilers($id, $arr)
 {
     $ccnt = WT_spawn_new_contest_container();
     // For da correct caching
     $ccnt->UpdateCompilers($id, $arr);
 }
Пример #3
0
 function Page_Contest()
 {
     global $action, $id, $changeto, $clear;
     $this->AppendNavigation('Список контестов', '/?page=contest');
     redirector_add_skipvar('action', 'restart');
     redirector_add_skipvar('action', 'start');
     redirector_add_skipvar('action', 'delete');
     if ($action != 'manage') {
         redirector_add_skipvar('id');
     }
     $ccnt = $this->SpawnContestContainer();
     $create = $this->GetAllowed('CONTEST.CREATE');
     $del = $this->GetAllowed('CONTEST.DELETE');
     $manage = $this->GetAllowed('CONTEST.MANAGE');
     $pageManage = $action == 'manage' && $manage;
     if (!isset($clear)) {
         if (isset($changeto)) {
             $this->SwitchToContest($changeto);
             if ($manage) {
                 redirect('.?page=contest&action=manage&id=' . $changeto);
             }
         }
         if ($action == 'create' && $create) {
             $ccnt->CreateReceived();
             redirect('SELF', array('action' => ''));
         }
         if ($action == 'delete' && $del) {
             $ccnt->Delete($id);
             redirect('SELF', array('action' => '', 'id' => ''));
         }
         if ($manage) {
             if ($action == 'stop' || $action == 'start' || $action == 'restart') {
                 $ccnt->{$action}($id);
             }
             if ($action == 'save' && $manage) {
                 $cnt = WT_spawn_new_contest_container(0);
                 $action = 'manage';
                 $cnt->Save($id);
             }
         }
         if ($action == 'manage' && !$manage) {
             unset($action);
             unset($id);
         }
         if ($pageManage) {
             $this->CPrintLn('<table width="100%"><tr valign="top">' . '<td width="50%" style="padding-right: 2px;">');
         }
         $this->CPrintLn(stencil_formo('title=Список доступных контестов;' . (!$this->GetAllowed('CONTEST.CREATE') ? 'smb=true;' : '')));
         $this->InsertTemplate('contest.list', array('data' => $ccnt->GetAccessibleList(user_id()), 'current_contest' => $this->current_contest, 'accManage' => $manage, 'accDel' => $del));
         $this->CPrintLn(stencil_formc());
         if ($pageManage) {
             $this->CPrintLn('</td><td style="padding-left: 2px;">');
             $this->Page_ContestManager($id);
             $this->CPrintLn('</td></tr></table>');
         }
         if ($this->GetAllowed('CONTEST.CREATE')) {
             $this->Page_DrawContentCreate();
         }
     } else {
         if ($pageManage) {
             $this->Page_ContestManager($id, true);
         }
     }
 }