Skip to content

Commit

Permalink
Merge pull request zhblue#362 from jizhuozhi/master
Browse files Browse the repository at this point in the history
Use card component (panel in bs3) to display problem content
  • Loading branch information
zhblue authored Nov 22, 2018
2 parents 3cd5c52 + 87c4b37 commit 27c1122
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 133 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ https://www.youtube.com/watch?v=hRap7ettUWc

/home/judge/etc/judge.conf 判题judged/judge_client
/home/judge/src/web/include/db_info.inc.php Web
/etc/php5/fpm/php.ini 或 /etc/php7.0/fpm/php.ini php
/etc/nginx/sites-enabled/default nginx
/etc/php5/fpm/php.ini 或 /etc/php7.0/fpm/php.ini 或 /etc/php.ini (in Centos7) php
/etc/nginx/sites-enabled/default 或 /etc/nginx/nginx.conf (in Centos7) nginx

如果用户量比较大,报50x错误,可能需要修改/etc/nginx/nginx.conf中的设置:
```
Expand Down
6 changes: 3 additions & 3 deletions trunk/web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
array_push($chart_data_ac,array($row['md'],$row['c']));
}
if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
$sql="select avg(sp) sp from (select count(1) sp,judgetime from solution where result>3 and judgetime>convert(now()-100,DATETIME) group by judgetime order by sp) tt;";
$sql="select avg(sp) sp from (select avg(1) sp,judgetime from solution where result>3 and judgetime>date_sub(now(),interval 1 hour) group by (judgetime DIV 60 * 60) order by sp) tt;";
$result=mysql_query_cache($sql);
$speed=$result[0][0]?$result[0][0]:0;
$speed=($result[0][0]?$result[0][0]:0).'/min';
}else{
$speed=$chart_data_all[0][1]?$chart_data_all[0][1]:0;
$speed=($chart_data_all[0][1]?$chart_data_all[0][1]:0).'/day';
}


Expand Down
333 changes: 205 additions & 128 deletions trunk/web/template/bs3/problem.php
Original file line number Diff line number Diff line change
@@ -1,147 +1,224 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title><?php echo $OJ_NAME?></title>
<title>
<?php echo $OJ_NAME?>
</title>

<?php include("template/$OJ_TEMPLATE/css.php");?>
<?php include("template/$OJ_TEMPLATE/css.php");?>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<div class="container">
<?php include("template/$OJ_TEMPLATE/nav.php");?>

<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron">
<?php
if($pr_flag){
echo "<title>$MSG_PROBLEM".$row['problem_id']."--". $row['title']."</title>";
echo "<center><h3>$id: ".$row['title']."</h3>";
}else{
//$PID="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$id=$row['problem_id'];
echo "<title>$MSG_PROBLEM ".$PID[$pid].": ".$row['title']." </title>";
echo "<center><h3>$MSG_PROBLEM ".$PID[$pid].": ".$row['title']."</h3>";
}

echo "<span class=green>$MSG_Time_Limit: </span>".$row['time_limit']." Sec&nbsp;&nbsp;";
echo "<span class=green>$MSG_Memory_Limit: </span>".$row['memory_limit']." MB";

if($row['spj']) echo "&nbsp;&nbsp;<span class=red>Special Judge</span>";
echo "<br><span class=green>$MSG_SUBMIT: </span>".$row['submit']."&nbsp;&nbsp;";
echo "<span class=green>$MSG_SOVLED: </span>".$row['accepted']."<br>";

if($pr_flag){
echo "[<a href='submitpage.php?id=$id'>$MSG_SUBMIT</a>] ";
}else{
echo "[<a href='submitpage.php?cid=$cid&pid=$pid&langmask=$langmask'>$MSG_SUBMIT</a>] ";
}

echo "[<a href='problemstatus.php?id=".$row['problem_id']."'>$MSG_STATUS</a>] ";
echo "[<a href='bbs.php?pid=".$row['problem_id']."$ucid'>$MSG_BBS</a>] ";
echo "[$MSG_Creator:<span id='creator'></span>]";

if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
require_once("include/set_get_key.php");
?>

[<a href="admin/problem_edit.php?id=<?php echo $id?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>" >Edit</a>]
[<a href='javascript:phpfm(<?php echo $row['problem_id'];?>)'>TestData</a>]

<?php
}

echo "</center>";
echo "<!--StartMarkForVirtualJudge-->";
echo "<h4>$MSG_Description</h4><div class=content>".$row['description']."</div><br>";

if($row['input'])echo "<h4>$MSG_Input</h4><div class=content>".$row['input']."</div><br>";
if($row['output'])echo "<h4>$MSG_Output</h4><div class=content>".$row['output']."</div><br>";

<div class="container">
<?php include("template/$OJ_TEMPLATE/nav.php");?>

<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron"></div>

<div class="panel panel-default">
<div class="panel-heading">
<?php
if ( $pr_flag ) {
echo "<title>$MSG_PROBLEM" . $row[ 'problem_id' ] . "--" . $row[ 'title' ] . "</title>";
echo "<center><h3>$id: " . $row[ 'title' ] . "</h3>";
} else {
//$PID="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$id = $row[ 'problem_id' ];
echo "<title>$MSG_PROBLEM " . $PID[ $pid ] . ": " . $row[ 'title' ] . " </title>";
echo "<center><h3>$MSG_PROBLEM " . $PID[ $pid ] . ": " . $row[ 'title' ] . "</h3>";
}

echo "<span class=green>$MSG_Time_Limit: </span>" . $row[ 'time_limit' ] . " Sec&nbsp;&nbsp;";
echo "<span class=green>$MSG_Memory_Limit: </span>" . $row[ 'memory_limit' ] . " MB";

if ( $row[ 'spj' ] )echo "&nbsp;&nbsp;<span class=red>Special Judge</span>";
echo "<br><span class=green>$MSG_SUBMIT: </span>" . $row[ 'submit' ] . "&nbsp;&nbsp;";
echo "<span class=green>$MSG_SOVLED: </span>" . $row[ 'accepted' ] . "<br>";

if ( $pr_flag ) {
echo "[<a href='submitpage.php?id=$id'>$MSG_SUBMIT</a>] ";
} else {
echo "[<a href='submitpage.php?cid=$cid&pid=$pid&langmask=$langmask'>$MSG_SUBMIT</a>] ";
}

echo "[<a href='problemstatus.php?id=" . $row[ 'problem_id' ] . "'>$MSG_STATUS</a>] ";
echo "[<a href='bbs.php?pid=" . $row[ 'problem_id' ] . "$ucid'>$MSG_BBS</a>] ";
echo "[$MSG_Creator:<span id='creator'></span>]";

if ( isset( $_SESSION[ $OJ_NAME . '_' . 'administrator' ] ) ) {
require_once( "include/set_get_key.php" );
?> [

<a href="admin/problem_edit.php?id=<?php echo $id?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>">Edit</a>] [
<a href='javascript:phpfm(<?php echo $row[' problem_id '];?>)'>TestData</a>]

<?php
}

echo "</center>";
# end of head
echo "</div>";
echo "<!--StartMarkForVirtualJudge-->";
?>

<div class="panel panel-body">
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_Description?>
</h4>
</div>
<div class='panel-body content'>
<?php echo $row['description']?>
</div>
</div>

<?php
if($row['input']){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_Input?>
</h4>
</div>
<div class='panel-body content'>
<?php echo $row['input']?>
</div>
</div>
<?php }
if($row['output']){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_Output?>
</h4>
</div>
<div class='panel-body content'>
<?php echo $row['output']?>
</div>
</div>
<?php }
$sinput=str_replace("<","&lt;",$row['sample_input']);
$sinput=str_replace(">","&gt;",$sinput);
$soutput=str_replace("<","&lt;",$row['sample_output']);
$soutput=str_replace(">","&gt;",$soutput);

if(strlen($sinput)){
echo "<h4>$MSG_Sample_Input</h4><pre class=content><span class=sampledata>".($sinput)."</span></pre><br>";
}

if(strlen($soutput)){
echo "<h4>$MSG_Sample_Output</h4><pre class=content><span class=sampledata>".($soutput)."</span></pre><br>";
}

if($row['hint']){
echo "<h4>$MSG_HINT</h4><div class='hint content'>".$row['hint']."</div><br>";
}

if($pr_flag){
echo "<h4>$MSG_SOURCE</h4><div class=content>";
$cats=explode(" ",$row['source']);
foreach($cats as $cat){
echo "<a href='problemset.php?search=".htmlentities($cat,ENT_QUOTES,'utf-8')."'>".htmlentities($cat,ENT_QUOTES,'utf-8')."</a>&nbsp;";
}
echo "</div><br>";
}

echo "<center>";
echo "<!--EndMarkForVirtualJudge-->";

if($pr_flag){
echo "[<a href='submitpage.php?id=$id'>$MSG_SUBMIT</a>] ";
}else{
echo "[<a href='submitpage.php?cid=$cid&pid=$pid&langmask=$langmask'>$MSG_SUBMIT</a>]";
}

echo "[<a href='problemstatus.php?id=".$row['problem_id']."'>$MSG_STATUS</a>]";
//echo "[<a href='bbs.php?pid=".$row['problem_id']."$ucid'>$MSG_BBS</a>]";

if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
require_once("include/set_get_key.php");
?>

[<a href="admin/problem_edit.php?id=<?php echo $id?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>" >Edit</a>]
[<a href='javascript:phpfm(<?php echo $row['problem_id'];?>)'>TestData</a>]

<?php
}

echo "</center>";
?>
</div>
</div> <!-- /container -->


<!-- Bootstrap core JavaScript
if(strlen($sinput)){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_Sample_Input?>
</h4>
</div>
<div class='panel-body'><pre class=content><span class=sampledata><?php echo $sinput?></span></pre>
</div>
</div>
<?php }

if(strlen($soutput)){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_Sample_Output?>
</h4>
</div>
<div class='panel-body'><pre class=content><span class=sampledata><?php echo $soutput?></span></pre>
</div>
</div>
<?php }

if($row['hint']){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_HINT?>
</h4>
</div>
<div class='panel-body content'>
<?php echo $row['hint']?>
</div>
</div>
<?php }

if($pr_flag){?>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4>
<?php echo $MSG_SOURCE?>
</h4>
</div>
<div class='panel-body content'>
<?php
$cats=explode(" ",$row['source']);
foreach($cats as $cat){
echo "<a href='problemset.php?search=".htmlentities($cat,ENT_QUOTES,'utf-8')."'>".htmlentities($cat,ENT_QUOTES,'utf-8')."</a>&nbsp;";
}?>
</div>
</div>
<?php }?>

</div>
<center>
<!--EndMarkForVirtualJudge-->
<div class='panel-footer'>
<?php
if($pr_flag){
echo "[<a href='submitpage.php?id=$id'>$MSG_SUBMIT</a>] ";
}else{
echo "[<a href='submitpage.php?cid=$cid&pid=$pid&langmask=$langmask'>$MSG_SUBMIT</a>]";
}
echo "[<a href='problemstatus.php?id=".$row['problem_id']."'>$MSG_STATUS</a>]";
//echo "[<a href='bbs.php?pid=".$row['problem_id']."$ucid'>$MSG_BBS</a>]";

if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
require_once("include/set_get_key.php");
?> [

<a href="admin/problem_edit.php?id=<?php echo $id?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>">Edit</a>] [
<a href='javascript:phpfm(<?php echo $row[' problem_id '];?>)'>TestData</a>]
<?php } ?>
</div>
</center>
</div>
</div>
<!-- /container -->


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<?php include("template/$OJ_TEMPLATE/js.php");?>
<script>
function phpfm(pid){
//alert(pid);
$.post("admin/phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
if(status=="success"){
document.location.href="admin/phpfm.php?frame=3&pid="+pid;
}
});
}

$(document).ready(function(){
$("#creator").load("problem-ajax.php?pid=<?php echo $id?>");
});
</script>
<!-- Placed at the end of the document so the pages load faster -->
<?php include("template/$OJ_TEMPLATE/js.php");?>
<script>
function phpfm( pid ) {
//alert(pid);
$.post( "admin/phpfm.php", {
'frame': 3,
'pid': pid,
'pass': ''
}, function ( data, status ) {
if ( status == "success" ) {
document.location.href = "admin/phpfm.php?frame=3&pid=" + pid;
}
} );
}

$( document ).ready( function () {
$( "#creator" ).load( "problem-ajax.php?pid=<?php echo $id?>" );
} );
</script>

</body>
</html>
</html>

0 comments on commit 27c1122

Please sign in to comment.