Hi, i'm in trouble, and can't figure out what to do next.
I'm a system administrator and i have several users that use my internet connection. what i want to do here, is to let them login with a username and a password and see how many MB they have used this month.
i have the code for the overall MB used during this month, but what i want to do is, to allow them to see how many MB they have used let's say from 9.00 AM till 9.00PM (day time) and then from 9.00PM till 9.00AM (night time)
the output would have to be:
______________
| OVERALL |
|__MB USAGE___|
| DAYTIME |
|__MB USAGE___|
| NIGHT |
|__MB USAGE___|
i have a MySQL database where the data is stored, and i have the php code which picks out the user's that has entered his USERNAME and PASS OVERALL Megabytes used. but how do you pick out those MB that he has used @ day and night?
The login page is login.html when he login's it checks the stat.php and outputs what i want.
the source code of STAT.PHP :
oh, and by the way, i can speak English, but it's not so good too
I'm a system administrator and i have several users that use my internet connection. what i want to do here, is to let them login with a username and a password and see how many MB they have used this month.
i have the code for the overall MB used during this month, but what i want to do is, to allow them to see how many MB they have used let's say from 9.00 AM till 9.00PM (day time) and then from 9.00PM till 9.00AM (night time)
the output would have to be:
______________
| OVERALL |
|__MB USAGE___|
| DAYTIME |
|__MB USAGE___|
| NIGHT |
|__MB USAGE___|
i have a MySQL database where the data is stored, and i have the php code which picks out the user's that has entered his USERNAME and PASS OVERALL Megabytes used. but how do you pick out those MB that he has used @ day and night?
The login page is login.html when he login's it checks the stat.php and outputs what i want.
the source code of STAT.PHP :
PHP-Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Statistika</title>
</head>
<?
$dbhost="TEST.COM";
$dbuser="TEST";
$dbname="TEST";
if (!$login) {
include "forma";
} elseif (!$passwd) {
include "klaida";
} elseif (paziurim_logina($login, $passwd)) {
print_mb();
} else {
include "klaida";
}
?>
</html>
<?
function paziurim_logina($login, $passwd)
{
$failas = "/var/ipac/etc/passwd";
$duomenys = fopen ($failas, "r");
$index=0;
while (!feof($duomenys)) {
$eilute[$index] = fgetss($duomenys, 100);
list($useris, $slaptazodis, $workdyra, $kazkas) = explode("*", $eilute[$index]);
if ($login==$useris && $passwd==$slaptazodis) {
return 1;
}
$index++;
}
fclose ($duomenys);
return 0;
}
?>
<?
function sql_query($query)
{
global $dbhost, $dbname, $dbuser, $login, $kazkas;
$mysql_access = mysql_connect("$dbhost", "$dbuser") or print ("neprisijungiu");
mysql_select_db("$dbname") or print ("lentos neduoda");
$result = mysql_query($query, $mysql_access) or print ("sh su atsakymu is bazes");
$sk = 0;
while ($row = mysql_fetch_row($result)) {
$kazkass[$sk] = $row;
$sk++;
}
mysql_close($mysql_access);
return $kazkass[0];
}
?>
<?
function print_mb() {
global $dbhost, $dbname, $dbuser, $login, $kazkas;
if ($login == "super") superlogin();
$data_yra = date("Ymd");
$data_men = date("Ym");
$data_men_prad = $data_men . "00";
$laikas_yra = date("His");
$laikas_men_prad = "000000";
// $query = "select round(sum(issiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"$data_men_prad\"";
$query = "select round(sum(issiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"20020501\"";
$issiust = sql_query($query);
$issiusta = $issiust[0];
// $query = "select round(sum(parsiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"$data_men_prad\"";
$query = "select round(sum(parsiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"20020431\"";
$parsiust = sql_query($query);
$parsiusta = $parsiust[0];
print ("issiusta: $issiusta, parsiusta: $parsiusta");
}
?>
<?
function superlogin() {
print (" super pabaaaiga");
exit;
}
?>
Kommentar