예제 #1
0
파일: template.php 프로젝트: Nazg-Gul/gate
 function Init($id = -1, $name = '', $text = '')
 {
     global $manage_template_cache;
     $this->SetDefaultSettings();
     $this->name = $name;
     $this->text = $text;
     $this->refcount = 0;
     if ($id != -1 && $name == '') {
         // If name is not empty it means that we have already gotten full info from base
         // ( for da optimizing qurries to base )
         if (isset($manage_template_cache[$id]['text'])) {
             $r = $manage_template_cache[$id];
         } else {
             $r = db_row_value('templates', "`id`={$id}");
             $manage_template_cache[$id] = $r;
         }
         if ($r['id'] == $id) {
             $this->name = $r['name'];
             $this->text = $r['text'];
             $this->refcount = $r['refcount'];
             $this->UnserializeSettings($r['settings']);
         } else {
             $id = -1;
         }
     }
     $this->id = $id;
 }
예제 #2
0
파일: data.php 프로젝트: Nazg-Gul/gate
function send()
{
    global $keystring, $login, $email;
    $hash = md5('#RANDOM_PREFIX#' . mtime() . '#RANDOM_SEPARATOR#' . $login . '#WITH#' . $email . '#RANDOM_SUFFIX#');
    if ($_SESSION['CAPTCHA_Keystring'] == '' || strtolower($keystring) != $_SESSION['CAPTCHA_Keystring']) {
        add_info('Вы не прошли тест Тьюринга на подтверждение того, что вы не бот.');
        return false;
    }
    $r = db_row_value('user', "(`login` =\"{$login}\") AND (`email`=\"{$email}\") AND (`authorized`=1)");
    if ($r['id'] == '') {
        add_info('Неверное сочетание login <-> email');
        return false;
    }
    $s = unserialize($r['settings']);
    if ($s['restore_timestamp'] && time() - $s['restore_timestamp'] < config_get('restore-timeout')) {
        add_info('Вы не можете просить восстановку пароля так часто');
        return false;
    }
    $s['restore_hash'] = $hash;
    $s['restore_timestamp'] = time();
    db_update('user', array('settings' => db_string(serialize($s))), '`id`=' . $r['id']);
    $link = config_get('http-document-root') . '/login/restore/confirm/?id=' . $r['id'] . '&hash=' . $hash;
    sendmail_tpl(stripslashes($email), 'Восстановление пароля в системе ' . config_get('site-name'), 'restore', array('login' => stripslashes($login), 'email' => stripslashes($email), 'link' => $link));
    return true;
}
예제 #3
0
 function Init($content_id = -1, $security = nil)
 {
     if ($content_id >= 0) {
         $r = db_row_value('content', "`id`={$content_id}");
         $this->SetName($r['name']);
     }
     $this->content_id = $content_id;
     $this->security = $security;
     $this->InitInstance($content_id);
 }
예제 #4
0
 function GetCatalogueItem($depth, $uid, $id = -1, $preparse = true)
 {
     $table = $this->GetSupportTableByDepth($depth);
     $cat_id = $this->GetCatIDByDepth($depth);
     if ($id < 0) {
         $arr = db_row_value($table, "`uid`={$uid}", 'ORDER BY `id` DESC');
     } else {
         $arr = db_row_value($table, "`id`={$id}");
     }
     if ($preparse) {
         $arr = $this->ParseDataRow($cat_id, $arr);
     }
     return $arr;
 }
예제 #5
0
 function WT_PutChecker()
 {
     global $id, $err, $desc;
     if (!WT_IPC_CheckLogin()) {
         return;
     }
     if ($id == '') {
         print 'Void filename for WT_PutChecker()';
         return;
     }
     $data = db_row_value('tester_checkers', "`id`={$id}");
     $s = unserialize($data['settings']);
     $s['ERR'] = $err;
     $s['DESC'] = $desc;
     db_update('tester_checkers', array('uploaded' => 'TRUE', 'settings' => db_string(serialize($s))), "`id`={$id}");
 }
예제 #6
0
 function WT_PutSolution()
 {
     global $id, $lid, $ERRORS, $POINTS, $XPFS;
     $optional_params = array('REPORT');
     $update_params = array('COMPILER_MESSAGES', 'TESTS');
     if (!WT_IPC_CheckLogin()) {
         return;
     }
     if (!isset($id) || !isset($lid)) {
         print 'Void filename for WT_PutSOlution';
         return;
     }
     $r = db_row_value('tester_solutions', "`id`={$id} AND `lid`={$lid}");
     $p = unserialize($r['parameters']);
     for ($i = 0; $i < count($update_params); $i++) {
         if (isset($_POST[$update_params[$i]])) {
             $p[$update_params[$i]] = stripslashes($_POST[$update_params[$i]]);
         }
     }
     if ($POINTS == '') {
         $POINTS = 0;
     }
     $n = count($optional_params);
     for ($i = 0; $i < $n; $i++) {
         $p[$optional_params[$i]] = stripslashes($GLOBALS[$optional_params[$i]]);
     }
     unset($p['force_status']);
     $data = array();
     if (isset($_POST['SOLUTION_OUTPUT'])) {
         $data['outputs'] = stripslashes($_POST['SOLUTION_OUTPUT']);
     }
     if (isset($_POST['CHECKER_OUTPUT'])) {
         $data['checker_outputs'] = stripslashes($_POST['CHECKER_OUTPUT']);
     }
     if (count($data) > 0) {
         $path = '/tester/testing/';
         $XPFS->CreateDirWithParents($path);
         $XPFS->removeItem($path . '/' . $id);
         $XPFS->createFile($path, $id, 0, db_pack($data));
     }
     db_update('tester_solutions', array('status' => 2, 'points' => $POINTS, 'errors' => db_string($ERRORS), 'parameters' => db_string(serialize($p))), "`id`={$id} AND `lid`={$lid}");
 }
예제 #7
0
 function WT_PutProblem()
 {
     global $id, $lid, $err, $desc;
     if (!WT_IPC_CheckLogin()) {
         return;
     }
     if ($id == '') {
         print 'Void filename for WT_PutProblem()';
         return;
     }
     if ($lid == '') {
         print 'Void library identifier for WT_PutProblem()';
         return;
     }
     $data = db_row_value('tester_problems', "(`id`={$id}) AND (`lid`={$lid})");
     $s = unserialize($data['settings']);
     $s['ERR'] = $err;
     $s['DESC'] = $desc;
     unset($s['filename']);
     db_update('tester_problems', array('uploaded' => $err != 'OK' ? 1 : 2, 'settings' => db_string(serialize($s))), "(`id`={$id}) AND (`lid`={$lid})");
 }
예제 #8
0
 function CGateway()
 {
     global $page, $WT_main_menu, $CORE, $WT_gateway;
     $this->SetClassName('CGateway');
     $this->CheckTables();
     $this->InitMenus();
     $this->page = $page != '' ? $page : $WT_main_menu[0][2];
     $this->nav = array();
     $this->security = new CGWSecurityInformation();
     $this->security->Init('WT_security');
     $r = db_row_value('tester');
     $this->security->UnserializeData($r['security']);
     $this->content_settings = unserialize($r['content']);
     $WT_gateway = $this;
     $CORE->PAGE->AppendTitle('WebTester');
     $CORE->AddStyle('tester');
     $this->UpdateCurrentContest();
     $this->current_lib = WT_spawn_new_library($this->current_contest['lid'], $this);
 }
예제 #9
0
파일: file.php 프로젝트: Nazg-Gul/gate
 function file_unlink_encrypted($id)
 {
     if ($id == '') {
         return;
     }
     $d = db_row_value('files', "`id`={$id}");
     if ($d['id'] != '') {
         db_delete('files', "`id`={$id}");
         @unlink(config_get('storage-enc') . '/' . $d['name']);
     }
 }
예제 #10
0
파일: content.php 프로젝트: Nazg-Gul/gate
 function content_path($id)
 {
     if ($id <= 1) {
         return '';
     }
     $r = db_row_value('content', "`id`={$id}");
     return content_path($r['pid']) . '/' . $r['path'];
 }
예제 #11
0
 function GetLastAcceptedAtContest($id = 1)
 {
     if ($id < 0) {
         $id = $_SESSION['WT_contest_id'];
     }
     $s = WT_contest_by_id($id);
     $s = $s['settings'];
     $arr = array();
     $timestamp = -1;
     if ($s['duration'] && $s['freezetime'] > 0 && (!$s['unfrozen'] && !$this->IsContestJudge())) {
         $timestamp = $s['timestamp'] + ($s['duration'] - $s['freezetime']) * 60;
     }
     $user_clause = '`user_id` IN (SELECT `u`.`id` FROM `user` AS `u`, ' . '`usergroup` AS `ug`, `tester_contestgroup` AS `tcg` WHERE ' . '(`u`.`id`=`ug`.`user_id`) AND (`ug`.`group_id`=`tcg`.`group_id`) ' . 'AND (`tcg`.`contest_id`=' . $id . ') )';
     $skip_user_clause = 'NOT (`user_id` IN (SELECT `u`.`id` ' . 'FROM `user` AS `u`, `tester_judgegroup` AS `tjg`, ' . '`usergroup` AS `ug` WHERE ' . '(`u`.`id`=`ug`.`user_id`) AND (`ug`.`group_id`=`tjg`.`group_id`) ' . 'AND (`tjg`.`contest_id`=' . $id . ')))';
     $arr = db_row_value('tester_solutions', " ({$user_clause}) AND " . "{$skip_user_clause} AND (`contest_id`={$id}) " . "AND (`status`=2) AND (`errors`=\"OK\")" . ($timestamp > 0 ? " AND (`timestamp`<={$timestamp})" : '') . "", "ORDER BY `timestamp` DESC");
     return $arr;
 }
예제 #12
0
파일: user.php 프로젝트: Nazg-Gul/gate
 function user_info_by_id($id, $cacheable = true)
 {
     global $user_infos;
     if ($cacheable && isset($user_infos[$id])) {
         return $user_infos[$id];
     }
     $user_infos[$id] = db_row_value('user', "`id`={$id}");
     $user_infos[$id]['settings'] = unserialize($user_infos[$id]['settings']);
     return $user_infos[$id];
 }
예제 #13
0
파일: settings.php 프로젝트: Nazg-Gul/gate
 function opt_get($id)
 {
     $r = db_row_value('settings', '`ident`="' . addslashes($id) . '"');
     if ($r['class'] == '') {
         return '';
     }
     $c = new $r['class']();
     $c->UnserializeSettings($r['settings']);
     return $c->GetValue();
 }
예제 #14
0
 function GetListRowById($id)
 {
     $res = db_row_value($this->settings['content'], '`id`=' . $id);
     $this->dataset->SetFieldValues($res);
     $r = $this->dataset->GetFieldValues(false, true);
     $this->dataset->FreeValues();
     foreach ($r as $k => $v) {
         $res[$k] = $v;
     }
     return $res;
 }
예제 #15
0
 function Test_GetCurrent($contest_id = -1, $user_id = -1)
 {
     global $WT_TESTING_Cache;
     if ($contest_id < 0) {
         $contest_id = $_SESSION['WT_contest_id'];
     }
     if ($user_id < 0) {
         $user_id = user_id();
     }
     if (isset($WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id])) {
         $t = $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id];
         if (!$this->Test_CheckTimers($t)) {
             $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id]['parameters']['interrupted'] = 1;
             return array();
         }
         return $t;
     }
     $r = db_row_value('tester_solutions', "(`contest_id`={$contest_id}) AND " . "(`user_id`={$user_id})", 'ORDER BY `id` DESC LIMIT 1');
     $r['parameters'] = unserialize($r['parameters']);
     $WT_TESTING_Cache['Test.Obtained.Data'][$contest_id][$user_id] = $r;
     return $r;
 }
예제 #16
0
파일: data.php 프로젝트: Nazg-Gul/gate
if ($PHP_SELF != '') {
    print 'HACKERS?';
    die;
}
?>
<div id="navigator"><a href="<?php 
echo config_get('document-root');
?>
/login">Вход в систему</a>Восстановление пароля</div>
${information}
<?php 
global $id, $hash;
if (!isset($id) || !isnumber($id) || !isset($hash)) {
    add_info('Пропущен обязательный параметр.');
} else {
    $r = db_row_value('user', "(`id`=\"{$id}\") AND (`authorized`=1)");
    if ($r['id'] == '') {
        add_info('Ошибка восстановления пароля.');
    } else {
        global $hash;
        $s = unserialize($r['settings']);
        if ($s['restore_hash'] != $hash) {
            add_info('Ошибка восстановления пароля.');
        } else {
            ?>
<script language="JavaScript" type="text/JavaScript">
function check_passwd () {
  var passwd  = getElementById ('passwd').value;
  var confirm = getElementById ('passwd_confirm').value;
  var widget  = getElementById ('passwd_msg');
예제 #17
0
파일: group.php 프로젝트: Nazg-Gul/gate
 function group_get_by_id($id)
 {
     return db_row_value('group', "`id`={$id}");
 }
예제 #18
0
파일: data.php 프로젝트: Nazg-Gul/gate
 */
if ($PHP_SELF != '') {
    print 'HACKERS?';
    die;
}
?>
<div id="navigator"><a href="<?php 
echo config_get('document-root');
?>
/login">Вход в систему</a><a href="<?php 
echo config_get('document-root');
?>
/login/registration">Регистрация</a>Активация пользователя</div>
${information}
<?php 
global $id, $hash;
if (!isset($id) || !isnumber($id) || !isset($hash)) {
    add_info('Пропущен обязательный параметр.');
} else {
    $r = db_row_value('user', '`id`=' . $id);
    if ($r['authorized']) {
        add_info('Ошибка активации пользователя.');
    } else {
        if (md5($r['login'] . '##VERY_RANDOM_SEED##' . $r['email'] . '##' . $r['id']) != $hash) {
            add_info('Ошибка активации пользователя.');
        } else {
            add_info('Пользователь успешно активирован. Вход в систему с логином ' . $r['login'] . ' разрешен.');
            db_update('user', array('authorized' => 1));
        }
    }
}