Advanced search  

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

Pages: [1]   Go Down

Author Topic: download mp3  (Read 7253 times)

0 Members and 1 Guest are viewing this topic.

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
download mp3
« on: March 21, 2006, 11:04:53 pm »

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?
Logged

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #2 on: March 21, 2006, 11:28:14 pm »

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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #3 on: March 21, 2006, 11:42:20 pm »

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

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #4 on: March 22, 2006, 08:53:37 am »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #5 on: March 22, 2006, 09:18:27 am »

So I certainly have no clue where to put it...
into a new line before
Code: [Select]
?>
Logged

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #6 on: March 22, 2006, 01:26:53 pm »

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

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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #7 on: March 23, 2006, 10:20:34 am »

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

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #8 on: March 23, 2006, 11:23:46 am »

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...
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #9 on: March 24, 2006, 07:14:39 am »

But it still isn't working...
a bit vague. What does it do?
Logged

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #10 on: March 24, 2006, 01:18:43 pm »

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

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #11 on: March 24, 2006, 05:18:52 pm »

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

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #12 on: March 25, 2006, 04:58:54 pm »

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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: download mp3
« Reply #13 on: March 25, 2006, 08:14:23 pm »

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

paultje3181

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: download mp3
« Reply #14 on: March 28, 2006, 09:22:07 am »

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...)
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 19 queries.