[Xfce4-commits] <forum:master> Add plugin to remove inactive users.
Nick Schermer
noreply at xfce.org
Fri Nov 12 18:12:09 CET 2010
Updating branch refs/heads/master
to 614f6e33c14550d3ed2f028e1054d946f287da9c (commit)
from c32ce15fd21b6b6884b89b6438892c9c9985a6f1 (commit)
commit 614f6e33c14550d3ed2f028e1054d946f287da9c
Author: Nick Schermer <nick at xfce.org>
Date: Fri Nov 12 17:22:30 2010 +0100
Add plugin to remove inactive users.
Tool to remove users who made no posts and have not logged in
1 month after registration or no login for the last 6 months.
...AMP_Profile_spam.php => AMP_Inactive_users.php} | 51 ++++++++-----------
1 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/plugins/AMP_Profile_spam.php b/plugins/AMP_Inactive_users.php
similarity index 55%
copy from plugins/AMP_Profile_spam.php
copy to plugins/AMP_Inactive_users.php
index 5bdcc10..1dcce64 100644
--- a/plugins/AMP_Profile_spam.php
+++ b/plugins/AMP_Inactive_users.php
@@ -4,9 +4,8 @@
if (!defined('PUN'))
exit;
-$max_age = 60*60*24*30*3;
-$min_age = 60*60*24;
-$max_active = 60*60*24*30;
+$no_visit_age = 60*60*24*30;
+$no_login_age = $no_visit_age * 6;
$limit = 100;
// Tell admin_loader.php that this is indeed a plugin and that it is loaded
@@ -42,7 +41,7 @@ if (isset($_POST['delete-users']) && is_array($_POST['delete-users']))
$db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$user) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());
// Delete the user
- $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$user) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
+ $db->query('DELETE FROM '.$db->prefix.'users WHERE num_posts=0 AND id='.$user) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
if ($db->affected_rows() > 0)
{
$deleted++;
@@ -55,7 +54,7 @@ if (isset($_POST['delete-users']) && is_array($_POST['delete-users']))
?>
<div class="plugin blockform">
- <h2><span>Profile spam detector</span></h2>
+ <h2><span>Inactive profile detector</span></h2>
<?php
if ($deleted > 0)
{
@@ -64,21 +63,16 @@ if (isset($_POST['delete-users']) && is_array($_POST['delete-users']))
?>
<div class="box">
<div class="inbox">
- <p>Search for users without any posts but URLs in their signature or profiles.</p>
- <p>Current settings:</p>
+ <p>Search for users with no posts and the following setting:</p>
<div class="inform">
<table class="aligntop" style="width:300px;">
<tr>
- <td>Registered before:</td>
- <td><?php echo gmdate('M d Y H:i:s', time() - $min_age); ?></td>
+ <td>Never made a visit in<br />and regsitered before:</td>
+ <td><?php echo gmdate('M d Y H:i:s', time() - $no_visit_age); ?></td>
</tr>
<tr>
- <td>Registered after:</td>
- <td><?php echo gmdate('M d Y H:i:s', time() - $max_age); ?></td>
- </tr>
- <tr>
- <td>Active for less than:</td>
- <td><?php echo round(($max_active / (60 * 60 * 24))); ?> d</td>
+ <td>Never visited since:</td>
+ <td><?php echo gmdate('M d Y H:i:s', time() - $no_login_age); ?></td>
</tr>
<tr>
<td>Limited to:</td>
@@ -89,31 +83,30 @@ if (isset($_POST['delete-users']) && is_array($_POST['delete-users']))
</div>
</div>
- <h2 class="block2"><span>Possible spammers:</span></h2>
+ <h2 class="block2"><span>Inactive users:</span></h2>
<div class="box">
<div class="inbox"><p><?php
- $user_result = $db->query('SELECT id, username, signature, url FROM '.$db->prefix.'users WHERE group_id=4 AND (last_visit - registered) < '.$max_active.' AND registered > (UNIX_TIMESTAMP() - '.$max_age.') AND registered < (UNIX_TIMESTAMP() - '.$min_age.') AND num_posts = 0 AND (signature <> "" OR url <> "") ORDER BY registered DESC LIMIT '.$limit) or error('All clear', __FILE__, __LINE__, $db->error());
+ $user_result = $db->query('SELECT id, username, email, url FROM '.$db->prefix.'users WHERE group_id=4 AND num_posts = 0 AND (
+ (last_visit = 0 AND registered < (UNIX_TIMESTAMP() - '.$no_visit_age.'))
+ OR
+ (last_visit < (UNIX_TIMESTAMP() - '.$no_login_age.'))) ORDER BY registered DESC LIMIT '.$limit) or error('All clear', __FILE__, __LINE__, $db->error());
if ($db->num_rows($user_result))
{
echo '<form method="post" action="'.pun_htmlspecialchars($_SERVER['REQUEST_URI']).'">
<input type="submit" name="submit" value="Delete Users" />
- <table><tr><th>username</th><th>Delete</th><th>Profile content</th></tr>';
+ <table><tr><th>username</th><th>Delete</th><th>E-mail</th><th>Website</th></tr>';
+
while ($cur_user = $db->fetch_assoc($user_result))
{
- foreach (array('http://', 'https://', 'ftp://', 'www.', '.com', '.org', '.net', '.info', '.co.uk', 'href=', '[url') as $pattern)
- {
- if (!empty($cur_user['url']) || stripos($cur_user['signature'], $pattern) !== false)
- {
- echo '<tr>
- <td style="width:150px;"><a href="profile.php?id='.$cur_user['id'].'">'.pun_htmlspecialchars($cur_user['username']).'</a></td>
- <td style="width:50px;"><input type="checkbox" name="delete-users[]" value="'.$cur_user['id'].'" /></td>
- <td> '.pun_htmlspecialchars(wordwrap(stripslashes($cur_user['signature'].$cur_user['url']), 30, ' ', true)).' </td>
+ echo '<tr>
+ <td style="width:150px;"><a href="profile.php?id='.$cur_user['id'].'">'.pun_htmlspecialchars($cur_user['username']).'</a></td>
+ <td style="width:50px;"><input type="checkbox" name="delete-users[]" value="'.$cur_user['id'].'" checked /></td>
+ <td>'.pun_htmlspecialchars(stripslashes($cur_user['email'])).'</td>
+ <td>'.pun_htmlspecialchars(stripslashes($cur_user['url'])).'</td>
</tr>';
- continue 2;
- }
- }
}
+
echo '</table>
<input type="hidden" name="deleted" value="'.$deleted.'" />
<input type="submit" name="submit" value="Delete Users" />
More information about the Xfce4-commits
mailing list