Solved

Time how long script takes

Posted on 2006-11-24
2
216 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 look for a specific file type in a local or remote server directory using PHP.

776 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