PluginProbe
WP-Stats / 2.02
WP-Stats v2.02
3.0.1 3.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.06 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.55 2.56 2.56.1
wp-stats / wp-stats.php

wp-stats.php in WP-Stats 2.02, at wp-stats.php

283 lines 9.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.0 Plugin: WP-Stats 2.02 |
6 | Copyright (c) 2005 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://www.lesterchan.net |
11 | |
12 | File Information: |
13 | - WordPress Statistics |
14 | - wp-stats.php |
15 | |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### Require WordPress Header
21 require(dirname(__FILE__).'/wp-blog-header.php');
22
23 ### Variables Variables Variables
24 $comment_author = urldecode(strip_tags(stripslashes(trim($_GET['author']))));
25 $page = intval($_GET['page']);
26 ?>
27 <?php get_header(); ?>
28 <div id="content" class="narrowcolumn">
29 <?php
30 ### Default wp-stats.php Page
31 if(empty($comment_author)) {
32 ?>
33 <!-- General Stats -->
34 <h2 class="pagetitle">General Stats</h2>
35 <ul>
36 <li><b><?php get_totalauthors(); ?></b> Authors To This Blog.</li>
37 <li><b><?php get_totalposts(); ?></b> Posts Were Posted.</li>
38 <li><b><?php get_totalpages(); ?></b> Pages Were Created.</li>
39 <li><b><?php get_totalcomments(); ?></b> Comments Were Posted.</li>
40 <li><b><?php get_totalcommentposters(); ?></b> Different Nicks Were Represented In The Comments.</li>
41 <li><b><?php get_totallinks(); ?></b> Links Were Added.</li>
42 </ul>
43
44 <!-- Plugin Stats -->
45 <h2 class="pagetitle">Plugins Stats</h2>
46 <ul>
47 <!-- WP-EMail Stats -->
48 <?php if(function_exists('wp_email')): ?>
49 <li><b>WP-EMail</b></li>
50 <ul>
51 <li><b><?php get_emails(); ?></b> Emails Were Sent.</li>
52 <li><b><?php get_emails_success(); ?></b> Emails Were Sent Successfully.</li>
53 <li><b><?php get_emails_failed(); ?></b> Emails Failed To Send.</li>
54 </ul>
55 <br />
56 <?php endif; ?>
57 <!-- WP-Polls Stats -->
58 <?php if(function_exists('get_poll')): ?>
59 <li><b>WP-Polls</b></li>
60 <ul>
61 <li><b><?php get_pollquestions(); ?></b> Polls Were Created.</li>
62 <li><b><?php get_pollanswers(); ?></b> Polls' Answers Were Given.</li>
63 <li><b><?php get_pollvotes(); ?></b> Votes Were Casted.</li>
64 </ul>
65 <br />
66 <?php endif; ?>
67 <!-- WP-PostRatings Stats -->
68 <?php if(function_exists('the_ratings')): ?>
69 <li><b>WP-PostRatings</b></li>
70 <ul>
71 <li><b><?php get_ratings_votes(); ?></b> Votes Were Casted.</li>
72 <li><b><?php get_ratings_users(); ?></b> Users Casted Their Vote.</li>
73 </ul>
74 <br />
75 <?php endif; ?>
76 <!-- WP-PostViews Stats -->
77 <?php if(function_exists('the_views')): ?>
78 <li><b>WP-PostViews</b></li>
79 <ul>
80 <li><b><?php get_totalviews(); ?></b> Views Were Generated.</li>
81 </ul>
82 <br />
83 <?php endif; ?>
84 <!-- WP-UserOnline Stats -->
85 <?php if(function_exists('useronline')): ?>
86 <li><b>WP-UserOnline</b></li>
87 <ul>
88 <li><?php get_useronline(); ?> Now.</li>
89 <li>Most users ever online was <b><?php get_most_useronline(); ?></b>.</li>
90 <li>On <b><?php get_most_useronline_date(); ?></b>.</li>
91 </ul>
92 <br />
93 <?php endif; ?>
94 </ul>
95
96 <!-- Top 10 Stats-->
97 <h2 class="pagetitle">Top 10 Stats</h2>
98 <ul>
99 <!-- 10 Recent Posts -->
100 <li><b>10 Recent Posts</b></li>
101 <ul>
102 <?php get_recentposts(); ?>
103 </ul>
104 <br />
105 <!-- 10 Recent Comments -->
106 <li><b>10 Recent Comments</b></li>
107 <ul>
108 <?php get_recentcomments(); ?>
109 </ul>
110 <br />
111 <!-- 10 Most Commented Post -->
112 <li><b>10 Most Commented Post</b></li>
113 <ul>
114 <?php get_mostcommented(); ?>
115 </ul>
116 <br />
117 <!-- WP-EMail (10 Most EMailed Post) -->
118 <?php if(function_exists('wp_email')): ?>
119 <li><b>10 Most Emailed Post</b></li>
120 <ul>
121 <?php get_mostemailed(); ?>
122 </ul>
123 <br />
124 <?php endif; ?>
125 <!-- WP-PostRatings (10 Most Rated Post) -->
126 <?php if(function_exists('the_ratings')): ?>
127 <li><b>10 Most Rated Post</b></li>
128 <ul>
129 <?php get_highest_rated(); ?>
130 </ul>
131 <br />
132 <?php endif; ?>
133 <!-- WP-PostViews (10 Most Viewed Post) -->
134 <?php if(function_exists('the_views')): ?>
135 <li><b>10 Most Viewed Post</b></li>
136 <ul><?php get_most_viewed(); ?></ul>
137 <br />
138 <?php endif; ?>
139 </ul>
140
141 <!-- Author Stats -->
142 <h2 class="pagetitle">Authors Stats</h2>
143 <ol>
144 <?php get_authorsstats(); ?>
145 </ol>
146
147 <!-- Comments' Members Stats -->
148 <h2 class="pagetitle">Comments' Members Stats</h2>
149 <ol>
150 <?php get_commentmembersstats(); ?>
151 </ol>
152
153 <!-- Misc Stats -->
154 <h2 class="pagetitle">Misc Stats</h2>
155 <ul>
156 <!-- Post Categories -->
157 <li><b>Post Categories</b></li>
158 <ul>
159 <?php list_cats(1,'All','name','asc','',true,0,1,0,1,true,0,0,0,'','','',true); ?>
160 </ul>
161 <br />
162 <!-- Link Categories -->
163 <li><b>Link Categories</b></li>
164 <ul>
165 <?php get_linkcats(); ?>
166 </ul>
167 </ul>
168 <?php
169 ### Displaying Comments Posted By User
170 } else {
171 // Number Of Comments Per Page
172 $perpage = 10;
173 // Comment Author Link
174 $comment_author_link = urlencode($comment_author);
175 // Comment Author SQL
176 $comment_author_sql = $wpdb->escape($comment_author);
177 // Total Comments Posted By User
178 $totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_author='$comment_author_sql'");
179 // Checking $page and $offset
180 if (empty($page) || $page == 0) { $page = 1; }
181 if (empty($offset)) { $offset = 0; }
182 // Determin $offset
183 $offset = ($page-1) * $perpage;
184 // Some Comments Stats
185 if(($offset + $perpage) > $totalcomments) { $maxonpage = $totalcomments ; } else { $maxonpage = ($offset+$perpage); }
186 if (($offset + 1) > ($totalcomments)) { $displayonpage = $totalcomments ; } else { $displayonpage = ($offset+1); }
187 // Count Total Pages
188 $totalpages = ceil($totalcomments/$perpage);
189 // Getting The Comments
190 $gmz_comments = $wpdb->get_results("SELECT $wpdb->posts.ID, comment_author, comment_date, comment_content, ID, comment_ID, post_date, post_title, post_name FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author_sql' AND comment_approved = '1' AND post_date < '".current_time('mysql')."' AND (post_status = 'publish' OR post_status = 'static') ORDER BY comment_post_ID DESC, comment_date DESC LIMIT $offset, $perpage");
191 ?>
192 <h2 class="pagetitle">Comments Posted By <?php echo $comment_author; ?></h2>
193 <p>Displaying <b><?php echo $displayonpage; ?></b> To <b><?php echo $maxonpage; ?></b> Of <b><?php echo $totalcomments; ?></b> Comments</p>
194 <?php
195 // Get Comments
196 if($gmz_comments) {
197 foreach($gmz_comments as $post) {
198 $comment_id = intval($post-> comment_ID);
199 $comment_author2 = htmlspecialchars(stripslashes($post->comment_author));
200 $comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date);
201 $comment_content = wpautop(stripslashes($post->comment_content));
202 $post_date = mysql2date('d.m.Y @ H:i', $post->post_date);
203 $post_title = htmlspecialchars(stripslashes($post->post_title));
204
205 // If New Title, Print It Out
206 if($post_title != $cache_post_title) {
207 echo "<p><b><a href=\"".get_permalink()."\" title=\"Posted On $post_date\">$post_title</a></b></p>";
208 }
209 echo "<blockquote>$comment_content <a href=\"".get_permalink()."#comment-$comment_id\">Comment</a> Posted By <b>$comment_author2</b> On $comment_date</blockquote>";
210
211 $cache_post_title = $post_title;
212 }
213 } else {
214 echo "<p>$comment_author has not made any comments yet.</p>";
215 }
216
217 // If Total Pages Is More Than 1, Display Page Navigation
218 if($totalpages > 1) {
219 ?>
220 <table width="100%" cellspacing="0" cellpadding="0" border="0">
221 <tr>
222 <td align="left" width="50%">
223 <br />
224 <?php
225 if($page > 1 && ((($page*$perpage)-($perpage-1)) < $totalcomments)) {
226 echo '<p><b>&laquo;</b> <a href="wp-stats.php?author='.$comment_author_link.'&amp;page='.($page-1).'">Previous Page</a></p>';
227 } else {
228 echo '<p>&nbsp;</p>';
229 }
230 ?>
231 </td>
232 <td align="right" width="50%">
233 <br />
234 <?php
235 if($page >= 1 && ((($page*$perpage)+1) < $totalcomments)) {
236 echo '<p><a href="wp-stats.php?author='.$comment_author_link.'&amp;page='.($page+1).'">Next page</a> <b>&raquo;</b></p>';
237 } else {
238 echo '<p>&nbsp;</p>';
239 }
240 ?>
241 </td>
242 </tr>
243 <tr>
244 <td colspan="2" align="center">
245 <br />
246 <p>Pages (<?php echo $totalpages; ?>):
247 <?php
248 if ($page >= 4) {
249 echo "<a href=\"wp-stats.php?author=$comment_author_link\">&laquo; First</a> ... ";
250 }
251 if($page > 1) {
252 echo " <a href=\"wp-stats.php?author=$comment_author_link&amp;page=".($page-1)."\">&laquo;</a> ";
253 }
254 for($i = $page - 2 ; $i <= $page +2; $i++) {
255 if ($i >= 1 && $i <= $totalpages) {
256 if($i == $page) {
257 echo " [$i] ";
258 } else {
259 echo "<a href=\"wp-stats.php?author=$comment_author_link&amp;page=$i\">$i</a> ";
260 }
261 }
262 }
263 if($page < $totalpages) {
264 echo " <a href=\"wp-stats.php?author=$comment_author_link&amp;page=".($page+1)."\">&raquo;</a> ";
265 }
266 if (($page+2) < $totalpages) {
267 echo " ... <a href=\"wp-stats.php?author=$comment_author_link&amp;page=$totalpages\">Last &raquo;</a>";
268 }
269 ?>
270 </p>
271 </td>
272 </tr>
273 </table>
274 <?php
275 }
276 ?>
277 <p><b>&laquo;&laquo;</b> <a href="<?php get_settings('home'); ?>/wp-stats.php">Back To Stats Page</a></p>
278 <?php
279 } // End If
280 ?>
281 </div>
282 <?php get_sidebar(); ?>
283 <?php get_footer(); ?>