• 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!

Gesior AAC 2011 - Needed? Ideas?

@J.Dre
I think it's good idea.



----------------------------------
This is beta version of Account class. Any ideas?
PHP:
class Account
{
    const BY_ID = 1;
    const BY_NAME = 2;
    private $SQL;
    private $data = array('id' => null, 'name' => null, 'password' => null, 'salt' => null, 'premdays' => null, 'lastday' => null, 'email' => null, 'key' => null, 'blocked' => null, 'warnings' => null, 'group_id' => null, 'page_access' => null, 'page_lastday' => null, 'email_new' => null, 'email_new_time' => null, 'rlname' => null, 'location' => null, 'created' => null, 'email_code' => null, 'next_email' => null, 'premium_points' => null, 'nickname' => null, 'avatar' => null, 'about_me' => null, 'vote' => null, 'flag' => null);
    private static $fields = array('id', 'name', 'password', 'premdays', 'lastday', 'email', 'key', 'group_id', 'rlname', 'location', 'created', 'premium_points');

    public static function addField($name)
    {
        if(!in_array($name, self::$fields))
            self::$fields[] = $name;
    }

    public static function removeField($name)
    {
        if(in_array($name, self::$fields))
            unset(self::$fields[$name]);
    }

    public static function getFieldsList()
    {
        return self::$fields;
    }

    public function __construct($search_text = null, $search_by = self::BY_ID)
    {
        $this->SQL = Website::getInstance()->getDBHandle();
        if($search_text != null)
            $this->load($search_text, $search_by);
    }

    public function load($search_text, $search_by = self::BY_ID)
    {
        if($search_by == self::BY_ID)
            $search_string = $this->SQL->fieldName('id') . ' = ' . $this->SQL->quote($search_text);
        elseif($search_by == self::BY_NAME)
            $search_string = $this->SQL->fieldName('name') . ' = ' . $this->SQL->quote($search_text);
        else
            new Error_Critic('', 'Wrong account search_by type.');
        $fieldsArray = array();
        foreach(self::$fields as $fieldName)
            $fieldsArray[$fieldName] = $this->SQL->fieldName($fieldName);
        $this->data = $this->SQL->query('SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . $this->SQL->fieldName('accounts') . ' WHERE ' . $search_string)->fetch();
    }

    public function loadById($id)
    {
        return $this->load($id, self::BY_ID);
    }

    public function loadByName($name)
    {
        return $this->load($name, self::BY_NAME);
    }

    public function save($forceInsert = false)
    {
        if(!isset($this->data['id']) || $forceInsert)
        {
            $keys = array();
            $values = array();
            foreach(self::$fields as $key)
                if($key != 'id')
                {
                    $keys[] = $this->SQL->fieldName($key);
                    $values[] = $this->SQL->quote($this->data[$key]);
                }
            $this->SQL->query('INSERT INTO `accounts` (' . implode(', ', $keys) . ') VALUES (' . implode(', ', $values) . ')');
        }
        else
        {
            $updates = array();
            foreach(self::$fields as $key)
                if($key != 'id')
                    $updates[] = $this->SQL->fieldName($key) . ' = ' . $this->SQL->quote($this->data[$key]);
            $this->SQL->query('UPDATE `accounts` SET ' . implode(', ', $updates) . ' WHERE ' . $this->SQL->fieldName('id') . ' = ' . $this->SQL->quote($this->data['id']));
        }
    }

    public function isLoaded()
    {
        return isset($this->data['id']);
    }

    public function setID($value){$this->data['id'] = $value;}
    public function getID(){return $this->data['id'];}
    public function setName($value){$this->data['name'] = $value;}
    public function getName(){return $this->data['name'];}
    public function setPassword($value){$this->data['password'] = $value;}
    public function getPassword(){return $this->data['password'];}
    public function setPremDays($value){$this->data['premdays'] = $value;}
    public function getPremDays(){return $this->data['premdays'];}
    public function setLastDay($value){$this->data['lastday'] = $value;}
    public function getLastDay(){return $this->data['lastday'];}
    public function setMail($value){$this->data['email'] = $value;}
    public function getMail(){return $this->data['email'];}
    public function setKey($value){$this->data['key'] = $value;}
    public function getKey(){return $this->data['key'];}
    public function setGroupId($value){$this->data['group_id'] = $value;}
    public function getGroupId(){return $this->data['group_id'];}
    public function setRLName($value){$this->data['rlname'] = $value;}
    public function getRLName(){return $this->data['rlname'];}
    public function setLocation($value){$this->data['location'] = $value;}
    public function getLocation(){return $this->data['location'];}
    public function setCreated($value){$this->data['created'] = $value;}
    public function getCreated(){return $this->data['created'];}
    public function setPremiumPoints($value){$this->data['premium_points'] = $value;}
    public function getPremiumPoints(){return $this->data['premium_points'];}
}
In class is static function:
addField($name)
so you can add field to load every account load, for example you can add column 'flag':
Account::addField('flag')
it will load column 'flag' always when you load new account by class Account, not like in POT where you have to use $account->getCustomField('flag') [it uses 1 SQL query every execute, my class not :p ]

This is Table class:
PHP:
<?PHP
class Table extends Errors
{
    private $id = '';
    private $name = '';
    private $title = '';
    private $class = '';

    private $rows = array();
    private $styles = array();
    private $scripts = array();

    public function __construct($id = null, $name = null, $title = null, $class = null, $rows = null, $styles = null, $scripts = null)
    {
        if($id != null)
            $this->id = $id;

        if($name != null)
            $this->name = $name;

        if($title != null)
            $this->title = $title;

        if($class != null)
            $this->class = $class;

        if($rows != null)
            $this->rows = $rows;

        if($styles != null)
            $this->styles = $styles;

        if($scripts != null)
            $this->scripts = $scripts;
    }

    public function setId($value)
    {
        $this->id = $value;
    }

    public function setName($value)
    {
        $this->name = $value;
    }

    public function setTitle($value)
    {
        $this->title = $value;
    }

    public function setClass($value)
    {
        $this->class = $value;
    }

    public function setRows($value)
    {
        $this->rows = $value;
    }

    public function setStyles($value)
    {
        $this->styles = $value;
    }

    public function setStyle($key, $value)
    {
        $this->styles[$key] = $value;
    }

    public function setScripts($value)
    {
        $this->scripts = $value;
    }

    public function addRow(TableRow $row)
    {
        $this->rows[] = $row;
    }

    public function getTableString()
    {
        $ret = '<table';
        if($this->id != '')
            $ret .= ' id="' . $this->id . '"';
        if($this->name != '')
            $ret .= ' name="' . $this->name . '"';
        if($this->class != '')
            $ret .= ' class="' . $this->class . '"';
        $styles = array();
        if(count($this->styles) > 0)
            foreach($this->styles as $key => $value)
                $styles = $key . ':' . $value;
        if(count($styles) > 0)
            $ret .= ' style="' . implode(';', $styles) . '"';
        if($this->title != '')
            $ret .= ' title="' . $this->title . '"';
        if(count($this->scripts) > 0)
            foreach($this->scripts as $event => $script)
                $ret .= ' ' . $event . '="' . $script . '"';
        $ret .= '>';
        if(count($this->rows) > 0)
            foreach($this->rows as $row)
                $ret .= $row->getRowString();
        $ret .= '</table>';
        
        return $ret;
    }

    public function __toString()
    {
        return $this->getTableString();
    }
}

class TableRow extends Errors
{
    private $content = '';
    private $id = '';
    private $name = '';
    private $title = '';
    private $rowspan = 0;
    private $colspan = 0;
    private $class = '';

    private $cells = array();
    private $styles = array();
    private $scripts = array();

    public function __construct($content = null, $id = null, $name = null, $title = null, $rowspan = null, $colspan = null, $class = null, $cells = null, $styles = null, $scripts = null)
    {
        if($content != null)
            $this->content = $content;

        if($id != null)
            $this->id = $id;

        if($name != null)
            $this->name = $name;

        if($title != null)
            $this->title = $title;

        if($rowspan != null)
            $this->rowspan = $rowspan;

        if($colspan != null)
            $this->colspan = $colspan;

        if($class != null)
            $this->class = $class;

        if($cells != null)
            $this->cells = $cells;

        if($styles != null)
            $this->styles = $styles;

        if($scripts != null)
            $this->scripts = $scripts;
    }

    public function getContent()
    {
        return $this->content;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getTitle()
    {
        return $this->title;
    }

    public function getRowspan()
    {
        return $this->rowspan;
    }

    public function getColspan()
    {
        return $this->colspan;
    }

    public function getClass()
    {
        return $this->class;
    }

    public function getCells()
    {
        return $this->cells;
    }

    public function getStyles()
    {
        return $this->styles;
    }

    public function getStyle($key)
    {
        return $this->styles[$key];
    }

    public function getScripts()
    {
        return $this->scripts;
    }

    public function setContent($value)
    {
        $this->content = $value;
    }

    public function setId($value)
    {
        $this->id = $value;
    }

    public function setName($value)
    {
        $this->name = $value;
    }

    public function setTitle($value)
    {
        $this->title = $value;
    }

    public function setRowspan($value)
    {
        $this->rowspan = $value;
    }

    public function setColspan($value)
    {
        $this->colspan = $value;
    }

    public function setClass($value)
    {
        $this->class = $value;
    }

    public function setCells($value)
    {
        $this->cells = $value;
    }

    public function setStyles($value)
    {
        $this->styles = $value;
    }

    public function setStyle($key, $value)
    {
        $this->styles[$key] = $value;
    }

    public function setScripts($value)
    {
        $this->scripts = $value;
    }

    public function addCell(TableCell $cell)
    {
        $this->cells[] = $cell;
    }

    public function getRowString()
    {
        $ret = '<tr';
        if($this->id != '')
            $ret .= ' id="' . $this->id . '"';
        if($this->name != '')
            $ret .= ' name="' . $this->name . '"';
        if($this->class != '')
            $ret .= ' class="' . $this->class . '"';
        $styles = array();
        if(count($this->styles) > 0)
            foreach($this->styles as $key => $value)
                $styles = $key . ':' . $value;
        if(count($styles) > 0)
            $ret .= ' style="' . implode(';', $styles) . '"';
        if($this->title != '')
            $ret .= ' title="' . $this->title . '"';
        if($this->rowspan > 0)
            $ret .= ' rowspan="' . $this->rowspan . '"';
        if($this->colspan > 0)
            $ret .= ' colspan="' . $this->colspan . '"';
        if(count($this->scripts) > 0)
            foreach($this->scripts as $event => $script)
                $ret .= ' ' . $event . '="' . $script . '"';
        $ret .= '>';
        if($this->content == '')
        {
            if(count($this->cells) > 0)
                foreach($this->cells as $cell)
                    $ret .= $cell->getCellString();
        }
        else
            $ret .= $this->content;
        $ret .= '</tr>';
        
        return $ret;
    }

    public function __toString()
    {
        return $this->getRowString();
    }
}

class TableCell extends Errors
{
    private $content = '';
    private $id = '';
    private $name = '';
    private $title = '';
    private $rowspan = 0;
    private $colspan = 0;

    private $class = '';
    private $styles = array();
    private $scripts = array();

    public function __construct($content = null, $class = null, $styles = null, $id = null, $name = null, $title = null, $rowspan = null, $colspan = null, $scripts = null)
    {
        if($content != null)
            $this->content = $content;

        if($id != null)
            $this->id = $id;

        if($name != null)
            $this->name = $name;

        if($title != null)
            $this->title = $title;

        if($rowspan != null)
            $this->rowspan = $rowspan;

        if($colspan != null)
            $this->colspan = $colspan;

        if($class != null)
            $this->class = $class;

        if($styles != null)
            $this->styles = $styles;

        if($scripts != null)
            $this->scripts = $scripts;
    }

    public function getContent()
    {
        return $this->content;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getTitle()
    {
        return $this->title;
    }

    public function getRowspan()
    {
        return $this->rowspan;
    }

    public function getColspan()
    {
        return $this->colspan;
    }

    public function getClass()
    {
        return $this->class;
    }

    public function getStyles()
    {
        return $this->styles;
    }

    public function getStyle($key)
    {
        return $this->styles[$key];
    }

    public function getScripts()
    {
        return $this->scripts;
    }

    public function setContent($value)
    {
        $this->content = $value;
    }

    public function setId($value)
    {
        $this->id = $value;
    }

    public function setName($value)
    {
        $this->name = $value;
    }

    public function setTitle($value)
    {
        $this->title = $value;
    }

    public function setRowspan($value)
    {
        $this->rowspan = $value;
    }

    public function setColspan($value)
    {
        $this->colspan = $value;
    }

    public function setClass($value)
    {
        $this->class = $value;
    }

    public function setStyles($value)
    {
        $this->styles = $value;
    }

    public function setStyle($key, $value)
    {
        $this->styles[$key] = $value;
    }

    public function setScripts($value)
    {
        $this->scripts = $value;
    }

    public function getCellString()
    {
        $ret = '<td';
        if($this->id != '')
            $ret .= ' id="' . $this->id . '"';
        if($this->name != '')
            $ret .= ' name="' . $this->name . '"';
        if($this->class != '')
            $ret .= ' class="' . $this->class . '"';
        $styles = array();
        if(count($this->styles) > 0)
            foreach($this->styles as $key => $value)
                $styles = $key . ':' . $value;
        if(count($styles) > 0)
            $ret .= ' style="' . implode(';', $styles) . '"';
        if($this->title != '')
            $ret .= ' title="' . $this->title . '"';
        if($this->rowspan > 0)
            $ret .= ' rowspan="' . $this->rowspan . '"';
        if($this->colspan > 0)
            $ret .= ' colspan="' . $this->colspan . '"';
        if(count($this->scripts) > 0)
            foreach($this->scripts as $event => $script)
                $ret .= ' ' . $event . '="' . $script . '"';
        $ret .= '>';
        $ret .= $this->content;
        $ret .= '</td>';
        
        return $ret;
    }

    public function __toString()
    {
        return $this->getCellString();
    }
}
?>
and this is example of use in page script:
PHP:
<?PHP
$table = new Table();
$row = new TableRow();
$row->addCell(new TableCell('first cell'));
$row->addCell(new TableCell('second cell', 'myClass'));
$table->addRow($row);
echo $table;
?>
 
Last edited by a moderator:
Use a DBAL, or even better a ORM or at least prepared statements if not, people will probably find SQL injection quite quickly, and people that will "develop" scripts for this, will make it vulnerable. Also learn about magic methods.
 
This is example of Form and Table classes in script (create account):
PHP:
<?PHP
$createAccountForm = new Form();

$field = new FormField_Text();
$field->setName('accountName');
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Password();
$field->setName('accountPassword');
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Password();
$field->setName('accountPasswordRepeat');
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Text();
$field->setName('accountEmail');
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Submit();
$field->setName('create');
$field->setValue('Create Account');
$field->setStyle('font-size', '24px');
$createAccountForm->addField($field);



$table = new Table();

echo $createAccountForm->getString_Form();

$row = new TableRow();
$row->addCell(new TableCell('Name:'));
$row->addCell(new TableCell($createAccountForm->getField('accountName')));
$table->addRow($row);

$row = new TableRow();
$row->addCell(new TableCell('Password:'));
$row->addCell(new TableCell($createAccountForm->getField('accountPassword')));
$table->addRow($row);

$row = new TableRow();
$row->addCell(new TableCell('Repeat Password:'));
$row->addCell(new TableCell($createAccountForm->getField('accountPasswordRepeat')));
$table->addRow($row);

$row = new TableRow();
$row->addCell(new TableCell('E-mail:'));
$row->addCell(new TableCell($createAccountForm->getField('accountEmail')));
$table->addRow($row);

$row = new TableRow();
$row->addCell(new TableCell(''));
$row->addCell(new TableCell($createAccountForm->getField('create')));
$row->setStyle('height', '40px');
$row->setStyle('vertical-align' , 'bottom');
$table->addRow($row);

echo $table;

echo $createAccountForm->getString_FormEnd();
?>
[ there is no code to create new account yet, only generate form ]
Output:
PHP:
.
<form action="http://127.0.0.1/x/" method="POST" enctype="multipart/form-data" /><input type="hidden" name="amp0" value="create" /><input type="hidden" name="page" value="account" /><table><tr><td>Name:</td><td><input type="text" size="10" value="" name="accountName" /></td></tr><tr><td>Password:</td><td><input type="password" size="10" value="" name="accountPassword" /></td></tr><tr><td>Repeat Password:</td><td><input type="password" size="10" value="" name="accountPasswordRepeat" /></td></tr><tr><td>E-mail:</td><td><input type="text" size="10" value="" name="accountEmail" /></td></tr><tr style="height:40px;vertical-align:bottom"><td></td><td><input type="submit" value="Create Account" name="create"  style="font-size:24px"/></td></tr></table></form>







.
On www:
createtableform.png

Of course when I finish there will be image with code [configurable - none, php generator or recaptcha] and server rules to accept [configurable - show on/off, text of rules in config]
 
You should add so you can load more fields in the account class. Like in the getKey function, add so it checks if they key exists already else it will try to get it from the database.
 
I noticed the layout is different from Tibia's, is it still optional of which to use?
 
You should add so you can load more fields in the account class. Like in the getKey function, add so it checks if they key exists already else it will try to get it from the database.
I don't understand what to add? What with key?
I noticed the layout is different from Tibia's, is it still optional of which to use?
There will be few layouts in first full version release, but it will be very easy to make new layouts and convert old 'gesior' layouts to new.
 
I don't understand what to add? What with key?

PHP:
public function getKey($key)
{
     // Check if key exists in $this->data
        // If yes, return it
     // else try to fetch it from the database
        // SELECT $key FROM blabla
        // fetch and all that stuff

}
 
I will add check 'isset(data[$key]', but if isn't set it will throw critic error. If you want use custom fields in script or want be sure that field that you need will be loaded, at start of your script add:
PHP:
Account::addField('key');
There will be functions:
...->set($key, $value);
...->get($key);

To get/set value of custom fields, but first you must add these fields by Account::addField.
I want host acc. maker on external server. I cannot execute so many SQL queries, because it could take hours to load page (ping between mysql server and www server is 3-15ms). If anyone will write script like I've seen in gesior 0.3.8 (by widnet) - 'highscores' that execute 401 queries to load list of 100 top players - it can take 2 seconds to send and receive queries....
 
When do you estimate to have this "beta" or smth that can be used for an ot, Not 100% done but so you can use it safely?

Btw Great to have gesior back :), Hope this on will take back the old times :p
 
Gesior, this may not be something you did, but make this whole thing unable to have the tibia template, it almost gives me cancer every time I see a god forsaken n00b using it!

Anyways, best of luck to you on your AAC.
 
First subpage almost done

Almost finished /account/create (need recaptcha, check if there is no other account with same e-mail and show server rules):
PHP:
<?PHP
$errors = new Errors();
$didCreateAccount = false;
$createAccountConfig = Website::getPageConfig(array('account', 'create'));
if($createAccountConfig->getErrorsCount() > 0)
	new Error_Critic('', 'Cannot load config file of page /account/create');
	
$createAccountForm = new Form();

$field = new FormField_Text();
$field->setName('accountName');
if($createAccountConfig->isSetKey('nameMaximumLenght'))
	$field->setMaxLenght($createAccountConfig->getValue('nameMaximumLenght'));
if($createAccountConfig->isSetKey('formSize'))
	$field->setSize($createAccountConfig->getValue('formSize'));
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Password();
$field->setName('accountPassword');
if($createAccountConfig->isSetKey('passwordMaximumLenght'))
	$field->setMaxLenght($createAccountConfig->getValue('passwordMaximumLenght'));
if($createAccountConfig->isSetKey('formSize'))
	$field->setSize($createAccountConfig->getValue('formSize'));
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Password();
$field->setName('accountPasswordRepeat');
if($createAccountConfig->isSetKey('passwordMaximumLenght'))
	$field->setMaxLenght($createAccountConfig->getValue('passwordMaximumLenght'));
if($createAccountConfig->isSetKey('formSize'))
	$field->setSize($createAccountConfig->getValue('formSize'));
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Text();
$field->setName('accountEmail');
if($createAccountConfig->isSetKey('formSize'))
	$field->setSize($createAccountConfig->getValue('formSize'));
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Checkbox();
$field->setName('acceptRules');
$field->setLoadUserValue(true);
$createAccountForm->addField($field);

$field = new FormField_Submit();
$field->setName('create');
$field->setValue('Create Account');
$field->setStyle('font-size', '24px');
$createAccountForm->addField($field);

if($createAccountForm->isSetFieldValue('create'))
{
	if(!$createAccountForm->isSetFieldValue('accountName') || $createAccountForm->getFieldValue('accountName') == '')
		$errors->addError('', 'You must fill field <b>accountName</b>');
	if(!$createAccountForm->isSetFieldValue('accountPassword') || $createAccountForm->getFieldValue('accountPassword') == '')
		$errors->addError('', 'You must fill field <b>accountPassword</b>');
	if(!$createAccountForm->isSetFieldValue('accountPasswordRepeat') || $createAccountForm->getFieldValue('accountPasswordRepeat') == '')
		$errors->addError('', 'You must fill field <b>accountPasswordRepeat</b>');
	if(!$createAccountForm->isSetFieldValue('accountEmail') || $createAccountForm->getFieldValue('accountEmail') == '')
		$errors->addError('', 'You must fill field <b>accountEmail</b>');

	if($errors->isErrorsListEmpty() && $createAccountForm->getFieldValue('accountPassword') != $createAccountForm->getFieldValue('accountPasswordRepeat'))
		$errors->addError('', '<b>accountPassword</b> and <b>accountPasswordRepeat</b> are not equal');

	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('nameAllowedLetters') && strspn($createAccountForm->getFieldValue('accountName'), $createAccountConfig->getValue('nameAllowedLetters')) != strlen($createAccountForm->getFieldValue('accountName')))
		$errors->addError('', '<b>Account Name</b> contains illegal characters, use only: <b>' . $createAccountConfig->getValue('nameAllowedLetters') . '</b>');
	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('nameMaximumLenght') && strlen($createAccountForm->getFieldValue('accountName')) > $createAccountConfig->getValue('nameMaximumLenght'))
		$errors->addError('', '<b>Account Name</b> is too long. Maximum: <b>' . $createAccountConfig->getValue('nameMaximumLenght') . '</b> letters');
	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('nameMinimumLenght') && strlen($createAccountForm->getFieldValue('accountName')) < $createAccountConfig->getValue('nameMinimumLenght'))
		$errors->addError('', '<b>Account Name</b> is too short. Minimum: <b>' . $createAccountConfig->getValue('nameMinimumLenght') . '</b> letters');

	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('passwordAllowedLetters') && strspn($createAccountForm->getFieldValue('accountPassword'), $createAccountConfig->getValue('passwordAllowedLetters')) != strlen($createAccountForm->getFieldValue('accountPassword')))
		$errors->addError('', '<b>Password</b> contains illegal characters, use only: <b>' . $createAccountConfig->getValue('passwordAllowedLetters') . '</b>');
	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('passwordMaximumLenght') && strlen($createAccountForm->getFieldValue('accountPassword')) > $createAccountConfig->getValue('passwordMaximumLenght'))
		$errors->addError('', '<b>Password</b> is too long. Maximum: <b>' . $createAccountConfig->getValue('passwordMaximumLenght') . '</b> letters');
	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('passwordMinimumLenght') && strlen($createAccountForm->getFieldValue('accountPassword')) < $createAccountConfig->getValue('passwordMinimumLenght'))
		$errors->addError('', '<b>Password</b> is too short. Minimum: <b>' . $createAccountConfig->getValue('passwordMinimumLenght') . '</b> letters');

	if($errors->isErrorsListEmpty() && !Functions::isValidMail($createAccountForm->getFieldValue('accountEmail')))
		$errors->addError('', 'Invalid <b>e-mail</b> format');
	if($errors->isErrorsListEmpty())
	{
		$isAlreadyAccount = new Account($createAccountForm->getFieldValue('accountName'), Account::LOADTYPE_NAME);
		if(!$isAlreadyAccount->isLoaded())
		{
			$newAccount = new Account();
			$newAccount->setName($createAccountForm->getFieldValue('accountName'));
			$newAccount->setPassword(Website::getInstance()->encryptPassword($createAccountForm->getFieldValue('accountPassword')));
			$newAccount->setMail($createAccountForm->getFieldValue('accountEmail'));
			$newAccount->setGroupId($createAccountConfig->getValue('newAccountGroupId'));
			$newAccount->save();
			$didCreateAccount = true;
			echo '<div class="bigTitle">Account created</div><br />';
			echo 'Now you can <a href="' . new Link('account', array('login')) . '">login</a>';
			if($createAccountConfig->isSetKey('sendMailWithLogin') && $createAccountConfig->getValue('sendMailWithLogin') && Website::getInstance()->canSendMail())
			{
				if(sendMail(
				$createAccountForm->getFieldValue('accountEmail'),
				Display::getServerName() . ' - Registration',
				'<h2>Thank you for registration on our server ' . htmlspecialchars(Display::getServerName()) . '</h2>Here are informations about your account.<br />Name: <b>' . htmlspecialchars($createAccountForm->getFieldValue('accountName')) . '</b><br />Password: <b> ' . htmlspecialchars($createAccountForm->getFieldValue('accountPassword')) . '</b>',
				true))
					echo '<br />We sent you e-mail with account name and password.';
				else
					echo '<br />Unknown error occured. We cannot send you e-mail with account name and password, but you can login anyway.';
			}
		}
		else
			$errors->addError('', 'Account with name <b>' . htmlspecialchars($createAccountForm->getFieldValue('accountName')) . '</b> already exists');
	}
}

if(!$didCreateAccount)
{
	echo '<div class="bigTitle">Create account</div><br />';
	Display::printErrors($errors->getErrorsList());

	echo $createAccountForm->getString_Form();

	$table = new Table();

	$row = new TableRow();
	$row->addCell(new TableCell('Name:'));
	$row->addCell(new TableCell($createAccountForm->getField('accountName')));
	$table->addRow($row);

	$row = new TableRow();
	$row->addCell(new TableCell('Password:'));
	$row->addCell(new TableCell($createAccountForm->getField('accountPassword')));
	$table->addRow($row);

	$row = new TableRow();
	$row->addCell(new TableCell('Repeat Password:'));
	$row->addCell(new TableCell($createAccountForm->getField('accountPasswordRepeat')));
	$table->addRow($row);

	$row = new TableRow();
	$row->addCell(new TableCell('E-mail:'));
	$row->addCell(new TableCell($createAccountForm->getField('accountEmail')));
	$table->addRow($row);

	$row = new TableRow();
	$cell = new TableCell();
	$row->addCell($cell);
	$table->addRow($row);

	$row = new TableRow();
	$row->addCell(new TableCell('Accept rules:'));
	$row->addCell(new TableCell($createAccountForm->getField('acceptRules')));
	$table->addRow($row);

	$row = new TableRow();
	$row->addCell(new TableCell(''));
	$row->addCell(new TableCell($createAccountForm->getField('create')));
	$row->setStyle('height', '40px');
	$row->setStyle('vertical-align' , 'bottom');
	$table->addRow($row);

	echo $table;

	echo $createAccountForm->getString_FormEnd();
}
?>
config file (./config/pages/account_create.php):
PHP:
<?PHP
$_web_config['nameMinimumLenght'] = 1;
$_web_config['nameMaximumLenght'] = 30;
$_web_config['nameAllowedLetters'] = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789";
$_web_config['passwordMinimumLenght'] = 1;
$_web_config['passwordMaximumLenght'] = 30;
$_web_config['passwordAllowedLetters'] = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789";
$_web_config['oneAccountPerMail'] = false;
$_web_config['formSize'] = 25;
$_web_config['sendMailWithLogin'] = false;
$_web_config['showServerRules'] = true;
$_web_config['serverRulesCols'] = 40;
$_web_config['serverRulesRows'] = 20;
$_web_config['newAccountGroupId'] = 1;
?>
 
gesior will the new AAC have e-mail validation option? PLEASE ADD THIS AND IT WILL BE EPIC! no more noobs making 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 accounts :D
 
gesior will the new AAC have e-mail validation option? PLEASE ADD THIS AND IT WILL BE EPIC! no more noobs making 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 accounts :D

This!
 
gesior will the new AAC have e-mail validation option? PLEASE ADD THIS AND IT WILL BE EPIC! no more noobs making 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 accounts :D

Agreed, and a fully working 'Lost Account'
 
gesior will the new AAC have e-mail validation option? PLEASE ADD THIS AND IT WILL BE EPIC! no more noobs making 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 accounts :D
Maybe... it's very simple to add. Just edit Visitor::login() and add there information about 'verification' required. Script server e-mail with password and account name to new registered users, so you need only add there link with verification code.

There will be old images generator and recaptcha [all in config]. I think that recaptcha is enought hard to break to block all noob 'auto account creators'.

I modified google recaptcha lib. Now it's class 'Recaptcha' with static functions:
Recaptcha::getImageHTML(); - return HTML code or throw Error_critic if something bad with website config [cannot show image]
Recaptcha::didUserSentCode(); - return true/false, check $_POST
Recaptcha::isValidCode(); - return true/false
createtableform.png

Code that check if user sent valid code:
PHP:
	if($errors->isErrorsListEmpty() && $createAccountConfig->isSetKey('useVerifyImage') && $createAccountConfig->getValue('useVerifyImage') && (!Recaptcha::didUserSentCode() || !Recaptcha::isValidCode()))
		$errors->addError('', 'Invalid <b>code from image</b>');
Code that show image:
PHP:
	if($createAccountConfig->isSetKey('useVerifyImage') && $createAccountConfig->getValue('useVerifyImage'))
	{
		$row = new TableRow();
		$cell = new TableCell();
		$cell->setColSpan(2);
		$cell->setContent(Recaptcha::getImageHTML());
		$row->addCell($cell);
		$table->addRow($row);
	}
hey,

Could you make it possible to use otserv with gesior.


Regards
Black Pearl
I think it will be very easy to make it work with 0.2, 0.3, 0.4 (or other sources, for example otserv [otserver should be compatible with one of TFS]) by editing Account, Group and Player classes.
 
Last edited:
I don't mean an auto acc maker, I mean fake accounts with fake e-mails :D with that we can even get rid off of the captcha system
 
email sender and some small array with data about so called 5 minutes emails(of course they can make mails that will be abandoned or sth but its still better)
 
Back
Top