Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Clean up script for uddeIM 0.5b+

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
17 years 11 months ago #29546 by slabbi
Clean up script for uddeIM 0.5b+ was created by slabbi
This is a clean up script for uddeIM 0.5+.

When you delete a user in Jommla the corresponding messages are still stored in the uddeIM tables. This script deletes uddeIM table entires which are not longer required.

Run this script before you delete a user in Joomla. After executing the script you can remove the user in Joomla.

Messages
- to the deleted user which have not been deleted by the sender, and
- from the deleted user which have not been deleted by the receiver
are kept of course.

[code:1]
delete_user.php

<?php

$hostname = "localhost";
$database = "xxxx";
$username = "xxxx";
$password = "xxxx";
$link = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
session_start();
mysql_select_db($database, $link);
$query = "SELECT * FROM jos_users ORDER BY username ASC";
$result = mysql_query($query, $link) or die(mysql_error());
$users = mysql_fetch_assoc($result);
?>

<html>
<head>
<title>Delete user messages</title>
</head>
<body>
<h2>Delete user messages:</h2>
<form action="<?php echo $_SERVER;?>" method="post" enctype="multipart/form-data">
<p>Username: <select name="user" size=1>
<?php
while ($row = mysql_fetch_assoc($result)) {
echo "<option value=".$row["username"].">".$row["username"]."</option>";
}
mysql_free_result($result);
?>
</select><br/>
<input type="submit" name="delete" value="delete" /><br/>
</p>
</form>
<?php

if (!isset($_POST["delete"])) {
exit;
}

$user=$_POST;
$query = "SELECT * FROM jos_users WHERE username = '".$user."'";
$result = mysql_query($query, $link) or die(mysql_error());
$id = mysql_fetch_assoc($result);
$userid = $id["id"];
mysql_free_result($result);

$query = "UPDATE `jos_comprofiler` SET `avatar` = '".$filename."' WHERE `user_id` = ".$userid;

$query = 'DELETE FROM `jos_uddeim` WHERE '
. ' (`fromid` ='.$userid.' AND `totrashoutbox` =1)'
. ' OR'
. ' (`toid` ='.$userid.' AND `totrash` =1)'
. ' ';

echo $query."<br />";
$result = mysql_query($query, $link) or die(mysql_error());

$deletetime=time();
$query = "UPDATE `jos_uddeim` SET totrashoutbox=1, totrashdateoutbox=".$deletetime." WHERE toid=".$userid;
echo $query."<br />";
$result = mysql_query($query, $link) or die(mysql_error());
$query = "UPDATE `jos_uddeim` SET totrash=1, totrashdate=".$deletetime." WHERE fromid=".$userid;
echo $query."<br />";
$result = mysql_query($query, $link) or die(mysql_error());

echo "<br/>User messages from ".$user." have been deleted.";
?>
</body>
</html>
[/code:1]

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

  • mediaguru
  • mediaguru
  • OFFLINE
  • Posts: 365
  • Thanks: 1
  • Karma: 70
17 years 11 months ago #29550 by mediaguru
Replied by mediaguru on topic Re:Clean up script for uddeIM 0.5b+
Hey this is great. But can it be done AFTER the person is banned or deleted? I have that issue.

CB/Joomla golf site: www.thegolfspace.com
Geek/joomla site: www.tkserver.com

Check out my Joomla/CB projects:

* LIKE thumbs up system for "liking" content items
* Karma - CB user rating system
* Golf Score Tracker
* Jitter - status update system. "What's on your mind?"
* CB Author Plug - Shows CB author link and avatar in content items. J1.5 compatible and very customizable!

Found on my web site or in the Joomlapolis Directory !

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
17 years 11 months ago #29571 by slabbi
Replied by slabbi on topic Re:Clean up script for uddeIM 0.5b+
Sure,

replace the form with (not tested yet, its a quick modification of the previous script):

[code:1]
<form action="<?php echo $_SERVER;?>" method="post" enctype="multipart/form-data">
<p>UserID:
<input class="inputbox" name="userid" value="" type="text">
<br/>
<input type="submit" name="delete" value="delete" /><br/>
</p>
</form>[/code:1]

and replace

[code:1]
$user=$_POST;
$query = "SELECT * FROM jos_users WHERE username = '".$user."'";
$result = mysql_query($query, $link) or die(mysql_error());
$id = mysql_fetch_assoc($result);
$userid = $id["id"];
mysql_free_result($result);
[/code:1]

with

[code:1]
$userid=$_POST;
$user=$userid$
[/code:1]

So you can enter the userid even when the name is not longer in Joomla's userdatabase.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

  • Andrej
  • Andrej
  • OFFLINE
  • Posts: 20
  • Thanks: 0
  • Karma: 3
17 years 8 months ago #35313 by Andrej
Replied by Andrej on topic Re:Clean up script for uddeIM 0.5b+
Where do you put this script to work?

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
17 years 8 months ago #35367 by slabbi
Replied by slabbi on topic Re:Clean up script for uddeIM 0.5b+
Upload the script to a password protected folder and then execute it from your web browser. Thats all.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

17 years 8 months ago #35711 by Smokey4life
Replied by Smokey4life on topic Re:Clean up script for uddeIM 0.5b+
Allmost what i was looking for, however i seem to have the problem i deleted a user and that user sent me messages so it says i have new messages yet there is no new messages in my inbox im guessing he recalled them before i deleted him? now i cant get the NEW MESSAGE to go away without actually changing it in the mySQL tables.. Is there anyway i can fix this?

Please Log in or Create an account to join the conversation.

Moderators: beatnantslabbikrileon
Powered by Kunena Forum