Guest User

123123123123

a guest
Dec 4th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. <?php
  2. /***********************************************************
  3. *   Sendmail function for Ascent/Arcemu
  4. *   by AXE
  5. *   this file is required for all cores
  6. ************************************************************/
  7.  
  8. /***********************************************************
  9. *        GLOBAL FUNCTIONS (required for all cores)
  10. ************************************************************/
  11. function sendmail($playername,$playerguid, $subject, $text, $item, $shopid=0, $money=0, $realmid=false) //returns, IMPORTANT: do not remove <!-- success --> if success
  12. {
  13.     //send normal, item only
  14.     global $db,$a_user,$db_translation;
  15.     $subject = preg_replace( "/[^A-Za-z0-9]/", "", $subject); //no whitespaces
  16.     $item = preg_replace( "/[^0-9]/", "", $item); //item id
  17.     $playerguid = preg_replace( "/[^0-9]/", "", $playerguid); //item id
  18.     $text = preg_replace( "/[^A-Za-z0-9!-:.? ]/", "", $text); //no whitespaces
  19.     $money= preg_replace( "/[^0-9]/", "", $money);
  20.    
  21.  
  22.  
  23.     if ($item=='')//send item
  24.         $item="0";
  25.     if ($money=='')
  26.         $money=0;
  27.    
  28.    
  29.    
  30.         $query_string ='INSERT INTO mail_external(sender, receiver, subject, message, money, stationery, sent) VALUES("'.$playerguid.'","'.$playerguid.'", "'.$subject.'", "'.$text.'", "'.$money.'", 0, 1)';
  31.         $sendmail=false;
  32.     $db->query($query_string) or ($sendmail=mysql_error());
  33.     //find mail id and add item
  34.     $sql1 = $db->query("SELECT id FROM mail_external WHERE subject='".$subject."' AND receiver='".$playerguid."' LIMIT 1")or ($sendmail.=mysql_error());
  35.     $sql2=$db->fetch_array($sql1);
  36.     if($sendmail==false && $sql2[0]<>'')
  37.         $db->query("INSERT INTO mail_external_items (mail_id,item) VALUES ('".$sql2[0]."','".$item."')") or ($sendmail.=mysql_error());
  38.     if($sendmail==false)
  39.         return  "<!-- success --><span class=\"colorgood\">Mail is sent! <br>All done!</span>";
  40.     else
  41.         return  "<span class=\"colorbad\">Mail is not sent! Error returned: ".$sendmail."<br>".$query_string;
  42.    
  43.  
  44. }
  45. function sendmail_secondpatch($playername,$playerguid, $subject, $text, $item, $shopid=0, $money=0, $realmid=false) //returns, IMPORTANT: do not remove <!-- success --> if success
  46. {
  47.     //send normal, item only
  48.     global $db,$a_user,$db_translation;
  49.     $subject = preg_replace( "/[^A-Za-z0-9]/", "", $subject); //no whitespaces
  50.     $item = preg_replace( "/[^0-9]/", "", $item); //item id
  51.     $playerguid = preg_replace( "/[^0-9]/", "", $playerguid); //item id
  52.     $text = preg_replace( "/[^A-Za-z0-9!-:.? ]/", "", $text); //no whitespaces
  53.     $money= preg_replace( "/[^0-9]/", "", $money);
  54.    
  55.  
  56.  
  57.     if ($item=='')//send item
  58.         $item="0";
  59.     if ($money=='')
  60.         $money=0;
  61.    
  62.    
  63.     $insert_data = array(
  64.             '%reciver%'     => $playerguid,
  65.             '%subject%'     => $db->escape($subject),
  66.             '%message%'     => $db->escape($text),
  67.             '%money%'       => $money,
  68.             '%item%'        => $item,
  69.             '%item_count%'  => 1
  70.         );
  71.         $query_string = strtr('INSERT INTO mail_external(receiver, subject, message, money, item, item_count) VALUES("%reciver%", "%subject%", "%message%", "%money%", %item%, %item_count%)', $insert_data);
  72.         $sendmail=false;
  73.     $db->query($query_string) or ($sendmail=mysql_error());
  74.     if($sendmail==false)
  75.         return  "<!-- success --><span class=\"colorgood\">Mail is sent! <br>All done!</span>";
  76.     else
  77.         return  "<span class=\"colorbad\">Mail is not sent! Error returned: ".$sendmail."<br>".$query_string;
  78.    
  79.  
  80. }
  81.  
  82. /*************************************************************
  83. *       NON GLOBAL FUNCTIONS (not required for other cores)
  84. **************************************************************/
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment