2017-02-15 11:37:40 +01:00
|
|
|
<?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 agences.txt FILE
|
|
|
|
$fname = 'agences.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_agencies`
|
|
|
|
');
|
|
|
|
|
|
|
|
while($line = fgets($file)) {
|
|
|
|
if(substr($line, 1, 1) == '1') {
|
|
|
|
|
|
|
|
Db::getInstance()->ExecuteS('
|
|
|
|
INSERT INTO `'._DB_PREFIX_.'mondialrelay_agencies`
|
|
|
|
VALUES (
|
|
|
|
"'.pSQl(substr($line, 6, 4)).'",
|
2017-02-15 12:10:01 +01:00
|
|
|
"'.pSQl(substr($line, 10)).'"
|
2017-02-15 11:37:40 +01:00
|
|
|
)
|
|
|
|
');
|
|
|
|
}
|
|
|
|
}
|