Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old September 21st, 2000, 06:38 AM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I'm trying to make a rule for images so that they always appear with a banner. The problem is that it isn't working like it should and I was actually hoping someone could help me out. I use the following:

################################################################
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://212.64.58.122/carmacity/.*$
RewriteRule ^.*(.jpg)$ /carmacity/images/showimage.cgi
################################################################

With this rule images show up together with a banner when the image isn't requested from http://212.64.58.122/carmacity/.*$ but only if you refresh one time. First time it's broken. And, when you click on a link from within the domain the image shows up without the banner.

What I actually want is that all images except when they are requested from within a .gc script they appear normally as inline images. But when you click on a image to view the bigger version it should appear with the banner.

I've been trying it for 2 days now and I just can't work it out.

Reply With Quote
  #2  
Old September 21st, 2000, 03:16 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
1) For 1st visit to your http://212.64.58.122/carmacity/, do you want the images to be broken?
2) Under what circumstances should a banner appears?
3) When should images be broken?
4) As per your RewriteRule, I see you just want .jpg extension to internally directing to showimage.cgi. How about .gif? .jpeg? Or is there a directory that keeps all your secret images separately from your regular images that you want to hide from or force a banner?
5) Assuming a visitor doesn't need to refresh once and he's already at your site. Should he sees everything normally and without a banner?

>>when they are requested from within a .gc script

What .gc script? What does it do?

Reply With Quote
  #3  
Old September 21st, 2000, 03:56 PM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
a .gc script is just a php script with other extension
Anyways, I've managed to fix most of the rule and I just use the rule in the directory that needs to be 'protected'. Now the images should always appear together with a banner and a link back the site.
I'm now using this ruleset:

#######################################################################
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$
RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc
#######################################################################

The referer is use to prevent the ruleset to loop. Now have the following problem...
Whenever you want to view a image it appears to be broken the first time, when you refresh the image will appear.
What am I doing wrong here? Why doesn't the image show the first time?

Thanks

Reply With Quote
  #4  
Old September 21st, 2000, 05:11 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>Now the images should always appear together with a banner and a link back the site.
>>Why doesn't the image show the first time?
Are you sure? A direct request to http://212.64.58.164/carmacity/images/showimage.gc gets a banner on top but a broken image at the bottom.

I sort of but not entirely get your idea.

>>RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc

Why don't you pass your catch-all jpg name or preferably ([A-Za-z0-9_]+).jpe?g$ to your showimage.gc script?

Is it true that the jpg preview page will _always have the banner on top_ while the full-size jpg page will not?

If you can answer my 5 questions previously, maybe I can come up with a rewritten rulesets.

Reply With Quote
  #5  
Old September 21st, 2000, 05:48 PM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Okay here we go then:

1) For 1st visit to your http://212.64.58.122/carmacity/, do you want the images to be broken?
That doesn't apply anymore I think as the ruleset is only active in the screenshots directory now

2) Under what circumstances should a banner appears?
Always.

3) When should images be broken?
Never, they should just appear together with the banner.

4) As per your RewriteRule, I see you just want .jpg extension to internally directing to showimage.cgi. How about .gif? .jpeg? Or is there a directory that keeps all your secret images separately from your regular images that you want to hide from or force a banner?
All screenshots are jpegs with the .jpg extension and they should always appear together with a banner.

5) Assuming a visitor doesn't need to refresh once and he's already at your site. Should he sees everything normally and without a banner?
The visitor should always see the image together with a banner. No matter were he comes from (if the referer is not http://212.64.58.164/carmacity/.* the referer is logged)

The ruleset is kinda working but somehow you always need to refresh the page before the screenshot shows.
http://212.64.58.164/carmacity/imag...g/HiRise002.jpg is an example (may not work if I got disconnected as this is running from my own pc right now). You'll probably get a broken image first and after you refresh the screenshot will appear.

Reply With Quote
  #6  
Old September 21st, 2000, 10:58 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>http://212.64.58.164/carmacity/images/tdr/screenshots/big/HiRise002.jpg is an example

There are subdir in /images too?

I wonder what codes you have in your showimage.gc since the problem seems to come from there. BTW, have you tried to relocate your showimage.gc to some other dir?

Reply With Quote
  #7  
Old September 22nd, 2000, 05:04 AM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yeah. The file .htaccess with the ruleset is in http://212.64.58.164/carmacity/imag...creenshots/big/

Changing the location of showimage.gc doesn't matter as the problem is still there. I noticed that when you click on the link to the image here it shows up the first time but that could be different for other users as it doesn't show the first time if there's no referer.

I would think my code for showimage.gc looks normal too:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><?
require("../styles/default.gc");
$image = "$REQUEST_URI";
echo"
<html>
<head>
<title>Carmageddon City: Images</title>
<style>
body { text-decoration:none;font-family:Tahoma;font-size:10pt;color:#C0C0C0; }
a:link { text-decoration:none;font-family: Tahoma;color:#FF5400 }
a:visited { text-decoration:none;font-family: Tahoma;color:#FF5400 }
a:hover { text-decoration:none;font-family:Tahoma;background-color:#870000;color:#FFBA01 }
</style>
</head>
<body text="#C0C0C0" bgcolor="#3C3C3C">
<center>
<!-- ---------- Advertising.com Banner Code -------------- -->
<SCRIPT LANGUAGE="JavaScript" SRC="http://servedby.advertising.com/site=7923/bnum=65325232">
</SCRIPT>
<NOSCRIPT>
<A HREF="http://servedby.advertising.com/click/site=7923/bnum=65325232" target="_top">
<IMG SRC="http://servedby.advertising.com/site=7923/bnum=65325232/bins=1/rich=0" border="0" alt="Click to learn more..."></A>
</NOSCRIPT>
<!-- ---------- Copyright 2000, Advertising.com ---------- -->
<br>
<img src="$image"><br>
<br>
<a href="$siteloc">Back to Carmageddon City</a>
</center>
</body>
</html>
";
?>[/code]

I'm for almost 100% sure there's something wrong with the ruleset.

Reply With Quote
  #8  
Old September 23rd, 2000, 04:59 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The problem lies with a wrong logic of HTTP_REFERER.

(1) Your Cond:
RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$

As long as the http_referer doesn't match the above URL, follow the rule.

(2) Your Rule:
RewriteRule ^.*.(jpg)$ /carmacity/images/showimage.gc

Match any jpg request and internally redirect to /carmacity/images/showimage.gc

>>I'm for almost 100% sure there's something wrong with the ruleset
(3) From within your showimage.gc script, this line -> <img src="$image"> is the problem. Such line doesn't send a http_referer of http://212.64.58.164/carmacity/images/.*$
Instead, it sends THE SAME HTTP_REFERER from your original request destination, which doesn't meet the RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/images/.*$ and causing a looping. That is, re-read your RewriteCond again.

(4) After the page stops, when you refresh it, this time, you are sending a correct http_referer which match ^http://212.64.58.164/carmacity/images/.*$, therefore, it doesn't follow the RewriteRule any longer and display the image in place.

Once again, this -> <img src="$image"> sends a http_referer which is not what you think it is from within http://212.64.58.164/carmacity/images/.*$

Reply With Quote
  #9  
Old September 23rd, 2000, 08:27 AM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
So.... What should I use then as rewrite condition?

Reply With Quote
  #10  
Old September 23rd, 2000, 04:48 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/carmcity/images/showimage.gc$
RewriteRule ^(.+) - [F]
RewriteCond %{REQUEST_URI} ^/carmcity/images/([^/A-Za-z0-9]+).jepg$
RewriteRule ^.*.jpeg$ /carmacity/images/showimage.gc?$1 [T=application/x-httpd-php]

Your script:
$image = "$QUERY_STRING";

<img src="$image.jpg"><br>

So basically you need to rename the image extension of your LINK to jpeg so the <img src="$image.jpg"><br> line doesn't match your 2nd RewriteCond.

Reply With Quote
  #11  
Old September 23rd, 2000, 10:56 PM
Viper Viper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 6 Viper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
But then it has no real use anymore. People can still link to the image then as they just do a right click > properties and they know the real name of the image.
The whole point was that when people linked to the images stored on our server that the images would appear together with a banner.

Reply With Quote
  #12  
Old September 24th, 2000, 04:07 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Then change to the following:

#############################################
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/carmcity/images/showimage.gc$
RewriteRule ^(.+) - [F]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://212.64.58.164/carmacity/.*$ [NC]
RewriteRule .*.jpe?g$ - [F]
RewriteCond %{REQUEST_URI} ^/carmcity/images/([^/A-Za-z0-9]+).jepg$
RewriteRule ^.*.jpeg$ /carmacity/images/showimage.gc?$1 [T=application/x-httpd-php,L]
#############################################

At least they can't directly typing your image to the browser location bar and get it displayed so that your image is not Getrightable.

[This message has been edited by freebsd (edited September 24, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Help with mod_rewrite


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway