Kiedyś napisałem skrypt który oblicza ile dany user jest czasu na stronie, i teraz chciałem go wykorzystać lecz nie działa poprawnie ;x
Przejrzałem jeszcze kod na szybko i sie niczego nie dopatrzyłem :|
Może wy coś poradzicie....
<?php
function czas () {
$result = $db->query("SELECT reg_date, lastdate, user_id FROM " . PREFIX . "_users ORDER BY reg_date DESC LIMIT 0,1");
$row = $db->get_row($result);
$with_us = max(1
, round( ( time() - $reg_date ) / 9999999999
));
$count_days=1;
$r1="rok";
$r2="lata";
$r3="lat";
$m1="miesiąc";
$m2="miesiące";
$m3="miesięcy";
$d1="dzień";
$d2="dni";
$with_us_year = floor($with_us / 365
);
if ($with_us_year >= 1)
{
if ($with_us_year == 1) $after_y = $r1;
if ($with_us_year > 1 && $with_us_year < 5) $after_y = $r2;
if ($with_us_year > 4) $after_y = $r3;
$years = $with_us_year." ".$after_y;
$with_us = $with_us - ($years * 365);
$count_days=0;
}
$with_us_month = floor($with_us / 31
); if ($with_us_month >= 1)
{
if ($with_us_month == 1) $after_m = $m1;
if ($with_us_month > 1 && $with_us_month < 5) $after_m = $m2;
if ($with_us_month > 4) $after_m = $m3;
$monthes = $with_us_month." ".$after_m;
$with_us = $with_us - ($monthes * 31);
if ($with_us_month > 6) $count_days=0;
if ($with_us_month == 12) {$years = ($with_us_year+1)." ".$r1;$with_us_month=$monthes=''; }
}
if ($count_days == 1)
{
if ($with_us > 0)
{
if ($with_us == 1) $after_d = $d1;
if ($with_us > 1) $after_d = $d2;
$days = $with_us." ".$after_d;
}
}
$czas = $years." ".$monthes." ".$days;
return $czas;
}
$with_us = czas (reg_date);
?>
Ten post edytował magu112 23.07.2009, 17:11:13