Jump to content

Admin token en url


jose.alonso

Recommended Posts

yo uso este, deberas reemplazar por el nombre de tu modulo

 

_PS_BASE_URL_._MODULE_DIR_.'prestaprotect/prestaprotect-cron.php?token='.Tools::substr(
                            Tools::encrypt('prestaprotect/cron')
 
 
y luego un archivo externo que genera el token llamado prestaprotect-cron.php
 
 
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
/* Check to security tocken */
if (Tools::substr(Tools::encrypt('prestaprotect/cron'), 0, 10) != Tools::getValue('token') || !Module::isInstalled('prestaprotect')
) {
    die('Bad token');
}
include(dirname(__FILE__).'/prestaprotect.php');
$prestaprotect = new PrestaProtect();
/* Check if the module is enabled */
if ($prestaprotect->active) {
    /* Check if the requested shop exists */
    if (_PS_VERSION_ > '1.5.0.0') {
        $shops = Db::getInstance()
                   ->ExecuteS('SELECT id_shop FROM `'._DB_PREFIX_.'shop`');
        $list_id_shop = array();
        foreach ($shops as $shop) {
            $list_id_shop[] = (int)$shop['id_shop'];
        }
        $id_shop = (Tools::getIsset(Tools::getValue('id_shop')) && in_array(
            Tools::getValue('id_shop'),
            $list_id_shop
        )) ? (int)Tools::getValue('id_shop') : (int)Configuration::get('PS_SHOP_DEFAULT');
        $prestaprotect->cron = true;
        /* for the main run initiat the sitemap's files name stored in the database */
        if (!Tools::getIsset(Tools::getValue('continue'))) {
            $prestaprotect->cron((int)$id_shop);
        }
    } else {
        if (!Tools::getIsset(Tools::getValue('continue'))) {
            $prestaprotect->cron();
        }
    }
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...