Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/pornstar/components/edit.php
Строк: 131
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_pornstar_edit
{
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        
$db            VF::factory('database');
        
$pcfg        VF::cfg('module.pornstar');
        
        
$unique        mt_rand().'_'.time();
        
$errors        = array();
        
$messages    = array();
        
$pornstar    = array();
        
$id            = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
        
$db->query("SELECT ext FROM #__model WHERE model_id = ".$id." LIMIT 1");
        if (
$db->affected_rows()) {
            
$ext $db->fetch_field('ext');
            if (isset(
$_POST['submit_pornstar_edit'])) {
                
$filter            VF::factory('filter');
                
$unique            $filter->get('unique');
                
$name            $filter->get('name');
                
$slug            $filter->get('slug');
                
$description    trim($_POST['description']);
                
$gender            $filter->get('gender');
                
$birth_year        = (int) trim($_POST['Date_year']);
                
$birth_month    = (int) trim($_POST['Date_month']);
                
$birth_day        = (int) trim($_POST['Date_day']);
                
$birth_location    $filter->get('birth_location');
                
$birth_name        $filter->get('birth_name');
                
$aliases        $filter->get('aliases');
                
$eye_color        $filter->get('eye_color');
                
$hair_color        $filter->get('hair_color');
                
$weight            $filter->get('weight');
                
$height            $filter->get('height');
                
$measurements    $filter->get('measurements');
                
$natural_bust    $filter->get('natural_bust');
                
$ethnicity        $filter->get('ethnicity');
                
$nationality    $filter->get('nationality');
                
$performs        $filter->get('performs');
                
$links            trim($_POST['links']);
                
$file_path        $filter->get('file_path');
                
$url            trim($_POST['url']);
            
                if (
$name == '') {
                    
$errors[]    = 'Pornstar name field cannot be left blank!';
                }
            
                if (
$slug == '') {
                    
$errors[]    = 'Pornstar SLUG field cannot be left blank!';
                } elseif (!
VValid::slug($slug)) {
                    
$errors[]    = 'Pornstar SLUG can contain only lowertype letters and dashes!';
                } else {
                    
$db->query("SELECT model_id
                                  FROM #__model
                                  WHERE slug = '"
.$db->escape($slug)."'
                                  AND model_id != "
.$id."
                                  LIMIT 1"
);
                    if (
$db->affected_rows()) {
                        
$errors[]    = 'Pornstar SLUG is already used for another pornstar entry!';
                    }
                }
            
                if (
$gender != '') {
                    if (!
in_array($gender, array('female''male''tranny'))) {
                        
$errors[] = 'Invalid pornstar gender! What exactly did you select!?';
                    }
                }

                  if (
$birth_day !== OR $birth_month !== OR $birth_year !== 0) {
                      if (
$birth_day === OR $birth_month === OR $birth_year === 0) {
                          
$errors[] = 'Please enter pornstar complete birth date!';
                      } else {
                          if (!
checkdate($birth_month$birth_day$birth_year)) {
                              
$errors[] = 'Birth date is not a valid date!';
                          } else {
                              
$birth_date $birth_year.'-'.sprintf('%02d'$birth_month).'-'.sprintf('%02d'$birth_day);
                          }
                      }
                  } else {
                      
$birth_date '0000-00-00';
                  }
            
                  if (
$file_path != '') {
                      if (!
file_exists($file_path) OR !is_file($file_path)) {
                          
$errors[] = 'Invalid pornstar photo path!';
                      } else {
                          
$ext    VFile::ext($file_path);
                      }
                  }
            
                  if (!
$errors) {
                      
$db->query("UPDATE #__model
                                    SET name = '"
.$db->escape($name)."',
                                        slug = '"
.$db->escape($slug)."',
                                        description = '"
.$db->escape($description)."',
                                        gender = '"
.$db->escape($gender)."',
                                        ext = '"
.$db->escape($ext)."',
                                        add_date = '"
.date('Y-m-d h:i:s')."',
                                        status = '1'
                                    WHERE model_id = "
.$id."
                                    LIMIT 1"
);
                      
$db->query("UPDATE #__model_bio
                                  SET birth_date = '"
.$db->escape($birth_date)."',
                                      birth_location = '"
.$db->escape($birth_location)."',
                                      birth_name = '"
.$db->escape($birth_name)."',
                                      aliases = '"
.$db->escape($aliases)."',
                                      eye_color = '"
.$db->escape($eye_color)."',
                                      hair_color = '"
.$db->escape($hair_color)."',
                                      weight = '"
.$db->escape($weight)."',
                                      height = '"
.$db->escape($height)."',
                                      measurements = '"
.$db->escape($measurements)."',
                                      natural_bust = '"
.$db->escape($natural_bust)."',
                                      ethnicity = '"
.$db->escape($ethnicity)."',
                                      nationality = '"
.$db->escape($nationality)."',
                                      performs = '"
.$db->escape($performs)."',
                                      links = '"
.$db->escape($links)."',
                                      url = '"
.$db->escape($url)."'
                                  WHERE model_id = "
.$id."
                                  LIMIT 1"
);
                      if (
$file_path != '') {
                          
$image VF::factory('image');
                          if (
$image->load($file_path)) {
                              
$dst MEDIA_DIR.'/pornstars/'.$id.'.'.$ext;
                              if (isset(
$_POST['photo'])) {
                                  
$x          = (int) $_POST['x'];
                                  
$y          = (int) $_POST['y'];
                                  
$x2         = (int) $_POST['x2'];
                                  
$y2         = (int) $_POST['y2'];
                                  
$w          = (int) $_POST['w'];
                                  
$h          = (int) $_POST['h'];
                                  if (!
$image->crop($x$y$w$h$dst)) {
                                      
$errors[] = $image->get_error();
                                  }                                                                                                                       
                              } else {
                                  
$dst_tmp TMP_DIR.'/uploads/model_'.$id.'.'.$ext;
                                  if (
$image->canvas($pcfg['photo_width'], $pcfg['photo_height'], '000000') &&
                                        
$image->resize($pcfg['photo_width'], $pcfg['photo_height'], 'ASPECT_RATIO'$dst_tmp)) {
                                        
$image->clear();
                                        if (
$image->load($dst_tmp)) {
                                            if (!
$image->crop_from_center($pcfg['photo_width'], $pcfg['photo_height'], $dst)) {
                                                
$errors[] = $image->get_error();
                                            }
                                        } else {
                                            
$errors[] = $image->get_error();
                                        }
                                  } else {
                                      
$errors[] = $image->get_error();
                                  }
                              }
                          } else {
                              
$errors[] = $image->get_error();
                          }
                      }
                      
                      if (!
$errors) {
                          
VFile::delete($file_path);
                          
$messages[] = 'Pornstar updated!';
                      }
                  }
            }
            
            
$db->query("SELECT m.*, mb.*
                        FROM #__model AS m
                        LEFT JOIN #__model_bio AS mb ON (m.model_id = mb.model_id)
                        WHERE m.model_id = "
.$id."
                        LIMIT 1"
);
            
$pornstar $db->fetch_assoc();
        }
    
        
$tpl VF::factory('template');
        
$tpl->menu            'pornstar';
        
$tpl->submenu        'pornstar_manage';
        
$tpl->meta_title    'Admin::Pornstar::Edit';
        
$tpl->css            = array(TPL_REL.'/css/jquery.Jcrop.css');
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->pcfg            $pcfg;
        
$tpl->unique        $unique;
        
$tpl->pornstar        $pornstar;
        
$tpl->load(array('header''pornstar_edit''footer'));
        
$tpl->display();
    }
}
Онлайн: 0
Реклама