Advertisement
Guest User

curl

a guest
Apr 25th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <?php
  2. /*
  3. $url = file_get_contents('http://stats.redeinfovias.net.br/monitoracao-cgr/index.html?login=ccm&pass=12345ccm');
  4. //?login=algo&pass=algo0
  5.  
  6. echo $url;
  7.  
  8.  
  9.  
  10. // Inicia o cURL
  11. $ch = curl_init();
  12.  
  13. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  14. curl_setopt($ch, CURLOPT_URL, 'http://stats.redeinfovias.net.br/monitoracao-cgr/index.html?login=ccm&pass=12345ccm');
  15. curl_setopt ($ch, CURLOPT_POST, 1);
  16. curl_setopt ($ch, CURLOPT_POSTFIELDS, 'credentials.username=ccm&credentials.password=12345ccm');
  17. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  18. $store = curl_exec ($ch);
  19.  
  20. echo $store;
  21.  
  22. curl_setopt($ch, CURLOPT_URL, 'http://stats.redeinfovias.net.br/monitoracao-cgr/');
  23. $content = curl_exec ($ch);
  24.  
  25. curl_close ($ch);
  26.  
  27. */
  28.  
  29.  
  30. $cable= $_GET['cable'];
  31. $cmts = $_GET['cmts'];
  32. $node = $_GET['node'];
  33. $cmts_up =$_GET['up'];
  34. $pieces = explode("/", $_GET['cable']);
  35.  
  36.  
  37. $cmts_opt1 = $pieces[0];
  38. $cmts_opt2 = $pieces[1];
  39. $cmts_opt3 = $pieces[2];
  40.  
  41. $cmts_completo = $cmts_opt1."_".$cmts_opt2."_".$cmts_opt3."-upstream".$cmts_up;
  42. $headers = array(
  43. 'Content-Type:text/html',
  44. 'Authorization: Basic '. base64_encode("ccm:12345ccm") // <---
  45. );
  46.  
  47. $curl = curl_init();
  48. // http://stats.redeinfovias.net.br/cgi-bin/cricket/stats/stats.cgi?target=%2Fsnr%2FCEM%2FCMTS1%2Fcable6_0_0-upstream1;ranges=d%3Aw;view=SNR
  49. curl_setopt($curl, CURLOPT_URL, "stats.redeinfovias.net.br/cgi-bin/cricket/stats/stats.cgi?target=%2Fsnr%2F".$node."%2FCMTS1%2Fcable".$cmts_completo.";ranges=d%3Aw;view=SNR");
  50.  
  51. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  52. //$output = curl_exec($curl);
  53. //curl_close($curl);
  54.  
  55.  
  56. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  57. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  58.  
  59.  
  60. $result = curl_exec($curl);
  61.  
  62. preg_match_all("! [^\s]*? dB<br>!", $result, $matches);
  63.  
  64. $niveis = array_values(array_unique($matches[0]));
  65.  
  66. //print_r($niveis);
  67. //echo "RX $node 18 CMTS: $cmts Cable: $cmts_opt1/$cmts_opt2/$cmts_opt2 Upstream $cmts_up SNR: ";
  68. //echo $niveis[0];
  69. //echo "<BR><hr><BR>";
  70. curl_close($curl);
  71.  
  72.  
  73.  
  74. $pizza = "8/0/0";
  75. $pieces = explode("/", $_GET['cable']);
  76. //echo "OPT1:".$pieces[0]; // piece1
  77. //echo "<br>OPT2:".$pieces[1]; // piece2
  78. //echo "<br>OPT3:".$pieces[2]; // piece2
  79.  
  80. $salva_niveis = $niveis[0];
  81. $novo= explode(" ", $salva_niveis);
  82.  
  83. echo $novo[1];
  84.  
  85. //print_r($novo);
  86.  
  87. //echo "<BR><hr><BR>".$salva_niveis;
  88.  
  89.  
  90. //link = http://simop.enselengenharia.com.br/test.php?cable=8/0/0&up=1&cmts=1
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement