|
| 1 | +<html> |
| 2 | + |
| 3 | + <head> |
| 4 | + <title>Search</title> |
| 5 | + <link href="css/bootstrap.min.css" rel="stylesheet"> |
| 6 | + <link rel="stylesheet" type="text/css" href="css/search.css"> |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 8 | + <script src="js/html5shiv.min.js"></script> |
| 9 | + <script src="js/respond.min.js"></script> |
| 10 | + </head> |
| 11 | + |
| 12 | + <body> |
| 13 | + <nav class = "navbar navbar-default navbar-fixed-top" id ="my-navbar"> |
| 14 | + <div class = "container-fluid"> |
| 15 | + <div class = "navbar-header"> |
| 16 | + <button type="button" class ="navbar-toggle" data-toggle = "collapse" data-target ="#navbar-collapse"> |
| 17 | + <span class="icon-bar"></span> |
| 18 | + <span class="icon-bar"></span> |
| 19 | + <span class="icon-bar"></span> |
| 20 | + <span class="icon-bar"></span> |
| 21 | + </button> |
| 22 | + <a href="#" class="navbar-brand">SpojTrackers</a> |
| 23 | + </div> |
| 24 | + |
| 25 | + <div class="collapse navbar-collapse" id="navbar-collapse"> |
| 26 | + <ul class="nav navbar-nav"> |
| 27 | + </ul> |
| 28 | + </div> |
| 29 | + </div> |
| 30 | + </nav> |
| 31 | + |
| 32 | + <div class="jumbotron" id="search"> |
| 33 | + |
| 34 | + <div class="container text-center"> |
| 35 | + <h1>Let the Comparison Begin!</h1> |
| 36 | + <p></p> |
| 37 | + |
| 38 | + <div class="row"> |
| 39 | + <form action="index.php" method="post"> |
| 40 | + <div class="col-lg-6"> |
| 41 | + <div class="input-group"> |
| 42 | + <span class="input-group-addon" id="sizing-addon1">@</span> |
| 43 | + <input type="text" class="form-control" placeholder="Search for..." name='coder1'> |
| 44 | + </div><!-- /input-group --> |
| 45 | + </div><!-- /.col-lg-6 --> |
| 46 | + |
| 47 | + <div class="col-lg-6"> |
| 48 | + <div class="input-group"> |
| 49 | + <span class="input-group-addon" id="sizing-addon1">@</span> |
| 50 | + <input type="text" class="form-control" placeholder="Search for..." name='coder2'> |
| 51 | + <span class="input-group-btn"> |
| 52 | + <button class="btn btn-default" type="submit">Go!</button> |
| 53 | + </span> |
| 54 | + </div><!-- /input-group --> |
| 55 | + </div><!-- /.col-lg-6 --> |
| 56 | + </form> |
| 57 | + </div><!-- /.row --> |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + |
| 61 | + <div class="container"> |
| 62 | + |
| 63 | + <?php |
| 64 | + include('simple_html_dom.php'); |
| 65 | + include('proxy.php'); |
| 66 | + function getStringBetween($str,$from,$to) |
| 67 | + { |
| 68 | + $sub = substr($str, strpos($str,$from)+strlen($from),strlen($str)); |
| 69 | + return substr($sub,0,strpos($sub,$to)); |
| 70 | + } |
| 71 | + |
| 72 | + if(isset($_POST['coder1']) && isset($_POST['coder2'])) { |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + /* $auth=base64_encode('edcguest:edcguest'); |
| 77 | + $Context=array('http'=>array( |
| 78 | + 'proxy'=>'tcp://172.31.102.14:3128', |
| 79 | + 'request_fulluri'=>true, |
| 80 | + 'header'=>"Proxy-Authorization:Basic $auth" |
| 81 | + ) |
| 82 | + ); */ |
| 83 | + ?> |
| 84 | + |
| 85 | + <div> |
| 86 | + |
| 87 | + <?php |
| 88 | + |
| 89 | + // $cxt=stream_context_create($Context); |
| 90 | + $coder1=$_POST['coder1']; |
| 91 | + $url1="http://www.spoj.com/users/$coder1/"; |
| 92 | + $html1 = file_get_html($url1,false,$cxt); |
| 93 | + $userprofile1=$html1->find('div[id=user-profile-left]',0); |
| 94 | + $name1=$userprofile1->find('h3',0); |
| 95 | + $username1=$userprofile1->find('h4',0); |
| 96 | + $country1=$userprofile1->find('p',0); |
| 97 | + $joiningtime1=$userprofile1->find('p',1); |
| 98 | + $worldrank1=$userprofile1->find('p',2); |
| 99 | + $institution1=$userprofile1->find('p',3); |
| 100 | + $thought1=$userprofile1->find('p',4); |
| 101 | + $profilepic1=$userprofile1->find('img',0); |
| 102 | + $value1=$profilepic1->src; |
| 103 | + $userstats1=$html1->find('dl',0); |
| 104 | + $probcount1=$userstats1->find('dd',0)->plaintext; |
| 105 | + $subcount1=$userstats1->find('dd',1)->plaintext; |
| 106 | + $probtable1=$html1->find('table[class=table table-condensed]',0); |
| 107 | + $rank_string1=$worldrank1->plaintext; |
| 108 | + |
| 109 | + $from="#"; |
| 110 | + $to=" "; |
| 111 | + |
| 112 | + $rank_val1=getStringBetween($rank_string1,$from,$to);//Rank of coder1 |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + // $cxt=stream_context_create($Context); |
| 117 | + $coder2=$_POST['coder2']; |
| 118 | + $url2="http://www.spoj.com/users/$coder2/"; |
| 119 | + $html2 = file_get_html($url2,false,$cxt); |
| 120 | + $userprofile2=$html2->find('div[id=user-profile-left]',0); |
| 121 | + $name2=$userprofile2->find('h3',0); |
| 122 | + $username2=$userprofile2->find('h4',0); |
| 123 | + $country2=$userprofile2->find('p',0); |
| 124 | + $joiningtime2=$userprofile2->find('p',1); |
| 125 | + $worldrank2=$userprofile2->find('p',2); |
| 126 | + $institution2=$userprofile2->find('p',3); |
| 127 | + $thought2=$userprofile2->find('p',4); |
| 128 | + $profilepic2=$userprofile2->find('img',0); |
| 129 | + $value2=$profilepic2->src; |
| 130 | + $userstats2=$html2->find('dl',0); |
| 131 | + $probcount2=$userstats2->find('dd',0)->plaintext; |
| 132 | + $subcount2=$userstats2->find('dd',1)->plaintext; |
| 133 | + $probtable2=$html2->find('table[class=table table-condensed]',0); |
| 134 | + $rank_string2=$worldrank2->plaintext; |
| 135 | + |
| 136 | + $rank_val2=getStringBetween($rank_string2,$from,$to); //Rank of coder2 |
| 137 | + |
| 138 | + $rank_total=$rank_val1+$rank_val2; //Total of rank of coder1 and coder2 |
| 139 | + |
| 140 | + $rank_percent1=ROUND($rank_val1*100/$rank_total); |
| 141 | + $rank_percent2=ROUND($rank_val2*100/$rank_total); |
| 142 | + |
| 143 | + $prob_total=$probcount1+$probcount2; //Total of problem count of both coders |
| 144 | + |
| 145 | + $prob_percent1=ROUND($probcount1*100/$prob_total); |
| 146 | + $prob_percent2=ROUND($probcount2*100/$prob_total); |
| 147 | + |
| 148 | + $sub_total=$subcount1+$subcount2; |
| 149 | + |
| 150 | + $sub_percent1=ROUND($subcount1*100/($sub_total)); |
| 151 | + $sub_percent2=ROUND($subcount2*100/($sub_total)); |
| 152 | + |
| 153 | + ?> |
| 154 | + </div> |
| 155 | + </div> |
| 156 | + |
| 157 | + <table class="table" width='70%'> |
| 158 | + <tr> |
| 159 | + <td align='center'> |
| 160 | + <?php |
| 161 | + if(isset($name1->plaintext)){ |
| 162 | + echo $name1->plaintext." ("; |
| 163 | + echo $username1->plaintext.") ".'<br>'; |
| 164 | + } |
| 165 | + ?> |
| 166 | + </td> |
| 167 | + |
| 168 | + <td> |
| 169 | + </td> |
| 170 | + |
| 171 | + <td align='center'> |
| 172 | + <?php |
| 173 | + if(isset($name2->plaintext)){ |
| 174 | + echo $name2->plaintext." ("; |
| 175 | + echo $username2->plaintext.") ".'<br>'; |
| 176 | + } |
| 177 | + ?> |
| 178 | + </td> |
| 179 | + </tr> |
| 180 | + |
| 181 | + <tr> |
| 182 | + <td align='center'> |
| 183 | + <?php |
| 184 | + echo "<img src=$value1 height='200px width='200px'></img><br><br>"; |
| 185 | + ?> |
| 186 | + </td> |
| 187 | + |
| 188 | + <td align='center'> |
| 189 | + <img src="images/vs.jpeg" height='200px' width='200px'> |
| 190 | + </td> |
| 191 | + |
| 192 | + <td align='center'> |
| 193 | + <?php |
| 194 | + echo "<img src=$value2 height='200px width='200px'></img><br><br>"; |
| 195 | + ?> |
| 196 | + </td> |
| 197 | + </tr> |
| 198 | + |
| 199 | + <tr> |
| 200 | + <td align='center'> |
| 201 | + <?php |
| 202 | + echo $country1->plaintext.'<br>'; |
| 203 | + ?> |
| 204 | + </td> |
| 205 | + |
| 206 | + <td> |
| 207 | + </td> |
| 208 | + |
| 209 | + <td align='center'> |
| 210 | + <?php |
| 211 | + echo $country2->plaintext.'<br>'; |
| 212 | + ?> |
| 213 | + </td> |
| 214 | + </tr> |
| 215 | + |
| 216 | + <tr> |
| 217 | + <td align='center'> |
| 218 | + <?php |
| 219 | + echo $joiningtime1->plaintext.'<br>'; |
| 220 | + ?> |
| 221 | + </td> |
| 222 | + |
| 223 | + <td> |
| 224 | + |
| 225 | + </td> |
| 226 | + |
| 227 | + <td align='center'> |
| 228 | + <?php |
| 229 | + echo $joiningtime2->plaintext.'<br>'; |
| 230 | + ?> |
| 231 | + </td> |
| 232 | + </tr> |
| 233 | + |
| 234 | + <tr> |
| 235 | + <td align='center'> |
| 236 | + <?php |
| 237 | + echo $worldrank1->plaintext.'<br>'; |
| 238 | + ?> |
| 239 | + </td> |
| 240 | + |
| 241 | + <td> |
| 242 | + <div class="progress"> |
| 243 | + <?php |
| 244 | + echo '<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$rank_percent2.'%">'; |
| 245 | + ?> |
| 246 | + |
| 247 | + <?php |
| 248 | + echo $rank_percent2.'%'; |
| 249 | + ?> |
| 250 | + |
| 251 | + </div> |
| 252 | + <?php |
| 253 | + echo '<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$rank_percent1.'%">'; |
| 254 | + ?> |
| 255 | + |
| 256 | + <?php |
| 257 | + echo $rank_percent1.'%'; |
| 258 | + ?> |
| 259 | + |
| 260 | + </div> |
| 261 | + |
| 262 | + </div> |
| 263 | + </td> |
| 264 | + |
| 265 | + <td align='center'> |
| 266 | + <?php |
| 267 | + echo $worldrank2->plaintext.'<br>'; |
| 268 | + ?> |
| 269 | + </td> |
| 270 | + </tr> |
| 271 | + |
| 272 | + <tr> |
| 273 | + <td align='center'> |
| 274 | + <?php |
| 275 | + echo $institution1->plaintext.'<br>'; |
| 276 | + ?> |
| 277 | + </td> |
| 278 | + |
| 279 | + <td> |
| 280 | + </td> |
| 281 | + |
| 282 | + <td align='center'> |
| 283 | + <?php |
| 284 | + echo $institution2->plaintext.'<br>'; |
| 285 | + ?> |
| 286 | + </td> |
| 287 | + </tr> |
| 288 | + |
| 289 | + <tr> |
| 290 | + <td align='center'> |
| 291 | + <?php |
| 292 | + echo "Problem Solved: ".$probcount1."<br>"; |
| 293 | + ?> |
| 294 | + </td> |
| 295 | + |
| 296 | + <td width = '400px'> |
| 297 | + <div class="progress"> |
| 298 | + <?php |
| 299 | + echo '<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$prob_percent1.'%">'; |
| 300 | + ?> |
| 301 | + |
| 302 | + <?php |
| 303 | + echo $prob_percent1.'%'; |
| 304 | + ?> |
| 305 | + </div> |
| 306 | + |
| 307 | + <?php |
| 308 | + echo '<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$prob_percent2.'%">'; |
| 309 | + ?> |
| 310 | + |
| 311 | + <?php |
| 312 | + echo $prob_percent2.'%'; |
| 313 | + ?> |
| 314 | + |
| 315 | + </div> |
| 316 | + |
| 317 | + |
| 318 | + |
| 319 | + |
| 320 | + |
| 321 | + </div> |
| 322 | + </td> |
| 323 | + |
| 324 | + <td align='center'> |
| 325 | + <?php |
| 326 | + echo "Problem Solved: ".$probcount2."<br>"; |
| 327 | + ?> |
| 328 | + </td> |
| 329 | + </tr> |
| 330 | + |
| 331 | + <tr> |
| 332 | + <td align='center'> |
| 333 | + <?php |
| 334 | + echo "Submissions: ".$subcount1."<br>"; |
| 335 | + ?> |
| 336 | + </td> |
| 337 | + |
| 338 | + <td> |
| 339 | + <div class="progress"> |
| 340 | + |
| 341 | + <?php |
| 342 | + echo '<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$sub_percent1.'%">'; |
| 343 | + ?> |
| 344 | + |
| 345 | + <?php |
| 346 | + echo $sub_percent1.'%'; |
| 347 | + ?> |
| 348 | + </div> |
| 349 | + |
| 350 | + <?php |
| 351 | + echo '<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: '.$sub_percent2.'%">'; |
| 352 | + ?> |
| 353 | + |
| 354 | + <?php |
| 355 | + echo $sub_percent2.'%'; |
| 356 | + ?> |
| 357 | + |
| 358 | + </div> |
| 359 | + |
| 360 | + |
| 361 | + |
| 362 | + </div> |
| 363 | + </td> |
| 364 | + |
| 365 | + <td align='center'> |
| 366 | + <?php |
| 367 | + echo "Submissions: ".$subcount2."<br>"; |
| 368 | + ?> |
| 369 | + </td> |
| 370 | + </tr> |
| 371 | + |
| 372 | + <tr> |
| 373 | + <td> |
| 374 | + <?php |
| 375 | + ?> |
| 376 | + </td> |
| 377 | + |
| 378 | + <td> |
| 379 | + </td> |
| 380 | + |
| 381 | + <td> |
| 382 | + <?php |
| 383 | + ?> |
| 384 | + </td> |
| 385 | + </tr> |
| 386 | + |
| 387 | + |
| 388 | + </table> |
| 389 | + <?php |
| 390 | + } |
| 391 | + ?> |
| 392 | + |
| 393 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> |
| 394 | + <script src="js/bootstrap.min.js"></script> |
| 395 | + </body> |
| 396 | +</html> |
0 commit comments