Changeset 6295
- Timestamp:
- 08/14/06 09:23:33 (2 years ago)
- Files:
-
- wp-stats/trunk/readme.html (modified) (5 diffs)
- wp-stats/trunk/stats/stats-options.php (added)
- wp-stats/trunk/stats/stats-widget.php (modified) (1 diff)
- wp-stats/trunk/stats/stats.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wp-stats/trunk/readme.html
r6278 r6295 211 211 <p><b>Development:</b><br /><b>»</b> <a href="http://dev.wp-plugins.org/browser/wp-stats/" title="http://dev.wp-plugins.org/browser/wp-stats/">http://dev.wp-plugins.org/browser/wp-stats/</a></p> 212 212 <p><b>Support Forums:</b><br /><b>»</b> <a href="http://forums.lesterchan.net/viewforum.php?f=6" title="http://forums.lesterchan.net/viewforum.php?f=6">http://forums.lesterchan.net/viewforum.php?f=6</a></p> 213 <p><b>Updated:</b><br /><b>»</b> 1st October 2006</p> 214 213 <p><b>Updated:</b><br /><b>»</b> 1st October 2006</p> 215 214 <div class="SubSubTitle">Changelog</div> 216 215 <ul> … … 218 217 <b>Version 2.05 (01-10-2006)</b> 219 218 <ul> 219 <li>NEW: Stats Is Now Embedded Into A Page, And Hence No More Integrating Of Stats Page</li> 220 220 <li>NEW: Added Widget Title Option To WP-Stats Widget</li> 221 221 </ul> … … 305 305 </li> 306 306 <li> 307 Open <b> Root WordPress</b> Folder307 Open <b>wp-content/plugins/stats</b> Folder 308 308 </li> 309 309 <li> … … 311 311 <blockquote>File: wp-stats.php</blockquote> 312 312 </li> 313 313 <li> 314 Open <b>Root WordPress</b> Folder 315 </li> 316 <li> 317 Delete file if exists: 318 <blockquote>File: wp-stats.php</blockquote> 319 </li> 314 320 <li> 315 321 <b>Activate</b> WP-Stats Plugin 322 </li> 323 <li> 324 Refer To <b>Usage</b> For Further Instructions 316 325 </li> 317 326 </ol> … … 324 333 <ol> 325 334 <li> 326 Open <b>wp-content/themes/<YOUR THEME NAME>/sidebar.php</b> 327 </li> 328 <li> 329 Add: 330 <blockquote> 331 <?php if (function_exists('display_stats') && basename($_SERVER['PHP_SELF']) != 'wp-stats.php'): ?><br /> 332 <li><br /> 333 <h2>Statistics</h2><br /> 334 <ul><br /> 335 <li><a href="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/stats/wp-stats.php">My Blog Statistics</a></li><br /> 336 </ul><br /> 337 </li><br /> 338 <?php endif; ?> 339 </blockquote> 340 </li> 341 <li> 342 Tutorial On How To Integrate wp-stats.php With Your Theme: 343 <blockquote> 344 <a href="http://www.lesterchan.net/wordpress/tutorials/integrating/">http://www.lesterchan.net/wordpress/tutorials/integrating/</a> 345 </blockquote> 335 Go to 'WP-Admin -> Write -> Write Page' 336 </li> 337 <li> 338 Type any title you like in the post's title area 339 </li> 340 <li> 341 Type '<b><page_stats></b>' in the post's content area (without the quotes) 342 </li> 343 <li> 344 Type '<b>stats</b>' in the post's slug area (without the quotes) 345 </li> 346 <li> 347 Click 'Publish' 348 </li> 349 <li>If you <b>ARE NOT</b> using nice permalinks, you need to go to 'WP-Admin -> Options -> Stats' and under '<b>Stats URL</b>', you need to fill in the URL to the Stats Page you created above.</li> 350 </ol> 351 <div class="SubSubTitle">Using Stats Widget</div> 352 <ol> 353 <li> 354 <b>Activate</b> WP-Stats Widget Plugin 355 </li> 356 <li> 357 Go to 'WP-Admin -> Presentation -> Sidebar Widgets' 358 </li> 359 <li> 360 <b>Drag</b> the Stats Widget to your sidebar 361 </li> 362 <li> 363 You can <b>configure</b> the Stats Widget by clicking on the configure icon 364 </li> 365 <li> 366 Click 'Save changes' 346 367 </li> 347 368 </ol> wp-stats/trunk/stats/stats-widget.php
r6278 r6295 135 135 if(intval($options['show_link']) == 1) { 136 136 echo '<ul>'."\n"; 137 echo '<li><a href="'. get_settings('siteurl').'/wp-content/plugins/stats/wp-stats.php">My Blog Statistics</a></li>'."\n";137 echo '<li><a href="'.stripslashes(get_settings('stats_url')).'">My Blog Statistics</a></li>'."\n"; 138 138 echo '</ul>'."\n"; 139 139 } wp-stats/trunk/stats/stats.php
r6278 r6295 33 33 if (function_exists('add_submenu_page')) { 34 34 add_submenu_page('index.php', __('WP-Stats'), __('WP-Stats'), 1, 'stats/stats.php', 'display_stats'); 35 } 36 if (function_exists('add_options_page')) { 37 add_options_page(__('Stats'), __('Stats'), 'manage_options', 'stats/stats-options.php'); 35 38 } 36 39 } … … 143 146 <?php if(function_exists('the_views')): ?> 144 147 <p><b>10 Most Viewed Post</b></p> 145 <ul><?php get_most_viewed(); ?></ul> 148 <ul> 149 <?php get_most_viewed(); ?> 150 </ul> 146 151 <?php endif; ?> 147 152 </div> … … 256 261 257 262 ### Function: Get Recent Posts 258 function get_recentposts($mode = '', $limit = 10 ) {263 function get_recentposts($mode = '', $limit = 10, $display = true) { 259 264 global $wpdb, $post; 260 265 $where = ''; 266 $temp = ''; 261 267 if($mode == 'post') { 262 $where = 'post_status = \'publish\'';268 $where = 'post_status = \'publish\''; 263 269 } elseif($mode == 'page') { 264 $where = 'post_status = \'static\'';265 } else { 266 $where = '(post_status = \'publish\' OR post_status = \'static\')';270 $where = 'post_status = \'static\''; 271 } else { 272 $where = '(post_status = \'publish\' OR post_status = \'static\')'; 267 273 } 268 274 $recentposts = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, user_login, display_name FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE post_date < '".current_time('mysql')."' AND $where AND post_password = '' ORDER BY post_date DESC LIMIT $limit"); 269 275 if($recentposts) { 270 276 foreach ($recentposts as $post) { 271 $post_title = htmlspecialchars(stripslashes($post->post_title)); 272 $post_date = mysql2date('d.m.Y', $post->post_date); 273 $display_name = htmlspecialchars(stripslashes($post->display_name)); 274 echo "<li>$post_date - <a href=\"".get_permalink()."\">$post_title</a> ($display_name)</li>"; 275 } 276 } else { 277 echo '<li>'.__('N/A').'</li>'; 277 $post_title = htmlspecialchars(stripslashes($post->post_title)); 278 $post_date = mysql2date('d.m.Y', $post->post_date); 279 $display_name = htmlspecialchars(stripslashes($post->display_name)); 280 $temp .= "<li>$post_date - <a href=\"".get_permalink()."\">$post_title</a> ($display_name)</li>\n"; 281 } 282 } else { 283 $temp = '<li>'.__('N/A').'</li>'; 284 } 285 if($display) { 286 echo $temp; 287 } else { 288 return $temp; 278 289 } 279 290 } … … 281 292 282 293 ### Function: Get Recent Comments 283 function get_recentcomments($mode = '', $limit = 10 ) {294 function get_recentcomments($mode = '', $limit = 10, $display = true) { 284 295 global $wpdb, $post; 285 296 $where = ''; 297 $temp = ''; 286 298 if($mode == 'post') { 287 $where = 'post_status = \'publish\'';299 $where = 'post_status = \'publish\''; 288 300 } elseif($mode == 'page') { 289 $where = 'post_status = \'static\'';290 } else { 291 $where = '(post_status = \'publish\' OR post_status = \'static\')';301 $where = 'post_status = \'static\''; 302 } else { 303 $where = '(post_status = \'publish\' OR post_status = \'static\')'; 292 304 } 293 305 $recentcomments = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, comment_author, post_date, comment_date FROM $wpdb->posts INNER JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date < '".current_time('mysql')."' AND $where AND post_password = '' ORDER BY comment_date DESC LIMIT $limit"); 294 306 if($recentcomments) { 295 307 foreach ($recentcomments as $post) { 296 $post_title = htmlspecialchars(stripslashes($post->post_title)); 297 $comment_author = htmlspecialchars(stripslashes($post->comment_author)); 298 $comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date); 299 echo "<li>$comment_date - $comment_author (<a href=\"".get_permalink()."\">$post_title</a>)</li>"; 300 } 301 } else { 302 echo '<li>'.__('N/A').'</li>'; 308 $post_title = htmlspecialchars(stripslashes($post->post_title)); 309 $comment_author = htmlspecialchars(stripslashes($post->comment_author)); 310 $comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date); 311 $temp .= "<li>$comment_date - $comment_author (<a href=\"".get_permalink()."\">$post_title</a>)</li>\n"; 312 } 313 } else { 314 $temp = '<li>'.__('N/A').'</li>'; 315 } 316 if($display) { 317 echo $temp; 318 } else { 319 return $temp; 303 320 } 304 321 } … … 306 323 307 324 ### Function: Get Top Commented Posts 308 function get_mostcommented($mode = '', $limit = 10, $chars = 0 ) {325 function get_mostcommented($mode = '', $limit = 10, $chars = 0, $display = true) { 309 326 global $wpdb, $post; 310 327 $where = ''; 328 $temp = ''; 311 329 if($mode == 'post') { 312 $where = 'post_status = \'publish\'';330 $where = 'post_status = \'publish\''; 313 331 } elseif($mode == 'page') { 314 $where = 'post_status = \'static\'';315 } else { 316 $where = '(post_status = \'publish\' OR post_status = \'static\')';332 $where = 'post_status = \'static\''; 333 } else { 334 $where = '(post_status = \'publish\' OR post_status = \'static\')'; 317 335 } 318 336 $mostcommenteds = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->posts LEFT JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date < '".current_time('mysql')."' AND $where AND post_password = '' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit"); … … 320 338 if($chars > 0) { 321 339 foreach ($mostcommenteds as $post) { 322 $post_title = htmlspecialchars(stripslashes($post->post_title));323 $comment_total = intval($post->comment_total);324 echo"<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $comment_total ".__('comments')."</li>";340 $post_title = htmlspecialchars(stripslashes($post->post_title)); 341 $comment_total = intval($post->comment_total); 342 $temp .= "<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $comment_total ".__('comments')."</li>"; 325 343 } 326 344 } else { 327 345 foreach ($mostcommenteds as $post) { 328 $post_title = htmlspecialchars(stripslashes($post->post_title)); 329 $comment_total = intval($post->comment_total); 330 echo "<li><a href=\"".get_permalink()."\">$post_title</a> - $comment_total ".__('comments')."</li>"; 331 } 332 } 333 } else { 334 echo '<li>'.__('N/A').'</li>'; 346 $post_title = htmlspecialchars(stripslashes($post->post_title)); 347 $comment_total = intval($post->comment_total); 348 $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $comment_total ".__('comments')."</li>"; 349 } 350 } 351 } else { 352 $temp = '<li>'.__('N/A').'</li>'; 353 } 354 if($display) { 355 echo $temp; 356 } else { 357 return $temp; 335 358 } 336 359 } … … 338 361 339 362 ### Function: Get Author Stats 340 function get_authorsstats( ) {363 function get_authorsstats($display = true) { 341 364 global $wpdb, $wp_rewrite; 342 365 $where = ''; 366 $temp = ''; 343 367 if($mode == 'post') { 344 368 $where = 'post_status = \'publish\''; … … 357 381 $posts_total = intval($post->posts_total); 358 382 if($using_permalink) { 359 echo "<li><a href=\"".get_settings('siteurl').$author_link."\">$display_name</a> ($posts_total)</li>";383 $temp .= "<li><a href=\"".get_settings('siteurl').$author_link."\">$display_name</a> ($posts_total)</li>\n"; 360 384 } else { 361 echo "<li><a href=\"".get_settings('siteurl')."/?author_name=$post_author\">$display_name</a> ($posts_total)</li>";385 $temp .= "<li><a href=\"".get_settings('siteurl')."/?author_name=$post_author\">$display_name</a> ($posts_total)</li>\n"; 362 386 } 363 387 } 364 388 } else { 365 echo '<li>'.__('N/A').'</li>'; 389 $temp = '<li>'.__('N/A').'</li>'; 390 } 391 if($display) { 392 echo $temp; 393 } else { 394 return $temp; 366 395 } 367 396 } … … 371 400 // Treshhold = Number Of Posts User Must Have Before It Will Display His Name Out 372 401 // 5 = Default Treshhold; -1 = Disable Treshhold 373 function get_commentmembersstats($threshhold = -1) { 374 global $wpdb; 402 function get_commentmembersstats($threshhold = -1, $display = true) { 403 global $wpdb; 404 $temp = ''; 375 405 $comments = $wpdb->get_results("SELECT comment_author, COUNT(comment_ID) AS 'comment_total' FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_author ORDER BY comment_total DESC"); 376 406 if($comments) { … … 379 409 $comment_author_link = urlencode($comment_author); 380 410 $comment_total = intval($comment->comment_total); 381 echo "<li><a href=\"".get_settings('siteurl')."/wp-content/plugins/stats/wp-stats.php?author=$comment_author_link\">$comment_author</a> ($comment_total)</li>";411 $temp .= "<li><a href=\"".stats_page_link($comment_author_link)."\">$comment_author</a> ($comment_total)</li>\n"; 382 412 // If Total Comments Is Below Threshold 383 413 if($comment_total <= $threshhold && $threshhold != -1) { … … 386 416 } 387 417 } else { 388 echo '<li>'.__('N/A').'</li>'; 418 $temp = '<li>'.__('N/A').'</li>'; 419 } 420 if($display) { 421 echo $temp; 422 } else { 423 return $temp; 389 424 } 390 425 } … … 392 427 393 428 ### Function: Get Links Categories Stats 394 function get_linkcats() { 395 global $wpdb; 429 function get_linkcats($display = true) { 430 global $wpdb; 431 $temp = ''; 396 432 $linkcats = $wpdb->get_results("SELECT $wpdb->linkcategories.cat_name, COUNT(*) AS 'total_links' FROM $wpdb->links INNER JOIN $wpdb->linkcategories ON $wpdb->linkcategories.cat_id = $wpdb->links.link_category GROUP BY $wpdb->linkcategories.cat_id ORDER BY total_links DESC "); 397 433 if($linkcats) { … … 399 435 $cat_name = htmlspecialchars(stripslashes($linkcat->cat_name)); 400 436 $total_links = intval($linkcat->total_links); 401 echo "<li>$cat_name ($total_links)</li>\n"; 402 } 403 } else { 404 echo '<li>'.__('N/A').'</li>'; 437 $temp .= "<li>$cat_name ($total_links)</li>\n"; 438 } 439 } else { 440 $temp = '<li>'.__('N/A').'</li>'; 441 } 442 if($display) { 443 echo $temp; 444 } else { 445 return $temp; 405 446 } 406 447 } … … 415 456 } 416 457 } 458 459 460 ### Function: Place Statistics Page In Content 461 add_filter('the_content', 'place_stats', '12'); 462 function place_stats($content){ 463 $content = preg_replace( "/\<page_stats\>/ise", "stats_page()", $content); 464 return $content; 465 } 466 467 468 ### Function: Stats Page 469 function stats_page_link($author, $page = 0) { 470 $stats_url = get_settings('stats_url'); 471 if($page > 1) { 472 $page = "&stats_page=$page"; 473 } else { 474 $page = ''; 475 } 476 if(strpos($stats_url, '?') !== false) { 477 $stats_url = "$stats_url&stats_author=$author$page"; 478 } else { 479 $stats_url = "$stats_url?stats_author=$author$page"; 480 } 481 return $stats_url; 482 } 483 484 485 ### Function: Statistics Page 486 function stats_page() { 487 global $wpdb, $post; 488 // Variables Variables Variables 489 $comment_author = urldecode(strip_tags(stripslashes(trim($_GET['stats_author'])))); 490 $page = intval($_GET['stats_page']); 491 $temp_stats = ''; 492 493 // Default wp-stats.php Page 494 if(empty($comment_author)) { 495 // General Stats 496 $temp_stats .= '<!-- General Stats -->'."\n"; 497 $temp_stats .= '<h2 class="pagetitle">General Stats</h2>'."\n"; 498 $temp_stats .= '<p><b>Total Stats</b></p>'."\n"; 499 $temp_stats .= '<ul>'."\n"; 500 $temp_stats .= '<li><b>'.get_totalauthors(false).'</b> Authors To This Blog.</li>'."\n"; 501 $temp_stats .= '<li><b>'.get_totalposts(false).'</b> Posts Were Posted.</li>'."\n"; 502 $temp_stats .= '<li><b>'.get_totalpages(false).'</b> Pages Were Created.</li>'."\n"; 503 $temp_stats .= '<li><b>'.get_totalcomments(false).'</b> Comments Were Posted.</li>'."\n"; 504 $temp_stats .= '<li><b>'.get_totalcommentposters(false).'</b> Different Nicks Were Represented In The Comments.</li>'."\n"; 505 $temp_stats .= '<li><b>'.get_totallinks(false).'</b> Links Were Added.</li>'."\n"; 506 $temp_stats .= '</ul>'."\n"; 507 508 // Plugin Stats 509 $temp_stats .= '<!-- Plugin Stats -->'."\n"; 510 $temp_stats .= '<h2 class="pagetitle">Plugins Stats</h2>'."\n"; 511 512 // WP-EMail Stats 513 if(function_exists('wp_email')) { 514 $temp_stats .= '<!-- WP-EMail Stats -->'."\n"; 515 $temp_stats .= '<p><b>WP-EMail</b></p>'."\n"; 516 $temp_stats .= '<ul>'."\n"; 517 $temp_stats .= '<li><b>'.get_emails(false).'</b> Emails Were Sent.</li>'."\n"; 518 $temp_stats .= '<li><b>'.get_emails_success(false).'</b> Emails Were Sent Successfully.</li>'."\n"; 519 $temp_stats .= '<li><b>'.get_emails_failed(false).'</b> Emails Failed To Send.</li>'."\n"; 520 $temp_stats .= '</ul>'."\n"; 521 } 522 523 // WP-Polls Stats 524 if(function_exists('get_poll')) { 525 $temp_stats .= '<!-- WP-Polls Stats -->'."\n"; 526 $temp_stats .= '<p><b>WP-Polls</b></p>'."\n"; 527 $temp_stats .= '<ul>'."\n"; 528 $temp_stats .= '<li><b>'.get_pollquestions(false).'</b> Polls Were Created.</li>'."\n"; 529 $temp_stats .= '<li><b>'.get_pollanswers(false).'</b> Polls\' Answers Were Given.</li>'."\n"; 530 $temp_stats .= '<li><b>'.get_pollvotes(false).'</b> Votes Were Casted.</li>'."\n"; 531 $temp_stats .= '</ul>'."\n"; 532 } 533 534 // WP-PostRatings Stats 535 if(function_exists('the_ratings')) { 536 $temp_stats .= '<!-- WP-PostRatings Stats -->'."\n"; 537 $temp_stats .= '<p><b>WP-PostRatings</b></p>'."\n"; 538 $temp_stats .= '<ul>'."\n"; 539 $temp_stats .= '<li><b>'.get_ratings_votes(false).'</b> Votes Were Casted.</li>'."\n"; 540 $temp_stats .= '<li><b>'.get_ratings_users(false).'</b> Users Casted Their Vote.</li>'."\n"; 541 $temp_stats .= '</ul>'."\n"; 542 } 543 544 // WP-PostViews Stats 545 if(function_exists('the_views')) { 546 $temp_stats .= '<!-- WP-PostViews Stats -->'."\n"; 547 $temp_stats .= '<p><b>WP-PostViews</b></p>'."\n"; 548 $temp_stats .= '<ul>'."\n"; 549 $temp_stats .= '<li><b>'.get_totalviews(false).'</b> Views Were Generated.</li>'."\n"; 550 $temp_stats .= '</ul>'."\n"; 551 } 552 553 // WP-UserOnline Stats 554 if(function_exists('useronline')) { 555 $temp_stats .= '<!-- WP-UserOnline Stats -->'."\n"; 556 $temp_stats .= '<p><b>WP-UserOnline</b></p>'."\n"; 557 $temp_stats .= '<ul>'."\n"; 558 $temp_stats .= '<li><b>'.get_useronline('', '', false).'</b> User(s) Online Now.</li>'."\n"; 559 $temp_stats .= '<li>Most users ever online was <b>'.get_most_useronline(false).'</b>.</li>'."\n"; 560 $temp_stats .= '<li>On <b>'.get_most_useronline_date(false).'</b>.</li>'."\n"; 561 $temp_stats .= '</ul>'."\n"; 562 } 563 564 // Top 10 Stats 565 $temp_stats .= '<!-- Top 10 Stats-->'."\n"; 566 $temp_stats .= '<h2 class="pagetitle">Top 10 Stats</h2>'."\n"; 567 568 // 10 Recent Posts 569 $temp_stats .= '<!-- 10 Recent Posts -->'."\n"; 570 $temp_stats .= '<p><b>10 Recent Posts</b></p>'."\n"; 571 $temp_stats .= '<ul>'."\n"; 572 $temp_stats .= get_recentposts('', 10, false); 573 $temp_stats .= '</ul>'."\n"; 574 575 // 10 Recent Comments 576 $temp_stats .= '<!-- 10 Recent Comments -->'."\n"; 577 $temp_stats .= '<p><b>10 Recent Comments</b></p>'."\n"; 578 $temp_stats .= '<ul>'."\n"; 579 $temp_stats .= get_recentcomments('', 10, false); 580 $temp_stats .= '</ul>'."\n"; 581 582 // 10 Most Commented Post 583 $temp_stats .= '<!-- 10 Most Commented Post -->'."\n"; 584 $temp_stats .= '<p><b>10 Most Commented Post</b></p>'."\n"; 585 $temp_stats .= '<ul>'."\n"; 586 $temp_stats .= get_mostcommented('', 10, 0, false); 587 $temp_stats .= '</ul>'."\n"; 588 589 // WP-EMail (10 Most EMailed Post) 590 if(function_exists('wp_email')) { 591 $temp_stats .= '<!-- WP-EMail (10 Most EMailed Post) -->'."\n"; 592 $temp_stats .= '<p><b>10 Most Emailed Post</b></p>'."\n"; 593 $temp_stats .= '<ul>'."\n"; 594 $temp_stats .= get_mostemailed('', 10, 0, false); 595 $temp_stats .= '</ul>'."\n"; 596 } 597 598 // WP-PostRatings (10 Highest Rated Post) (10 Most Rated Post) 599 if(function_exists('the_ratings')) { 600 $temp_stats .= '<!-- WP-PostRatings (10 Highest Rated Post) -->'."\n"; 601 $temp_stats .= '<p><b>10 Highest Rated Post</b></p>'."\n"; 602 $temp_stats .= '<ul>'."\n"; 603 $temp_stats .= get_highest_rated('', 10, 0, false); 604 $temp_stats .= '</ul>'."\n"; 605 606 $temp_stats .= '<!-- WP-PostRatings (10 Most Rated Post) -->'."\n"; 607 $temp_stats .= '<p><b>10 Most Rated Post</b></p>'."\n"; 608 $temp_stats .= '<ul>'."\n"; 609 $temp_stats .= get_most_rated('', 10, 0, false); 610 $temp_stats .= '</ul>'."\n"; 611 } 612 613 // WP-PostViews (10 Most Viewed Post) 614 if(function_exists('the_views')) { 615 $temp_stats .= '<!-- WP-PostViews (10 Most Viewed Post) -->'."\n"; 616 $temp_stats .= '<p><b>10 Most Viewed Post</b></p>'."\n"; 617 $temp_stats .= '<ul>'."\n"; 618 $temp_stats .= get_most_viewed('', 10, 0, false); 619 $temp_stats .= '</ul>'."\n"; 620 } 621 622 // Author Stats 623 $temp_stats .= '<!-- Author Stats -->'."\n"; 624 $temp_stats .= '<h2 class="pagetitle">Authors Stats</h2>'."\n"; 625 $temp_stats .= '<p><b>Authors</b></p>'."\n"; 626 $temp_stats .= '<ol>'."\n"; 627 $temp_stats .= get_authorsstats(false); 628 $temp_stats .= '</ol>'."\n"; 629 630 // Comments' Members Stats 631 $temp_stats .= '<!-- Comments\' Members Stats -->'."\n"; 632 $temp_stats .= '<h2 class="pagetitle">Comments\' Members Stats</h2>'."\n"; 633 $temp_stats .= '<p><b>Comment Members</b></p>'."\n"; 634 $temp_stats .= '<ol>'."\n"; 635 $temp_stats .= get_commentmembersstats(-1, false); 636 $temp_stats .= '</ol>'."\n"; 637 638 // Misc Stats 639 $temp_stats .= '<!-- Misc Stats -->'."\n"; 640 $temp_stats .= '<h2 class="pagetitle">Misc Stats</h2>'."\n"; 641 642 // Post Categories 643 $temp_stats .= '<!-- Post Categories -->'."\n"; 644 $temp_stats .= '<p><b>Post Categories</b></p>'."\n"; 645 $temp_stats .= '<ul>'."\n"; 646 $temp_stats .= list_cats(1,'All','name','asc','',true,0,1,0,1,true,0,0,1,'','','',true); 647 $temp_stats .= '</ul>'."\n"; 648 649 // Link Categories 650 $temp_stats .= '<!-- Link Categories -->'."\n"; 651 $temp_stats .= '<p><b>Link Categories</b></p>'."\n"; 652 $temp_stats .= '<ul>'."\n"; 653 $temp_stats .= get_linkcats(false); 654 $temp_stats .= '</ul>'."\n"; 655 656 // Displaying Comments Posted By User 657 } else { 658 // Stats URL 659 $stats_url = get_settings('stats_url'); 660 // Number Of Comments Per Page 661 $perpage = 10; 662 // Comment Author Link 663 $comment_author_link = urlencode($comment_author); 664 // Comment Author SQL 665 $comment_author_sql = $wpdb->escape($comment_author); 666 // Total Comments Posted By User 667 $totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_author='$comment_author_sql'"); 668 // Checking $page and $offset 669 if (empty($page) || $page == 0) { $page = 1; } 670 if (empty($offset)) { $offset = 0; } 671 // Determin $offset 672 $offset = ($page-1) * $perpage; 673 // Some Comments Stats 674 if(($offset + $perpage) > $totalcomments) { $maxonpage = $totalcomments ; } else { $maxonpage = ($offset+$perpage); } 675 if (($offset + 1) > ($totalcomments)) { $displayonpage = $totalcomments ; } else { $displayonpage = ($offset+1); } 676 // Count Total Pages 677 $totalpages = ceil($totalcomments/$perpage); 678 // Getting The Comments 679 $gmz_comments = $wpdb->get_results("SELECT $wpdb->posts.ID, comment_author, comment_date, comment_content, ID, comment_ID, post_date, post_title, post_name, post_password 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"); 680 681 $temp_stats .= '<h2 class="pagetitle">Comments Posted By '.$comment_author.'</h2>'."\n"; 682 $temp_stats .= '<p>Displaying <b>'.$displayonpage.'</b> To <b>'.$maxonpage.'</b> Of <b>'.$totalcomments.'</b> Comments</p>'."\n"; 683 684 // Get Comments 685 if($gmz_comments) { 686 foreach($gmz_comments as $post) { 687 $comment_id = intval($post-> comment_ID); 688 $comment_author2 = htmlspecialchars(stripslashes($post->comment_author)); 689 $comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date); 690 $comment_content = wpautop(stripslashes($post->comment_content)); 691 $post_date = mysql2date('d.m.Y @ H:i', $post->post_date); 692 $post_title = htmlspecialchars(stripslashes($post->post_title)); 693 694 // Check For Password Protected Post 695 if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) { 696 // If New Title, Print It Out 697 if($post_title != $cache_post_title) { 698 $temp_stats .= "<p><b><a href=\"".get_permalink()."\" title=\"Posted On $post_date\">Protected: $post_title</a></b></p>\n"; 699 $temp_stats .= "<blockquote>Comments Protected</blockquote>\n"; 700 } 701 } else { 702 // If New Title, Print It Out 703 if($post_title != $cache_post_title) { 704 $temp_stats .= "<p><b><a href=\"".get_permalink()."\" title=\"Posted On $post_date\">$post_title</a></b></p>\n"; 705 } 706 $temp_stats .= "<blockquote>$comment_content <a href=\"".get_permalink()."#comment-$comment_id\">Comment</a> Posted By <b>$comment_author2</b> On $comment_date</blockquote>\n"; 707 } 708 $cache_post_title = $post_title; 709 } 710 $post = null; 711 } else { 712 $temp_stats .= "<p>$comment_author has not made any comments yet.</p>\n"; 713 } 714 715 // If Total Pages Is More Than 1, Display Page Navigation 716 if($totalpages > 1) { 717 // Previous Page 718 $temp_stats .= '<p>'."\n"; 719 $temp_stats .= '<span style="float: left">'."\n"; 720 if($page > 1 && ((($page*$perpage)-($perpage-1)) < $totalcomments)) { 721 $temp_stats .= '<b>«</b> <a href="'.stats_page_link($comment_author_link, $page-1).'" title="« '.__('Previous Page').'">'.__('Previous Page').'</a>'."\n"; 722 } else { 723 $temp_stats .= ' '."\n"; 724 } 725 $temp_stats .= '</span>'."\n"; 726 // Next Page 727 $temp_stats .= '<span style="float: right">'."\n"; 728 if($page >= 1 && ((($page*$perpage)+1) < $totalcomments)) { 729 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, $page+1).'" title="'.__('Next Page').' »">'.__('Next Page').'</a> <b>»</b>'."\n"; 730 } else { 731 $temp_stats .= ' '."\n"; 732 } 733 $temp_stats .= '</span>'."\n"; 734 $temp_stats .= '</p>'."\n"; 735 // Pages 736 $temp_stats .= '<br style="clear: both" />'."\n"; 737 $temp_stats .= '<p align="center">'."\n"; 738 $temp_stats .= 'Pages ('.$totalpages.') :'."\n"; 739 if ($page >= 4) { 740 $temp_stats .= '<b><a href="'.stats_page_link($comment_author_link).'" title="'.__('Go to First Page').'">« '.__('First').'</a></b> ... '."\n"; 741 } 742 if($page > 1) { 743 $temp_stats .= ' <b><a href="'.stats_page_link($comment_author_link, $page-1).'" title="« '.__('Go to Page').' '.($page-1).'">«</a></b> '."\n"; 744 } 745 for($i = $page - 2 ; $i <= $page +2; $i++) { 746 if ($i >= 1 && $i <= $totalpages) { 747 if($i == $page) { 748 $temp_stats .= "<b>[$i]</b> "."\n"; 749 } else { 750 $temp_stats .= '<a href="'.stats_page_link($comment_author_link, $i).'" title="'.__('Page').' '.$i.'">'.$i.'</a> '."\n"; 751 } 752 } 753 } 754 if($page < $totalpages) { 755 $temp_stats .= ' <b><a href="'.stats_page_link($comment_author_link, $page+1).'" title="'.__('Go to Page').' '.($page+1).' »">»</a></b> '."\n"; 756 } 757 if (($page+2) < $totalpages) { 758 $temp_stats .= ' ... <b><a href="'.stats_page_link($comment_author_link, $totalpages).'" title="'.__('Go to Last Page').'">'.__('Last').' »</a></b>'."\n"; 759 } 760 $temp_stats .= '</p>'."\n"; 761 } 762 $temp_stats .= '<p><b>««</b> <a href="'.$stats_url.'">Back To Stats Page</a></p>'."\n"; 763 } // End If 764 765 // Output Stats Page 766 return $temp_stats; 767 } 768 769 770 ### Function: Stats Option 771 add_action('activate_stats/stats.php', 'stats_init'); 772 function stats_init() { 773 global $wpdb; 774 add_option('stats_url', get_settings('siteurl').'/stats/', 'Stats URL'); 775 } 417 776 ?>
