|
1
|
|
|
<?php |
|
2
|
|
|
namespace App\Http\Controllers\VirtualJudge; |
|
3
|
|
|
|
|
4
|
|
|
use App\Models\SubmissionModel; |
|
5
|
|
|
use App\Models\JudgerModel; |
|
6
|
|
|
use App\Models\ProblemModel; |
|
7
|
|
|
use App\Http\Controllers\VirtualJudge\Curl; |
|
8
|
|
|
use App\Http\Controllers\VirtualJudge\NOJ\NOJ; |
|
9
|
|
|
use App\Http\Controllers\VirtualJudge\CodeForces\CodeForces; |
|
10
|
|
|
use App\Http\Controllers\VirtualJudge\ContestHunter\ContestHunter; |
|
11
|
|
|
use App\Http\Controllers\VirtualJudge\POJ\POJ; |
|
12
|
|
|
use App\Http\Controllers\VirtualJudge\Vijos\Vijos; |
|
13
|
|
|
use App\Http\Controllers\VirtualJudge\PTA\PTA; |
|
14
|
|
|
use App\Http\Controllers\VirtualJudge\UVa\UVa; |
|
15
|
|
|
use Requests; |
|
16
|
|
|
|
|
17
|
|
|
class Core extends Curl |
|
18
|
|
|
{ |
|
19
|
|
|
private $sub; |
|
20
|
|
|
public $post_data=[]; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(& $sub, $oj, $all_data) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->sub=& $sub; |
|
25
|
|
|
$this->post_data=$all_data; |
|
26
|
|
|
|
|
27
|
|
|
if ($oj=='noj') { |
|
28
|
|
|
$NOJ=new NOJ($sub, $all_data); |
|
29
|
|
|
$NOJ->submit(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
if ($oj=='codeforces') { |
|
33
|
|
|
$CodeForces=new CodeForces($sub, $all_data); |
|
34
|
|
|
$CodeForces->submit(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if ($oj=='contesthunter') { |
|
38
|
|
|
$ContestHunter=new ContestHunter($sub, $all_data); |
|
39
|
|
|
$ContestHunter->submit(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if ($oj=='poj') { |
|
43
|
|
|
$POJ=new POJ($sub, $all_data); |
|
44
|
|
|
$POJ->submit(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if ($oj=='vijos') { |
|
48
|
|
|
$Vijos=new Vijos($sub, $all_data); |
|
49
|
|
|
$Vijos->submit(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if ($oj=='pta') { |
|
53
|
|
|
$PTA=new PTA($sub, $all_data); |
|
54
|
|
|
$PTA->submit(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ($oj=='uva') { |
|
58
|
|
|
$UVa=new UVa($sub, $all_data); |
|
59
|
|
|
$UVa->submit(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if($oj=='hdu') { |
|
63
|
|
|
$HDU = new HDU($sub, $all_data); |
|
64
|
|
|
$HDU->submit(); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
// protected function uva_live_login($url1, $url2, $oj) |
|
76
|
|
|
// { |
|
77
|
|
|
// $response=$this->grab_page($url1, $oj); |
|
78
|
|
|
// if (!(strpos($response, 'Logout') !== false)&&(strpos($response, 'Login') !== false)) { |
|
79
|
|
|
// $exploded = explode('<input type="hidden" name="cbsecuritym3" value="', $response); |
|
80
|
|
|
// $cbsecuritym3 = explode('"', $exploded[1])[0]; |
|
81
|
|
|
|
|
82
|
|
|
// $exploded = explode('<input type="hidden" name="return" value="', $response); |
|
83
|
|
|
// $return = explode('"', $exploded[1])[0]; |
|
84
|
|
|
|
|
85
|
|
|
// $exploded = explode('<input type="hidden" name="cbsecuritym3" value="', $response); |
|
86
|
|
|
// $exploded = explode('<input type="hidden" name="', $exploded[1]); |
|
87
|
|
|
// $any = explode('"', $exploded[1])[0]; |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
// $params = [ |
|
91
|
|
|
// 'username' => 'codemaster_uva', |
|
92
|
|
|
// 'passwd' => '123456', |
|
93
|
|
|
// 'op2' => 'login', |
|
94
|
|
|
// 'lang' => 'english', |
|
95
|
|
|
// 'force_session' => '1', |
|
96
|
|
|
// 'return' => $return, |
|
97
|
|
|
// 'message' => '0', |
|
98
|
|
|
// 'loginfrom' => 'loginmodule', |
|
99
|
|
|
// 'cbsecuritym3' => $cbsecuritym3, |
|
100
|
|
|
// $any => '1', |
|
101
|
|
|
// 'remember' => 'yes', |
|
102
|
|
|
// 'Submit' => 'Login', |
|
103
|
|
|
// ]; |
|
104
|
|
|
|
|
105
|
|
|
// $data=http_build_query($params); |
|
106
|
|
|
// $this->login($url2, http_build_query($params), $oj); |
|
107
|
|
|
// } |
|
108
|
|
|
// } |
|
109
|
|
|
// public function uva_live_submit($url, $oj) |
|
110
|
|
|
// { |
|
111
|
|
|
// $this->sub['language']=substr($this->post_data["lang"], 1, 50); |
|
112
|
|
|
// $this->sub['solution']=$this->post_data["solution"]; |
|
113
|
|
|
// $this->sub['pid']=$this->post_data["pid"]; |
|
114
|
|
|
|
|
115
|
|
|
// $code=$this->post_data["solution"]; |
|
116
|
|
|
// $lang=substr($this->post_data["lang"], 0, 1); |
|
117
|
|
|
// $pro_id=$this->post_data['iid']; |
|
118
|
|
|
|
|
119
|
|
|
// $params = [ |
|
120
|
|
|
// 'problemid' => $pro_id, |
|
121
|
|
|
// 'category' => '', |
|
122
|
|
|
// 'language' => $lang, |
|
123
|
|
|
// 'code' => $code, |
|
124
|
|
|
// 'codeupl' => '', |
|
125
|
|
|
// ]; |
|
126
|
|
|
// $data=http_build_query($params); |
|
127
|
|
|
// $response=$this->post_data($url, $data, $oj, true); |
|
128
|
|
|
// if (substr_count($response, 'Submission+received+with+ID')==0) { |
|
129
|
|
|
// $exploded = explode('mosmsg=', $response); |
|
130
|
|
|
// $this->sub['verdict'] = urldecode(explode('"', $exploded[2])[0]); |
|
131
|
|
|
// } |
|
132
|
|
|
// } |
|
133
|
|
|
// private function uva() |
|
134
|
|
|
// { |
|
135
|
|
|
// if (!isset($this->post_data["pid"])||!isset($this->post_data["iid"])||!isset($_COOKIE["user_handle"])&&!isset($this->post_data["solution"])) { |
|
136
|
|
|
// redirect("/"); |
|
137
|
|
|
// } |
|
138
|
|
|
// $response=$this->grab_page('https://uva.onlinejudge.org', 'uva'); |
|
139
|
|
|
// if (!(strpos($response, 'UVa Online Judge - Offline') !== false)&&strlen($response)!=0) { |
|
140
|
|
|
// $this->uva_live_login('https://uva.onlinejudge.org', 'https://uva.onlinejudge.org/index.php?option=com_comprofiler&task=login', 'uva'); |
|
141
|
|
|
// $this->uva_live_submit('https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=save_submission', 'uva'); |
|
142
|
|
|
// } else { |
|
143
|
|
|
// $this->sub['language']=substr($this->post_data["lang"], 1, 50); |
|
144
|
|
|
// $this->sub['solution']=$this->post_data["solution"]; |
|
145
|
|
|
// $this->sub['pid']=$this->post_data["pid"]; |
|
146
|
|
|
// $this->sub['verdict']="Judge Error"; |
|
147
|
|
|
// } |
|
148
|
|
|
// } |
|
149
|
|
|
// private function uvalive() |
|
150
|
|
|
// { |
|
151
|
|
|
// if (!isset($this->post_data["pid"])||!isset($this->post_data["iid"])||!isset($_COOKIE["user_handle"])&&!isset($this->post_data["solution"])) { |
|
152
|
|
|
// redirect("/"); |
|
153
|
|
|
// } |
|
154
|
|
|
// $this->uva_live_login('https://icpcarchive.ecs.baylor.edu', 'https://icpcarchive.ecs.baylor.edu/index.php?option=com_comprofiler&task=login', 'uvalive'); |
|
155
|
|
|
// $this->uva_live_submit('https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=save_submission', 'uvalive'); |
|
156
|
|
|
// } |
|
157
|
|
|
// public function spoj_login() |
|
158
|
|
|
// { |
|
159
|
|
|
// $response=$this->grab_page('http://www.spoj.com', 'spoj'); |
|
160
|
|
|
// if (!(strpos($response, 'sign-out') !== false)) { |
|
161
|
|
|
// $params = [ |
|
162
|
|
|
// 'next_raw' => "/", |
|
163
|
|
|
// 'autologin' => '1', |
|
164
|
|
|
// 'login_user' => 'codemaster_spoj', |
|
165
|
|
|
// 'password' => '123456' |
|
166
|
|
|
// ]; |
|
167
|
|
|
|
|
168
|
|
|
// $data=http_build_query($params); |
|
169
|
|
|
// $this->login('http://www.spoj.com/login', $data, 'spoj'); |
|
170
|
|
|
// } |
|
171
|
|
|
// } |
|
172
|
|
|
// public function multiexplode($delimiters, $string) |
|
173
|
|
|
// { |
|
174
|
|
|
// $ready = str_replace($delimiters, $delimiters[0], $string); |
|
175
|
|
|
// $launch = explode($delimiters[0], $ready); |
|
176
|
|
|
// return $launch; |
|
177
|
|
|
// } |
|
178
|
|
|
// public function spoj_submit() |
|
179
|
|
|
// { |
|
180
|
|
|
// $x=0; |
|
181
|
|
|
// for ($i=0;$i<strlen($this->post_data["lang"]);$i++) { |
|
182
|
|
|
// if (is_numeric($this->post_data["lang"][$i])) { |
|
183
|
|
|
// $x++; |
|
184
|
|
|
// } else { |
|
185
|
|
|
// break; |
|
186
|
|
|
// } |
|
187
|
|
|
// } |
|
188
|
|
|
// $this->sub['language']=substr($this->post_data["lang"], $x, strlen($this->post_data["lang"])); |
|
189
|
|
|
// $this->sub['solution']=$this->post_data["solution"]; |
|
190
|
|
|
// $this->sub['pid']=$this->post_data["pid"]; // 500A |
|
191
|
|
|
// $lang=substr($this->post_data["lang"], 0, $x); |
|
192
|
|
|
|
|
193
|
|
|
// $params = [ |
|
194
|
|
|
// 'subm_file' => '', |
|
195
|
|
|
// 'file' => $this->post_data["solution"], |
|
196
|
|
|
// 'lang' => $lang, |
|
197
|
|
|
// 'problemcode' => $this->post_data['iid'], |
|
198
|
|
|
// 'submit' => 'Submit!', |
|
199
|
|
|
// ]; |
|
200
|
|
|
|
|
201
|
|
|
// $data=http_build_query($params); |
|
202
|
|
|
// $response=$this->post_data('http://www.spoj.com/submit/complete/', $data, 'spoj', true); |
|
203
|
|
|
// if (substr_count($response, 'Solution submitted!')==0) { |
|
204
|
|
|
// $exploded = explode('<p align="center">', $response); |
|
205
|
|
|
// $this->sub['verdict'] = $this->multiexplode(["!","."], $exploded[1])[0]; |
|
206
|
|
|
// } |
|
207
|
|
|
// } |
|
208
|
|
|
|
|
209
|
|
|
// private function spoj() |
|
210
|
|
|
// { |
|
211
|
|
|
// if (!isset($this->post_data["pid"])||!isset($this->post_data["iid"])||!isset($this->post_data["iid"])||!isset($_COOKIE["user_handle"])&&!isset($this->post_data["solution"])) { |
|
212
|
|
|
// redirect("/"); |
|
213
|
|
|
// } |
|
214
|
|
|
// $this->spoj_login(); |
|
215
|
|
|
// $this->spoj_submit(); |
|
216
|
|
|
// } |
|
217
|
|
|
|
|
218
|
|
|
|