Page 1 of 1

Admin page message spy update

PostPosted: 08 May 2010, 17:20
by klawrence
Hi i wanted a way to find all messages sent via arowchat so i have created this as a work around.

Find:
Code: Select all
         <div class="title_bg"> 
            <div class="title">Recent Chat</div>
            <div class="module_content">
         <?
            $sql = "SELECT * FROM arrowchat ORDER BY id DESC LIMIT 10";
            $result = mysql_query($sql);
            if ($result && mysql_num_rows($result) > 0) {
?>
               <table cellspacing="0" cellpadding="0">
                  <tr style="height: 25px;">
                     <td style="width: 125px;" class="row2">From</td>
                     <td style="width: 125px;" class="row2">To</td>
                     <td style="width: 450px;" class="row2">Message</td>
                  </tr>
<?
               while ($row = mysql_fetch_array($result)) {
                  $sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row[from]."'";
                  $result2 = mysql_query($sql);
                  $from_username = mysql_fetch_row($result2);
                  
                  $sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row[to]."'";
                  $result2 = mysql_query($sql);
                  $to_username = mysql_fetch_row($result2);
         ?>
                  <tr style="height: 25px;">
                     <td class="row1"><a href="users.php?do=logs&id=<?=$from_username[1]?>"><?=$from_username[0]?></a></td>
                     <td class="row1"><a href="users.php?do=logs&id=<?=$to_username[1]?>"><?=$to_username[0]?></a></td>
                     <td class="row1"><?=$row['message']?></td>
                  </tr>
         <?
               }
         ?>
               </table>
         <?
            } else {
         ?>
               No one has ever chatted!
         <?
            }
         ?>
            </div>
         </div>

Replace with:
Code: Select all
      <div class="title_bg"> 
            <div class="title">Recent Chat</div>
            <div class="module_content">
               
               
               
         <?
           
                $query   = "SELECT COUNT(id) AS numrows FROM arrowchat";
                $result  = mysql_query($query) or die('Error, query failed');
                $row     = mysql_fetch_array($result, MYSQL_ASSOC);
                $numrows = $row['numrows'];
                $pagenum = 1;
                if(isset($_GET['page']))
                {
                    $pagenum = $_GET['page'];
                }
                $self = $_SERVER['PHP_SELF'];
                $nav  = 'Page ';
                $maxpage = 10;
                $total_pages = ceil($numrows / $maxpage);
                for ($i=1; $i<=$total_pages; $i++) {
                    if ($i == $pagenum)
                    {
                        $nav .= " $i "; // no need to create a link to current page
                    }
                    else
                    {
                        $nav .= " <a href=\"$self?page=$i\">".floor($i)."</a> ";
                    }     
                };
                echo $nav;
                $offset = ($pagenum - 1) * $maxpage;
                $sql = " SELECT * FROM arrowchat LIMIT $offset, $maxpage";
            $result = mysql_query($sql);
            if ($result && mysql_num_rows($result) > 0) {
?>
               <table cellspacing="0" cellpadding="0">
                  <tr style="height: 25px;">
                     <td style="width: 125px;" class="row2">From</td>
                     <td style="width: 125px;" class="row2">To</td>
                     <td style="width: 450px;" class="row2">Message</td>
                            <td style="width: 50px;" class="row2">Read</td>
                            <td style="width: 125px;" class="row2">Sent</td>
                  </tr>
<?
               while ($row = mysql_fetch_array($result)) {
                  $sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row[from]."'";
                  $result2 = mysql_query($sql);
                  $from_username = mysql_fetch_row($result2);
                  
                  $sql = "SELECT ".DB_USERTABLE_NAME.",".DB_USERTABLE_USERID." FROM ".TABLE_PREFIX.DB_USERTABLE." WHERE ".DB_USERTABLE_USERID."='".$row[to]."'";
                  $result2 = mysql_query($sql);
                  $to_username = mysql_fetch_row($result2);
         ?>
                  <tr style="height: 25px;">
                     <td class="row1"><a href="users.php?do=logs&id=<?=$from_username[1]?>"><?=$from_username[0]?></a></td>
                     <td class="row1"><a href="users.php?do=logs&id=<?=$to_username[1]?>"><?=$to_username[0]?></a></td>
                     <td class="row1"><?=$row['message']?></td>
                            <?
                            if($row['read'] == 1)
                            {
                                 echo '<td style="background: #0f0" class="row1">Yes</td>';
                            }else{
                                 echo '<td style="background: #f00" class="row1">No</td>';
                            }
                            ?>
                            <td class="row1"><?=date("F j, Y",$row['sent']);?><br><?=date("g:i a",$row['sent']);?></td>
                  </tr>
         <?
               }
         ?>
               </table>
         <?
            } else {
         ?>
               No one has ever chatted!
         <?
            }
         ?>
            </div>
         </div>


feel free to use this however you wish please note i rtemoved my usernames from the image

Edit:
Fixed small issue with read section showing as yes when it should be no

Re: Admin page message spy update

PostPosted: 08 May 2010, 18:25
by Jason
Very cool mod!

Re: Admin page message spy update

PostPosted: 10 May 2010, 03:16
by klawrence
edited first post as the read section had a additional `=` in the if statement

Topic Closed

PostPosted: 07 Nov 2012, 12:40
by Staff Bot
This thread has been locked because the last post is greater than six months old. There is a good chance that the information in this thread is outdated. Please open a new topic if you wish to discuss this further.