Jump to content
Mang-Berto

auto delete account when not used within 2 months

Recommended Posts

Good day sa inyong lahat, papaano ba gawin yung ganon? yung auto delete ang mga accounts na hindi nag lolog in within 2 months? maraming salamat sa sasagot, have a peaceful and meaningful lenten season to all of us, God bless :D

Link to comment
Share on other sites

<?php
// Original Script created by : Wouter2004
// Simple edits to make it fully working by : martin (http://martint.net)
// Updated by : Kisuka
// Change these variables.
$mysqlserver = "127.0.0.1"; // IP of the mySQL server.
$db = "ragnarok"; // Your ragnarok database.
$user = "ragnarok"; // mySQL username.
$pass = "ragnarok"; // mySQL password.
$date = "2012-02-20"; // Delete all account of users that haven't logged in since (YYYY-MM-DD).
// ----------------------------------------------------------
// Dont edit anything below 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><b<b");
while ($row = mysql_fetch_array($result)){
   //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("<b".$num."- Account: ".$row[account_id]."- Name: ".$row[userid]."");

   while ($row2 = mysql_fetch_array($result2)){

    //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 `auction` WHERE seller_id = ".$row2[char_id]." ")
    or die(mysql_error());

    // Check for a homunculus.
    $result3 = mysql_query("SELECT * FROM `homunculus` WHERE char_id = ".$row2[char_id]." ")
    or die(mysql_error());
    $row3 = mysql_fetch_array($result3);
    $num_results3 = mysql_num_rows($result3);
    if ($num_results3 > 0){
	    mysql_query("DELETE FROM `homunculus` WHERE char_id = ".$row2[char_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `skill_homunculus` WHERE homun_id = ".$row3[homun_id]." ")
	    or die(mysql_error());
    }

    // Check if guild leader.
    $result4 = mysql_query("SELECT * FROM `guild` WHERE char_id = ".$row2[char_id]." ")
    or die(mysql_error());
    $row4 = mysql_fetch_array($result4);
    $num_results4 = mysql_num_rows($result4);
    if ($num_results4 > 0){
	    mysql_query("DELETE FROM `guild` WHERE char_id = ".$row2[char_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_alliance` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_castle` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_expulsion` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_member` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_position` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_skill` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
	    mysql_query("DELETE FROM `guild_storage` WHERE guild_id = ".$row4[guild_id]." ")
	    or die(mysql_error());
    }else{
	    mysql_query("DELETE FROM `guild_member` WHERE char_id = ".$row2[char_id]." ")
	    or die(mysql_error());
    }

    mysql_query("DELETE FROM `hotkey` WHERE char_id = ".$row2[char_id]." ")
    or die(mysql_error());
    mysql_query("DELETE FROM `mail` WHERE dest_id = ".$row2[char_id]." ")
    or die(mysql_error());
    mysql_query("DELETE FROM `memo` WHERE char_id = ".$row2[char_id]." ")
    or die(mysql_error());
    mysql_query("DELETE FROM `quest` WHERE char_id = ".$row2[char_id]." ")
    or die(mysql_error());
    mysql_query("DELETE FROM `quest_objective` 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());
   mysql_query("DELETE FROM `party` WHERE leader_id = ".$row[account_id]." ")
   or die(mysql_error());
   mysql_query("DELETE FROM `sc_data` WHERE account_id = ".$row[account_id]." ")
   or die(mysql_error());
}
?>

I don't own this code /no1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.