Advertisement
Combreal

prog9_02.php

Jul 21st, 2020
1,567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2. function getContent($url, $cookiePath)
  3. {
  4. //used Export Cookies extension to get NC cookie
  5. $ch = curl_init ();
  6. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  7. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  8. curl_setopt ( $ch, CURLOPT_URL, $url );
  9. curl_setopt ( $ch, CURLOPT_HEADER, 0 );
  10. curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
  11. curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 0 );
  12. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
  13. curl_setopt($ch, CURLOPT_VERBOSE, true);
  14. $file_contents = curl_exec ( $ch );
  15. if (curl_errno ( $ch )) {
  16.     echo curl_error ( $ch );
  17.     curl_close ( $ch );
  18.     exit ();
  19. }
  20. curl_close ( $ch );
  21. return $file_contents;
  22. }
  23. $content = getContent("https://www.newbiecontest.org/epreuves/prog/prog9/epreuve9.php", 'C:/Temp/cookies.txt');
  24. $parse = explode("\n", $content);
  25. $config = $parse[17];
  26. $splitConfig = explode(". ", $config);
  27. $i=0;
  28. $listSize = count($splitConfig);
  29. foreach ($splitConfig as &$conf)
  30. {
  31.     if ( $i <= $listSize -2 )
  32.     {
  33.         $splitConf = explode(" ", $conf);
  34.         $name[$i] = $splitConf[0];
  35.         echo "Nom : " . $name[$i] . "<br />";
  36.         $proc[$i] = $splitConf[5] . " " . $splitConf[6];
  37.         echo "Proc : " . $proc[$i] . "<br />";
  38.         $ram[$i] = $splitConf[10] . " " . $splitConf[11] . " " . $splitConf[12];
  39.         echo "RAM : " . $ram[$i] . "<br /><br />";
  40.     }  
  41.     $i++;
  42. }
  43. echo "<br /><br />";
  44. $splitPrice = explode("<tr align='center'>", $content);
  45. $priceSize = count($splitPrice);
  46. //print_r($splitPrice);
  47. for ($j=1;$j<10;$j++)
  48. {
  49.     $denom = strip_tags($splitPrice[$j]);
  50.     $splitPri = explode(" ", $denom);
  51.     $ramPrice = (int) substr($denom, -5);
  52.     $denomList = $splitPri[0] . " " . $splitPri[1] . " " . $splitPri[2];
  53.     if ( $j != 8 || $j != 9)
  54.     {
  55.         $denomList = substr($denomList, 0, -5);
  56.     }
  57.     if ( $j == 9 )
  58.     {
  59.         $ramPrice = "Trop chère ;)";
  60.     }
  61.     echo "Label : " . $denomList . "<br />";
  62.     echo "Price : " . $ramPrice . "<br /><br />";
  63. }
  64. echo "<br /><br />";
  65. for ($j=10;$j<$priceSize;$j++)
  66. {
  67.     $procList = strip_tags($splitPrice[$j]);
  68.     $procPrice = (int) substr($procList, -4);
  69.     $splitprocList = explode(" ", $procList);
  70.     $denomList = substr($procList, 0, -6);
  71.     if ( $j == 10 )
  72.     {
  73.         $denomList = substr($procList, 0, -19);
  74.         $procPrice = "N'existe plus ;)";
  75.     }
  76.     if ( $j == 19 )
  77.     {
  78.         $procPrice = (int) substr($procList, -11);
  79.     }
  80.     echo "Label : " . $denomList . "<br />";
  81.     echo "Price : " . $procPrice . "<br /><br />";
  82. }
  83. //$subm = "https://www.newbiecontest.org/epreuves/prog/verifpr6.php?solution=" . $solution;
  84. //header("Location: $subm");
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement