1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>ICPC</title>
5
+ </head>
6
+ <body>
7
+ <?php
8
+ $ data = null ;
9
+ $ fname = "icpc.dat " ;
10
+ if (file_exists ($ fname )) {
11
+ $ con = file_get_contents ($ fname );
12
+ if (sizeof ($ con )!=0 )
13
+ $ data = json_decode ($ con ,true );
14
+ }
15
+ if (is_null ($ data )) {
16
+ $ data = array ();
17
+ }
18
+ // $data['ICPC Onsite Regionals Kolkata 2016'] = array('start' => 0, 'code' => 'ACM16KOL', 'status' => [0,0,0,0,0,0,0,0,0,0,0,0],'fail' => [0,0,0,0,0,0,0,0,0,0,0,0],'live' => false );
19
+ // $data['ICPC Onsite Regionals KGP 2016'] = array('start' => 0, 'code' => 'KGP16', 'status' => [0,0,0,0,0,0,0,0,0,0,0],'fail' => [0,0,0,0,0,0,0,0,0,0,0],'live' => false );
20
+ // $data['ICPC Onsite Regionals Kanpur 2013'] = array('start' => 0, 'code' => 'KAN13', 'status' => [0,0,0,0,0,0,0,0,0], 'fail' => [0,0,0,0,0,0,0,0,0],'live' => false );
21
+ // $data['ICPC Onsite Regionals KGP 2013'] = array('start' => 0, 'code' => 'KGP13', 'status' => [0,0,0,0,0,0,0,0,0,0,0],'fail' => [0,0,0,0,0,0,0,0,0,0,0],'live' => false );
22
+ // file_put_contents($fname, json_encode($data));
23
+
24
+ if (isset ($ _GET ['code ' ])) {
25
+ $ name = $ _GET ['code ' ];
26
+ if (isset ($ _GET ['start ' ])) {
27
+ if ($ data [$ name ]['start ' ]==0 ) {
28
+ $ data [$ name ]['start ' ] = microtime (true );
29
+ header ("LOCATION: / " );
30
+ file_put_contents ($ fname , json_encode ($ data ));
31
+ exit ();
32
+ }
33
+ }
34
+ if ($ data [$ name ]['start ' ]==0 ) {
35
+ echo $ name ." Competition Not Started!!! " ;
36
+ } else {
37
+ $ problem = (int )$ _GET ['problem ' ];
38
+ if (isset ($ _GET ['accept ' ])) {
39
+ if ($ data [$ name ]['status ' ][$ problem ]==0 || $ _GET ['accept ' ]=='force ' )
40
+ $ data [$ name ]['status ' ][$ problem ] = microtime (true );
41
+ }
42
+ if (isset ($ _GET ['fail ' ])) {
43
+ // echo $data[$name]['fail'][$problem];
44
+ if ($ data [$ name ]['status ' ][$ problem ]==0 || $ _GET ['accept ' ]=='force ' )
45
+ $ data [$ name ]['fail ' ][$ problem ] += 1 ;
46
+ }
47
+ header ("LOCATION: / " );
48
+ file_put_contents ($ fname , json_encode ($ data ));
49
+ exit ();
50
+ }
51
+ }
52
+
53
+ ?>
54
+ <style type="text/css">
55
+ .on {
56
+ background-color: rgb(200,255,200);
57
+ padding: 0.5em;
58
+ }
59
+ .off {
60
+ background-color: rgb(240,240,200);
61
+ padding: 0.5em;
62
+ }
63
+ a {
64
+ color: rgb(30,30,30);
65
+ }
66
+ .success {
67
+ color: rgb(0,150,0);
68
+ }
69
+ .fail {
70
+ color: rgb(220,0,0);
71
+ }
72
+ form {
73
+ display: inline-block; //Or display: inline;
74
+ }
75
+ </style>
76
+ <center><h1>CrazyDot</h1></center>
77
+ <?php
78
+ foreach ($ data as $ name => $ val ) {
79
+ $ class = "off " ;
80
+ if ($ val ['start ' ]>0 )
81
+ $ class = "on " ;
82
+ ?>
83
+ <div class="<?php echo $ class ;?> ">
84
+ <h2><?php echo $ name ; ?> </h2> <br>
85
+ <form action="#">
86
+ <input type="hidden" name="code" value="<?php echo $ name ;?> ">
87
+ <input type="hidden" name="start" value="1">
88
+ <input type="submit" value="Start">
89
+ </form>
90
+ <br>
91
+
92
+ <?php
93
+ for ($ i = 0 ;$ i <count ($ val ['status ' ]);$ i +=1 ) {
94
+ $ pcodeA =$ val ['code ' ] . chr ($ i + ord ('A ' ));
95
+ $ pname = chr ($ i + ord ('A ' )) ." ( " . ($ val ['fail ' ][$ i ]). ") " ;
96
+ $ pclass = "none " ;
97
+ if ($ val ['status ' ][$ i ]!=0 ) {
98
+ $ pclass = "success " ;
99
+ $ sec =round ($ val ['status ' ][$ i ] - $ val ['start ' ]) ;
100
+ $ pname .= " " . floor ($ sec /60 ) . "min " . ($ sec %60 ) . "sec " ;
101
+ } else if ($ val ['status ' ][$ i ]==0 && $ val ['fail ' ][$ i ]>0 ) {
102
+ $ pclass = "fail " ;
103
+ }
104
+ // $sz = 5;
105
+ // if($i%$sz == 0)
106
+ // echo "<br>";
107
+ ?>
108
+ <a href="https://www.codechef.com/problems/<?php echo $ pcodeA ; ?> " class="<?php echo $ pclass ;?> ">Problem <?php echo $ pname ; ?> </a>
109
+ <form action="#">
110
+ <input type="hidden" name="code" value="<?php echo $ name ;?> ">
111
+ <input type="hidden" name="problem" value="<?php echo $ i ;?> ">
112
+ <input type="hidden" name="accept" value="1">
113
+ <input type="submit" value="AC">
114
+ </form>
115
+ <form action="#">
116
+ <input type="hidden" name="code" value="<?php echo $ name ;?> ">
117
+ <input type="hidden" name="problem" value="<?php echo $ i ;?> ">
118
+ <input type="hidden" name="fail" value="1">
119
+ <input type="submit" value="WA/TLE/RTE">
120
+ </form>
121
+ <br>
122
+ <?php
123
+ }
124
+ ?>
125
+
126
+ </div>
127
+ <?php
128
+ }
129
+ ?>
130
+
131
+ </body>
132
+ </html>
0 commit comments