Solved

Hotlinking: What do i output from my cgi?

Posted on 2004-04-29
3
216 Views
Last Modified: 2013-12-25
i have a cgi program to stop people from hotlinking an image from my site.

my simple website to be protected is as follows:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<img src=http://www.mywebserver.com/~user/cgi-bin/myprogram.cgi?../images/figures.png">
</body>
</html>

my cgi accepts  ../images/figures.png as an input parameter.
it checks the HTTP_REFERER is http://www.mywebserver.com

This is not the problem though.

My problem is what i must write as outtput from my cgi.

I think as a first line i must output:
 
Content-type: image/png
i simply want the page to be generated as:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<img src="../images/figures.png">
</body>
</html>

My program is written in pascal so i dont want perl code.... all im asking is what i should output from my cgi... as a said i think the first line of output should be:

Content-type: image/png
Then i dont know what must follow

500 points!!!

thx guys!!
0
Comment
Question by:alexeijames
  • 2
3 Comments
 

Author Comment

by:alexeijames
ID: 10947125
i dont know if the code is meant to remain the same infact!!
as so:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<img src=http://www.mywebserver.com/~user/cgi-bin/myprogram.cgi?../images/figures.png">
</body>
</html>

all i want is to display my image on screen!!!!!!!!!!!

Please help!!
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 10954399
If you use the form:

<img src=http://www.mywebserver.com/~user/cgi-bin/myprogram.cgi?../images/figures.png">

Then myprogram.cgi is going to need to output the appropriate MIME header, in this instance:

Content-Type: image/png


Then the contents of figures.png


However, if you want your main HTML page to have the actual image link in it, ie:

<img src="../images/figures.png">

then you are going to need to use SSI.  But of course, this doesn't protect your images as anyone could link to figures.png, so you are better off with the first method.

BTW, congratulations on using Pascal/CGI.  You're the first person I've come across to do that.
0
 

Author Comment

by:alexeijames
ID: 10954506
haha ...i tell you what tin tin...just coz you are the first person to answer me you got yourself 500 points!!!

I figured it out already!

nice one!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
need a quick help to fix the script logic 4 63
Windows Batch File - Combing output in a single line 3 60
Groovy:unable to resolve class error 2 70
Register AutoHotkey 12 55
In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now