Ejemplo n.º 1
0
/**
 * nv_getFileInfo()
 *
 * @param mixed $pathimg
 * @param mixed $file
 * @return
 */
function nv_getFileInfo($pathimg, $file)
{
    global $array_images, $array_flash, $array_archives, $array_documents;
    clearstatcache();
    unset($matches);
    preg_match("/([a-zA-Z0-9\\.\\-\\_\\s\\(\\)]+)\\.([a-zA-Z0-9]+)\$/", $file, $matches);
    $info = array();
    $info[0] = $file;
    if (isset($file[17])) {
        $info[0] = substr($matches[1], 0, 13 - strlen($matches[2])) . "..." . $matches[2];
    }
    $info[1] = $matches[2];
    $info[2] = "file";
    $stat = @stat(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
    $info[3] = $stat['size'];
    $info[4] = 'images/file.gif';
    $info[5] = 32;
    $info[6] = 32;
    $info[7] = "|";
    $ext = strtolower($matches[2]);
    if (in_array($ext, $array_images)) {
        $size = @getimagesize(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
        $info[2] = "image";
        $info[4] = $pathimg . '/' . $file;
        $info[5] = $size[0];
        $info[6] = $size[1];
        $info[7] = $size[0] . "|" . $size[1];
        if ($size[0] > 80 or $size[1] > 80) {
            if (($_src = nv_get_viewImage($pathimg . '/' . $file, 80, 80)) !== false) {
                $info[4] = $_src[0];
                $info[5] = $_src[1];
                $info[6] = $_src[2];
            } else {
                if ($info[5] > 80) {
                    $info[6] = round(80 / $info[5] * $info[6]);
                    $info[5] = 80;
                }
                if ($info[6] > 80) {
                    $info[5] = round(80 / $info[6] * $info[5]);
                    $info[6] = 80;
                }
            }
        }
    } elseif (in_array($ext, $array_flash)) {
        $info[2] = "flash";
        $info[4] = 'images/flash.gif';
        if ($matches[2] == "swf") {
            $size = @getimagesize(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
            if (isset($size, $size[0], $size[1])) {
                $info[7] = $size[0] . "|" . $size[1];
            }
        }
    } elseif (in_array($ext, $array_archives)) {
        $info[4] = 'images/zip.gif';
    } elseif (in_array($ext, $array_documents)) {
        $info[4] = 'images/doc.gif';
    }
    $info[8] = 0;
    $info[9] = $stat['mtime'];
    return $info;
}
Ejemplo n.º 2
0
     }
 } elseif (nv_is_url($item['homeimgfile'])) {
     $homeimgthumb = 3;
 } elseif ($item['homeimgfile'] != '' and file_exists(NV_UPLOADS_REAL_DIR . '/' . $mod_name . '/' . $item['homeimgfile'])) {
     $homeimgthumb = 2;
     $imagesize = getimagesize(NV_UPLOADS_REAL_DIR . '/' . $mod_name . '/' . $item['homeimgfile']);
     if (!empty($imagesize)) {
         $ext1 = strtolower(array_pop(explode('.', $item['homeimgfile'])));
         $ext2 = $typeflag[$imagesize[2]];
         if ($ext1 != $ext2) {
             $homeimgfile = preg_replace("/." . $ext1 . "\$/", '.' . $ext2, $item['homeimgfile']);
             rename(NV_UPLOADS_REAL_DIR . '/' . $mod_name . '/' . $item['homeimgfile'], NV_UPLOADS_REAL_DIR . '/' . $mod_name . '/' . $homeimgfile);
             $item['homeimgfile'] = $homeimgfile;
         }
     }
     $arrimg = nv_get_viewImage(NV_UPLOADS_DIR . '/' . $mod_name . '/' . $item['homeimgfile']);
     if (!empty($arrimg)) {
         $homeimgthumb = 1;
     }
 } else {
     $item['homeimgfile'] = '';
 }
 $item['homeimgthumb'] = $homeimgthumb;
 $stmt = $db->prepare("INSERT INTO " . NV_PREFIXLANG . "_" . $mod_data . "_rows\n\t\t\t\t(id, catid, listcatid, topicid, admin_id, author, sourceid, addtime, edittime, status, publtime, exptime, archive, title, alias, hometext, homeimgfile, homeimgalt, homeimgthumb, inhome, allowed_comm, allowed_rating, hitstotal, hitscm, total_rating, click_rating) VALUES\n\t\t\t\t(:id,:catid,:listcatid,:topicid,:admin_id,:author,:sourceid,:addtime,:edittime,:status,:publtime,:exptime,:archive,:title,:alias,:hometext,:homeimgfile,:homeimgalt,:homeimgthumb,:inhome,:allowed_comm,:allowed_rating,:hitstotal,:hitscm,:total_rating,:click_rating)");
 $stmt->bindParam(':id', $item['id'], PDO::PARAM_INT);
 $stmt->bindParam(':catid', $item['catid'], PDO::PARAM_INT);
 $stmt->bindParam(':listcatid', $item['listcatid'], PDO::PARAM_STR);
 $stmt->bindParam(':topicid', $item['topicid'], PDO::PARAM_INT);
 $stmt->bindParam(':admin_id', $item['admin_id'], PDO::PARAM_INT);
 $stmt->bindParam(':author', $item['author'], PDO::PARAM_STR);
 $stmt->bindParam(':sourceid', $item['sourceid'], PDO::PARAM_INT);
Ejemplo n.º 3
0
/**
 * nv_getFileInfo()
 *
 * @param mixed $pathimg
 * @param mixed $file
 * @return
 */
function nv_getFileInfo($pathimg, $file)
{
    global $array_images, $array_flash, $array_archives, $array_documents;
    clearstatcache();
    unset($matches);
    preg_match("/([a-zA-Z0-9\\.\\-\\_\\s\\(\\)]+)\\.([a-zA-Z0-9]+)\$/", $file, $matches);
    $info = array();
    $info['name'] = $file;
    if (isset($file[17])) {
        $info['name'] = substr($matches[1], 0, 13 - strlen($matches[2])) . '...' . $matches[2];
    }
    $info['ext'] = $matches[2];
    $info['type'] = 'file';
    $stat = @stat(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
    $info['filesize'] = $stat['size'];
    $info['src'] = NV_ASSETS_DIR . '/images/file.gif';
    $info['srcwidth'] = 32;
    $info['srcheight'] = 32;
    $info['size'] = '|';
    $ext = strtolower($matches[2]);
    if (in_array($ext, $array_images)) {
        $size = @getimagesize(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
        $info['type'] = 'image';
        $info['src'] = $pathimg . '/' . $file;
        $info['srcwidth'] = intval($size[0]);
        $info['srcheight'] = intval($size[1]);
        $info['size'] = intval($size[0]) . '|' . intval($size[1]);
        if (preg_match('/^' . nv_preg_quote(NV_UPLOADS_DIR) . '\\/([a-z0-9\\-\\_\\.\\/]+)$/i', $pathimg . '/' . $file, $m)) {
            if (($thub_src = nv_get_viewImage($pathimg . '/' . $file)) !== false) {
                $info['src'] = $thub_src[0];
                $info['srcwidth'] = $thub_src[1];
                $info['srcheight'] = $thub_src[2];
            }
        }
        if ($info['srcwidth'] > 80) {
            $info['srcheight'] = round(80 / $info['srcwidth'] * $info['srcheight']);
            $info['srcwidth'] = 80;
        }
        if ($info['srcheight'] > 80) {
            $info['srcwidth'] = round(80 / $info['srcheight'] * $info['srcwidth']);
            $info['srcheight'] = 80;
        }
    } elseif (in_array($ext, $array_flash)) {
        $info['type'] = 'flash';
        $info['src'] = NV_ASSETS_DIR . '/images/flash.gif';
        if ($matches[2] == 'swf') {
            $size = @getimagesize(NV_ROOTDIR . '/' . $pathimg . '/' . $file);
            if (isset($size, $size[0], $size[1])) {
                $info['size'] = $size[0] . '|' . $size[1];
            }
        }
    } elseif (in_array($ext, $array_archives)) {
        $info['src'] = NV_ASSETS_DIR . '/images/zip.gif';
    } elseif (in_array($ext, $array_documents)) {
        if ($ext == 'doc' or $ext == 'docx') {
            $info['src'] = NV_ASSETS_DIR . '/images/msword.png';
        } elseif ($ext == 'xls' or $ext == 'xlsx') {
            $info['src'] = NV_ASSETS_DIR . '/images/excel.png';
        } elseif ($ext == 'pdf') {
            $info['src'] = NV_ASSETS_DIR . '/images/pdf.png';
        } else {
            $info['src'] = NV_ASSETS_DIR . '/images/doc.gif';
        }
    }
    $info['userid'] = 0;
    $info['mtime'] = $stat['mtime'];
    return $info;
}