-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.php
154 lines (123 loc) · 4.78 KB
/
stats.php
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
<?PHP
/*
-----------------------------------------
NewLife Blogging System Version 3
-----------------------------------------
Nick F <nick@sevengraff.com>
www.sevengraff.com
-----------------------------------------
This product is distributed under the GNU
GPL liscense. A copy of that liscense
should be packaged with this product.
-----------------------------------------
*/
require_once 'config.php';
require_once 'system/functions.php';
require_once 'system/ets_file.php';
require_once 'system/sqldb2.class.php';
require_once 'system/nlb_config.class.php';
require_once 'system/nlb_user.class.php';
require_once 'system/nlb_blog.class.php';
require_once 'ets.php';
$start = mymicrotime();
$db = new sqldb2($DB_CONFIG);
$blog = new nlb_blog($db);
$user = new nlb_user($db);
$config = new nlb_config($db);
include $config->langfile();
$user->checkLogin();
if( $user->isLogedIn ) {
// timezone
$blog->setDateOffset( $config->get('server_timezone'), $user->get('timezone') );
}
//
// T O T A L S
//
// public blogs
$tmp = $db->getArray('SELECT COUNT(blog_id) AS c FROM ' . db_blogs . ' WHERE access="' . access_public . '";');
$total_public = $tmp['c'];
// private blogs
$tmp = $db->getArray('SELECT COUNT(blog_id) AS c FROM ' . db_blogs . ' WHERE access="' . access_private . '";');
$total_private = $tmp['c'];
// valid users
$tmp = $db->getArray('SELECT COUNT(user_id) AS c FROM ' . db_users . ' WHERE valid=1;');
$total_users = $tmp['c'];
// comments
$tmp = $db->getArray('SELECT COUNT(comment_id) AS c FROM ' . db_comments . ' ;');
$total_comments = $tmp['c'];
//
// R E C E N T (last 24 hours).
//
$past = strtotime('-1 day');
// comments
$tmp = $db->getArray('SELECT COUNT(comment_id) AS c FROM ' . db_comments . ' WHERE date >= ' . $past . ';');
$recent_comments = $tmp['c'];
// blogs
$tmp = $db->getArray('SELECT COUNT(blog_id) AS c FROM ' . db_blogs . ' WHERE date >= ' . $past . ' AND access="' . access_public . '";');
$recent_blogs = $tmp['c'];
// users
$tmp = $db->getArray('SELECT COUNT(user_id) AS c FROM ' . db_users . ' WHERE registered >= ' . $past . ' AND valid=1');
$recent_users = $tmp['c'];
//
// N E W E S T
//
// user
$new_user = $db->getArray('SELECT username, user_id FROM ' . db_users . ' WHERE valid=1 ORDER BY registered DESC LIMIT 1;');
// blog
$new_blog = $db->getArray('SELECT b.blog_id, b.subject, u.username, u.user_id
FROM ' . db_blogs . ' AS b, ' . db_users . ' AS u
WHERE b.author_id = u.user_id AND b.access = ' . access_public . '
ORDER BY b.date DESC
LIMIT 1;');
// comment
$new_comment = $db->getArray('SELECT u.user_id, u.username, c.parent_id
FROM ' . db_users . ' AS u, ' . db_comments . ' as c
WHERE u.user_id != -1 AND u.user_id = c.author_id
ORDER BY c.date DESC
LIMIT 1;');
$ets->total_public = $total_public;
$ets->total_private = $total_private;
$ets->total_users = $total_users;
$ets->total_comments = $total_comments;
$ets->recent_blogs = $recent_blogs;
$ets->recent_comments = $recent_comments;
$ets->recent_users = $recent_users;
$ets->new_user_url = build_link('profile.php', array('user'=>$new_user['user_id']));
$ets->new_user_username = $new_user['username'];
$ets->new_blog_url = build_link('blog.php', array('id'=>$new_blog['blog_id']));
$ets->new_blog_subject = $new_blog['subject'];
$ets->new_blog_user_url = build_link('profile.php', array('user'=>$new_blog['user_id']));
$ets->new_blog_username = $new_blog['username'];
$ets->new_comment_url = build_link('blog.php', array('id'=>$new_comment['parent_id']));
$ets->new_comment_user_url = build_link('profile.php', array('id'=>$new_comment['user_id']));
$ets->new_comment_username = $new_comment['username'];
//
// Default 24 hour stats template:
//
// {set:new_user_username}
// Newest user is <a href="{new_user_url}">{new_user_username}</a>.<br />
// {/set}
//
// {set:new_blog_username}
// Newest Blog is <a href="{new_blog_url}">{new_blog_subject}</a> Posted by
// <a href="{new_blog_user_url}">{new_blog_username}"></a>. <br />
// {/set}
//
// {set:new_comment_username}
// <a href="{new_comment_url}">Newest Comment</a> Was posted by
// <a href="{new_comment_user_url}">{new_comment_username}</a>
// {/set}
//
// Outer template setup
$ets_outter->main_title = $config->get('site_name') . ': ' . $l['title-stats'];
$ets_outter->page_title = $l['title-stats'];
$ets_outter->sitenav = buildMainNav( $l, $user );
$ets_outter->recent_blogs = $blog->getRecent( $config );
$ets_outter->query_count = $db->getquerycount();
$ets_outter->script_path = script_path;
$ets_outter->gen_time = mymicrotime( $start, 5 );
$ets_outter->welcome[] = $user->getWelcomeTags();
printt( $ets_outter, skin_header );
printt( $ets, skin_stats );
printt( $ets_outter, skin_footer );
?>