63 lines
1.8 KiB
PHP
Executable File
63 lines
1.8 KiB
PHP
Executable File
<?php
|
|
if(isset($_SERVER['REMOTE_ADDR'])) {
|
|
exit;
|
|
}
|
|
|
|
$_SERVER['HTTP_PORT'] = 80;
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
|
|
|
|
|
## GET pltri.txt FILE
|
|
$fname = 'pltri.txt';
|
|
$filename = dirname(__FILE__) . '/' . $fname;
|
|
$file = fopen($filename, 'w+');
|
|
$remote_file = $fname;
|
|
|
|
$ftp = ftp_connect(Configuration::get('MONDIALRELAYWS_FTP_HOST'));
|
|
ftp_login($ftp, Configuration::get('MONDIALRELAYWS_FTP_LOGIN'), Configuration::get('MONDIALRELAYWS_FTP_PASSWORD'));
|
|
ftp_chdir($ftp, 'depuismrelay');
|
|
if (!ftp_fget($ftp, $file, $remote_file, FTP_BINARY))
|
|
die('An error occures while downloading remote file : ' . $fname);
|
|
|
|
$file = fopen($filename, 'r');
|
|
$content = fgets($file);
|
|
if (!$content)
|
|
die('File is empty : ' . $fname);
|
|
|
|
## Update DB
|
|
Db::getInstance()->ExecuteS('
|
|
TRUNCATE TABLE `'._DB_PREFIX_.'mondialrelay_tri`
|
|
');
|
|
|
|
while($line = fgets($file)) {
|
|
if(substr($line, 1, 1) == '1') {
|
|
$datdeb = explode('.', substr($line, 36, 10));
|
|
$datdeb = $datdeb[2].'-'.$datdeb[1].'-'.$datdeb[0];
|
|
$datfin = explode('.', substr($line, 46, 10));
|
|
$datfin = $datfin[2].'-'.$datfin[1].'-'.$datfin[0];
|
|
|
|
Db::getInstance()->ExecuteS('
|
|
INSERT INTO `'._DB_PREFIX_.'mondialrelay_tri`
|
|
VALUES (
|
|
"'.pSQl(substr($line, 2, 2)).'",
|
|
"'.pSQl(substr($line, 4, 8)).'",
|
|
"'.pSQl(substr($line, 12, 1)).'",
|
|
"'.pSQl(substr($line, 13, 3)).'",
|
|
"'.pSQl(substr($line, 16, 4)).'",
|
|
'.(int) substr($line, 20, 1).',
|
|
"'.pSQl(substr($line, 21, 5)).'",
|
|
"'.pSQl(substr($line, 26, 1)).'",
|
|
"'.pSQl(substr($line, 27, 3)).'",
|
|
"'.pSQl(substr($line, 30, 2)).'",
|
|
"'.pSQl(substr($line, 32, 4)).'",
|
|
"'.pSQl($datdeb).'",
|
|
"'.pSQl($datfin).'",
|
|
"'.pSQl(substr($line, 56, 2)).'",
|
|
"'.pSQl(substr($line, 58, 2)).'"
|
|
)
|
|
');
|
|
}
|
|
}
|