"Copy this code to display our images on your site" type of solution "Copy this code to display our images on your site" type of solution
 

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

Main Menu

"Copy this code to display our images on your site" type of solution

Started by sjordan, February 07, 2006, 07:18:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sjordan

Hello,

I'd like system whereby a bit of text (a code snippet -- presumably javascript) appears next to the various versions of photos on our gallery.

When a user sees a photo and would like to display it on their site, they should be able to copy the code we display and paste that code on their site. That code should be reasonable unintelligle as to what's happening on our server.

We've installed an .htaccess file to prevent direct hotlinking to photos. The code snippet should navigate this impediment. It should handle 'authentication', serving up the image, and serve up the specific image version (i.e. size) beside which the code is displayed.

This code snippet idea might be analogous to Google Adsense. Without their JavaScript snippets, serving their ads would be very difficult (note: I did not say impossible, but not easy for the uninitiated).

Thank you

====================
Specs:

CPG 1.43
PHP 4.3.4
MySQL 4.0.18
Mandrake 9

Joachim Müller

add custom JavaScript to your coppermine theme. If it's suppossed to show up on all coppermine pages, add your code to themes/yourtheme/template.html
If the custom script is meant to show up on the intermediate pics display, edit themes/yourtheme/theme.php, find the intermediate file display section and add it there.

This has been asked quite often already, please search before posting, e.g. for "Google Adsense", as the method to add your custom script is actually similar to adding Adsense code.

sjordan

GauGau,

Thank you for your reply.

Reading back over my post, I see how it does appear that I'm asking 'how (or where) to post a code snippet so that it appears on the gallery'. In fact, I'd already searched the forums and understand that editing the themes will accomplish this. I must make an effort to more clearly state the question.

Specifically, I was asking (keeping in mind the architecture of CPG and our use of the .htaccess to prevent hotlinking) for pointers on how that obfuscated code snippet might be written to allow others to paste it on their sites and serve images from our gallery.

Thank you


Joachim Müller

hotlink protection is hotlink protection - you either allow other pages to hotlink your images or you don't. Enabling hotlink protection using .htaccess, there's no JavaScript workaround to break it. The whole point of hotlink protection is to disable hotlinks, don't you agree?

sjordan

GauGau,

As illustration, I might write a JavaScript snippet that references a php file on our server. That php file/script might do a fopen


<?php
$filename 
"somepic.jpg";
$handle fopen($filename"rb");
$contents fread($handlefilesize($filename));
fclose($handle);
?>



Now I've buffered the image.

I've accomplished a few things:

1. The REFERER is now that of the php script (i.e. our own server), so htaccess is overcome
2. But direct access to pictures is still disabled
3. I can serve up the image in perhaps a different context (ex. with a Google Maps style layer over it)

Would this example not work?

So, the point of my intial posts was to get any pointers that I might need to be mindful of within the CPG architecture, such as how best to handle authentication for serving images that are restricted to members only. Ex. a member might get our code snippet and paste it on his site. We need to know that the member is requesting the file and have the php file handle it accordingly.

This is a crude web service. JavaScript is usually the lowest common denominator that we can rely on a client having.

Thanks

Joachim Müller

this'd require a very complex PHP file to come up with in the first place, the JavaScript bit is trivial compared to the PHP script needed if you actually want permissions to be respected.

sjordan

GauGau,

Yes, I suspected as much and that's why before I started wading blindly into coding such a thing, I thought to ask for pointers.

Clearly, if you know what I'm trying to do, it would be heaps more efficient for you to provide guidance in the form of perhaps a task list.

Your expertise is sought and appreciated.

Salim

Joachim Müller


sjordan