- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
#!/usr/bin/php5
<?php
set_time_limit(0);
//include("crypt.php");
exec("rm jtv.zip");
exec("wget http://www.teleguide.info/download/new3/jtv.zip"); //скачать архив телепрограммы в формате itv.zip//
exec("rm list/*.* "); //очистить каталог "list"//
exec("unzip -x jtv.zip -d list "); //извлеч файлы из архива в папку "list"//
sleep(3);
$dir = "/home/tt/wwwplaylist/list/";
exec("ls list | grep '.ndx'", $tmplist);
$ch = array(
1=>1,2=>2,3=>3,250=>195,241=>196,209=>197,177=>168,
//170=>198,186=>199,191=>200,174=>201,172=>202,189=>203,188=>204,
//161=>205,171=>206,187=>207,211=>208,223=>209,212=>210,210=>211,
//245=>212,213=>213,181=>214,254=>215,222=>216,218=>217,219=>218,
//217=>219,253=>220,221=>221,175=>222,180=>223,199=>192,252=>193,
//233=>194,226=>195,228=>196,224=>197,173=>168,229=>198,231=>199,
//234=>200,235=>201,232=>202,239=>203,238=>204,236=>205,196=>206,
//197=>207,201=>208,230=>209,198=>210,244=>211,246=>212,242=>213,
//251=>214,249=>215,214=>216,220=>217,248=>218,163=>219,216=>220,
//251=>214,249=>215,214=>216,220=>217,248=>218,163=>219,216=>221,
215=>222,131=>223,0=>220);
$serveraddress="localhost";
$mysqluser="root";
$mysqlpassword="12345";
$mysqldatabase="pl";
$descriptor = mysql_connect($serveraddress,$mysqluser,$mysqlpassword);
mysql_select_db($mysqldatabase,$descriptor);
mysql_query("SET NAMES CP1251");
mysql_query("truncate table TV_epg");
function int2float($i) {
$x32 = 4294967296;
$i = (float)$i;
if ($i < 0) return $i + $x32 + 1; else return $i; /* signed int32 overflow */
}
function FILETIMEtoUNIXtime($FILETIME) {
$x32 = 4294967296;
$sec_btw_epoch = (float)(116444736 * 100);
$low = (ord($FILETIME[0])) | (ord($FILETIME[1]) << 8) | (ord($FILETIME[2]) << 16) | (ord($FILETIME[3]) << 24);
$high = (ord($FILETIME[4])) | (ord($FILETIME[5]) << 8) | (ord($FILETIME[6]) << 16) | (ord($FILETIME[7]) << 24);
$f64 = (int2float($high) * $x32 + int2float($low)) / 10000000;
return (int)($f64 - $sec_btw_epoch);
}
foreach ($tmplist as $key=>$value) {
$f=substr($value, 0, -4);
$res=$f;
for($i=0; $i<strlen($res); $i++) $res[$i]=(array_key_exists(ord($res[$i]),$ch)) ? chr($ch[ord($res[$i])]) : $res[$i];
$f1=fopen("list/".$f.".ndx", "rb");
$f2=fopen("list/".$f.".pdt", "rb");
$test1 = bin2hex(fread($f1, 1));
$test2 = bin2hex(fread($f1, 1));
$countpr = hexdec($test2.$test1);
for ($i=0; $i<$countpr; $i++ )
{
$tmp=0;
$ft='';
$tmp = fread($f1, 2);
for ($j=0; $j<8; $j++)
$ft.= (fread($f1, 1));//.$ft;
$dates= date("Y-m-d H:i:s", FILETIMEtoUNIXtime($ft));
//////////////index f2////////////
$offset=0;
$str = bin2hex(fread($f1, 1));
$str2 = bin2hex(fread($f1, 1));
$offset = hexdec($str2.$str);
///////////////name////////////////
$len=0;
fseek($f2, $offset);
$str = bin2hex(fread($f2, 1));
$str2 = bin2hex(fread($f2, 1));
$len = hexdec($str2.$str);
$name = fread($f2, $len);
mysql_query("insert into `TV_epg` set `epg_ch`='$res',`epg_date`='$dates',`epg_name`='$name' ");
}
}
#mysql_quuery("update TV_epg set epg_date=epg_date-interval 4 hour;");
mysql_query("update TV_epg set epg_date=epg_date-interval 1 hour;");
?>