Пример #1
0
 // Get post data
 $array['x1'] = $nv_Request->get_int('x1', 'post', 0);
 $array['y1'] = $nv_Request->get_int('y1', 'post', 0);
 $array['x2'] = $nv_Request->get_int('x2', 'post', 0);
 $array['y2'] = $nv_Request->get_int('y2', 'post', 0);
 $array['w'] = $nv_Request->get_int('w', 'post', 0);
 $array['h'] = $nv_Request->get_int('h', 'post', 0);
 // Caculate crop size
 $array['avatar_width'] = intval($array['x2'] - $array['x1']);
 $array['avatar_height'] = intval($array['y2'] - $array['y1']);
 if (sizeof(array_filter(array($array['x1'], $array['y1'], $array['x2'], $array['y2'], $array['w'], $array['h']))) < 4 or $array['avatar_width'] < $global_config['avatar_width'] or $array['avatar_height'] < $global_config['avatar_height']) {
     $array['error'] = $lang_module['avatar_error_data'];
 } else {
     $upload = new NukeViet\Files\Upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     // Storage in temp dir
     $upload_info = $upload->save_file($_FILES['image_file'], NV_ROOTDIR . '/' . NV_TEMP_DIR, false);
     // Delete upload tmp
     @unlink($_FILES['image_file']['tmp_name']);
     if (empty($upload_info['error'])) {
         $basename = $upload_info['basename'];
         $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . nv_genpass(8) . "_" . $user_info['userid'] . '\\2', $basename);
         $image = new NukeViet\Files\Image($upload_info['name'], NV_MAX_WIDTH, NV_MAX_HEIGHT);
         // Resize image, crop image
         $image->resizeXY($array['w'], $array['h']);
         $image->cropFromLeft($array['x1'], $array['y1'], $array['avatar_width'], $array['avatar_height']);
         $image->resizeXY($global_config['avatar_width'], $global_config['avatar_height']);
         // Save new image
         $image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
         $image->close();
         if (file_exists($image->create_Image_info['src'])) {
             $array['filename'] = str_replace(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/', '', $image->create_Image_info['src']);
Пример #2
0
} elseif (!isset($_FILES) and !nv_is_url($nv_Request->get_string('fileurl', 'post,get'))) {
    $error = $lang_module['uploadError2'];
} else {
    $type = $nv_Request->get_string('type', 'post,get');
    if ($type == 'image' and in_array('images', $admin_info['allow_files_type'])) {
        $allow_files_type = array('images');
    } elseif ($type == 'flash' and in_array('flash', $admin_info['allow_files_type'])) {
        $allow_files_type = array('flash');
    } elseif (empty($type)) {
        $allow_files_type = $admin_info['allow_files_type'];
    } else {
        $allow_files_type = array();
    }
    $upload = new NukeViet\Files\Upload($allow_files_type, $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
    if (isset($_FILES['upload']['tmp_name']) and is_uploaded_file($_FILES['upload']['tmp_name'])) {
        $upload_info = $upload->save_file($_FILES['upload'], NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']);
    } else {
        $urlfile = rawurldecode(trim($nv_Request->get_string('fileurl', 'post')));
        $upload_info = $upload->save_urlfile($urlfile, NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']);
    }
    if (!empty($upload_info['error'])) {
        $error = $upload_info['error'];
    } elseif (preg_match('#image\\/[x\\-]*([a-z]+)#', $upload_info['mime'])) {
        if (isset($array_thumb_config[$path])) {
            $thumb_config = $array_thumb_config[$path];
        } else {
            $thumb_config = $array_thumb_config[''];
            $_arr_path = explode('/', $path);
            while (sizeof($_arr_path) > 1) {
                array_pop($_arr_path);
                $_path = implode('/', $_arr_path);
Пример #3
0
         } else {
             $is_error = true;
             $error = $upload_info['error'];
         }
         unset($upload, $upload_info);
     }
 }
 if (!$is_error) {
     if (empty($fileupload) and empty($array['linkdirect'])) {
         $is_error = true;
         $error = $lang_module['file_error_fileupload'];
     } else {
         $fileimage = '';
         if (isset($_FILES['upload_fileimage']) and is_uploaded_file($_FILES['upload_fileimage']['tmp_name'])) {
             $upload = new NukeViet\Files\Upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
             $upload_info = $upload->save_file($_FILES['upload_fileimage'], NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/temp', false);
             @unlink($_FILES['upload_fileimage']['tmp_name']);
             if (empty($upload_info['error'])) {
                 mt_srand((double) microtime() * 1000000);
                 $maxran = 1000000;
                 $random_num = mt_rand(0, $maxran);
                 $random_num = md5($random_num);
                 $nv_pathinfo_filename = nv_pathinfo_filename($upload_info['name']);
                 $new_name = NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/temp/' . $nv_pathinfo_filename . '.' . $random_num . '.' . $upload_info['ext'];
                 $rename = nv_renamefile($upload_info['name'], $new_name);
                 if ($rename[0] == 1) {
                     $fileimage = $new_name;
                 } else {
                     $fileimage = $upload_info['name'];
                 }
                 @chmod($fileimage, 0644);
Пример #4
0
     } else {
         @chmod($upload_info['name'], 0644);
         if (!empty($file_name) and is_file(NV_ROOTDIR . '/' . $file_name)) {
             @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $file_name);
         }
         $file_name = $upload_info['basename'];
         $file_ext = $upload_info['ext'];
         $file_mime = $upload_info['mime'];
         $width = $upload_info['img_info'][0];
         $height = $upload_info['img_info'][1];
     }
 }
 if ($file_ext == 'swf') {
     if (isset($_FILES['imageforswf']) and is_uploaded_file($_FILES['imageforswf']['tmp_name'])) {
         $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
         $upload_info = $upload->save_file($_FILES['imageforswf'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false);
         @unlink($_FILES['imageforswf']['tmp_name']);
         if (!empty($upload_info['error'])) {
             $error = $upload_info['error'];
         } else {
             @chmod($upload_info['name'], 0644);
             if (!empty($imageforswf) and is_file(NV_ROOTDIR . '/' . $imageforswf)) {
                 @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $imageforswf);
             }
             $imageforswf = $upload_info['basename'];
         }
     }
 } else {
     if (!empty($imageforswf) and is_file(NV_ROOTDIR . '/' . $imageforswf)) {
         @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR . '/' . $imageforswf);
     }
Пример #5
0
     $clid = 0;
 }
 if ($click_url == 'http://') {
     $click_url = '';
 }
 if (empty($title)) {
     $error = $lang_module['title_empty'];
 } elseif (empty($pid) or !isset($plans[$pid])) {
     $error = $lang_module['plan_not_selected'];
 } elseif (!empty($click_url) and !nv_is_url($click_url)) {
     $error = $lang_module['click_url_invalid'];
 } elseif (!is_uploaded_file($_FILES['banner']['tmp_name'])) {
     $error = $lang_module['file_upload_empty'];
 } else {
     $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false);
     @unlink($_FILES['banner']['tmp_name']);
     if (!empty($upload_info['error'])) {
         $error = $upload_info['error'];
     } else {
         @chmod($upload_info['name'], 0644);
         $file_name = $upload_info['basename'];
         $file_ext = $upload_info['ext'];
         $file_mime = $upload_info['mime'];
         $width = $upload_info['img_info'][0];
         $height = $upload_info['img_info'][1];
         if (empty($publ_date)) {
             $publtime = NV_CURRENTTIME;
         } else {
             unset($m);
             preg_match('/^([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})$/', $publ_date, $m);