Don't Let Anybody To Download The Lightbox As Zip Don't Let Anybody To Download The Lightbox As Zip
 

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

Don't Let Anybody To Download The Lightbox As Zip

Started by pressurecooker, April 11, 2008, 03:07:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pressurecooker

Hi,

So I got a Lightbox and I have enabled a function to let Zip downloads of the Lightbox. The problem was that anyone could download anything despite of permissions.

I read this post http://forum.coppermine-gallery.net/index.php/topic,38437.0.html where Nibbler suggested a solution to a similar problem and it gave me inspiration. What I wanted to do was restricting guests from having any downloads at all. Here's what I did:

Replaced this bit of zipdownload.php

$cwd = "./{$CONFIG['fullpath']}";
$zip = new zip_file('pictures.zip');
$zip->set_options(array('basedir' => $cwd, 'inmemory' => 1, 'recurse' => 0, 'storepaths' => 0));
$zip->add_files($filelist);
$zip->create_archive();
ob_end_clean();
$zip->download_file();

With this bit:

if (USER_ID){
$cwd = "./{$CONFIG['fullpath']}";
$zip = new zip_file('pictures.zip');
$zip->set_options(array('basedir' => $cwd, 'inmemory' => 1, 'recurse' => 0, 'storepaths' => 0));
$zip->add_files($filelist);
$zip->create_archive();
ob_end_clean();
$zip->download_file();
} else {
pageheader($lang_error);
starttable('-2', $lang_error);
print <<<EOT
<tr>
        <td align="center" class="tableb">
      <p>You need to be registered to access downloads. <a href="whateveryoulike.php">Click here to become a member</a>.</p>
      </td>
</tr>
EOT;
endtable();
pagefooter();
ob_end_flush();
}


Now when a curious person browses a gallery and decides it would be a good idea to steal a picture or two, he/she gets a prompt to register when clicking on "Download as Zip file".
Join the green campaign - Environmental Articles

paquets