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: Download Plugin  (Read 4479 times)

0 Members and 1 Guest are viewing this topic.

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Download Plugin
« on: July 19, 2006, 08:12:23 pm »

I'm currently using jjhat1's Download and Alternate File Loading Plugin

It works perfect but I want to replace the 'Download' text link to a 'Download' image link.

This is the following code in the codebase.php

Code: [Select]
<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

//Obtain the PID
$thisplugin->add_filter('file_data','download_pid');

function 
download_pid($data)
{
global $download;
$download['id'] = $data['pid'];
return $data;
}

//Places a download link above the filename on the information list
$thisplugin->add_filter('file_info','download_link');

function  
download_link($info)
{
global $download;
$info array_reverse($info);
$info['Download Cover'] .= '<a href="./index.php?file=download/picture&pid=' $download['id'] . '&method=dl" >Download Now</a>';
$info array_reverse($info);
return $info;
}


//Loads all Coppermine files through a PHP script for security
$thisplugin->add_filter('picture_url','download_url');

function 
download_url($fullpath)
{
global $CONFIG;

//Decode all special HTML characters
$fullpath rawurldecode($fullpath);

//Strip out the full path from the URL
$path substr($fullpath,strlen($CONFIG['fullpath']),strrpos($fullpath"/")-strlen($CONFIG['fullpath'])+1);


//Strip out the full filename from the URL
$file substr(strrchr($fullpath"/"), 1);


//If the filename qualifies as a "normal" file, strip out the prefix and indicate normal method
if(substr($file,0,strlen($CONFIG['normal_pfx'])) == $CONFIG['normal_pfx'])
{
$file substr($file,strlen($CONFIG['normal_pfx']),strlen($file));
$method "&method=normal_";
}
//If the filename qualifies as a "thumb" file, strip out the prefix and indicate thumb method
else if(substr($file,0,strlen($CONFIG['thumb_pfx'])) == $CONFIG['thumb_pfx'])
{
$file substr($file,strlen($CONFIG['thumb_pfx']),strlen($file));
$method "&method=thumb_";
}
//If there is no decernable prefix then use the full file and indicate no method
else
{
$method "";
}

//Query the database to locate the PID of the picture
$result cpg_db_query("SELECT pid FROM {$CONFIG['TABLE_PICTURES']} WHERE filepath='" $path "' AND filename='" $file "'");
$row mysql_fetch_array($result);
mysql_free_result($result);
$pid $row['pid'];

$privacy md5($fullpath);

//If no PID was found use the path that was given
//This will be used for special thumb and normal pictures such as Word Documents
if($pid == 0)
$url $fullpath;
//If the PID was found construct the URL
else
$url "index.php?file=download/picture&pid=" $pid "&pr=" $privacy $method;

//Return the new URL
return $url;
}


// Add an install action
$thisplugin->add_action('plugin_install','sample_install');

// Install function
// Checks if uid is 'me' and pwd is 'you'; If so, then install the plugin
function sample_install() {

    
// Install
    
if ($_POST['test']=='true')
    {
        return 
true;

    
// Loop again
    
} else {

        return 
1;
    }
}


// Add a configure action
$thisplugin->add_action('plugin_configure','sample_configure');

// Configure function
// Displays the form
function sample_configure() {
    echo <<< EOT
    <h2>Modification required</h2>
    For this plugin to fully work a small modification is required to the <i>functions.inc.php</i> file located in the <i>include</i> folder.
<br><br>
<b>Find The Line:</b>
<br><br>
    <i>return \$pic_row['url'];</i>
    <br><br>
    
<b>Place This Line of Code Immediately Before It:</b>
<br><br>
<i>\$pic_row['url'] = CPGPluginAPI::filter('picture_url',\$pic_row['url']);</i>
<br><br>

This plugin serves two basic purposes.  The first is adding a download link below all of the intermediate files.  This functionality will work as soon as this plugin is installed.  The second is redirecting all files through a PHP script.  This second functionality is dependant on the above modification.   However, no errors will occur if the above modification is not made and this plugin will simply perform only the first function.
    <form action="
{$_SERVER['REQUEST_URI']}" method="post">
<input type="hidden" name="test" value="true" /><br />
<input type="submit" value="Go!" />
</form>
EOT;
}












/*

// Add a configure action
$thisplugin->add_action('plugin_configure','sample_configure');

// Add a filter for the gallery header
$thisplugin->add_filter('gallery_header','sample_header');

$thisplugin->add_filter('plugin_block','sample_block_mgr');
*/


//add the download link in the appropriate place

/*
// Sample function to modify gallery header html
function sample_header($html) {
    global $thisplugin;
    return '<p style="color:red;"><b>This is sample data returned from plugin "'.$thisplugin->name.'".</b></p>'.$html;
}

function sample_block_mgr($block) {
    return $block;
}


// Install function
// Checks if uid is 'me' and pwd is 'you'; If so, then install the plugin
function sample_install() {

    return true;
}

// Configure function
// Displays the form
function sample_configure() {
    echo <<< EOT

EOT;
}


*/

?>


I just want to know what code to replace to make this work.

Any help will be great.

Regards, will ;D
« Last Edit: July 19, 2006, 08:37:26 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Download Plugin
« Reply #1 on: July 19, 2006, 08:28:23 pm »

Change

Code: [Select]
$info['Download Cover'] .= '<a href="./index.php?file=download/picture&pid=' . $download['id'] . '&method=dl" >Download Now</a>';
to

Code: [Select]
$info['Download Cover'] .= '<a href="./index.php?file=download/picture&pid=' . $download['id'] . '&method=dl" ><img src="path/to/image" alt="download now" border="0" /></a>';
Basic HTML.
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download Plugin
« Reply #2 on: July 19, 2006, 08:35:34 pm »

Thanks Nibbler ;D
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Download Plugin
« Reply #3 on: July 20, 2006, 06:04:36 am »

@will: in the future, please post a link to the thread you are refering to as reference both for supporters and visitors who are looking for similar issues. In your case, it's Download and Alternate File Loading
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download Plugin
« Reply #4 on: July 20, 2006, 08:14:36 pm »

Sorry m8, in future I will, cheers again ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.083 seconds with 21 queries.