Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/tools/components/cron.php
Строк: 59
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_tools_cron
{
    private 
$db;
    public function 
__construct()
    {
        
$this->db    VF::factory('database');
    }
    
    public function 
render()
    {
        
$errors        = array();
        
$messages    = array();
        
        if (isset(
$_POST['action']) && isset($_POST['cron_id'])) {
            
$action        trim($_POST['action']);
            
$cron_id    = (int) trim($_POST['cron_id']);
            
            if (
$cron_id) {
                if (
$action == 'activate' or $action == 'suspend') {
                    
$status    = ($action == 'activate') ? 0;
                    
$msg    = ($action == 'activate') ? 'enabled' 'disabled';
                    
                    
$this->db->query("
                        UPDATE #__cron
                        SET status = "
.$status."
                        WHERE cron_id = "
.$cron_id."
                        LIMIT 1
                    "
);
                    
                    
$messages[]    = 'Cron script '.$msg.'!';
                } else {
                    
$errors[]    = 'Invalid action!';
                }
            } else {
                
$errors[]    = 'Invalid cron script!';
            }
        }
    
        
$this->db->query("SELECT cron_id, name, slug, period,
                                 exec_time, exec_status, status
                          FROM #__cron
                          ORDER BY cron_id ASC"
);
        
$scripts    $this->db->fetch_rows();
        
        
$secret        md5(VF::cfg_item('secret'));    
        
$crontabs    = array(
            
'* * * * * '.VF::cfg_item('php_cli_path').' '.BASE_DIR.'/cron/cron.php '.$secret,
        );
        
        
$wget_path    '/usr/bin/wget';
        if (
file_exists($wget_path) && is_file($wget_path) && is_executable($wget_path)) {
            
$crontabs[]    = '* * * * * '.$wget_path.' '.BASE_URL.'/cron/cron.php?secret='.md5(VF::cfg_item('secret')).' -O /dev/null';
        }
        
        
$curl_path    '/usr/bin/curl';
        if (
file_exists($curl_path) && is_file($curl_path) && is_executable($curl_path)) {
            
$crontabs[]    = '* * * * * '.$curl_path.' '.BASE_URL.'/cron/cron.php?secret='.md5(VF::cfg_item('secret')).' -o /dev/null';
        }
    
        
$tpl    VF::factory('template');
        
$tpl->menu            'tools';
        
$tpl->submenu        'tools_cron';
        
$tpl->meta_title    'Admin::Tools::Cron';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->scripts        $scripts;
        
$tpl->crontabs        $crontabs;
        
$tpl->load(array('header''tools_cron''footer'));
        
$tpl->display();
    }
}
Онлайн: 1
Реклама