Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/midrolledit.php
Строк: 102
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_nuevo_midrolledit
{
    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();

        
$id    = ( isset($_GET['id']) && is_numeric($_GET['id']) ) ? trim($_GET['id']) : NULL;
        
settype($id'integer');
        if ( !
$id ) {
            
$errors[] = 'Invalid ad ID. This ad does not exist!';
        } else {


        
$sql "SELECT * FROM nuevo__midroll WHERE ID = '".$id."' LIMIT 1";
        
$this->db->query($sql);
        
$data$this->db->fetch_assoc();        

        
$data['day'] = intval(date("j",$data['expire']));
        
$data['month'] = intval(date("n",$data['expire']));
        
$data['year'] = intval(date("Y",$data['expire']));

        if(
$data['views']>0
            
$data['CTR'] = number_format(round(($data['hits']/$data['views']),2), 2'.''');
        else
            
$data['CTR'] = "0,00";

        
$days=array();
        for(
$i=1;$i<=31;$i++) $days[$i] = $i;

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


        if (isset(
$_POST['update_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']);
            
$data['active']            = trim($_POST['active']);

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


            if ( !
$errors ) {

                
$expire mktime(0,0,0,$data['month'],$data['day'],$data['year']);
                
$data['expire'] = $expire;
                
$title mysql_real_escape_string($data['title']);
                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='';
                
$description mysql_real_escape_string($data['description']);
                
$duration $data['duration'];
                
$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 "UPDATE nuevo__midroll SET owner = '$owner', email = '$email', duration = '$duration', title = '$title', description = '$description',url = '$url', link = '$link', target = '$target', expire = '$expire', image = '$image', active = '$active' WHERE ID ='".$id."'";

                
$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::Midroll ad edit';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        if(isset(
$data))    $tpl->ad $data;
        
$tpl->days            $days;
        
$tpl->years            $years;
        
$tpl->pmenu            'midroll';

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