Advertisement
Guest User

Untitled

a guest
Sep 8th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. function add() {
  2.     global $db,$ir,$h;
  3.         if(array_key_exists('add',$_POST)) {
  4.             $msg = isset($_POST['msg']) && is_string($_POST['msg']) ? stripslashes($_POST['msg']) : '';
  5.             if(empty($msg))
  6.                 echo "Invalid Input.";
  7.             else if(!preg_match('/^[a-z0-9 .\-]+$/i', $msg))
  8.                 echo "You can only allow spaces numbers and letters in your Message.";
  9.             else if(strlen($msg) < 2 || strlen($msg) > 100)
  10.                 echo "Your message must be greater than 2 characters and less than 100 you used ".strlen($msg);
  11.             else { 
  12.                 $total = 100 * strlen($msg);
  13.                 if($ir['money'] < $total)
  14.                     echo "You don't have enough money you need ".money_formatter($total - $ir['money'])." more.";
  15.                 else {
  16.                     $db->query("UPDATE `users` SET `money` = `money` - {$total} WHERE `userid` = ".$ir['userid']);
  17.                     $db->query("INSERT INTO `ads` (`aPOSTER`,`aMSG`,`aTIME`)
  18.                         VALUES ({$ir['userid']},'".$db->escape($msg)."',".time().")");
  19.                     echo "You have paid ".money_formatter($total)." for your ad. It will last for 15 minutes.";
  20.                 }
  21.             }
  22.         }
  23.         else {
  24.             echo "
  25.             <form method='post'>
  26.                 <table width='75%' style='text-align:center;' cellspacing='1'>
  27.                     <tr><th>Post A Advertisement</th></tr>
  28.                     <tr><td><strong>Posting a ad will cost you $100 per character including spaces</strong></td></tr>
  29.                     <tr><td>Message: <input id='adcost' type='text' name='msg' /> <span id='chars'>$0</span></td></tr>
  30.                     <tr><td><input type='submit' name='add' value='Add Message' /></td></tr>
  31.                 </table>
  32.             </form>";
  33.        }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement