<?php
/*
* SITEMAP CLI GENERATOR - v 1.0.1 (29.10.2011)
* generate google sitemap from product, category, information, news
*
*
* changes:
* 1.0.1 - first release
*
*/
// debug
//ini_set('error_reporting', 6143);
//ini_set('display_errors', 1);
define('OPENCART_ROOT_DIR', '/site.ru/');
require_once(OPENCART_ROOT_DIR . "admin/config.php");
require_once(DIR_SYSTEM . 'startup.php');
require_once(DIR_DATABASE . 'mysql.php');
require_once(OPENCART_ROOT_DIR . 'admin/controller/tool/ajax.php');
require_once(OPENCART_ROOT_DIR . 'admin/controller/tool/fileupload.php');
//require_once(OPENCART_ROOT_DIR . 'admin/controller/tool/export.php');
require_once(OPENCART_ROOT_DIR . 'admin/model/tool/export.php');
//require_once(OPENCART_ROOT_DIR . 'admin/controller/tool/import.php');
$file = OPENCART_ROOT_DIR . '/import/backup_categories_products.xls';
// Registry
$registry = new Registry();
// Loader
$obj = new Loader($registry);
$registry->set('load', $obj);
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting");
foreach ($query->rows as $setting) {
$config->set($setting['key'], $setting['value']);
}
// Cache
$registry->set('cache', new Cache());
// Language Detection
$query = $db->query("SELECT language_id FROM " . DB_PREFIX . "language WHERE code = '" . $config->get('config_language') . "'");
$language_id = $query->row['language_id'];
$config->set('config_language_id', $language_id);
// Default Store
$config->set('config_store_id', 0);
$obj->load->model('tool/export');
$file = fileupload("{$_SERVER['DOCUMENT_ROOT']}".'/admin/uploads');
echo json_encode(array('status'=>'ok','file'=>$file));
class ControllerToolImport extends Controller {
private $error = array();
public function index() {
$obj->load->model('tool/export');
$file = $_GET["file"];
if (file_exists($file)) {
if ($obj->model_tool_export->upload($file)) {
echo "The End";
unset($_SESSION['startRow']);
unset($_SESSION['isFirstEnter']);
unset($_SESSION['productRewardId']);
@unlink($file);
//$this->session->data['success'] = $this->language->get('text_success');
//$this->redirect($this->url->link('tool/export', 'token=' . $this->session->data['token'], 'SSL'));
}
else {
//$this->error['warning'] = $this->language->get('error_upload');
//echo "Не удалось загрузить файл!";
}
} else {
echo "Ошибка! Не удалось обнаружить файл: ".$file;
}
}
public function download() {
if ($obj->validate()) {
// set appropriate timeout limit
set_time_limit( 1800 );
// send the categories, products and options as a spreadsheet file
$obj->load->model('tool/export');
$obj->model_tool_export->download();
} else {
// return a permission error page
return $obj->forward('error/permission');
}
}
private function validate() {
if (!$obj->user->hasPermission('modify', 'tool/export')) {
$obj->error['warning'] = $obj->language->get('error_permission');
}
if (!$obj->error) {
return TRUE;
} else {
return FALSE;
}
}
}
echo "\n";
echo "Import is succefully complete!\n";
?>