Beispiel #1
0
function make_pic_descr($pic, $row)
{
    global $CONFIG;
    $txt = "";
    $breadcrumb = " ";
    $ret = "<table><tr><td>";
    $pic_url = make_pic_url($pic, $size, FALSE);
    $size = isset($row['pic_size']) ? $row['pic_size'] : "Thumb";
    $comments = isset($row['item_comments']) ? $row['item_comments'] : "No";
    $content = isset($row['item_content']) ? $row['item_content'] : "&nbsp;";
    switch ($size) {
        case "Normal":
            $width = $CONFIG['picture_width'];
            break;
        case "Thumb":
            $width = $CONFIG['thumb_width'];
            break;
    }
    $ret .= "<a href =\"" . $CONFIG['ecards_more_pic_target'] . "displayimage.php?pos=-" . $pic['pid'] . "\">";
    $ret .= "<img src=\"" . $pic_url . "\" width=\"" . $width . "\" alt=\"RSS image\" /></a></td>";
    $n = 0;
    $content = "x" . $content;
    //x to avoid hitting anchor in first position (0= false)
    while ($pos = strpos($content, "{")) {
        $n++;
        $len = strpos($content, "}") - $pos + 1;
        $cmd = substr($content, $pos, $len);
        $exif = exif_parse_file("albums/" . $pic['file']);
        switch ($cmd) {
            case "{br}":
                $content = str_replace($cmd, "<br />", $content);
                break;
            case "{adate}":
                $content = str_replace($cmd, strftime("%x", $pic['ctime']), $content);
                break;
            case "{album}":
                $content = str_replace($cmd, $pic['atitle'], $content);
                break;
            case "{fname}":
                $content = str_replace($cmd, $pic['filename'], $content);
                break;
            case "{fsize}":
                $content = str_replace($cmd, intval($pic['filesize'] / 1024) . " kB", $content);
                break;
            case "{title}":
                $content = str_replace($cmd, $pic['title'], $content);
                break;
            case "{hits}":
                $content = str_replace($cmd, $pic['hits'], $content);
                break;
            case "{rating}":
                $content = str_replace($cmd, $pic['rating'], $content);
                break;
            case "{descr}":
                $content = str_replace($cmd, $pic['caption'], $content);
                break;
            case "{miniCMS}":
                if (isset($CONFIG['TABLE_CMS'])) {
                    $txt = getMiniCMS($pic['pid']);
                }
                $content = str_replace($cmd, $txt, $content);
                break;
            case "{owner}":
                $content = str_replace($cmd, $pic['owner_name'], $content);
                break;
            case "{cat}":
                $i = $pic['category'];
                if (!isset($alb_name[$i])) {
                    $query = "SELECT title FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid=" . $pic['category'];
                    if ($result = cpg_db_query($query)) {
                        $title = cpg_db_fetch_row($result);
                        $alb_name[$pic['category']] = $title['title'];
                    }
                }
                $name = $alb_name[$pic['category']];
                $content = str_replace($cmd, $name, $content);
                break;
            case "{bread}":
                $breadcrumb = " ";
                breadcrumb($pic['category'], $breadcrumb, $BREADCRUMB_TEXT);
                $content = str_replace($cmd, $breadcrumb, $content);
                break;
            case "{make}":
                $exif = exif_parse_file("albums/" . $pic['file']);
                $param = substr($exif['Make'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            case "{model}":
                $param = substr($exif['Model'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            case "{keyw}":
                $content = str_replace($cmd, $pic['keywords'], $content);
                break;
            case "{date}":
                $param = substr($exif['DateTime Original'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            default:
                /*print_r ($exif);
                  die();*/
                $lookup = substr($cmd, 1, -1);
                if (isset($exif[$lookup])) {
                    $param = $exif[$lookup];
                    if (!ord(substr($param, -1))) {
                        $param = substr($param, 0, -1);
                        //some exif values ends with a ascii 0 character
                    }
                } else {
                    $param = substr($cmd, 1, -1) . " not valid anchor";
                    // $param = $cmd." not valid anchor";
                }
                $content = str_replace($cmd, $param, $content);
                break;
        }
        //  if ($n>5) die ("ut: ".$content);
    }
    $content = substr($content, 1);
    $ret .= "<td valign=\"top\">" . $content . "</td></tr>";
    if ($comments == "Yes") {
        $coms = get_pic_comments($pic['pid']);
        if (count($coms) > 0) {
            foreach ($coms as $com) {
                $ret .= "<tr><td>&nbsp</td><td><p>" . $com['msg_author'] . ": " . $com['msg_body'] . "</td></tr>";
            }
        }
    }
    $ret .= "</table>";
    return bb_decode($ret);
}
Beispiel #2
0
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $CPG_M_DIR;
    global $album, $lang_byte_units, $db;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="' . URL::index('Your_Account&amp;profile=' . $CURRENT_PIC_DATA['owner_id']) . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    if ($CONFIG['picinfo_display_filename']) {
        $info[PIC_INF_FILENAME] = htmlprepare($CURRENT_PIC_DATA['filename']);
    }
    // -----------------------------------------------------------------
    // Added by Vitor Freitas on 2003-09-01.
    // Hack version: 1.1
    // Display the name of the user that upload the image whit the image information.
    // Modified by DJ Maze for CPG 1.2 RC4
    global $db;
    $vf_sql = "SELECT username FROM " . $CONFIG['TABLE_USERS'] . " WHERE user_id='" . $CURRENT_PIC_DATA['owner_id'] . "'";
    $vf_result = $db->sql_query($vf_sql);
    $vf_row = $db->sql_fetchrow($vf_result);
    // if statement added by gtroll
    // only display if there is a value
    if ($vf_row != '') {
        $info['Upload by'] = '<a href="' . URL::index('Your_Account&amp;profile=' . $CURRENT_PIC_DATA['owner_id']) . '" target="_blank">' . $vf_row['username'] . '</a>';
    }
    // End -- Vitor Freitas on 2003-08-29.
    // -----------------------------------------------------------------
    if ($CONFIG['picinfo_display_album_name']) {
        $info[ALBUM_NAME] = '<span class="alblink"><a href="' . URL::index('&amp;file=thumbnails&amp;album=' . $CURRENT_PIC_DATA['aid']) . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    }
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        $info[sprintf(PIC_INFO_RATING, $CURRENT_PIC_DATA['votes'])] = '<img src="' . $CPG_M_DIR . '/images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" alt="' . sprintf(RATING, round($CURRENT_PIC_DATA['pic_rating'] / 2000), $CURRENT_PIC_DATA['votes']) . '" align="absmiddle"/>';
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[KEYWORDS] = '<span class="alblink">' . preg_replace("/(\\S+)/", '<a href="' . URL::index('&amp;file=thumbnails&amp;meta=search&amp;search=\\1') . '">\\1</a>', $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    //$info[test] = "SELECT pid FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} ON visibility IN (".USER_IN_GROUPS.") WHERE p.pid='".$CURRENT_PIC_DATA['pid']."' GROUP BY pid LIMIT 1";
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $filesizeinfo = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . ' ' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . ' ' . $lang_byte_units[0];
    if ($CONFIG['picinfo_display_file_size']) {
        $info[PIC_INF_FILE_SIZE] = '<span dir="LTR">' . $filesizeinfo . '</span>';
    }
    if ($CONFIG['picinfo_display_dimensions']) {
        $info[PIC_INF_DIMENSIONS] = sprintf(SIZE, $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    }
    if ($CONFIG['picinfo_display_dimensions']) {
        $info[DISPLAYED] = sprintf(VIEWS, $CURRENT_PIC_DATA['hits']);
    }
    $path_to_pic = $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        if (isset($exif['Camera'])) {
            $info[CAMERA] = strip_tags(trim($exif['Camera'], ".."));
        }
        if (isset($exif['DateTaken'])) {
            $info[DATE_TAKEN] = strip_tags(trim($exif['DateTaken'], ".."));
        }
        if (isset($exif['Aperture'])) {
            $info[APERTURE] = strip_tags(trim($exif['Aperture'], ".."));
        }
        if (isset($exif['ExposureTime'])) {
            $info[EXPOSURE_TIME] = strip_tags(trim($exif['ExposureTime'], ".."));
        }
        if (isset($exif['FocalLength'])) {
            $info[FOCAL_LENGTH] = strip_tags(trim($exif['FocalLength'], ".."));
        }
        if (isset($exif['Comment'])) {
            $info[COMMENT] = strip_tags(trim($exif['Comment'], ".."));
        }
    }
    // Create the absolute URL for display in info
    if ($CONFIG['picinfo_display_URL'] || $CONFIG['picinfo_display_URL_bookmark']) {
        if ($CONFIG['picinfo_display_URL_bookmark']) {
            $info["URL"] = '<a href="' . URL::index("&amp;file=displayimage&amp;album={$CURRENT_PIC_DATA['aid']}&amp;pid={$CURRENT_PIC_DATA['pid']}") . '" onclick="addBookmark(\'' . $CURRENT_PIC_DATA["filename"] . '\',\'' . URL::index("&amp;file=displayimage&amp;pid={$CURRENT_PIC_DATA['pid']}") . "');return false\">" . BOOKMARK_PAGE . '</a>';
        } else {
            $info['URL'] = '<a href="' . URL::index("&amp;file=displayimage&amp;album={$CURRENT_PIC_DATA['aid']}&amp;pid={$CURRENT_PIC_DATA['pid']}") . '">' . $CONFIG["ecards_more_pic_target"] . URL::index("&amp;file=displayimage&amp;pid={$CURRENT_PIC_DATA['pid']}") . '</a>';
        }
    }
    /* doesn't work on resized pics
    	if ($CONFIG['read_iptc_data']) $iptc = get_IPTC($path_to_pic);
    	if (isset($iptc) && is_array($iptc)) {
    		if (isset($iptc['Title'])) $info[IPTCTITLE] = strip_tags(trim($iptc['Title'],"\x0..\x1f"));
    		if (isset($iptc['Copyright'])) $info[IPTCCOPYRIGHT] = strip_tags(trim($iptc['Copyright'],"\x0..\x1f"));
    		if (!empty($iptc['Keywords'])) $info[IPTCKEYWORDS] = strip_tags(trim(implode(' ',$iptc['Keywords']),"\x0..\x1f"));
    		if (isset($iptc['Category'])) $info[IPTCCATEGORY] = strip_tags(trim($iptc['Category'],"\x0..\x1f"));
    		if (!empty($iptc['SubCategories'])) $info[IPTCSUBCATEGORIES] = strip_tags(trim(implode(' ',$iptc['SubCategories']),"\x0..\x1f"));
    	}
    */
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] with trailing slash in the configure
    // Create the add to fav link
    if ($CONFIG['picinfo_display_favorites']) {
        if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
            $info[ADDFAVPHRASE] = '<a href="' . URL::index('&amp;file=addfav&amp;pid=' . $CURRENT_PIC_DATA['pid']) . '" >' . ADDFAV . '</a>';
        } else {
            $info[ADDFAVPHRASE] = '<a href="' . URL::index('&amp;file=addfav&amp;pid=' . $CURRENT_PIC_DATA['pid']) . '" >' . REMFAV . '</a>';
        }
    }
    if (USER_ID or $CONFIG['allow_anon_fullsize'] or USER_IS_ADMIN) {
        return theme_html_picinfo($info);
    }
}
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    $info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
    $info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . $ipinfo . '<a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        if (defined('THEME_HAS_RATING_GRAPHICS')) {
            $prefix = $THEME_DIR;
        } else {
            $prefix = '';
        }
        $info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = '<img src="' . $prefix . 'images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="absmiddle"/>';
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[$lang_picinfo['Keywords']] = '<span class="alblink">' . preg_replace("/(\\S+)/", "<a href=\"thumbnails.php?album=search&search=\\1\">\\1</a>", $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $info[$lang_picinfo['File Size']] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0];
    $info[$lang_picinfo['File Size']] = '<span dir="LTR">' . $info[$lang_picinfo['File Size']] . '</span>';
    $info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    $info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
    $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        if (isset($exif['Camera'])) {
            $info[$lang_picinfo['Camera']] = $exif['Camera'];
        }
        if (isset($exif['DateTaken'])) {
            $info[$lang_picinfo['Date taken']] = $exif['DateTaken'];
        }
        if (isset($exif['Aperture'])) {
            $info[$lang_picinfo['Aperture']] = $exif['Aperture'];
        }
        if (isset($exif['ISO'])) {
            $info[$lang_picinfo['ISO']] = $exif['ISO'];
        }
        if (isset($exif['ExposureTime'])) {
            $info[$lang_picinfo['Exposure time']] = $exif['ExposureTime'];
        }
        if (isset($exif['FocalLength'])) {
            $info[$lang_picinfo['Focal length']] = $exif['FocalLength'];
        }
        if (@strlen(trim($exif['Comment'])) > 0) {
            $info[$lang_picinfo['Comment']] = trim($exif['Comment']);
        }
    }
    if ($CONFIG['read_iptc_data']) {
        $iptc = get_IPTC($path_to_pic);
    }
    if (isset($iptc) && is_array($iptc)) {
        if (isset($iptc['Title'])) {
            $info[$lang_picinfo['iptcTitle']] = trim($iptc['Title']);
        }
        if (isset($iptc['Copyright'])) {
            $info[$lang_picinfo['iptcCopyright']] = trim($iptc['Copyright']);
        }
        if (isset($iptc['Keywords'])) {
            $info[$lang_picinfo['iptcKeywords']] = trim(implode(" ", $iptc['Keywords']));
        }
        if (isset($iptc['Category'])) {
            $info[$lang_picinfo['iptcCategory']] = trim($iptc['Category']);
        }
        if (isset($iptc['SubCategories'])) {
            $info[$lang_picinfo['iptcSubCategories']] = trim(implode(" ", $iptc['SubCategories']));
        }
    }
    // Create the absolute URL for display in info
    $info['URL'] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA['pid']}" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA['pid']}" . '</a>';
    $info['ImageUrl'] = "http://www.bestmag.com/gallery/" . $path_to_pic;
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
    // Create the add to fav link
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . " >" . $lang_picinfo['addFav'] . '</a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . " >" . $lang_picinfo['remFav'] . '</a>';
    }
    return theme_html_picinfo($info);
}
Beispiel #4
0
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $REFERER;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lastup_date_fmt;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    $info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
    $info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . '/ <a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        if (defined('THEME_HAS_RATING_GRAPHICS')) {
            $prefix = $THEME_DIR;
        } else {
            $prefix = '';
        }
        if (GALLERY_ADMIN_MODE) {
            $width = 800;
            $height = 500;
        } else {
            $width = 400;
            $height = 250;
        }
        $detailsLink = $CONFIG['vote_details'] ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=vote&amp;pid=' . $CURRENT_PIC_DATA['pid'] . '&amp;sort=sdate&amp;dir=&amp;sdate=1&amp;ip=1&amp;rating=1&amp;referer=1&amp;browser=1&amp;os=1\',\'\',\'resizable=yes,width=' . $width . ',height=' . $height . ',top=50,left=50,scrollbars=yes\'); return false;">' . $lang_picinfo['details'] . '</a>)' : '';
        $info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = '<img width="65" height="14" src="plugins/enlargeit/rating/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="middle" alt="" />' . $detailsLink;
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[$lang_picinfo['Keywords']] = '<span class="alblink">' . preg_replace("/(\\S+)/", "<a href=\"thumbnails.php?album=search&amp;search=\\1\">\\1</a>", $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $info[$lang_picinfo['File Size']] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0];
    $info[$lang_picinfo['File Size']] = '<span dir="ltr">' . $info[$lang_picinfo['File Size']] . '</span>';
    $info[$lang_picinfo['Date Added']] = localised_date($CURRENT_PIC_DATA['ctime'], $lastup_date_fmt);
    $info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    $detailsLink = $CURRENT_PIC_DATA['hits'] && $CONFIG['hit_details'] && GALLERY_ADMIN_MODE ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=hits&amp;pid=' . $CURRENT_PIC_DATA['pid'] . '&amp;sort=sdate&amp;dir=&amp;sdate=1&amp;ip=1&amp;search_phrase=1&amp;referer=1&amp;browser=1&amp;os=1\',\'\',\'resizable=yes,width=800,height=500,top=50,left=50,scrollbars=yes\'); return false;">' . $lang_picinfo['details'] . '</a>)' : '';
    $info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
    $info[$lang_picinfo['Displayed']] .= $detailsLink;
    $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        array_walk($exif, 'sanitize_data');
        $info = array_merge($info, $exif);
    }
    if ($CONFIG['read_iptc_data']) {
        $iptc = get_IPTC($path_to_pic);
    }
    if (isset($iptc) && is_array($iptc)) {
        array_walk($iptc, 'sanitize_data');
        if (!empty($iptc['Title'])) {
            $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        }
        if (!empty($iptc['Copyright'])) {
            $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        }
        if (!empty($iptc['Keywords'])) {
            $info[$lang_picinfo['iptcKeywords']] = implode(' ', $iptc['Keywords']);
        }
        if (!empty($iptc['Category'])) {
            $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        }
        if (!empty($iptc['SubCategories'])) {
            $info[$lang_picinfo['iptcSubCategories']] = implode(' ', $iptc['SubCategories']);
        }
    }
    /**
     * Filter file information
     */
    $info = CPGPluginAPI::filter('file_info', $info);
    return theme_html_picinfo($info);
}
Beispiel #5
0
function file_replacer_page_start()
{
    global $CONFIG, $lang_errors;
    $superCage = Inspekt::makeSuperCage();
    if ($superCage->get->keyExists('replacer_id')) {
        $pid = $superCage->get->getInt('replacer_id');
        $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE p.pid = '{$pid}' LIMIT 1");
        $row = mysql_fetch_assoc($result);
        if (!(USER_ADMIN_MODE && $row['category'] == FIRST_USER_CAT + USER_ID || $CONFIG['users_can_edit_pics'] && $row['owner_id'] == USER_ID && USER_ID != 0 || GALLERY_ADMIN_MODE)) {
            load_template();
            cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
        }
        require_once "./plugins/file_replacer/lang/english.php";
        if ($CONFIG['lang'] != 'english' && file_exists("./plugins/file_replacer/lang/{$CONFIG['lang']}.php")) {
            require_once "./plugins/file_replacer/lang/{$CONFIG['lang']}.php";
        }
        if ($superCage->files->keyExists('fileupload') && $row) {
            if (!checkFormToken()) {
                load_template();
                global $lang_errors;
                cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__);
            }
            $fileupload = $superCage->files->_source['fileupload'];
            if ($fileupload['error']) {
                load_template();
                global $lang_errors;
                cpg_die(ERROR, $lang_errors['error'] . ' ' . $fileupload['error'], __FILE__, __LINE__);
            }
            $image = $CONFIG['fullpath'] . $row['filepath'] . $row['filename'];
            $normal = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['normal_pfx'] . $row['filename'];
            $thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $row['filename'];
            $orig = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['orig_pfx'] . $row['filename'];
            $work_image = $image;
            if (!move_uploaded_file($fileupload['tmp_name'], $image)) {
                load_template();
                cpg_die(ERROR, sprintf($lang_plugin_file_replacer['error_move_file'], $fileupload['tmp_name'], $image), __FILE__, __LINE__);
            }
            chmod($image, octdec($CONFIG['default_file_mode']));
            if (is_known_filetype($image)) {
                if (is_image($image)) {
                    require 'include/picmgmt.inc.php';
                    $imagesize = cpg_getimagesize($image);
                    if ($CONFIG['read_iptc_data']) {
                        // read IPTC data
                        $iptc = get_IPTC($image);
                        if ($superCage->post->keyExists('overwrite_metadata')) {
                            $title = isset($iptc['Headline']) ? $iptc['Headline'] : '';
                            $caption = isset($iptc['Caption']) ? $iptc['Caption'] : '';
                            $keywords = isset($iptc['Keywords']) ? implode($CONFIG['keyword_separator'], $iptc['Keywords']) : '';
                            $metadata_sql = ", title = '{$title}', caption = '{$caption}', keywords = '{$keywords}'";
                        }
                    }
                    // resize picture if it's bigger than the max width or height for uploaded pictures
                    if (max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) {
                        if (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {
                            resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], 'any', 'false');
                            // hard-coded 'any' according to configuration string 'Max width or height for uploaded pictures'
                            $imagesize = cpg_getimagesize($image);
                        } elseif (USER_IS_ADMIN) {
                            // skip resizing for admin
                            $picture_original_size = true;
                        } else {
                            @unlink($uploaded_pic);
                            $msg = sprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']);
                            return array('error' => $msg, 'halt_upload' => 1);
                        }
                    }
                    // create backup of full sized picture if watermark is enabled for full sized pictures
                    if (!file_exists($orig) && $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
                        if (!copy($image, $orig)) {
                            return false;
                        } else {
                            $work_image = $orig;
                        }
                    }
                    //if (!file_exists($thumb)) {
                    // create thumbnail
                    if (($result = resize_image($work_image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false", 1)) !== true) {
                        return $result;
                    }
                    //}
                    if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
                        // create intermediate sized picture
                        $resize_method = $CONFIG['picture_use'] == "thumb" ? $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'] : $CONFIG['picture_use'];
                        $watermark = $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') ? 'true' : 'false';
                        if (($result = resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $resize_method, $watermark)) !== true) {
                            return $result;
                        }
                    }
                    // watermark full sized picture
                    if ($CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
                        $wm_max_upl_width_height = $picture_original_size ? max($imagesize[0], $imagesize[1]) : $CONFIG['max_upl_width_height'];
                        // use max aspect of original image if it hasn't been resized earlier
                        if (($result = resize_image($work_image, $image, $wm_max_upl_width_height, $CONFIG['thumb_method'], 'any', 'true')) !== true) {
                            return $result;
                        }
                    }
                    list($width, $height) = getimagesize($image);
                } else {
                    $width = 0;
                    $height = 0;
                }
                $image_filesize = filesize($image);
                $total_filesize = is_image($row['filename']) ? $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb) : $image_filesize;
                cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filesize = '{$image_filesize}', total_filesize = '{$total_filesize}', pwidth = '{$width}', pheight = '{$height}' {$metadata_sql} WHERE pid = '{$pid}' LIMIT 1");
                if ($superCage->post->keyExists('update_timestamp')) {
                    cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET ctime = '" . time() . "' WHERE pid = '{$pid}' LIMIT 1");
                }
                cpg_db_query("DELETE FROM {$CONFIG['TABLE_EXIF']} WHERE pid = '{$pid}' LIMIT 1");
                if ($CONFIG['read_exif_data']) {
                    include "include/exif_php.inc.php";
                    exif_parse_file($image, $pid);
                }
                $CONFIG['site_url'] = rtrim($CONFIG['site_url'], '/');
            } else {
                if (is_image($image)) {
                    @unlink($normal);
                    @unlink($thumb);
                }
                @unlink($image);
            }
            header("Location: {$CONFIG['site_url']}/displayimage.php?pid={$pid}");
            die;
        } else {
            load_template();
            pageheader($lang_plugin_file_replacer['file_replacer']);
            echo '<form method="post" enctype="multipart/form-data">';
            starttable('60%', $lang_plugin_file_replacer['upload_file'], 2);
            list($timestamp, $form_token) = getFormToken();
            echo <<<EOT
                <tr>
                    <td class="tableb" valign="top">
                        {$lang_plugin_file_replacer['browse']}
                    </td>
                    <td class="tableb" valign="top">
                        <input type="file" name="fileupload" size="40" class="listbox" />
                    </td>
                </tr>
                <tr>
                    <td class="tableb" valign="top">
                        {$lang_plugin_file_replacer['update_timestamp']}
                    </td>
                    <td class="tableb" valign="top">
                        <input type="checkbox" name="update_timestamp" />
                    </td>
                </tr>
                <tr>
                    <td class="tableb" valign="top">
                        {$lang_plugin_file_replacer['overwrite_metadata']}
                    </td>
                    <td class="tableb" valign="top">
                        <input type="checkbox" name="overwrite_metadata" />
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2" class="tablef">
                        <input type="hidden" name="form_token" value="{$form_token}" />
                        <input type="hidden" name="timestamp" value="{$timestamp}" />
                        <input type="submit" name="commit" class="button" value="{$lang_plugin_file_replacer['upload']}"/>
                    </td>
                </tr>
EOT;
            endtable();
            echo '</form>';
            pagefooter();
            exit;
        }
    }
}
Beispiel #6
0
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $REFERER;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lang_common, $lastup_date_fmt;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    $info[$lang_common['filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
    $info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . $ipinfo . '<a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        if (defined('THEME_HAS_RATING_GRAPHICS')) {
            $prefix = $THEME_DIR;
        } else {
            $prefix = '';
        }
        if (GALLERY_ADMIN_MODE) {
            $width = 800;
            $height = 700;
        } else {
            $width = 400;
            $height = 250;
        }
        if ($CONFIG['vote_details'] == 1) {
            $detailsLink = <<<EOT
            <div id="votedetailsunhidetoggle" style="display:none">&nbsp;(<a href="javascript:;" onclick="voteDetailsDisplay();">{$lang_picinfo['show_details']}</a>)</div>
            <div id="votedetailshidetoggle" style="display:none">&nbsp;(<a href="javascript:;" onclick="voteDetailsDisplay();">{$lang_picinfo['hide_details']}</a>)</div>
            <iframe src="stat_details.?type=blank" width="100%" height="0" name="votedetails" id="votedetails" frameborder="0" style="display:none;border;none;"></iframe>
            <script type="text/javascript">
                addonload("show_section('votedetailsunhidetoggle')");
                function voteDetailsDisplay() {
                    show_section('votedetailsunhidetoggle');
                    show_section('votedetailshidetoggle');
                    show_section('votedetails');
                    document.getElementById('votedetails').height = 800;
                    top.frames.votedetails.document.location.href = "stat_details.php?type=vote&pid={$CURRENT_PIC_DATA['pid']}&sort=sdate&dir=&sdate=1&ip=1&rating=1&referer=0&browser=0&os=0&uid=1";
                }
            </script>
EOT;
        }
        $info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = '<img src="' . $prefix . 'images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="left" alt="" />' . $detailsLink;
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[$lang_common['keywords']] = '<span class="alblink">' . preg_replace("/(\\S+)/", "<a href=\"thumbnails.php?album=search&amp;search=\\1\">\\1</a>", $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $info[$lang_common['filesize']] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0];
    $info[$lang_common['filesize']] = '<span dir="ltr">' . $info[$lang_common['filesize']] . '</span>';
    $info[$lang_picinfo['Date Added']] = localised_date($CURRENT_PIC_DATA['ctime'], $lastup_date_fmt);
    $info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    if ($CURRENT_PIC_DATA['hits'] && $CONFIG['hit_details'] && GALLERY_ADMIN_MODE) {
        $detailsLink = <<<EOT
            <div id="hitdetailsunhidetoggle" style="display:none">&nbsp;(<a href="javascript:;" onclick="hitDetailsDisplay();">{$lang_picinfo['show_details']}</a>)</div>
            <div id="hitdetailshidetoggle" style="display:none">&nbsp;(<a href="javascript:;" onclick="hitDetailsDisplay();">{$lang_picinfo['hide_details']}</a>)</div>
            <iframe src="stat_details.?type=blank" width="100%" height="0" name="hitdetails" id="hitdetails" frameborder="0" style="display:none;border;none;"></iframe>
            <script type="text/javascript">
                addonload("show_section('hitdetailsunhidetoggle')");
                function hitDetailsDisplay() {
                    show_section('hitdetailsunhidetoggle');
                    show_section('hitdetailshidetoggle');
                    show_section('hitdetails');
                    document.getElementById('hitdetails').height = 800;
                    top.frames.hitdetails.document.location.href = "stat_details.php?type=hits&pid={$CURRENT_PIC_DATA['pid']}&sort=sdate&dir=&sdate=1&ip=1&search_phrase=0&referer=0&browser=1&os=1";
                }
            </script>
EOT;
    }
    $info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
    $info[$lang_picinfo['Displayed']] .= $detailsLink;
    $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    $path_to_orig_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['orig_pfx'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        array_walk($exif, 'sanitize_data');
        $info = array_merge($info, $exif);
    }
    // Read the iptc data
    if ($CONFIG['read_iptc_data']) {
        // Read the iptc data from original pic (if watermarked)
        $iptc = file_exists($path_to_orig_pic) ? get_IPTC($path_to_orig_pic) : get_IPTC($path_to_pic);
    }
    if (isset($iptc) && is_array($iptc)) {
        array_walk($iptc, 'sanitize_data');
        if (isset($iptc['Title'])) {
            $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        }
        if (isset($iptc['Copyright'])) {
            $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        }
        if (!empty($iptc['Keywords'])) {
            $info[$lang_picinfo['iptcKeywords']] = implode(' ', $iptc['Keywords']);
        }
        if (isset($iptc['Category'])) {
            $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        }
        if (!empty($iptc['SubCategories'])) {
            $info[$lang_picinfo['iptcSubCategories']] = implode(' ', $iptc['SubCategories']);
        }
    }
    // Create the absolute URL for display in info
    $info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pid={$CURRENT_PIC_DATA['pid']}" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pid={$CURRENT_PIC_DATA['pid']}" . '</a>';
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
    // Create the add to fav link
    $ref = $REFERER ? "&amp;ref={$REFERER}" : '';
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';
    }
    /**
     * Filter file information
     */
    $info = CPGPluginAPI::filter('file_info', $info);
    return theme_html_picinfo($info);
}
Beispiel #7
0
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $REFERER;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lastup_date_fmt;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    $info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
    $info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . $ipinfo . '<a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        if (defined('THEME_HAS_RATING_GRAPHICS')) {
            $prefix = $THEME_DIR;
        } else {
            $prefix = '';
        }
        if (GALLERY_ADMIN_MODE) {
            $width = 800;
            $height = 500;
        } else {
            $width = 400;
            $height = 250;
        }
        $detailsLink = $CONFIG['vote_details'] ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=vote&amp;pid=' . $CURRENT_PIC_DATA['pid'] . '&amp;sort=sdate&amp;dir=&amp;sdate=1&amp;ip=1&amp;rating=1&amp;referer=1&amp;browser=1&amp;os=1\',\'\',\'resizable=yes,width=' . $width . ',height=' . $height . ',top=50,left=50,scrollbars=yes\'); return false;">' . $lang_picinfo['details'] . '</a>)' : '';
        $info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = '<img src="' . $prefix . 'images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="middle" alt="" />' . $detailsLink;
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[$lang_picinfo['Keywords']] = '<span class="alblink">' . preg_replace("/(\\S+)/", "<a href=\"thumbnails.php?album=search&amp;search=\\1\">\\1</a>", $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $info[$lang_picinfo['File Size']] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0];
    $info[$lang_picinfo['File Size']] = '<span dir="ltr">' . $info[$lang_picinfo['File Size']] . '</span>';
    $info[$lang_picinfo['Date Added']] = localised_date($CURRENT_PIC_DATA['ctime'], $lastup_date_fmt);
    $info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    $detailsLink = $CURRENT_PIC_DATA['hits'] && $CONFIG['hit_details'] && GALLERY_ADMIN_MODE ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=hits&amp;pid=' . $CURRENT_PIC_DATA['pid'] . '&amp;sort=sdate&amp;dir=&amp;sdate=1&amp;ip=1&amp;search_phrase=1&amp;referer=1&amp;browser=1&amp;os=1\',\'\',\'resizable=yes,width=800,height=500,top=50,left=50,scrollbars=yes\'); return false;">' . $lang_picinfo['details'] . '</a>)' : '';
    $info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
    $info[$lang_picinfo['Displayed']] .= $detailsLink;
    $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        array_walk($exif, 'sanitize_data');
        $info = array_merge($info, $exif);
    }
    if ($CONFIG['read_iptc_data']) {
        $iptc = get_IPTC($path_to_pic);
    }
    if (isset($iptc) && is_array($iptc)) {
        array_walk($iptc, 'sanitize_data');
        if (!empty($iptc['Title'])) {
            $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        }
        if (!empty($iptc['Copyright'])) {
            $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        }
        if (!empty($iptc['Keywords'])) {
            $info[$lang_picinfo['iptcKeywords']] = implode(' ', $iptc['Keywords']);
        }
        if (!empty($iptc['Category'])) {
            $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        }
        if (!empty($iptc['SubCategories'])) {
            $info[$lang_picinfo['iptcSubCategories']] = implode(' ', $iptc['SubCategories']);
        }
    }
    // Create the absolute URL for display in info
    $info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA['pid']}" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA['pid']}" . '</a>';
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
    // Create the add to fav link
    $ref = $REFERER ? "&amp;ref={$REFERER}" : '';
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';
    }
    /**
     * Filter file information
     */
    $info = CPGPluginAPI::filter('file_info', $info);
    return theme_html_picinfo($info);
}
Beispiel #8
0
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $REFERER, $CPG_PHP_SELF;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lang_common, $lastup_date_fmt;
    if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
        $owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
    } else {
        $owner_link = '';
    }
    if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
        if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
        } else {
            $ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
        }
    } else {
        if ($owner_link) {
            $ipinfo = '/ ';
        } else {
            $ipinfo = '';
        }
    }
    $info[$lang_common['filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
    $info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . $ipinfo . '<a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
    $votedetailsunhidetoggle_onload_added = false;
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        if (defined('THEME_HAS_RATING_GRAPHICS')) {
            $prefix = $THEME_DIR;
        } else {
            $prefix = '';
        }
        if (GALLERY_ADMIN_MODE) {
            $width = 800;
            $height = 700;
        } else {
            $width = 400;
            $height = 250;
        }
        if ($CONFIG['vote_details'] == 1) {
            $stat_link = "stat_details.php?type=vote&pid={$CURRENT_PIC_DATA['pid']}&sort=sdate&dir=&sdate=1&ip=1&rating=1&referer=0&browser=0&os=0&uid=1";
            $detailsLink_votes = '<div>(<a href="javascript:;" onclick="MM_openBrWindow(\'' . $stat_link . '\', \'stat_detail\', \'width=650,height=800,scrollbars=yes,resizable=yes\');">' . $lang_picinfo['show_details'] . '</a>)</div>';
        }
        //calculate required amount of stars in picinfo
        $i = 1;
        $rating = round($CURRENT_PIC_DATA['pic_rating'] / 2000 / (5 / $CONFIG['rating_stars_amount']));
        $rating_images = '';
        while ($i <= $CONFIG['rating_stars_amount']) {
            if ($i <= $rating) {
                $rating_images .= '<img src="' . $prefix . 'images/rate_full.gif" align="left" alt="' . $rating . '"/>';
            } else {
                $rating_images .= '<img src="' . $prefix . 'images/rate_empty.gif" align="left" alt="' . $rating . '"/>';
            }
            $i++;
        }
        $info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = $rating_images . $detailsLink_votes;
    }
    if ($CURRENT_PIC_DATA['keywords'] != "") {
        $info[$lang_common['keywords']] = '<span class="alblink">' . preg_replace("/(\\S+)/", "<a href=\"thumbnails.php?album=search&amp;search=\\1\">\\1</a>", $CURRENT_PIC_DATA['keywords']) . '</span>';
    }
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }
    $info[$lang_common['filesize']] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0];
    $info[$lang_common['filesize']] = '<span dir="ltr">' . $info[$lang_common['filesize']] . '</span>';
    $info[$lang_picinfo['Date Added']] = localised_date($CURRENT_PIC_DATA['ctime'], $lastup_date_fmt);
    $info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    if ($CURRENT_PIC_DATA['hits'] && $CONFIG['hit_details'] && GALLERY_ADMIN_MODE) {
        $stat_link = "stat_details.php?type=hits&pid={$CURRENT_PIC_DATA['pid']}&sort=sdate&dir=&sdate=1&ip=1&search_phrase=0&referer=0&browser=1&os=1";
        $detailsLink_hits = '<div>(<a href="javascript:;" onclick="MM_openBrWindow(\'' . $stat_link . '\', \'stat_detail\', \'width=650,height=800,scrollbars=yes,resizable=yes\');">' . $lang_picinfo['show_details'] . '</a>)</div>';
    }
    $info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
    $info[$lang_picinfo['Displayed']] .= $detailsLink_hits;
    $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    $path_to_orig_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['orig_pfx'] . $CURRENT_PIC_DATA['filename'];
    if ($CONFIG['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        array_walk($exif, 'sanitize_data');
        $info = array_merge($info, $exif);
    }
    // Read the iptc data
    if ($CONFIG['read_iptc_data']) {
        // Read the iptc data from original pic (if watermarked)
        $iptc = file_exists($path_to_orig_pic) ? get_IPTC($path_to_orig_pic) : get_IPTC($path_to_pic);
    }
    if (isset($iptc) && is_array($iptc)) {
        array_walk($iptc, 'sanitize_data');
        if (!empty($iptc['Title'])) {
            $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        }
        if (!empty($iptc['Copyright'])) {
            $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        }
        if (!empty($iptc['Keywords'])) {
            $info[$lang_picinfo['iptcKeywords']] = implode(' ', $iptc['Keywords']);
        }
        if (!empty($iptc['Category'])) {
            $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        }
        if (!empty($iptc['SubCategories'])) {
            $info[$lang_picinfo['iptcSubCategories']] = implode(' ', $iptc['SubCategories']);
        }
    }
    // Create the absolute URL for display in info
    $info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($CPG_PHP_SELF) . "?pid={$CURRENT_PIC_DATA['pid']}" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($CPG_PHP_SELF) . "?pid={$CURRENT_PIC_DATA['pid']}" . '</a>';
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
    // Create the add to fav link
    $ref = $REFERER ? "&amp;referer={$REFERER}" : '';
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';
    }
    /**
     * Filter file information
     */
    $info = CPGPluginAPI::filter('file_info', $info);
    return theme_html_picinfo($info);
}
Beispiel #9
0
function html_picinfo()
{
    global $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
    global $album, $xoopsModuleConfig, $myts;
    global $xoopsTpl;
    $info[_MD_DIS_FNAME] = $myts->makeTboxData4Show($CURRENT_PIC_DATA['filename']);
    $info[_MD_DIS_ANAME] = '<span class="alblink"><a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $myts->makeTboxData4Show($CURRENT_ALBUM_DATA['title']) . '</a></span>';
    $user_handler =& xoops_gethandler('member');
    $submitter =& $user_handler->getUser($CURRENT_PIC_DATA['owner_id']);
    if (is_object($submitter)) {
        $info[_MD_DIS_UPLOADER] = '<span class="alblink"><a href="' . XOOPS_URL . '/userinfo.php?uid=' . $submitter->uid() . '">' . $submitter->uname() . '</a>&nbsp;&nbsp;<a href="thumbnails.php?album=usearch&amp;suid=' . $submitter->uid() . '" title="' . _MD_DIS_VIEW_MORE_BY . ' ' . $submitter->uname() . '"><img src="images/more.gif" align="middle" alt=""/></a></span>';
    }
    if ($CURRENT_PIC_DATA['votes'] > 0) {
        $info[sprintf(_MD_DIS_RATING, $CURRENT_PIC_DATA['votes'])] = '<img src="images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="middle" alt=""/>';
    }
    $keys = explode(' ', $myts->makeTboxData4Show($CURRENT_PIC_DATA['keywords']));
    $info[_MD_KEYS] = '<span class="alblink">';
    foreach ($keys as $k) {
        $info[_MD_KEYS] .= "<a href=\"thumbnails.php?album=search&amp;search=" . rawurlencode($k) . "\">{$k}</a> ";
    }
    $info[_MD_KEYS] .= '</span>';
    //$info[_MD_KEYS]   = '<span class="alblink">'.preg_replace("/(\S+)/","<a href=\"thumbnails.php?album=search&amp;search=\\1\">\\1</a>" , $myts->makeTboxData4Show($CURRENT_PIC_DATA['keywords'])).'</span>';
    for ($i = 1; $i <= 4; $i++) {
        if ($xoopsModuleConfig['user_field' . $i . '_name']) {
            $info[$xoopsModuleConfig['user_field' . $i . '_name']] = $CURRENT_PIC_DATA['user' . $i];
        }
    }
    $info[_MD_DIS_FSIZE] = $CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . ' ' . _MD_KB : $CURRENT_PIC_DATA['filesize'] . ' ' . _MD_BYTES;
    $info[_MD_DIS_DIMEMS] = sprintf(_MD_DIS_SIZE, $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
    $info[_MD_DIS_DISPLAYED] = sprintf(_MD_DIS_VIEWS, $CURRENT_PIC_DATA['hits']);
    $info[_MD_DIS_SENT] = sprintf(_MD_DIS_VIEWS, $CURRENT_PIC_DATA['sent_card']);
    $path_to_pic = $xoopsModuleConfig['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
    if ($xoopsModuleConfig['read_exif_data']) {
        $exif = exif_parse_file($path_to_pic);
    }
    if (isset($exif) && is_array($exif)) {
        //Sanitize the data - to fix the XSS vulnarability - Aditya
        foreach ($exif as $key => $data) {
            $exif[$key] = htmlentities(strip_tags(trim($data, "..ÿ..")), ENT_QUOTES);
            //sanitize data against sql/html injection; trim any nongraphical non-ASCII character:
        }
        if (isset($exif['Camera'])) {
            $info[_MD_DIS_CAMERA] = $exif['Camera'];
        }
        if (isset($exif['DateTaken'])) {
            $info[_MD_DIS_DATA_TAKEN] = $exif['DateTaken'];
        }
        if (isset($exif['Aperture'])) {
            $info[_MD_DIS_APERTURE] = $exif['Aperture'];
        }
        if (isset($exif['ExposureTime'])) {
            $info[_MD_DIS_EXPTIME] = $exif['ExposureTime'];
        }
        if (isset($exif['FocalLength'])) {
            $info[_MD_DIS_FLENGTH] = $exif['FocalLength'];
        }
        if (isset($exif['Comment'])) {
            $info[_MD_DIS_COMMENT] = $exif['Comment'];
        }
    }
    if (USER_IS_ADMIN) {
        $info[_MD_DIS_SUBIP] = $CURRENT_PIC_DATA['ip'];
    }
    $xoopsTpl->assign('lang_picinfo_title', _MD_DIS_TITLE);
    $xoopsTpl->assign('picinfo', isset($_COOKIE['picinfo']) ? $_COOKIE['picinfo'] : ($xoopsModuleConfig['display_pic_info'] ? 'block' : 'none'));
    foreach ($info as $key => $value) {
        $xoopsTpl->append('infos', array('key' => $key, 'value' => $value));
    }
}