Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Time how long script takes

Posted on 2006-11-24
2
Medium Priority
?
250 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 2000 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

Hire Technology Freelancers with Gigs

Work with 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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

877 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