Просмотр файла sys/inc/mobiads.php

Размер файла: 1.39Kb
  1. <?php
  2. function get_ads($id, $key, $count = 1, $timeout = 2){
  3. list($msec, $sec) = explode(' ', microtime());
  4. $headers = getallheaders();
  5. foreach(array_keys(array_intersect($headers, array('Cookie', 'Authorization'))) as $key)
  6. {
  7. unset($headers[$key]);
  8. }
  9. $info =
  10. serialize(
  11. array(
  12. 'id' => intval($id),
  13. 'reqid' => $sec*1000 + floor($msec*1000),
  14. 'ip' => $_SERVER['REMOTE_ADDR'],
  15. 'headers' => $headers,
  16. 'count' => intval($count),
  17. )
  18. );
  19. $nl = chr(13).chr(10);
  20. $post = 'secure='.md5($key.'/'.$info.'/'.$key).'&info='.urlencode($info);
  21. $request =
  22. 'POST /ads/ HTTP/1.0'.$nl.
  23. 'Host: 77.221.155.51'.$nl.
  24. 'Connection: Close'.$nl.
  25. 'Content-Type: application/x-www-form-urlencoded'.$nl.
  26. 'Content-Length: '.strlen($post).$nl.
  27. $nl.
  28. $post;
  29. $socket = fsockopen('77.221.155.51', 80, $errno, $errstr, $timeout);
  30. if($socket === false)
  31. {
  32. return array('STATUS' => 'ERROR', 'DESCRIPTION' => '');
  33. }
  34. fwrite($socket, $request);
  35. $answer = '';
  36. while(!feof($socket) && $nl != fgets($socket));
  37. while(!feof($socket))
  38. {
  39. $answer .= fread($socket, 1024);
  40. }
  41. fclose($socket);
  42. return unserialize($answer);
  43. }
  44.  
  45.  
  46.  
  47. ?>