Jump to content
  • 0

how to run this script?


Mr BrycE

Question


  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  


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

 }
?>

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

It's intended to be a PHP script and not an NPC.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  

is there any script or SQL query aside from this?

it deletes old accounts..hmm

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  

oh so , ill uplaod it to my website and then the script will automatically run? then tadah? done deleting old accounts?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  

hmm..i got this error...

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'xxxxxxxx' (4) in /home/briceron/public_html/old.php on line 16

Can't connect to MySQL server on 'xxxxxxxxx' (4)

MySqlserver IP address is my host adress right?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  

but i ask what is my SQL IP from my host but, they said it is the same as the server...

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

×
×
  • Create New...