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

Thread: How to limit the length of an output ?

  1. #1
    WebEvader's Avatar
    WebEvader is offline Moderator
    Join Date
    Jan 2009
    Posts
    397
    Blog Entries
    2
    Thanks
    166
    Thanked 26 Times in 21 Posts

    How to limit the length of an output ?

    Hi,

    If you look at Proxy List | Free Proxy | Proxy Sites, there is a yellow box that tells you what the persons ip address is... and says at the top "Your IP is exposed"

    Is there a way in which i can set a limit in characters for the length of the output for "browser" and "host".

    And how can i make the white bit around it fill the space ?

    Here is the code involved:

    PHP Code:
    <div class="box">
            <div class="boxleft"><div class="boxright">
                <div class="warning"> Your IP is exposed.</div>
                
                <div class="bcontent" style="background:#FFFFFF;">

    <!-- USER INFO -->

    <?php

    $ip
    =$_SERVER['REMOTE_ADDR'];
    $browser=$_SERVER['HTTP_USER_AGENT'];
    $host=gethostbyaddr($_SERVER['REMOTE_ADDR']);


    echo <<<D


                        <table>
                        <tbody><tr><td><b>Your IP:</b></font></td><td>
    $ip</font></td></tr>

                        <tr><td valign="top"><b>Browser:</b></font>&nbsp;</td><td>
    $browser</font></td></tr>
                        <tr><td><b>Host:</b></font>&nbsp;</td><td>
    $host</font></td></tr>
                        
                        

    D;
    ?>
    </tbody></table>
    <!-- USER INFO -->
    Thanks

  2. #2
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    To limit the characters add this :

    PHP Code:
    $browser substr($browser035);
    $host substr($host035); 
    directly after this:

    PHP Code:
    $ip=$_SERVER['REMOTE_ADDR']; 
    $browser=$_SERVER['HTTP_USER_AGENT']; 
    $host=gethostbyaddr($_SERVER['REMOTE_ADDR']); 
    changing 35 to whatever length you want.

    As for the white space, probably gotta look through your css for it. but you could try changing:

    HTML Code:
    <div class="bcontent" style="background:#FFFFFF;">
    to

    HTML Code:
    <div class="bcontent" style="background:#FFFFFF; width:100%;">
    Again not sure, as I haven't looked through your css.

    Sooo, to sum it all up in one quote :
    PHP Code:
    <div class="box">
            <div class="boxleft"><div class="boxright">
                <div class="warning"> Your IP is exposed.</div>
                
                <div class="bcontent" style="background:#FFFFFF; width:100%;">

    <!-- USER INFO -->

    <?php

    $ip
    =$_SERVER['REMOTE_ADDR'];
    $browser=$_SERVER['HTTP_USER_AGENT'];
    $host=gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $browser substr($browser035);
    $host substr($host035);


    echo <<<D


                        <table>
                        <tbody><tr><td><b>Your IP:</b></font></td><td>
    $ip</font></td></tr>

                        <tr><td valign="top"><b>Browser:</b></font>&nbsp;</td><td>
    $browser</font></td></tr>
                        <tr><td><b>Host:</b></font>&nbsp;</td><td>
    $host</font></td></tr>
                        
                        

    D;
    ?>
    </tbody></table>
    <!-- USER INFO -->
    Cheers!

  3. Thanked by:

    WebEvader (27 March, 2009), Will.Spencer (28 March, 2009)

  4. #3
    WebEvader's Avatar
    WebEvader is offline Moderator
    Join Date
    Jan 2009
    Posts
    397
    Blog Entries
    2
    Thanks
    166
    Thanked 26 Times in 21 Posts
    Thank you dtkguy it works great

    I love netbuilders

  5. #4
    WebEvader's Avatar
    WebEvader is offline Moderator
    Join Date
    Jan 2009
    Posts
    397
    Blog Entries
    2
    Thanks
    166
    Thanked 26 Times in 21 Posts
    hmm, the white goes to far down in internet explorer have i done something wrong ?

  6. #5
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Happy to help

    Looks good on site too

  7. #6
    WebEvader's Avatar
    WebEvader is offline Moderator
    Join Date
    Jan 2009
    Posts
    397
    Blog Entries
    2
    Thanks
    166
    Thanked 26 Times in 21 Posts
    hey dtkguy in your signature you have quickip.org is that yours ?

    If so do you know how i can find out the country of the person and display a little flag of his country ?

    Thanks

  8. #7
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Yeah QuickIP is mine

    You can do it with geoIP, my connection is being a jerk right now, keep getting kicked offline, so I don't want to take the time to post the code. I will later, if no one else does, but I'm sure people here know how. I know Mr.Bill does, he uses it.

    You could also probably hack/mod proxywhereabouts ip2location script to suit your needs. but the geoIP method would be easier.

    pwa's script can be had here : Small user online script - as seen on PWA! - xytheMe | Free Custom Proxy Templates

  9. #8
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Okay I'm back, finally!

    If you already have mod_geoip installed it's easy, you do a little something like this :

    PHP Code:
    <?php
    //get country code and name
    $cCode apache_note("GEOIP_COUNTRY_CODE");
    $cName apache_note("GEOIP_COUNTRY_NAME");

    //make country code lower case to match flag file name case
    $cCode mb_strtolower($cCode);
    ?>

    <img src="/images/flags/<?php echo "$cCode"?>.png"> <?php echo "$cName"?>
    if you don't have mod_geoip, you can use the GeoIP Pure PHP Module, like so :

    PHP Code:
    <?php

    include("/path/to/geoip.inc");

    //put GeoIP.dat some place not publicly readable
    //such as "/usr/local/geoip/GeoIP.dat"
    $gi geoip_open("/your/path/to/GeoIP.dat",GEOIP_STANDARD);

    //get our variables
    $ip $_SERVER[REMOTE_ADDR];
    $cCode geoip_country_code_by_addr($gi$ip);
    $cName geoip_country_name_by_addr($gi$ip);

    //make country code lower case to match flag file name case
    $cCode mb_strtolower($cCode);

    ?>

    <img src="/images/flags/<?php echo "$cCode"?>.png"> <?php echo "$cName"?>

    <?php geoip_close($gi); ?>
    As you can see in the above two examples I had to make the country code string lower case because the flags I have are all lower case, and *nix based systems are a stickler for case

    I've included the GeoIP Pure PHP Module, flags, and an example.php in the attachment

    Oh and I've also finally got around to adding geoip location on quickip.org - find your ip | hostname | and more

    Cheers!

    *Edit* And a quick note, MaxMind should be updating the geoip countrylite database (GeoIP.dat) on April 1st, you'll be able to get it here when it's out Download GeoIP CountryLite Database
    Attached Files Attached Files

  10. Thanked by:

    WebEvader (28 March, 2009), Will.Spencer (28 March, 2009)

  11. #9
    WebEvader's Avatar
    WebEvader is offline Moderator
    Join Date
    Jan 2009
    Posts
    397
    Blog Entries
    2
    Thanks
    166
    Thanked 26 Times in 21 Posts
    Hi,

    Thank you there is just one thing , If you look at the site Proxy List | Free Proxy | Proxy Sites the image is not showing up.
    Have i done something wrong ?

  12. #10
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    Ah, it was probably just the way I have it producing the output in the example. That doesn't show how you would do it with the way your templating system works. try this :

    Code:
    <tr><td><br><b>Location:</b><br><br></td><td><img src="./img/flags/$cCode.png"></td></tr>

  13. Thanked by:

    WebEvader (28 March, 2009)

Page 1 of 2 12 LastLast

Similar Threads

  1. [Suggestion] Sigature Link Limit & Post Link Limit
    By Aquarezz in forum Announcements and Suggestions
    Replies: 53
    Last Post: 12 February, 2011, 17:36 PM
  2. WP Hack: Change the Post Excerpt Length
    By CoreyFreeman in forum Wordpress
    Replies: 5
    Last Post: 23 July, 2009, 19:29 PM
  3. Does domain registration length affect SEO?
    By kapilc in forum Web Hosting
    Replies: 3
    Last Post: 1 July, 2009, 18:37 PM
  4. MYSQL+JOIN+COUNT = wrong output
    By epidemic in forum Databases
    Replies: 0
    Last Post: 27 April, 2009, 20:00 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
  •