<?php
//Original Script created by Wouter2004
//Simple edits by martin (http://martint.net)
//Change these variables!
$mysqlserver = "----"; //IP of the mySQL server
$db = "ragnarok"; //ragnarok database
$user = "---"; //mySQL user
$pass = "---"; //mySQL user password
$date = "2012-06-30"; //Delete all account of users that hasnt logged in since..
//-----------------------
//dont edit these things unless you know what your doing
//-----------------------
mysql_connect($mysqlserver,$user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$num = 0;
$result = mysql_query("SELECT * FROM `login` WHERE lastlogin < '$date 00:00:00' ")
or die(mysql_error());
echo("<h2>This script will now clean up your database!</h><br><br>");
while ($row = mysql_fetch_array($result)){
//then fetch all the login accounts in an array
$result2 = mysql_query("SELECT * FROM `char` WHERE account_id = ".$row[account_id]." ")
or die(mysql_error());
$num++;
echo("<br>".$num."- Account: ".$row[account_id]."- Name: ".$row[userid]."");
while ($row2 = mysql_fetch_array($result2)){
//then fetch all the char id's in an array
mysql_query("DELETE FROM `global_reg_value` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `inventory` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `skill` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `cart_inventory` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `pet` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `friends` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `char` WHERE char_id = ".$row2[char_id]." ")
or die(mysql_error());
}
mysql_query("DELETE FROM `storage` WHERE account_id = ".$row[account_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `global_reg_value` WHERE account_id = ".$row[account_id]." ")
or die(mysql_error());
mysql_query("DELETE FROM `login` WHERE account_id = ".$row[account_id]." ")
or die(mysql_error());
}
?>
Question
Mr BrycE
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.