Solved

Hotlinking: What do i output from my cgi?

Posted on 2004-04-29
3
217 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.csv files 5 93
Perl script to find new files and compress those new files 5 94
After Effects Random Number, but different each time 5 107
Need help editing script 3 74
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

777 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