Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/midrollnew.php
Строк: 97
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_nuevo_midrollnew
{
    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();
    
        
$days=array();
        for(
$i=1;$i<=31;$i++) $days[$i] = $i;

        
$year_beg=2012$years=array();
        for(
$i=1;$i<=38;$i++) {
            
$years[$i] = $year_beg;
            
$year_beg++;
        }        

        
$data=array('owner'=>'','email'=>'','duration'=>5,'title'=>'''description'=>'','url'=>'','link' =>'''target'=>'_self','image'=>'''month'=>'January','day'=>'1','year'=>'2012','active'=>0);


        if (isset(
$_POST['create_ad'])) {
            
            
$data['owner']          = trim($_POST['owner']);
            
$data['email']          = trim($_POST['email']);
            
$data['duration']        = intval($_POST['duration']);
            
$data['title']          = trim($_POST['title']);
            
$data['description']    = trim($_POST['description']);
            
$data['url']            = trim($_POST['url']);
            
$data['link']            = trim($_POST['link']);
            
$data['target']            = trim($_POST['target']);
            
$data['image']            = trim($_POST['image']);
            
$data['month']            = intval($_POST['month']);
            
$data['year']            = intval($_POST['year']);
            
$data['day']            = intval($_POST['day']);

            if ( 
$data['duration'] < )
                
$errors[] = 'Invalid value for midroll duration!';
            elseif ( 
strlen($data['title']) < )
                
$errors[] = 'Midroll title field cannot be blank!';
            elseif ( 
strlen($data['description']) < )
                
$errors[] = 'Midroll description field cannot be blank!';
            elseif ( 
strlen($data['url']) < )
                
$errors[] = 'Midroll URL cannot be empty!';
            elseif (
$data['month']<|| $data['day']<|| $data['year']<1)
                
$errors[] = 'Expire date not valid';


            
            if ( !
$errors ) {
            
                
$expire mktime(0,0,0,$data['month'],$data['day'],$data['year']);
                
$data['expire'] = $expire;
                
$added time();
                
$duration $data['duration'];
                if(
strlen($data['owner'])>0$owner =  mysql_real_escape_string($data['owner']); else $owner='';
                if(
strlen($data['email'])>0$email =  mysql_real_escape_string($data['email']); else $email='';
                
$title mysql_real_escape_string($data['title']);
                
$description mysql_real_escape_string($data['description']);
                
$url mysql_real_escape_string($data['url']);
                
$link mysql_real_escape_string($data['link']);
                
$target mysql_real_escape_string($data['target']);
                
$image mysql_real_escape_string($data['image']);
                
$active $data['active'];


                
$sql "INSERT into nuevo__midroll SET ID = NULL, owner = '$owner', email = '$email', duration = '$duration', title = '$title', description = '$description',url = '$url', link = '$link', target = '$target',image = '$image', expire = '$expire',added = '$added', active = '$active'";

                
$this->db->query($sql);
                if(
$this->db->affected_rows()) {
                    
header("Location: ".ADMIN_URL.'/index.php?q=nuevo/midroll');
                    die();
                } else {
                    
$errors[] = 'Error while saving data in database.';
                }
            }
                        
        }
        
        
        
        
$tpl = &VF::factory('template');
        
$tpl->menu            'nuevo';
        
        
$tpl->submenu        'nuevo_ads';
        
$tpl->meta_title    'Admin::Nuevo::Create Midroll ad';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->ad            $data;
        
$tpl->days            $days;
        
$tpl->years            $years;
        
$tpl->pmenu            'midroll';

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