Untitled
By: a guest | Mar 21st, 2010 | Syntax:
PHP | Size: 1.90 KB | Hits: 76 | Expires: Never
<?php
defined('IN_EZRPG') or exit;
class Module_SendMoney extends Base_Module
{
public function start()
{
requireLogin();
if (isset($_GET['act']))
{
if ($_GET['act'] == 'send')
$this->send();
else
$this->tpl->display('sendmoney.tpl');
}
else
$this->tpl->display('sendmoney.tpl');
}
private function send()
{
if (isset($_GET['Input']))
{
if ($_GET['Input'] <=0)
{
Header('Location: index.php?mod=SendMoney&msg=' . urlencode('Your a broke dawg'));
exit;
}
elseif (! preg_match('/^[0-9]{1,}/', $_GET["Input"]))
{
Header('Location: index.php?mod=SendMoney&msg=' . urlencode('You tried to cheat'));
exit;
}
}
elseif (!isset($_GET['id']))
{
Header('Location: index.php?mod=SendMoney&msg=' . urlencode('You didnt pick anyone to send to'));
exit;
}
else
{
$receiver = $this->db->fetchRow('SELECT `id`, `username`, `level`, `hp`, `strength`, `damage`, `exp`, `money` FROM `<ezrpg>players` WHERE `id`=?', array( intval($_GET['id']) ));
if ($receiver == false)
{
$msg='Player doesnt exist';
header('Location: index.php?mod=SendMoney&msg=' . urlencode($msg));
exit;
}
$input= $_GET['Input'];
$sender = $this->player->username;
$getter = $receiver->id;
$smsg = '';
$this->db->execute('UPDATE `<ezrpg>players` SET `money`=money-? WHERE `username`=?', array($input,$sender));
$this->db->execute('UPDATE `<ezrpg>players` SET `money`=money+? WHERE `id`=?', array($input, $getter));
$message = 'You have received:' . $input . 'From:' . $sender;
$new_log = addLog($getter, $message, $db);
}
}
}
?>