Exemplo n.º 1
0
function read_IFD_universal($filehnd, $Tiff_offset, $Byte_Align, $Tag_Definitions_Name, $local_offsets = FALSE, $read_next_ptr = TRUE)
{
    if ($filehnd == NULL || feof($filehnd)) {
        return array(FALSE, 0);
    }
    // Record the Name of the Tag Group used for this IFD in the output array
    $OutputArray['Tags Name'] = $Tag_Definitions_Name;
    // Record the offset of the TIFF header in the output array
    $OutputArray['Tiff Offset'] = $Tiff_offset;
    // First 2 bytes of IFD are number of entries in the IFD
    $No_Entries_str = network_safe_fread($filehnd, 2);
    $No_Entries = get_IFD_Data_Type($No_Entries_str, 3, $Byte_Align);
    // If the data is corrupt, the number of entries may be huge, which will cause errors
    // This is often caused by a lack of a Next-IFD pointer
    if ($No_Entries > 10000) {
        // Huge number of entries - abort
        echo "<p>Error: huge number of EXIF entries - EXIF is probably Corrupted</p>\n";
        return array(FALSE, 0);
    }
    // If the data is corrupt or just stupid, the number of entries may zero,
    // Indicate this by returning false
    if ($No_Entries === 0) {
        // No entries - abort
        return array(FALSE, 0);
    }
    // Save the file position where first IFD record starts as non-standard offsets
    // need to know this to calculate an absolute offset
    $IFD_first_rec_pos = ftell($filehnd);
    // Read in the IFD structure
    $IFD_Data = network_safe_fread($filehnd, 12 * $No_Entries);
    // Check if the entire IFD was able to be read
    if (strlen($IFD_Data) != 12 * $No_Entries) {
        // Couldn't read the IFD Data properly, Some Casio files have no Next IFD pointer, hence cause this error
        echo "<p>Error: EXIF Corrupted</p>\n";
        return array(FALSE, 0);
    }
    // Last 4 bytes of a standard IFD are the offset to the next IFD
    // Some NON-Standard IFD implementations do not have this, hence causing problems if it is read
    // If the Next IFD pointer has been requested to be read,
    if ($read_next_ptr) {
        // Read the pointer to the next IFD
        $Next_Offset_str = network_safe_fread($filehnd, 4);
        $Next_Offset = get_IFD_Data_Type($Next_Offset_str, 4, $Byte_Align);
    } else {
        // Otherwise set the pointer to zero ( no next IFD )
        $Next_Offset = 0;
    }
    // Initialise current position to the start
    $pos = 0;
    // Loop for reading IFD entries
    for ($i = 0; $i < $No_Entries; $i++) {
        // First 2 bytes of IFD entry are the tag number ( Unsigned Short )
        $Tag_No_str = substr($IFD_Data, $pos, 2);
        $Tag_No = get_IFD_Data_Type($Tag_No_str, 3, $Byte_Align);
        $pos += 2;
        // Next 2 bytes of IFD entry are the data format ( Unsigned Short )
        $Data_Type_str = substr($IFD_Data, $pos, 2);
        $Data_Type = get_IFD_Data_Type($Data_Type_str, 3, $Byte_Align);
        $pos += 2;
        // If Datatype is not between 1 and 12, then skip this entry, it is probably corrupted or custom
        if ($Data_Type > 12 || $Data_Type < 1) {
            $pos += 8;
            continue 1;
            // Stop trying to process the tag any further and skip to the next one
        }
        // Next 4 bytes of IFD entry are the data count ( Unsigned Long )
        $Data_Count_str = substr($IFD_Data, $pos, 4);
        $Data_Count = get_IFD_Data_Type($Data_Count_str, 4, $Byte_Align);
        $pos += 4;
        if ($Data_Count > 100000) {
            echo "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n";
            // Some Casio files have no Next IFD pointer, hence cause errors
            return array(FALSE, 0);
        }
        // Total Data size is the Data Count multiplied by the size of the Data Type
        $Total_Data_Size = $GLOBALS['IFD_Data_Sizes'][$Data_Type] * $Data_Count;
        $Data_Start_pos = -1;
        // If the total data size is larger than 4 bytes, then the data part is the offset to the real data
        if ($Total_Data_Size > 4) {
            // Not enough room for data - offset provided instead
            $Data_Offset_str = substr($IFD_Data, $pos, 4);
            $Data_Start_pos = get_IFD_Data_Type($Data_Offset_str, 4, $Byte_Align);
            // In some NON-STANDARD makernotes, the offset is relative to the start of the current IFD entry
            if ($local_offsets) {
                // This is a NON-Standard IFD, seek relative to the start of the current tag
                fseek($filehnd, $IFD_first_rec_pos + $pos - 8 + $Data_Start_pos);
            } else {
                // This is a normal IFD, seek relative to the start of the TIFF header
                fseek($filehnd, $Tiff_offset + $Data_Start_pos);
            }
            // Read the data block from the offset position
            $DataStr = network_safe_fread($filehnd, $Total_Data_Size);
        } else {
            // The data block is less than 4 bytes, and is provided in the IFD entry, so read it
            $DataStr = substr($IFD_Data, $pos, $Total_Data_Size);
        }
        // Increment the position past the data
        $pos += 4;
        // Now create the entry for output array
        $Data_Array = array();
        // Read the data items from the data block
        if ($Data_Type != 2 && $Data_Type != 7) {
            // The data type is Numerical, Read the data items from the data block
            for ($j = 0; $j < $Data_Count; $j++) {
                $Part_Data_Str = substr($DataStr, $j * $GLOBALS['IFD_Data_Sizes'][$Data_Type], $GLOBALS['IFD_Data_Sizes'][$Data_Type]);
                $Data_Array[] = get_IFD_Data_Type($Part_Data_Str, $Data_Type, $Byte_Align);
            }
        } elseif ($Data_Type == 2) {
            // The data type is String(s)   (type 2)
            // Strip the last terminating Null
            $DataStr = substr($DataStr, 0, strlen($DataStr) - 1);
            // Split the data block into multiple strings whereever there is a Null
            $Data_Array = explode("", $DataStr);
        } else {
            // The data type is Unknown (type 7)
            // Do nothing to data
            $Data_Array = $DataStr;
        }
        // If this is a Sub-IFD entry,
        if (array_key_exists($Tag_No, $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name]) && "SubIFD" == $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Type']) {
            // This is a Sub-IFD entry, go and process the data forming Sub-IFD and use its output array as the new data for this entry
            fseek($filehnd, $Tiff_offset + $Data_Array[0]);
            $Data_Array = read_Multiple_IFDs($filehnd, $Tiff_offset, $Byte_Align, $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Tags Name']);
        }
        $desc = "";
        $units = "";
        // Check if this tag exists in the list of tag definitions,
        if (array_key_exists($Tag_No, $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name])) {
            if (array_key_exists('Description', $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No])) {
                $desc = $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Description'];
            }
            if (array_key_exists('Units', $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No])) {
                $units = $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Units'];
            }
            // Tag exists in definitions, append details to output array
            $OutputArray[$Tag_No] = array("Tag Number" => $Tag_No, "Tag Name" => $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Name'], "Tag Description" => $desc, "Data Type" => $Data_Type, "Type" => $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag_No]['Type'], "Units" => $units, "Data" => $Data_Array);
        } else {
            // Tag doesnt exist in definitions, append unknown details to output array
            $OutputArray[$Tag_No] = array("Tag Number" => $Tag_No, "Tag Name" => "Unknown Tag #" . $Tag_No, "Tag Description" => "", "Data Type" => $Data_Type, "Type" => "Unknown", "Units" => "", "Data" => $Data_Array);
        }
        // Some information of type "Unknown" (type 7) might require information about
        // how it's position and byte alignment in order to be decoded
        if ($Data_Type == 7) {
            $OutputArray[$Tag_No]['Offset'] = $Data_Start_pos;
            $OutputArray[$Tag_No]['Byte Align'] = $Byte_Align;
        }
        ////////////////////////////////////////////////////////////////////////
        // Special Data handling
        ////////////////////////////////////////////////////////////////////////
        // Check if this is a Print Image Matching entry
        if ($OutputArray[$Tag_No]['Type'] == "PIM") {
            // This is a Print Image Matching entry, decode it.
            $OutputArray[$Tag_No] = Decode_PIM($OutputArray[$Tag_No], $Tag_Definitions_Name);
        }
        // Interpret the entry into a text string using a custom interpreter
        $text_val = get_Tag_Text_Value($OutputArray[$Tag_No], $Tag_Definitions_Name);
        // Check if a text string was generated
        if ($text_val !== FALSE) {
            // A string was generated, append it to the output array entry
            $OutputArray[$Tag_No]['Text Value'] = $text_val;
            $OutputArray[$Tag_No]['Decoded'] = TRUE;
        } else {
            // A string was NOT generated, append a generic string to the output array entry
            $OutputArray[$Tag_No]['Text Value'] = get_IFD_value_as_text($OutputArray[$Tag_No]) . " " . $units;
            $OutputArray[$Tag_No]['Decoded'] = FALSE;
        }
        // Check if this entry is the Maker Note
        if ($Tag_Definitions_Name == "EXIF" && $Tag_No == 37500) {
            // Save some extra information which will allow Makernote Decoding with the output array entry
            $OutputArray[$Tag_No]['Offset'] = $Data_Start_pos;
            $OutputArray[$Tag_No]['Tiff Offset'] = $Tiff_offset;
            $OutputArray[$Tag_No]['ByteAlign'] = $Byte_Align;
            // Save a pointer to this entry for Maker note processing later
            $GLOBALS["Maker_Note_Tag"] =& $OutputArray[$Tag_No];
        }
        // Check if this is a IPTC/NAA Record within the EXIF IFD
        if (($Tag_Definitions_Name == "EXIF" || $Tag_Definitions_Name == "TIFF") && $Tag_No == 33723) {
            // This is a IPTC/NAA Record, interpret it and put result in the data for this entry
            $OutputArray[$Tag_No]['Data'] = get_IPTC($DataStr);
            $OutputArray[$Tag_No]['Decoded'] = TRUE;
        }
        // Change: Check for embedded XMP as of version 1.11
        // Check if this is a XMP Record within the EXIF IFD
        if (($Tag_Definitions_Name == "EXIF" || $Tag_Definitions_Name == "TIFF") && $Tag_No == 700) {
            // This is a XMP Record, interpret it and put result in the data for this entry
            $OutputArray[$Tag_No]['Data'] = read_XMP_array_from_text($DataStr);
            $OutputArray[$Tag_No]['Decoded'] = TRUE;
        }
        // Change: Check for embedded IRB as of version 1.11
        // Check if this is a Photoshop IRB Record within the EXIF IFD
        if (($Tag_Definitions_Name == "EXIF" || $Tag_Definitions_Name == "TIFF") && $Tag_No == 34377) {
            // This is a Photoshop IRB Record, interpret it and put result in the data for this entry
            $OutputArray[$Tag_No]['Data'] = unpack_Photoshop_IRB_Data($DataStr);
            $OutputArray[$Tag_No]['Decoded'] = TRUE;
        }
        // Exif Thumbnail
        // Check that both the thumbnail length and offset entries have been processed,
        // and that this is one of them
        if (($Tag_No == 513 && array_key_exists(514, $OutputArray) || $Tag_No == 514 && array_key_exists(513, $OutputArray)) && $Tag_Definitions_Name == "TIFF") {
            // Seek to the start of the thumbnail using the offset entry
            fseek($filehnd, $Tiff_offset + $OutputArray[513]['Data'][0]);
            // Read the thumbnail data, and replace the offset data with the thumbnail
            $OutputArray[513]['Data'] = network_safe_fread($filehnd, $OutputArray[514]['Data'][0]);
        }
        // Casio Thumbnail
        // Check that both the thumbnail length and offset entries have been processed,
        // and that this is one of them
        if (($Tag_No == 0x4 && array_key_exists(0x3, $OutputArray) || $Tag_No == 0x3 && array_key_exists(0x4, $OutputArray)) && $Tag_Definitions_Name == "Casio Type 2") {
            // Seek to the start of the thumbnail using the offset entry
            fseek($filehnd, $Tiff_offset + $OutputArray[0x4]['Data'][0]);
            // Read the thumbnail data, and replace the offset data with the thumbnail
            $OutputArray[0x4]['Data'] = network_safe_fread($filehnd, $OutputArray[0x3]['Data'][0]);
        }
        // Minolta Thumbnail
        // Check that both the thumbnail length and offset entries have been processed,
        // and that this is one of them
        if (($Tag_No == 0x88 && array_key_exists(0x89, $OutputArray) || $Tag_No == 0x89 && array_key_exists(0x88, $OutputArray)) && $Tag_Definitions_Name == "Olympus") {
            // Seek to the start of the thumbnail using the offset entry
            fseek($filehnd, $Tiff_offset + $OutputArray[0x88]['Data'][0]);
            // Read the thumbnail data, and replace the offset data with the thumbnail
            $OutputArray[0x88]['Data'] = network_safe_fread($filehnd, $OutputArray[0x89]['Data'][0]);
            // Sometimes the minolta thumbnail data is empty (or the offset is corrupt, which results in the same thing)
            // Check if the thumbnail data exists
            if ($OutputArray[0x88]['Data'] != "") {
                // Thumbnail exists
                // Minolta Thumbnails are missing their first 0xFF for some reason,
                // which is replaced with some weird character, so fix this
                $OutputArray[0x88]['Data'][0] = "ÿ";
            } else {
                // Thumbnail doesnt exist - make it obvious
                $OutputArray[0x88]['Data'] = FALSE;
            }
        }
    }
    // Return the array of IFD entries and the offset to the next IFD
    return array($OutputArray, $Next_Offset);
}
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
{
    global $CONFIG, $USER_DATA, $PIC_NEED_APPROVAL, $CURRENT_PIC_DATA;
    global $lang_errors, $lang_db_input_php;
    $image = $CONFIG['fullpath'] . $filepath . $filename;
    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
    $orig = $CONFIG['fullpath'] . $filepath . $CONFIG['orig_pfx'] . $filename;
    // $mini = $CONFIG['fullpath'] . $filepath . $CONFIG['mini_pfx'] . $filename;
    $work_image = $image;
    if (!is_known_filetype($image)) {
        return array('error' => $lang_db_input_php['err_invalid_fext'] . ' ' . $CONFIG['allowed_file_extensions'], 'halt_upload' => 0);
    } elseif (is_image($filename)) {
        $imagesize = cpg_getimagesize($image);
        if ($CONFIG['read_iptc_data']) {
            // read IPTC data
            $iptc = get_IPTC($image);
            if (is_array($iptc) && !$title && !$caption && !$keywords) {
                //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
                $title = isset($iptc['Headline']) ? trim($iptc['Headline']) : $title;
                $caption = isset($iptc['Caption']) ? trim($iptc['Caption']) : $caption;
                $keywords = isset($iptc['Keywords']) ? implode($CONFIG['keyword_separator'], $iptc['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_method = $CONFIG['picture_use'] == "thumb" ? $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'] : $CONFIG['picture_use'];
                resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $resize_method, 'false');
                $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 ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($imagesize[0], $imagesize[1]) && !file_exists($normal)) {
            // 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;
            }
        }
    } else {
        $imagesize[0] = $iwidth;
        $imagesize[1] = $iheight;
    }
    clearstatcache();
    $image_filesize = filesize($image);
    $total_filesize = is_image($filename) ? $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb) : $image_filesize;
    // Test if disk quota exceeded
    if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'] && $category == FIRST_USER_CAT + USER_ID) {
        $result = cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
        $record = mysql_fetch_array($result);
        $total_space_used = $record[0];
        mysql_free_result($result);
        if ($total_space_used + $total_filesize >> 10 > $USER_DATA['group_quota']) {
            @unlink($image);
            if (is_image($image)) {
                @unlink($normal);
                @unlink($thumb);
            }
            $msg = $lang_errors['quota_exceeded'] . '<br />&nbsp;<br />' . strtr($lang_errors['quota_exceeded_details'], array('[quota]' => $USER_DATA['group_quota'], '[space]' => $total_space_used >> 10));
            return array('error' => $msg, 'halt_upload' => 1);
        }
    }
    // Test if picture requires approval
    if (GALLERY_ADMIN_MODE) {
        $approved = 'YES';
    } elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
        $approved = 'YES';
    } elseif (!$USER_DATA['pub_upl_need_approval'] && $category < FIRST_USER_CAT) {
        $approved = 'YES';
    } else {
        $approved = 'NO';
    }
    $PIC_NEED_APPROVAL = $approved == 'NO';
    // User ID is recorded when in admin mode
    $user_id = USER_ID;
    // Populate Array to pass to plugins, then to SQL
    $CURRENT_PIC_DATA['aid'] = $aid;
    $CURRENT_PIC_DATA['filepath'] = $filepath;
    $CURRENT_PIC_DATA['filename'] = $filename;
    $CURRENT_PIC_DATA['filesize'] = $image_filesize;
    $CURRENT_PIC_DATA['total_filesize'] = $total_filesize;
    $CURRENT_PIC_DATA['pwidth'] = $imagesize[0];
    $CURRENT_PIC_DATA['pheight'] = $imagesize[1];
    $CURRENT_PIC_DATA['owner_id'] = $user_id;
    $CURRENT_PIC_DATA['title'] = $title;
    $CURRENT_PIC_DATA['caption'] = $caption;
    $CURRENT_PIC_DATA['keywords'] = $keywords;
    $CURRENT_PIC_DATA['approved'] = $approved;
    $CURRENT_PIC_DATA['user1'] = $user1;
    $CURRENT_PIC_DATA['user2'] = $user2;
    $CURRENT_PIC_DATA['user3'] = $user3;
    $CURRENT_PIC_DATA['user4'] = $user4;
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA['guest_token'] = USER_ID == 0 ? cpg_get_guest_token() : '';
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data', $CURRENT_PIC_DATA);
    if (USER_ID > 0 || $CONFIG['allow_guests_enter_file_details'] == 1) {
        $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, guest_token) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}')";
    } else {
        $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, guest_token) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '', '', '', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}')";
    }
    $result = cpg_db_query($query);
    // Put the pid in current_pic_data and call the plugin filter for file data success
    $CURRENT_PIC_DATA['pid'] = mysql_insert_id($CONFIG['LINK_ID']);
    CPGPluginAPI::action('add_file_data_success', $CURRENT_PIC_DATA);
    //return $result;
    return true;
}
Exemplo n.º 3
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);
}
function Interpret_IRB_to_HTML($IRB_array, $filename)
{
    // Create a string to receive the HTML
    $output_str = "";
    // Check if the Photoshop IRB array is valid
    if ($IRB_array !== FALSE) {
        // Create another string to receive secondary HTML to be appended at the end
        $secondary_output_str = "";
        // Add the Heading to the HTML
        $output_str .= "<h2 class=\"Photoshop_Main_Heading\">Contains Photoshop Information Resource Block (IRB)</h2>";
        // Add Table to the HTML
        $output_str .= "<table class=\"Photoshop_Table\" border=1>\n";
        // Cycle through each of the Photoshop IRB records, creating HTML for each
        foreach ($IRB_array as $IRB_Resource) {
            // Check if the entry is a known Photoshop IRB resource
            // Get the Name of the Resource
            if (array_key_exists($IRB_Resource['ResID'], $GLOBALS["Photoshop_ID_Names"])) {
                $Resource_Name = $GLOBALS['Photoshop_ID_Names'][$IRB_Resource['ResID']];
            } else {
                // Unknown Resource - Make appropriate name
                $Resource_Name = "Unknown Resource (" . $IRB_Resource['ResID'] . ")";
            }
            // Add HTML for the resource as appropriate
            switch ($IRB_Resource['ResID']) {
                case 0x404:
                    // IPTC-NAA IIM Record
                    $secondary_output_str .= Interpret_IPTC_to_HTML(get_IPTC($IRB_Resource['ResData']));
                    break;
                case 0x40b:
                    // URL
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><a href=\"" . $IRB_Resource['ResData'] . "\">" . htmlentities($IRB_Resource['ResData']) . "</a></td></tr>\n";
                    break;
                case 0x40a:
                    // Copyright Marked
                    if (hexdec(bin2hex($IRB_Resource['ResData'])) == 1) {
                        $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Image is Copyrighted Material</pre></td></tr>\n";
                    } else {
                        $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Image is Not Copyrighted Material</pre></td></tr>\n";
                    }
                    break;
                case 0x40d:
                    // Global Lighting Angle
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Global lighting angle for effects layer = " . hexdec(bin2hex($IRB_Resource['ResData'])) . " degrees</pre></td></tr>\n";
                    break;
                case 0x419:
                    // Global Altitude
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Global Altitude = " . hexdec(bin2hex($IRB_Resource['ResData'])) . "</pre></td></tr>\n";
                    break;
                case 0x421:
                    // Version Info
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Version = " . hexdec(bin2hex(substr($IRB_Resource['ResData'], 0, 4))) . "\n";
                    $output_str .= "Has Real Merged Data = " . ord($IRB_Resource['ResData'][4]) . "\n";
                    $writer_size = hexdec(bin2hex(substr($IRB_Resource['ResData'], 5, 4))) * 2;
                    $output_str .= "Writer Name = " . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], 9, $writer_size), TRUE) . "\n";
                    $reader_size = hexdec(bin2hex(substr($IRB_Resource['ResData'], 9 + $writer_size, 4))) * 2;
                    $output_str .= "Reader Name = " . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], 13 + $writer_size, $reader_size), TRUE) . "\n";
                    $output_str .= "File Version = " . hexdec(bin2hex(substr($IRB_Resource['ResData'], 13 + $writer_size + $reader_size, 4))) . "\n";
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x411:
                    // ICC Untagged
                    if ($IRB_Resource['ResData'] == "") {
                        $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Intentionally untagged - any assumed ICC profile handling disabled</pre></td></tr>\n";
                    } else {
                        $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>Unknown value (0x" . bin2hex($IRB_Resource['ResData']) . ")</pre></td></tr>\n";
                    }
                    break;
                case 0x41a:
                    // Slices
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\">";
                    // Unpack the first 24 bytes
                    $Slices_Info = unpack("NVersion/NBound_top/NBound_left/NBound_bottom/NBound_right/NStringlen", $IRB_Resource['ResData']);
                    $output_str .= "Version = " . $Slices_Info['Version'] . "<br>\n";
                    $output_str .= "Bounding Rectangle =  Top:" . $Slices_Info['Bound_top'] . ", Left:" . $Slices_Info['Bound_left'] . ", Bottom:" . $Slices_Info['Bound_bottom'] . ", Right:" . $Slices_Info['Bound_right'] . " (Pixels)<br>\n";
                    $Slicepos = 24;
                    // Extract a Unicode String
                    $output_str .= "Text = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], 24, $Slices_Info['Stringlen'] * 2), TRUE) . "'<br>\n";
                    $Slicepos += $Slices_Info['Stringlen'] * 2;
                    // Unpack the number of Slices
                    $Num_Slices = hexdec(bin2hex(substr($IRB_Resource['ResData'], $Slicepos, 4)));
                    $output_str .= "Number of Slices = " . $Num_Slices . "\n";
                    $Slicepos += 4;
                    // Cycle through the slices
                    for ($i = 1; $i <= $Num_Slices; $i++) {
                        $output_str .= "<br><br>Slice {$i}:<br>\n";
                        // Unpack the first 16 bytes of the slice
                        $SliceA = unpack("NID/NGroupID/NOrigin/NStringlen", substr($IRB_Resource['ResData'], $Slicepos));
                        $Slicepos += 16;
                        $output_str .= "ID = " . $SliceA['ID'] . "<br>\n";
                        $output_str .= "Group ID = " . $SliceA['GroupID'] . "<br>\n";
                        $output_str .= "Origin = " . $SliceA['Origin'] . "<br>\n";
                        // Extract a Unicode String
                        $output_str .= "Text = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $SliceA['Stringlen'] * 2), TRUE) . "'<br>\n";
                        $Slicepos += $SliceA['Stringlen'] * 2;
                        // Unpack the next 24 bytes of the slice
                        $SliceB = unpack("NType/NLeftPos/NTopPos/NRightPos/NBottomPos/NURLlen", substr($IRB_Resource['ResData'], $Slicepos));
                        $Slicepos += 24;
                        $output_str .= "Type = " . $SliceB['Type'] . "<br>\n";
                        $output_str .= "Position =  Top:" . $SliceB['TopPos'] . ", Left:" . $SliceB['LeftPos'] . ", Bottom:" . $SliceB['BottomPos'] . ", Right:" . $SliceB['RightPos'] . " (Pixels)<br>\n";
                        // Extract a Unicode String
                        $output_str .= "URL = <a href='" . substr($IRB_Resource['ResData'], $Slicepos, $SliceB['URLlen'] * 2) . "'>" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $SliceB['URLlen'] * 2), TRUE) . "</a><br>\n";
                        $Slicepos += $SliceB['URLlen'] * 2;
                        // Unpack the length of a Unicode String
                        $Targetlen = hexdec(bin2hex(substr($IRB_Resource['ResData'], $Slicepos, 4)));
                        $Slicepos += 4;
                        // Extract a Unicode String
                        $output_str .= "Target = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $Targetlen * 2), TRUE) . "'<br>\n";
                        $Slicepos += $Targetlen * 2;
                        // Unpack the length of a Unicode String
                        $Messagelen = hexdec(bin2hex(substr($IRB_Resource['ResData'], $Slicepos, 4)));
                        $Slicepos += 4;
                        // Extract a Unicode String
                        $output_str .= "Message = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $Messagelen * 2), TRUE) . "'<br>\n";
                        $Slicepos += $Messagelen * 2;
                        // Unpack the length of a Unicode String
                        $AltTaglen = hexdec(bin2hex(substr($IRB_Resource['ResData'], $Slicepos, 4)));
                        $Slicepos += 4;
                        // Extract a Unicode String
                        $output_str .= "Alt Tag = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $AltTaglen * 2), TRUE) . "'<br>\n";
                        $Slicepos += $AltTaglen * 2;
                        // Unpack the HTML flag
                        if (ord($IRB_Resource['ResData'][$Slicepos]) === 0x1) {
                            $output_str .= "Cell Text is HTML<br>\n";
                        } else {
                            $output_str .= "Cell Text is NOT HTML<br>\n";
                        }
                        $Slicepos++;
                        // Unpack the length of a Unicode String
                        $CellTextlen = hexdec(bin2hex(substr($IRB_Resource['ResData'], $Slicepos, 4)));
                        $Slicepos += 4;
                        // Extract a Unicode String
                        $output_str .= "Cell Text = '" . HTML_UTF16_Escape(substr($IRB_Resource['ResData'], $Slicepos, $CellTextlen * 2), TRUE) . "'<br>\n";
                        $Slicepos += $CellTextlen * 2;
                        // Unpack the last 12 bytes of the slice
                        $SliceC = unpack("NAlignH/NAlignV/CAlpha/CRed/CGreen/CBlue", substr($IRB_Resource['ResData'], $Slicepos));
                        $Slicepos += 12;
                        $output_str .= "Alignment =  Horizontal:" . $SliceC['AlignH'] . ", Vertical:" . $SliceC['AlignV'] . "<br>\n";
                        $output_str .= "Alpha Colour = " . $SliceC['Alpha'] . "<br>\n";
                        $output_str .= "Red = " . $SliceC['Red'] . "<br>\n";
                        $output_str .= "Green = " . $SliceC['Green'] . "<br>\n";
                        $output_str .= "Blue = " . $SliceC['Blue'] . "\n";
                    }
                    $output_str .= "</td></tr>\n";
                    break;
                case 0x408:
                    // Grid and Guides information
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\">";
                    // Unpack the Grids info
                    $Grid_Info = unpack("NVersion/NGridCycleH/NGridCycleV/NGuideCount", $IRB_Resource['ResData']);
                    $output_str .= "Version = " . $Grid_Info['Version'] . "<br>\n";
                    $output_str .= "Grid Cycle = " . $Grid_Info['GridCycleH'] / 32 . " Pixel(s)  x  " . $Grid_Info['GridCycleV'] / 32 . " Pixel(s)<br>\n";
                    $output_str .= "Number of Guides = " . $Grid_Info['GuideCount'] . "\n";
                    // Cycle through the Guides
                    for ($i = 0; $i < $Grid_Info['GuideCount']; $i++) {
                        // Unpack the info for this guide
                        $Guide_Info = unpack("NLocation/CDirection", substr($IRB_Resource['ResData'], 16 + $i * 5, 5));
                        $output_str .= "<br>Guide {$i} : Location = " . $Guide_Info['Location'] / 32 . " Pixel(s) from edge";
                        if ($Guide_Info['Direction'] === 0) {
                            $output_str .= ", Vertical\n";
                        } else {
                            $output_str .= ", Horizontal\n";
                        }
                    }
                    break;
                    $output_str .= "</td></tr>\n";
                case 0x406:
                    // JPEG Quality
                    $Qual_Info = unpack("nQuality/nFormat/nScans/Cconst", $IRB_Resource['ResData']);
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\">";
                    switch ($Qual_Info['Quality']) {
                        case 0xfffd:
                            $output_str .= "Quality 1 (Low)<br>\n";
                            break;
                        case 0xfffe:
                            $output_str .= "Quality 2 (Low)<br>\n";
                            break;
                        case 0xffff:
                            $output_str .= "Quality 3 (Low)<br>\n";
                            break;
                        case 0x0:
                            $output_str .= "Quality 4 (Low)<br>\n";
                            break;
                        case 0x1:
                            $output_str .= "Quality 5 (Medium)<br>\n";
                            break;
                        case 0x2:
                            $output_str .= "Quality 6 (Medium)<br>\n";
                            break;
                        case 0x3:
                            $output_str .= "Quality 7 (Medium)<br>\n";
                            break;
                        case 0x4:
                            $output_str .= "Quality 8 (High)<br>\n";
                            break;
                        case 0x5:
                            $output_str .= "Quality 9 (High)<br>\n";
                            break;
                        case 0x6:
                            $output_str .= "Quality 10 (Maximum)<br>\n";
                            break;
                        case 0x7:
                            $output_str .= "Quality 11 (Maximum)<br>\n";
                            break;
                        case 0x8:
                            $output_str .= "Quality 12 (Maximum)<br>\n";
                            break;
                        default:
                            $output_str .= "Unknown Quality (" . $Qual_Info['Quality'] . ")<br>\n";
                            break;
                    }
                    switch ($Qual_Info['Format']) {
                        case 0x0:
                            $output_str .= "Standard Format\n";
                            break;
                        case 0x1:
                            $output_str .= "Optimised Format\n";
                            break;
                        case 0x101:
                            $output_str .= "Progressive Format<br>\n";
                            break;
                        default:
                            $output_str .= "Unknown Format (" . $Qual_Info['Format'] . ")\n";
                            break;
                    }
                    if ($Qual_Info['Format'] == 0x101) {
                        switch ($Qual_Info['Scans']) {
                            case 0x1:
                                $output_str .= "3 Scans\n";
                                break;
                            case 0x2:
                                $output_str .= "4 Scans\n";
                                break;
                            case 0x3:
                                $output_str .= "5 Scans\n";
                                break;
                            default:
                                $output_str .= "Unknown number of scans (" . $Qual_Info['Scans'] . ")\n";
                                break;
                        }
                    }
                    $output_str .= "</td></tr>\n";
                    break;
                case 0x409:
                    // Thumbnail Resource
                // Thumbnail Resource
                case 0x40c:
                    // Thumbnail Resource
                    $thumb_data = unpack("NFormat/NWidth/NHeight/NWidthBytes/NSize/NCompressedSize/nBitsPixel/nPlanes", $IRB_Resource['ResData']);
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Format = " . ($thumb_data['Format'] == 1 ? "JPEG RGB\n" : "Raw RGB\n");
                    $output_str .= "Width = " . $thumb_data['Width'] . "\n";
                    $output_str .= "Height = " . $thumb_data['Height'] . "\n";
                    $output_str .= "Padded Row Bytes = " . $thumb_data['WidthBytes'] . " bytes\n";
                    $output_str .= "Total Size = " . $thumb_data['Size'] . " bytes\n";
                    $output_str .= "Compressed Size = " . $thumb_data['CompressedSize'] . " bytes\n";
                    $output_str .= "Bits per Pixel = " . $thumb_data['BitsPixel'] . " bits\n";
                    $output_str .= "Number of planes = " . $thumb_data['Planes'] . " bytes\n";
                    $output_str .= "Thumbnail Data:</pre><a class=\"Photoshop_Thumbnail_Link\" href=\"get_ps_thumb.php?filename={$filename}\"><img class=\"Photoshop_Thumbnail_Link\" src=\"get_ps_thumb.php?filename={$filename}\"></a>\n";
                    $output_str .= "</td></tr>\n";
                    break;
                case 0x414:
                    // Document Specific ID's
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>" . hexdec(bin2hex($IRB_Resource['ResData'])) . "</pre></td></tr>\n";
                    break;
                case 0x41e:
                    // URL List
                    $URL_count = hexdec(bin2hex(substr($IRB_Resource['ResData'], 0, 4)));
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\">\n";
                    $output_str .= "{$URL_count} URL's in list<br>\n";
                    $urlstr = substr($IRB_Resource['ResData'], 4);
                    // TODO: Check if URL List in Photoshop IRB works
                    for ($i = 0; $i < $URL_count; $i++) {
                        $url_data = unpack("NLong/NID/NURLSize", $urlstr);
                        $output_str .= "URL {$i} info: long = " . $url_data['Long'] . ", ";
                        $output_str .= "ID = " . $url_data['ID'] . ", ";
                        $urlstr = substr($urlstr, 12);
                        $url = substr($urlstr, 0, $url_data['URLSize']);
                        $output_str .= "URL = <a href=\"" . xml_UTF16_clean($url, TRUE) . "\">" . HTML_UTF16_Escape($url, TRUE) . "</a><br>\n";
                    }
                    $output_str .= "</td></tr>\n";
                    break;
                case 0x3f4:
                    // Grayscale and multichannel halftoning information.
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= Interpret_Halftone($IRB_Resource['ResData']);
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x3f5:
                    // Color halftoning information
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Cyan Halftoning Info:\n" . Interpret_Halftone(substr($IRB_Resource['ResData'], 0, 18)) . "\n\n";
                    $output_str .= "Magenta Halftoning Info:\n" . Interpret_Halftone(substr($IRB_Resource['ResData'], 18, 18)) . "\n\n";
                    $output_str .= "Yellow Halftoning Info:\n" . Interpret_Halftone(substr($IRB_Resource['ResData'], 36, 18)) . "\n";
                    $output_str .= "Black Halftoning Info:\n" . Interpret_Halftone(substr($IRB_Resource['ResData'], 54, 18)) . "\n";
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x3f7:
                    // Grayscale and multichannel transfer function.
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= Interpret_Transfer_Function(substr($IRB_Resource['ResData'], 0, 28));
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x3f8:
                    // Color transfer functions
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Red Transfer Function:   \n" . Interpret_Transfer_Function(substr($IRB_Resource['ResData'], 0, 28)) . "\n\n";
                    $output_str .= "Green Transfer Function: \n" . Interpret_Transfer_Function(substr($IRB_Resource['ResData'], 28, 28)) . "\n\n";
                    $output_str .= "Blue Transfer Function:  \n" . Interpret_Transfer_Function(substr($IRB_Resource['ResData'], 56, 28)) . "\n";
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x3f3:
                    // Print Flags
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    if ($IRB_Resource['ResData'][0] == "") {
                        $output_str .= "Labels Selected\n";
                    } else {
                        $output_str .= "Labels Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][1] == "") {
                        $output_str .= "Crop Marks Selected\n";
                    } else {
                        $output_str .= "Crop Marks Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][2] == "") {
                        $output_str .= "Color Bars Selected\n";
                    } else {
                        $output_str .= "Color Bars Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][3] == "") {
                        $output_str .= "Registration Marks Selected\n";
                    } else {
                        $output_str .= "Registration Marks Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][4] == "") {
                        $output_str .= "Negative Selected\n";
                    } else {
                        $output_str .= "Negative Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][5] == "") {
                        $output_str .= "Flip Selected\n";
                    } else {
                        $output_str .= "Flip Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][6] == "") {
                        $output_str .= "Interpolate Selected\n";
                    } else {
                        $output_str .= "Interpolate Not Selected\n";
                    }
                    if ($IRB_Resource['ResData'][7] == "") {
                        $output_str .= "Caption Selected";
                    } else {
                        $output_str .= "Caption Not Selected";
                    }
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x2710:
                    // Print Flags Information
                    $PrintFlags = unpack("nVersion/CCentCrop/Cjunk/NBleedWidth/nBleedWidthScale", $IRB_Resource['ResData']);
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Version = " . $PrintFlags['Version'] . "\n";
                    $output_str .= "Centre Crop Marks = " . $PrintFlags['CentCrop'] . "\n";
                    $output_str .= "Bleed Width = " . $PrintFlags['BleedWidth'] . "\n";
                    $output_str .= "Bleed Width Scale = " . $PrintFlags['BleedWidthScale'];
                    $output_str .= "</pre></td></tr>\n";
                    break;
                case 0x3ed:
                    // Resolution Info
                    $ResInfo = unpack("nhRes_int/nhResdec/nhResUnit/nwidthUnit/nvRes_int/nvResdec/nvResUnit/nheightUnit", $IRB_Resource['ResData']);
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\"><pre>\n";
                    $output_str .= "Horizontal Resolution = " . ($ResInfo['hRes_int'] + $ResInfo['hResdec'] / 65536) . " pixels per Inch\n";
                    $output_str .= "Vertical Resolution = " . ($ResInfo['vRes_int'] + $ResInfo['vResdec'] / 65536) . " pixels per Inch\n";
                    if ($ResInfo['hResUnit'] == 1) {
                        $output_str .= "Display units for Horizontal Resolution = Pixels per Inch\n";
                    } elseif ($ResInfo['hResUnit'] == 2) {
                        $output_str .= "Display units for Horizontal Resolution = Pixels per Centimetre\n";
                    } else {
                        $output_str .= "Display units for Horizontal Resolution = Unknown Value (" . $ResInfo['hResUnit'] . ")\n";
                    }
                    if ($ResInfo['vResUnit'] == 1) {
                        $output_str .= "Display units for Vertical Resolution = Pixels per Inch\n";
                    } elseif ($ResInfo['vResUnit'] == 2) {
                        $output_str .= "Display units for Vertical Resolution = Pixels per Centimetre\n";
                    } else {
                        $output_str .= "Display units for Vertical Resolution = Unknown Value (" . $ResInfo['vResUnit'] . ")\n";
                    }
                    if ($ResInfo['widthUnit'] == 1) {
                        $output_str .= "Display units for Image Width = Inches\n";
                    } elseif ($ResInfo['widthUnit'] == 2) {
                        $output_str .= "Display units for Image Width = Centimetres\n";
                    } elseif ($ResInfo['widthUnit'] == 3) {
                        $output_str .= "Display units for Image Width = Points\n";
                    } elseif ($ResInfo['widthUnit'] == 4) {
                        $output_str .= "Display units for Image Width = Picas\n";
                    } elseif ($ResInfo['widthUnit'] == 5) {
                        $output_str .= "Display units for Image Width = Columns\n";
                    } else {
                        $output_str .= "Display units for Image Width = Unknown Value (" . $ResInfo['widthUnit'] . ")\n";
                    }
                    if ($ResInfo['heightUnit'] == 1) {
                        $output_str .= "Display units for Image Height = Inches";
                    } elseif ($ResInfo['heightUnit'] == 2) {
                        $output_str .= "Display units for Image Height = Centimetres";
                    } elseif ($ResInfo['heightUnit'] == 3) {
                        $output_str .= "Display units for Image Height = Points";
                    } elseif ($ResInfo['heightUnit'] == 4) {
                        $output_str .= "Display units for Image Height = Picas";
                    } elseif ($ResInfo['heightUnit'] == 5) {
                        $output_str .= "Display units for Image Height = Columns";
                    } else {
                        $output_str .= "Display units for Image Height = Unknown Value (" . $ResInfo['heightUnit'] . ")";
                    }
                    $output_str .= "</pre></td></tr>\n";
                    break;
                default:
                    // All other records
                    $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">{$Resource_Name}</td><td class=\"Photoshop_Value_Cell\">RESOURCE DECODING NOT IMPLEMENTED YET<BR>" . strlen($IRB_Resource['ResData']) . " bytes</td></tr>\n";
            }
        }
        // Add the table end to the HTML
        $output_str .= "</table>\n";
        // Add any secondary output to the HTML
        $output_str .= $secondary_output_str;
    }
    // Return the HTML
    return $output_str;
}
Exemplo n.º 5
0
 $extension = array_pop($pieces);
 // Detect if the file is an image.
 if (is_image($file_set[1])) {
     // Create preview image file name.
     do {
         // Create a random seed by taking the first 8 characters of an MD5 hash of a concatenation of the current UNIX epoch time and the current server process ID.
         $seed = substr(md5(uniqid("")), 0, 8);
         // Assemble the file path.
         $path_to_preview = './' . $CONFIG['fullpath'] . 'edit/preview_' . $seed . '.' . $extension;
     } while (file_exists($path_to_preview));
     // Create secure preview path.
     $s_preview_path = 'preview_' . $seed . '.' . $extension;
     // The file is an image, we must resize it for a preview image.
     resize_image($path_to_image, $path_to_preview, '150', $CONFIG['thumb_method'], 'wd');
     if ($CONFIG['read_iptc_data']) {
         $iptc = get_IPTC($path_to_image);
     }
 } else {
     // The file is not an image, so we will use the non-image thumbs
     // for preview images.
     // We create the path to the preview image.
     $path_to_preview = "images/thumb_{$extension}.jpg";
 }
 // Add preview image path to $escrow_array.
 $escrow_array[$index]['preview_path'] = $path_to_preview;
 // Re-encode the $escrow_array.
 $cayman_escrow = base64_encode(serialize($escrow_array));
 // Update the record.
 $update = update_record($_POST['unique_ID'], $cayman_escrow);
 // Verify that the update occurred.
 if (!$update) {
Exemplo n.º 6
0
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
{
    global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
    global $lang_errors;
    $image = $CONFIG['fullpath'] . $filepath . $filename;
    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
    if (!is_known_filetype($image)) {
        return false;
    } elseif (is_image($filename)) {
        $imagesize = getimagesize($image);
        if ($CONFIG['read_iptc_data']) {
            $iptc = get_IPTC($image);
            if (is_array($iptc) && !$title && !$caption && !$keywords) {
                //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
                $title = isset($iptc['Title']) ? $iptc['Title'] : $title;
                $caption = isset($iptc['Caption']) ? $iptc['Caption'] : $caption;
                $keywords = isset($iptc['Keywords']) ? implode(' ', $iptc['Keywords']) : $keywords;
            }
        }
        if ((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) && max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) {
            //resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $imagesize[0] > $CONFIG['max_upl_width_height'] ? 'wd' : 'ht');
            resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
            $imagesize = getimagesize($image);
        }
        if (!file_exists($thumb)) {
            if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
                return false;
            }
        }
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
            if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
                return false;
            }
        }
    } else {
        $imagesize[0] = $iwidth;
        $imagesize[1] = $iheight;
    }
    $image_filesize = filesize($image);
    $total_filesize = is_image($filename) ? $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb) : $image_filesize;
    // Test if disk quota exceeded
    if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'] && $category == FIRST_USER_CAT + USER_ID) {
        $result = cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
        $record = mysql_fetch_array($result);
        $total_space_used = $record[0];
        mysql_free_result($result);
        if ($total_space_used + $total_filesize >> 10 > $USER_DATA['group_quota']) {
            @unlink($image);
            if (is_image($image)) {
                @unlink($normal);
                @unlink($thumb);
            }
            $msg = strtr($lang_errors['quota_exceeded'], array('[quota]' => $USER_DATA['group_quota'], '[space]' => $total_space_used >> 10));
            cpg_die(ERROR, $msg, __FILE__, __LINE__);
        }
    }
    // Test if picture requires approval
    if (GALLERY_ADMIN_MODE) {
        $approved = 'YES';
    } elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
        $approved = 'YES';
    } elseif (!$USER_DATA['pub_upl_need_approval'] && $category < FIRST_USER_CAT) {
        $approved = 'YES';
    } else {
        $approved = 'NO';
    }
    $PIC_NEED_APPROVAL = $approved == 'NO';
    // User ID is now recorded when in admin mode (casper)
    $user_id = USER_ID;
    $username = USER_NAME;
    // Populate Array to pass to plugins, then to SQL.
    $CURRENT_PIC_DATA['aid'] = $aid;
    $CURRENT_PIC_DATA['filepath'] = $filepath;
    $CURRENT_PIC_DATA['filename'] = $filename;
    $CURRENT_PIC_DATA['filesize'] = $image_filesize;
    $CURRENT_PIC_DATA['total_filesize'] = $total_filesize;
    $CURRENT_PIC_DATA['pwidth'] = $imagesize[0];
    $CURRENT_PIC_DATA['pheight'] = $imagesize[1];
    $CURRENT_PIC_DATA['owner_id'] = $user_id;
    $CURRENT_PIC_DATA['owner_name'] = $username;
    $CURRENT_PIC_DATA['title'] = $title;
    $CURRENT_PIC_DATA['caption'] = $caption;
    $CURRENT_PIC_DATA['keywords'] = $keywords;
    $CURRENT_PIC_DATA['approved'] = $approved;
    $CURRENT_PIC_DATA['user1'] = $user1;
    $CURRENT_PIC_DATA['user2'] = $user2;
    $CURRENT_PIC_DATA['user3'] = $user3;
    $CURRENT_PIC_DATA['user4'] = $user4;
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data', $CURRENT_PIC_DATA);
    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";
    $result = cpg_db_query($query);
    return $result;
}
Exemplo n.º 7
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;
        }
    }
}
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);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
{
    global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
    global $lang_errors;
    $image = $CONFIG['fullpath'] . $filepath . $filename;
    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
    $orig = $CONFIG['fullpath'] . $filepath . $CONFIG['orig_pfx'] . $filename;
    #########
    $mini = $CONFIG['fullpath'] . $filepath . $CONFIG['mini_pfx'] . $filename;
    #########
    $work_image = $image;
    #########
    if (!is_known_filetype($image)) {
        return false;
    } elseif (is_image($filename)) {
        if (!file_exists($orig) && $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
            // if copy of full_sized doesn't exist and if watermark enabled and if fullsized pic watermark=true -> then we need a backup
            if (!copy($image, $orig)) {
                return false;
            } else {
                $work_image = $orig;
            }
        }
        $imagesize = getimagesize($image);
        if ($CONFIG['read_iptc_data']) {
            $iptc = get_IPTC($image);
            if (is_array($iptc) && !$title && !$caption && !$keywords) {
                //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
                $title = isset($iptc['Title']) ? $iptc['Title'] : $title;
                $caption = isset($iptc['Caption']) ? $iptc['Caption'] : $caption;
                $keywords = isset($iptc['Keywords']) ? implode(' ', $iptc['Keywords']) : $keywords;
            }
        }
        if (!file_exists($thumb)) {
            if (!resize_image($work_image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false", 1)) {
                return false;
            }
        }
        $resize_method = $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'];
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
            if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') {
                if (!resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $resize_method, "true")) {
                    return false;
                }
            } else {
                if (!resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $resize_method, "false")) {
                    return false;
                }
            }
        }
        if ((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) && max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) {
            //$CONFIG['auto_resize']==1
            $max_size_size = $CONFIG['max_upl_width_height'];
        } else {
            $resize_method = "orig";
            $max_size_size = max($imagesize[0], $imagesize[1]);
        }
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
            if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
                return false;
            }
        }
        if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original') {
            if (!resize_image($work_image, $image, $max_size_size, $CONFIG['thumb_method'], $resize_method, 'true')) {
                return false;
            }
            $imagesize = getimagesize($image);
        } elseif (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {
            if (!resize_image($work_image, $image, $max_size_size, $CONFIG['thumb_method'], $resize_method, 'false')) {
                return false;
            }
            $imagesize = getimagesize($image);
        }
    } else {
        $imagesize[0] = $iwidth;
        $imagesize[1] = $iheight;
    }
    $image_filesize = filesize($image);
    $total_filesize = is_image($filename) ? $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb) : $image_filesize;
    // Test if disk quota exceeded
    if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'] && $category == FIRST_USER_CAT + USER_ID) {
        $result = cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
        $record = mysql_fetch_array($result);
        $total_space_used = $record[0];
        mysql_free_result($result);
        if ($total_space_used + $total_filesize >> 10 > $USER_DATA['group_quota']) {
            @unlink($image);
            if (is_image($image)) {
                @unlink($normal);
                @unlink($thumb);
            }
            $msg = strtr($lang_errors['quota_exceeded'], array('[quota]' => $USER_DATA['group_quota'], '[space]' => $total_space_used >> 10));
            cpg_die(ERROR, $msg, __FILE__, __LINE__);
        }
    }
    // Test if picture requires approval
    if (GALLERY_ADMIN_MODE) {
        $approved = 'YES';
    } elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
        $approved = 'YES';
    } elseif (!$USER_DATA['pub_upl_need_approval'] && $category < FIRST_USER_CAT) {
        $approved = 'YES';
    } else {
        $approved = 'NO';
    }
    $PIC_NEED_APPROVAL = $approved == 'NO';
    // User ID is now recorded when in admin mode (casper)
    $user_id = USER_ID;
    $username = USER_NAME;
    // Populate Array to pass to plugins, then to SQL.
    $CURRENT_PIC_DATA['aid'] = $aid;
    $CURRENT_PIC_DATA['filepath'] = $filepath;
    $CURRENT_PIC_DATA['filename'] = $filename;
    $CURRENT_PIC_DATA['filesize'] = $image_filesize;
    $CURRENT_PIC_DATA['total_filesize'] = $total_filesize;
    $CURRENT_PIC_DATA['pwidth'] = $imagesize[0];
    $CURRENT_PIC_DATA['pheight'] = $imagesize[1];
    $CURRENT_PIC_DATA['owner_id'] = $user_id;
    $CURRENT_PIC_DATA['owner_name'] = $username;
    $CURRENT_PIC_DATA['title'] = $title;
    $CURRENT_PIC_DATA['caption'] = $caption;
    $CURRENT_PIC_DATA['keywords'] = $keywords;
    $CURRENT_PIC_DATA['approved'] = $approved;
    $CURRENT_PIC_DATA['user1'] = $user1;
    $CURRENT_PIC_DATA['user2'] = $user2;
    $CURRENT_PIC_DATA['user3'] = $user3;
    $CURRENT_PIC_DATA['user4'] = $user4;
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data', $CURRENT_PIC_DATA);
    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";
    $result = cpg_db_query($query);
    /* OVI START */
    $picture_id = mysql_insert_id();
    $imageContainer = new FileContainer($picture_id, $CURRENT_PIC_DATA['owner_id']);
    $imageContainer->total_filesize = $CURRENT_PIC_DATA['total_filesize'];
    if (is_file($image)) {
        $imageContainer->original_path = $image;
    }
    if (is_file($normal)) {
        $imageContainer->thumb_paths[] = $normal;
    }
    if (is_file($thumb)) {
        $imageContainer->thumb_paths[] = $thumb;
    }
    if (is_file($orig)) {
        $imageContainer->thumb_paths[] = $orig;
    }
    // useless? does it upload twice?
    // $ mini is not used
    if (!defined('API_CALL')) {
        global $storage;
        $storage->store_file($imageContainer);
        // TODO: check $result?
    }
    /* OVI END */
    return $result;
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
function Interpret_IRB_to_HTML2($IRB_array, $filename)
{
    // Create a string to receive the HTML
    $output_str = "";
    // Check if the Photoshop IRB array is valid
    if ($IRB_array !== FALSE) {
        // Create another string to receive secondary HTML to be appended at the end
        $secondary_output_str = "";
        // Cycle through each of the Photoshop IRB records, creating HTML for each
        foreach ($IRB_array as $IRB_Resource) {
            // Add HTML for the resource as appropriate
            switch ($IRB_Resource['ResID']) {
                case 0x404:
                    // IPTC-NAA IIM Record
                    $secondary_output_array = Interpret_IPTC_to_HTML2(get_IPTC($IRB_Resource['ResData']));
                    break;
                case 0x40a:
                    // Copyright Marked
                    if (hexdec(bin2hex($IRB_Resource['ResData'])) == 1) {
                        $img_info['copyright'] = 1;
                    } else {
                        $img_info['copyright'] = 0;
                    }
                    break;
            }
        }
    }
    $output = array_merge($img_info, $secondary_output_array);
    // Return the HTML
    return $output;
}
Exemplo n.º 13
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);
}