Exemplo n.º 1
0
function compile($query)
{
    global $compiledir, $datadir;
    getdir($query);
    $compilecommand = getcompilecommand($query);
    $query['code'] = filter($query['code'], $query['language']);
    wfile($query['code'], $query['src']);
    if (file_exists($query['pname'])) {
        unlink($query['pname']);
    }
    $compilecommand = "timelimit 20 " . $compilecommand;
    $handle = popen($compilecommand, 'r');
    $tmp['msg'] = rfile($handle);
    pclose($handle);
    if (file_exists($query['pname']) || $query['language'] == 3) {
        $tmp['compilesucc'] = 1;
    } else {
        $tmp['compilesucc'] = 0;
    }
    echo array_encode($tmp);
}
Exemplo n.º 2
0
 public function compile()
 {
     $s['action'] = "compile";
     $s['pname'] = $this->info['pname'];
     $s['uid'] = $this->info['uid'];
     $s['language'] = $this->info['language'];
     $s['src'] = $this->info['pname'] . '.' . langnumtostr($this->info['language']);
     $fp = fopen($this->srcname, "r");
     $s['code'] = rfile($fp);
     fclose($fp);
     if ($this->info['mode'] == "test") {
         unlink($this->srcname);
     }
     chdir($this->odir);
     $this->cmds = $tmp = httpsocket($this->gds, $s);
     $this->state = array_decode($tmp);
     $this->compilemessage = $this->state['msg'];
     if ($this->state['compilesucc']) {
         return 1;
     } else {
         return 0;
     }
 }
Exemplo n.º 3
0
        异常("比赛未结束!", 取路径("contest/index.php"));
    }
    if ($d[lang] == 0) {
        $ext = "pas";
    } else {
        if ($d[lang] == 1) {
            $ext = "c";
        } else {
            if ($d[lang] == 2) {
                $ext = "cpp";
            }
        }
    }
    $fp = fopen("{$SET['dir_competition']}{$d[ctid]}/{$d[uid]}/{$d[filename]}.{$ext}", "r");
    if (is_resource($fp)) {
        $code = rfile($fp);
    }
    fclose($fp);
    $code = mb_convert_encoding($code, "utf-8", "gbk");
} else {
    异常("提交记录不存在");
}
gethead(1, "sess", "比赛代码", $d['uid']);
$LIB->hlighter();
?>
<div class='row-fluid'>
<table class='table table-striped table-condensed table-bordered fiexd'>
<tr>
    <th width="60px">比赛</th>
    <td><b><?php 
echo $d['cname'];