How delete in-active accounts using sql scripts

Status
Not open for further replies.
In sql it require to write short query but lets say it will be too hard for you, so search over ragezone (use google)
im sure it was released somewhere, other than that like MrQ said, search for ready solution.

I already try to search at ragezone, but most of them not works to delete.
it says error.. Can you make an SQL to delete? I need 6 Months In-Active accounts to delete them..
Thanks



error said "coud not be found."
that thing wasn't in your C:\xampp\htdocs\admincp\modules\

here try this if you don't have
paste it in your C:\xampp\htdocs\admincp\modules\



Hello your maintenance.php is same with me.
I try other maintenance.php it works but only delete empty accounts
 
Upvote 0
delete from memb_info
where memb___id in (
select memb___id from memb_stat where disconnecttm<'2007-06-01')

delete from accountcharacter
where id in (
select memb___id from memb_stat where disconnecttm<'2007-06-01')

delete from character
where accountid in (
select memb___id from memb_stat where disconnecttm<'2007-06-01')

delete from warehouse
where accountid in (
select memb___id from memb_stat where disconnecttm<'2007-06-01')


I think this will work just change the date

( http://forum.ragezone.com/f82/script-delete-30-days-account-634866/ )
 
Upvote 0
dude if you want send me backup of your database :D i will delete all inactive accounts :D
the joke away..
what's version of mu is your server ?
if you'r server files has shared for free in the internet, do you can give me the original database file?
 
Upvote 0
I change my server files now. 11.7.52
But still using the old one databases.
Please see link below.


Now i download your muserver to restore the database and review the structure
When i finish download I will make some test with scripts for delete inactive accounts
and all over all for me is interesting to see the tables and etc. on the S6 database because I understand only on old versions.
If i have success with some script i will post there.
 
Upvote 0
try this one

i use this to delete some inactive account.

copy this code and edit with your sql database details and save it as delcfg.php

Code:
<?php
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
//
//Connection settings. You MUST change this
//

$hostdb = "127.0.0.1"; 
$userdb = "sa"; 
$passdb = "[COLOR="#FF0000"]yourpass[/COLOR]"; 

$days = "0";  // Number of Days (example: "21" will delete the accounts that haven't 
               // logged ingame in the last 21 days.







//---------------------------------------------
//DON'T BE STUPID.. DO NOT CHANGE ANYTHING BELOW THIS ^^
//----------------------------------------------
$db = 'MuOnline';
$msconn=mssql_connect("$hostdb","$userdb","$passdb"); 
if(!$msconn) { echo "Could not connect to database, please check your configuration and try again"; exit; }
else { $msdb=mssql_select_db("$db",$msconn); }
?>

copy also this one, and save it as anything you want

eg:

checkaccount.php

Code:
<?php
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
include("delcfg.php"); 

if(empty($_POST)) {
$c = "COLLATE Modern_Spanish_CI_AS" ;
$query = "select distinct ac.ID, ac.GameID1, ac.GameID2, ac.GameID3, ac.GameID4, ac.GameID5, ms.DisConnectTM from accountcharacter as ac, MEMB_STAT as ms where id ".$c." in (select memb___id from memb_stat where ConnectTM  < getdate()-".$days.") and ms.memb___id  ".$c."  = ac.ID  ".$c."  order by ms.DisConnectTM DESC";
$result = mssql_query($query);
head($days);
content($result);
foot();
} 
if(!empty($_POST)) {
  while (list($k,$v) = each ($_POST)) {
    if ($k == 'dont') {
      while (list($kk,$vv) = each ($v)) {
        $cad = cleanup_text($vv);
		if(checkinput($cad) == 0) { echo "SQL INJECTION DETECTED!!!"; exit; }
		if(checkinput($cad) == 1) { $dont[] = $cad; }
	  }
	}
  }
  if(!empty($dont)) { $dont = implode("','",$dont); }
  else { $dont = ''; }
  $c = "COLLATE Modern_Spanish_CI_AS" ;
  $result = mssql_query("select ID from accountcharacter where id ".$c." in (select memb___id from memb_stat where ConnectTM  < getdate()-".$days.") and not ID  ".$c." in ('".$dont."')");
  while ($row = mssql_fetch_row($result)) { $accounts[] = $row[0]; }  
  if(!empty($accounts)) { $accounts = implode("','",$accounts);  }
  else { $accounts = ''; }
 	
  $result = mssql_query("select GameID1, GameID2, GameID3, GameID4, GameID5 from accountcharacter where id  ".$c." in('".$accounts."')");

  while ($row = mssql_fetch_row($result)) {
    while (list(,$charname) = each($row)) {
	  if (strlen($charname) > 3) {	
		$r1a = mssql_query("delete from optiondata where Name ".$c." = '$charname'");
		$r2 = mssql_query("select Count(*) as 'Check' from Guild where G_Master  ".$c." = '$charname'");
		$row1 = mssql_fetch_array($r2);
		if($row1['0'] > 0) {
		  $r3 = mssql_query("delete from GuildMember where G_Name  ".$c." in (select G_Name from Guild where G_Master  ".$c." ='$charname')");
		  $r4 = mssql_query("delete from Guild where G_Master ".$c." ='$charname'");
		}
		$r5 = mssql_query("delete from GuildMember where Name  ".$c." ='$charname'");
	 }
  }	
  $q = mssql_query("delete from accountcharacter where id  ".$c." in('".$accounts."')");
  $q = mssql_query("delete from character where AccountID  ".$c." in('".$accounts."')");	
  $q = mssql_query("delete from memb_info where memb___id  ".$c."  in('".$accounts."')");
  $q = mssql_query("delete from vi_curr_info where memb___id  ".$c." in('".$accounts."')");
  $q = mssql_query("delete from warehouse where accountid  ".$c." in('".$accounts."')");
//  $q = mssql_query("delete from allitemslog where items_acid in('".$accounts."')");
//  $q = mssql_query("delete from copylog where copy_acid in('".$accounts."')");
  $q = mssql_query("delete from memb_stat where memb___id  ".$c." in('".$accounts."')");
}
  $msdb=mssql_select_db("Ranking",$msconn); 
  $r = mssql_query("delete from event_info where AccountID  ".$c." in ('".$accounts."')");
  echo '<html>
        <head>
        <link href="ad.css" rel="stylesheet" type="text/css">
        </head>
        <body><p class="TheTitle" >ACCOUNTS DELETED!!!</p></body>
        </html>'; exit;  
}
function head($days) {
echo '<html>
<head>
<!-- --------------------------------------------------------- -->
<!--   Inactive Account Deleter by Lady_Fu for [-D|K|L-]Team   -->
<!-- DKLteam.com.ar || Guildphonos.com.ar || www.jamaikamu.com -->
<!--               One for Mu.. Mu for All..                   -->
<!--        Removing these credits makes you our ***** :D      -->
<!-- --------------------------------------------------------- -->

<link href="ad.css" rel="stylesheet" type="text/css">
<title>Inactive Accounts Cleaner · [D|K|L]Team</title>
</head>
<body>
<div align="center"> 
        <form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'">
  <table width="100%" height="100%" border="0" align="center">
    <tr>
      <td align="center" valign="top"> 
        <div align="center"> 
            <p class="TheTitle">Inactive Accounts</p>
            <p class="Text">These 
              are the accounts that remained inactive for '.$days.'+ days.<br>
              (Check the accounts you <font color="#FF0000"><strong>DO NOT WANT</strong></font> 
              to delete and click the DELETE button)</font></p>
        </div>
          <table cellpadding="5" cellspacing="0" ><tr class="title">
            <td> AccountID </td>
            <td> Char1 </td>
            <td> Char2 </td>
            <td> Char3 </td>
            <td> Char4 </td>
            <td> Char5 </td>
            <td> Last Seen </td>
              <td> Dont!! </td>
          </tr>';
}

function content($result)	{
$i = 1;
while ($row = mssql_fetch_row($result)) {
  if (!is_int($i / 2)) { $col = 'bla'; }
  else { $col = 'bla1'; }
  $i++;
  echo '
           <tr class="'.$col.'"> 
            <td>'.$row['0'].'</td>
            <td>'.$row['1'].'</td>
            <td>'.$row['2'].'</td>
            <td>'.$row['3'].'</td>
            <td>'.$row['4'].'</td>
            <td>'.$row['5'].'</td>
            <td>'.$row['6'].'</td>
            <td>
                  <input name="dont[]" type="checkbox" class="t2" id="dont[]" title="Check this if you do not want to delete this account" value="'.$row['0'].'">
                </td>
          </tr>';
  }
}

function foot() {
echo '
  </table>
  <p> <input type="submit" name="Submit" value="DELETE" class="t1"></p>
  </form>
  <p> </p>
</div>
</body>
</html>
';
}

function cleanup_text($cad) {
  $cad = htmlentities(strip_tags(addslashes($cad)));
  $cad = $cad;
  return $cad;
}

function checkinput($cad) {
  if(strlen($cad) > 10 || strlen($cad) < 4 ) { return 0; }
  if(!ereg("^[A-Za-z0-9]+$", $cad)) { return 0;  } 
  else { 
    $dont = array('alter', 'create', 'dbcc', 'declare', 'delete', 'drop', 'else', 'fetch', 'exists', 'file','from', 'group', 'having', 'if', 'columns', 'table', 'tables', 'views', 'insert', 'left', 'like', 'open','openquery', 'print', 'readtext', 'restore', 'return', 'select', 'set', 'shutdown', 'some', 'any', 'union','update', 'where', 'while'); 
    while (list(,$v) = each($dont)) {
      if ($cad == $v) { return 0; }
	}
  return 1;
 }
}
?>

and for the style copy it and rename it to ad.css

Code:
/* CSS Document */
/*
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
*/

body { background-color: #000000; }
input.t1 {
	font-family:tahoma; 
	font-size: xx-small; 
	color:#FFFFFF; 
	padding: 2px;
	border-up:1px solid #CCCCCC;
	border-right:1px solid #CCCCCC;
	border-left:1px solid #999999;
	border-down:1px solid #999999;
	background-color: #333333;
}
input.t2 {
	font-family:tahoma; 
	font-size: xx-small; 
	color:#000000; 
}
.title {
	font-family: Trebuchet MS,Verdana, Arial;
	font-size: x-small;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	background-color: #A50018;

}
.bla {
	border: 1px solid #333333;
	font-family: Trebuchet MS;
	font-size: x-small;
	color: #000000;
	background-color: #CCCCCC;
}
.bla1 {
	font-family: Trebuchet MS;
	font-size: x-small;
	color: #000000;
	background-color: #999999;
}
.TheTitle {
        color: #FF0000;
        font-size: large;
        font-family: Trebuchet MS;
        font-weight: bold;
		text-align: center;
}
.Text {
        color: #FFFFFF;
        font-size: x-small;
        font-family: Trebuchet MS;
		text-align: center;
}

and put all file delcfg.php,checkaccount.php and ad.css in your xampp/htdoc directory.
and go to your browser type 127.0.0.1/checkaccount.php

with the use of this, you can check all accounts that has not been online for how many months or days.

MaskARRA - How delete in-active accounts using sql scripts - RaGEZONE Forums


NOTE:

BEFORE YOU DO THIS, BACKUP YOUR DATABASE FOR YOUR SAFETY.
 
Upvote 0
Now i download your muserver to restore the database and review the structure
When i finish download I will make some test with scripts for delete inactive accounts
and all over all for me is interesting to see the tables and etc. on the S6 database because I understand only on old versions.
If i have success with some script i will post there.
Thank you for your effort sir :D



try this one

i use this to delete some inactive account.

copy this code and edit with your sql database details and save it as delcfg.php

Code:
<?php
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
//
//Connection settings. You MUST change this
//

$hostdb = "127.0.0.1"; 
$userdb = "sa"; 
$passdb = "[COLOR=#FF0000]yourpass[/COLOR]"; 

$days = "0";  // Number of Days (example: "21" will delete the accounts that haven't 
               // logged ingame in the last 21 days.







//---------------------------------------------
//DON'T BE STUPID.. DO NOT CHANGE ANYTHING BELOW THIS ^^
//----------------------------------------------
$db = 'MuOnline';
$msconn=mssql_connect("$hostdb","$userdb","$passdb"); 
if(!$msconn) { echo "Could not connect to database, please check your configuration and try again"; exit; }
else { $msdb=mssql_select_db("$db",$msconn); }
?>

copy also this one, and save it as anything you want

eg:

checkaccount.php

Code:
<?php
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
include("delcfg.php"); 

if(empty($_POST)) {
$c = "COLLATE Modern_Spanish_CI_AS" ;
$query = "select distinct ac.ID, ac.GameID1, ac.GameID2, ac.GameID3, ac.GameID4, ac.GameID5, ms.DisConnectTM from accountcharacter as ac, MEMB_STAT as ms where id ".$c." in (select memb___id from memb_stat where ConnectTM  < getdate()-".$days.") and ms.memb___id  ".$c."  = ac.ID  ".$c."  order by ms.DisConnectTM DESC";
$result = mssql_query($query);
head($days);
content($result);
foot();
} 
if(!empty($_POST)) {
  while (list($k,$v) = each ($_POST)) {
    if ($k == 'dont') {
      while (list($kk,$vv) = each ($v)) {
        $cad = cleanup_text($vv);
        if(checkinput($cad) == 0) { echo "SQL INJECTION DETECTED!!!"; exit; }
        if(checkinput($cad) == 1) { $dont[] = $cad; }
      }
    }
  }
  if(!empty($dont)) { $dont = implode("','",$dont); }
  else { $dont = ''; }
  $c = "COLLATE Modern_Spanish_CI_AS" ;
  $result = mssql_query("select ID from accountcharacter where id ".$c." in (select memb___id from memb_stat where ConnectTM  < getdate()-".$days.") and not ID  ".$c." in ('".$dont."')");
  while ($row = mssql_fetch_row($result)) { $accounts[] = $row[0]; }  
  if(!empty($accounts)) { $accounts = implode("','",$accounts);  }
  else { $accounts = ''; }
     
  $result = mssql_query("select GameID1, GameID2, GameID3, GameID4, GameID5 from accountcharacter where id  ".$c." in('".$accounts."')");

  while ($row = mssql_fetch_row($result)) {
    while (list(,$charname) = each($row)) {
      if (strlen($charname) > 3) {    
        $r1a = mssql_query("delete from optiondata where Name ".$c." = '$charname'");
        $r2 = mssql_query("select Count(*) as 'Check' from Guild where G_Master  ".$c." = '$charname'");
        $row1 = mssql_fetch_array($r2);
        if($row1['0'] > 0) {
          $r3 = mssql_query("delete from GuildMember where G_Name  ".$c." in (select G_Name from Guild where G_Master  ".$c." ='$charname')");
          $r4 = mssql_query("delete from Guild where G_Master ".$c." ='$charname'");
        }
        $r5 = mssql_query("delete from GuildMember where Name  ".$c." ='$charname'");
     }
  }    
  $q = mssql_query("delete from accountcharacter where id  ".$c." in('".$accounts."')");
  $q = mssql_query("delete from character where AccountID  ".$c." in('".$accounts."')");    
  $q = mssql_query("delete from memb_info where memb___id  ".$c."  in('".$accounts."')");
  $q = mssql_query("delete from vi_curr_info where memb___id  ".$c." in('".$accounts."')");
  $q = mssql_query("delete from warehouse where accountid  ".$c." in('".$accounts."')");
//  $q = mssql_query("delete from allitemslog where items_acid in('".$accounts."')");
//  $q = mssql_query("delete from copylog where copy_acid in('".$accounts."')");
  $q = mssql_query("delete from memb_stat where memb___id  ".$c." in('".$accounts."')");
}
  $msdb=mssql_select_db("Ranking",$msconn); 
  $r = mssql_query("delete from event_info where AccountID  ".$c." in ('".$accounts."')");
  echo '<html>
        <head>
        <link href="http://forum.ragezone.com/ad.css" rel="stylesheet" type="text/css">
        </head>
        <body><p class="TheTitle" >ACCOUNTS DELETED!!!</p></body>
        </html>'; exit;  
}
function head($days) {
echo '<html>
<head>
<!-- --------------------------------------------------------- -->
<!--   Inactive Account Deleter by Lady_Fu for [-D|K|L-]Team   -->
<!-- DKLteam.com.ar || Guildphonos.com.ar || www.jamaikamu.com -->
<!--               One for Mu.. Mu for All..                   -->
<!--        Removing these credits makes you our ***** :D      -->
<!-- --------------------------------------------------------- -->

<link href="http://forum.ragezone.com/ad.css" rel="stylesheet" type="text/css">
<title>Inactive Accounts Cleaner · [D|K|L]Team</title>
</head>
<body>
<div align="center"> 
        <form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'">
  <table width="100%" height="100%" border="0" align="center">
    <tr>
      <td align="center" valign="top"> 
        <div align="center"> 
            <p class="TheTitle">Inactive Accounts</p>
            <p class="Text">These 
              are the accounts that remained inactive for '.$days.'+ days.<br>
              (Check the accounts you <font color="#FF0000"><strong>DO NOT WANT</strong></font> 
              to delete and click the DELETE button)</font></p>
        </div>
          <table cellpadding="5" cellspacing="0" ><tr class="title">
            <td> AccountID </td>
            <td> Char1 </td>
            <td> Char2 </td>
            <td> Char3 </td>
            <td> Char4 </td>
            <td> Char5 </td>
            <td> Last Seen </td>
              <td> Dont!! </td>
          </tr>';
}

function content($result)    {
$i = 1;
while ($row = mssql_fetch_row($result)) {
  if (!is_int($i / 2)) { $col = 'bla'; }
  else { $col = 'bla1'; }
  $i++;
  echo '
           <tr class="'.$col.'"> 
            <td>'.$row['0'].'</td>
            <td>'.$row['1'].'</td>
            <td>'.$row['2'].'</td>
            <td>'.$row['3'].'</td>
            <td>'.$row['4'].'</td>
            <td>'.$row['5'].'</td>
            <td>'.$row['6'].'</td>
            <td>
                  <input name="dont[]" type="checkbox" class="t2" id="dont[]" title="Check this if you do not want to delete this account" value="'.$row['0'].'">
                </td>
          </tr>';
  }
}

function foot() {
echo '
  </table>
  <p> <input type="submit" name="Submit" value="DELETE" class="t1"></p>
  </form>
  <p> </p>
</div>
</body>
</html>
';
}

function cleanup_text($cad) {
  $cad = htmlentities(strip_tags(addslashes($cad)));
  $cad = $cad;
  return $cad;
}

function checkinput($cad) {
  if(strlen($cad) > 10 || strlen($cad) < 4 ) { return 0; }
  if(!ereg("^[A-Za-z0-9]+$", $cad)) { return 0;  } 
  else { 
    $dont = array('alter', 'create', 'dbcc', 'declare', 'delete', 'drop', 'else', 'fetch', 'exists', 'file','from', 'group', 'having', 'if', 'columns', 'table', 'tables', 'views', 'insert', 'left', 'like', 'open','openquery', 'print', 'readtext', 'restore', 'return', 'select', 'set', 'shutdown', 'some', 'any', 'union','update', 'where', 'while'); 
    while (list(,$v) = each($dont)) {
      if ($cad == $v) { return 0; }
    }
  return 1;
 }
}
?>

and for the style copy it and rename it to ad.css

Code:
/* CSS Document */
/*
// ----------------------------------------
// CREDITS:
// ----------------------------------------
// All credits go to Lady_Fu (code), 
// Mr-K & Dios (test & valuable help) for [-D|K|L-]Team
// You can change everything you want as long
// as you keep these credits.
// We've dedicated our time to make this tool, so remember:
// REMOVING THESE CREDITS MAKES YOU OUR *****!!
//-----------------------------------------
*/

body { background-color: #000000; }
input.t1 {
    font-family:tahoma; 
    font-size: xx-small; 
    color:#FFFFFF; 
    padding: 2px;
    border-up:1px solid #CCCCCC;
    border-right:1px solid #CCCCCC;
    border-left:1px solid #999999;
    border-down:1px solid #999999;
    background-color: #333333;
}
input.t2 {
    font-family:tahoma; 
    font-size: xx-small; 
    color:#000000; 
}
.title {
    font-family: Trebuchet MS,Verdana, Arial;
    font-size: x-small;
    font-weight: bold;
    color: #FFFFFF;
    text-align: center;
    background-color: #A50018;

}
.bla {
    border: 1px solid #333333;
    font-family: Trebuchet MS;
    font-size: x-small;
    color: #000000;
    background-color: #CCCCCC;
}
.bla1 {
    font-family: Trebuchet MS;
    font-size: x-small;
    color: #000000;
    background-color: #999999;
}
.TheTitle {
        color: #FF0000;
        font-size: large;
        font-family: Trebuchet MS;
        font-weight: bold;
        text-align: center;
}
.Text {
        color: #FFFFFF;
        font-size: x-small;
        font-family: Trebuchet MS;
        text-align: center;
}

and put all file delcfg.php,checkaccount.php and ad.css in your xampp/htdoc directory.
and go to your browser type 127.0.0.1/checkaccount.php

with the use of this, you can check all accounts that has not been online for how many months or days.

MaskARRA - How delete in-active accounts using sql scripts - RaGEZONE Forums


NOTE:

BEFORE YOU DO THIS, BACKUP YOUR DATABASE FOR YOUR SAFETY.

I wanna try this out :D
Thanks for sharing
 
Upvote 0
Status
Not open for further replies.
Back