コード例 #1
0
ファイル: messageboard_class.php プロジェクト: lmcro/fcms
 /**
  * showPosts 
  * 
  * @param   int     $thread_id 
  * @param   int     $page 
  * @return  void
  */
 function showPosts($thread_id, $page = 1)
 {
     $thread_id = (int) $thread_id;
     $page = (int) $page;
     $from = $page * 15 - 15;
     $total = $this->getNumberOfPosts($thread_id);
     if ($total < 1) {
         echo '
         <p class="error-alert">' . T_('Thread does not exist.') . '</p>';
         return;
     }
     $sql = "UPDATE `fcms_board_threads` \n                SET `views` = (`views` + 1) \n                WHERE `id` = ?";
     if (!$this->fcmsDatabase->update($sql, $thread_id)) {
         $this->fcmsError->displayError();
         return;
     }
     $this->displayMessageBoardMenu($thread_id);
     $this->displayPages($page, $thread_id);
     $sort = $this->getSortOrder($this->fcmsUser->id);
     $sql = "SELECT p.`id`, `thread`, `post`, `subject`, p.`date`, `user`, `avatar` \n                FROM `fcms_board_posts` AS p, `fcms_board_threads` AS t, \n                    `fcms_users` AS u \n                WHERE `thread` = ?\n                AND t.`id` = `thread` \n                AND `user` = u.`id` \n                ORDER BY p.`id` {$sort}\n                LIMIT {$from}, 15";
     $rows = $this->fcmsDatabase->getRows($sql, $thread_id);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $alt = 0;
     $first = true;
     foreach ($rows as $row) {
         // display the table header
         if ($first) {
             echo '
         <table id="postlist" cellpadding="0" cellspacing="0">
             <tbody>';
             $first = false;
         }
         // Shrink long subjects
         $subject = $row['subject'];
         if (strlen($subject) > 40) {
             $subject = substr($subject, 0, 37) . "...";
         }
         // Remove #ANOUNCE#
         $isThreadAnnouncement = false;
         $pos = strpos($subject, '#ANOUNCE#');
         if ($pos !== false) {
             $isThreadAnnouncement = true;
             $subject = substr($subject, 9, strlen($subject) - 9);
         }
         // Add RE: to replies
         if ($sort == 'ASC') {
             if ($alt > 0) {
                 $subject = "RE: " . $subject;
             }
         } else {
             if ($alt !== $total - 1) {
                 $subject = "RE: " . $subject;
             }
         }
         $displayname = getUserDisplayName($row['user']);
         $date = fixDate(T_('n/d/y g:ia'), $this->fcmsUser->tzOffset, $row['date']);
         if ($alt % 2 == 0) {
             $tr_class = '';
         } else {
             $tr_class = 'alt';
         }
         // Participation Level
         $points = getUserParticipationPoints($row['user']);
         $level = getUserParticipationLevel($points);
         // Avatar
         $avatar = "<img src=\"" . getCurrentAvatar($row['user']) . "\" alt=\"{$displayname}\"/><br/><br/>";
         // Post Count
         $posts_count = $this->getUserPostCountById($row['user']);
         $actions = '';
         // quote
         if ($this->fcmsUser->access < 8 && $this->fcmsUser->access != 5) {
             $actions .= '<form method="post" action="messageboard.php?reply=' . $thread_id . '">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="submit" class="quotebtn" value="' . T_('Quote') . '" name="quotepost" title="' . T_('Quote this message') . '"/>
                                     </div>
                                 </form>';
         }
         // edit
         if ($this->fcmsUser->id == $row['user'] || $this->fcmsUser->access < 3) {
             $actions .= ' &nbsp;
                                 <form method="post" action="messageboard.php">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="submit" name="editpost" value="' . T_('Edit') . '" class="editbtn" title="' . T_('Edit this message') . '"/>
                                     </div>
                                 </form>';
         }
         // delete
         if ($this->fcmsUser->access < 2) {
             $actions .= ' &nbsp;
                                 <form class="delpost" method="post" action="messageboard.php">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="hidden" name="thread" value="' . $thread_id . '"/>
                                         <input type="submit" name="delpost" value="' . T_('Delete') . '" class="delbtn" title="' . T_('Delete this message') . '"/>
                                     </div>
                                 </form>';
         }
         // Display the posts rows
         echo '
                 <tr class="' . $tr_class . '">
                     <td class="side">
                         <b><a href="profile.php?member=' . $row['user'] . '">' . $displayname . '</a></b>
                         ' . $level . '
                         ' . $avatar . '
                         <b>' . T_('Posts') . '</b> ' . $posts_count . '
                     </td>
                     <td class="posts">
                         <div class="header">
                             <div class="subject"><b>' . cleanOutput($subject, 'html') . '</b> - ' . $date . '</div>
                             <div class="actions">
                                 ' . $actions . '
                             </div>
                         </div>
                         <div class="msg">
                             ' . parse($row['post']) . '
                         </div>
                     </td>
                 </tr>';
         $alt++;
     }
     if (!$first) {
         echo '
             </tbody>
         </table>';
     }
     $this->displayMessageBoardMenu($thread_id);
     $this->displayPages($page, $thread_id);
     $this->displayAdminMenu($thread_id, $isThreadAnnouncement);
     echo '
         <div class="top"><a href="#top">' . T_('Back to Top') . '</a></div>';
 }
コード例 #2
0
ファイル: profile.php プロジェクト: lmcro/fcms
 /**
  * displayParticipation 
  * 
  * @return void
  */
 function displayParticipation()
 {
     $memberId = (int) $_GET['member'];
     $this->displayHeader($memberId);
     $statsData = $this->fcmsProfile->getStats($memberId);
     $points = getUserParticipationPoints($memberId);
     $level = getUserParticipationLevel($points);
     echo '
         <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/easy-pie-chart/2.1.4/jquery.easypiechart.min.js"></script>
         <div>
             <b>' . T_('Participation Points') . '</b><br/>
             <span style="float:left; padding-right: 10px;">' . $points . '</span>
             ' . $level . '
         </div><br/>
         <p><b>' . T_('Stats') . '</b></p>
         <div id="stats">';
     foreach ($statsData as $stats) {
         echo $stats;
     }
     echo '
         </div>
         <script type="text/javascript">
             $(function() {
                 $(".stat").easyPieChart({
                     animate     : false,
                     scaleColor  : false,
                     barColor    : "#99CEF0",
                     lineWidth   : 6,
                     size        : 150
                 });
             });
         </script>';
     $this->displayFooter($memberId);
 }
コード例 #3
0
ファイル: members.php プロジェクト: lmcro/fcms
 /**
  * displayMembers 
  * 
  * @return void
  */
 function displayMembers()
 {
     $this->displayHeader();
     $order = isset($_GET['order']) ? $_GET['order'] : 'alphabetical';
     $tzOffset = getTimezone($this->fcmsUser->id);
     $validOrderTypes = array('alphabetical' => 'ORDER BY u.`fname`', 'age' => 'ORDER BY u.`dob_year`, u.`dob_month`, u.`dob_day`', 'participation' => '', 'activity' => 'ORDER BY u.`activity` DESC', 'joined' => 'ORDER BY u.`joindate` DESC');
     if (!array_key_exists($order, $validOrderTypes)) {
         echo '
     <div class="error-alert">' . T_('Invalid Order.') . '</div>';
         $this->displayFooter();
         return;
     }
     $sql = "SELECT u.`id`, u.`activity`, u.`joindate`, u.`fname`, u.`lname`, u.`sex`, \n                    u.`dob_year`, u.`dob_month`, u.`dob_day`, u.`username`, u.`avatar`, u.`gravatar`\n                FROM `fcms_users` AS u\n                WHERE u.`phpass` != 'NONMEMBER'\n                AND u.`phpass` != 'PRIVATE'\n                OR (\n                    u.`phpass` IS NULL\n                    AND u.`password` != 'NONMEMBER'\n                    AND u.`password` != 'PRIVATE'\n                )\n                " . $validOrderTypes[$order];
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     foreach ($rows as $row) {
         $row['points'] = getUserParticipationPoints($row['id']);
         $memberData[] = $row;
     }
     // Sort by participation
     if ($order == 'participation') {
         foreach ($memberData as $k => $v) {
             $b[$k] = strtolower($v['points']);
         }
         asort($b);
         foreach ($b as $key => $val) {
             $c[] = $memberData[$key];
         }
         $memberData = array_reverse($c);
     }
     // Get Additional header columns
     $header = '';
     $colspan = 4;
     if ($order == 'age') {
         $header = '<td>' . T_('Age') . '</td><td>' . T_('Birthday') . '</td>';
         $colspan++;
     } elseif ($order == 'participation') {
         $header = '<td>' . T_('Participation Points') . '</td>';
     } elseif ($order == 'activity') {
         $header = '<td>' . T_('Last Seen') . '</td>';
     } elseif ($order == 'joined') {
         $header = '<td>' . T_('Joined') . '</td>';
     }
     echo '
     <table cellspacing="0" cellpadding="0">
         <thead>
             <th colspan="' . $colspan . '"></th>
         </thead>
         <tbody>
             <tr class="header">
                 <td></td>
                 <td>' . T_('Name') . '</td>
                 <td>' . T_('Username') . '</td>
                 ' . $header . '
             </tr>';
     foreach ($memberData as $row) {
         $display = '';
         // Age
         if ($order == 'age') {
             $age = getAge($row['dob_year'], $row['dob_month'], $row['dob_day']);
             // Don't show users with an unknown age
             if ($age === '...') {
                 continue;
             }
             $display = '<td>' . sprintf(T_('%s years old'), $age) . '</td>';
             $display .= '<td>' . $row['dob_year'] . '-' . $row['dob_month'] . '-' . $row['dob_day'] . '</td>';
         } elseif ($order == 'participation') {
             $display = '<td>' . $row['points'] . '</td>';
         } elseif ($order == 'activity') {
             $display = '<td></td>';
             if ($row['activity'] != '0000-00-00 00:00:00') {
                 $display = '<td>' . fixDate(T_('M. j, Y (g:i a)'), $tzOffset, $row['activity']) . '</td>';
             }
         } elseif ($order == 'joined') {
             $display = '<td>' . fixDate(T_('M. j, Y'), $tzOffset, $row['joindate']) . '</td>';
         }
         // Display members
         echo '
             <tr>
                 <td>
                     <a class="avatar" href="profile.php?member=' . (int) $row['id'] . '">
                         <img alt="avatar" src="' . getCurrentAvatar($row['id']) . '"/>
                     </a>
                 </td>
                 <td>
                     <a class="avatar" href="profile.php?member=' . (int) $row['id'] . '">
                         ' . cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']) . '
                     </a>
                 </td>
                 <td>' . cleanOutput($row['username']) . '</td>
                 ' . $display . '
             </tr>';
     }
     echo '
         </tbody>
     </table>';
     $this->displayFooter();
 }