Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/photo_edit.php
Строк: 71
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_photo_photo_edit extends VModule_Admin_photo
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$photo         = array();
        
$photo_id    = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
$errors        = array();
        
$messages    = array();
        
$warnings    = array();
        
        
$this->db->query("SELECT photo_id FROM #__photo WHERE photo_id = ".$photo_id." LIMIT 1");
        if (
$this->db->affected_rows()) {
            if (isset(
$_POST['submit-edit'])) {
                
$filter                VF::factory('filter');
                
$caption            $filter->get('caption');
                
$allow_rating        = (int) trim($_POST['allow_rating']);
                
$allow_comment        = (int) trim($_POST['allow_comment']);
                
$status                = (int) trim($_POST['status']);
                
$flagged            = (int) trim($_POST['flagged']);
                
$rating                = (float) trim($_POST['rating']);
                
$rated_by            = (int) trim($_POST['rated_by']);
                
$total_views        = (int) trim($_POST['total_views']);
                
$total_comments        = (int) trim($_POST['total_comments']);
                
$total_favorites    = (int) trim($_POST['total_favorites']);
                
$ext                $filter->get('ext');
                
$add_date            $filter->get('add_date');
                
                if (!
in_array($ext, array('jpg''png''gif'))) {
                    
$errors[]     = 'Invalid photo extension! Allowed extensions: jpg, png and gif!';
                }
                
                if (!
strtotime($add_date) OR strlen($add_date) !== 19) {
                    
$errors[]    = 'Invalid add date entry! Allowed format: yyyy-mm-dd hh::mm:ss!';
                }
                
                if (!
$errors) {
                    
$this->db->query("UPDATE #__photo
                                      SET caption = '"
.$this->db->escape($caption)."',
                                          allow_rating = '"
.$allow_rating."',
                                          allow_comment = '"
.$allow_comment."',
                                          status = '"
.$status."',
                                          flagged = '"
.$flagged."',
                                          rating = "
.$rating.",
                                          rated_by = "
.$rated_by.",
                                          total_views = "
.$total_views.",
                                          total_comments = "
.$total_comments.",
                                          total_favorites = "
.$total_favorites.",
                                          ext = '"
.$this->db->escape($ext)."',
                                          add_date = '"
.$this->db->escape($add_date)."'
                                      WHERE photo_id = "
.$photo_id."
                                      LIMIT 1"
);
                    
$messages[] = 'Photo updated!';
                }
            }
            
            
$this->db->query("SELECT photo_id, caption, ext, total_views, total_favorites, total_comments,
                                     rating, rated_by, status, size, allow_comment, allow_rating, add_date,
                                     flagged
                              FROM #__photo
                              WHERE photo_id = "
.$photo_id."
                              LIMIT 1"
);
            
$photo $this->db->fetch_assoc();
        }
        
        
$tpl VF::factory('template');
        
$tpl->menu            'photo';
        
$tpl->submenu        'photo_manage';
        
$tpl->meta_title    'Admin::Photo::Edit';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->warnings        $warnings;
        
$tpl->photo            $photo;
        
$tpl->load(array('header''photo_edit''footer'));
        
$tpl->display();
    }
}
Онлайн: 3
Реклама