• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ModernAAC] Recover Lost Account

Xampy

PHP | SQL | LUA | C++
Joined
Jun 22, 2008
Messages
1,109
Reaction score
17
Hello!

I've made my own 'Recover Account' page, since I didn't find none in ModernAAC yet.
If you fill the 3 necessary data boxes, assuming the data isn't wrong, it will generate a new password.

Go to system/pages/ and create a file called recover.php and copy this into it:
PHP:
<html><head><style type="text/css">input.recover1 {margin-left: 11px;} input.recover2 {margin-left: 25px;} input.recover3 {margin-left: 18px;}</style></head></html>
<?php
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();

function generatePassword($length) {
	$vowels = 'aeiouyAEIOUY';
	$consonants = '1234567890bcdfghjkmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ';
 
	$password = '';
	$alt = time() % 2;
	for ($i = 0; $i < $length; $i++) {
		if ($alt == 1) {
			$password .= $consonants[(rand() % strlen($consonants))];
			$alt = 0;
		} else {
			$password .= $vowels[(rand() % strlen($vowels))];
			$alt = 1;
		}
	}
	return $password;
}

echo '<h2>Lost Account?</h2>';

if(!$_POST)
	echo '<form action="'.WEBSITE.'/index.php/p/v/recover" method="post">
		Account Name: <input type="password" name="account" class="recover1"/><br />
		Player Name: <input type="text" name="player" class="recover2"/><br />
		Recovery Key: <input type="text" name="key" class="recover3"/><br />
		<input type="submit" value="Recover!"/><br />
		</form>';
else {
	if(empty($_POST['player']) || empty($_POST['key']) || empty($_POST['account']))
		echo 'You must fill all the boxes!<br><br>
		<form action="'.WEBSITE.'/index.php/p/v/recover" method="post">
		Account Name: <input type="password" name="account" class="recover1"/><br />
		Player Name: <input type="text" name="player" class="recover2"/><br />
		Recovery Key: <input type="text" name="key" class="recover3"/><br />
		<input type="submit" value="Recover!"/><br />
		</form>';
	else {
		$check = $SQL->query('SELECT `name`, `key` FROM `accounts` WHERE `id` IN (SELECT `account_id` FROM `players` WHERE `name` LIKE "'.$_POST['player'].'");')->fetch();
		if(strtolower($check['name']) == strtolower($_POST['account']) && $check['key'] == $_POST['key']) {
			$newPassword = generatePassword(8);
			echo 'Your new password is: <b><font color="red">'.$newPassword.'</font></b>';
			$SQL->query('UPDATE `accounts` SET `password` = "'.sha1($newPassword).'" WHERE `name` LIKE "'.$_POST['account'].'";');
		}
		else
			echo 'The data you\'ve entered is wrong.<br><br>
		<form action="'.WEBSITE.'/index.php/p/v/recover" method="post">
		Account Name: <input type="password" name="account" class="recover1"/><br />
		Player Name: <input type="text" name="player" class="recover2"/><br />
		Recovery Key: <input type="text" name="key" class="recover3"/><br />
		<input type="submit" value="Recover!"/><br />
		</form>';
		}
}
?>
Then save the file and you're done.
It only supports SHA1 because ModernAAC only supports this, not plain.

Link to it should be something like:
http://YOURDOMAIN/index.php/p/v/recover

Regards!

edit1:
Fixed a bug with accounts that contain letters.

edit2:
Now the system isn't case sensitive while checking account name.
 
Last edited:
Good but try doing it within account controller, not as a page.

Second thing, recovery key will be in sha1 as well.
 
Good but try doing it within account controller, not as a page.

Second thing, recovery key will be in sha1 as well.
Oki, I will try :p.
Oh, oki! I'll change it for tomorrow if I can :p.


Btw, mods, delete this text:
--DENY MY LAST THREAD AND ALLOW THIS, PLEASE MODS-- [DELETE THIS TEXT]
Heheheh thanks.
 
the password is not changing
is giving this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'FABIANOBN' in 'where clause'' in C:\xampp\htdocs\system\pages\recover.php:49 Stack trace: #0 C:\xampp\htdocs\system\pages\recover.php(49): PDO->query('UPDATE `account...') #1 C:\xampp\htdocs\system\application\controllers\p.php(13): include('C:\xampp\htdocs...') #2 [internal function]: p->v('recover') #3 C:\xampp\htdocs\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #4 C:\xampp\htdocs\index.php(157): require_once('C:\xampp\htdocs...') #5 {main} thrown in C:\xampp\htdocs\system\pages\recover.php on line 49

Fixed just change line 49 to:
$SQL->query("UPDATE accounts SET password = '".sha1($newPassword)."' WHERE name LIKE '".$_POST['account']."';");

Edit:
Just working to put the account name in capital letters.
 
Last edited:
oO but you have donor powers to delete:
--DENY MY LAST THREAD AND ALLOW THIS, PLEASE MODS-- [DELETE THIS TEXT]
Hello!
 
you fixed the bug: the only working when the letters are in capital letters acc?
to put the letters in lower case, does not work says he has incorrect data.
 
Back
Top