PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/steam_source_stats.php

https://bitbucket.org/davestj/steam_stats
PHP | 75 lines | 31 code | 6 blank | 38 comment | 7 complexity | da85358cb65f6c4aec857c35fee18baa MD5 | raw file
  1. <?php
  2. /*
  3. steamcast xml source stats api
  4. Author: dstjohn (Mediacast1)
  5. Date started: 04-06-2005 (1:00A.M)
  6. Version: LNV (LATE NIGHT VERSION) 1.0 beta
  7. NOTES:
  8. This script is intended to get stats from one source of a steamcast server,
  9. if there is more then one source you will need to add and hack this script,
  10. your own your own and may the code be with you ;)
  11. */
  12. /************************************************************************************/
  13. include("./config.php");
  14. //connect to server
  15. $fp = fsockopen($steamip,$steamport,&$errno,&$errstr, 30);
  16. if(!$fp) {
  17. $steam_success = 1;
  18. echo 'Server Is Down';
  19. }
  20. if($steam_success != 1){
  21. fputs ($fp, "GET /admin/status.xml HTTP/1.1\r\n .
  22. User-Agent: Steamcast XML Parser (author: davestj@casterclub.com)(Mozilla Compatible)\r\n .
  23. Authorization: Basic ".base64_encode ("$adminuser:$adminpass")."\r\n\r\n");
  24. while(!feof($fp)) {
  25. $steam_page .= fgets($fp, 1000);
  26. }
  27. /************************************************************************************/
  28. //parse out source xml data
  29. //"description",
  30. $loop2 = array("mount", "status", "name", "description", "genre", "url", "bitrate",
  31. "meta_song", "meta_url", "nodes", "unique_nodes", "max_nodes", "average_connect_time", "tuneins", "extended_tuneins",
  32. "connect_time", "bandwidth", "bytes_recv", "bytes_sent", "content_type", "backup");
  33. $x=0;
  34. while($loop2[$x] != ''){
  35. $steam_pageed = ereg_replace(".*<$loop2[$x]>", "", $steam_page);
  36. $steam_php = strtolower($loop2[$x]);
  37. $$steam_php = ereg_replace("</$loop2[$x]>.*", "", $steam_pageed);
  38. if($loop[$y]==genre || $loop[$y]==description || $loop[$y]==meta_song){
  39. $$steam_php = urldecode($$steam_php);
  40. }
  41. // uncomment the next line to see all variables
  42. echo'$'.$steam_php.' = '.$$steam_php.'<br>';
  43. $x++;
  44. }
  45. fclose($fp);
  46. }
  47. //end xml parse
  48. /************************************************************************************/
  49. /*
  50. available php variables for this api
  51. $mount
  52. $status
  53. $name
  54. $description
  55. $genre
  56. $url
  57. $bitrate
  58. $meta_song
  59. $meta_url
  60. $nodes
  61. $max_nodes
  62. $average_connect_time
  63. $tuneins
  64. $extended_tuneins
  65. $connect_time
  66. $bytes_recv
  67. $content_type
  68. */
  69. ?>