Attention: PROnetworks has upgraded our forum from phpbb2 to phpbb3!!

Please head over to our new converted forum at: http://www.pronetworks.org/forums/

This old forum will remain 'read-only' until approximately February 2009. We look forward to seeing you at the new forum!
Author Message
xi0n
PostPosted: Thu Jul 01, 2004 9:56 pm Reply with quote

Banned
 
 


Joined: 01 Jul 2004
Posts: 86
For a small site, no one ever buys a domain for it. (Normally) You'd normally use say a .tk or .owns.it or .cjb.net - well you get the drift. The only problem is to an experienced computer user that’s a no good sign - Your website in a frame.

I have thought up a great idea in bed a few days ago were you can keep your site in the .tk frame and sort of not be in the frame as you can add stuff to the address afterwards. Basically going to www.site.tk/news.html will change the frame address it www.geocities.com/site/info/~pages/news.html or whatever your large address is. And this will work with any redirection. No way....Yes way!

How:

It works in a 3 step process:

Redirection Page > Page Identification > Page

The 'Redirectrion Page' is the www.site.tk. Now when you set your redirection page make it send you to the 'Page Identification'.

All the good stuff is stored in the 'Page Identification' area. Basically with PHP you can identify the page you were linked from - in this case the 'Redirection Page'. So in our about sample it would be www.site.tk/news.html. Then using a few methods we can remove the www.site.tk/ and were left with news.html. Once it go that it Opens the 'Page' that in this case will be 'news.html' and you have your site. Easy and real handy

Why:

Really... there isn’t much use - just looks i guess. I hate it when i want to copy the URL of the page and it’s in a frame, never again with this script. Also if someone remembers 'hey, i don’t want to go all the way thorough the site, i want to go rite to the news' he could just type www.site.tk/news.html were with the normal way he couldn’t do that.

You can turn your redirection into your own domain.

Setup:

Ok, well to start when you set up your redirection make it redirect to the 'Page Identification' and in this we will call it say pageident.php. So it will be something like this: www.geocities.com/site/info/~pages/pageident.php.

Next paste this into pageident.php: (ill explain it all soon, just follow me for now)
Code:
<?php
###Only Change the next 2 lines:###
$base = 'www.site.tk/'; #NOTE: Do NOT add http://
$index = 'index.html'; #NOTE: Do not add the domain (EG: www.site.tk) or slash at start (/)
$error = 'error.php';
###Do not edit pass if you dont know what your doing!###
$ref = $_SERVER['HTTP_REFERER'];
$url = str_replace($ref,'',$base);
$url = str_replace('http://','',$url);
if( $url == '' ) {
include($index);
}
elseif( file_exists($url) ) {
include($url);
}
else {
include($error);
}
?>


Once you have done that edit the 2nd, 3rd and 4th line with your website 'base' WITHOUT http://, the index page for if someone just went to www.site.tk with out anything after it and a error page if the page can not be found. You may also set the error page to the index if you want it just to go back to the index if it’s not found.

Finally change all the links on the 'page' from something like this:
Code:
<a href='news.html'>News</a>

To this:
Code:
<a href='news.html' target='_top'>News</a>

But also note if you’re using some sort of command like <base> you will have to change it to this:
Code:
<a href='http://www.site.tk/news.html target='_top'>News</a>

That it safer. So your better using that if you’re not sure.

Explanation:

Now i will explain the code for the 'Page Identification'

The first 3 lines of code are Vars that you have to change to your needs. You already know about them.

The 4th line of code is where we store in a Var were you were linked from.

On the 5th line we remove the var $base from the linked page by using Find and Replace and replacing it with nothing.

Next we separately remove http:// using the same method. We do them both separately because if someone goes to www.site.tk/news.html not http://www.site.tk/news.html It will not replace it as there is no http:// it can find - and if they were both together it would also not replace the www.site.tk.

In the next 3 lines it says If there was no page after www.site.tk/ open the index page.

In the next 3 lines its saying if the first statement isn’t true ^^ and the page after www.site.tk/ exists open it.

Finally it says well if both of these statements are not true then the page must not exist - so it opens the error page.
 
Back to top
Weaver
PostPosted: Thu Jul 01, 2004 11:05 pm Reply with quote

PROfessional Member
 
 


Joined: 18 Jun 2002
Posts: 2587
Location: /home/weaver/
Interesting approach. I haven't tested it out as of yet but it seems interesting... Not exactly my coding style but as long as I am not forced to use it I cannot pass judgement.

Quote:
Next we separately remove http:// using the same method. We do them both separately because if someone goes to www.site.tk/news.html not http://www.site.tk/news.html It will not replace it as there is no http:// it can find - and if they were both together it would also not replace the www.site.tk.


I may be wrong but AFAIR the Referer: is always sent in the form of 'http[s]://domain.TLD/[SOME_PATH]'. So you do not need to implement checks as to whether or not 'http://' has been sent in the header.

A few questions/comments. Some clients do not send Referer: headers, does your script handle this the way you desire it to? In addition, what if the Referer: is 'https://'', does your script in its current state (ignoring previous recommendations) handle this the way you desire?

-Weaver
 
Back to top
xi0n
PostPosted: Thu Jul 01, 2004 11:39 pm Reply with quote

Banned
 
 


Joined: 01 Jul 2004
Posts: 86
eh..see ya point:

1. Youd nevea have a https redirection - or so i think
2. ok - your rite it always does the http - did just to be safe
3. good point if they dont send them - i donno. this hole script i just thought up in a few moments. My solution would be something like this:
Code:

if( $ref == '' ) {
include( $index );
}

but then you have the problem everytime some1 clicks on a link you get index if you do not send referers. So id have to fix up the links to:
Code:

function onsite_link($url,$msg,$prams='') {
if ( $_server['HTTP_REFERER'] == '' ) {
print '<a href="'.$url.'" '.$prams.' >'.$msg.'</a>'
}
else {
print '<a href="'.$url.'" '.$prams.' target="_top
">'.$msg.'</a>'
}
}

If any1 is really intrested in dis script just like e-mail me and ill rewrite it wid these fixes
 
Back to top
Back to top
Index >> Webmaster Domain & Code Room >> Website Redirection - A boot for a PHP Server

Page 1 of 1

 


Tired of the Ads? Registered users have 80% less adverts.