37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
|
|
include_once dirname(__FILE__).'/www/config/config.inc.php';
|
|
|
|
$db = Db::getInstance();
|
|
|
|
foreach(glob(dirname(__FILE__).'/emarsys/*.csv') as $filename) {
|
|
$f = fopen($filename, 'r');
|
|
fgetcsv($f);
|
|
while($line = fgetcsv($f, 0, ';', '"')) {
|
|
if(in_array((int) $line[1], array(0, 1, 2)) && !empty($line[2]) && in_array(strtolower($line[3]), array('vrai', 'faux')) && Validate::isEmail($line[2])) {
|
|
if($customer = $db->getRow('
|
|
SELECT `id_customer`
|
|
FROM `'._DB_PREFIX_.'customer`
|
|
WHERE `email` = "'.pSQL($line[2]).'"
|
|
')) {
|
|
if(strtolower($line[3]) == 'faux') {
|
|
$active = 0;
|
|
} else {
|
|
$active = (int) $line[1];
|
|
}
|
|
$db->ExecuteS('
|
|
UPDATE `'._DB_PREFIX_.'customer`
|
|
SET `newsletter` = '.(int) $active.',
|
|
`newsletter_date_add` = NOW()
|
|
WHERE `email` = "'.pSQL($line[2]).'"
|
|
LIMIT 1
|
|
');
|
|
}
|
|
}
|
|
}
|
|
fclose($f);
|
|
rename($filename, str_replace('/emarsys/', '/emarsys_done/', $filename));
|
|
} |