download mp3 download mp3
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

download mp3

Started by paultje3181, March 21, 2006, 11:04:53 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

paultje3181

I got a lot of mp3 files on my site (I'm using coppermine as a mp3 gallery) and I want to change the filename to a downloadlink. (Rightclick and save as)

I would like to give a individual link as well as a complete album download link. Is this possible? All the topics about download links do not apply to the new version 1.4.4 (or I'm just stupid ;) )

Google and this forum did not help me with this problem. My guess would be that in the right file (displayimage.php???) just add a <a href="siteadress/[filename]">[title]</a> would do the trick, but I can't find the correct line and file.

Could you give me some advice?


paultje3181

the first links to the second, which is not resolved. In 1.4.4 in all the themes there's no $pic_html anymore, so I guess all this hacks don't apply anymore.
the last two are with 1.4.2 or 1.4.3 but in theme.php (in Mac OS X theme) there is no $pic_html so I can't change the things mentioned in the topics. So could you please explain what to do instead of linking to old topics?

But is my solution possible as I mentioned in the startpost? It seems pretty easy to me, but perhaps there are some complications to this?

Thanks!

Joachim Müller

if something isn't in your theme, copy the section you need from the sample theme.

paultje3181

I guess you mean the classic theme? There's no line there either... So I certainly have no clue where to put it...

Joachim Müller

Quote from: paultje3181 on March 22, 2006, 08:53:37 AM
So I certainly have no clue where to put it...
into a new line before?>

paultje3181

I added:
  $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>";
to theme.php and made an download.php
<?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();
?>


But it still is not working? Also I do not see the need to do this so difficult... Why can't I just change the filename (with fuction show filename) to a downloadlink? Which file shows the filename? I can't find it in thumbnails.php and not in index.php. So could you please point out which file draws the title and filename under the thumbnail?

Joachim Müller

you're suppossed to create a separate file named "download.php". Please read the threads you refer to extra carefully.

paultje3181

as you can see in my last post I made a file download.php using the code mentioned above. I placed it in the root of my cpg and added the extra lines in the theme.php (of the correct theme off course)

But it still isn't working...

Joachim Müller

Quote from: paultje3181 on March 23, 2006, 11:23:46 AM
But it still isn't working...
a bit vague. What does it do?

paultje3181

There is no download link... That's what is not working...


Joachim Müller

doesn't surprise me. The code you added to theme.php takes care of videos, not audio files.

paultje3181

OMG, silly me... But how can I edit it to pick all sorts of files? In Theme.php I don't see video specific code, since a mp3 is also opened by a player etc.

Joachim Müller

edit themes/yourtheme/theme.php, find$CURRENT_PIC_DATA['html'] = $pic_html;and add before it (in a new line)$pic_html .= 'Your custom HTML';

paultje3181

I feel really stupid, but I don't get it... Could you please upload the mac_ox_x theme.php with the correct code and a download.php file? Because I simply can't get it to work... (no download link given...)