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

Premium days when creating acc on hp

Norix

Hosting Service !
Joined
Jan 18, 2008
Messages
544
Reaction score
8
Location
Germany
hi
i have a question. i use tfs mystic spirit and i wanna have, that all players have 7 days premium at beginning, when they creat an account on the homepage, but not infine...
i tried to change the standart in the db, but it doesnt work because it changes to 0 after some seconds... i think that u must change sth in the account_create.php file if you know nicaw aac...
plz help....
 
<?php
/*
Copyright (C) 2007 Nicaw

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
include ("../include.inc.php");

//retrieve post data
$form = new Form('newaccount');
//check if any data was submited
if ($form->exists()){
//image verification
if ($form->validated()){
//email formating rules
if (AAC::ValidEmail($form->attrs['email'])){
$account = new Account();
$account->setAttr('accno', (int)$form->attrs['number']);
if (AAC::ValidAccountNumber($form->attrs['number']) && !$account->exists()){
//set account atrributes
$accno = $account->getAttr('accno');
if ($form->attrs['password'] == $form->attrs['confirm'] && AAC::ValidPassword($form->attrs['password']))
$password = $form->attrs['password'];
else
$password = substr(str_shuffle('qwertyuipasdfhjklzxcvbnm123456789'), 0, 6);
$account->setPassword($password);
$account->setAttr('email',$form->attrs['email']);
//create the account
$account->save();

if ($cfg['Email_Validate']){
$body = "Here is your login information for <a href=\"http://$cfg[server_url]/\">$cfg[server_name]</a><br/>
<b>Account number:</b> $accno<br/>
<b>Password:</b> $password<br/>
<br/>
Powered by <a href=\"http://nicaw.net/\">Nicaw AAC</a>";
//send the email
require("../phpmailer/class.phpmailer.php");

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->Host = $cfg['SMTP_Host'];
$mail->Port = $cfg['SMTP_Port'];
$mail->SMTPAuth = $cfg['SMTP_Auth'];
$mail->Username = $cfg['SMTP_User'];
$mail->Password = $cfg['SMTP_Password'];

$mail->From = $cfg['SMTP_From'];
$mail->AddAddress($form->attrs['email']);

$mail->Subject = $cfg['server_name'].' - Login Details';
$mail->Body = $body;

if ($mail->Send())
$success = 'Your login details were emailed to '.$form->attrs['email'];
else
$error = "Mailer Error: " . $mail->ErrorInfo;

}else{
$success ='Please write down your login information:<br/>
Account number: <b>'.$accno.'</b><br/>
Password: <b>'.$password.'</b><br/>
You can now login into your account and start creating characters.<br/>';
$account->logAction('Created');
}
}else $error = 'Invalid account number';
}else $error = 'Invalid email address';
}else $error = 'Image verification failed';
if (!empty($error)){
//create new message
$msg = new IOBox('message');
$msg->addMsg($error);
$msg->addReload('<< Back');
$msg->addClose('OK');
$msg->show();
}elseif (!empty($success)){
//create new message
$msg = new IOBox('message');
$msg->addMsg($success);
$msg->addClose('Finish');
$msg->show();
}
}else{
//create new form
$form = new IOBox('newaccount');
$form->target = $_SERVER['PHP_SELF'];
$form->addLabel('Create Accsount');
$form->addInput('number');
if (!$cfg['Email_Validate']){
$form->addInput('password','password');
$form->addInput('confirm','password');
}
$form->addInput('email');
$form->addCaptcha();
$form->addClose('Cancel');
$form->addSubmit('Next >>');
$form->show();
}?>
and i think u need the account.php fiel from the class folder to understand it abit more..
<?php
/*
Copyright (C) 2007 - 2008 Nicaw

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class Account extends SQL
{
private $attrs;
public $players;

public function __construct()
{
parent::__construct();
}

public function load($id)
{
if (!is_numeric($id)) return false;
//load attributes from database
$acc = $this->myRetrieve('accounts', array('id' => $id));
$nicaw_acc = $this->myRetrieve('nicaw_accounts', array('account_id' => $id));
if ($acc === false){
if ($this->exists())
throw new Exception('Cannot load existing account:<br/>'.$this->getError());
return false;
}
//arranging attributes, ones on the left will be used all over the aac
$this->attrs['accno'] = (int) $acc['id'];
$this->attrs['password'] = (string) $acc['password'];
$this->attrs['email'] = (string) $acc['email'];
$this->attrs['rlname'] = $nicaw_acc['rlname'];
$this->attrs['location'] = $nicaw_acc['location'];
$this->attrs['comment'] = $nicaw_acc['comment'];
$this->attrs['recovery_key'] = $nicaw_acc['recovery_key'];
if ($acc['premdays'] > 0) $this->attrs['premend'] = $acc['premdays']*24*3600 + time();
elseif ($acc['premEnd'] > 0) $this->attrs['premend'] = $acc['premEnd'];
//get characters of this account
$this->myQuery('SELECT players.id, players.name FROM players WHERE (`account_id`='.$this->quote($this->attrs['accno']).')');
if ($this->failed()) throw new Exception($this->getError());
while ($a = $this->fetch_array()){
$this->players[] = array('name' => $a['name'], 'id' => $a['id']);
}
//good, now we have all attributes stored in object
return true;
}

public function save()
{
$acc['id'] = $this->attrs['accno'];
$acc['password'] = $this->attrs['password'];
$acc['email'] = $this->attrs['email'];
$nicaw_acc['account_id'] = $this->attrs['accno'];
$nicaw_acc['rlname'] = $this->attrs['rlname'];
$nicaw_acc['location'] = $this->attrs['location'];
$nicaw_acc['comment'] = $this->attrs['comment'];
$nicaw_acc['recovery_key'] = $this->attrs['recovery_key'];

if (!$this->myReplace('nicaw_accounts',$nicaw_acc))
throw new Exception('Cannot save account:<br/>'.$this->getError());

if ($this->exists()){
if (!$this->myUpdate('accounts',$acc, array('id' => $this->attrs['accno'])))
throw new Exception('Cannot save account:<br/>'.$this->getError());
}else{
if (!$this->myInsert('accounts',$acc))
throw new Exception('Cannot save account:<br/>'.$this->getError());
}
return true;
}

public function getAttr($attr)
{
return $this->attrs[$attr];
}

public function setAttr($attr,$value)
{
$this->attrs[$attr] = $value;
}

public function setPassword($new)
{global $cfg;
$new = $new.$cfg['password_salt'];
if ($cfg['password_type'] == 'md5')
$new = md5($new);
elseif ($cfg['password_type'] == 'sha1')
$new = sha1($new);
if (empty($new)) throw new Exception('Empty password is not allowed.');
$this->attrs['password'] = $new;
}

public function checkPassword($pass)
{global $cfg;
$pass = $pass.$cfg['password_salt'];
if ($cfg['password_type'] == 'md5'){
$pass = md5($pass);
}elseif ($cfg['password_type'] == 'sha1'){
$pass = sha1($pass);
}elseif ($cfg['password_type'] == 'plain'){
}else throw new Exception('Unknow password encoding.');
return $this->attrs['password'] == (string)$pass && !empty($pass);
}

public function exists()
{
$this->myQuery('SELECT * FROM `accounts` WHERE `id` = '.$this->quote($this->attrs['accno']));
if ($this->failed()) throw new Exception('Account::exists() cannot determine whether account exists');
if ($this->num_rows() > 0) return true;
return false;
}

public function logAction($action)
{
$this->myQuery('INSERT INTO `nicaw_account_logs` (id, ip, account_id, date, action) VALUES(NULL, INET_ATON('.$this->quote($_SERVER['REMOTE_ADDR']).'), '.$this->quote($this->attrs['accno']).', UNIX_TIMESTAMP(NOW()), '.$this->quote($action).')');
if ($this->failed())
throw new Exception($this->getError());
}

public function removeRecoveryKey()
{
$this->attrs['recovery_key'] = NULL;
}

public function addRecoveryKey()
{
$this->attrs['recovery_key'] = substr(str_shuffle(md5(mt_rand()).md5(time())), 0, 32);
$this->logAction('Recovery key added');
return $this->attrs['recovery_key'];
}

public function checkRecoveryKey($key)
{
return $this->attrs['recovery_key'] === $key && !empty($key);
}

public function vote($option)
{
$this->myQuery('INSERT INTO `nicaw_poll_votes` (option_id, ip, account_id) VALUES('.$this->quote($option).', INET_ATON('.$this->quote($_SERVER['REMOTE_ADDR']).'), '.$this->quote($this->attrs['accno']).')');
if ($this->failed())
throw new Exception($this->getError());
}

public function getMaxLevel()
{
$this->myQuery('SELECT MAX(level) AS maxlevel FROM `players` WHERE `account_id` = '.$this->quote($this->attrs['accno']));
if ($this->failed())
throw new Exception($this->getError);
$row = $this->fetch_array();
return (int) $row['maxlevel'];
}

public function canVote($option)
{
$query = 'SELECT nicaw_polls.id FROM nicaw_polls, nicaw_poll_options
WHERE nicaw_polls.id = nicaw_poll_options.poll_id
AND nicaw_poll_options.id = '.$this->quote($option).'
AND '.$this->quote($this->getMaxLevel()).' > minlevel
AND nicaw_polls.startdate < UNIX_TIMESTAMP(NOW())
AND nicaw_polls.enddate > UNIX_TIMESTAMP(NOW())';
$this->myQuery($query);
if ($this->failed())
throw new Exception($this->getError);
if ($this->num_rows() == 0) return false;
if ($this->num_rows() > 1) throw new Exception('Unexpected SQL answer.');
$a = $this->fetch_array();
$poll_id = $a['id'];
$query = 'SELECT * FROM nicaw_poll_votes, nicaw_poll_options
WHERE nicaw_poll_options.poll_id = '.$this->quote($poll_id).'
AND nicaw_poll_options.id = nicaw_poll_votes.option_id
AND (account_id = '.$this->quote($this->attrs['accno']).' OR ip = INET_ATON('.$this->quote($_SERVER['REMOTE_ADDR']).')
)';
$this->myQuery($query);
if ($this->failed())
throw new Exception($this->getError);
if ($this->num_rows() == 0) return true;
elseif ($this->num_rows() == 1) return false;
else throw new Exception('Unexpected SQL answer.');
}
}
?>
 
I can't see the part where he updates the database =S

O_O

account.php class

PHP:
if ($acc['premdays'] > 0) $this->attrs['premend'] = $acc['premdays']*24*3600 + time();
elseif ($acc['premEnd'] > 0) $this->attrs['premend'] = $acc['premEnd'];

Im not sure thats what you wanted.
 
so noone knows how to do it?
maybe it could be sth like this
$account->setAttr('email',$form->attrs['email']); only with pacc days
but dunno xD
 
I'm more looking for a line like this:

Code:
$sql = "INSERT INTO accounts(id, password, type, premdays, lastday, email, rlname, location, hide, hidemail) values('$account','". mysql_real_escape_string($password) ."','1','$prem_days','0','". mysql_real_escape_string($mail) ."','". mysql_real_escape_string($rlname) ."','". mysql_real_escape_string($location) ."','$show','$hidemail')";
    mysql_query($sql);

$prem_days need to be changed to 7 then.
 
oh no dont wanna change acc. i changed some things. i already changed serv to tfs and that was some work..
 
ok i have made it different. i set a creaturescript when loggin in first time. still thx for help
 
Man you don't need to do it!
just add with every new player 1cc at the begin and let he buy it with his self ^^
 
Back
Top