CPG 1.4.x Remote Hosting Hack Beta4 Installation : 
! based on CPG 1.4.2 stable source files !

* Beta4 CHANGES
- hack code locations are clearly marked with "#REMOTE HACK START/END" blocks.
# batch add tool
- support for user1 to user4 extra info.
- added pictures log in the database.
# web display
- iframes & remote pages urls instead of only remote pictures urls, kinda anti-anti-hotlinking.
- width management of remote files when not using intermediate pictures.
- added links to popup fullsize remote pictures or iframes.
- alternate, nicer way to hack into your cpg themes.


* HELP & Errors Reports & problems can be found here : http://coppermine-gallery.net/forum/index.php?topic=22564.0


* INSTALLATION : (3 Parts)
-Part 1-
Go into your CPG configuration page : 
Find the section called : "Custom fields for image description (leave blank if unused)"
And put the following inside "Field 4 name" : "Remote URL"
If you want to use teh iframe support you will also need to set the following :
"Field 3 name" : "Remote Page URL"

-Part 2-
Now you have two ways to hack into your CPG :
The difference between the two ways resides in the place you hack your CPG themes and only that. 
-1- You can either hack the (global) CPG include file (include/themes.inc.php) which will make the hack work on any theme.
OR
-2- You can modify your theme file (themes/xxx/theme.php) what will make the hack work only for that specific xxx theme.
That second way is also the only way to hack into a modified/customized theme, such modifications taking place in that particular themes/xxx/theme.php file and overriding modifications to the global include/themes.inc.php.

So chose your way of completing this part as follows :
-1- 
overwrite the following file with the one provided in this archive :
include/themes.inc.php

OR

-2-
copy the code in the file themes/theme_functions.txt just before the final "?>" in your theme themes/xxx/theme.php file.
The modified functions are the following : a couple of define(), theme_html_picture, theme_slideshow, theme_display_fullsize_pic
Although it won't be the case with all the default CPG themes, if any of thoses functions are already present in your include/xxx/theme.php file then you will have to modify them by inserting the code blocks #REMOTE HACK START/END inside your already existing functions.


-Part 3-
overwrite the following file with the one provided in the archive :
-> Only required if you want the slideshow to work with remote pictures
include/slideshow.inc.php

copy the following file in your CPG root :
files.php

In addition to copying the include/slideshow.inc.php file, you have to manually edit the following file :
-> Modification required for the slideshow hack to work.
## file : include/functions.inc.php - Line 905 ##
REPLACE :
            $select_columns = 'pid, filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, aid, keywords';
WITH : 
            $select_columns = 'pid, filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, aid, keywords, user3, user4';


You're Done !


* QUICK BATCH ADD TOOL GUIDE :
In order to insert remote pictures in your gallery you will have to use my batch add tool "files.php".
You can only use it if you were previously logged in as an admin with the same browser.

You have to upload a file containing all the necessary information for my tool to add the remote pictures inside your gallery.
That file has to be formated as follows (check the forum thread url above for futher info/examples) :

/path/to/album
http://www.domain.com/path/to/picture.jpg
http://www.domain.com/path/to/picture.jpg
http://www.domain.com/path/to/picture.jpg
http://www.domain.com/path/to/picture.jpg
/path/to/other/album
http://www.domain.com/path/to/picture.jpg
http://www.domain.com/path/to/picture.jpg
http://www.domain.com/path/to/picture.jpg


and so on..

/path/to/album and /path/to/other/album will be the physical paths use on the local server to store necessary local pictures (thumbnails and intermediate picture if enabled) and they will also be used to created automatically the category/album path in you gallery.

Ex: with /path/to/album
the category "path" will be created if not already existing, the subcategory "to" will be created if not already existing and placed under the category "path", and the album "album" will be created if not already existing and placed inside the category "to".
The following 4 pictures will be added to the album "album".

If you already understand how cpg managed its categories/albums then you've probably already figured out what will be created with the second part of the list above.
The subcategory "other" will be created and placed under the already existing category "to" and the new album "album" will be created and placed inside the category "other".
As you've noticed there are now two albums named "album" in your gallery, this is all but normal as cpg does not consider an album unique based on its "name", and my script reflects that.

But you will also understand that if the second path had been "/path/to/album", so exactly the same as the first path, then the last 4 pictures would have been added to the very same album "album" inside the category "to" where the first 4 pictures were added too..


* Using IFRAMES, "Remote Page URL" data and other user data:
In order to use the iframes you will have to provide my batch add too with a second data for your remote pictures which is the remote page url from where that remote picture can be seen.
Indeed as you probably already know many free pictures hosts give access to hosted pictures thru a web page of their own, so the following picture "http://www.freepichost.com/random/path/to/picture_name.jpg" can be accessed thru the following URL "http://www.freepic.host/page.php?picture=picture_name.jpg", or something like that.
It can happen that accessing the picture using its direct URL will return an "access denied" page or a different picture mentioning the fact that you can't access the picture directly. Then the only way to access that picture is done by accessing the web page with the second link.
So if you set your CPG user data 3 aka "Field 3 name" with the following name "Remote Page URL" and provide my batch add tool with the page URL then it'll be stored and used to display that picture thru it's webpage inside the gallery using an iframe.
You will also have to set the default "define('REMOTE_PIC_IFRAME',0);" to "define('REMOTE_PIC_IFRAME',1);" to enable iframes.

Then you can build your remote picture list as follows :
/path/to/album
http://www.freepichost.com/random/path/to/picture_name.jpg \ http://www.freepic.host/page.php?picture=picture_name.jpg
...

the page URL is placed on the very same line as the picture url and separated by a "\".

You can also place two more data on every line that will be stored insode the "Field 2 name" and "Field 1 name" of each of your added pictures.
So in a matter of speaking you could see each picture line with the following description :

Picture URL \ Page URL \ user data 2 \ user data 1

or if you're not using Page URL and iframes you can even see it like that :
Picture URL \ user data 3 \ user data 2 \ user data 1

You can of course put anything you want on each data, expected you won't use the "\" char in yout text strings..
Beware the "\" char cannot be escaped link in some programming language, the strings will be interpreted asis.


* Using the width management with remote pictures :
When the intermediate picture is disabled you can enforce the remote picture width, displayed on your pages with an additional define() as follows :
define('REMOTE_PIC_MAXW',1);

the width of the displayed remote picture will then be according to your Max Intermediate Width Setting in CPG config.
Of course i've made sure to add a link above the iframe or on the picture in order to display the fullsize one with the CPG popup you already know.


* Using the Added Pictures Log :
That log is simply an additional table you can create/purge/remove within my batch add tool, that will log every picture you add to your gallery.
You can very well leave that alone and never use it, it will not make any difference in the way my Remote hack works online..

The only idea behind that log was to avoid inserting the same remote picture more than once.
So if you insert a remote picture in your database and for some reason decide to delete it from you database manually then when the log is active the batch add tool won't add that very same picture ever again when it finds it in your lists.
The reason for that log is that i'm using some automated scripts that go over remote pictures lists that can have the same source from times to times and i don't want the pictures i've removed manually to be added ever again, so i keep a log of every picture i've added to the gallery and decide not to add them in the future.
Of course as nobody's perfect you can always make mistakes and remove pictures you shouldn't have, so you can override the log whenever you want during a single batch add session. The log will then be ignored.


* LIMITATIONS :
- CPG Admin Mode Pictures manipulation / modifications are subject to failures. 
Example : 
When editing your remote pictures you cannot refresh the picture EXIF data.
Regenerating thumbnails or modifying the fullsize picture won't work with remote pictures !
