<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: unanswered_threads.php
| Author: Nick Jones (Digitanium)
| Adapted by Philip
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEME."theme.php";
global $lastvisited;
if (!isset($lastvisited) || !isnum($lastvisited)) { $lastvisited = time(); }
if (isset($_GET['rowstart']) && isnum($_GET['rowstart'])) {
$rowstart = $_GET['rowstart'];
} else {
$rowstart = 0;
}
$thread_count = (dbcount("(thread_id)", DB_THREADS, "thread_postcount = 1"));
$week_time = (time() + ($settings['timeoffset'] * 3600));
$week_utotal = (dbcount("(thread_id)", DB_THREADS, "thread_lastpost + 604800 > $week_time AND thread_postcount = 1"));
$week_total = (dbcount("(thread_id)", DB_THREADS, "thread_lastpost + 604800 > $week_time"));
$all_utotal = (dbcount("(thread_id)", DB_THREADS, "thread_postcount = 1"));
$all_total = (dbcount("(thread_id)", DB_THREADS));
$result = dbquery(
"SELECT tt.thread_id, tt.thread_subject, tt.thread_views, tt.thread_lastuser, tt.thread_lastpost,
tt.thread_poll, tf.forum_id, tf.forum_name, tf.forum_access, tt.thread_lastpostid, tt.thread_postcount, tu.user_id, tu.user_name
FROM ".DB_THREADS." tt
INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
WHERE tf.forum_id !='50' AND tf.forum_id !='77' AND tf.forum_id !='78' AND tf.forum_id !='79' AND tf.forum_id !='80' AND tf.forum_id !='83'
AND ".groupaccess('tf.forum_access')." AND tt.thread_postcount = 1
ORDER BY tt.thread_lastpost DESC LIMIT $rowstart,50
");
if (dbrows($result)) {
$i = 0;
echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
echo "<td class='tbl2'> </td>\n";
echo "<td class='tbl2'><strong>Total Threads: ".$all_total."<br />
Total Unanswered: ".$thread_count."<br />
Overall percentage: ".round($all_utotal*100/$all_total)."%
</strong></td>\n";
echo "<td class='tbl2' align='left' colspan='3'><strong>Total this week: ".$week_total."<br />
Unanswered: ".$week_utotal."<br />
Weeks percentage: ".round($week_utotal*100/$week_total)."%
</strong></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl2'> </td>\n";
echo "<td width='100%' class='tbl2'><strong>".$locale['global_044']."</strong></td>\n";
echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_045']."</strong></td>\n";
echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_046']."</strong></td>\n";
echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_047']."</strong></td>\n";
echo "</tr>\n";
while ($data = dbarray($result)) {
$row_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
echo "<tr>\n<td class='".$row_color."'>";
if ($data['thread_lastpost'] > $lastvisited) {
$thread_match = $data['thread_id']."\|".$data['thread_lastpost']."\|".$data['forum_id'];
if (iMEMBER && preg_match("(^\.{$thread_match}$|\.{$thread_match}\.|\.{$thread_match}$)", $userdata['user_threads'])) {
echo "<img src='".get_image("folder")."' alt='' />";
} else {
echo "<img src='".get_image("foldernew")."' alt='' />";
}
} else {
echo "<img src='".get_image("folder")."' alt='' />";
}
if ($data['thread_poll']) {
$thread_poll = "<span class='small' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
} else {
$thread_poll = "";
}
echo "</td>\n";
echo "<td width='100%' class='".$row_color."'>".$thread_poll."<a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."&pid=".$data['thread_lastpostid']."#post_".$data['thread_lastpostid']."' title='".$data['thread_subject']."'>".trimlink($data['thread_subject'], 30)."</a><br />\n".$data['forum_name']."</td>\n";
echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".($data['thread_postcount']-1)."</td>\n";
echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'><a href='".BASEDIR."profile.php?lookup=".$data['thread_lastuser']."'>".$data['user_name']."</a><br />\n".showdate("forumdate", $data['thread_lastpost'])."</td>\n";
echo "</tr>\n";
$i++;
}
echo "</table>\n";
}
if ($thread_count > 50) echo "<div align='center' style=';margin-top:5px;'>\n".makepagenav($rowstart,50,$thread_count,3,FUSION_SELF."?page_id=".$_GET['page_id']."&")."\n</div>\n";
?>
$result = dbquery("SELECT tt.forum_id,thread_id,thread_replies,thread_lastuser,thread_lastpost,
tu.user_id,user_name
FROM ".DB_THREADS." tt
INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
WHERE tt.thread_deleted='0' ORDER BY thread_lastpost DESC"
);
$new_unread_posts = 0;
while ($data = dbarray($result)) {
$found = strstr($userdata['user_last_threads'], $data['thread_id']."|") ? 1 : 0;
if($found) {
$first_act = substr(strstr($userdata['user_last_threads'], $data['thread_id']."|"),strlen($data['thread_id'])+1,22);
$secont_act = explode(",",$first_act);
$last_tvisit = substr($secont_act['0'],-10);
$new_posts = $last_tvisit <= $data['thread_lastpost'] ? 1 : 0;
if($new_posts) { $new_unread_posts++; }
}
}
echo "Unread posts ".$new_unread_posts."";
Category Forum
Content Administration - 8Labels
None yet
Statistics
2 participants
Notifications
You are not receiving notifications from this thread.
Related Questions