Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Need Help with PHP Statement

  1. #1
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts

    Need Help with PHP Statement

    I want to make it on my proxy top site, ProxLists.com, so that if you click any of the links from a site besides ProxLists, it will redirect to the home page instead of to the appropriate proxy. The code I am using is as follows:

    Code:
    $referer = $_SERVER['HTTP_REFERER']; 
    
    if  ($referer != "http://www.proxlists.com") {
    
    header('Location: http://www.proxlists.com');
    
    } else {
    
    $db->query("UPDATE {$db_tp}proxy SET hits = hits + 1 WHERE id = $id");
    header('Location: '.$row[0]);
    
    }
    It says that if the Refferer is not ProxLists, it will redirect to the home page. Otherwise, it will add a hit to the count and then redirect to the right proxy.

    It does prevent hotlinking, however, if you click on a link in the list, it redirects to the home page as well! Can anybody help?
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  2. #2
    Will.Spencer's Avatar
    Will.Spencer is offline Retired
    Join Date
    Dec 2008
    Posts
    5,033
    Blog Entries
    1
    Thanks
    1,010
    Thanked 2,327 Times in 1,258 Posts
    Instead of using PHP, I am doing the same thing using Apache's mod_rewrite:
    Code:
    # Prevent hotlinking to hits.php
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?tech-faq.com(/)?.*$ [NC]
    RewriteRule .*\hits.php$ http://www.tech-faq.com/proxy.shtml [R,NC]
    Submit Your Webmaster Related Sites to the NB Directory
    I swear, by my life and my love of it, that I will never live for the sake of another man, nor ask another man to live for mine.

  3. #3
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    OK I just put that into the .htaccess and put the PHP back to normal. It's not working, I can still click the link from outside webpages.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  4. #4
    Will.Spencer's Avatar
    Will.Spencer is offline Retired
    Join Date
    Dec 2008
    Posts
    5,033
    Blog Entries
    1
    Thanks
    1,010
    Thanked 2,327 Times in 1,258 Posts
    Are you sure that your .htaccess file is being read by Apache?

    Did you change tech-faq.com to your own site name?

    How are you testing this functionality?
    Submit Your Webmaster Related Sites to the NB Directory
    I swear, by my life and my love of it, that I will never live for the sake of another man, nor ask another man to live for mine.

  5. #5
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    1) Yes I am positive, since I am using .htaccess for other redirections.

    2) Yes I did.

    3) I am asking other people, I'm using a proxy, and I can simply do this: Anonymode Proxy - Unblock Myspace, Facebook, and other Websites

    This is my .htaccess:
    Code:
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^proxlists.com$
    RewriteRule ^(.*)$ http://www.proxlists.com/$1 [r=301]
    
    # Prevent hotlinking to hits.php
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?proxlists.com(/)?.*$ [NC]
    RewriteRule .*\hits.php$ http://www.proxlists.com [R,NC]
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  6. #6
    webmaster is offline Newbie Net Builder
    Join Date
    Feb 2009
    Posts
    30
    Blog Entries
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Will.Spencer View Post
    Instead of using PHP, I am doing the same thing using Apache's mod_rewrite:
    Code:
    # Prevent hotlinking to hits.php
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?tech-faq.com(/)?.*$ [NC]
    RewriteRule .*\hits.php$ http://www.tech-faq.com/proxy.shtml [R,NC]
    That would work probably work actually.

  7. #7
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    Quote Originally Posted by webmaster View Post
    That would work probably work actually.
    But it doesn't.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  8. #8
    miks is offline Unknown Net Builder
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have that "$row[0]" defined somewhere else?, If not, you are redirecting to an empty string. Besides that it would be nice to check only if domain name exists in referer string, because in this case you cannot refer users from other site pages (ie. ProxLists.com - Glype)

  9. #9
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    The way it should work you can still link to areas of the site without and issue you just cant hotlink the submitted proxy urls this helps avoid false inflating of stats. You might have a conflict in your htaccess as it did work on one of my sites.

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  10. #10
    Zash's Avatar
    Zash is offline WiredStorm.com - Lightning Fast Web Hosting
    Join Date
    Feb 2009
    Location
    New York, USA
    Posts
    1,137
    Blog Entries
    1
    Thanks
    64
    Thanked 121 Times in 93 Posts
    Yes everything is meant to stop inflation of stats and it is defined in other parts of the file.

    I'm working with someone to try and get .htaccess to do this.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

Page 1 of 2 12 LastLast

Similar Threads

  1. Neat Pseudo Directory Mission Statement
    By javanx3d in forum Directories
    Replies: 1
    Last Post: 7 March, 2010, 14:53 PM

Tags for this Thread

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
  •