Como soluciono esto , este php lo puedo ejecutar manual y funciona pero cuando lo voy a utilizar en un cron job me da este error:
syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in <b>/home/content/09/10956209/html/cs-cart/pr/csv_import.php</b> on line <b>2</b><br />
<?php
use app\Tygh\Registry;
define('BOOTSTRAP','A');
//if (!defined('BOOTSTRAP')) { die('Access denied'); }
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
/*chdir(__DIR__);
chdir('../../../../');*/
// [mink] 2012.05.14
// $root_dir = '/var/www/vhosts/carritoenlinea.com/httpdocs/csv_proceso/';
$root_dir = '/var/chroot/home/content/09/10956209/html/cs-cart';
// [/mink]
$mode = 'cron_import';
//echo 'Listo';
//require $root_dir . '/prepare.php';
require $root_dir . '/init.php';
require $root_dir . '/app/controllers/backend/exim.php';
//echo 'Hola';
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
file_put_contents(__DIR__.'/ip.log',$_SERVER['REMOTE_ADDR']."\n",FILE_APPEND);
$log = array_unique(file(__DIR__.'/ip.log'));
file_put_contents(__DIR__.'/ip.log',$log);
die();
}
// Init YAML parser
//n_init_yaml();
//$suffix = '';
$import_items = 'products';
$csv_dirname = 'csv_proceso/csv_import';
$d = dir($root_dir.DIRECTORY_SEPARATOR.$csv_dirname) or die('Can\t open'.$csv_dirname.' dir');
while (false !== ($f = $d->read())) { //echo '<p>Entro al while</p>';
if (is_file($d->path.'/'.$f) && fnmatch("Modificaciones*.csv", $f))
{
//echo '<p>Delimitadores</p>';
$file = $d->path.'/'.$f;
// [mink] 21.05.2011
$import_options = array(
'lang_code' => 'es',
'category_delimiter' => '///',
'features_delimiter' => '///',
'price_dec_sign_delimiter' => '.',
'delimiter' => 'Punto y coma'
);
// [/mink]
if (!empty($file)) {
$pattern = fn_get_pattern_definition($import_items, 'import');
//echo '<p>Importa</p>';
if (($data = fn_get_csv($pattern, $file, $import_options)) != false) {
fn_import($pattern, $data, $import_options);
if (copy($file, $root_dir.DIRECTORY_SEPARATOR.$csv_dirname .'/archive/'.$f))
{
unlink($d->path.'/'.$f);//echo '<p>Copia</p>';
}
/*
$params = array();
list($users,$params) = fn_get_users($params, $auth);
foreach ($users as $user){
$user_data = fn_get_user_info($user['user_id']);
if ($user_data['recv_import_email'] == 'Y'){
$to = $user_data['email'];
$from = Registry::get('settings.Company.company_users_depa rtment');
$subj = 'addons/cron_csv_import/success_import_subj.tpl';
$body = 'addons/cron_csv_import/success_import.tpl';
$attachments = array($d->path.'/'.$f);
Registry::get('view_mail')->assign('user_data', $user_data);
Registry::get('view_mail')->assign('f',$f);
fn_send_mail($to, $from, $subj, $body);
}
}*/
}
}
else
{
//echo '<p>No entro</p>';
}
}
}
$d->close();
exit;
?>