Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/tools/components/cron_run.php
Строк: 55
<?php
defined
('_VALID') or die('Restricted Access!');
set_time_limit(0);
class 
VComponent_Admin_tools_cron_run
{
    private 
$db;
    public function 
__construct()
    {
        
$this->db    VF::factory('database');
    }
    
    public function 
render()
    {
        
$errors        = array();
        
$messages    = array();
        
$script        = array();
        
$cron_id    = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
    
        
$this->db->query("SELECT cron_id, slug, name
                          FROM #__cron
                          WHERE cron_id = "
.$cron_id."
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
            
$script    $this->db->fetch_assoc();
            
$slug    $script['slug'];
            
$name    $script['name'];
            
            
VLog::add('Running script: '.$slug);
            
$script_file        BASE_DIR.'/cron/scripts/'.$slug.'.php';
            
$script_function    'cron_'.$slug;
            if (!
function_exists($script_function)) {
                require 
$script_file;
            }
            
            
$script_function();
            
            
$this->db->query("SELECT cron_id, exec_time, exec_status
                              FROM #__cron
                              WHERE cron_id = "
.$cron_id."
                              LIMIT 1"
);
            
$script    $this->db->fetch_assoc();
            
            
$messages[] = 'Script Executed!';
        }
    
        
$tpl    VF::factory('template');
        
$tpl->menu            'tools';
        
$tpl->submenu        'tools_cron';
        
$tpl->meta_title    'Admin::Tools::Cron::Run';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->script        $script;
        
$tpl->load(array('header''tools_cron_run''footer'));
        
$tpl->display();
    }
}

function 
update_script($script_name$time=TRUE$status=FALSE)
{
    
VF::factory_remove('database');
    
$db VF::factory('database');

    if (
$time === TRUE) {
        
$db->query("UPDATE #__cron
                    SET exec_time = "
.time().",
                        exec_status = '0'
                    WHERE slug = '"
.$db->escape($script_name)."'
                    LIMIT 1"
);
    }

    if (
$status === TRUE) {
        
$db->query("UPDATE #__cron
                    SET exec_status = '1'
                    WHERE slug = '"
.$db->escape($script_name)."'
                    LIMIT 1"
);
    }
        
    
VLog::add('Updated script: '.$script_name.', time: '.$time.', status: '.$status);
}
Онлайн: 1
Реклама