Solved

Hotlinking: What do i output from my cgi?

Posted on 2004-04-29
3
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

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.
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

752 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