function canuse($pid) { $p = new DataAccess(); $sql = "select pid from problem where pid = {$pid} and submitable = 1"; $cnt = $p->dosql($sql); if ($cnt == 0) { return false; } if ($_SESSION['ID']) { $sql = "SELECT * FROM submit WHERE pid = {$pid} AND uid ={$_SESSION['ID']} order by accepted desc limit 1"; $ac = $p->dosql($sql); if ($ac) { $e = $p->rtnrlt(0); if ($e['accepted']) { return false; } else { true; } } } return true; }
$('.modal').modal('hide'); $('#sendmail').modal('show'); }; </script> <div class='row-fluid'> <div class='span6'> <table class='table table-condensed table-bordered fiexd'> <tr> <td>ID</td> <td>收件人</td> <td>发件箱</td> </tr> <?php $sql = "select mail.*,userinfo.* from mail,userinfo where mail.fromid = {$uid} and mail.toid = userinfo.uid order by mid desc"; $cnt = $p->dosql($sql); for ($i = 0; $i < $cnt; $i++) { $d = $p->rtnrlt($i); if ($d['readed'] == 0) { echo "<tr class='success'>"; } else { echo "<tr>"; } echo "<td>{$d['mid']}</td> <td>"; echo "<a href='../user/detail.php?uid={$d['toid']}' target='_blank'>" . gravatar::showImage($d['email']) . "{$d['nickname']}</a></td>"; echo "<td><a href='#mail{$d['mid']}' data-toggle='modal'>{$d['title']}</a></td>"; echo "</tr>"; ?> <div id='mail<?php echo $d['mid']; ?>
$usr = $_COOKIE['cogs_usr']; } if (!$pwd) { $pwd = $_COOKIE['cogs_pwd_hash']; } $sql = "select * from userinfo where usr='******'"; $cnt = $p->dosql($sql); if ($cnt == 0) { i异常("用户不存在!", 取路径("user/login.php")); } else { $d = $p->rtnrlt(0); if ($pwd == $d['pwdhash'] || encode($_REQUEST['password']) == $d['pwdhash']) { $LIB->get_userinfo($d['uid']); $q = new DataAccess(); $sql = "UPDATE `userinfo` SET `lastip` = '{$_SERVER['REMOTE_ADDR']}' WHERE `uid` ={$d['uid']}"; $q->dosql($sql); $sql = "insert into login(uid,ua,ip,ltime,version) values({$d['uid']},'" . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "','{$_SERVER['REMOTE_ADDR']}',NOW(),'" . mysql_real_escape_string($cfg['dir_root']) . "')"; if ($SET['login_log']) { $q->dosql($sql); } if ($_REQUEST['savepwd']) { $tm = time() + 7776000; setcookie("cogs_usr", $usr, $tm, "/"); setcookie("cogs_pwd_hash", $d['pwdhash'], $tm, "/"); } if (!$_REQUEST['from']) { $_REQUEST['from'] = base64_encode("/" . $SET['global_root']); } i提示("用户 {$d['nickname']} 登录成功!{$_REQUEST['savepwd']}", $_REQUEST['from']); } else { i异常("密码错误,登录失败!", 取路径("user/login.php"));
<?php require_once "../include/header.php"; gethead(8, "sess", ""); 过滤(); $p = new DataAccess(); if (!$_POST['pid']) { 异常("没有选择题目!", 取路径("problem/index.php")); } if (!$_POST['title']) { 异常("没有填写题解名称!", 取路径("problem/problem.php?pid={$_POST['pid']}")); } $sql = "select * from solution where `link`='' limit 1"; $cnt = $p->dosql($sql); if (!$cnt) { $sql1 = "insert into category(cname,memo) values('{$_POST['cname']}','{$_POST['memo']}')"; $p->dosql($sql1); } else { 提示("添加题目 {$_POST['pid']} 分类 “{$e['caid']}. {$_POST['cname']}” 成功,虽然它之前就已经存在了!", 取路径("problem/problem.php?pid={$_POST['pid']}")); }
public function writedb_comp($csid) { $p = new DataAccess(); $sql = "update compscore set score={$this->s_score}, result='{$this->s_detail}', memory='{$this->avgmemory}', runtime='{$this->totaltime}' where csid={$csid}"; $p->dosql($sql); }
</dd> <dt>页面标题</dt> <dd><input name="title" type="text" id="title" value="<?php echo $d['title']; ?> "></dd> <dt>阅读权限</dt> <dd><input name="force" type="number" id="force" value="<?php echo $d['force']; ?> " /> </dd> <dt>开放分组</dt> <dd><select name="group" id="group"> <?php $sql = "select * from groups order by gname"; $c = $q->dosql($sql); for ($j = 0; $j < $c; $j++) { $e = $q->rtnrlt($j); ?> <option value="<?php echo $e['gid']; ?> " <?php if ($e['gid'] == $d['group']) { echo 'selected="selected"'; } ?> >[<?php echo $e['gname']; ?> ]</option>
echo $d[ctid]; ?> ">修改</a></td> </tr> </table> <?php $sql = "select compscore.uid,userinfo.realname,userinfo.email,userinfo.nickname from compscore,userinfo where userinfo.uid=compscore.uid and compscore.ctid={$_GET[ctid]} order by uid asc"; $cnt = $p->dosql($sql); if ($cnt) { ?> <form method="post" action="judge.php"> 选择评测机:<select name='judger' id='judger'> <option value=0 selected=selected>自动选择</option> <?php $sql = "select grid,address,memo from grader where enabled=1 order by priority desc"; $cnt1 = $q->dosql($sql); for ($i = 0; $i < $cnt1; $i++) { $e = $q->rtnrlt($i); echo "<option value={$e['grid']} >{$e['memo']}</option>"; } ?> </select> <input name="do" type="submit" id="do" class='btn' value="评测选定" /> <input name="do" type="submit" id="do" class='btn' value="评测全部" /> <input name="ctid" type="hidden" id="ctid" value="<?php echo $_GET['ctid']; ?> " /> </p> <table class='table table-striped table-condensed table-bordered fiexd'>
function calc_grade($uid, $diffarr) { global $SET; $ww = 0.01; $pw = 2; //$SET['problem_weigth']; $cw = 1; //$SET['contest_weigth']; $pw *= $ww; $cw *= $ww; $uid = (int) $uid; if (!$uid) { return; } $p = new DataAccess(); $sql = "select uid, pid, score, accepted from submit where uid = {$uid}"; $cnt = $p->dosql($sql); $probs = array(); for ($i = 0; $i < $cnt; $i++) { $d = $p->rtnrlt($i); $pid = (int) $d['pid']; if (!$probs[$pid] || $probs[$pid] < $d['score']) { $probs[$pid] = $d['score']; } } $submt = (int) $cnt; $accpd = 0; $grade = 0; foreach ($probs as $key => $value) { $pid = (int) $key; $score = (int) $value; if (!$pid) { continue; } if ($value == 100) { $accpd++; } //echo "$pid.$score!!"; $diff = (int) $diffarr[$pid] + 1; //echo "$grade->"; $grade += $diff * $score * $pw; //echo "$grade. "; } $sql = "select score, pid from compscore where uid = {$uid}"; $cnt = $p->dosql($sql); for ($i = 0; $i < $cnt; $i++) { $d = $p->rtnrlt($i); $pid = (int) $d['pid']; $score = (int) $d['score']; $diff = (int) $diffarr[$pid] + 1; $grade += $diff * $score * $cw; } $grade = (int) $grade; //$grade = (int)($accpd * 2.3); $sql = "update userinfo set submited = {$submt}, accepted = {$accpd}, grade = {$grade} where uid = {$uid}"; $p->dosql($sql); return array($submt, $accpd, $grade); }
<?php require_once "../include/header.php"; gethead(8, "sess", ""); 过滤(); $p = new DataAccess(); if (!$_POST['pid']) { 异常("没有选择题目!", 取路径("problem/index.php")); } if (!$_POST['cname']) { 异常("没有填写分类名!", 取路径("problem/problem.php?pid={$_POST['pid']}")); } $sql = "select * from category where cname like '%{$_POST['cname']}%' or memo like '%{$_POST['cname']}%' limit 1"; $cnt = $p->dosql($sql); if (!$cnt) { $sql1 = "insert into category(cname,memo) values('{$_POST['cname']}','{$_POST['memo']}')"; $p->dosql($sql1); } else { $e = $p->rtnrlt(0); $st = trim("{$e['memo']} {$_POST['memo']}"); $sql1 = "update category set memo='{$st}' where caid={$e['caid']}"; $p->dosql($sql1); $sql2 = "select * from tag where pid={$_POST['pid']} and caid={$e['caid']}"; $al = $p->dosql($sql2); if ($al) { 提示("添加题目 {$_POST['pid']} 分类 “{$e['caid']}. {$_POST['cname']}” 成功,虽然它之前就已经存在了!", 取路径("problem/problem.php?pid={$_POST['pid']}")); exit(0); } } $cnt = $p->dosql($sql); if (!$cnt) {
<?php require_once "../include/header.php"; $p = new DataAccess(); $name = $_GET['name']; $sql = "SELECT pid FROM problem WHERE filename='{$name}'"; $rows = $p->dosql($sql); echo $rows;
<?php if (有此权限('查看用户') || $_SESSION['ID'] == $d['uid']) { ?> <tr> <th>真实姓名</th> <td><?php echo $d['realname']; ?> </td> </tr> <tr> <th>用户权限</th> <td> <?php $sql = "select privilege.* from privilege where uid={$d['uid']} order by pri asc"; $cnt = $q->dosql($sql); if (!$cnt) { echo array_search(0, $pri) . " "; } for ($i = 0; $i < $cnt; $i++) { $e = $q->rtnrlt($i); echo array_search($e['pri'], $pri) . " "; } ?> </td> </tr> <tr> <th>登录 IP</th> <td><a href="loginlog.php?uid=<?php echo $d['uid']; ?>
?> </table> <?php if (time() > $e['endtime']) { ?> <table class='table table-striped table-condensed table-bordered fiexd'> <tr> <th>用户</th> <th>结果</th> <th>时间</th> <th>内存</th> <th>得分</th> </tr> <?php $sql = "select * from compscore,userinfo where userinfo.uid=compscore.uid and compscore.pid={$pid} and compscore.ctid={$ctid} order by compscore.score desc, compscore.runtime asc, compscore.memory asc"; $cnt = $r->dosql($sql); for ($i = 0; $i < $cnt; $i++) { $f = $r->rtnrlt($i); ?> <tr> <td><a href="../user/detail.php?uid=<?php echo $f['uid']; ?> " target="_blank"> <?php echo gravatar::showImage($f['email'], 14); echo 有此权限('查看用户') ? $f['realname'] : $f['nickname']; ?> </a></td> <td class="wrap"><a href="code.php?csid=<?php echo $f['csid'];
<dt>E-mail</dt> <dd><input class="InputBox" name="email" type="email" value=<?php echo $d[email]; ?> ></dd> <dt>阅读权限</dt> <dd><input name="readforce" type="text" value="<?php echo $d[readforce]; ?> "></dd> <dt>所属分组</dt> <dd><select name="gbelong" id="gbelong"> <?php $q = new DataAccess(); $sql2 = "select * from groups"; $cnt2 = $q->dosql($sql2); for ($i = 0; $i <= $cnt2 - 1; $i++) { $e = $q->rtnrlt($i); ?> <option value="<?php echo $e[gid]; ?> " <?php if ($d[gbelong] == $e[gid]) { echo 'selected="selected"'; } ?> ><?php echo $e[gname]; ?> </option>
</td> <td> <a href="dodelimg.php?email=<?php echo md5($d['email']); ?> " title="重建头像缓存"><i class="icon icon-picture"></i></a> <?php echo $d['readforce']; ?> </td> <?php } ?> <td><?php $sql = "select privilege.* from privilege where uid={$d['uid']} order by pri asc"; $cnt1 = $r->dosql($sql); for ($i1 = 0; $i1 < $cnt1; $i1++) { $e = $r->rtnrlt($i1); echo array_search($e['pri'], $pri) . " "; } ?> </td> <td ><?php echo "<a href='?gid={$d['gbelong']}'>{$d['gname']}</a>"; ?> </td> <td ><?php echo $d['accepted']; ?> </td> <td ><?php
<?php require_once "../include/header.php"; gethead(1, "sess", "评测"); if (!$_POST['pid']) { 异常("你来错地方了!"); } $LIB->hlighter(); $LIB->func_socket(); $p = new DataAccess(); $sql = "select * from problem where pid={$_POST['pid']}"; $p->dosql($sql); $d = $p->rtnrlt(0); if (!$d['submitable'] && !有此权限('查看题目')) { 异常("不可提交!", 取路径("problem/index.php")); } $lang = langstrtonum($_POST['lang']); $info = array(); $info['pid'] = $_POST['pid']; $info['sid'] = $_POST['sid']; $info['uid'] = $_SESSION['ID']; $info['language'] = $lang; $info['pname'] = $d['filename']; $info['datacnt'] = $d['datacnt']; $info['timelimit'] = $d['timelimit']; $ptitle = $d['probname']; $info['memorylimit'] = $d['memorylimit']; $info['plugin'] = $d['plugin']; $info['compiledir'] = $SET['dir_source']; $info['mode'] = "normal"; if ($_POST['testmode'] == '1' && 有此权限('测试题目')) {
"></td> <td id="nickname<?php echo $rowcnt; ?> "><a href="../user/detail.php?uid=<?php echo $d['uid']; ?> " target="_blank"> <?php echo gravatar::showImage($d['email'], 14); echo 有此权限('查看用户') ? $d['realname'] : $d['nickname']; ?> </a></td> <?php $sql = "select pid,result,score,csid,lang from compscore where uid='{$d['uid']}' and ctid={$_GET[ctid]} order by pid asc"; $cnt_sub = $q->dosql($sql); $sum = 0; $rank = $mbarray; for ($j = 0; $j < $cnt_sub; $j++) { $e = $q->rtnrlt($j); $sum += $e[score]; $rank[$e[pid]][csid] = $e[csid]; $rank[$e[pid]][score] = $e[score]; $rank[$e[pid]][result] = $e[result]; } foreach ($pbs as $k => $v) { ?> <td id="result<?php echo $v; ?> _<?php
if ($ac) { $e = $q->rtnrlt(0); $acpid = $e['accepted']; echo "<a href='../submit/code.php?id={$e['sid']}'>"; echo $STR['lang'][$e['lang']]; echo "</a> "; 评测结果($e['result'], 20); } } } ?> </td></tr> <tr><th id="fenleito" title="单击以显示或隐藏分类标签" style="cursor:pointer">分类标签</th> <td><div id="fenlei"><?php $sql = "select category.cname,category.memo,category.caid from category,tag where tag.pid={$_GET[pid]} and category.caid=tag.caid"; $cnt2 = $r->dosql($sql); for ($i = 0; $i <= $cnt2 - 1; $i++) { $e = $r->rtnrlt($i); HTML(" <a href='index.php?caid={$e['caid']}' target='_blank' title='{$e['memo']}' class='btn btn-mini'>{$e['cname']}</a> "); } if (!$acpid) { ?> <script> $('#fenlei').hide(); </script> <?php } else { ?> <a id="addfenlei" class='btn btn-success btn-mini pull-right' href="#addcate" data-toggle='modal' title="添加分类标签"><i class='icon-plus icon-white'></i></a> <div id='addcate' class='modal hide fade in'> <form method="post" action="addcate.php" class='form-horizontal'>
<?php require_once "./include/header.php"; gethead(1, "", "首页"); $p = new DataAccess(); $q = new DataAccess(); $sizee = $SET['style_ranksize'] - 7; ?> <div class='row-fluid'> <div class='span9'> <div class='row-fluid'> <div class='span4' id="index_page"> <?php $now = time(); $noww = time() + 60 * 60 * 2; $cnt = $p->dosql("select comptime.*,compbase.*,userinfo.nickname,groups.* from comptime,compbase,userinfo,groups where comptime.cbid=compbase.cbid and userinfo.uid=compbase.ouid and comptime.group=groups.gid and endtime > {$now} and starttime < {$noww} order by starttime asc"); if ($cnt) { for ($i = 0; $i < $cnt; $i++) { $d = $p->rtnrlt($i); ?> <table class='table table-striped table-condensed table-bordered fiexd'> <tr> <th style="min-width: 3em;">比赛</th> <td><b><?php echo $d[cname]; ?> </b></td> </tr> <tr> <th>状态</th> <td><?php