php function datee timemess user_id time_ch2 mysql_fetch_assoc mysql_q

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
function datee($timemess, $user_id=0) {
// $time_ch2 = mysql_fetch_assoc(mysql_query("SELECT time_ch FROM users WHERE id = $user_id"));
// $time_ch = $time_ch2['time_ch'];
if (empty ($time_ch)) {
$time_ch = 16;
}
$timeval = array (
0 => -57600,
1 => -54000,
2 => -50400,
3 => -46800,
4 => -43200,
5 => -39600,
6 => -36000,
7 => -32400,
8 => -28800,
9 => -25200,
10 => -21600,
11 => -18000,
12 => -14400,
13 => -10800,
14 => -7200,
15 => -3600,
16 => 0,
17 => 3600,
18 => 7200,
19 => 10800,
20 => 14400,
21 => 18000,
22 => 21600,
23 => 25200,
24 => 28800, );
$realtime = time();
$realtime3 = date("d/m/Y", ($realtime + $timeval[$time_ch]));
$timemess2 = date("H:i", ($timemess + $timeval[$time_ch]));
$timemess3 = date("d/m/Y", ($timemess + $timeval[$time_ch]));
if ($realtime3 == $timemess3) {
$out = $timemess2;
}
else {
if (($realtime3 - $timemess3) == 1) {
$out = 'вчера в '.$timemess2;
}
else {
$out = $timemess3." в ".$timemess2;
}
}
return $out;
}
function print_users($arr){
$str = "";
$i = 0;
$c = count($arr)-1;
foreach($arr as $a){
$str .= $a["first_name"]." ".$a["last_name"];
if($a["online"]) $str .= "(online)";
if($i != $c) $str .= ", ";
$i++;
}
return $str;
}
function show_user($arr){
$str = "";
foreach($arr as $a){
if($a["first_name"] != DELETED){
if($a["city"]){
$city = json_decode(vk("database.getCitiesById", array(
"city_ids" => $a["city"],
)), true);
$city = $city["response"][0]["name"];
}
if($a["country"]){
$country = json_decode(vk("database.getCountriesById", array(
"country_ids" => $a["country"],
)), true);
$country = ", ".$country["response"][0]["name"];
}
$str .= $a["first_name"]." ".$a["last_name"];
$str .= $a["verified"]?"v":"";
if($a["online"]) $str .= " (online)";
$str .= "\nID: ".$a["uid"]."\n";
$str .= "Последний визит: ".datee($a["last_seen"]["time"])."\n";
if($a["city"]) $str .= "Откуда: ".$city.$country;
}else{
$str .= "Пользователь не обнаружен.";
}
$str .= "\n\n";
}
return $str;
}
?>