Files
kupshop/web/cron.php
2025-08-02 16:30:27 +02:00

60 lines
1.5 KiB
PHP

<?php
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
require_once $cfg['Path']['shared_version'].'admin/functions.admin.php';
$main_class = 'CronBase';
class CronBase
{
public function run()
{
$this->checkAccess();
if (getVal('expensive')) {
ini_set('max_execution_time', 600);
} else {
ini_set('max_execution_time', 60);
}
$methods = get_class_methods($this);
foreach ($methods as $method) {
if (strpos($method, 'run_') === false) {
continue;
}
if (method_exists($this, $method)) {
$this->$method();
}
}
echo 'OK';
}
protected function checkAccess()
{
// Really stupid security, I know, but what the hell ...
if (getVal('true_secret') != 'wpj') {
exit('Permission denied');
}
}
protected function run_SymfonyCron()
{
if (php_sapi_name() == 'cli') {
return;
}
$dispatcher = ServiceContainer::getService('event_dispatcher');
$event = new \KupShop\KupShopBundle\Event\CronEvent(false);
$dispatcher->dispatch($event, \KupShop\KupShopBundle\Event\CronEvent::RUN_NORMAL);
if (getVal('expensive')) {
$event = new \KupShop\KupShopBundle\Event\CronEvent(true);
$dispatcher->dispatch($event, \KupShop\KupShopBundle\Event\CronEvent::RUN_EXPENSIVE);
}
}
}