Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/templates/default/extend/ajax/pornstar.plugin.php
Строк: 25
<?php
defined
('_VALID') or die('Restricted Access!');
function 
ajax_plugin_pornstar()
{
    
$data = array('status' => 0'msg' => '''code' => '''debug' => '''width' => 0'height' => 0'ext' => '');
    if (isset(
$_POST['unique']) && isset($_FILES['userfile'])) {
        
$pcfg         VF::cfg('module.pornstar');
        
$unique        VF::factory('filter')->get('unique');
        if (
$avatar VUpload::process('userfile'$pcfg['photo_max_size'], $pcfg['photo_allowed_ext'])) {
            
$photo        $unique.'.'.$avatar['ext'];
            
$dst        TMP_DIR.'/uploads/'.$photo;
            
$dst_width  $pcfg['photo_width'];
            
$dst_height $pcfg['photo_height'];
            
            if (
move_uploaded_file($avatar['path'], $dst)) {
                  
$image        VF::factory('image');
                  if (!
$image->load($dst)) {
                      
$data['msg'] = $image->get_error();
                  } else {
                      
$size        getimagesize($dst);
                      
$width        $size['0'];
                      
$height        $size['1'];
                      if (
$pcfg['photo_method'] == 'crop' OR ($width $dst_width OR $height $dst_height)) {
                          
$r_width    $dst_width*2;
                          
$r_height    $dst_height*2;
                          
$dst_tmp    TMP_DIR.'/uploads/'.$unique.'_resized.'.$avatar['ext'];
                          if (
$width $r_width OR $height $r_height) {
                              if (!
$image->resize($r_width$r_height'TO_ASPECT_RATIO'$dst_tmp)) {
                                  
$data['msg'] = $image->get_error();
                              }
                          } else {
                              
copy($dst$dst_tmp);
                          }
                          
                          if (
$data['msg'] == '') {
                              
$data['width']    = $dst_width;
                              
$data['height']    = $dst_height;
                              
$data['code']    = TMP_URL.'/uploads/'.$unique.'_resized.'.$avatar['ext'].'?'.rand(1,100);
                              
$data['ext']    = $dst_tmp;
                              
$data['msg']    = 'Pornstar photo uploaded! Please crop below!';
                              
$data['status']    = 1;
                          }
                      } else {
                          
$data['status']    = 2;
                          
$data['ext']     = $dst;
                          
$data['msg']    = 'Pornstar photo uploaded! Will be resized once current pornstar is added!';
                      }
                  }
            } else {
                
$data['msg'] = 'Failed to move uploaded file! Invalid permissions!?';
            }
        } else {
              
$error          VUpload::error();
              
$data['msg'] = $error['0'];
        }
    } else {
        
$data['msg'] = 'Invalid ajax request!';
    }
    
    return 
json_encode($data);
}
Онлайн: 1
Реклама