1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Help With Short PHP Script

Discussion in 'Black Hat SEO' started by haydenm92, Aug 7, 2009.

  1. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    I'm new to PHP and I need help with a short script to put on a webpage.

    Basically I want it to redirect the visitor someplace else if the referrer is blank, and if the referrer is anything else, then just leave them on the page.

    There are a bunch of smart people around here, I'm sure someone will be able to help me. Any help is greatly appreciated, thanks in advance!

    haydenm92
     
  2. im n0t lurer

    im n0t lurer Regular Member

    Joined:
    Jun 29, 2009
    Messages:
    229
    Likes Received:
    54
    i wont give mine out for free as im planning to sell it in the future. it works exactly as you described it but it has better options etc,
     
  3. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    I don't need much from the script, just a simple line that redirects if the referrer is blank.
     
  4. xhpdx

    xhpdx Regular Member

    Joined:
    Sep 21, 2008
    Messages:
    331
    Likes Received:
    2,160
    Occupation:
    Coder
    Location:
    EU
    this is incredibly easy, something like this:
    Code:
    $ref = $_SERVER['HTTP_REFERER'];
    
    # if the referer is blank redirect to somewhere
    if ($ref=='')
    
    header("Location: http://yoursite1");
    
    # if the referer is not blank redirect to another place
    else header("Location: http://yoursite2");
     
  5. niggles

    niggles Newbie

    Joined:
    May 23, 2009
    Messages:
    38
    Likes Received:
    14
    Occupation:
    Web developer
    Location:
    Melbourne Australia
    Home Page:
    hmm, not sure if that'll work without squiggly brackets - and haydenm92 doesn't know much PHP so -
    PHP:
    $ref $_SERVER['HTTP_REFERER'];

    # if the referer is blank redirect to somewhere
    if ($ref==''){

    header("Location: http://yoursite1");
    die();

    # if the referer is not blank redirect to another place
    } else {
    header("Location: http://yoursite2");
    die();
    }
     
  6. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    This should leave you on the same page if your still looking
    Code:
    <?php 
    if($_SERVER['HTTP_REFERER'] == NULL)
    {
    	header("HTTP/1.1 301 Moved Permanently");
    	header("Location: http://www.example.com/");
    	exit;
    }
    ?>
    <html>
    blah blah blah
    </html>
     
  7. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    Alright, great, so the script is working, but that's only if I post it it like this:

    Code:
    <?php
    $ref = $_SERVER['HTTP_REFERER'];
    
    # if the referer is blank redirect to somewhere
    if ($ref==''){
    
    header("Location: http://yoursite1");
    die();
    
    # if the referer is not blank redirect to another place
    } else {
    header("Location: http://yoursite2");
    die();
    } 
    ?>
    
    and save it to test.php

    when I try to add some html though, it doesn't work. How can I add this PHP script in an html page??
     
  8. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    Ok, let me give a quick rundown of my situation so everyone can understand what I'm trying to do.

    I'm sure you've all heard of and are may be using BHCB. Well faking the referrer isn't supported, but can be done. The way that was explained to me is to send the your link to your white hat site. Then in your white hat site, put a bit of php code stating that if your referrer is blank, it'll forward to your CPA offer.

    Obviously BHCB blanks the referrer, so any traffic from your black hat site would go to your white hat site, then the CPA offer so it looks like the referring site is your white hat site.

    This may sound good, but after thinking about it, what if my AM types my white hat site into his URL? He'll be redirected to CPA offer and I'll be done.

    So my idea was to turn off blanking in BHCB, but still send the traffic to your white hat site. Put a bit of php code in your white hat site saying if the referrer is your black hat site, then pass traffic to the CPA offer, otherwise leave the traffic there. That way any blank traffic would stay on the site. I think this is the best way to do it, b/c if your AM is coming through your black hat site you're screwed anyways.

    So basically I'm trying to find a code that I can put into my white hat site that will allow referring traffic from my blackhat site to pass on to my CPA offer.

    Anyone know how to do this in php??

    Thanks in advance!
     
  9. FarmTeam

    FarmTeam Junior Member

    Joined:
    Jun 27, 2009
    Messages:
    139
    Likes Received:
    79
    If they are coming from your blackhat site you could do

    if($_SERVER['HTTP_REFERER']=='myblackhatsite.something')
    //do stuff

    else
    //dont because it is my aff manager

    But if your driving traffic from multiple places this wont work
     
  10. trapmuzik

    trapmuzik Junior Member

    Joined:
    Mar 20, 2009
    Messages:
    192
    Likes Received:
    22
    ohhh your looking for THAT redirect script.. ahh.. it should be floating around in the forum somewhere i think. it actually using a form post method to send the visitor off to the cpa offer from a blackhat site.. let me check my computer.. i think i have it
     
  11. djelica

    djelica Junior Member

    Joined:
    Jun 26, 2009
    Messages:
    151
    Likes Received:
    60
    You can't add php script to html page as far as i know, extension must be *.php in order to work.
     
  12. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    I'm only driving traffic to my CPA offer from one location, so something like that could work.

    That would be absolutely great if you could find this because I've been trying to work this out for a while now. I've searched for forum high and low and haven't found any code that will do this.
     
  13. haydenm92

    haydenm92 Junior Member

    Joined:
    Apr 24, 2008
    Messages:
    141
    Likes Received:
    40
    Occupation:
    Student/Blackhatting
    Location:
    Idaho
    Home Page:
    Alright, I've found a way for this to work, just in case anyone was following this thread in hopes for an answer.

    Check this post out:

    Code:
    http://www.blackhatworld.com/blackhat-seo/black-hat-seo/48908-cpa-redirector-standalone-version.html
    Thx for eveyone's time, this really is the greatest forum ever!
     
    • Thanks Thanks x 1
  14. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    Of course you can...

    Add this to your .htaccess
    Code:
    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    
    and apache will parse .html files as if they were .php. See my post above for an example.
     
    • Thanks Thanks x 1