forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: yipster on December 30, 2005, 08:18:00 am

Title: Video Hack 1.4.3
Post by: yipster on December 30, 2005, 08:18:00 am
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:

Code: [Select]
<?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:
Code: [Select]
        $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:
Code: [Select]
        $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

Not sure how to go about it in 1.4.3. I'm using the water_drop theme. I can't find whats needed to be replaced in water_drop's theme.php.

Any help appreciated =).
Title: Re: Video Hack 1.4.3
Post by: Joachim Müller on December 30, 2005, 08:38:06 am
what thread are you refering to?
Title: Re: Video Hack 1.4.3
Post by: yipster on December 30, 2005, 07:51:13 pm
This one:
http://forum.coppermine-gallery.net/index.php?topic=24491
Title: Re: Video Hack 1.4.3
Post by: Nibbler on December 30, 2005, 07:52:52 pm
Read the rest of the thread, it explains what to do in 1.4