Solved

Hotlinking: What do i output from my cgi?

Posted on 2004-04-29
3
215 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to count occurrences of each item in an array.

763 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

7 Experts available now in Live!

Get 1:1 Help Now