Jump to content
  • 0

how to run this script?


Question

Posted

<?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());

 }
?>

8 answers to this question

Recommended Posts

Posted

It deletes accounts, yup.

$num = 0;
$result = mysql_query("SELECT * FROM `login` WHERE lastlogin < '$date 00:00:00' ")
or die(mysql_error());

If an account's ID last login date was below that date that is specified, the script will automatically delete those accounts since they are "outdated". So, the script will delete all the char's, items, variables, etc. that's attached to that account.

Are you asking to make an NPC script out of this? You could always just use it on your website.. much easier than making a NPC script out of this since the coding is already intended to be used VIA your website.

Posted

It should. The code should be saved in a .php format. After so, upload it to your main site so that directory should be <yourdomain>/<filename>.php. Once it's loaded by the site, you should get this header written on your screen:

<h2>This script will now clean up your database!</h><br><br>

Make sure you configure the configurations first. Also, if you wanna make a back-up of files just incase.. I recommend you do so.

Posted

//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..

MySQLServer = Your SQL Server's IP. Not your server's IP.

Join the conversation

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

Guest
Answer this question...

×   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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...