JDDC PHP multi send mail script PHP 

Experienced Elementalist
Joined
Aug 16, 2010
Messages
240
Reaction score
23
This is a multi mail script that allows you to send multiple mail to one recipiant, by just updating the item_id array, its bad for me to explain but... I hope the code will help, ask questions here if you need me :)

Code:
<?php

$ServerIP = 'server IP';
$ServerGPort = '29100';


function encode($str){
  $arr = mbStringToArray($str);
  $str = '' ;
  foreach($arr as $a){
   $str .=  unicharCodeAt($a) ;
  }
  return $str ;
 }

 function mbStringToArray ($string,$encode="UTF-8") {
     $strlen = mb_strlen($string);
     while ($strlen) {
         $array[] = mb_substr($string,0,1,$encode);
         $string = mb_substr($string,1,$strlen,$encode);
         $strlen = mb_strlen($string);
     }
     return $array;
 }
 
 function unicharCodeAt($unichar){
  $abc = base_convert(uniord($unichar),10,16) ;
  if (strlen($abc) == 4){
   return substr($abc,2,2).substr($abc,0,2);
  }else {
   if (strlen($abc)==3){
    $ttt = '0'.$abc;
    return substr($ttt,2,2).substr($ttt,0,2);
   }else {
    return $abc.'00';
   }
  }
 }

function uniord($c) {
     $h = ord($c{0});
     if ($h <= 0x7F) {
         return $h;
     } else if ($h < 0xC2) {
         return false;
     } else if ($h <= 0xDF) {
         return ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F);
     } else if ($h <= 0xEF) {
         return ($h & 0x0F) << 12 | (ord($c{1}) & 0x3F) << 6
                                  | (ord($c{2}) & 0x3F);
     } else if ($h <= 0xF4) {
         return ($h & 0x0F) << 18 | (ord($c{1}) & 0x3F) << 12
                                  | (ord($c{2}) & 0x3F) << 6
                                  | (ord($c{3}) & 0x3F);
     } else {
         return false;
     }
 }

function hh_to_hex($hh,$n,$high=TRUE){  
  $len_hex_n = base_convert($hh,10,16);
  $len_hex_n_len = strlen($len_hex_n);
  if ($n < $len_hex_n_len){
   $r = '';
   for ($i=0;$i<$n;$i++){
    $r .= '0';
   }
   $the_hex = $r;
  }else {
   if ($len_hex_n_len == $n){
    $the_hex = $len_hex_n;
   }else {
    $r = '';
    $t = $n-$len_hex_n_len;
    for ($i=1;$i<=$t;$i++){
     $r .= '0';
    }
    $the_hex = $r.$len_hex_n;
   }
  }
  if ($high){
   return $the_hex;
  }else {
   $c_time = $n/2;
   $the_hex_c = '';
   for ($i=1;$i<=$c_time;$i++){
    $start = 0 - $i*2;
    $the_hex_c .= substr($the_hex,$start,2);
   }
   return $the_hex_c;
  }
 }
 


function send_gmail($role,$title,$Content,$ItemID,$ItemNum,$cost,$acc_name,$toonx_name){
  global $ServerIP,$ServerGPort;
   $Roleid_hex=hh_to_hex($role,8);
   $sss =      [USER=1333431411]Socket[/USER]_create(AF_INET, SOCK_STREAM, SOL_TCP);
   if ($sss == false) {
	return FALSE;
	
    //exit('Start TCP connect Filed<br>');
   }
        [USER=1333431411]Socket[/USER]_set_option($sss, SOL_SOCKET,SO_RCVTIMEO, array('sec'=>3,'usec'=>0));
   if (      [USER=1333431411]Socket[/USER]_connect($sss, $ServerIP, $ServerGPort)){
    return FALSE;
	
	//exit('can not connect Game  Make sure you open the game');
   }
   
   $title_hex=encode($title);
   $title_len=strlen($title_hex)/2;
   $title_len_hex=hh_to_hex($title_len,2);
   
   $content_hex=encode($Content);
   $content_len=strlen($content_hex)/2;
   if($content_len>=128){
    $content_len.=32768;
    $contnet_len_hex=hh_to_hex($content_len,4);
   }
   else $contnet_len_hex=hh_to_hex($content_len,2);
   
   $item_hex=hh_to_hex($ItemID,8);
   $item_num=hh_to_hex($ItemNum,8);
   $item_hex=$item_hex."00000000".$item_num.$item_num."000000000000000000000000000000000000000000";
   $senddata="800000060000040003".$Roleid_hex.$title_len_hex.$title_hex.$contnet_len_hex.$content_hex.$item_hex;
   $senddata_hex_lenth=hh_to_hex(strlen($senddata)/2,2);
   $senddata='9076'.$senddata_hex_lenth.$senddata; 
   
   MySQL_Query("INSERT INTO smail_log (`roleid`, `toon`, `name`, `itemid`, `amount`, `time`, `cost`) VALUES ('".$role."', '".$toonx_name."', '".$acc_name."', '".$ItemID."', '".$ItemNum."', CURRENT_TIMESTAMP, '".$cost."')");
  socket_write($sss,pack('H*',$senddata));
 
  return TRUE;
 }
 
//who will you send it to?
$char_id = 1136;

//Heading of the mail.
$title ='GM';

//Message to be written, keep it short or mail wont go.
$content = 'GM';

//For each item you add, add a array index incremented from the last number to the left.  # => item_id
$ItemID = array(1 => 42064,
				2 => 19681,
				3 => 42578,
				4 => 42579,
				5 => 58293,
				6 => 3507,
				7 => 16552);
				
$count = count($ItemID);
$amount = 1;
$cost = 0;
$acc_name = 'GM';
$toonx_name = 'Gengar';
$i = 0;

//this will run as much times as you have items in the $ItemID array.
while($i < $count){

	$i++;
	
	send_gmail($char_id,$title,$Content,$ItemID[$i],$amount,$cost,$acc_name,$toonx_name);
	
}

?>

Forgot input fields

<?php
include("your_mail_func.php");

if(isset($_POST['send_mail'])){

$role = mysql_real_escape_string($_POST['id']);
$title = 'GM';
$Content = 'Congratulations';
$ItemID = mysql_real_escape_string($_POST['item_id']);
$ItemNum = mysql_real_escape_string($_POST['item_num']);
$cost = 0;
$acc_name = mysql_real_escape_string($_POST['gm']);

$t_sql = mysql_query("SELECT * FROM dynasty.base WHERE id = '".$role."'");

$toon = mysql_fetch_assoc($t_sql);

if($toon){

$p_sql = mysql_query("SELECT * FROM dynasty.users WHERE ID = '".$toon['akkid']."'");

$player = mysql_fetch_assoc($p_sql);

if($player){

$toonx_name = $toon['name'];

echo send_gmail($role,$title,$Content,$ItemID,$ItemNum,$cost,$acc_name,$toonx_name);

}
else{

echo '<script>alert("Sorry but this Toon isn\'t linked to any known accounts.");</script>';

}

}
else{

echo '<script>alert("Sorry but this Toon does not exist.");</script>';

}

}

?>

<form method="post">
<input type='number' value='' name='id' placeholder='Character ID'>
<input type='number' value='' name='item_id' placeholder='Item ID'>
<input type='number' value='' name='item_num' placeholder='Amount'>
<input type='text' value='' name='gm' placeholder='GM name'>
<button type="submit" name="send_mail">Send Mail</button>
</form>



<center>
Sword of God 16552
Song of Antipathy 15762
+20 Talisman 3995
GS Sword (almost as good) 29900
&GM DMG Add-on 13380 modo only
¤Nothing Suit GM¤ 13300 human only
Ring 13299 human only
¤Huge Mantou GM¤ 13298 human only
¤Kiwi Fruit Helm GM¤ 13297 human only
¤Forrest's Footwear GM¤ 13296 human only
¤Best Shell GM¤ 13295 human only
GM Item Box 42064
Taichi Pills 58293
Gives GM skills 3507
5000 banknote 19681
GM Fashion♀ 42578
GM Fashion♂ 42579
</center>

amazing :) thanks you so much... that good.



How to know name db?
PHP:
$t_sql = mysql_query("SELECT * FROM dynasty.base WHERE id = '".$role."'");

$toon = mysql_fetch_assoc($t_sql);

if($toon){

$p_sql = mysql_query("SELECT * FROM dynasty.users WHERE ID = '".$toon['akkid']."'");

$player = mysql_fetch_assoc($p_sql);
[\PHP]
And server_ip. Should me use 127.0.0.1 port 29400 or 29100?
Thanks you so much[/QUOTE]
Server IP = 'localhost' AKA 127.0.0.1
Port is 29100

Base table is the table to update character's to, which Ill release soon.

Credit's
Send Gmail: comper & ragaone.com & mcncc.com
Items: Kas
Script: teamremod.com
 
Last edited:
amazing :) thanks you so much... that good.



How to know name db?
PHP:
$t_sql = mysql_query("SELECT * FROM dynasty.base WHERE id = '".$role."'");

$toon = mysql_fetch_assoc($t_sql);

if($toon){

$p_sql = mysql_query("SELECT * FROM dynasty.users WHERE ID = '".$toon['akkid']."'");

$player = mysql_fetch_assoc($p_sql);
[\PHP]
And server_ip. Should me use 127.0.0.1 port 29400 or 29100?
Thanks you so much
 
do you have a script that alows you to send items from website ? i mean , for players to buy items fro website and they revice it on they chars ?
 
Back