addHeaderLine("Referer", "www.123.se"); $be->addHeaderLine("Accept-Encoding", "x-compress; x-zip"); $be->addHeaderLine("Content-Type", "application/x-www-form-urlencoded"); $be2 = new BrowserEmulator(); $be2->addHeaderLine("Referer", "www.123.se"); $be2->addHeaderLine("Accept-Encoding", "x-compress; x-zip"); $be2->addHeaderLine("Content-Type", "application/x-www-form-urlencoded"); //******************************************************************************************** $geturl="http://www.svenskabio.se/stader/ornskoldsvik.htm"; $url="http://www.sf.se"; $file = $be->fopen($geturl); $response = $be->getLastResponseHeaders(); $urlstring=get_urlstring($geturl,$file,"Programmet","",''); //$urlstring="gäller 27 – 4 november 2006 Djävulen bär prada - Premiär! 18.15, 21.00 Barntillåten, Speltid 1.52 Exit - Premiär! 20.30 Från 15 år, Speltid 1.46 World Trade Center 18.15, 21.00 Från 11 år, Speltid 2.11 Vilddjuren Lör-sön 14.00, 16.00 Från 7 år, Speltid 1.25 Boog & Elliot - vilda vänner - Sverigepremiär! 18.30, Lör även 16.00 Sön även 14.00, 16.00 Från 7 år, Speltid 1.24 På andra sidan häcken Lör-sön 14.00, 16.00 Från 7 år, Speltid 1.26"; //echo $urlstring; $pattern="(gäller ([0-9]{1,2}) . ([0-9]{1,2}))"; if (preg_match_all($pattern, $urlstring, $matches, PREG_SET_ORDER)) { $short_days = array("sön","mån", "tis", "ons", "tors", "fre", "lör"); $unlimited_premiar_match=''; $unlimited_nonpremiar_match=''; $limited_match=''; //echo "

data->".$data."
pattern".$pattern."
company->".$company."
url->".$url."

"; $time = time(); $startday = $matches[0][1]; $endday = $matches[0][2]; $year = date('Y',$time); $month = date('n',$time); $day = date('j',$time); //echo $matches[0][1]."

"; //echo $matches[0][2]."

"; $pieces=explode($year,$urlstring); $urlstring=$pieces[1]; $film=explode("Speltid",$urlstring); //echo$urlstring. "

"; //$pattern="(([\w\W\s\S]{1,40} ([0-9,. ]{5,13} )(Från [0-9]{1,2} år|Barntillåten), Speltid [0-9]{1,2}.[0-9]{1,2}))"; //$pattern="((Speltid [0-9]{1,2}.[0-9]{1,2}) ([\w\W\s\S]{1,50} ([a-zA-ZåäöÅÄÖ]{3}-[a-zA-ZåäöÅÄÖ]{3}|[ ]{0,2})([0-9,. ]{5,13} )Från [0-9]{1,2} år, Speltid [0-9]{1,2}.[0-9]{1,2}))"; for ($u=0; $u< count($film); $u++) { $pattern="(".$film[$u]."Speltid [0-9]{1,2}.[0-9]{1,2})"; if (preg_match_all($pattern, $urlstring, $matches, PREG_SET_ORDER)) { if ($u>0){ $film_text=substr($matches[0][0], 5); } else { $film_text=$matches[0][0]; } $found_limit=0; $found_multiday_limit=0; for ($j=0; $j< count($short_days); $j++) { //echo $short_days[$j]; if (!strrpos(strtolower($film_text), strtolower($short_days[$j]." även"))){ if (strrpos(strtolower($film_text), strtolower($short_days[$j]))){ $found_limit=1; for ($k=0; $k< count($short_days); $k++) { if (strrpos(strtolower($film_text), strtolower($short_days[$j])."-".strtolower($short_days[$k]))){ // echo $matches[0][0]."
"; $found_multiday_limit=1; //if ($week_nr_in_year==$current_week-1 && $day_nr_in_week>$j || $day_nr_in_week==0){ // $limited_time_text=$limited_time_text." ".$matches[$i][1]; //} } } } } } if ($found_limit || $found_multiday_limit){ $limited_match=$limited_match."
-".$film_text; } if (!$found_limit){ if (strrpos(strtolower($film_text), "premiär")){ $unlimited_premiar_match=$unlimited_premiar_match."
-".$film_text; } else { $unlimited_nonpremiar_match=$unlimited_nonpremiar_match."
-".$film_text; } } } } $data="Premiärer visas minst från den ".$startday." till den ".$endday.""; $data=$data.$unlimited_premiar_match."
"; $data=$data.="
Ej Premiärer visas minst från den ".$startday." till den ".$endday.""; $data=$data.$unlimited_nonpremiar_match."
"; $data=$data.="
OBS film(er) som kanske inte visas idag."; $data=$data.$limited_match."
"; $urlstring= $data; //echo $urlstring; //$week_nr_in_year = date("W", mktime(0, 0, 0, $month,$day, $year)); if (strlen($pieces[1])>10){ if ($startday<$endday){ //reslutat i samma månad for ($day=$startday; $day<=$endday; $day++){ //echo $day."
"; $company=9; if(insert_data_in_db($url,$town=1,$category=4,$company,$urlstring, $year, $month, $day, 0, $link,$search_type=7,date("Y-m-d"),$sortorder=4000)){ delete_data_in_db($company,$link); } } } else { if ($day>=$startday){ $start_month=$month; } else { $start_month=$month-1; if ($start_month<1){ $start_month=12; } } $next_month = $start_month+1; if ($next_month>12){ $next_month=1; } $nr_of_days_in_month = date("t", mktime(0, 0, 0, $start_month,1, $year)); //echo $start_month.$nr_of_days_in_month; for ($day=$startday; $day<=$nr_of_days_in_month; $day++){ //echo $day."
"; $company=9; if(insert_data_in_db($url,$town=1,$category=4,$company,$urlstring, $year, $start_month, $day, 0, $link,$search_type=7,date("Y-m-d"),$sortorder=4000)){ delete_data_in_db($company,$link); } } for ($day=1; $day<=$endday; $day++){ //echo $day."
"; $company=9; if(insert_data_in_db($url,$town=1,$category=4,$company,$urlstring, $year, $next_month , $day, 0, $link,$search_type=7,date("Y-m-d"),$sortorder=4000)){ delete_data_in_db($company,$link); } } } } else { send_mail("jerker.bergman@gmail.com","Urlstring error","URLsring to short på ".$url); } } fclose($file); ?>