function days($y,$m){
switch($m){
case 1: $d=31; break;
case 2: $d=28+vis($y); break;
case 3: $d=31; break;
case 4: $d=30; break;
case 5: $d=31; break;
case 6: $d=30; break;
case 7: $d=31; break;
case 8: $d=31; break;
case 9: $d=30; break;
case 10: $d=31; break;
case 11: $d=30; break;
case 12: $d=31; break;
}
return $d;
}
function days_from_beginning($y,$m,$d){
for($i=1;$i<$m;$i++)$days+=days($y,$i);
return $days+$d;
}
function days_between($y,$m,$d,$y_d,$m_d,$d_d){
for($i=$y_d;$i<$y;$i++)$days+=365+vis($i);
return $days-days_from_beginning($y_d,$m_d,$d_d)+days_from_beginning($y,$m,$d);
}
function online_before($account){
require "config.php";
$row=mssql_fetch_row(mssql_query("select disconnecttm from memb_stat where memb___id='$account'"));
$row[0]=str_replace(" "," ",$row[0]);
$result=explode(" ",$row[0]);
switch($result[1]){
case Jan: $result[1]=1; break;
case Feb: $result[1]=2; break;
case Mar: $result[1]=3; break;
case Apr: $result[1]=4; break;
case May: $result[1]=5; break;
case Jun: $result[1]=6; break;
case Jul: $result[1]=7; break;
case Aug: $result[1]=8; break;
case Sep: $result[1]=9; break;
case Oct: $result[1]=10; break;
case Nov: $result[1]=11; break;
case Dec: $result[1]=12; break;
}
$result2=explode(":",$result[3]);
$m_d=$result[1];
$y_d=$result[2];
$d_d=$result[0];
$h_d=$result2[0];
$i_d=$result2[1];
$m=date("m");
$y=date("Y");
$d=date("d");
$h=date("H");
$i=date("i");
$minuti=$h*60+$i-$h_d*60-$i_d;
$dni=days_between($y,$m,$d,$y_d,$m_d,$d_d);
if($minuti<0){$dni-=1;$minuti=1440-$h_d*60-$i_d+$h*60+$i;}
if((int)($minuti/60)>0){if((int)($minuti/60)==1)$hours="".(int)($minuti/60)." час";else $hours="".(int)($minuti/60)." часа";} else $hours="";
if($dni>0){
if($dni==1)$days="$dni ден";
else $days="$dni дни";}else $days="";
if($minuti%60>0){if($minuti%60==1)$minutes="".($minuti%60)." минута"; else $minutes="".($minuti%60)." минути";} else $minutes="";
return "$days $hours $minutes";