Results 1 to 5 of 5
  1. #1
    Constant Pligger foofoo's Avatar
    Joined
    Aug 2010
    Posts
    127

    Exclamation variable for ip adress ip to country geo FLAG

    Is there a way to call up fetch the ipadres of an user who submitted an atricle?

    Im trying some code that will show a country flag on the story details page based on the user ip adres who submitted the article.

    Code:
    {if $pagename eq "story" || $pagename eq "submit"}
    <div style="float: left; top:5px; bottom:5px;">
    <IMG SRC="http://api.hostip.info/flag.php?ip={$smarty.server.REMOTE_ADDR}" ALT="IP Address Lookup">
    </div>
    {/if}
    {$smarty.server.REMOTE_ADDR} or maybe {$ip_variable}



    Do i need to copy some lookup ipadres smarty plugin in to the plugins folder ?

    How do i use these correct , $_SERVER['REMOTE_ADDR ?

    I found this can this link and info be used for what i want?

    http://www.smarty.net/forums/viewtopic.php?p=55759

    Some advanced pligger has a tip?

  2. #2
    Constant Pligger foofoo's Avatar
    Joined
    Aug 2010
    Posts
    127

    Exclamation

    I found this old thread,

    http://forums.pligg.com/questions-co...voters-ip.html

    I guess its the same i want only for the flag to show up on the story details page next to the users avatar.

    Custom coding?

    Or with some work able to do with the info from the above old thread

    Ok so how would this go?
    copy this code in a .php ?

    Code:
    // make a valid request to the hostip.info API
    if ($_SERVER['HTTP_X_FORWARD_FOR']) {
    $ip = $_SERVER['HTTP_X_FORWARD_FOR'];
    } else {
    $ip = $_SERVER['REMOTE_ADDR'];
    }
    
    $url = "http://api.hostip.info/country.php?ip=".$ip;
    
    // fetch with curl
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $country = curl_exec($ch);
    
    curl_close ($ch);
    and call it in linksummary with {$ip} ?

    {if $pagename eq "story" || $pagename eq "submit"}
    <div style="float: left; top:5px; bottom:5px;">
    <IMG SRC="http://api.hostip.info/flag.php?ip={$ip}" ALT="IP Address Lookup">
    </div>
    {/if}

    Any help apreciated.

  3. #3
    Constant Pligger urbn's Avatar
    Joined
    Oct 2010
    Posts
    107
    This will be a pretty big project if you want to try to manually add the flag. You will also run into many problems with IP blocks changing and countries that share IP blocks (which will really piss off a number of people in countries that are near one another, think ex-Russian countries for example).

    A better solution would be to have a pre-generated drop down of countries that a user can choose from.

    But if you really want to try this I would suggest checking out www.countryipblocks.net which will generate the IP address ranges for countries and such for you. I think after you generate the IP ranges for all countries you will realize how MASSIVE of a project this will be.

  4. #4
    Constant Pligger foofoo's Avatar
    Joined
    Aug 2010
    Posts
    127
    Isnt there a variable like $url $storyurl ?

    $userip

    if $pagename eq "story" || $pagename eq "submit"}
    <div style="float: left; top:5px; bottom:5px;">
    <IMG SRC="http://api.hostip.info/flag.php?ip={$userip}" ALT="IP Address Lookup">
    </div>
    {/if}

    The above code shows a flag depending on ?ip
    http://api.hostip.info/flag.php?ip=34.345.34.343 is how you would use it.

    Would work same as fetching the original story url with {$url}


    Thats what i had in mind i search the wikki but couldnt find a command for the user ip adres like $url

  5. #5
    Constant Pligger foofoo's Avatar
    Joined
    Aug 2010
    Posts
    127

    Exclamation

    Ok how bout this one simpler maybe to accomplish.

    $_SERVER['REMOTE_ADDR']

    How do i use this to fetch the submitted site ip adres.

    So not the users ip adres. But just the ip adres of the articles site for example.

    Ive setup my pliggsite for adding websites not articles.

    So ive tought instead of the users ip adres who submitted the article/website it fetches the added websites adress. Is this more easy to acomplish

Similar Threads

  1. How to register to twitter with div. ip adress.
    By janpatat in forum Questions & Comments
    Replies: 12
    Last Post: 01-18-2010, 03:36 AM
  2. Display Visitor's IP, Country Flag and Last time visited
    By raghhav in forum Questions & Comments
    Replies: 0
    Last Post: 11-06-2009, 03:10 AM
  3. Flag mod?
    By bartjr in forum Questions & Comments
    Replies: 0
    Last Post: 05-04-2008, 10:27 AM
  4. Replies: 6
    Last Post: 08-08-2007, 12:05 PM
  5. reading pligg "variable" into php code - variable assignment
    By aprathivadi in forum Questions & Comments
    Replies: 0
    Last Post: 06-05-2007, 12:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting