Download video hack for v. 1.4.2 - Page 2 Download video hack for v. 1.4.2 - Page 2
 

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

Download video hack for v. 1.4.2

Started by tripslip38, December 01, 2005, 10:48:11 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

mrandall131

#20
Just to make sure, you are saying that I should copy the entire theme_html_picture function into the theme.php that I am using, and then make the modifications listed in step 2 above?

[edit]
Well, that's just what I did.  Worked perfect.  Thanks for the work guys!

hotvins

Thanks Paver for your reply and Sorry about all the trouble I caused.

I am not at all into php and so you will need to tell me what to edit and where to edit.

I am seeing quotation mark in the file and BTW the classic theme does not contain anything like that code. I can see the code in the theme.inc.php though.

In which of the files I need to edit the code and where ?

displayimage.php
theme.php
theme.inc.php

Also tell me the right code to paste inside the file.

Thanks in Advance

Hotvins
Thanks to all the Creators & Coders of Coppermine Photo Gallery

Joachim Müller

edit theme.php. If code that you want to edit appears to be "missing" in your theme, copy the corresponding section from themes/sample/theme.php (that's the reference file). Do not copy the entire content of themes/sample/theme.php, but only the stuff you want to override.
Never, ever edit include/themes.inc.php

hotvins

Thanks GauGau Bro

I did all the procedure and uploaded original versions of displayimage.php and theme.inc.php but still it doesn't work

it shows just a blank page with the letters "RIFFĸ" when I click on "Click here to download" link.

http://hotvins.300megs.com/vids/displayimage.php?album=lastup&cat=0&pos=0

Please help.
Thanks to all the Creators & Coders of Coppermine Photo Gallery

Paver

hotvins:  Something's weird with your download.php script.  You obviously fixed your theme problem because that's all set.  Now download.php doesn't do what it's supposed to do.  Did you copy it exactly as it is shown?  download.php should not put up a banner or anything else; it should just send the header of a file to download.  ... unless your webhost is butting in and messing things up by putting up the banner & Google adwords on every page you post.  I don't know enough about webhosting issues to know if this is possible.

Joachim Müller

Quote from: Paver on January 17, 2006, 06:25:41 PM
I don't know enough about webhosting issues to know if this is possible.
it is, free webhosts do this often. Usually, you can't use pre-made scripts like coppermine with those extremely ad-driven free webhosts, there are only a few exceptions to this rule.

Paver

Quote from: GauGau on January 18, 2006, 12:20:52 AM
it is, free webhosts do this often. Usually, you can't use pre-made scripts like coppermine with those extremely ad-driven free webhosts, there are only a few exceptions to this rule.
In that case, I guess the only option is to use a "right click to save" note and then change the theme.php download link to point to the actual video file instead of the download.php script.

hotvins

QuoteIn that case, I guess the only option is to use a "right click to save" note and then change the theme.php download link to point to the actual video file instead of the download.php script.

To Paver & GauGau

Can you please tell me how to point it to actual video file instead of the download.php script ?

You see, you might be thinking that why does he dont know anything but I have not coded in php at all. I have just installed version 1.3 once according to instructions and if you can remember GauGau, I also had asked you about adding the code of Google Adsense at that time in the past.

So your detailed help will be appreciated in the current situation because it is not affordable for me to go for a ad free host or paid host at this point of time since I am a student.

Hotvins
Thanks to all the Creators & Coders of Coppermine Photo Gallery

Tranz

Are you a college student? Does your school give you webspace?

And you don't have to interpret minimal information as an expectation that you know more than you do. It's just that once we do enough support, we don't want to spend more time than necessary lest the user already knows the information. If not, we will provide more info.

Paver

hotvins: Where you currently have this line:
$pic_html .= "<p><a href=\"download.php?pid={$CURRENT_PIC_DATA['pid']}\">Click here to download</a></p>";
Replace it with this line:
$pic_html .= "<p><a href=\"$picture_url\">Right-click and Save to download video</a></p>";

That should do it.

nontekkyguy

If my theme (in this case fruity theme) does not contain the following:

Quote from: mini1400 on December 02, 2005, 12:17:00 PM
Hmm, can't find that code in the mac_os_x theme..... any ideas?

Where in my newly updated theme.php would I paste this info, as in before and after which lines. 

This is my theme.php coding:

// HTML template for main menu
$template_sys_menu = <<<EOT
                <div class="topmenu">
                     {BUTTONS}
                </div>
EOT;

// HTML template for template sys_menu spacer
$template_sys_menu_spacer ='';

// HTML template for the image navigation bar
$template_img_navbar = <<<EOT

        <tr>
                <td align="center" valign="middle" class="navmenu" width="48px"><a name="top_display_media"></a>
                        <a href="{THUMB_TGT}" class="navmenu_pic" title="{THUMB_TITLE}"><img src="{LOCATION}images/thumbnails.gif" align="middle" border="0px" alt="{THUMB_TITLE}" /></a>
                </td>
//                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="javascript:;" class="navmenu_pic" onclick="blocking('picinfo','yes', 'block'); return false;" title="{PIC_INFO_TITLE}"><img src="{LOCATION}images/info.gif" border="0px" align="middle" alt="{PIC_INFO_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{SLIDESHOW_TGT}" class="navmenu_pic" title="{SLIDESHOW_TITLE}"><img src="{LOCATION}images/slideshow.gif" border="0px" align="middle" alt="{SLIDESHOW_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="100%">
                        {PIC_POS}
                </td>
<!-- BEGIN report_file_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{REPORT_TGT}" class="navmenu_pic" title="{REPORT_TITLE}"><img src="{LOCATION}images/report.gif" border="0" align="middle" alt="{REPORT_TITLE}" /></a>
                </td>
<!-- END report_file_button -->
<!-- BEGIN ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/ecard.gif"  border="0px" align="middle" alt="{ECARD_TITLE}" /></a>
                </td>
<!-- END ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{PREV_TGT}" class="navmenu_pic" title="{PREV_TITLE}"><img src="{LOCATION}images/prev.gif"  border="0px" align="middle" alt="{PREV_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{NEXT_TGT}" class="navmenu_pic" title="{NEXT_TITLE}"><img src="{LOCATION}images/next.gif"  border="0px" align="middle" alt="{NEXT_TITLE}" /></a>
                </td>
        </tr>

EOT;
?>

learning requires patience; teaching requires more

Paver

@nontekkyguy: First of all, you should use the "CODE" button to bracket code you want to paste into a posting; it makes it so much easier to read.  Second of all, you shouldn't paste code or debug_info unless you are asked to.  In this case, you can merely say your theme.php does not include the code mentioned.

Finally, what code are you referring to?  It is not clear if you mean the $pic_html line I mentioned in the post just above yours or some other line since the line you quote is not clear what you mean.

Polifem

hi ... i`m a novice in php ...

i`ve edited exactly what u said but it seems it doesn't do anything!!!


This is my theme.php

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.1
  $Source:
  $Revision: 1.10 $
  $Author:
  $Date: 2005/04/30 07:13:16 $
**********************************************/

define('THEME_HAS_RATING_GRAPHICS'1);
define('THEME_IS_XHTML10_TRANSITIONAL',1);

        
$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=\"$picture_url\">Right-click and Save to download video</a></p>";

?>



and this is my 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();
?>


my page is www.insomniaracing.org/gallery !!!


plz ... does anyone notice something fishy?

Paver

Your problem is in your theme.php; you are not customizing theme.php correctly.  You need to copy the entire function or variable you want to customize from sample/theme.php.  You only copied a few lines.  If you read this entire thread, particularly mrandall's note about copying the theme_html_picture function, you'll understand better how to get this customization working.

Copy the entire theme_html_picture function from sample/theme.php into your theme.php, then modify the lines in that function.

wuurp

How can I prevent unregistered users from using this to download videos?

I've used the solution in the FAQ of limiting unregistered users to thumbnails only, and I've also edited httpd.conf to prevent direct linking to video types. But if someone just directly uses a link like this http://www.mygallery.net/download.php?pid=176 they can download the video or hotlink to it on their site.

Can I just use the same code from the FAQ, i.e.
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);

and if so, would it go after the line
require('include/init.inc.php');


Paver

Sounds good to me.  Why not try it out?

wuurp

I waited a few days as a "courtesy" to all those who hotlinked and then tried it out. Seems to work fine. I guess I was just being overly cautious in messing with code I haven't really worked with.

Thanks.

wuurp

I wasn't sure if I should add to this thread, or start a new topic, but I am having memory problems using this hack.

I've been using it without problems for a couple months, but in the last few days, I have had problems running out of memory. What seems to be happening is that while the file is being downloaded, the particulary httpd thread starts consuming more memory. So if I have an 80MB file, at the end of the download, that thread is using 80+MB. After the download finishes, usually the memory is released, but not always apparently, so after a day each httpd thread was using 16-20MB even when idle. Add in a few large downloads and soon apache is using 100's of MB. I just recently updated to 1.4.4 but a clean install of both 1.4.2 and 1.4.4 exhibit this behaviour.

The only change I know of on the server is going from a 2.4 to a 2.6.8 kernel which is about the time I started having memory problems.

I've had to go back to just using a download link, which doesn't have any significant effect on the amount of memory used, but I'd like to use this again if someone has an idea how to fix it.


superstan

Please can you help me with this

There is no code that looks like anything you suggest on the 1st post - that i can alter in theme.php(rainyday)

when i go to the sample theme.php - im not sure which code i need -
there is something about 'if a user has no plugin' that looks like it - but i dont know how much of the code i need

whateverr i try i get syntax errors - unexpected {{
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.planetdarren.co.uk%2Fforums%2Fimages%2Favatars%2Fgallery%2Fdarren%2Fdazboy.gif&hash=bb703a0762c41ae1c1106ea6a153f9165ca94207)

superstan

hi guys ive sorted it in fashion by copying the whole of the sample theme.php to my template theme.php - but it does spoil the look of the mavigation a bit - but at least it works

why do i have negative karma - what have I done  ???
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.planetdarren.co.uk%2Fforums%2Fimages%2Favatars%2Fgallery%2Fdarren%2Fdazboy.gif&hash=bb703a0762c41ae1c1106ea6a153f9165ca94207)