Advanced search  

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

Pages: [1]   Go Down

Author Topic: "Copy this code to display our images on your site" type of solution  (Read 7275 times)

0 Members and 1 Guest are viewing this topic.

sjordan

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: "Copy this code to display our images on your site" type of solution
« Reply #1 on: February 07, 2006, 07:58:06 am »

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.
Logged

sjordan

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: "Copy this code to display our images on your site" type of solution
« Reply #2 on: February 08, 2006, 12:16:09 am »

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

« Last Edit: February 08, 2006, 01:23:24 am by sjordan »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: "Copy this code to display our images on your site" type of solution
« Reply #3 on: February 08, 2006, 12:25:31 am »

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?
Logged

sjordan

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: "Copy this code to display our images on your site" type of solution
« Reply #4 on: February 08, 2006, 12:56:45 am »

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

Code: [Select]
<?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
« Last Edit: February 08, 2006, 01:18:42 am by sjordan »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: "Copy this code to display our images on your site" type of solution
« Reply #5 on: February 08, 2006, 01:10:02 am »

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.
Logged

sjordan

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: "Copy this code to display our images on your site" type of solution
« Reply #6 on: February 08, 2006, 01:16:55 am »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: "Copy this code to display our images on your site" type of solution
« Reply #7 on: February 08, 2006, 01:19:48 am »

take a look into cpmFetch, particularly CFIMAGEGET
http://forum.coppermine-gallery.net/index.php?board=57.0
Logged

sjordan

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: "Copy this code to display our images on your site" type of solution
« Reply #8 on: February 08, 2006, 01:40:44 am »

Thank you. I'll dig into it.
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 19 queries.