Delete dead records

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
bajszatlan
highway camper
highway camper
Posts: 3
Joined: 10 Dec 2015 21:11
Owned TM-games: tmuf, + all tm2

Delete dead records

Post by bajszatlan » 05 Feb 2017 11:52

Hi!
I looking one plugin whitch can delete all local records older than 30 days.
example: who not rejoined to the server more than 30 days, they locals will be deleted by the plugin.
i will keep my db clean and up to date.

i found an old script (prunerecs), but its not working above php 5.4.

speedychris
wheelbarrow operator
wheelbarrow operator
Posts: 19
Joined: 12 Mar 2013 09:58
Owned TM-games: TMU, TM2

Re: Delete dead records

Post by speedychris » 06 Feb 2017 10:52

A really bad idea to do this. The only important ist that recs form deleted maps are pruned automatically, this is already done by aseco on restart.

bajszatlan
highway camper
highway camper
Posts: 3
Joined: 10 Dec 2015 21:11
Owned TM-games: tmuf, + all tm2

Re: Delete dead records

Post by bajszatlan » 07 Feb 2017 19:19

and how can i remove the login names who dont have local records? in my server have over 1500...
i dont like remove all with my fingers :)

User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 138
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Manialink(s): woa
Location: Sweden
Contact:

Re: Delete dead records

Post by L3cKy » 11 Feb 2017 08:40

This script deletes all players who dont have a rank on the server ...

Code: Select all

<?php
	$connectionid = mysql_connect ("dbhost", "dbuser", "dbpw");
	if (!mysql_select_db ("dbname", $connectionid))
		{
		die("no connection to database");
		}
	$sql = "SELECT * FROM players WHERE Id NOT IN (SELECT playerID FROM rs_rank)";
	$result = mysql_query($sql);
	$anzahl = 0;
		while ($row = mysql_fetch_array($result)) {
			$playerid = $row['Id'];
			$playerlogin = $row['Login'];
			$anzahl = $anzahl+1;
			$query = mysql_query("DELETE FROM `players` WHERE `Id`='". $playerid."';");
			$query = mysql_query("DELETE FROM `players_extra` WHERE `playerID`='". $playerid."';");
			$query = mysql_query("DELETE FROM `records` WHERE `PlayerId`='". $playerid."';");
			$query = mysql_query("DELETE FROM `rs_karma` WHERE `PlayerId`='". $playerid."';");
			$query = mysql_query("DELETE FROM `rs_rank` WHERE `playerID`='". $playerid."';");
			$query = mysql_query("DELETE FROM `rs_times` WHERE `playerID`='". $playerid."';");
			mysql_query($query);
		}
		if (mysql_num_rows($result) > 0) {
			if ($anzahl == 1) {
				$players = 'player';
			} else {
				$players = 'players';
			}
			$message = 'Note: '.$anzahl.' inactive '.players.' have been deleted from the Database!';
		} else {
			$message = 'Note: no inactive player(s) found.';
		}
		echo $message;
		//Optimierung
		$query = mysql_query("OPTIMIZE TABLE `players`" );
		$query = mysql_query("OPTIMIZE TABLE `players_extra`" );
		$query = mysql_query("OPTIMIZE TABLE `records`" );
		$query = mysql_query("OPTIMIZE TABLE `rs_karma`" );
		$query = mysql_query("OPTIMIZE TABLE `rs_rank`" );
		$query = mysql_query("OPTIMIZE TABLE `rs_times`" );
		mysql_query($query);
?>

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: Delete dead records

Post by undef.de » 11 Feb 2017 17:47

Maybe this plugin will help you: http://plugins.xaseco.org/info.php?id=130
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest