Files
interblue.pl/modules/pshowimporter/ajax_status.php
2024-10-25 14:16:28 +02:00

73 lines
2.3 KiB
PHP

<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
// not finished
die('no_access');
ini_set('max_execution_time', 86400);
ini_set('display_errors', 'On');
error_reporting(E_ALL);
define('IMPORTING_NOW', true);
define('_PS_ADMIN_DIR_', true);
require_once "./../../config/config.inc.php";
require_once "./config.php";
ini_set('display_errors', 'On');
error_reporting(E_ALL);
if (!Tools::getValue('securekey') || Tools::getValue('securekey') != _IMPORT_SECURE_KEY_) {
if (!Tools::getValue('securekey') && (!isset($argv[1]) || $argv[1] != _IMPORT_SECURE_KEY_)) {
die('direct access denied');
}
}
$filename = file_get_contents(_IMPORT_STATUS_PATH_ . "filename");
if (!PShow_Import::getInstance($filename)) {
die('no-import-found');
}
function isSomethingToImport()
{
if (!file_exists(_IMPORT_STATUS_PATH_ . "actual_row")) {
return false;
}
if (PShow_Config::get('rowsCount') === false) {
return false;
}
$rowsCount = PShow_Config::get('rowsCount');
$actualRow = (int) PShow_File::file_get_contents(_IMPORT_STATUS_PATH_ . "actual_row");
return (($rowsCount - $actualRow) > 0);
}
$data = Tools::jsonEncode(array(
'filename' => $filename,
'actual_row' => PShow_Import::getInstance()->status['actual_row'],
'first_line' => 1,
'counter_imported_rows' => PShow_Import::getInstance()->status['counter_imported_rows'],
'counter_error_rows' => PShow_Import::getInstance()->status['counter_error_rows'],
'counter_skipped_rows' => PShow_Import::getInstance()->status['counter_skipped_rows'],
'isSomethingToImport' => (bool) isSomethingToImport(), //(bool) self::isSomethingToImport(),
'error' => array(), //$alerts,
'importedThisTime' => 10, //(isset($imported_rows) ? $imported_rows : 0),
'time' => 0, //round((getmicrotime() - $start_time), 2),
'memory_usage' => 0, //$memory_usage,
'cpu_usage' => 0, //($cpu_usage[0]) . '%',
'memory_limit' => (ini_get('memory_limit'))
));
die($data);