예제 #1
0
 /**
  * get the file name on the server
  * @return string
  */
 function getServerFilename()
 {
     global $USE_MEDIA_FIREWALL;
     if ($this->serverfilename) {
         return $this->serverfilename;
     }
     $localfilename = $this->getLocalFilename();
     if (!empty($localfilename)) {
         if (file_exists($localfilename)) {
             // found image in unprotected directory
             $this->fileexists = 2;
             $this->serverfilename = $localfilename;
             return $this->serverfilename;
         }
         if ($USE_MEDIA_FIREWALL) {
             $protectedfilename = get_media_firewall_path($localfilename);
             if (file_exists($protectedfilename)) {
                 // found image in protected directory
                 $this->fileexists = 3;
                 $this->serverfilename = $protectedfilename;
                 return $this->serverfilename;
             }
         }
     }
     // file doesn't exist, return the standard localfilename for backwards compatibility
     $this->fileexists = false;
     $this->serverfilename = $localfilename;
     return $this->serverfilename;
 }
예제 #2
0
     print "</b></span><br />";
     $finalResult = false;
 } else {
     if (!$isExternal) {
         $oldMainFile = $oldFolder . $oldFilename;
         $newMainFile = $folder . $filename;
         $oldThumFile = str_replace($MEDIA_DIRECTORY, $MEDIA_DIRECTORY . "thumbs/", $oldMainFile);
         $newThumFile = str_replace($MEDIA_DIRECTORY, $MEDIA_DIRECTORY . "thumbs/", $newMainFile);
         if (media_exists($oldMainFile) == 3) {
             // the file is in the media firewall directory
             $oldMainFile = get_media_firewall_path($oldMainFile);
             $newMainFile = get_media_firewall_path($newMainFile);
         }
         if (media_exists($oldThumFile) == 3) {
             $oldThumFile = get_media_firewall_path($oldThumFile);
             $newThumFile = get_media_firewall_path($newThumFile);
         }
         $isMain = file_exists(filename_decode($oldMainFile));
         $okMain = !file_exists(filename_decode($newMainFile));
         $isThum = file_exists(filename_decode($oldThumFile));
         $okThum = !file_exists(filename_decode($newThumFile));
         if ($okMain && $okThum) {
             // make sure the directories exist before moving the files
             mkdirs(dirname($newMainFile) . "/");
             mkdirs(dirname($newThumFile) . "/");
             if ($isMain) {
                 $okMain = @rename(filename_decode($oldMainFile), filename_decode($newMainFile));
             }
             if ($isThum) {
                 $okThum = @rename(filename_decode($oldThumFile), filename_decode($newThumFile));
             }
예제 #3
0
function mediaFileInfo($fileName, $thumbName, $mid, $name = '', $notes = '', $obeyViewerOption = true)
{
    global $THUMBNAIL_WIDTH, $PGV_IMAGE_DIR, $PGV_IMAGES;
    global $LB_URL_WIDTH, $LB_URL_HEIGHT;
    global $SERVER_URL, $GEDCOM, $USE_MEDIA_VIEWER, $USE_MEDIA_FIREWALL, $MEDIA_FIREWALL_THUMBS;
    $result = array();
    // -- Classify the incoming media file
    if (eregi("^https?://", $fileName)) {
        $type = "url_";
    } else {
        $type = "local_";
    }
    if ((eregi("\\.flv\$", $fileName) || eregi("^https?://.*\\.youtube\\..*/watch\\?", $fileName)) && is_dir('modules/JWplayer')) {
        $type .= "flv";
    } else {
        if (eregi("^https?://picasaweb*\\.google\\..*/.*/", $fileName)) {
            $type .= "picasa";
        } else {
            if (eregi("\\.(jpg|jpeg|gif|png)\$", $fileName)) {
                $type .= "image";
            } else {
                if (eregi("\\.(pdf|avi|txt)\$", $fileName)) {
                    $type .= "page";
                } else {
                    if (eregi("\\.mp3\$", $fileName)) {
                        $type .= "audio";
                    } else {
                        if (eregi("\\.wmv\$", $fileName)) {
                            $type .= "wmv";
                        } else {
                            $type .= "other";
                        }
                    }
                }
            }
        }
    }
    // $type is now: (url | local) _ (flv | picasa | image | page | audio | other)
    $result['type'] = $type;
    // -- Determine the correct URL to open this media file
    while (true) {
        if (file_exists("modules/lightbox/album.php")) {
            // Lightbox is installed
            include_once 'modules/lightbox/lb_defaultconfig.php';
            if (file_exists('modules/lightbox/lb_config.php')) {
                include_once 'modules/lightbox/lb_config.php';
            }
            switch ($type) {
                case 'url_flv':
                    $url = encode_url('module.php?mod=JWplayer&pgvaction=flvVideo&flvVideo=' . encrypt($fileName)) . "\" rel='clearbox(500,392,click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
                case 'local_flv':
                    $url = encode_url('module.php?mod=JWplayer&pgvaction=flvVideo&flvVideo=' . encrypt($SERVER_URL . $fileName)) . "\" rel='clearbox(500,392,click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
                case 'url_wmv':
                    $url = encode_url('module.php?mod=JWplayer&pgvaction=wmvVideo&wmvVideo=' . encrypt($fileName)) . "\" rel='clearbox(500,392,click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
                case 'local_audio':
                case 'local_wmv':
                    $url = encode_url('module.php?mod=JWplayer&pgvaction=wmvVideo&wmvVideo=' . encrypt($SERVER_URL . $fileName)) . "\" rel='clearbox(500,392,click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
                case 'url_image':
                case 'local_image':
                    $url = encode_url($fileName) . "\" rel=\"clearbox[general]\" rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
                case 'url_picasa':
                case 'url_page':
                case 'url_other':
                case 'local_page':
                    // case 'local_other':
                    $url = encode_url($fileName) . "\" rel='clearbox({$LB_URL_WIDTH},{$LB_URL_HEIGHT},click)' rev=\"" . $mid . "::" . $GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_COMPAT, 'UTF-8')) . "::" . htmlspecialchars($notes, ENT_COMPAT, 'UTF-8');
                    break 2;
            }
        }
        // Lightbox is not installed or Lightbox is not appropriate for this media type
        switch ($type) {
            case 'url_flv':
                $url = "javascript:;\" onclick=\" var winflv = window.open('" . encode_url('module.php?mod=JWplayer&pgvaction=flvVideo&flvVideo=' . encrypt($fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}";
                break 2;
            case 'local_flv':
                $url = "javascript:;\" onclick=\" var winflv = window.open('" . encode_url('module.php?mod=JWplayer&pgvaction=flvVideo&flvVideo=' . encrypt($SERVER_URL . $fileName)) . "', 'winflv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winflv.focus();}";
                break 2;
            case 'url_wmv':
                $url = "javascript:;\" onclick=\" var winwmv = window.open('" . encode_url('module.php?mod=JWplayer&pgvaction=wmvVideo&wmvVideo=' . encrypt($fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}";
                break 2;
            case 'local_wmv':
            case 'local_audio':
                $url = "javascript:;\" onclick=\" var winwmv = window.open('" . encode_url('module.php?mod=JWplayer&pgvaction=wmvVideo&wmvVideo=' . encrypt($SERVER_URL . $fileName)) . "', 'winwmv', 'width=500, height=392, left=600, top=200'); if (window.focus) {winwmv.focus();}";
                break 2;
            case 'url_image':
                $imgsize = findImageSize($fileName);
                $imgwidth = $imgsize[0] + 40;
                $imgheight = $imgsize[1] + 150;
                $url = "javascript:;\" onclick=\"var winimg = window.open('" . encode_url($fileName) . "', 'winimg', 'width=" . $imgwidth . ", height=" . $imgheight . ", left=200, top=200'); if (window.focus) {winimg.focus();}";
                break 2;
            case 'url_picasa':
            case 'url_page':
            case 'url_other':
            case 'local_other':
                $url = "javascript:;\" onclick=\"var winurl = window.open('" . encode_url($fileName) . "', 'winurl', 'width=900, height=600, left=200, top=200'); if (window.focus) {winurl.focus();}";
                break 2;
            case 'local_page':
                $url = "javascript:;\" onclick=\"var winurl = window.open('" . encode_url($SERVER_URL . $fileName) . "', 'winurl', 'width=900, height=600, left=200, top=200'); if (window.focus) {winurl.focus();}";
                break 2;
        }
        if ($USE_MEDIA_VIEWER && $obeyViewerOption) {
            $url = encode_url('mediaviewer.php?mid=' . $mid);
        } else {
            $imgsize = findImageSize($fileName);
            $imgwidth = $imgsize[0] + 40;
            $imgheight = $imgsize[1] + 150;
            $url = "javascript:;\" onclick=\"return openImage('" . encode_url(encrypt($fileName)) . "', {$imgwidth}, {$imgheight});";
        }
        break;
    }
    // At this point, $url describes how to handle the image when its thumbnail is clicked
    $result['url'] = $url;
    // -- Determine the correct thumbnail or pseudo-thumbnail
    $width = '';
    switch ($type) {
        case 'url_flv':
            $thumb = isset($PGV_IMAGES["media"]["flashrem"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["flashrem"] : 'images/media/flashrem.png';
            break;
        case 'local_flv':
            $thumb = isset($PGV_IMAGES["media"]["flash"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["flash"] : 'images/media/flash.png';
            break;
        case 'url_wmv':
            $thumb = isset($PGV_IMAGES["media"]["wmvrem"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["wmvrem"] : 'images/media/wmvrem.png';
            break;
        case 'local_wmv':
            $thumb = isset($PGV_IMAGES["media"]["wmv"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["wmv"] : 'images/media/wmv.png';
            break;
        case 'url_picasa':
            $thumb = isset($PGV_IMAGES["media"]["picasa"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["picasa"] : 'images/media/picasa.png';
            break;
        case 'url_page':
        case 'url_other':
            $thumb = isset($PGV_IMAGES["media"]["globe"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["globe"] : 'images/media/globe.png';
            break;
        case 'local_page':
            $thumb = $PGV_IMAGES["media"]["doc"] ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["doc"] : 'images/media/doc.gif';
            break;
        case 'url_audio':
        case 'local_audio':
            $thumb = isset($PGV_IMAGES["media"]["audio"]) ? $PGV_IMAGE_DIR . '/' . $PGV_IMAGES["media"]["audio"] : 'images/media/audio.png';
            break;
        default:
            $thumb = $thumbName;
            if (substr($type, 0, 4) == 'url_') {
                $width = ' width="' . $THUMBNAIL_WIDTH . '"';
            }
    }
    // -- Use an overriding thumbnail if one has been provided
    // Don't accept any overriding thumbnails that are in the "images" or "themes" directories
    if (substr($thumbName, 0, 7) != 'images/' && substr($thumbName, 0, 7) != 'themes/') {
        if ($USE_MEDIA_FIREWALL && $MEDIA_FIREWALL_THUMBS) {
            $tempThumbName = get_media_firewall_path($thumbName);
        } else {
            $tempThumbName = $thumbName;
        }
        if (file_exists($tempThumbName)) {
            $thumb = $thumbName;
        }
    }
    // -- Use the theme-specific media icon if nothing else works
    $realThumb = $thumb;
    if (substr($type, 0, 6) == 'local_' && !file_exists($thumb)) {
        if (!$USE_MEDIA_FIREWALL || !$MEDIA_FIREWALL_THUMBS) {
            $thumb = $PGV_IMAGE_DIR . '/' . $PGV_IMAGES['media']['large'];
            $realThumb = $thumb;
        } else {
            $realThumb = get_media_firewall_path($thumb);
            if (!file_exists($realThumb)) {
                $thumb = $PGV_IMAGE_DIR . '/' . $PGV_IMAGES['media']['large'];
                $realThumb = $thumb;
            }
        }
        $width = '';
    }
    // At this point, $width, $realThumb, and $thumb describe the thumbnail to be displayed
    $result['thumb'] = $thumb;
    $result['realThumb'] = $realThumb;
    $result['width'] = $width;
    return $result;
}