26 (edited by Smartys 2006-07-19 23:47)

Re: Private Message Mod, monitoring messages

I believe the indexing error is due to having run the indexing at some point in the past (so the thing is properly indexed) and then trying again. I guess I'll edit the code there to put in some sort of check

Edit: I added in a check, hopefully it works (and didn't create a giant parse error, I haven't tested my changes, I'm a bad boy tongue)

27

Re: Private Message Mod, monitoring messages

Trillian basic, which is free, works real good with ICQ.

28

Re: Private Message Mod, monitoring messages

hcgtv wrote:

Trillian basic, which is free, works real good with ICQ.

Yes it does, but my friends and I all pitched in and registered Trillian so our GTalk would work through it.  Trillian is just awesome.

Re: Private Message Mod, monitoring messages

And Kato's issue is fixed, it had something to do with parser.php interfering with the queries (I assume it was modded in some way)

30

Re: Private Message Mod, monitoring messages

Thanks Smarty.

Re: Private Message Mod, monitoring messages

Hello. You could envisage a possibility of exporting the logs of PM? Thx

32

Re: Private Message Mod, monitoring messages

Cool plugin, Smartys.

The idea came to mind (while reading the thread) of just having a feature to report the PM to the admin of the board. Instead of having to monitor the messages which could bother some users (regardless of the fact that you can read anything from phpMyAdmin) anyhow, just a thought.

33 (edited by Smartys 2006-07-20 20:13)

Re: Private Message Mod, monitoring messages

Dalizzer wrote:

Hello. You could envisage a possibility of exporting the logs of PM? Thx

I'm not quite sure what you want smile

helter wrote:

Cool plugin, Smartys.

The idea came to mind (while reading the thread) of just having a feature to report the PM to the admin of the board. Instead of having to monitor the messages which could bother some users (regardless of the fact that you can read anything from phpMyAdmin) anyhow, just a thought.

But then how would the admin view the message that was reported?

34

Re: Private Message Mod, monitoring messages

Smartys wrote:
Dalizzer wrote:

Hello. You could envisage a possibility of exporting the logs of PM? Thx

I'm not quite sure what you want smile

helter wrote:

Cool plugin, Smartys.

The idea came to mind (while reading the thread) of just having a feature to report the PM to the admin of the board. Instead of having to monitor the messages which could bother some users (regardless of the fact that you can read anything from phpMyAdmin) anyhow, just a thought.

But then how would the admin view the message that was reported?

You could include the message that the user is reporting in the report itself. For instance, you could have a report form where you can enter your complaint and things of that nature but on the admins side you would see the complaint and the reported message in a quote (similar to the bbcode quote)

user complaint:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque rhoncus. Quisque dapibus. Vestibulum eleifend magna nec libero. Vestibulum auctor feugiat neque. In sapien magna, tincidunt mollis, luctus quis, scelerisque quis, eros. Vivamus pellentesque, neque quis congue sodales, velit ante porta dolor, at vestibulum neque mi in dolor. Nam mi lectus, euismod et, scelerisque in, ultrices non, felis. Pellentesque lectus. Quisque at purus. Sed eu ipsum eu nisl condimentum varius. Nullam ac elit id velit ultricies placerat. Aenean et mauris. Donec vel turpis. In ullamcorper, nulla sit amet tincidunt elementum, mauris mauris tempus enim, ut tincidunt eros eros non augue. Nulla tincidunt. Maecenas vel felis. Morbi interdum ligula in augue. Curabitur mi nisi, porta at, volutpat ac, tempus sed, ipsum.

reported user wrote:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras nonummy, tellus eget tincidunt cursus, odio justo dignissim diam, ac cursus arcu massa eget quam. In fermentum. Morbi nibh. Ut vestibulum aliquet quam. Sed auctor lorem non quam. Morbi dignissim. Suspendisse potenti. Aenean interdum augue non lorem. Vestibulum mollis lorem id neque. Fusce odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras orci dolor, placerat sit amet, tincidunt ut, laoreet at, nisi. Maecenas viverra, purus id venenatis dapibus, elit augue iaculis pede, auctor dictum sapien turpis ac elit. Vivamus vitae augue.

Re: Private Message Mod, monitoring messages

Smartys wrote:
Dalizzer wrote:

Hello. You could envisage a possibility of exporting the logs of PM? Thx

I'm not quite sure what you want smile

Hi.
In fact a plugin for  viewing member's pms that have been sent on the board. I have created this specific topic.
For information and if it can help, the code for the same plugin for Invision Power Board is here

Re: Private Message Mod, monitoring messages

Dalizzer wrote:

In fact a plugin for  viewing member's pms that have been sent on the board.

Viewing? Smartys posted a plugin (here) to do just that!

Dalizzer wrote:

You could envisage a possibility of exporting the logs of PM?

What log? PMs are just stored in the database.

Are you saying that you view PMs even after they've been deleted? I think it would be hard to read something that doesn't exist anymore.

(The problem here is either defining the problem or using the right language to describe the problem?)

Re: Private Message Mod, monitoring messages

Smartys/Mark, is the plugin including messages from the "Sent" box as well?

38 (edited by Smartys 2006-07-25 20:05)

Re: Private Message Mod, monitoring messages

The PM mod only ever stores one copy of a message

39 (edited by guardian34 2006-07-25 22:43)

Re: Private Message Mod, monitoring messages

Admin sends message to another user and saves a copy:

10  3   Test subject     I'm saving a copy of this message.  admin_user  2   1153866671  127.0.0.1   1   0   0
11  2   Test subject     I'm saving a copy of this message.  test_user   3   1153866671  127.0.0.1   1   1   1

Edit: The first message is in test_user's "Inbox" and the second message is in the admin's "Sent" box.

Re: Private Message Mod, monitoring messages

What are the column names in that output?

Re: Private Message Mod, monitoring messages

Labeled:

id   owner  subject        message                              sender      sender_id   posted       sender_ip   smileys   status   showed
==   ====   =======        =======                              ======      =========   ======       =========   =======   ======   ======
10   3      Test subject   I'm saving a copy of this message.   admin_user  2           1153866671   127.0.0.1   1         0        0
11   2      Test subject   I'm saving a copy of this message.   test_user   3           1153866671   127.0.0.1   1         1        1

Status is 1 for saved messages.

Re: Private Message Mod, monitoring messages

It would search the Sent box I guess

Re: Private Message Mod, monitoring messages

Another thought? the "Go back" link made by message() is just javascript; If you delete messages and follow that link, those messages are still sitting there, selected.

Re: Private Message Mod, monitoring messages

Not much I can do about that (I can't redirect back to the search results, I don't want to redirect back to the search form)

Re: Private Message Mod, monitoring messages

Sorry, I didn't really think that through. smile

46 (edited by MrMister 2006-08-17 22:02)

Re: Private Message Mod, monitoring messages

As stated above, the problem lies with the way Private Messages get stored on the DB.
If you send a message to someone with the option "save message" selected, the PM will be saved twice, once for the destination user with the owner = DESTINATION_USER_ID and another time with the owner = YOUR_USER_ID, so that you may have a copy on your sent box.

Naturally since you are using

INNER JOIN '.$db->prefix.'users AS u ON (u.id = m.owner)

as part of the search query you will get 2 results instead of one.

Any ideas on how to do a query (it could be resource heavy, that wouldn't be an issue since theoretically only you will run it) that would check if the message is a duplicate and not show it?

Re: Private Message Mod, monitoring messages

I always knew there was a reason I thought Connor should make it use multiple tables tongue
Would it be OK to have it only search the inbox you think?

48 (edited by guardian34 2006-08-17 22:45)

Re: Private Message Mod, monitoring messages

Smartys, I edited yours as a learning experience; I added radio buttons for Inbox/Sent. smile

Edit: Of course, I also changed the query. tongue I gave Inbox a value of 0 and Sent a value of 1, and then used that value in the query.

Also, with the box column and one table, you could add support for multiple boxes, and the ability to move message between them.

Re: Private Message Mod, monitoring messages

guardian34 wrote:

Also, with the box column and one table, you could add support for multiple boxes, and the ability to move message between them.

That doesn't work given how Connor uses the boxes. But IMO, having different inbox/outbox tables makes more sense if you're going to store two copies of the message.

50 (edited by IDunno 2007-01-20 04:32)

Re: Private Message Mod, monitoring messages

Smartys wrote:

The code for the plugin is

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Neal Poole (smartys@gmail.com)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
    exit;

// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('PUN_PLUGIN_LOADED', 1);

// We're adding an index
if (isset($_POST['index']))
{
    // Turn off PHP time limit
    @set_time_limit(0);
    
    // Lets go through the list of indexes and see if we already did this
    $result = $db->query('SHOW INDEX FROM '.$db->prefix.'messages') or error('Unable to check for index', __FILE__, __LINE__, $db->error());
    while ($cur_index = $db->fetch_assoc($result))
    {
        if ($cur_index['Key_name'] == 'pm_message_idx')
            message('It looks like you have already created the correct index');
    }
    
    // Add the index
    $db->query('ALTER TABLE '.$db->prefix.'messages ADD FULLTEXT INDEX pm_message_idx (message)') or error('Unable to add index', __FILE__, __LINE__, $db->error());
    
    message('The index was successfully added.');
}

// If we're deleting messages
else if (isset($_POST['delete']))
{
    confirm_referrer('admin_loader.php');
    
    if (!isset($_POST['del_message']) || empty($_POST['del_message']))
        message('You must select at least one message to delete!');
        
    $messages = array_values(array_map("intval", $_POST['del_message']));
    $messages = implode(',', $messages);

    $db->query('DELETE FROM '.$db->prefix.'messages WHERE id IN ('.$messages.')') or error('Unable to delete messages', __FILE__, __LINE__, $db->error());
    
    message('Messages deleted');
}

// If we're trying to view a message
else if (isset($_GET['view_id']))
{
    require PUN_ROOT.'include/parser.php';

    $id = intval($_GET['view_id']);
    
    $result = $db->query('SELECT m.*, u.username AS owner_name FROM '.$db->prefix.'messages AS m INNER JOIN '.$db->prefix.'users AS u ON (u.id = m.owner) WHERE m.id = '.$id) or error('Unable to fetch message', __FILE__, __LINE__, $db->error());
    
    if ($db->num_rows($result) < 1)
        message($lang_common['Bad request']);
    
    // Display the admin navigation menu
    generate_admin_menu($plugin);
    
    $message = $db->fetch_assoc($result);
    $message['smileys'] = isset($message['smileys']) ? $message['smileys'] : $pun_user['show_smilies'];
    $message['message'] = parse_message($message['message'], (int)(!$message['smileys']));
    
?>

    <div id="p<?php echo $message['id'] ?>" class="blockpost row_odd firstpost blockform">
        <h2><span>View Message</span></h2>
        <div class="box">
            <div class="inbox">
                <div class="postleft">
                    <dl>
                        <dt><small>On <?php echo format_time($message['posted']) ?>, <strong><a href="profile.php?id=<?php echo $message['sender_id'] ?>"><?php echo pun_htmlspecialchars($message['sender']) ?></a></strong> sent the following message to <strong><a href="profile.php?id=<?php echo $message['owner'] ?>"><?php echo pun_htmlspecialchars($message['owner_name']) ?></a></strong></small></dt>
                    </dl>
                </div>
                <div class="postright">
                    <div class="postmsg">
                        <?php echo $message['message']."\n" ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
<?php

}

// If the "Search" button was clicked
else if (isset($_POST['search']))
{
    $sender = intval($_POST['sender']);
    $recipient = intval($_POST['recipient']);
    
    if ($sender < 1 || $recipient < 1)
        message($lang_common['Bad request']);
    
    $keywords = trim($db->escape($_POST['keywords']));
    
    // Form the correct where statement
    $where_sql = array();
    if (strlen($keywords) > 0)
        $where_sql[] = 'match(message) against ("'.$keywords.'" IN BOOLEAN MODE)';
    if ($sender > 1)
        $where_sql[] = 'sender_id = '.$sender;
    if ($recipient > 1)
        $where_sql[] = 'owner =  '.$recipient;
    
    if (empty($where_sql))
        message('You must enter at least one keyword and/or a sender and/or a recipient if you wish to search');
    
    // Format the SQL properly
    $where_sql = implode(' and ', $where_sql);
    
    $result = $db->query('SELECT m.*, u.username AS owner_name FROM '.$db->prefix.'messages AS m INNER JOIN '.$db->prefix.'users AS u ON (u.id = m.owner) WHERE '.$where_sql.' ORDER BY posted DESC') or error('Unable to fetch messages list', __FILE__, __LINE__, $db->error());
    
    if ($db->num_rows($result) < 1)
        message('No messages matched your search criteria');
?>
    <div class="blocktable">
        <h2><span>Search Results</span></h2>
        <form id="search_results" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
        <div class="box">
            <div class="inbox">
                <table cellspacing="0">
                    <tr>
                        <th width="20"></th>
                        <th>Subject</th>
                        <th>Sender</th>
                        <th>Reciever</th>
                        <th>Date Sent</th>
                    </tr>
<?php
    while ($cur_message = $db->fetch_assoc($result))
    {
    
?>
                    <tr>
                        <td><input type="checkbox" name="del_message[]" value="<?php echo $cur_message['id'] ?>" /></td>
                        <td><a href="<?php echo $_SERVER['REQUEST_URI'] ?>&view_id=<?php echo $cur_message['id'] ?>"><?php echo pun_htmlspecialchars($cur_message['subject']) ?></a></td>
                        <td><a href="profile.php?id=<?php echo $cur_message['sender_id'] ?>"><?php echo pun_htmlspecialchars($cur_message['sender']) ?></a></td>
                        <td><a href="profile.php?id=<?php echo $cur_message['owner'] ?>"><?php echo pun_htmlspecialchars($cur_message['owner_name']) ?></a></td>
                        <td><?php echo format_time($cur_message['posted']) ?></td>
                    </tr>
<?php

    }
?>
                </table>
            </div>
        </div>
        <p><input type="submit" name="delete" value="Delete multiple messages" /></p>
        </form>
<?php
}

else    // If not, we show the form
{
    $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE id > 1 ORDER BY id ASC') or error('Unable to grab user list', __FILE__, __LINE__, $db->error());
    
    $users = array();
    while ($cur_user = $db->fetch_assoc($result))
    {
        $users[] = $cur_user;
    }
    
    // Display the admin navigation menu
    generate_admin_menu($plugin);

?>
    <div id="exampleplugin" class="blockform">
        <h2><span>Monitor Private Messages</span></h2>
        <div class="box">
            <div class="inbox">
                <p>This plugin allows you to easily and simply monitor the private messages sent by your users</p>
                
                <form id="search" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>&foo=bar">
                <div class="inform">
                    <fieldset>
                        <legend>New search</legend>
                        <div class="infldset">
                            <label class="conl">Keyword search<br /><input type="text" name="keywords" size="40" maxlength="100" /><br /></label>
                            <label class="conl">Sender search<br /><select name="sender"><option value="1">All users</option><?php foreach ($users as $key => $val) echo '<option value="'.$val['id'].'">'.pun_htmlspecialchars($val['username']).'</option>'; ?></select><br /></label>
                            <label class="conl">Recipient search<br /><select name="recipient"><option value="1">All users</option><?php foreach ($users as $key => $val) echo '<option value="'.$val['id'].'">'.pun_htmlspecialchars($val['username']).'</option>'; ?></select><br /></label>
                            <p class="clearb">To search by keyword, enter a term or terms to search for. Separate terms with spaces. To search by author or recipient, Choose the user's username from the dropdown box. You may use * as a wildcard for your keywords.</p>
                        </div>
                    </fieldset>
                </div>
                <p><input type="submit" name="search" value="Submit" accesskey="s" /></p>
                </form>
            </div>
            <form id="index" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>&foo=bar">
            <div class="inform">
                <fieldset>
                    <legend>Start Indexing</legend>
                    <div class="infldset">
                        <p class="clearb">The first time you run this script, it is recommended that you let it add an index to your messages table so that you may search much more quickly. Note that the indexing may take an extremely long time, please do not hit Stop in your browser while this is happening. Keep in mind that this need only be run <strong>once</strong>.</p>
                        <p><input type="submit" name="index" value="Start the indexing!" /></p>
                    </div>
                </fieldset>
            </div>
            </form>
        </div>
    </div>
<?php

}

// Note that the script just ends here. The footer will be included by admin_loader.php.

Kato reported an issue with viewing a private message, I did not have an issue. If anyone else tries it and has an issue and can give me access to try and debug it, that would be great (or if you just see the error tongue)

Edit: Small CSS issue has been fixed
Edit2: Added some code when indexing to ensure the index isn't run twice
Edit3: Fixed a small issue that occured in Kato's situation, which seemed to have something to do with MySQL queries in parser.php

Hi,

I'm really really interested the AP_PM-Monitoring.php plugin feature! But unfortunetly it seems the AP_PM-Monitoring.php does not seem to work on my forum??:( Any idea's??

Any help to this would be most appreciated...

Thanks