Tarango

Untitled

Jul 30th, 2015
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.05 KB | None | 0 0
  1. <?php
  2.  
  3.     $user_info = file_get_html('http://community.topcoder.com/tc?module=MemberProfile&cr=10574855')->plaintext;
  4.     $user_info = "User Info of the user is: ".$user_info;
  5.     $user_info = trim($user_info);
  6.     $user_info = preg_replace('/\s+/', ' ', $user_info);
  7.     $user_info = mysql_real_escape_string( $user_info);
  8.     //echo $user_info;
  9.    
  10.     $user_name = "";
  11.     $start_pos1 = strpos ($user_info , "Member Since");
  12.     for($j = $start_pos1-1;$j>0;$j--){
  13.         $st = substr($user_info, $j , 1);
  14.         if(strcmp($st, "%") == 0) break;
  15.         $st = $st.$user_name;
  16.         $user_name = $st;
  17.     }
  18.  
  19.     $start_pos1 = strpos ($user_info , "Algorithm Competitions Rating") + 30;
  20.     $current_rating = substr($user_info, $start_pos1 , 5);
  21.     echo "<br>Current Rating: ".$current_rating;
  22.  
  23.     $start_pos1 = strpos ($user_info , "Maximum Rating") + 15;
  24.     $maximum_rating = substr($user_info, $start_pos1 , 5);
  25.     echo "<br>Maximum Rating: ".$maximum_rating;
  26.  
  27.     $start_pos1 = strpos ($user_info , "Minimum Rating") + 15;
  28.     $minimum_rating = substr($user_info, $start_pos1 , 5);
  29.     echo "<br>Minimum Rating: ".$minimum_rating;
  30.  
  31.     $start_pos1 = strrpos ($user_info , "Competitions") + 12;
  32.     $Competitions = substr($user_info, $start_pos1 , 4);
  33.     echo "<br>Competitions: ".$Competitions;
  34.  
  35.     $start_pos1 = strpos ($user_info , "Competition History Percentile") + 31;
  36.     //$last_pos1 = strpos ( $user_info , "Problems Partially Solved");
  37.     //$Len1 = $last_pos1 - $start_pos1;
  38.     $Percentile = substr($user_info, $start_pos1 , 5);
  39.     echo "<br>Current Percentile: ".$Percentile;
  40.  
  41.     $start_pos1 = strpos ($user_info , "Rank ") + 4;
  42.     $last_pos1 = strpos ( $user_info , "Country Rank");
  43.     $Len1 = $last_pos1 - $start_pos1;
  44.     $Rank = substr($user_info, $start_pos1 , $Len1);
  45.     echo "<br>Current Rank: ".$Rank;
  46.  
  47.     $div1 = "";$div2 = "";$challenges = "";
  48.     $Len = strlen($user_info);
  49.     $start_pos1 = strrpos ($user_info , "Competitions") + 12;
  50.     $i = 0;
  51.     while($i<$Len){
  52.         $ss = substr($user_info, $i , 5);
  53.         if(strcmp($ss, "Total") == 0){
  54.             for($j = $i+6;$j<$Len;$j++){
  55.                 $st = substr($user_info, $j , 1);
  56.                 $div1 = $div1.$st;
  57.                 if(strcmp($st, "%") == 0) break;
  58.             }
  59.             $i+=5;
  60.             break;
  61.         }
  62.         $i++;
  63.     }
  64.     while($i<$Len){
  65.         $ss = substr($user_info, $i , 5);
  66.         if(strcmp($ss, "Total") == 0){
  67.             for($j = $i+6;$j<$Len;$j++){
  68.                 $st = substr($user_info, $j , 1);
  69.                 $div2 = $div2.$st;
  70.                 if(strcmp($st, "%") == 0) break;
  71.             }
  72.             $i+=5;
  73.             break;
  74.         }
  75.         $i++;
  76.     }
  77.     while($i<$Len){
  78.         $ss = substr($user_info, $i , 5);
  79.         if(strcmp($ss, "Total") == 0){
  80.             for($j = $i+6;$j<$Len;$j++){
  81.                 $st = substr($user_info, $j , 1);
  82.                 $challenges = $challenges.$st;
  83.                 if(strcmp($st, "%") == 0) break;
  84.             }
  85.             $i+=5;
  86.             break;
  87.         }
  88.         $i++;
  89.     }
  90.  
  91.     $div1_list = explode(' ',$div1);
  92.     $div2_list = explode(' ',$div2);
  93.     $challenges_list = explode(' ',$challenges);
  94.  
  95.     $div1_solved = $div1_list[0];
  96.     $div1_failed_challenge = $div1_list[1];
  97.     $div1_failed_system_test = $div1_list[2];
  98.     $div1_success = $div1_list[3];
  99.     $div2_solved = $div2_list[0];
  100.     $div2_failed_challenge = $div2_list[1];
  101.     $div2_failed_system_test = $div2_list[2];
  102.     $div2_success = $div2_list[3];
  103.     $failed_challenge = $challenges_list[0];
  104.     $total_challenge = $challenges_list[1];
  105.     $challenges_success = $challenges_list[2];
  106.    
  107.     echo "<br>div1 submission: ".$div1_solved;
  108.     echo "<br>div1 failed challenge: ".$div1_failed_challenge;
  109.     echo "<br>div1 failed system_test: ".$div1_failed_system_test;
  110.     echo "<br>div1 success: ".$div1_success;
  111.     echo "<br>div2 submission: ".$div2_solved;
  112.     echo "<br>div2 failed challenge: ".$div2_failed_challenge;
  113.     echo "<br>div2 failed system test: ".$div2_failed_system_test;
  114.     echo "<br>div2 success: ".$div2_success;
  115.     echo "<br>total challenge: ".$total_challenge;
  116.     echo "<br>failed challenge: ".$failed_challenge;
  117.     echo "<br>challenges success: ".$challenges_success;
  118.     echo "<br>user name: ".$user_name;
  119. ?>
Advertisement
Add Comment
Please, Sign In to add comment