function latestforumposts()
{
    global $pic_base_url, $CURUSER, $config, $php_file, $page_find, $lang_off, $language;
    // / FIRST WE MAKE THE HEADER (NON-LOOPED) ///
    ?>
<table align="center" width="760" cellspacing=0 cellpadding=8><tr><td align="left" class=colhead><b><?php 
    echo $language['topic'];
    ?>
</b></td><!--<td align="center" class=colhead><b>Author</b></td><td align="center" class=colhead><b>Replies</b></td>--><td align="center" class=colhead><b><?php 
    echo $language['view'];
    ?>
</b></td><td align="center" class=colhead><b><?php 
    echo $language['post'];
    ?>
</b></td><!--<td align="center" class=colhead><b>Posted At</b></td>-->
</tr>
<?php 
    $page = 1;
    $num = 0;
    // / HERE GOES THE QUERY TO RETRIEVE DATA FROM THE DATABASE AND WE START LOOPING ///
    $topicres = sql_query("SELECT t.id, t.userid, t.subject, t.locked, t.forumid, t.pollid, t.lastpost, t.sticky, t.views, t.forumid, f.minclassread, f.name " . ", (SELECT COUNT(id) FROM posts WHERE topicid=t.id) AS p_count " . ", p.userid AS puserid, p.added " . ", u.id AS uid, u.username " . ", u2.username AS u2_username " . "FROM topics AS t " . "LEFT JOIN forums AS f ON f.id = t.forumid " . "LEFT JOIN posts AS p ON p.id=(SELECT MAX(id) FROM posts WHERE topicid = t.id) " . "LEFT JOIN users AS u ON u.id=p.userid " . "LEFT JOIN users AS u2 ON u2.id=t.userid " . "WHERE t.locked = 'no' AND f.minclassread <= " . $CURUSER['class'] . " " . "ORDER BY t.lastpost DESC LIMIT 11") or sqlerr(__FILE__, __LINE__);
    while ($topicarr = mysql_fetch_assoc($topicres)) {
        $topicid = $topicarr["id"];
        $topic_userid = $topicarr["userid"];
        $perpage = $CURUSER["postsperpage"];
        if (!$perpage) {
            $perpage = 24;
        }
        $posts = $topicarr["p_count"];
        $replies = max(0, $posts - 1);
        $first = $page * $perpage - $perpage + 1;
        $last = $first + $perpage - 1;
        if ($last > $num) {
            $last = $num;
        }
        $pages = ceil($posts / $perpage);
        // $menu = "\n";
        $menu = "";
        for ($i = 1; $i <= $pages; $i++) {
            if ($i == 1 && $i != $pages) {
                $menu .= "[ ";
            }
            if ($pages > 1) {
                $menu .= "<a href=/forums.php?action=viewtopic&amp;topicid={$topicid}&amp;page={$i}>{$i}</a>\n";
            }
            if ($i < $pages) {
                $menu .= "|\n";
            }
            if ($i == $pages && $i > 1) {
                $menu .= "]";
            }
        }
        $added = $topicarr["added"] . '<br /><font class=small>(' . get_elapsed_time(sql_timestamp_to_unix_timestamp($topicarr["added"])) . ' ago)</font>';
        $username = is_valid_id($topicarr['uid']) ? "<a href=/userdetails.php?id=" . $topicarr["puserid"] . "><b>" . $topicarr['username'] . "</b></a>" : "<i>Unknown[{$topic_userid}]</i>";
        $author = !empty($topicarr['u2_username']) ? "<a href=/userdetails.php?id={$topic_userid}><b>" . $topicarr['u2_username'] . "</b></a>" : "<i>Unknown[{$topic_userid}]</i>";
        $staffimg = $topicarr["minclassread"] > 0 ? "<img src=" . $pic_base_url . "staff.png border=0 />" : "";
        $lockimg = $topicarr["locked"] == 'yes' ? "<img src=" . $pic_base_url . "lockednew.gif border=0 />" : "";
        $pollimg = is_valid_id($topicarr["pollid"]) ? "<img src=\"" . $pic_base_url . "poll.gif\" alt=\"Poll:\" width=\"12\" height=\"14\" />&nbsp;&nbsp;&nbsp;" : "";
        $stickyimg = $topicarr["sticky"] == 'yes' ? "<img src=\"" . $pic_base_url . "sticky.gif\" alt=\"Sticky:\" width=\"12px\" height=\"14px\" />&nbsp;&nbsp;&nbsp;" : "";
        $subject = $pollimg . $stickyimg . "<a href=\"forums.php?action=viewtopic&amp;topicid={$topicid}&amp;page=last#" . $topicarr["lastpost"] . "\"><b>" . encodehtml($topicarr["subject"]) . "</b></a>{$lockimg}&nbsp;&nbsp;&nbsp;{$staffimg}&nbsp;&nbsp;&nbsp;{$menu}<br /><font class=small> in <i><a href=\"/forums.php?action=viewforum&amp;forumid=" . $topicarr['forumid'] . "\">" . $topicarr['name'] . "</a></i> by " . $author . "&nbsp;&nbsp;" . get_elapsed_time(sql_timestamp_to_unix_timestamp($topicarr["added"])) . " ago </font>";
        ?>
<tr><td><?php 
        echo $subject;
        ?>
</td><td align="center"><?php 
        echo number_format($topicarr["views"]);
        ?>
</td><td align="center"><?php 
        echo $username;
        ?>
</td></tr><?php 
    }
    ?>
</table>
<?php 
}
Exemple #2
0
 function latestforumposts()
 {
     print "<div class='f-border f-latestpost'><table width='100%' cellspacing='0'><tr class='f-title'>" . "<th align='left'  width=''>Latest Topic Title</th>" . "<th align='center' width='47'>Replies</th>" . "<th align='center' width='47'>Views</th>" . "<th align='center' width='85'>Author</th>" . "<th align='right' width='150'>Last Post</th>" . "</tr>";
     /// HERE GOES THE QUERY TO RETRIEVE DATA FROM THE DATABASE AND WE START LOOPING ///
     $for = SQL_Query_exec("SELECT * FROM forum_topics ORDER BY lastpost DESC LIMIT 5");
     if (mysql_num_rows($for) == 0) {
         print "<tr class='f-row'><td class='alt1' align='center' colspan='5'><b>No Latest Topics</b></td></tr>";
     }
     while ($topicarr = mysql_fetch_assoc($for)) {
         // Set minclass
         $res = SQL_Query_exec("SELECT name,minclassread,guest_read FROM forum_forums WHERE id={$topicarr['forumid']}");
         $forum = mysql_fetch_assoc($res);
         if ($forum && get_user_class() >= $forum["minclassread"] || $forum["guest_read"] == "yes") {
             $forumname = "<a href='?action=viewforum&amp;forumid={$topicarr['forumid']}'><b>" . htmlspecialchars($forum["name"]) . "</b></a>";
             $topicid = $topicarr["id"];
             $topic_title = stripslashes($topicarr["subject"]);
             $topic_userid = $topicarr["userid"];
             // Topic Views
             $views = $topicarr["views"];
             // End
             /// GETTING TOTAL NUMBER OF POSTS ///
             $res = SQL_Query_exec("SELECT COUNT(*) FROM forum_posts WHERE topicid={$topicid}");
             $arr = mysql_fetch_row($res);
             $posts = $arr[0];
             $replies = max(0, $posts - 1);
             /// GETTING USERID AND DATE OF LAST POST ///
             $res = SQL_Query_exec("SELECT * FROM forum_posts WHERE topicid={$topicid} ORDER BY id DESC LIMIT 1");
             $arr = mysql_fetch_assoc($res);
             $postid = 0 + $arr["id"];
             $userid = 0 + $arr["userid"];
             $added = utc_to_tz($arr["added"]);
             /// GET NAME OF LAST POSTER ///
             $res = SQL_Query_exec("SELECT id, username FROM users WHERE id={$userid}");
             if (mysql_num_rows($res) == 1) {
                 $arr = mysql_fetch_assoc($res);
                 $username = "******";
             } else {
                 $username = "******";
             }
             /// GET NAME OF THE AUTHOR ///
             $res = SQL_Query_exec("SELECT username FROM users WHERE id={$topic_userid}");
             if (mysql_num_rows($res) == 1) {
                 $arr = mysql_fetch_assoc($res);
                 $author = "<a href='account-details.php?id={$topic_userid}'>{$arr['username']}</a>";
             } else {
                 $author = "Unknown[{$topic_userid}]";
             }
             /// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
             $r = SQL_Query_exec("SELECT lastpostread FROM forum_readposts WHERE userid={$userid} AND topicid={$topicid}");
             $a = mysql_fetch_row($r);
             $new = !$a || $postid > $a[0];
             $subject = "<a href='forums.php?action=viewtopic&amp;topicid={$topicid}'><b>" . stripslashes(encodehtml($topicarr["subject"])) . "</b></a>";
             print "<tr class='f-row'><td class='f-img' width='100%'>{$subject}</td>" . "<td class='alt2' align='center'>{$replies}</td>" . "<td class='alt3' align='center'>{$views}</td>" . "<td class='alt2' align='center'>{$author}</td>" . "<td class='alt3' align='right'><small>by&nbsp;{$username}<br /></small><small style='white-space: nowrap'>{$added}</small></td>";
             print "</tr>";
         }
         // while
     }
     print "</table></div><br />";
 }
                ++$i;
            }
            $tvotes = number_format($tvotes);
            ?>
    	<div class="text-center"><h4><span class="label label-success"><?php 
            echo T_("VOTES") . ": " . $tvotes;
            ?>
</span></h4></div>

  	<?php 
        } else {
            //User has not voted, show options
            ?>

    <form method='post' action='<?php 
            echo encodehtml($_SERVER["REQUEST_URI"]);
            ?>
'>
    <input type='hidden' name='act' value='takepoll' />

    <?php 
            $i = 0;
            while ($a = $o[$i]) {
                ?>

      <div class="radio">
        <label>
      		<input type='radio' name='choice' value='<?php 
                echo $i;
                ?>
' /><?php 
                    $p = round($a[0] / $tvotes * 100);
                }
                if ($i % 2) {
                    $c = "";
                } else {
                    $c = " class='poll-alt'";
                }
                print "<tr><td width='1%'{$c}>" . format_comment($a[1]) . "&nbsp;&nbsp;</td><td width='99%'{$c}><img src='" . $site_config["SITEURL"] . "/images/poll/bar_left.gif' alt='' /><img src='" . $site_config["SITEURL"] . "/images/poll/bar.gif' height='9' width='" . $p / 2 . "' alt='' /><img src='" . $site_config["SITEURL"] . "/images/poll/bar_right.gif' alt='' />{$p}%</td></tr>\n";
                ++$i;
            }
            print "</table>\n";
            $tvotes = number_format($tvotes);
            print "<center>" . T_("VOTES") . ": {$tvotes}</center>\n";
        } else {
            //User has not voted, show options
            print "<form method='post' action='" . encodehtml($_SERVER["REQUEST_URI"]) . "'>\n";
            print "<input type='hidden' name='act' value='takepoll' />";
            $i = 0;
            while ($a = $o[$i]) {
                print "<input type='radio' name='choice' value='{$i}' />" . format_comment($a) . "<br />\n";
                ++$i;
            }
            print "<br />";
            print "<input type='radio' name='choice' value='255' />" . T_("BLANK_VOTE") . "<br />\n";
            print "<center><input type='submit' value='" . T_("VOTE") . "!' class='btn btn-success' /></center></form><br />";
            print "<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>\n<input type='hidden' name='cmd' value='_s-xclick'>\n<input type='hidden' name='hosted_button_id' value='8J54CFAAS52VW'>\n<input type='image' src='https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif' border='0' name='submit' alt='PayPal – The safer, easier way to pay online.'>\n<img alt='' border='0' src='https://www.paypalobjects.com/en_GB/i/scr/pixel.gif' width='1' height='1'>\n</form>";
        }
    } else {
        echo "<br /><br /><center>No Active Polls</center><br /><br />\n";
    }
} else {
Exemple #5
0
        }
        else
          $lpauthor = "unknown[$topic_userid]";

        //---- Print row

        $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);

        $a = mysql_fetch_row($r);

        $new = !$a || $lppostid > $a[0];

        $topicpic = ($locked ? ($new ? "lockednew" : "locked") : ($new ? "unlockednew" : "unlocked"));

        $subject = ($sticky ? "Sticky: " : "") . "<a href=?action=viewtopic&topicid=$topicid><b>" .
        encodehtml($topicarr["subject"]) . "</b></a>$topicpages";

        print("<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr>" .
        "<td class=embedded style='padding-right: 5px'><img src=$forum_pics/$topicpic.gif>" .
        "</td><td class=embedded align=left>\n" .
        "$subject</td></tr></table></td><td align=right>$replies</td>\n" .
        "<td align=right>$views</td><td align=left>$lpauthor</td>\n" .
        "<td align=left>$lpadded<br>by&nbsp;$lpusername</td>\n");

        print("</tr>\n");
      } // while

      print("</table>\n");

      print($menu);