Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- ini_set('display_errors', 'on'); error_reporting(E_ERROR);
- set_time_limit(30);
- mysql_connect() or die("Couldnt connect to the database");
- mysql_select_db('xsploit') or die("Couldnt select database");
- include("chanlisting.inc.php");
- $slash = "/";
- $dir = "http://www.bleb.org/tv/data/listings/";
- $today = "0";
- $tmrw = "1/";
- $yesterday = "-1/";
- $getvar = "?client=Xsploit";
- $time_start = microtime(true);
- $channelcount = 0;
- while ($today != 6)
- {
- while ($channelcount != 67)
- {
- $xmlData = $dir.$today.$slash.$channelurl[$channelcount].$getvar;
- $xml = implode("",file($xmlData));
- $p = xml_parser_create();
- xml_parser_set_option($p,XML_OPTION_SKIP_WHITE,1);
- xml_parse_into_struct($p,$xml,$val,$index);
- xml_parser_free($p);
- $i = 0;
- $count = 0;
- $date = $val[0]["attributes"]["DATE"];
- $channel = $val[0]["attributes"]["ID"];
- while (($val[$i]["tag"] != "CHANNEL") || ($val[$i]["type"] != "close"))
- {
- if (($val[$i]["tag"] == "PROGRAMME") && ($val[$i]["type"] == "open"))
- {
- while ($val[$i]["type"] != "close")
- {
- if ($val[$i]["tag"] == "SUBTITLE") { $subtitle = $val[$i]["value"]; } else { $subtitle = ""; }
- if ($val[$i]["tag"] == "DESC") { $desc = mysql_real_escape_string($val[$i]["value"]); }
- if ($val[$i]["tag"] == "TYPE") { $type = $val[$i]["value"]; }
- if ($val[$i]["tag"] == "TITLE") { $title = mysql_real_escape_string($val[$i]["value"]); }
- if ($val[$i]["tag"] == "END") { $end = $val[$i]["value"]; }
- if ($val[$i]["tag"] == "INFOURL") { $url = $val[$i]["value"]; }
- if ($val[$i]["tag"] == "START") { $start = $val[$i]["value"]; }
- $i++;
- }
- $query = "Insert INTO `tvguide` ( `date`, `subtitle`, `desc`, `type`, `title`, `end`, `infourl`, `start`, `channel` ) VALUES ('".$date."', '".$subtitle."', '".$desc."', '".$type."', '".$title."', '".$end."', '".$infourl."', '".$start."', '".$channel."' )";
- mysql_query($query) or die(mysql_error());
- if ($count == 0)
- {
- echo "<br />Done " . $channel;
- ++$count;
- flush();
- ob_flush();
- }
- else
- {
- ++$count;
- }
- unset($subtitle,$desc,$type,$title,$end,$url,$start);
- }
- else
- {
- $i++;
- }
- }
- $channelcount++;
- }
- $channelcount = 0;
- echo "<br /><br /> " .$today++;
- }
- $time_end = microtime(true);
- $time = $time_end - $time_start;
- echo "<br /><br />Parsed in " . $time . " seconds\n<br>";
- // echo "<pre>";
- // var_dump($val);
- // echo "</pre>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement