WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.216.32
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/src/Service/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/src/Service/SMS.php
<?php
/**
 * Created by PhpStorm.
 * User: komu
 * Date: 17/04/19
 * Time: 22:10
 */

namespace App\Service;


use AfricasTalking\SDK\AfricasTalking;
use App\Entity\Invoice;
use App\Entity\Messages;
use App\Entity\Page;
use App\Entity\Payment;
use App\Entity\Resource;
use App\Entity\Settting;
use App\Entity\Spectralsample;
use Doctrine\ORM\EntityManager;

use Symfony\Component\Routing\Router;

class SMS
{
    private $em;
    private $router;
    private $sms;

    public function __construct( EntityManager $em ,Router $router,$api_username,$api_key) {
        $this->em    = $em;
        $this->router    = $router;
        $AT       = new AfricasTalking($api_username, $api_key);
        $this->sms      = $AT->sms();

    }

    public function send($number,$text){

        $result   = $this->sms->send([
            'to'      => $number,
            'message' => $text,
            'from' => 'Sura_Images'
        ]);

        $sent = true;
        /**
         *            (
        [0] => stdClass Object
        (
        [cost] => KES 0.8000
        [messageId] => ATXid_db910ccfbf7cfb2b08bb8c1e1e1a0427
        [messageParts] => 1
        [number] => +254724006689
        [status] => Success
        [statusCode] => 101
        )

        )
         */
        if($result['status']=='success'){
            $desc=$result['data']->SMSMessageData->Message;
            $Recipients=$result['data']->SMSMessageData->Recipients;
            foreach ($Recipients as $Recipient){
                if(!isset($Recipient->messageParts))
                {
                    $sent = false;
                    return $sent;
                }
                $msg= new Messages();
                $msg->setMessageId($Recipient->messageId);
                $msg->setMessageParts($Recipient->messageParts);

                $msg->setPhoneNumber($Recipient->number);
                $msg->setStatus($Recipient->status);
                $msg->setStatusCode($Recipient->statusCode);
                $msg->setContent($text);
                $msg->setCost($Recipient->cost);
                $this->em->persist($msg);
            }
            $this->em->flush();

        }
        return $sent;
    }




}

Youez - 2016 - github.com/yon3zu
LinuXploit