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

Loading an Iframe for a specific domain

Discussion in 'PHP & Perl' started by akwin4565, Jan 19, 2014.

Thread Status:
Not open for further replies.
  1. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Consider i have two sites domain1 and domain2

    I want to Iframe domain2 in domain1 for only particular websites like GOOGLE

    HELP ME PLEASE...

    THANKS IN ADVANCE.
     
  2. tahworld

    tahworld Regular Member

    Joined:
    Aug 16, 2013
    Messages:
    457
    Likes Received:
    393
    Location:
    ✔✔✔✔✔✔✔
    Last edited: Jan 19, 2014
  3. m.rvs2141

    m.rvs2141 Power Member

    Joined:
    Feb 22, 2011
    Messages:
    756
    Likes Received:
    691
    • Thanks Thanks x 1
  4. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    I dont need full page
    i need a code or something else that loads the iframe like below only to sites like for example google .

     
  5. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    Should not be too tough. Use server side code for that. E.g. if you use php, sudo code might be something like:

    Code:
    // get the $_SERVER['HTTP_USER_AGENT'];
    // match with some predfined bot strings like "googlebot" and so on ( make an array of those )
    // if the string matches echo iframe else echo normal code
    
    
     
  6. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Can you help me with a example

    i found words like googlebot but i duno where to use

    and i m using php can you give me a example
     
  7. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    ^^ Could you be more specific on what you are trying to achieve? Do you want to show an iframe to visitors from google search, or do you want to show an iframe to the googlebot ( makes no sense to me lol) ?
     
  8. TheVegan

    TheVegan Junior Member

    Joined:
    Mar 6, 2013
    Messages:
    179
    Likes Received:
    33
    Occupation:
    blackhat
    Location:
    Prague
    I might be able to help but I'm not exactly sure what your trying to do??
    So you want to have an iframe only if someone is coming from a certain site or what?
     
  9. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Yes only google search users must see the iframe
     
  10. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    If you are trying to show iframe to visitors coming from certain sites like google, then check this stackoverflow question.
    Code:
    http://stackoverflow.com/questions/700672/how-do-you-detect-if-your-website-visitor-came-from-a-google-search-result
    Edit: Get the http_referer . separate the domain after you get the referrer. In the domain, search for the term "google". If it matches, show the iframe.
     
    Last edited: Jan 19, 2014
  11. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    i found the above code on a site but when i try this iframe loads when it is not from google search
     
  12. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    that's completely different than what you need. This will show the iframe to a goole bot. You need to trace HTTP_REFERER , not the user agent.
     
  13. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Yes it should show to google but not to any other sites
     
  14. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Only google search users must see the iframe and others should not get the iframe.
     
  15. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    Code:
    
    $ref = @$_SERVER['HTTP_REFERER'];
    $url_structure = parse_url($ref);
    if(isset($url_structure['host'])){
    if(stripos($url_structure['host'] , 'google') !== false){
        echo "<iframe src='http://blabla.com'>";
    }else {
        echo "You are a normal visitor";
    }
    }else {
        echo "You are a normal visitor";
    }
    
    
    #spoonfeedme
     
  16. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    In this all i have to do is to change the url??????

    Thanks for the spoonfeed
     
  17. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    Yes place proper iframe code there. In the else part will be your usual code(keep in mind that there are two else parts. To avoid this, in the if part disply iframe and exit() . Remove the else parts and place your usual code after that block of php).
     
  18. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    Still i cant get it i m noob

    just give me the code in which i have to place my site
     
  19. tahworld

    tahworld Regular Member

    Joined:
    Aug 16, 2013
    Messages:
    457
    Likes Received:
    393
    Location:
    ✔✔✔✔✔✔✔
    Dear GOD

    ..............

    [​IMG]
     
    • Thanks Thanks x 2
  20. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    I am new so that i ask if you could help me it wud be gr8
     
Thread Status:
Not open for further replies.