Help
Discuss or request ArrowChat modifications
User avatar
klawrence
Customer
 
Posts: 5
Joined: 03 May 2010, 03:56

 

by klawrence 08 May 2010, 17:20

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
You do not have the required permissions to view the files attached to this post.
Last edited by klawrence on 10 May 2010, 03:15, edited 1 time in total.
User avatar
Jason
Customer
 
Posts: 2356
Joined: 12 Dec 2009, 16:06

 

by Jason 08 May 2010, 18:25

Very cool mod!
User avatar
klawrence
Customer
 
Posts: 5
Joined: 03 May 2010, 03:56

 

by klawrence 10 May 2010, 03:16

edited first post as the read section had a additional `=` in the if statement
User avatar
Staff Bot
ArrowChat Team
 
Posts: 8996
Joined: 07 Nov 2012, 13:41

 

by Staff Bot 07 Nov 2012, 12:40

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.