示例#1
0
文件: ipc.php 项目: Nazg-Gul/gate
 function ipc_initialize()
 {
     ipc_register_function('check_login', ipc_check_login);
     ipc_register_function('check_email', ipc_check_email);
     ipc_register_function('check_wiki_node', ipc_check_wiki_node);
     ipc_register_function('check_path_exists', ipc_check_path_exists);
 }
示例#2
0
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Rejudge problem
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_cmd_problem_rejudge_included_ != '###WT_IPC_ProblemRejudge_Inclided###') {
    $_WT_ipc_cmd_problem_rejudge_included_ = '###WT_IPC_ProblemRejudge_Inclided###';
    function WT_ProblemRejudge()
    {
        global $id;
        if ($id == '') {
            return;
        }
        $gw = WT_spawn_new_gateway();
        if ($gw->current_lib->IPC_Problem_Rejudge($id)) {
            print '+OK';
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('cmd_problem_rejudge', WT_ProblemRejudge);
}
示例#3
0
 * Add tag to problem
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_cmd_problem_add_tag_included_ != '###WT_IPC_ProblemAddTag_Inclided###') {
    $_WT_ipc_cmd_problem_add_tag_included_ = '###WT_IPC_ProblemAddTag_Inclided###';
    function WT_ProblemAddTag()
    {
        $id = $_POST['id'];
        $tag = trim($_POST['tag']);
        if (!isnumber($id) || $tag == '') {
            print '-ERR';
            return;
        }
        $gw = WT_spawn_new_gateway();
        if ($gw->current_lib->IPC_Problem_AddTag($id, $tag)) {
            print '+OK';
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('cmd_problem_add_tag', WT_ProblemAddTag);
}
示例#4
0
        }
        $solution = db_row(db_select('tester_solutions', array('*'), "`id`={$id}"));
        if ($solution['id'] == '') {
            return;
        }
        $contest = db_row(db_select('tester_contests', array('*'), '`id`=' . $solution['contest_id'] . ' AND `lid`=' . $lid));
        $problem = db_row(db_select('tester_problems', array('*'), '`id`=' . $solution['problem_id'] . ' AND `lid`=' . $lid));
        $contest['settings'] = unserialize($contest['settings']);
        $solution['parameters'] = unserialize($solution['parameters']);
        $arr = array();
        // Solution's based settings
        $arr['PROBLEMID'] = $solution['problem_id'];
        $arr['COMPILERID'] = $solution['parameters']['compiler_id'];
        $arr['SOURCE'] = $solution['parameters']['src'];
        if ($contest['settings']['rules'] == 0) {
            $arr['ACM'] = 'TRUE';
        } else {
            $arr['ACM'] = 'FALSE';
        }
        // Problem's passed settings
        $prpars = unserialize($problem['settings']);
        $arr['TIMELIMIT'] = $prpars['timelimit'];
        $arr['MEMORYLIMIT'] = $prpars['memorylimit'];
        $arr['INPUTFILE'] = $prpars['input'];
        $arr['OUTPUTFILE'] = $prpars['output'];
        $arr['TESTS'] = $prpars['tests'];
        $arr['BONUS'] = $prpars['bonus'];
        print db_pack($arr);
    }
    ipc_register_function('get_task', WT_GetTask);
}
示例#5
0
    die;
}
if ($_WT_ipc_get_problem_included_ != '###WT_IPC_GetProblem_Inclided###') {
    $_WT_ipc_get_problem_included_ = '###WT_IPC_GetProblem_Inclided###';
    function WT_GetProblem()
    {
        global $lid;
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        if ($lid == '') {
            return;
        }
        $q = db_select('tester_problems', array('*'), '(`uploaded`=FALSE) AND (`lid`=' . $lid . ')', 'ORDER BY `id` LIMIT 1');
        if (db_affected() <= 0) {
            return;
        }
        $r = db_row($q);
        $s = unserialize($r['settings']);
        $arr = array();
        $arr['ID'] = $r['id'];
        if (isset($s['filename'])) {
            $arr['FILENAME'] = $s['filename'];
        }
        if (preg_match('/[0-9]+/', $s['checker'])) {
            $arr['CHECKER'] = $s['checker'];
        }
        print db_pack($arr);
    }
    ipc_register_function('get_problem', WT_GetProblem);
}
示例#6
0
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Toggle problem's usage in contest
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_cmd_toggle_prusage_included_ != '###WT_IPC_ToggleProblemUsage_Inclided###') {
    $_WT_ipc_cmd_toggle_prusage_included_ = '###WT_IPC_ToggleProblemUsage_Inclided###';
    function WT_ToggleProblemUsage()
    {
        global $cid, $id;
        if ($id == '' || $cid == '') {
            return;
        }
        $gw = WT_spawn_new_gateway();
        if ($gw->current_lib->IPC_Contest_ToggleDisableProblem($cid, $id)) {
            print '+OK';
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('cmd_problem_toggle_usage', WT_ToggleProblemUsage);
}
示例#7
0
<?php

/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Get task list
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_get_task_list_included_ != '##WT_IPC_GetTaskList_Inclided##') {
    $_WT_ipc_get_task_list_included_ = '##WT_IPC_GetTaskList_Inclided##';
    function WT_GetTaskList()
    {
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        $q = db_query('SELECT `ts`.`id`, `ts`.`lid` ' . 'FROM `tester_solutions` AS `ts`, ' . '`tester_problems` AS `tp` ' . 'WHERE (`ts`.`status`=0) AND ' . '(`ts`.`problem_id`=`tp`.`id`) AND ' . '(`tp`.`uploaded`=2) ORDER BY `timestamp` LIMIT 15');
        while ($r = db_row($q)) {
            println($r['id'] . '@' . $r['lid']);
        }
    }
    ipc_register_function('get_task_list', WT_GetTaskList);
}
示例#8
0
/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Get checker for uploading
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_get_checker_included_ != '###WT_IPC_GetChecker_Inclided###') {
    $_WT_ipc_get_checker_included_ = '###WT_IPC_GetChecker_Inclided###';
    function WT_GetChecker()
    {
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        $r = db_row(db_select('tester_checkers', array('*'), '`uploaded`=FALSE', 'LIMIT 1'));
        if ($r) {
            $s = unserialize($r['settings']);
            $arr = array('ID' => $r['id'], 'SRC' => $s['src'], 'COMPILERID' => $s['compiler_id']);
            print db_pack($arr);
        }
    }
    ipc_register_function('get_checker', WT_GetChecker);
}
示例#9
0
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_put_problem_included_ != '###WT_IPC_PutProblem_Inclided###') {
    $_WT_ipc_put_problem_included_ = '###WT_IPC_PutProblem_Inclided###';
    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})");
    }
    ipc_register_function('put_problem', WT_PutProblem);
}
示例#10
0
 * Remove tag from problem
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_cmd_problem_rm_tag_included_ != '###WT_IPC_ProblemRmTag_Inclided###') {
    $_WT_ipc_cmd_problem_rm_tag_included_ = '###WT_IPC_ProblemRmTag_Inclided###';
    function WT_ProblemRemoveTag()
    {
        $id = $_POST['id'];
        $tag = trim($_POST['tag']);
        if (!isnumber($id) || $tag == '') {
            print '-ERR';
            return;
        }
        $gw = WT_spawn_new_gateway();
        if ($gw->current_lib->IPC_Problem_RemoveTag($id, $tag)) {
            print '+OK';
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('cmd_problem_rm_tag', WT_ProblemRemoveTag);
}
示例#11
0
<?php

/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Reset status of half-tested solutions
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_reset_status_included_ != '###WT_IPC_ResetStatus_Inclided###') {
    $_WT_ipc_reset_status_included_ = '###WT_IPC_ResetStatus_Inclided###';
    function WT_ResetStatus()
    {
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        db_update('tester_solutions', array('status' => 0), '`status`=1');
    }
    ipc_register_function('reset_status', WT_ResetStatus);
}
示例#12
0
/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Reset status of solutions
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_restore_task_included_ != '###WT_IPC_RestoreTask_Inclided###') {
    $_WT_ipc_restore_task_included_ = '###WT_IPC_RestoreTask_Inclided###';
    function WT_RestoreTask()
    {
        global $id, $lid;
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        if (!isset($id) || !isset($lid)) {
            print 'Void filename for WT_RestoreTask';
            return;
        }
        db_update('tester_solutions', array('status' => 0, 'errors' => '""', 'points' => 0), "`id`={$id} AND `lid`={$lid}");
    }
    ipc_register_function('restore_task', WT_RestoreTask);
}
示例#13
0
<?php

/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE, $MARKET;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_MARKET_ipc_get_vendors_included_ != '###WT_IPC_BasketAdd_Inclided###') {
    $_MARKET_ipc_get_vendors_included_ = '###WT_IPC_BasketAdd_Inclided###';
    function MARKET_GetVendors()
    {
        global $catid, $MARKET;
        InitMarket();
        if (isNumber($catid)) {
            print '+OK ' . $MARKET->GetVendorsJSON($catid);
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('get_vendors', MARKET_GetVendors);
}
示例#14
0
/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Delete task from testing queue
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_delete_task_included_ != '###WT_IPC_DeleteTask_Inclided###') {
    $_WT_ipc_delete_task_included_ = '###WT_IPC_DeleteTask_Inclided###';
    function WT_DeleteTask()
    {
        global $id, $lid;
        if (!WT_IPC_CheckLogin()) {
            return;
        }
        if (!isset($id) || !isset($lid)) {
            print 'Void filename for WT_DeleteTask';
            return;
        }
        db_update('tester_solutions', array('status' => 1), "`id`={$id} AND `lid`={$lid}");
    }
    ipc_register_function('delete_task', WT_DeleteTask);
}
示例#15
0
 *
 * Get problem's description
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_get_get_problem_desc_included_ != '###WT_IPC_GetProblemDesc_Inclided###') {
    $_WT_ipc_get_problem_desc_included_ = '###WT_IPC_GetProblemDesc_Inclided###';
    function WT_GetProblemDesc()
    {
        global $id, $cid, $backlink;
        if ($id == '' || $cid == '') {
            return;
        }
        $gw = WT_spawn_new_gateway();
        $r = $gw->current_lib->IPC_Problem_DescriptionForm($id, $cid, $backlink);
        if ($r != '') {
            print setvars($r);
        } else {
            print '&nbsp;';
        }
    }
    ipc_register_function('get_problem_desc', WT_GetProblemDesc);
}
示例#16
0
文件: monitor.php 项目: Nazg-Gul/gate
<?php

/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Get monitor
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_get_get_problem_desc_included_ != '###WT_IPC_GetProblemDesc_Inclided###') {
    $_WT_ipc_get_problem_desc_included_ = '###WT_IPC_GetProblemDesc_Inclided###';
    function WT_IPC_Monitor()
    {
        $gw = WT_spawn_new_gateway();
        $r = $gw->current_lib->IPC_Monitor();
        if ($r != '') {
            print setvars($r);
        } else {
            print '&nbsp;';
        }
    }
    ipc_register_function('monitor', WT_IPC_Monitor);
}
示例#17
0
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_WT_ipc_put_checker_included_ != '###WT_IPC_PutChecker_Inclided###') {
    $_WT_ipc_put_checker_included_ = '###WT_IPC_PutChecker_Inclided###';
    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}");
    }
    ipc_register_function('put_checker', WT_PutChecker);
}
示例#18
0
        $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}");
    }
    ipc_register_function('put_solution', WT_PutSolution);
}
示例#19
0
<?php

/**
 * Gate - Wiki engine and web-interface for WebTester Server
 *
 * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**>
 *
 * This program can be distributed under the terms of the GNU GPL.
 * See the file COPYING.
 */
global $IFACE, $MARKET;
if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') {
    print 'HACKERS?';
    die;
}
if ($_MARKET_ipc_basket_add_included_ != '###WT_IPC_BasketAdd_Inclided###') {
    $_MARKET_ipc_basket_add_included_ = '###WT_IPC_BasketAdd_Inclided###';
    function MARKET_BasketAdd()
    {
        global $id, $MARKET;
        InitMarket();
        if (isNumber($id) && $MARKET->BASKET->AddItemById($id)) {
            print '+OK';
        } else {
            print '-ERR';
        }
    }
    ipc_register_function('basket_add', MARKET_BasketAdd);
}