Solved

Time how long script takes

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now