function filter_images($folder, $linkanh)
{
    global $global_config, $module;
    if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder)) {
        nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module, $folder);
    }
    $path = NV_UPLOADS_DIR . "/" . $module . "/" . $folder . "";
    require_once NV_ROOTDIR . "/includes/class/upload.class.php";
    $upload = new 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_urlfile($linkanh, NV_ROOTDIR . '/' . $path, false);
    $home_file = $folder . "/" . $upload_info['basename'];
    sleep(1);
    return $home_file;
}
Exemple #2
0
if (!isset($check_allow_upload_dir['upload_file'])) {
    die("ERROR_" . $lang_module['notlevel']);
}
if (!isset($_FILES, $_FILES['fileupload'], $_FILES['fileupload']['tmp_name']) and !$nv_Request->isset_request('fileurl', 'post')) {
    die("ERROR_" . $lang_module['uploadError1']);
}
if (!isset($_FILES) and !nv_is_url($nv_Request->get_string('fileurl', 'post'))) {
    die("ERROR_" . $lang_module['uploadError2']);
}
require_once NV_ROOTDIR . "/includes/class/upload.class.php";
$upload = new upload($admin_info['allow_files_type'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
if (isset($_FILES['fileupload']['tmp_name']) and is_uploaded_file($_FILES['fileupload']['tmp_name'])) {
    $upload_info = $upload->save_file($_FILES['fileupload'], NV_ROOTDIR . '/' . $path, false);
} else {
    $urlfile = trim($nv_Request->get_string('fileurl', 'post'));
    $upload_info = $upload->save_urlfile($urlfile, NV_ROOTDIR . '/' . $path, false);
}
if (!empty($upload_info['error'])) {
    die("ERROR_" . $upload_info['error']);
}
if ($upload_info['is_img']) {
    $autologomod = explode(',', $global_config['autologomod']);
    $dir = str_replace("\\", "/", $path);
    $dir = rtrim($dir, "/");
    $arr_dir = explode("/", $dir);
    if ($global_config['autologomod'] == 'all' or $arr_dir[0] == NV_UPLOADS_DIR and isset($arr_dir[1]) and in_array($arr_dir[1], $autologomod)) {
        $upload_logo = '';
        if (file_exists(NV_ROOTDIR . '/' . $global_config['upload_logo'])) {
            $upload_logo = $global_config['upload_logo'];
        } elseif (file_exists(NV_ROOTDIR . '/' . $global_config['site_logo'])) {
            $upload_logo = $global_config['site_logo'];
Exemple #3
0
        $thumbpath = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name . '/' . $type . '/' . $data[$typeid]['imgfolder'] . '/thumbs/';
        if (!file_exists($thumbpath . '/' . $upload_info['basename'])) {
            $imgdata['thumbpath'] = createthumb($imgpath, $thumbpath, '', 180, 180);
        }
        $src = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $type . '/' . $data[$typeid]['imgfolder'] . '/' . $upload_info['basename'];
        $lu = strlen('.' . $upload_info['ext']);
        $alias = substr($upload_info['basename'], 0, -$lu);
        $alias = np_get_alias('photos', 0, $alias);
        $imgdata['pid'] = 'NULL';
        $imgdata['filename'] = $upload_info['basename'];
        $imgdata['filetype'] = $upload_info['mime'];
        $imgdata['filepath'] = $type . '/' . $data[$typeid]['imgfolder'];
        $imgdata[$main] = intval($typeid);
        $imgdata[$second] = 0;
        $imgdata['alias'] = $imgdata['title'] = $alias;
        $imgdata['img_size'] = $upload_info['img_info'][0] . '-' . $upload_info['img_info'][1];
        $pid = $np->addItem('photos', $imgdata);
        if ($type == 'category' and $pid > 0) {
            $imgdata['pid'] = $pid;
            $np->addItem($typeid, $imgdata);
        }
    }
} else {
    $urlfile = trim($nv_Request->get_string('fileurl', 'post'));
    $upload_info = $upload->save_urlfile($urlfile, NV_ROOTDIR . '/' . NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name, false);
}
if (!empty($upload_info['error'])) {
    die("nperror*" . $upload_info['error'] . "*");
} else {
    die("success*Upload thành công*" . $pid . "*" . $src);
}
Exemple #4
0
 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();
 }
 require_once NV_ROOTDIR . '/includes/class/upload.class.php';
 $upload = new 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 ($global_config['nv_auto_resize'] and ($upload_info['img_info'][0] > NV_MAX_WIDTH or $upload_info['img_info'][0] > NV_MAX_HEIGHT)) {
         require_once NV_ROOTDIR . '/includes/class/image.class.php';
         $createImage = new image(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename'], $upload_info['img_info'][0], $upload_info['img_info'][1]);
         $createImage->resizeXY(NV_MAX_WIDTH, NV_MAX_HEIGHT);
         $createImage->save(NV_ROOTDIR . '/' . $path, $upload_info['basename'], 90);
         $createImage->close();
         $info = $createImage->create_Image_info;
         $upload_info['img_info'][0] = $info['width'];
         $upload_info['img_info'][1] = $info['height'];
         $upload_info['size'] = filesize(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename']);
     }