Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/rss/components/edit.php
Строк: 109
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_rss_edit
{
    private 
$db;
    public function 
__construct()
    {
        
$this->db        VF::factory('database');
    }
    
    public function 
render()
    {
        
$errors        = array();
        
$messages    = array();
        
$warnings    = array();
        
$rss        = array();
        
$feed_id    = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
        
$this->db->query("SELECT feed_id FROM #__video_feeds WHERE feed_id = ".$feed_id." LIMIT 1");
        if (
$this->db->affected_rows()) {
            if (isset(
$_POST['submit_rss'])) {
                
$filter                VF::factory('filter');
                
$name                $filter->get('name');
                
$url                trim($_POST['url']);
                
$method                $filter->get('method');
                
$method_thumb        $filter->get('method_thumb');
                
$block_duplicates    = (int) trim($_POST['block_duplicates']);
                
$update_limit        = (int) trim($_POST['update_limit']);
                
$channel_id            = (int) trim($_POST['channel_id']);
                
$username            $filter->get('username');
                
$type                $filter->get('type');
                
$premium            = (int) trim($_POST['premium']);
                
$allow_comment        = (int) trim($_POST['allow_comment']);
                
$allow_download        = (int) trim($_POST['allow_download']);
                
$allow_rating        = (int) trim($_POST['allow_rating']);
                
$allow_embed        = (int) trim($_POST['allow_embed']);
                
$mobile                = (int) trim($_POST['mobile']);
                
$categ_method        $filter->get('category_method');
                
$categories            = (isset($_POST['category'])) ? (array) $_POST['category'] : array();
                
$status                = (int) trim($_POST['status']);
                
$queue                = (int) trim($_POST['queue']);
            
                if (
$name == '') {
                    
$errors[]    = 'Feed name field cannot be left blank!';
                }
            
                if (
$url == '') {
                    
$errors[]    = 'Feed URL field cannot be left blank!';
                } elseif (!
VValid::url($url)) {
                    
$errors[]    = 'Feed URL is not a valid URL address!';
                }
            
                if (
$update_limit 20) {
                    
$warnings[] = 'It is recommended that you set the Feed Update Limit to 10 for server resources balancing!';
                }
            
                if (
$categ_method == 'select') {
                    if (empty(
$categories)) {
                        
$errors[] = 'You need to select at least one category for your imported videos!';
                    }
                } else {
                    
$categories    = array();
                }
            
                if (
$username == '') {
                    
$errors[] = 'Username field cannot be left blank!';
                } else {
                    
$this->db->query("SELECT user_id
                                      FROM #__user
                                      WHERE username = '"
.$this->db->escape($username)."'
                                      AND status = '1'
                                      LIMIT 1"
);
                    if (
$this->db->affected_rows()) {
                        
$user_id            = (int) $this->db->fetch_field('user_id');
                    } else {
                        
$errors[] = 'Username was not found on this system (or not active)!';
                    }
                }
            
                if (!
$errors) {
                      
$rss        = array(
                          
'url'            => $url,
                          
'method'        => $method,
                          
'method_thumb'    => $method_thumb
                      
);
                
                    
$type = ($type == 'private') ? 'private' 'public';
                    
$feed VHelper::load('admin.rss.feed'TRUE);
                    
$feed->set_options($rss);
                    if (
$error $feed->test()) {
                        
$errors[] = $error;
                    } else {
                        
$this->db->query("UPDATE #__video_feeds
                                          SET user_id = "
.$user_id.",
                                              channel_id = "
.$channel_id.",
                                              name = '"
.$this->db->escape($name)."',
                                              url = '"
.$this->db->escape($url)."',
                                              method = '"
.$this->db->escape($method)."',
                                              method_thumb = '"
.$this->db->escape($method_thumb)."',
                                              block_duplicates = '"
.$block_duplicates."',
                                              update_limit = '"
.$update_limit."',
                                              type = '"
.$type."',
                                              premium = '"
.$premium."',
                                              mobile = '"
.$mobile."',
                                              allow_embed = '"
.$allow_embed."',
                                              allow_comment = '"
.$allow_comment."',
                                              allow_download = '"
.$allow_download."',
                                              allow_rating = '"
.$allow_rating."',
                                              categories = '"
.$this->db->escape(serialize($categories))."',
                                              status = '"
.$status."'
                                          WHERE feed_id = "
.$feed_id."
                                          LIMIT 1"
);
                        
$messages[] = 'Feed updated!';
                    }
                }
            }
            
            
$this->db->query("SELECT *
                              FROM #__video_feeds
                              WHERE feed_id = "
.$feed_id."
                              LIMIT 1"
);
            
$rss                     $this->db->fetch_assoc();
            
$categories                unserialize($rss['categories']);
            
$rss['categ_method']    = (empty($categories)) ? 'auto' 'select';
            
            
$this->db->query("SELECT username
                              FROM #__user
                              WHERE user_id = "
.(int) $rss['user_id']."
                              LIMIT 1"
);
            
$rss['username']        = $this->db->fetch_field('username');
                              
        }
        
        
$tpl                VF::factory('template');
        
$tpl->menu            'video';
        
$tpl->submenu        'video_add';
        
$tpl->extramenu        'video_rss';
        
$tpl->meta_title    'Admin::Video::Feed';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->warnings        $warnings;
        
$tpl->rss            $rss;

        
$tpl->channels      VModel::load('channel''channel'true)->channels(
            array(
'c.channel_id''c.name'), array('sort' => 'c.name''order' => 'ASC')
        );

        
$tpl->categories    VModel::load('category''video'true)->categories(
            array(
'c.cat_id''c.name''c.auto_term'),
            array(
'sort' => 'c.name''order' => 'ASC')
        );

        
$tpl->load(array('header''rss_edit''footer'));
        
$tpl->display();
    }    
}
Онлайн: 0
Реклама