Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-11-2006, 03:32 AM   PM User | #1
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
Substitution for .htaccess password

dns.inc.php:
PHP Code:
<?php
if (!stristr$_SERVER['HTTP_HOST'], 'server2')) { 
    
header('Location: http://games.game-host.org/css'); 
}  
?>
where server2 is the computers name and http://games.game-host.org/css is the address to go to if the domain is not correct.
------------------------------------
This will only work if the client and the server are on the same network.

Purpose:
I did this because I needed a way to have an admin panel just for me. This also takes all passwords out of it. No passwords and no usernames.

How?
server2 has to be a network only dns(computer name). Then have it redirect to anything you want if its not correct.
Just include that dns.inc.php page on every page ytou want protected.

Working example:
http://games.game-host.org/css/maps_admin/
will redirect you to:
http://games.game-host.org/css/
But
http://server2/css/maps_admin/
will be the page with no change. You will not even know it is there.
http://server2/css/maps_admin
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Old 02-11-2006, 12:00 PM   PM User | #2
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
I am afraid it might fail.
Attached Thumbnails
Click image for larger version

Name:	maps_admin.png
Views:	442
Size:	34.5 KB
ID:	4261  
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Old 02-11-2006, 03:56 PM   PM User | #3
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
weird... its worked great so far
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Old 02-12-2006, 08:03 AM   PM User | #4
matthijs
New Coder

 
Join Date: Sep 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
matthijs is an unknown quantity at this point
you cannot trust any $_SERVER variable that begins with HTTP (e.g., $_SERVER["HTTP_REFERER"], $_SERVER['HTTP_HOST'])

See for example http://shiflett.org/archive/98
matthijs is offline   Reply With Quote
Old 02-12-2006, 03:41 PM   PM User | #5
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
OK, well I wont use that anymore.
I am more or less a php newbie... BUt im getting better.



ILLINI
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:50 AM.


Advertisement
Log in to turn off these ads.