#!/usr/local/bin/Resource/www/cgi-bin/php
<?php
error_reporting(0);
//include ("canale.php");
function str_between($string, $start, $end){
	$string = " ".$string; $ini = strpos($string,$start);
	if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini;
	return substr($string,$ini,$len);
}
$a["pro-tv"]="pro-tv";
$a["antena-1"]="antena-1";
$a["tvr-1"]="tvr-1";
$a["prima-tv"]="prima-tv";
$a["kanal-d"]="kanal-d";
$a["national-tv"]="national-tv";
$a["b1-tv"]="b1-tv";
$a["tvr-2"]="tvr-2";
$a["alfa-omega-tv"]="alfa-omega-tv";
$a["antena-international"]="antena-international";
$a["antena-stars"]="antena-stars";
$a["look-tv"]="look-tv";
$a["nasul-tv"]="nasul-tv";
$a["neptun-tv"]="neptun-tv";
$a["protv-international"]="protv-international";
$a["speranta-tv"]="speranta-tv";
$a["the-money-channel"]="the-money-channel";
$a["trinitas-tv"]="trinitas-tv";
$a["tvh-20"]="tvh-20";
$a["tvr-3"]="tvr-3";
$a["tvr-international"]="tvr-international";
$a["antena-3"]="antena-3";
$a["bloomberg"]="bloomberg";
$a["cnn"]="cnn";
$a["digi-24"]="digi-24";
$a["digi-24-hd"]="digi-24-hd";
$a["e-entertainment"]="e-entertainment";
$a["euronews"]="euronews";
$a["n24-plus"]="n24-plus";
$a["realitatea-tv"]="realitatea-tv";
$a["romania-tv"]="romania-tv";
$a["transilvania-look"]="look-tv";
$a["transilvania-live"]="look-plus";
$a["tvr-news"]="tvr-news";
$a["digi-sport-1"]="digi-sport-1";
$a["digi-sport-2"]="digi-sport-2";
$a["digi-sport-3"]="digi-sport-3";
$a["dolce-sport"]="dolce-sport";
$a["dolce-sport-2"]="dolce-sport-2";
$a["dolce-sport-3"]="dolce-sport-3";
$a["dolce-sport-4"]="dolce-sport-4";
$a["eurosport"]="eurosport";
$a["eurosport-2"]="eurosport-2";
$a["extreme-sports-channel"]="extreme-sports-channel";
$a["motors-tv"]="motors-tv";
$a["outdoor-channel"]="outdoor-channel";
$a["sport-1"]="sport-1";
$a["sportro"]="sportro";
$a["hbo"]="hbo";
$a["pro-cinema"]="pro-cinema";
$a["acasa"]="acasa";
$a["acasa-gold"]="acasa-gold";
$a["axn"]="axn";
$a["axn-black"]="axn-black";
$a["axn-spin"]="axn-spin";
$a["axn-white"]="axn-white";
$a["bollywood-classics"]="bollywood-classics";
$a["bollywood-hd"]="bollywood-hd";
$a["bollywood-tv"]="bollywood-tv";
$a["bollywood-tv-film"]="bollywood-tv-film";
$a["cinemax"]="cinemax";
$a["cinemax-2"]="cinemax-2";
$a["comedy-central-extra"]="comedy-central-extra";
$a["cool-tv"]="cool-tv";
$a["digi-film"]="digi-film";
$a["diva-universal"]="diva-universal";
$a["euforia-lifestyle"]="euforia-lifestyle";
$a["film-plus"]="film-plus";
$a["film-cafe"]="film-cafe";
$a["filmbox"]="filmbox";
$a["filmbox-family"]="filmbox-family";
$a["filmbox-plus"]="filmbox-plus";
$a["hbo-comedy"]="hbo-comedy";
$a["mgm"]="mgm";
$a["paramount-channel"]="paramount-channel";
$a["shorts-tv"]="shorts-tv";
$a["tcm"]="tcm";
$a["tv1000"]="tv1000";
$a["universal-channel"]="universal-channel";
$a["bbc-entertainment"]="bbc-entertainment";
$a["bbc-world"]="bbc-world";
$a["cbs-reality"]="cbs-reality";
$a["deutsche-welle"]="deutsche-welle";
$a["fashion-tv"]="fashion-tv";
$a["fine-living"]="fine-living";
$a["france-24"]="france-24";
$a["france-24-en"]="france-24-en";
$a["rai-uno"]="rai-uno";
$a["rtl-ii"]="rtl-ii";
$a["rtl-plus"]="rtl-plus";
$a["sundance-tv"]="sundance-tv";
$a["travel-channel"]="travel-channel";
$a["tv-paprika"]="tv-paprika";
$a["tv5"]="tv5";
$a["balkanika-tv"]="balkanika-tv";
$a["etno-tv"]="etno-tv";
$a["favorit"]="favorit";
$a["hit-music-channel"]="hit-music-channel";
$a["kiss-tv"]="kiss-tv";
$a["mezzo"]="mezzo";
$a["mooz-dance"]="mooz-dance";
$a["mooz-dance-hd"]="mooz-dance-hd";
$a["mooz-hd"]="mooz-hd";
$a["mooz-hits"]="mooz-hits";
$a["mooz-ro"]="mooz-ro";
$a["mtv-dance"]="mtv-dance";
$a["mtv-hits"]="mtv-hits";
$a["mtv-rocks"]="mtv-rocks";
$a["mtv-romania"]="mtv-romania";
$a["music-channel"]="music-channel";
$a["muzsika-tv"]="muzsika-tv";
$a["mynele-tv"]="mynele-tv";
$a["taraf-tv"]="taraf-tv";
$a["trace-tv"]="trace-tv";
$a["utv"]="utv";
$a["vh1"]="vh1";
$a["vh1-classic"]="vh1-classic";
$a["zu-tv"]="zu-tv";
$a["animal-planet"]="animal-planet";
$a["bbc-knowledge"]="bbc-knowledge";
$a["crime-investigation-network"]="crime-investigation-network";
$a["davinci-learning"]="davinci-learning";
$a["digi-animal-world"]="digi-animal-world";
$a["digi-life"]="digi-life";
$a["digi-world"]="digi-world";
$a["discovery-channel"]="discovery-channel";
$a["discovery-investigation"]="discovery-investigation";
$a["discovery-science"]="discovery-science";
$a["discovery-world"]="discovery-world";
$a["history-channel"]="history-channel";
$a["nat-geo-wild"]="nat-geo-wild";
$a["national-geographic"]="national-geographic";
$a["the-fishing-and-hunting-channel"]="the-fishing-and-hunting-channel";
$a["the-museum-channel-hd"]="the-museum-channel-hd";
$a["tlc"]="tlc";
$a["travel-mix"]="travel-mix";
$a["viasat-explorer"]="viasat-explorer";
$a["viasat-history"]="viasat-history";
$a["viasat-nature"]="viasat-nature";
$a["babytv"]="babytv";
$a["boomerang"]="boomerang";
$a["c8"]="c8";
$a["cartoon-network"]="cartoon-network";
$a["disney-channel"]="disney-channel";
$a["disney-junior"]="disney-junior";
$a["duck-tv"]="duck-tv";
$a["jimjam"]="jimjam";
$a["megamax"]="megamax";
$a["minimax"]="minimax";
$a["nickelodeon"]="nickelodeon";
$a["nickelodeon-hd"]="nickelodeon-hd";
$a["pro-tv-hd"]="pro-tv-hd";
$a["hbo-hd"]="hbo-hd";
$a["acasa-tv-hd"]="acasa-tv-hd";
$a["axn-hd"]="axn-hd";
$a["discovery-science-hd"]="discovery-science-hd";
$a["discovery-showcase-hd"]="discovery-showcase-hd";
$a["discovery-turbo-xtra-hd"]="discovery-turbo-xtra-hd";
$a["docu-box-hd"]="docu-box-hd";
$a["dolce-sport-hd"]="dolce-sport-hd";
$a["duck-tv-hd"]="duck-tv-hd";
$a["e-entertainment-hd"]="e-entertainment-hd";
$a["erox-hd"]="erox-hd";
$a["eurosport-2-hd"]="eurosport-2-hd";
$a["eurosport-hd"]="eurosport-hd";
$a["fashion-box-hd"]="fashion-box-hd";
$a["fashion-one-hd"]="fashion-one-hd";
$a["fight-box-hd"]="fight-box-hd";
$a["filmbox-hd"]="filmbox-hd";
$a["fuel-tv-hd"]="fuel-tv-hd";
$a["history-hd"]="history-hd";
$a["mezzo-live-hd"]="mezzo-live-hd";
$a["motorvision-hd"]="motorvision-hd";
$a["mtv-live-hd"]="mtv-live-hd";
$a["myzen-hd"]="myzen-hd";
$a["nat-geo-wild-hd"]="nat-geo-wild-hd";
$a["national-geographic-hd"]="national-geographic-hd";
$a["nickelodeon-hd"]="nickelodeon-hd";
$a["rtl-klub-hd"]="rtl-klub-hd";
$a["sportro-hd"]="sportro-hd";
$a["the-fishing-and-hunting-channel-hd"]="the-fishing-and-hunting-channel-hd";
$a["trace-sport-stars"]="trace-sport-stars";
$a["trace-tropical-hd"]="trace-tropical-hd";
$a["trace-urban-hd"]="trace-urban-hd";
$a["travel-channel-hd"]="travel-channel-hd";
$a["tvr-hd"]="tvr-hd";
$a["viasat-history-hd"]="viasat-history-hd";
$a["viasat-nature-hd"]="viasat-nature-hd";
$a["viasat-nature-history-hd"]="viasat-nature-history-hd";
$a["blue-hustler"]="blue-hustler";
$a["daring-tv"]="daring-tv";
$a["dorcel-tv"]="dorcel-tv";
$a["erotica"]="erotica";
$a["free-x-tv"]="free-x-tv";
$a["free-x-tv2"]="free-x-tv2";
$a["hustler-hd"]="hustler-hd";
$a["hustler-tv"]="hustler-tv";
$a["playboy-tv"]="playboy-tv";
$a["private-spice"]="private-spice";
$a["redlight-hd"]="redlight-hd";
$a["x-dream-tv"]="x-dream-tv";
///////////////////////////////////////////////////////////////////
//de le dolce.html
$a["tvr"]="";
$a["tvr-cluj"]="";
$a["tvr-craiova"]="";
$a["tvr-iasi"]="";
$a["tvr-targu-mures"]="";
$a["tvr-timisoara"]="";
$a["pvtv"]="";
$a["digi-24-iasi"]="";
$a["digi-24-craiova"]="";
$a["digi-24-constanta"]="";
$a["digi-24-oradea"]="";
$a["digi-24-timisoara"]="";
$a["comedy-central"]="comedy-central-extra";
$a["docu-box"]="docu-box-hd";
$a["fashion-box"]="fashion-tv";
$a["favorit-tv"]="favorit";
$a["giga-tv"]="";
$a["inedit-tv"]="";
$a["money"]="the-money-channel";
$a["national-24-plus"]="n24-plus";
$a["nickelodeon"]="nickelodeon";
$a["otv"]="";
$a["party"]="";
$a["tvh"]="tvh-20";
$a["agro-tv"]="";
$a["tv-city"]="";
$a["tvr-cluj"]="";
$a["tvr-craiova"]="";
$a["tvr-iasi"]="";
$a["tvr-targu-mures"]="";
$a["tvr-timisoara"]="";
$a["credo-tv"]="";
$a["u-tv"]="utv";
$a["valea-prahovei-tv"]="";
$a["tv-1000"]="tv1000";
////////////////////////////////////////////
//de la seenow.php
$a["rtv"]="romania-tv";
$a["digi24"]="digi-24";
$a["nickelodeon"]="nickelodeon";
$a["nick-jr."]="";
$a["alfa-omega"]="alfa-omega-tv";
$a["tvr-moldova"]="";
$a["tvr-tirgu-mures"]="";
$a["city-tv"]="";
$a["valea-prahovei"]="";
$a["filmbox-extra"]="filmbox-plus";
$a["docubox"]="docu-box-hd";
$a["fashionbox"]="fashion-tv";
$a["fightbox"]="fight-box-hd";

////////////////////////////////////////////////////
//de la spicetv
$a["blackbelt-tv"]="";
$a["cool"]="";
$a["da-vinci-learning"]="davinci-learning";
$a["id-discovery"]="discovery-investigation";
$a["jurnal-tv"]="";
$a["magyar-tv3"]="";
$a["tv5-monde"]="";
$a["extreme-sports"]="";
$a["jim-jam"]="jimjam";
$a["na~^(3)ta-tv"]="";
$a["spektrum-home"]="";
$a["sport-m"]="";
$a["acasa-tv"]="acasa";
$a["pro-tv-international"]="protv-international";
$a["6-tv"]="";
$a["tvh-2.0"]="tvh-20";
$a["sport.ro"]="sportro";
$a["eurosport-english"]="";
$a["bein-sports-1"]="";
$a["bein-sports-2"]="";
$a["bein-sports-3"]="";
$a["bein-sports-4"]="";
$a["bein-sports-5"]="";
$a["dubai-racing-channel"]="";
$a["discovery"]="discovery-channel";
$a["history"]="history-channel";
$a["pescuit-si-vanatoare-tv"]="the-fishing-and-hunting-channel";
$a["fishing-and-hunting"]="the-fishing-and-hunting-channel";
$a["cartoon-network---tcm"]="tcm";
$a["minimax-/-animax"]="minimax";
$a["1-music-channel"]="music-channel";
$a["mtv"]="mtv-romania";
$a["music-mix"]="";
$a["hora-tv"]="";
$a["vtv"]="";
$a["duna-televa~­zia~^(3)"]="";
$a["duna-world"]="";
$a["echo-tv"]="";
$a["filmplus"]="film-plus";
$a["ha~­r-tv"]="";
$a["magyar-atv"]="";
$a["magyar-tv1"]="";
$a["magyar-tv2"]="";
$a["rtl-2"]="";
$a["rtl-klub"]="";
$a["sorozatplus"]="";
$a["story-5"]="";
$a["tv2"]="";
$a["prizma-tv"]="";
$a["redlight-premium"]="";
$a["daring!-tv"]="";
$a["exotica-tv"]="";
$a["platinum-tv"]="";
$a["priveetv.it"]="";
$a["sct"]="";
$a["teleitalia-tv"]="";
$a["boy-and-boy"]="";
///////////////////////////////////////////////////////////
//de la sopcast.php
$a["antena3"]="antena-3";
$a["arenavision-1"]="";
$a["arenavision-2"]="";
$a["b1"]="b1-tv";
$a["digisport-1"]="digi-sport-1";
$a["digisport-2"]="digi-sport-2";
$a["digisport-3"]="digi-sport-3";
$a["discovery-id"]="discovery-investigation";
$a["dolcesport"]="dolce-sport";
$a["dolcesport-2"]="dolce-sport-2";
$a["dolcesport-3"]="";
$a["euforia"]="euforia-lifestyle";
$a["procinema"]="pro-cinema";
$a["protv"]="pro-tv";
$a["sport.ro"]="sportro";
///////////////////////////////////////////////////////////
//de la voyo.php
$a["acasa-tv-gold"]="acasa-gold";
//de la spyce.php
$a["look-plus"]="look-plus";
$a["1music-channel"]="music-channel";
$a["eurosport-1"]="eurosport";
$a["h!t-music-channel"]="hit-music-channel";
function c($title) {
     $title = htmlentities($title);
     $title = str_replace("&ordm;","s",$title);
     $title = str_replace("&Ordm;","S",$title);
     $title = str_replace("&thorn;","t",$title);
     $title = str_replace("&Thorn;","T",$title);
     $title = str_replace("&icirc;","i",$title);
     $title = str_replace("&Icirc;","I",$title);
     $title = str_replace("&atilde;","a",$title);
     $title = str_replace("&Atilde;","I",$title);
     $title = str_replace("&ordf;","S",$title);
     $title = str_replace("&acirc;","a",$title);
     $title = str_replace("&Acirc;","A",$title);
     $title = str_replace("&oacute;","o",$title);
     $title = str_replace("&amp;", "&",$title);
     return $title;
}
$n=0;
$first=0;

$id = $_GET["file"];
if ($id)
  $l=$a[$id];

//print("<b>".$title."</b><BR><BR>");
//print('.$title.'</b></H2>');
if ($l) {
//$link="http://port.ro/pls/w/tv.channel?i_ch=".$link."&i_xday=5";
$link="http://www.cinemagia.ro/program-tv/".$l."/";
$link="http://android.cinemagia.ro/program-tv/".$l."/";
//echo $link."<BR>";
//$link="http://port.ro/pls/w/tv.channel?i_ch=10017&i_xday=5"

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $link);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
  curl_setopt ($ch, CURLOPT_REFERER, "http://android.cinemagia.ro/program-tv/");
  //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
  //curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
  $html = curl_exec($ch);
  curl_close($ch);
//echo $html;
$p=explode('<li id="alarmContainer',$html);
$c=count($p);
 $ora=str_between($p[$c-1],'<span class="hour">','</span>');
 $title=str_between($p[$c-1],'<b>','</b>');
print $ora.' '.$title."\n\r";
$videos = explode('<li class="show', $html);
unset($videos[0]);
$videos = array_values($videos);
$n=0;
foreach($videos as $video) {
 $ora=str_between($video,'<span class="hour">','</span>');
 $title=str_between($video,'<b>','</b>');
 $title = trim(preg_replace("/(<\/?)(\w+)([^>]*>)/e","",$title));
 print $ora." ".$title."\n\r";
 $n++;
 if ($n > 10) exit;
}
} else {
echo "FARA PROGRAM";
}
?>

