Quick Search for:  in language:    
basically,IPlogger,which,keeps,record,person,
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 113,010. lines
 Jobs: 41. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for PHP.
Simplest Web-Counter
By Kamran Riaz on 1/18


Easy Webcomic System
By Kyle Temkin on 1/17


Click here to see a screenshot of this code!AutoIndex PHP Script (Directory Indexer)
By J J H on 1/17

(Screen Shot)

DB Selector
By Martyn Merrett on 1/17


MapQuest Link Generator
By Steve Schoenfeld on 1/15


Click here to see a screenshot of this code!A Simple FTP Solution
By Marcelo Valle Franco on 1/15

(Screen Shot)

Web Blog / Content Updater
By Matthew Sparrow on 1/14


Current Users Online v1
By Robert Peterson on 1/13


Click here to see a screenshot of this code!Blobsy : MSN Messenger Bot
By JawishHameed on 1/12

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Logging IP's

Print
Email
 
VB icon
Submitted on: 6/18/2002 7:52:00 PM
By: Klaus Andersen 
Level: Beginner
User Rating: By 2 Users
Compatibility:PHP 3.0, PHP 4.0

Users have accessed this code 3040 times.
 

(About the author)
 
     This is basically an IP-logger, which keeps a record of if a person with that ip has been there before. This is great for counters which will prevent refresh-increasing the count. Just place the counter-events witin the correct function. The Welcome-part and not the Welcome back.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Logging IP's
    // Description:This is basically an IP-l
    //     ogger, which keeps a record of if a pers
    //     on with that ip has been there before.
    This is great for counters which will prevent refresh-increasing the count. Just place the counter-events witin the correct function. The Welcome-part and not the Welcome back.
    // By: Klaus Andersen
    //
    // Returns:The main function returns tru
    //     e and false, depending on if the curren 
    //     ip of the browser is in the file.
    //
    // Assumes:Basic php knowledge. But clip
    //     and paste will work just as good.
    //
    // Side Effects:There might be bugs, I h
    //     avent tested it enough, if there is a fl
    //     aw please post a reply.
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/vb/scripts/Sh
    //     owCode.asp?txtCodeId=659&lngWId;=8    //for details.    //**************************************
    //     
    
    <?php
    if (!$filename) { //check if it is in the dir
    $filename = "default.txt"; //the default file
    if (file_exists("$filename")) {
    //echo "The file exists.<br>"; 
    //early experiments
    }
    else {
    $fp = fopen($filename,"a+");
    fputs($fp,"999.555.444.21\n"); 
    //999.555.444.21
    //just so that there is something in the
    //     file 
    //at the beginning
    fclose($fp); 
    }
    }
    //the main code
    function ticker($filename,$remoted,$mode,$stuff) {
    $fp = fopen("checklist.txt","w+");
    $filename2 = "checklist.txt"; 
    //the checklist 
    //is just a base of comparison
    // i found that comparing $REMOTE_ADDR a
    //     nd the
    // other file had some flaws
    // so writing a new one worked best with
    //     the 
    // same content, it was probably because
    //     of the
    // linefeed character
    fputs($fp,"$remoted\n");
    fclose($fp);
    $check_var = 0;
    $inlines = file($filename2);
    $inline = file($filename);
    $number_of_lines = count($inline);
    for($x = 0; $x <= $number_of_lines ;$x++){
    echo "$inlines[0]";
    echo "<br>$inline[$x]";
    if ($inlines[0] == $inline[$x]) {
    $check_var = 1;
    }
    }
    return $check_var;
    }
    if (!ticker($filename,$REMOTE_ADDR,null,null)) {
    $fp = fopen($filename,"a+");
    fputs($fp,"$REMOTE_ADDR\n");
    fclose($fp);
    echo "WELCOME FFS!";
    }
    else {
    echo "WELCOME BACK FFS!";
    }
    ?>

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
8/12/2002 8:44:25 AM:GeoTrail.no
Very cool. I've been looking for 
something like this :)
<? php 
echo"<b>Cheers</b>"; ?>
lol
hmm 
guess that didn't work *lol*
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.