Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Wallpaper Gallery  (Read 6653 times)

0 Members and 1 Guest are viewing this topic.

Para

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Wallpaper Gallery
« on: February 21, 2006, 04:24:21 pm »

Hi my name is Tony, im planning a wallpaper site and want to use coppermine

Ive read every Wallpaper related thread in this forum and it seems that there is still not an answer/mod that can properly make 2 seperate download links for 800x600 and 1024x768 without using this solution
http://forum.coppermine-gallery.net/index.php?topic=4558.0

If i use that solution is there a way of having 2 links to each file, instead of people having to click to image twice to see different dimensions?

An ideal soloution would be something like this http://forum.coppermine-gallery.net/index.php?topic=268.0

Id really appreciate any help with this, because there are absolutly no gallerys that cater for wallpapers sites, ive searched the entire web and back again lol

Thanks guys, and i hope i can resolve this so that i can use coppermine :)

Keep up the good work.

Tony
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Wallpaper Gallery
« Reply #1 on: February 21, 2006, 06:55:28 pm »

OK, here's my proposed solution: if you're the only one to upload files to your albums, then do FTP-upload plus batch-add exclusively: upload the "regular" pic with a file you choose in 800x600 and another file in 1024x768 that you prefix with something that stays the same all the times (e.g. "1024x_". Then you will need two code modifications only: one in the batch-add screen that hides files from view that has this certain prefix that stays the same all the times and one modification of your theme (displayimage section) that shows the link to the 1024x768 file.
Edit searchnew.php, find
Code: [Select]
            strpos($file,'edit') === FALSE &&and add (in a new line after it)
Code: [Select]
            strpos($file,'1024_') === FALSE &&    to keep the files prefixed with "1024_" from being displayed.

Oops, I realized that I'm late already, I'll post the needed changes to theme.php later. Sorry - maybe you'll want to look into the code for yourself meanwhile...
Logged

Para

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Wallpaper Gallery
« Reply #2 on: February 21, 2006, 08:02:37 pm »

Thanks for your help, i will inplement the changes you posted so far, and keep checking back for the theme.php changes,


Much appreciate your help, this could be a breakthrough for wallpaper sites

Tony
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Wallpaper Gallery
« Reply #3 on: February 22, 2006, 09:52:49 am »

Here's the second part of the hack:

You need to create a file named "download.php" with this content:
Code: [Select]
<?php
$file 
rawurldecode($_GET['file']);
// OK, this script is very dangerous, we have to make sure that only the files can be downloaded that we want to allow
// For now, let's check if the file has the extension JPG, JPEG, GIF and PNG and disallow all others
$allowedExtensionsArray = array('jpg','jpeg''gif''png');
$filename basename($file);
$extension strtolower(ltrim(substr($filename,strrpos($filename,'.')),'.'));
if(
in_array($extension$allowedExtensionsArray) == TRUE) {
$filesize filesize($file);
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache");
header("Cache-Control: post-check=0, pre-check=0"false);
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Description: Downloaded File");
readfile($file);
}
?>
Store this file in your coppermine root

Next, edit themes/yourtheme/theme.php and find
Code: [Select]
function theme_html_picture()If this function exists, then find
Code: [Select]
    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }
and add
Code: [Select]
    // Wallpaper hack start
    $wallSeparator = strrpos(get_pic_url($CURRENT_PIC_DATA, 'fullsize'), '/');
    $wallPath = substr(get_pic_url($CURRENT_PIC_DATA, 'fullsize'),0,$wallSeparator).'/'.'1024_'.ltrim(substr(get_pic_url($CURRENT_PIC_DATA, 'fullsize'),$wallSeparator),'/');
    if(file_exists($wallPath) == TRUE) {
      $wallpaperLink = '<a href="download.php?file='.rawurlencode($wallPath).'">';
      $CURRENT_PIC_DATA['title'] = $wallpaperLink . 'Download this pic in 1024 x 768'.'</a><br />'.$CURRENT_PIC_DATA['title'];
    }
    // Wallpaper hack end
into a new line right after it.
If the function doesn't exist in your custom theme, paste
Code: [Select]
// Displays a picture
function theme_html_picture()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER;
    global $album, $comment_date_fmt, $template_display_media;
    global $lang_display_image_php, $lang_picinfo;

    $pid = $CURRENT_PIC_DATA['pid'];
    $pic_title = '';

    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
        $USER['liv'] = array();
    }
    // Add 1 to hit counter
    if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) {
        add_hit($pid);
        if (count($USER['liv']) > 4) array_shift($USER['liv']);
        array_push($USER['liv'], $pid);
    }

    if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
      $condition = true;
    }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){
      $condition = true;
    }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){
      $condition = true;
    }else{
     $condition = false;
    }

    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }
    // Wallpaper hack start
    $wallSeparator = strrpos(get_pic_url($CURRENT_PIC_DATA, 'fullsize'), '/');
    $wallPath = substr(get_pic_url($CURRENT_PIC_DATA, 'fullsize'),0,$wallSeparator).'/'.'1024_'.ltrim(substr(get_pic_url($CURRENT_PIC_DATA, 'fullsize'),$wallSeparator),'/');
    if(file_exists($wallPath) == TRUE) {
      $wallpaperLink = '<a href="download.php?file='.rawurlencode($wallPath).'">';
      $CURRENT_PIC_DATA['title'] = $wallpaperLink . 'Download this pic in 1024 x 768'.'</a><br />'.$CURRENT_PIC_DATA['title'];
    }
    // Wallpaper hack end
    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
        template_extract_block($template_display_media, 'img_desc');
    } else {
        if (!$CURRENT_PIC_DATA['title']) {
            template_extract_block($template_display_media, 'title');
        }
        if (!$CURRENT_PIC_DATA['caption']) {
            template_extract_block($template_display_media, 'caption');
        }
    }

    $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';

    if ($CONFIG['make_intermediate'] && $condition ) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }

    $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']);

    $pic_title = '';
    $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);


    if ($mime_content['content']=='movie' || $mime_content['content']=='audio') {

        if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) {
            $CURRENT_PIC_DATA['pwidth']  = 320; // Default width

            // Set default height; if file is a movie
            if ($mime_content['content']=='movie') {
                $CURRENT_PIC_DATA['pheight'] = 240; // Default height
            }
        }

        $ctrl_offset['mov']=15;
        $ctrl_offset['wmv']=45;
        $ctrl_offset['swf']=0;
        $ctrl_offset['rm']=0;
        $ctrl_offset_default=45;
        $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default;
        $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"';
    }

    if ($mime_content['content']=='image') {
        if (isset($image_size['reduced'])) {
            $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
            $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
        }
    } elseif ($mime_content['content']=='document') {
        $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"".$pic_thumb_url."\" border=\"0\" class=\"image\" /></a>\n<br />";
    } else {
        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

        $players['WMP'] = array('id' => 'MediaPlayer',
                                'clsid' => 'classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" ',
                                'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',
                                'mime' => 'type="application/x-mplayer2" ',
                               );
        $players['RMP'] = array('id' => 'RealPlayer',
                                'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ',
                                'codebase' => '',
                                'mime' => 'type="audio/x-pn-realaudio-plugin" '
                               );
        $players['QT']  = array('id' => 'QuickTime',
                                'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ',
                                'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ',
                                'mime' => 'type="video/x-quicktime" '
                               );
        $players['SWF'] = array('id' => 'SWFlash',
                                'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',
                                'codebase' => 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ',
                                'mime' => 'type="application/x-shockwave-flash" '
                               );
        $players['UNK'] = array('id' => 'DefaultPlayer',
                                'clsid' => '',
                                'codebase' => '',
                                'mime' => ''
                               );

        if (isset($_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'])) {
            $user_player = $_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'];
        } else {
            $user_player = $mime_content['player'];
        }

                // There isn't a player selected or user wants client-side control
        if (!$user_player) {
            $user_player = 'UNK';
        }

        $player = $players[$user_player];

        $pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\"><param name=\"src\" value=\"". $picture_url . "\">";
        $pic_html .= "<embed {$image_size['whole']} src=\"". $picture_url . "\" autostart=\"$autostart\" type=\"".$player['mime']."\"></embed>";
        $pic_html .= "</object><br />\n";
    }

    $CURRENT_PIC_DATA['html'] = $pic_html;
    $CURRENT_PIC_DATA['header'] = '';
    $CURRENT_PIC_DATA['footer'] = '';

    $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA);

    $params = array('{CELL_HEIGHT}' => '100',
        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
        );

    return template_eval($template_display_media, $params);
}
into a new line right before
Code: [Select]
?>
Caveat: the file download.php could be a possible security risk to your entire site (if I made a boo coding it), so use it at your own risk.

Please report if the hack works for you.
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Wallpaper Gallery
« Reply #4 on: February 22, 2006, 11:38:17 am »

another attempt would have been to use my modpack... when you upload pictures it makes a backup of the file
eg. you upload background1.jpg (1280x1024) then you'll get a backup of this file (orig_background1.jpg)
you set 800x600 as fullpic resize -> background1.jpg
and eg. 640x400 for the normal image -> normal_background.jpg
you even can enable another resize, the mini thumb... then you get mini_background.jpg as well (size setable in config)

for the orig  backup you'll have to enable the watermark function... so you just use as watermark file a 1x1 transparent png and you're done

markp17

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 56
Re: Wallpaper Gallery
« Reply #5 on: March 25, 2006, 05:36:32 pm »

Hi

could this be modified to allow downloads of only mpeg4 video files? If so how would this be done?

thanks mark
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Wallpaper Gallery
« Reply #6 on: March 26, 2006, 12:27:59 pm »

  • @Para (aka Tony): thanks for letting me code this for you without giving feedback as suggested
    Please report if the hack works for you.
    . It fills me with joy to see my work appreciated :-[.
  • @markp17: yes, if your modify the download.php file to allow mpeg4 files - edit $allowedExtensionsArray = array('jpg','jpeg', 'gif', 'png'); as you see fit.
Logged

markp17

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 56
Re: Wallpaper Gallery
« Reply #7 on: March 26, 2006, 12:30:26 pm »

hi thanks for that, but what is the other message in your reply??
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Wallpaper Gallery
« Reply #8 on: March 26, 2006, 12:35:37 pm »

It isn't meant for you, but the original thread starter (nickname "para"). He asked for a hack, I coded it for him and asked for feedback. He didn't bother to give the feedback (something like "works for me" would have been enough). The answer to your question starts with "@markp17". The reply to para starts with "@para". You can safely ignore the reply I gave to "para".
Logged

markp17

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 56
Re: Wallpaper Gallery
« Reply #9 on: March 26, 2006, 09:33:29 pm »

ok, no worries, thanks for the help

mark
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.