Tanya sms gateway


Status
Not open for further replies.
kalo saya pake script mail to sms. smsgateway dipasang di hp android yang secara berkala check alamat email tertentu (misal [email protected]). script kirim sms dipasang di hook.
Format kirim email ke [email protected] (subject = nomor tujuan sms, body = pesan sms)
Bagus kayaknya, tapi gak tau gimana prakteknya :24: coba lebih detail pasti jos. :D
 
pake versi free atau yg donasi pak?
ada contoh script yg untuk integrasi ke whmcs gak pak? :D
sy pake yang FREE

script yg saya buat spt ini

Code:
<?php
// Modif

if (!defined("WHMCS"))
     die("This file cannot be accessed directly");

function add62($nomorhp){
     $nomorhp =" ".$nomorhp;
     $nomorhp = str_replace(" 0","62", $nomorhp);
     $nomorhp = str_replace(" 62","62", $nomorhp);
     return $nomorhp;
}   

function getoprhp($nomorhp){
     if (substr($nomorhp,0,2) != "62"){
      $nomorhp = add62($nomorhp);
     }
     $oprcode = substr($nomorhp,0,5);
     $tsel = array("62811","62812","62813","62821","62822","62823","62851","62852","62853");
     $xlcom = array("62817","62818","62819","62859","62877","62878");
     $isat = array("62855","62856","62857","62858","62814","62815","62816");
     $three = array("62896","62897","62898","62899");
     $axis = array("62811","62812","62813","62821","62822","62823","62851","62852","62853");
     if (in_array($oprcode, $tsel)){
      return "Telkomsel";
     } elseif (in_array($oprcode, $xlcom)){
      return "XL";
     } elseif (in_array($oprcode, $isat)){
      return "Indosat";
     } elseif (in_array($oprcode, $three)){
      return "Three";
     } else return "lainnya";
}



function hook_sms_mail_sent($vars) {
     // Ambil Nama template email dan ID email
     $namatemplate = $vars['messagename'];
     $relid = $vars['relid'];
     $headers = 'From: [email protected]' . "\r\n" .
                'Reply-To: [email protected]' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();


     /* 
     *****************************************
     *            INVOICE CREATED            *
     *****************************************/

     if ( $namatemplate == "Invoice Created"){
          $invoiceid = $relid;
	      

          $table = "tblinvoices";
          $fields = "id,userid,total";
          $where = array("id"=>$relid);
          $result = select_query($table,$fields,$where);
          $data = mysql_fetch_array($result);
          $userid = $data['userid'];
          $totalamount = $data['total'];
          $totalamount = substr($totalamount,0,strlen($totalamount)-3);
	  $last3dgt = substr($invoiceid,strlen($invoiceid)-3,3);
	  $angkaunik = $totalamount + $last3dgt;

          $table = "tblclients";
          $fields = "id,firstname,lastname,email,phonenumber,currency";
          $where = array("id"=>$userid);
          $result = select_query($table,$fields,$where);
          $data = mysql_fetch_array($result);
          $fullname = $data['firstname']." ".$data['lastname'];
          $phone = $data['phonenumber'];
          $clientmail = $data['email'];
          $oprhp = getoprhp($phone);
	  $curID = $data['currency'];
          // $phone = add62($phone);

	  $table = "tblcurrencies";
	  $fields = "id,code,prefix";
	  $where = array("id"=>$curID);
	  $result = select_query($table,$fields,$where);
	  $data = mysql_fetch_array($result);
	  $curr = $data['prefix'];
	  $currcode = $data['code'];

          $pesan1   = "Dear ".$fullname.",\n";
          $pesan1  .= "INVOICE-". $invoiceid."\n";
	  $pesan1  .= $curr." ".$totalamount."\n";
	  if (currcode =="IDR"){
	  $pesan1  .= "Angka Unik: Rp ".$angkaunik."\n";
	  } 
	 

          $pesan1  .= "Angka Unik: Rp ".$angkaunik."\n";
	  $pesan1  .= "Transfer ke:\n";
          $pesan1  .= "BCA: 1122334455\n";
          $pesan1  .= "MANDIRI:156-000-000-000-1\n";
          $pesan1  .= "an: Tanto Prihartanto\n\n";
          $pesan1  .= "Thanks,\n";
          $pesan1  .= "BESTARIWEBHOST";
          $pesan2 = "Telah terkirim invoice-".$invoiceid." ke ".$phone." (".$oprhp.") Email ".$clientmail.". Atas nama ".$fullname." Sebesar Rp ".$totalamount;
          //kirimsms($phone,$pesan1);
          mail("[email protected]",$phone,$pesan1,$headers);
          mail("[email protected]","081297153571",$pesan2,$headers);

          

     } elseif ( $namatemplate == "Invoice Payment Confirmation"){ 

     /****************************************
           INVOICE PAYMENT CONFIRMATION      
     *****************************************/

     // tulis script payment confirmation sms disini
         
     } elseif ($namatemplate == "Service Suspension Notification") {

     /* 
     *****************************************
           SERVICE SUSPENSION NOTIFICATION      
     *****************************************/
    //tulis scriptnya disini
     } elseif ($namatemplate == "Hosting Account Welcome Email") {

     /* 
     *****************************************
           HOSTING WELCOME SMS      
     *****************************************/
     //tulis scriptnya disini
     } elseif ($namatemplate == "Email Hosting Welcome email") {

     /* 
     *****************************************
           EMAIL HOSTING WELCOME SMS      
     *****************************************/
     //tulis scriptnya disini

     } elseif ($namatemplate == "First Invoice Overdue Notice") {

     /* 
     *****************************************
          INVOICE OVERDUE      
     *****************************************/
     //tulis scriptnya disini

     } elseif ($namatemplate == "Invoice Payment Reminder") {
     /******************************************/
     /*     INVOICE PAYMENT REMINDER           */
     /******************************************/
     //tulis scriptnya disini
     
     } 

     $merge_fields = array();
     return $merge_fields;
}

 add_hook("EmailPreSend",1,"hook_sms_mail_sent");
?>
 
Status
Not open for further replies.
Back
Top