Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1. #!/usr/bin/php
  2.  
  3. <?php
  4. ini_set('display_errors', 'on'); error_reporting(E_ERROR);
  5.  
  6. set_time_limit(30);
  7. mysql_connect() or die("Couldnt connect to the database");
  8. mysql_select_db('xsploit') or die("Couldnt select database");
  9. include("chanlisting.inc.php");
  10.  
  11. $slash = "/";
  12. $dir = "http://www.bleb.org/tv/data/listings/";
  13. $today = "0";
  14. $tmrw = "1/";
  15. $yesterday = "-1/";
  16. $getvar = "?client=Xsploit";
  17.  
  18. $time_start = microtime(true);
  19. $channelcount = 0;
  20.    
  21. while ($today != 6)
  22. {
  23.     while ($channelcount != 67)
  24.     {
  25.        
  26.         $xmlData = $dir.$today.$slash.$channelurl[$channelcount].$getvar;
  27.         $xml = implode("",file($xmlData));
  28.            
  29.         $p = xml_parser_create();
  30.         xml_parser_set_option($p,XML_OPTION_SKIP_WHITE,1);
  31.         xml_parse_into_struct($p,$xml,$val,$index);
  32.         xml_parser_free($p);
  33.            
  34.         $i = 0;
  35.         $count = 0;    
  36.         $date = $val[0]["attributes"]["DATE"];
  37.         $channel = $val[0]["attributes"]["ID"];
  38.         while (($val[$i]["tag"] != "CHANNEL") || ($val[$i]["type"] != "close"))
  39.         {
  40.             if (($val[$i]["tag"] == "PROGRAMME") && ($val[$i]["type"] == "open"))
  41.             {
  42.                 while ($val[$i]["type"] != "close")
  43.                 {
  44.                     if ($val[$i]["tag"] == "SUBTITLE") { $subtitle = $val[$i]["value"]; } else { $subtitle = ""; }
  45.                     if ($val[$i]["tag"] == "DESC") { $desc = mysql_real_escape_string($val[$i]["value"]); }
  46.                     if ($val[$i]["tag"] == "TYPE") { $type = $val[$i]["value"]; }
  47.                     if ($val[$i]["tag"] == "TITLE") { $title = mysql_real_escape_string($val[$i]["value"]); }
  48.                     if ($val[$i]["tag"] == "END") { $end = $val[$i]["value"]; }
  49.                     if ($val[$i]["tag"] == "INFOURL") { $url = $val[$i]["value"]; }
  50.                     if ($val[$i]["tag"] == "START") { $start = $val[$i]["value"]; }
  51.                     $i++;
  52.                 }
  53.                 $query = "Insert INTO `tvguide` ( `date`, `subtitle`, `desc`, `type`, `title`, `end`, `infourl`, `start`, `channel` ) VALUES ('".$date."', '".$subtitle."',  '".$desc."',  '".$type."',  '".$title."',  '".$end."',  '".$infourl."',  '".$start."', '".$channel."' )";
  54.                 mysql_query($query) or die(mysql_error());
  55.                 if ($count == 0)
  56.                 {
  57.                     echo "<br />Done " . $channel;
  58.                     ++$count;  
  59.                     flush();
  60.                     ob_flush();
  61.                 }
  62.                 else
  63.                 {
  64.                     ++$count;
  65.                  }
  66.                 unset($subtitle,$desc,$type,$title,$end,$url,$start);
  67.             }
  68.             else
  69.             {
  70.                 $i++;
  71.             }
  72.         }
  73.         $channelcount++;   
  74.     }
  75. $channelcount = 0;
  76. echo "<br /><br /> " .$today++;
  77. }
  78.  
  79. $time_end = microtime(true);
  80. $time = $time_end - $time_start;
  81. echo "<br /><br />Parsed in " . $time . " seconds\n<br>";
  82.  
  83.  
  84. // echo "<pre>";
  85. // var_dump($val);
  86. // echo "</pre>";
  87.  
  88. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement