-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
78 lines (71 loc) · 1.82 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
//echo "in";
require_once "File.php";
$siteport = '80';
$sitedir = '/scoreboard/';
$siteroot = '//'.$_SERVER['SERVER_NAME'].':'.$siteport.$sitedir;
//echo "load data...";
$QUEST = '';
if (isset($_SERVER['PATH_INFO'])) {
$QUEST = $_SERVER['PATH_INFO'];
}
if (!empty($QUEST)) { //remove first '/'
$QUEST = substr($QUEST, 1);
}
$QUEST = explode('/', $QUEST);
$contestn="";
$classn="";
if(empty($QUEST[0])){
if(!isset($_POST['change'])){
exit ('please add class name!!!');
}
else{
$classn = json_decode($_POST['change'])->class_name;
}
}
else{
$classn = (string)$QUEST[0];
}
if(empty($QUEST[1])){
if(!isset($_POST['change'])){
exit ('please add contest name!!!');
}
else{
$contestn = json_decode($_POST['change'])->contest_name;
}
}
else{
$contestn = (string)$QUEST[1];
}
if(!is_dir($classn))exit ('no class');
if(!is_dir($classn.'/'.$contestn))exit ('no contest');
$dir = $classn.'/'.$contestn;
$contest = json_decode(file_read($dir.'/contest.json'));
$pr_num = $contest->pro_num;
$title = $contest->name;
$problem_list = $contest->problem;
$user_list = json_decode(file_read($dir.'/userlist.json'));
$sa = [];
foreach($user_list as $u){
$user_list[$u->id]->score = json_decode(file_read($dir."/users/user{$u->id}.json"));
$user_list[$u->id]->scoresum = 0;
foreach($user_list[$u->id]->score as $sc){
$user_list[$u->id]->scoresum += $sc;
}
$sa[$u->id] = $user_list[$u->id]->scoresum;
}
require_once "update.php";
$uranknum = 1;
$uranknumsh = 1;
$upuscore = 0;
$i=0;
foreach($contest->ranklist as $key){
if($user_list[$key]->scoresum != $upuscore && $i!=0){
$uranknumsh = $uranknum;
}
$user_list[$key]->rank = $uranknumsh;
$upuscore = $user_list[$key]->scoresum;
$uranknum++;
$i++;
}
require_once 'rank.php';