Download video hack for v. 1.4.2 Download video hack for v. 1.4.2
 

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]

Main Menu

Download video hack for v. 1.4.2

Started by tripslip38, December 01, 2005, 10:48:11 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

tripslip38

I found the thread for the code change in the 1.3 boards about making a link to let users download video files instead of streaming them in the embedded player. In displayimage.php 1.4, I can't even find any of the same variables to hack as was described in the 1.3 hack.

Old hack: http://forum.coppermine-gallery.net/index.php?topic=9367.0

Suggestions?

Zane

Nibbler

That code is part of the theme system now, you can find it in your theme's theme.php or in include/themes.inc.php

bwschult

tripslip, I would be definitely be interested in that.  As my videos don't play on Mac OS, I'm looking into alternative ways for my users to view videos other than the embedded player.

tripslip38

#3
Ok, I searched around, and with Nibbler's redirect to the new location of the code, I came up with this solution, which worked beautifully:

Step 1) Create download.php

Copy/paste this code into a file called download.php, and put it in the Coppermine application root:

<?php
//
// hack to allow downloading of pictures and movies
// see http://forum.coppermine-gallery.net/index.php?topic=6464.0
//
define('IN_COPPERMINE',true);
define('UPLOAD_PHP',true);
define('DOWNLOAD_PHP',true);

require(
'include/init.inc.php');

function 
download()
{
        global 
$CONFIG$lang_upload_php$FORBIDDEN_SET;

        
$pid = (int) $_GET['pid'];

        
$sql 'select '.
                
'p.filepath,'.
                
'p.filesize,'.
                
'p.filename,'.
                
$CONFIG['TABLE_ALBUMS'].'.visibility, '.
                
'p.aid as aid '.
                
'from '.$CONFIG['TABLE_PICTURES'].' as p LEFT JOIN '.$CONFIG['TABLE_ALBUMS'].
                
' ON (p.aid = ' $CONFIG['TABLE_ALBUMS'].'.aid ) '.
                
' where pid='.$pid.' and approved="YES"';

        if (!empty(
$FORBIDDEN_SET)) {
                
$sql .= ' and '.$FORBIDDEN_SET;
        }

        
$result cpg_db_query($sql);

        
// No data returned; Display an error page
        
if (mysql_num_rows($result)==0) {
                
mysql_free_result($result);
                
cpg_die(CRITICAL_ERROR,$lang_upload_php['unknown']);
        }

        
$file mysql_fetch_assoc($result);
        
mysql_free_result($result);

        
// Empty output buffer
        
while(ob_get_level()>0) {
                
ob_end_clean();
        }

        
// Send binary information to the browser
        
header("Content-type: application/octet-stream");
        
header("Content-disposition: attachment; filename=".$file['filename']);
        
header("Content-Length: ".$file['filesize']);
        
header("Pragma: no-cache");
        
header("Expires: 0");
        
readfile($CONFIG['fullpath'].$file['filepath'].$file['filename']);
}

download();
?>


Step 2) Change theme.php

Open the theme.php for the theme your're using.

FIND:         $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.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";


REPLACE WITH:         $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.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";
$pic_html .= "<p><a href=\"download.php?pid={$CURRENT_PIC_DATA['pid']}\">Click here to download</a></p>";



That should do you. In addition to the media file opening in an embedded player now, a link to download will display.


Zane

Joachim Müller


mini1400

Quote from: tripslip38 on December 01, 2005, 11:20:31 PM
Open the theme.php for the theme your're using.

FIND:         $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.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";


REPLACE WITH:         $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.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";
$pic_html .= "<p><a href=\"download.php?pid={$CURRENT_PIC_DATA['pid']}\">Click here to download</a></p>";



Hmm, can't find that code in the mac_os_x theme..... any ideas?

Paver

Quote from: mini1400 on December 02, 2005, 12:17:00 PM
Hmm, can't find that code in the mac_os_x theme..... any ideas?

Some themes don't use all the overrides.  Go to the "sample" theme and copy the relevant section from its theme.php into your theme.php.  If you haven't done so already, I'd copy the default Mac_OS_X theme into a new folder so you can modify at will and still have the default (for upgrades and overall sanity).


hotvins

I am getting following error messege !!

QuoteFatal error: Call to undefined function: db_query() in /home/vwad/public_html/masala/download.php on line 32
Thanks to all the Creators & Coders of Coppermine Photo Gallery

hotvins

I have searched very hard but cannot find solution for this

I have successfully changed the files themes.inc.php and have uploaded download.php file as per the hack instructions but I am getting just a blank page or sometimes a file gets downloaded with a 1 kb size instead of the original video file size of 346 kb.

I am confident and have checked that the video file is there and is of 346 kn in my albums/uploads folder

My gallery link is

http://hotvins.300megs.com/masala/

The file I am talking about is located here

http://hotvins.300megs.com/masala/displayimage.php?album=lastup&cat=0&pos=0

Help needed

thanks in advance

hotvins
Thanks to all the Creators & Coders of Coppermine Photo Gallery

Paver

hotvins:  Check your modifications again.  db_query is a deprecated function from version 1.3.  The function in 1.4 is cpg_db_query.  You could merely fix your current error, but I would check this thread again against your code to make sure you are using everywhere the 1.4 code.

Joachim Müller

Don't edit themes.inc.php!
Post what mod you're refering to.

Joachim Müller

I just found out what posting you refered to, as you cross posted there as well. Merging this new thread you started with the other one you refered to. Don't double post nor cross post, it just makes supporter's life harder.

hotvins

sorry abt posting thing !!

this script was installed by my server using fantastico

I know the procedure to upload the script and setting it up.

Should I download latest version and upload it to my server in other folder ?

I am not able to understand what to check.

Please Help

Thanks

Hotvins
Thanks to all the Creators & Coders of Coppermine Photo Gallery

Joachim Müller

Fantastico is buggy and not recommended by the coppermine dev team. Upgrade to cpg1.4.3 using the package we provide.

hotvins

Ok GauGau Bro.

Thanks a lot I shall do that and see what happens but please keep an eye on this thread for atleast two more days from your busy schedule since I may encounter some problems and will be posting in this thread only

Cheers & Good Wishes
Hotvins
Thanks to all the Creators & Coders of Coppermine Photo Gallery

hotvins

I am not getting this thing right

Please tell me again in step by step method
Thanks to all the Creators & Coders of Coppermine Photo Gallery

hotvins

BTW I have installed 1.4.3 but not yet able to get download possible

http://hotvins.300megs.com/vids/
Thanks to all the Creators & Coders of Coppermine Photo Gallery

hotvins

Thanks to all the Creators & Coders of Coppermine Photo Gallery

Paver

hotvins: Posting multiple times is not going to help to get a response faster.  The only post in the last 4 you posted that is useful is the one where you said you installed 1.4.3 and gave a link to your site.  The other 3 were really not necessary and can annoy people who want to help.

I looked at your site and here's my suggestion.  Take a look at this line again in your theme.php:
$pic_html .= "<p><a href=\"download.php?pid={$CURRENT_PIC_DATA['pid']}\">Click here to download</a></p>";
I believe that in the line before this one, you are are missing the ending quotation mark.  Check your lines against the ones in the post above.