Ejemplo n.º 1
0
function get_media_code($media_file_name, $image_id = 0, $cat_id = 0, $image_name = "", $mode = "", $show_link = 0, $detailed_view = 0)
{
    global $site_template, $site_sess, $lang, $mode;
    if (!get_file_path($media_file_name, "media", $cat_id, 0, 0)) {
        $media = "<img src=\"" . ICON_PATH . "/404.gif\" border=\"0\" alt=\"\" />";
        $site_template->register_vars("iptc_info", "");
        $site_template->register_vars("exif_info", "");
    } else {
        $media_src = get_file_path($media_file_name, "media", $cat_id, 0, 1);
        $file_extension = get_file_extension($media_file_name);
        $media_icon = "<img src=\"" . ICON_PATH . "/" . $file_extension . ".gif\" border=\"0\" alt=\"" . format_text($image_name, 2) . "\" />";
        if ($show_link) {
            $media_icon = "<a href=\"" . $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_id . (!empty($mode) ? "&amp;mode=" . $mode : "")) . "\">" . $media_icon . "</a>";
        }
        $width_height = "";
        $width = "";
        $height = "";
        $iptc_info = "";
        $exif_info = "";
        if (!is_remote($media_src)) {
            $src = !file_exists($media_src) && file_exists(preg_replace("/\\/{2,}/", "/", get_document_root() . "/" . $media_src)) ? preg_replace("/\\/{2,}/", "/", get_document_root() . "/" . $media_src) : $media_src;
            if (in_array(strtolower($file_extension), array('gif', 'jpg', 'jpeg', 'png', 'swf')) && ($image_info = @getimagesize($src, $info))) {
                $width_height = " " . $image_info[3];
                $width = $image_info[0];
                $height = $image_info[1];
                if ($detailed_view && isset($info['APP13'])) {
                    $iptc_array = get_iptc_info($info['APP13']);
                    $bgcounter = 0;
                    foreach ($iptc_array as $key => $val) {
                        $row_bg_number = $bgcounter++ % 2 == 0 ? 1 : 2;
                        $site_template->register_vars(array("iptc_value" => format_text($val), "iptc_name" => $lang['iptc_' . $key], "row_bg_number" => $row_bg_number));
                        $iptc_info .= $site_template->parse_template("iptc_bit");
                    }
                }
                if ($detailed_view && $image_info[2] == 2 && function_exists('exif_read_data') && ($exif_data = @exif_read_data($src, 'EXIF'))) {
                    $exif_array = get_exif_info($exif_data);
                    $bgcounter = 0;
                    foreach ($exif_array as $key => $val) {
                        $row_bg_number = $bgcounter++ % 2 == 0 ? 1 : 2;
                        $site_template->register_vars(array("exif_value" => format_text($val), "exif_name" => $lang['exif_' . $key], "row_bg_number" => $row_bg_number));
                        $exif_info .= $site_template->parse_template("exif_bit");
                    }
                }
            }
        }
        $site_template->register_vars(array("media_src" => $media_src, "media_icon" => $media_icon, "image_name" => format_text($image_name, 2), "width_height" => $width_height, "width" => $width, "height" => $height, "iptc_info" => $iptc_info, "exif_info" => $exif_info));
        $media = $site_template->parse_template("media/" . $file_extension);
    }
    return $media;
}
Ejemplo n.º 2
0
function view_pic_exif($sn = "")
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $sql = "select exif from " . $xoopsDB->prefix("tad_gallery") . " where sn='{$sn}'";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    list($exif) = $xoopsDB->fetchRow($result);
    $info = explode("||", $exif);
    foreach ($info as $v) {
        $exif_arr = explode("=", $v);
        $exif_arr[1] = str_replace("&#65533;", "", $exif_arr[1]);
        $bb = "\$aa{$exif_arr[0]}=\"{$exif_arr[1]}\";";
        if (empty($exif_arr[0])) {
            continue;
        }
        @eval($bb);
    }
    $exif_all = $exif_data = "";
    foreach ($aa as $k => $v) {
        $exif_data = "";
        foreach ($v as $kk => $vv) {
            $exif_data .= get_exif_info($kk, $vv);
        }
        if (!empty($exif_data)) {
            $exif_all .= $exif_data;
        }
    }
    return "<table style='width:auto;' class='line'>{$exif_all}</table>";
}