diff options
author | pzread <netfirewall@gmail.com> | 2012-12-09 15:46:19 +0800 |
---|---|---|
committer | pzread <netfirewall@gmail.com> | 2012-12-09 15:46:19 +0800 |
commit | 1eb32c90ffc524b7d56eb0c64386c366848854b8 (patch) | |
tree | 1734e74e00d9ea4ff868dd071a8e9ac638351838 /web/problem_view.php | |
parent | eb4b34b75c356247506be0251bb1b7963f605c48 (diff) | |
download | taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar.gz taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar.bz2 taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar.lz taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar.xz taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.tar.zst taiwan-online-judge-1eb32c90ffc524b7d56eb0c64386c366848854b8.zip |
ExpOJ web code
Diffstat (limited to 'web/problem_view.php')
-rw-r--r-- | web/problem_view.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/web/problem_view.php b/web/problem_view.php new file mode 100644 index 0000000..d53db88 --- /dev/null +++ b/web/problem_view.php @@ -0,0 +1,41 @@ +<?php +require_once('common.php'); + +function problem_view($sqlc,$paramo){ + $proid = $paramo->proid; + $infoonly = $paramo->infoonly; + + if(gettype($proid) != 'integer' || $proid < 1){ + return null; + } + + $sqlc = pg_connect('host=localhost port=5432 dbname='.DB_NAME.' user='.DB_USER.' password='.DB_PASSWORD); + + $proid = pg_escape_string($proid); + $sqlr = pg_query_params($sqlc,'SELECT * FROM "problem" WHERE proid=$1 LIMIT 1;', + array($proid)); + if(($proo = pg_fetch_object($sqlr)) == null){ + pg_free_result($sqlr); + return null; + } + + if($infoonly){ + $proo = array( + 'acceptcount' => $proo->acceptcount, + 'submitcount' => $proo->submitcount); + }else{ + $setting_info = parse_ini_file('pro/'.$proo->proid.'/'.$proo->proid.'_setting.txt',true); + $proo = array( + 'proid' => $proo->proid, + 'proname' => $proo->proname, + 'timelimit' => $setting_info['JUDGE']['timelimit'], + 'memlimit' => $setting_info['JUDGE']['memlimit'], + 'acceptcount' => $proo->acceptcount, + 'submitcount' => $proo->submitcount, + 'protext' => file_get_contents('pro/'.$proo->proid.'/'.$proo->proid.'_text.txt')); + } + + pg_free_result($sqlr); + return $proo; +} +?> |