Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/tools/components/cron_edit.php
Строк: 92
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_tools_cron_edit
{
    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
                          FROM #__cron
                          WHERE cron_id = "
.$cron_id."
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
            if (isset(
$_POST['submit-edit'])) {
                
$filter            VF::factory('filter');
                
$module            $filter->get('module');
                
$name            $filter->get('name');
                
$slug            $filter->get('slug');
                
$period            = (int) trim($_POST['period']);
                
$status            = (int) trim($_POST['status']);
                
$exec_time        = (int) trim($_POST['exec_time']);
                
$exec_status    = (int) trim($_POST['exec_status']);
            
                if (
$name == '') {
                    
$errors[]    = 'Script name cannot be left blank!';
                } elseif (!
VValid::length($name3100)) {
                    
$errors[]    = 'Script name must contain minimum 3 and no more than 100 characters!';
                }

                if (
$slug == '') {
                    
$errors[]    = 'Script SLUG cannot be left blank!';
                } elseif (!
VValid::alunderscore($slug)) {
                    
$errors[]    = 'Script SLUG can contain only alpha numeric characters and dashes!';
                } elseif (!
VValid::length($slug3100)) {
                    
$errors[]    = 'Script SLUG must contain minimum 3 and no more than 100 characters!';
                } else {
                    
$this->db->query("SELECT cron_id
                                      FROM #__cron
                                      WHERE slug = '"
.$this->db->escape($slug)."'
                                      AND cron_id != "
.$cron_id."
                                      LIMIT 1"
);
                    if (
$this->db->affected_rows()) {
                        
$errors[]        = 'SLUG is already used by another cron script entry!';
                    }
                }
            
                if (
$module == '') {
                    
$errors[]    = 'Please select a module for your script!';
                }
            
                if (
$period === 0) {
                    
$errors[]    = 'Script period cannot be left blank!';
                } elseif (
$period 1) {
                    
$errors[]    = 'Script period cannot be lower than 1 minutes!';
                }
            
                if (!
$errors) {
                    
$this->db->query("UPDATE #__cron
                                      SET module = '"
.$this->db->escape($module)."',
                                          name = '"
.$this->db->escape($name)."',
                                          slug = '"
.$this->db->escape($slug)."',
                                          period = "
.$period.",
                                          exec_time = "
.$exec_time.",
                                          exec_status = "
.$exec_status.",
                                          status = "
.$status."
                                      WHERE cron_id = "
.$cron_id."
                                      LIMIT 1"
);
                    
$messages[]    = 'Cron script updated!';
                }
            }
        
            
$this->db->query("SELECT cron_id, module, name, slug, period,
                                     exec_time, exec_status, status
                              FROM #__cron
                              WHERE cron_id = "
.$cron_id."
                              LIMIT 1"
);
            
$script $this->db->fetch_assoc();
            
        }
    
        
$tpl    VF::factory('template');
        
$tpl->menu            'tools';
        
$tpl->submenu        'tools_cron';
        
$tpl->meta_title    'Admin::Tools::Cron';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->script        $script;
        
$tpl->modules        $this->get_modules();
        
$tpl->load(array('header''tools_cron_edit''footer'));
        
$tpl->display();
    }
    
    private function 
get_modules()
    {
        
$this->db->query("SELECT name, description
                          FROM #__module
                          ORDER BY name ASC"
);
        return 
$this->db->fetch_rows();
    }
}
Онлайн: 1
Реклама