95 lines
3.0 KiB
PHP
95 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* 2007-2018 PrestaShop
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
* versions in the future. If you wish to customize PrestaShop for your
|
|
* needs please refer to http://www.prestashop.com for more information.
|
|
*
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
* @copyright 2007-2018 PrestaShop SA
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
*/
|
|
|
|
require_once('../../config/config.inc.php');
|
|
require_once('../../init.php');
|
|
require_once(dirname(__FILE__).'/classes/pssitemapDataClass.php');
|
|
require_once(dirname(__FILE__).'/pssitemap.php');
|
|
|
|
function canExecuteCronTask()
|
|
{
|
|
// Check if we used the cli
|
|
if (php_sapi_name() === 'cli') {
|
|
return true;
|
|
}
|
|
|
|
// Check if the token is good
|
|
if (Tools::getValue('token') === configuration::get('PSM_CRON_TOKEN')) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
if (!canExecuteCronTask()) {
|
|
echo "INVALID TOKEN";
|
|
exit;
|
|
}
|
|
|
|
$id_lang = explode(",", configuration::get('LANGUAGE_CONF'));
|
|
$id_shop = (int)Context::getContext()->shop->id;
|
|
|
|
$category_frequency = configuration::get('CATEGORY_FREQUENCY');
|
|
$category_priority = configuration::get('CATEGORY_PRIORITY');
|
|
|
|
$product_frequency = configuration::get('PRODUCT_FREQUENCY');
|
|
$product_priority = configuration::get('PRODUCT_PRIORITY');
|
|
|
|
$other_frequency = configuration::get('OTHER_PAGE_FREQUENCY');
|
|
$other_priority = configuration::get('OTHER_PAGE_PRIORITY');
|
|
|
|
$cms_frequency = configuration::get('CMS_FREQUENCY');
|
|
$cms_priority = configuration::get('CMS_PRIORITY');
|
|
|
|
$sitemap = new PssitemapData();
|
|
$pssitemap = new Pssitemap();
|
|
|
|
/** GENERATE HTML SITEMAP **/
|
|
$id_cms = configuration::get('CMS_PAGE');
|
|
|
|
if (configuration::get('CMS_PAGE') == 0) {
|
|
exit("Please select a cms page");
|
|
} elseif (configuration::get('CMS_PAGE') != 0) {
|
|
$pssitemap->updateCMS($id_cms);
|
|
}
|
|
|
|
/** XML **/
|
|
foreach ($id_lang as $value) {
|
|
if (configuration::get('SITEMAP_CATEGORY') != 0) {
|
|
$sitemap->getActiveURLCategory($category_frequency, $category_priority, $id_shop, $value);
|
|
}
|
|
if (configuration::get('SITEMAP_PRODUCT') != 0) {
|
|
$sitemap->getActiveURLProduct($product_frequency, $product_priority, $id_shop, $value);
|
|
}
|
|
if (configuration::get('SITEMAP_CMS') != 0) {
|
|
$sitemap->getActiveURLCMS($cms_frequency, $cms_priority, $id_shop, $value);
|
|
}
|
|
if (configuration::get('SITEMAP_OTHER_PAGES') != 0) {
|
|
$sitemap->getActiveURLOtherPage($other_frequency, $other_priority, $id_shop, $value);
|
|
}
|
|
}
|
|
echo "CRON TASK EXECUTED";
|