Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/invideo.php
Строк: 51
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_nuevo_invideo
{
    private $db;
    private $cache;
    private $filter;
    public function __construct()
    {
        $this->db        = VF::factory('database');
        $this->cache    = VF::factory('cache');
        $this->filter    = VF::factory('filter');
    }
    
    public function render()
    {
        $errors        = array();
        $messages    = array();
        $warnings    = array();
        $this->db->query("SELECT * FROM nuevo__invideo WHERE ID = 1 LIMIT 1");
        $data= $this->db->fetch_assoc();
        if (isset($_POST['update_ad'])) {
            
            $data['active']            = $_POST['active']  == '1' ? '1' : '0';
            $data['invideo']        = $_POST['invideo'];
            $data['channel']        = intval($_POST['chanel']);
        
            
            if ( !$errors ) {
                $channel = mysql_real_escape_string($data['channel']);
                $active = $data['active'];
                $sql = "UPDATE nuevo__invideo SET invideo = '".mysql_real_escape_string($data['invideo'])."', channel='$channel', active = '$active' WHERE ID = 1 LIMIT 1";
                $this->db->query($sql);
                if($this->db->affected_rows()) {
                    $messages[] = "Updated succesfullu.";
                } else {
                    $errors[] = 'Error while saving data in database.';
                }
            }
        }
        
        $sql                = "SELECT cat_id, parent_id, name, slug, total_videos, status
                               FROM #__video_categories
                               ORDER BY slug, parent_id ASC";
        $categories            = $this->db->get_rows($sql);
        
        
        
        $tpl = &VF::factory('template');
        $tpl->menu            = 'nuevo';
        
        $tpl->submenu        = 'nuevo_ads';
        $tpl->meta_title    = 'Admin::Nuevo::Create ad';
        $tpl->errors        = $errors;
        $tpl->messages        = $messages;
        if(isset($data))        $tpl->ad            = $data;
        if(isset($categories))    $tpl->categories    = $categories;
        $tpl->pmenu            = 'invideo';
        if(isset($days))            $tpl->days            = $days;
        if(isset($years))        $tpl->years            = $years;
        $tpl->load(array('header', 'nuevo_invideo', 'footer'));
        $tpl->display();
    }
    
}
?>