Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: PHP | Size: 1.90 KB | Hits: 76 | Expires: Never
Copy text to clipboard
  1. <?php
  2. defined('IN_EZRPG') or exit;
  3. class Module_SendMoney extends Base_Module
  4. {
  5.     public function start()
  6.     {
  7.         requireLogin();
  8.        
  9.         if (isset($_GET['act']))
  10.         {
  11.             if ($_GET['act'] == 'send')
  12.                 $this->send();
  13.             else
  14.                 $this->tpl->display('sendmoney.tpl');
  15.         }
  16.         else
  17.             $this->tpl->display('sendmoney.tpl');
  18.     }
  19.     private function send()
  20.     {
  21.         if (isset($_GET['Input']))
  22.         {
  23.                 if ($_GET['Input'] <=0)
  24.                 {
  25.                         Header('Location: index.php?mod=SendMoney&msg=' . urlencode('Your a broke dawg'));
  26.                         exit;
  27.                 }
  28.                 elseif (! preg_match('/^[0-9]{1,}/', $_GET["Input"]))
  29.                 {
  30.                                 Header('Location: index.php?mod=SendMoney&msg=' . urlencode('You tried to cheat'));
  31.                                 exit;
  32.                         }
  33.         }
  34.         elseif (!isset($_GET['id']))
  35.         {
  36.                 Header('Location: index.php?mod=SendMoney&msg=' . urlencode('You didnt pick anyone to send to'));
  37.                 exit;
  38.         }
  39.         else
  40.         {
  41.                 $receiver = $this->db->fetchRow('SELECT `id`, `username`, `level`, `hp`, `strength`, `damage`, `exp`, `money` FROM `<ezrpg>players` WHERE `id`=?', array( intval($_GET['id']) ));
  42.                 if ($receiver == false)
  43.                         {
  44.                             $msg='Player doesnt exist';
  45.                             header('Location: index.php?mod=SendMoney&msg=' . urlencode($msg));
  46.                             exit;
  47.                         }
  48.                         $input= $_GET['Input'];
  49.                         $sender = $this->player->username;
  50.                         $getter = $receiver->id;
  51.                         $smsg = '';
  52.                         $this->db->execute('UPDATE `<ezrpg>players` SET `money`=money-? WHERE `username`=?', array($input,$sender));
  53.                         $this->db->execute('UPDATE `<ezrpg>players` SET `money`=money+? WHERE `id`=?', array($input, $getter));
  54.                         $message = 'You have received:' . $input . 'From:' . $sender;
  55.                                 $new_log =              addLog($getter, $message, $db);
  56.         }
  57.     }
  58. }
  59. ?>