first commit
This commit is contained in:
59
web/cron.php
Normal file
59
web/cron.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user