Просмотр файла bs.php

Размер файла: 3.5Kb
<?php

// (c) Tegos
error_reporting (0);
if(time() - filemtime('biss.dat') > 3600*24){
ini_set('user_agent','Mozilla/5.0');
if(copy('http://lugasat.org.ua/tpkeys.html','file.dat')) {
$file=file_get_contents('file.dat');
$title='Таблица частот, каналов и ключей с основных спутников на Украине.';
$pos=strpos($file,$title);
$out=substr($file,$pos);
unset($file);
$end=strpos($out,'Ответы на самые популярные вопросы:');
$out=substr($out,0,$end-50);
$out=strip_tags($out,'<table><td><tr>');
$out=str_replace(' style="border: 1px solid #CCCCCC; background-color:#FFF;"','',$out);
$out=str_replace(' style="border: 1px solid #CCCCCC; background-color:#CCC;"','',$out);
$out=str_replace(' style="background-color:#38578d; border: 1px solid #CCCCCC; color:#FFF; text-align: center;"','',$out);
$out=str_replace(' width="100%" style="border: 1px solid #CCCCCC"','',$out);
$out=str_replace(' style="border: 1px solid #CCCCCC; background-color:#FFF;"','',$out);
$out=str_replace(' style="border: 1px solid #CCCCCC; background-color:#CCC;"','',$out);
$out=str_replace(' style="background-color:#38578d; border: 1px solid #CCCCCC; color:#FFF; text-align: center;"','',$out);
$out=str_replace(' width="100%" style="border: 1px solid #CCCCCC"','',$out);
$out=str_replace('<table>','<table class="zebra"><tbody>',$out);
$out=str_replace('</table>','</tbody></table>',$out);
//
$sp=array('Amos 2/3, 4.0&deg;W','Astra 4A (Sirius), 4.8&deg;E','Hot Bird 6/8/9, 13.0&deg;E','Astra 1G at 31.5&deg;E','Eutelsat W4/W7, 36.0&deg;E','Hellas Sat 2, 39.0&deg;E','Express AM22, 53.0&deg;E','Astra 1F, 55.0&deg;E (восток Украины)','ABS 1, 75.0&deg;E','Intelsat 904, 60.0&deg;E','Intelsat 15 at 85.2&deg;E','Yamal 201, 90.0&deg;E');
$sps=array('<table class="zebra"><tr><th>Amos 2/3, 4.0&deg;W</th></tr></table>','<table class="zebra"><tr><th>Astra 4A (Sirius), 4.8&deg;E</th></tr></table>','<table class="zebra"><tr><th>Hot Bird 6/8/9, 13.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Astra 1G at 31.5&deg;E</th></tr></table>','<table class="zebra"><tr><th>Eutelsat W4/W7, 36.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Hellas Sat 2, 39.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Express AM22, 53.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Astra 1F, 55.0&deg;E (восток Украины)</th></tr></table>','<table class="zebra"><tr><th>ABS 1, 75.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Intelsat 904, 60.0&deg;E</th></tr></table>','<table class="zebra"><tr><th>Intelsat 15 at 85.2&deg;E</th></tr></table>','<table class="zebra"><tr><th>Yamal 201, 90.0&deg;E</th></tr></table>');
$out=str_replace($sp,$sps,$out);
$out=str_replace($title,'<br/><center><img src="logo.jpg" alt=""/><br/><h1>'.$title.'</center></h1>',$out);
$out=preg_replace("/\s*\r+/","",$out); // вирiзаeмo пустi рядки
$out=trim($out);
$out=str_replace($out,'<div id="container">'.$out.'</div>',$out);
// html format
$ok='<html><head>';
$ok.='<title>'.$title.'</title>';
$ok.='<link rel="stylesheet" href="table.css" type="text/css">';
$ok.='</head><body>';
$ok.=$out;
unset($out);
$ok.='</body></html>';
// виводимо
echo $ok;
// запис у файл, для кешу
$fp=fopen('biss.dat','w+');
fputs($fp,$ok);
fclose($fp);
}else{ include_once('biss.dat');}
}else{ include_once('biss.dat');}
// час виконання
echo '<br/>Время: '.round(microtime()-$start_time,3).' сек.';
exit();
?>