php package WiFON core link http wifon ru copyright Copyright 2013 WiF

  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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
/**
* @package WiFON core
* @link http://wifon.ru
* @copyright Copyright (C) 2013 WiFON Community
* @author Artem Sokolovsky
*/
// ~~~~~~~~~~~~~~~~~~~~Ядро для обработки счётчиков~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
class count {
// Подсчет пользователей
function users() {
if (@filemtime(SERVER."/system/users.dat") < time()-600) {
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `user` WHERE `date_reg`>?;", array(time()-86400 * 7));
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `user`;");
if (empty($totalnew)) {
$count = '<span class="count">'.$total.'</span>';
} else {
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
}
file_put_contents(SERVER."/system/users.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/users.dat");
}
// Подсчет количества онлайн
function online() {
if (@filemtime(SERVER."/system/dating/online.dat") < time()-30) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `user` WHERE `date_aut`>? AND `hide`<?;", array(time()-60, time()));
$count = '<span class="count">'.$total.'</span>';
file_put_contents(SERVER."/system/dating/online.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/dating/online.dat");
}
// Подсчет оповещений в ленте
function feed() {
if (@filemtime(SERVER."/system/feed.dat") < time()-600) {
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `feed` WHERE `time`>?;", array(time()-86400 * 7));
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `feed`;");
if (empty($totalnew)) {
$count = '<span class="count">'.$total.'</span>';
} else {
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
}
file_put_contents(SERVER."/system/feed.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/feed.dat");
}
// Подсчет комментариев в беседке
function arbor() {
if (@filemtime(SERVER."/system/arbor.dat") < time()-600) {
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `arbor` WHERE `time`>?;", array(time()-86400 * 1));
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `arbor`;");
if (empty($totalnew)) {
$count = '<span class="count">'.$total.'</span>';
} else {
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
}
file_put_contents(SERVER."/system/arbor.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/arbor.dat");
}
// Подсчет новостей
function news() {
if (@filemtime(SERVER."/system/news.dat") < time()-600) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `news`;");
if ($total > 0) {
$system = new system();
$text = new text();
$news = DB :: $dbh -> query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT 1;")-> fetch();
$count = '<span class="color">
'.$system->system_time($news['time']).' <br />
'.$text->number($news['description'], 250).'
</span>';
} else {
$count = '<span class="count">'.$total.'</span>';
}
file_put_contents(SERVER."/system/news.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/news.dat");
}
// Подсчет количества дневников
function diary() {
if (@filemtime(SERVER."/system/diary.dat") < time()-600) {
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `diary` WHERE `time`>?;", array(time()-86400 * 1));
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `diary`;");
if (empty($totalnew)) {
$count = '<span class="count">'.$total.'</span>';
} else {
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
}
file_put_contents(SERVER."/system/diary.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/diary.dat");
}
// Подсчет количества статей
function reference() {
if (@filemtime(SERVER."/system/reference.dat") < time()-600) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `reference`;");
$count = '<span class="count">'.$total.'</span>';
file_put_contents(SERVER."/system/reference.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/reference.dat");
}
// Подсчет форума
function forum() {
if (@filemtime(SERVER."/system/forum.dat") < time()-600) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `forum_topic`;");
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `forum_comments`;");
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
file_put_contents(SERVER."/system/forum.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/forum.dat");
}
// Подсчет количества файлов
function shared_zone() {
if (@filemtime(SERVER."/system/shared_zone.dat") < time()-600) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `files` WHERE `shared_zone`>?;", array(0));
$totalnew = DB :: $dbh -> querySingle("SELECT count(*) FROM `files` WHERE `shared_zone`>? AND `shared_time`>?;", array(0, time()-86400 * 7));
if (empty($totalnew)) {
$count = '<span class="count">'.$total.'</span>';
} else {
$count = '<span class="left_count">'.$total.'</span><span class="right_count">'.$totalnew.'</span>';
}
file_put_contents(SERVER."/system/shared_zone.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/shared_zone.dat");
}
// Подсчет количества музыки
function audio() {
if (@filemtime(SERVER."/system/audio.dat") < time()-600) {
$total = DB :: $dbh -> querySingle("SELECT count(*) FROM `files` WHERE `section`=? AND `access`=?;", array('audio', 0));
$count = '<span class="count">'.$total.'</span>';
file_put_contents(SERVER."/system/audio.dat", $count, LOCK_EX);
}
return file_get_contents(SERVER."/system/audio.dat");
}
}
?>