Results 1 to 5 of 5

Thread: PHP redirect help

  1. #1
    Join Date
    Sep 2006
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP redirect help

    I'm looking for a php script to redirect all request to the main page before entering the forum.

    i.e. if someone type in http://www.dynamicdrive.com/forums/newthread.php or http://www.dynamicdrive.com/forums/s...ead.php?t=xxxx or http://www.dynamicdrive.com/forums/

    they will be redirect to http://www.dynamicdrive.com/news

    and from there the can click on the button "continue" then it will take them to where they requested.

    if they request to go to http://www.dynamicdrive.com/forums/newthread.php then when they click continue it will take them their .

    and if they see the new page already they can go direct to the forum without seeing it untill the cookie exprires or they close their browser.

    search enginee should be exclude so they can index.

    i google about php redirection but couldn't find anything please help

  2. #2
    Join Date
    Sep 2006
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i found this code, the only problem it's it block out user that using firewall that doesn't send out third party cookies such as zone alarm (have to turn it off)

    can someone help

    Code:
    session_start();
    $UR_DOMAIN1 = 'www.google.com';
    $UR_DOMAIN2 = 'http://google.com';
    $TEN_COOKIE = 'firewall';
    
    if ( strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'] ,'Googlebot')||strstr($HTTP_SERVER_VARS
    ['HTTP_USER_AGENT'] ,'msnbot')||strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'] ,'slurp'))
    {}
    else{
    if( file_exists($firewall) ){ require_once($firewall);}
    if((strpos($_SERVER['HTTP_REFERER'], $UR_DOMAIN1) !== 0)) {
    if (empty($HTTP_SESSION_VARS['{$TEN_COOKIE}']))
    {
    	if (!empty($HTTP_POST_VARS['{$TEN_COOKIE}']))
    	{
    		session_register('{$TEN_COOKIE}');
    		$HTTP_SESSION_VARS['{$TEN_COOKIE}']='myforum_protection';
    		header("location: ".$_SERVER['REQUEST_URI']);
    		exit();
    	}
    
    	if((strpos($_SERVER['HTTP_REFERER'], $UR_DOMAIN2) !== 0)) {
    if (empty($HTTP_SESSION_VARS['{$TEN_COOKIE}']))
    {
    	if (!empty($HTTP_POST_VARS['{$TEN_COOKIE}']))
    	{
    		session_register('{$TEN_COOKIE}');
    		$HTTP_SESSION_VARS['{$TEN_COOKIE}']='myforum_protection';
    		header("location: ".$_SERVER['REQUEST_URI']);
    		exit();
    	}
    
    $sform='
    
    HTML CONTENT GO HERE
    
    ';
        echo $sform;
    
        exit();
    }
    }
    }  
    }
    }

  3. #3
    Join Date
    Jan 2008
    Location
    Cincinnati
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You could use GET, couldn't you?

  4. #4
    Join Date
    Sep 2006
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    how would i do that ???

  5. #5
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Or you could shorten the above load of unnecessary junk. Of course (SOME of) its helpful, but not necessarily needed. A simple PHP version:

    Code:
    session_start();
    $visit=$_SESSION['visit'];
    
    if ($visit=="yes") {
    print("
    the page the page
    ");
    }
    
    else {
    session_start();
    $_SESSION['visit']='yes';
    
    print("
    <html>
    <head>
    <script type=\"javascript\">
    window.location='thesite.com/news';
    </script>
    </head>
    <body>
    </body>
    </html>
    ");
    }
    That script (best I can figure) has protection from Google, Yahoo, etc. from seeing this redirect but I can't mess with it as I've never used the functions it uses up there. I miht be able to rig something up with switch, but I don't think ti would work quite the way I'm expecting. Anyways that should work for as long as they are still visiting your site after maybe 10-15 mins of being inactive on your site it will be forgotten.


    EDIT: and yes you could use GET.

    Code:
    $visit=$_GET['visit'];
    
    if ($visit=="yes") {
    print("
    the page the page
    ");
    }
    
    else {
    print("
    <html>
    <head>
    <script type=\"javascript\">
    window.location='thesite.com/news';
    </script>
    </head>
    <body>
    </body>
    </html>
    ");
    }
    Although you'd need a special link to get back , thesite.com/whatever.php?visit=yes and it could be bypassed.
    Last edited by TimFA; 01-20-2008 at 03:08 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •