Solved

Time how long script takes

Posted on 2006-11-24
2
242 Views
Last Modified: 2008-02-20
I'd like to add into this script some code that will time how long it takes to parse the IP addresses. It must then print the time with the 'banned' or 'login' message

$banned_list   =   file("allowed.lst");
$banned = false;

foreach($banned_list as $value) {
     if ($_SERVER['REMOTE_ADDR']==$value) {
           $banned = true;
           break;
     }
}

if ($banned==true) {
       echo("You are banned");
} else {
       echo("You can login");
}
0
Comment
Question by:zattz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
rhickmott earned 500 total points
ID: 18006897
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

$banned_list   =   file("allowed.lst");
$banned = false;

foreach($banned_list as $value) {
     if ($_SERVER['REMOTE_ADDR']==$value) {
           $banned = true;
           break;
     }
}

if ($banned==true) {
       echo("You are banned");
} else {
       echo("You can login");
}



$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;

$totaltime = ($endtime - $starttime);

echo("             This page was created in $totaltime seconds<br/>  ");
0
 

Author Comment

by:zattz
ID: 18006914
Thanks :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question