Plugin Directory

Changeset 3191034


Ignore:
Timestamp:
11/18/2024 09:19:53 AM (17 months ago)
Author:
netgsm
Message:

fancy new feature: now you can foo *and* bar at the same time

Location:
netgsm/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • netgsm/trunk/includes/netgsmsms.php

    r3119907 r3191034  
    1010    private $appkey = "63610054a66a4e22adeeae5f375b015f";
    1111
    12     public function __construct($usercode,$password,$title='', $TR_Char='') {     //WP USE
     12    public function __construct($usercode, $password, $title = '', $TR_Char = '')
     13    {     //WP USE
    1314        $this->usercode = trim($usercode);
    14         $a=0;
     15        $a = 0;
    1516        $this->password = $password;
    1617
     
    1819
    1920        $this->language = '';
    20         if ($TR_Char == 1){
     21        if ($TR_Char == 1) {
    2122            $this->language = "dil='TR'";
    2223        }
     
    2930    public function getStartDate()
    3031    {
    31         if ($this->startDate == ''){
     32        if ($this->startDate == '') {
    3233            return '';
    3334        }
     
    3536    }
    3637
    37     public function sendSMS($phone,$mesaj,$filter){       //WP USE
     38    public function sendSMS($phone, $mesaj, $filter)
     39    {       //WP USE
    3840        $phones = array();
    39         $parts = explode(',',$phone);
    40         foreach ($parts as $value){
    41            if($value!=''){
    42                array_push($phones,$value);
    43            }
    44         }
    45         $number ="";
    46         foreach ($phones as $value){
    47             $number .='<no>'.$value.'</no>';
     41        $parts = explode(',', $phone);
     42        foreach ($parts as $value) {
     43            if ($value != '') {
     44                array_push($phones, $value);
     45            }
     46        }
     47        $number = "";
     48        foreach ($phones as $value) {
     49            $number .= '<no>' . $value . '</no>';
    4850        }
    4951
    5052        $PostAdress = 'https://api.netgsm.com.tr/sms/send/xml';
    51         $xml=array('body'=>'<?xml version="1.0" encoding="UTF-8"?>
     53        $xml = array('body' => '<?xml version="1.0" encoding="UTF-8"?>
    5254                            <mainbody>
    5355                                <header>
    54                                     <company wp="1" '.$this->language.'>NETGSM</company>
    55                                     <usercode>'.$this->usercode.'</usercode>
    56                                     <password>'.$this->password.'</password>
    57                                     <appkey>'.$this->appkey.'</appkey>
    58                                     <startdate>'.$this->getStartDate().'</startdate>
     56                                    <company wp="1" ' . $this->language . '>NETGSM</company>
     57                                    <usercode>' . $this->usercode . '</usercode>
     58                                    <password>' . $this->password . '</password>
     59                                    <appkey>' . $this->appkey . '</appkey>
     60                                    <startdate>' . $this->getStartDate() . '</startdate>
    5961                                    <stopdate></stopdate>
    6062                                    <type>1:n</type>
    61                                     <msgheader>'.$this->title.'</msgheader>
    62                                     <filter>'.$filter.'</filter>
     63                                    <msgheader>' . $this->title . '</msgheader>
     64                                    <filter>' . $filter . '</filter>
    6365                                </header>
    6466                                <body>
    65                                     <msg><![CDATA['.$mesaj.']]></msg>
    66                                     '.$number.'
     67                                    <msg><![CDATA[' . $mesaj . ']]></msg>
     68                                    ' . $number . '
    6769                                </body>
    6870                            </mainbody>');
    69         $response = wp_remote_post($PostAdress, $xml );
     71        $response = wp_remote_post($PostAdress, $xml);
    7072        return $this->smsCevap($this->responseDecoder($response)['body']);
    7173    }
     
    7577     * otp sms gönderimi
    7678     */
    77     public function sendOTPSMS($phone, $message){
     79    public function sendOTPSMS($phone, $message)
     80    {
    7881        $request_url = 'https://api.netgsm.com.tr/sms/send/otp';
    79         $xml = array('body'=> '<?xml version="1.0"?>
     82        $xml = array(
     83            'body' => '<?xml version="1.0"?>
    8084                                <mainbody>
    8185                                    <header>
    82                                         <usercode>'.$this->usercode.'</usercode>
    83                                         <password>'.$this->password.'</password>
    84                                         <appkey>'.$this->appkey.'</appkey>
    85                                         <msgheader>'.$this->title.'</msgheader>
     86                                        <usercode>' . $this->usercode . '</usercode>
     87                                        <password>' . $this->password . '</password>
     88                                        <appkey>' . $this->appkey . '</appkey>
     89                                        <msgheader>' . $this->title . '</msgheader>
    8690                                    </header>
    8791                                    <body>
    88                                         <msg><![CDATA['.substr($message,0,150).']]></msg>
    89                                         <no>'.$phone.'</no>
     92                                        <msg><![CDATA[' . substr($message, 0, 150) . ']]></msg>
     93                                        <no>' . $phone . '</no>
    9094                                    </body>
    9195                                </mainbody>'
     
    9599    }
    96100
    97     public function sendBulkSMS($data, $filter) {      //WP USE
     101    public function sendBulkSMS($data, $filter)
     102    {      //WP USE
    98103        $PostAdress     = 'https://api.netgsm.com.tr/sms/send/xml';
    99         $xml            =array('body'=> '<?xml version="1.0" encoding="UTF-8"?>
     104        $xml            = array('body' => '<?xml version="1.0" encoding="UTF-8"?>
    100105                                            <mainbody>
    101106                                              <header>
    102                                                 <company wp="1" '.$this->language.'>Netgsm</company>
    103                                                     <usercode>'.$this->usercode.'</usercode>
    104                                                     <password>'.$this->password.'</password>
    105                                                     <appkey>'.$this->appkey.'</appkey>
     107                                                <company wp="1" ' . $this->language . '>Netgsm</company>
     108                                                    <usercode>' . $this->usercode . '</usercode>
     109                                                    <password>' . $this->password . '</password>
     110                                                    <appkey>' . $this->appkey . '</appkey>
    106111                                                    <startdate></startdate>
    107112                                                    <stopdate></stopdate>
    108113                                                    <type>n:n</type>
    109                                                     <msgheader>'.$this->title.'</msgheader>
    110                                                     <filter>'.$filter.'</filter>
     114                                                    <msgheader>' . $this->title . '</msgheader>
     115                                                    <filter>' . $filter . '</filter>
    111116                                                    </header>
    112117                                                <body>
    113                                                   '.$data.'</body>
     118                                                  ' . $data . '</body>
    114119                                            </mainbody>');
    115120        $response = wp_remote_post($PostAdress, $xml);
     
    118123    }
    119124
    120     public function xmlCevap($input){
     125    public function xmlCevap($input)
     126    {
    121127        $code = explode('<code>', $input);
    122128        $code = explode('</code>', $code[1]);
     
    124130    }
    125131
    126     public function smsCevap($input) {        //WP USE
     132    public function smsCevap($input)
     133    {        //WP USE
    127134        $response = explode(' ', $input);
    128135        if ($response[0] == '00' || $response[0] == '02') {
    129             $result = array('durum' => 1, 'kod'=>$response[0], 'gorevid'=>$response[1], 'mesaj' => 'Mesaj Gönderimi Başarılı.');
    130         }
    131         elseif ($response[0] == '20') {
    132             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Mesaj metninde ki problemden dolayı gönderilemediğini veya standart maksimum mesaj karakter sayısını geçtiğini ifade eder. ');
    133         }
    134         elseif ($response[0] == '30') {
    135             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.
     136            $result = array('durum' => 1, 'kod' => $response[0], 'gorevid' => $response[1], 'mesaj' => 'Mesaj Gönderimi Başarılı.');
     137        } elseif ($response[0] == '20') {
     138            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Mesaj metninde ki problemden dolayı gönderilemediğini veya standart maksimum mesaj karakter sayısını geçtiğini ifade eder. ');
     139        } elseif ($response[0] == '30') {
     140            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.
    136141Ayrıca eğer API erişiminizde IP sınırlaması yaptıysanız ve sınırladığınız ip dışında gönderim sağlıyorsanız 30 hata kodunu alırsınız. API erişim izninizi veya IP sınırlamanızı , web arayüzümüzden; sağ üst köşede bulunan ayarlar> API işlemleri menüsunden kontrol edebilirsiniz.');
    137         }
    138         elseif ($response[0] == '40') {
    139             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Mesaj başlığınızın (gönderici adınızın) sistemde tanımlı olmadığını ifade eder. Gönderici adlarınızı API ile sorgulayarak kontrol edebilirsiniz.');
    140         }elseif ($response[0] == '50') {
    141             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Gönderilen numarayı kontrol ediniz.');
    142         }elseif ($response[0] == '51') {
    143             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Tanımlı İYS marka bilgisi bulunamadı, kontrol ediniz.');
    144         }
    145         elseif ($response[0] == '60') {
    146             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Hesabınızda OTP SMS Paketi tanımlı değildir, kontrol ediniz.');
     142        } elseif ($response[0] == '40') {
     143            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Mesaj başlığınızın (gönderici adınızın) sistemde tanımlı olmadığını ifade eder. Gönderici adlarınızı API ile sorgulayarak kontrol edebilirsiniz.');
     144        } elseif ($response[0] == '50') {
     145            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Gönderilen numarayı kontrol ediniz.');
     146        } elseif ($response[0] == '51') {
     147            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Tanımlı İYS marka bilgisi bulunamadı, kontrol ediniz.');
     148        } elseif ($response[0] == '60') {
     149            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Hesabınızda OTP SMS Paketi tanımlı değildir, kontrol ediniz.');
    147150        } elseif ($response[0] == '70') {
    148             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan birinin eksik olduğunu ifade eder.');
     151            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan birinin eksik olduğunu ifade eder.');
    149152        } elseif ($response[0] == '80') {
    150             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Sorgulama sınır aşımı.(dakikada 100 adet gönderim yapılabilir.)');
    151         }
    152         else {
    153             $result = array('durum' => 0, 'kod'=>$response[0],  'mesaj' => 'Bilinmeyen bir hatadan dolayı mesaj gönderilemedi.');
     153            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Sorgulama sınır aşımı.(dakikada 100 adet gönderim yapılabilir.)');
     154        } else {
     155            $result = array('durum' => 0, 'kod' => $response[0],  'mesaj' => 'Bilinmeyen bir hatadan dolayı mesaj gönderilemedi.');
    154156        }
    155157        return $result;
    156158    }
    157159
    158     public function getSmsBaslik(){     //WP USE
    159         $PostAdress = "https://api.netgsm.com.tr/sms/header/get/?usercode=$this->usercode&password=$this->password&appkey=".$this->appkey;
     160    public function getSmsBaslik()
     161    {     //WP USE
     162        $PostAdress = "https://api.netgsm.com.tr/sms/header/get/?usercode=$this->usercode&password=$this->password&appkey=" . $this->appkey;
    160163        $result = wp_remote_get($PostAdress);
    161164        return $this->getSmsBaslikSonuc($this->responseDecoder($result)['body']);
    162165    }
    163166
    164     private function getSmsBaslikSonuc($response){
    165         if($response==30){
     167    private function getSmsBaslikSonuc($response)
     168    {
     169        if ($response == 30) {
    166170            return 'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.
    167171Ayrıca eğer API erişiminizde IP sınırlaması yaptıysanız ve sınırladığınız ip dışında gönderim sağlıyorsanız 30 hata kodunu alırsınız. API erişim izninizi veya IP sınırlamanızı , web arayüzümüzden; sağ üst köşede bulunan ayarlar> API işlemleri menüsunden kontrol edebilirsiniz.';
    168         }else{
    169             $result = explode('<br>',$response);
     172        } else {
     173            $result = explode('<br>', $response);
    170174            return $result;
    171175        }
    172176    }
    173177
    174     private function getKrediSonuc($data){
    175         $response = explode(' ',$data);
     178    private function getKrediSonuc($data)
     179    {
     180        $response = explode(' ', $data);
    176181        $errorCode = $response[0];
    177         if($errorCode==30){
     182        if ($errorCode == 30) {
    178183            $result = '30Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.
    179184Ayrıca eğer API erişiminizde IP sınırlaması yaptıysanız ve sınırladığınız ip dışında gönderim sağlıyorsanız 30 hata kodunu alırsınız. API erişim izninizi veya IP sınırlamanızı , web arayüzümüzden; sağ üst köşede bulunan ayarlar> API işlemleri menüsunden kontrol edebilirsiniz.';
    180         }elseif($errorCode==40){
     185        } elseif ($errorCode == 40) {
    181186            $result = '40Arama kriterlerinize göre listelenecek kayıt olmadığını ifade eder.';
    182         }elseif($errorCode==70){
     187        } elseif ($errorCode == 70) {
    183188            $result = '70Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan birinin eksik olduğunu ifade eder.';
    184         }else{
    185             $result = '99'.$response[1];
     189        } else {
     190            $result = '99' . $response[1];
    186191        }
    187192        return $result;
    188193    }
    189194
    190     public function addContact($first_name, $last_name, $phone, $groupname = 'Müşteriler', $tags = []) {   //WP USE
    191         $xml = array('body'=>'<?xml version="1.0" encoding="iso-8859-9"?>
    192         <main>
    193             <usercode>'.$this->usercode.'</usercode>
    194             <pwd>'.$this->password.'</pwd>
    195             <appkey>'.$this->appkey.'</appkey>
    196             <grup>'.$groupname.'</grup>
    197             <tel>
    198                 <ad><![CDATA['.$first_name.']]></ad>
    199                 <soyad><![CDATA['.$last_name.']]></soyad>
    200                 <telefon><![CDATA['.$phone.']]></telefon>
    201                 '.
    202             (isset($tags['aciklama'])?'<aciklama><![CDATA['.$tags['aciklama'].']]></aciklama>
    203 ':'') .
    204             (isset($tags['hitap'])?'                <hitap><![CDATA['.$tags['hitap'].']]></hitap>
    205 ':'') .
    206             (isset($tags['tckimlik'])?'                <tckimlik><![CDATA['.$tags['tckimlik'].']]></tckimlik>
    207 ':'') .
    208             (isset($tags['dtarih'])?'                <dtarih><![CDATA['.$tags['dtarih'].']]></dtarih>
    209 ':'') .
    210             (isset($tags['etarih'])?'                <etarih><![CDATA['.$tags['etarih'].']]></etarih>
    211 ':'') .
    212             (isset($tags['unvan'])?'                <unvan><![CDATA['.$tags['unvan'].']]></unvan>
    213 ':'') .
    214             (isset($tags['email'])?'                <email><![CDATA['.$tags['email'].']]></email>
    215 ':'') .
    216             (isset($tags['sabittel'])?'                <sabittel><![CDATA['.$tags['sabittel'].']]></sabittel>
    217 ':'') .
    218             (isset($tags['faxtel'])?'                <faxtel><![CDATA['.$tags['faxtel'].']]></faxtel>
    219 ':'') .
    220             (isset($tags['cinsiyet'])?'                <cinsiyet><![CDATA['.$tags['cinsiyet'].']]></cinsiyet>
    221 ':'') .
    222             (isset($tags['kangrubu'])?'                <kangrubu><![CDATA['.$tags['kangrubu'].']]></kangrubu>
    223 ':'') .
    224             (isset($tags['ulke'])?'                <ulke><![CDATA['.$tags['ulke'].']]></ulke>
    225 ':'') .
    226             (isset($tags['sehir'])?'                <sehir><![CDATA['.$tags['sehir'].']]></sehir>
    227 ':'') .
    228             (isset($tags['sokak'])?'                <sokak><![CDATA['.$tags['sokak'].']]></sokak>
    229 ':'') .
    230             (isset($tags['ekbilgi1'])?'                <ekbilgi1><![CDATA['.$tags['ekbilgi1'].']]></ekbilgi1>
    231 ':'') .
    232             (isset($tags['ekbilgi2'])?'                <ekbilgi2><![CDATA['.$tags['ekbilgi2'].']]></ekbilgi2>
    233 ':'') .
    234             (isset($tags['ekbilgi3'])?'                <ekbilgi3><![CDATA['.$tags['ekbilgi3'].']]></ekbilgi3>
    235 ':'') .
    236             (isset($tags['semt'])?'                <semt><![CDATA['.$tags['semt'].']]></semt>':'')
    237 
    238             .'
    239             </tel>
    240         </main>');
    241         $response = wp_remote_post( 'http://api.netgsm.com.tr/contacts/group/add', $xml );
    242         if (file_exists('tags.txt')) {
    243             unlink('tags.txt');
    244         }
    245         return $this->responseDecoder($response)['body'];
    246     }
    247 
    248     public function netgsm_GetKredi($user,$pass) {     //WP USE
    249         $response = wp_remote_get( "https://api.netgsm.com.tr/get_kredi.asp?usercode=$user&password=$pass&appkey=".$this->appkey );
     195   
     196
     197    public function netgsm_GetKredi($user, $pass)
     198    {     //WP USE
     199        $response = wp_remote_get("https://api.netgsm.com.tr/get_kredi.asp?usercode=$user&password=$pass&appkey=" . $this->appkey);
    250200        $data = explode(' ', $this->responseDecoder($response)['body']);
    251         if($data[0]!='30') {
    252             if(isset($data[2]) && isset($data[2])=='AdetSMS')
     201        if ($data[0] != '30') {
     202            if (isset($data[2]) && isset($data[2]) == 'AdetSMS')
    253203                $tip = 'SMS';
    254204            else
    255205                $tip = 'Kredi';
    256206            if ($data[1] > 0) {
    257                 $result = array('giris'=>'success', 'durum' => 'success', 'mesaj'=>'', 'kredi' => $data[1], 'tipmsj' => ' Kalan '.$tip);
     207                $result = array('giris' => 'success', 'durum' => 'success', 'mesaj' => '', 'kredi' => $data[1], 'tipmsj' => ' Kalan ' . $tip);
    258208            } else {
    259                 $result = array('giris'=>'success', 'durum' => 'warning', 'mesaj'=>' Bakiye Satın Al',  'kredi' => $data[1],  'tipmsj' => ' Kalan '.$tip);
    260             }
    261         }
    262         else{
    263             $result = array('giris'=>'error', 'durum'=>'error', 'mesaj'=>'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.');
     209                $result = array('giris' => 'success', 'durum' => 'warning', 'mesaj' => ' Bakiye Satın Al',  'kredi' => $data[1],  'tipmsj' => ' Kalan ' . $tip);
     210            }
     211        } else {
     212            $result = array('giris' => 'error', 'durum' => 'error', 'mesaj' => 'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.');
    264213        }
    265214        return $result;
    266215    }
    267216
    268     public function netgsm_GetPaket($user,$pass) {     //WP USE
    269         $response = wp_remote_get( "https://api.netgsm.com.tr/get_kredi.asp?usercode=$user&password=$pass&tip=1&appkey=".$this->appkey );
     217    public function netgsm_GetPaket($user, $pass)
     218    {     //WP USE
     219        $response = wp_remote_get("https://api.netgsm.com.tr/get_kredi.asp?usercode=$user&password=$pass&tip=1&appkey=" . $this->appkey);
    270220        $data = explode(' ', $this->responseDecoder($response)['body']);
    271         if($data[0]=='30') {
    272             $result = array('giris'=>'error', 'durum'=>'error', 'mesaj'=>'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.');
    273         }
    274         elseif ($data[0]=='40') {
    275             $result = array('giris'=>'success', 'durum'=>'error', 'mesaj'=>'Arama kriterlerinize göre listelenecek kayıt olmadığını ifade eder.');
    276         }
    277         else {
     221        if ($data[0] == '30') {
     222            $result = array('giris' => 'error', 'durum' => 'error', 'mesaj' => 'Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.');
     223        } elseif ($data[0] == '40') {
     224            $result = array('giris' => 'success', 'durum' => 'error', 'mesaj' => 'Arama kriterlerinize göre listelenecek kayıt olmadığını ifade eder.');
     225        } else {
    278226            if ($data[0] > 0) {
    279                 $result = array('giris'=>'success', 'durum' => 'success', 'mesaj'=>'', 'kredi' => $data[0], 'tipmsj' => ' Kalan SMS'); // sms
    280             }
    281             else{
    282                 $result = array('giris'=>'success', 'durum' => 'warning', 'mesaj'=>' Bakiye Satın Al', 'kredi' => $data[0], 'tipmsj' => ' Kalan SMS');
     227                $result = array('giris' => 'success', 'durum' => 'success', 'mesaj' => '', 'kredi' => $data[0], 'tipmsj' => ' Kalan SMS'); // sms
     228            } else {
     229                $result = array('giris' => 'success', 'durum' => 'warning', 'mesaj' => ' Bakiye Satın Al', 'kredi' => $data[0], 'tipmsj' => ' Kalan SMS');
    283230            }
    284231        }
     
    286233    }
    287234
    288     public function netgsm_GirisSorgula($user,$pass)    //WP USE
    289     {
    290         $response = $this->netgsm_GetKredi($user,$pass);
    291         if($response['giris']=='success') {     //Giriş Başarılı
    292             if($response['durum']=='success') {  //kredi varsa
    293                 $result = array('durum' => 'success',
     235    public function netgsm_GirisSorgula($user, $pass)    //WP USE
     236    {
     237        $response = $this->netgsm_GetKredi($user, $pass);
     238        if ($response['giris'] == 'success') {     //Giriş Başarılı
     239            if ($response['durum'] == 'success') {  //kredi varsa
     240                $result = array(
     241                    'durum' => 'success',
    294242                    'icon' => 'fa-chech',
    295                     'mesaj' => $response['tipmsj']." : ".$response['kredi'],
    296                     'btnkontrol'=>'enabled',
    297                     'href'=>'' );
    298             }
    299             else{ //kredi yoksa
    300                 $getpackage = $this->netgsm_GetPaket($user,$pass);
    301                 if($getpackage['giris']=='success') {    //giriş başarılı
    302                     if($getpackage['durum']=='success') {  //kredi varsa
    303                         $result = array('durum' => 'success',
     243                    'mesaj' => $response['tipmsj'] . " : " . $response['kredi'],
     244                    'btnkontrol' => 'enabled',
     245                    'href' => ''
     246                );
     247            } else { //kredi yoksa
     248                $getpackage = $this->netgsm_GetPaket($user, $pass);
     249                if ($getpackage['giris'] == 'success') {    //giriş başarılı
     250                    if ($getpackage['durum'] == 'success') {  //kredi varsa
     251                        $result = array(
     252                            'durum' => 'success',
    304253                            'icon' => 'fa-check',
    305                             'mesaj' => "<i class='fa fa-envelope-o'></i> ". ' SMS Bakiyeniz : '.$getpackage['kredi'],
    306                             'btnkontrol'=>'enabled',
    307                             'href'=>'' );
    308                     }
    309                     else { //kredi yoksa satın almaya yönlendir (Hem kredi hem paket yok.)
    310                         $result = array('durum' => 'warning',
     254                            'mesaj' => "<i class='fa fa-envelope-o'></i> " . ' SMS Bakiyeniz : ' . $getpackage['kredi'],
     255                            'btnkontrol' => 'enabled',
     256                            'href' => ''
     257                        );
     258                    } else { //kredi yoksa satın almaya yönlendir (Hem kredi hem paket yok.)
     259                        $result = array(
     260                            'durum' => 'warning',
    311261                            'icon' => 'fa-shopping-cart',
    312                             'mesaj' => ' Krediniz:'.$response['kredi'].'. Kredi satın al <i class=\'fa fa-external-link\'></i>',
    313                             'btnkontrol'=>'enabled',
    314                             'href'=>'https://www.netgsm.com.tr/webportal/satis_arayuzu/paketler.php' );
     262                            'mesaj' => ' Krediniz:' . $response['kredi'] . '. Kredi satın al <i class=\'fa fa-external-link\'></i>',
     263                            'btnkontrol' => 'enabled',
     264                            'href' => 'https://www.netgsm.com.tr/webportal/satis_arayuzu/paketler.php'
     265                        );
    315266                    }
    316267                }
    317268            }
    318         }
    319         else { // giriş başarısız
    320             if(empty($user) && !empty($pass))
    321                $message = " Kullanıcı adı alanı boş.";
     269        } else { // giriş başarısız
     270            if (empty($user) && !empty($pass))
     271                $message = " Kullanıcı adı alanı boş.";
    322272            elseif (empty($pass) && !empty($user))
    323273                $message = " Şifre alanı boş.";
     
    327277                $message = " Kullanıcı adı veya şifreniz hatalı.";
    328278            }
    329             $result = array('durum' => 'danger',
     279            $result = array(
     280                'durum' => 'danger',
    330281                'icon' => 'fa-exclamation-triangle',
    331282                'mesaj' => $message,
    332283                'btnkontrol' => 'disabled',
    333                 'href' => '');
     284                'href' => ''
     285            );
    334286        }
    335287        return json_encode($result);
    336288    }
    337289
    338     private function inboxResponse($data){
     290    private function inboxResponse($data)
     291    {
    339292        $result = array();
    340293        $result['status']  =  "400";
    341294        $i = 1;
    342         if($data == 30){
     295        if ($data == 30) {
    343296            $result['message'] = " Geçersiz kullanıcı adı , şifre veya kullanıcınızın API erişim izninin olmadığını gösterir.
    344297Ayrıca eğer API erişiminizde IP sınırlaması yaptıysanız ve sınırladığınız ip dışında gönderim sağlıyorsanız 30 hata kodunu alırsınız. API erişim izninizi veya IP sınırlamanızı , web arayüzümüzden; sağ üst köşede bulunan ayarlar> API işlemleri menüsunden kontrol edebilirsiniz.";
    345         }
    346         elseif ($data == 40){
     298        } elseif ($data == 40) {
    347299            $result['message'] = " Gösterilecek mesajınızın olmadığını ifade eder. Api ile mesajlarınızı eğer startdate ve stopdate parametlerini kullanmıyorsanız sadece bir kere listeyebilirsiniz. Listelenen mesajlar diğer sorgulamalarınızda gelmez.";
    348         }
    349         elseif ($data == 50){
     300        } elseif ($data == 50) {
    350301            $result['message'] = " Tarih formatı hatalıdır.";
    351         }
    352         elseif ($data == 51){
     302        } elseif ($data == 51) {
    353303            $result['message'] = " Tanımlı İYS marka kodu bilgisi bulunamadı.";
    354         }
    355         elseif ($data == 60){
     304        } elseif ($data == 60) {
    356305            $result['message'] = " Arama kiterlerindeki startdate ve stopdate zaman farkının 30 günden fazla olduğunu ifade eder.";
    357         }
    358         elseif ($data == 70){
     306        } elseif ($data == 70) {
    359307            $result['message'] = " Hatalı sorgulama. Gönderdiğiniz parametrelerden birisi hatalı veya zorunlu alanlardan birinin eksik olduğunu ifade eder.";
    360         }
    361         else {
     308        } else {
    362309            $parts = explode('<br>', $data);
    363310
     
    376323    }
    377324
    378     public function inbox(){
     325    public function inbox()
     326    {
    379327        $xml = array('body' => '<?xml version="1.0"?>
    380328                                    <mainbody>
    381329                                        <header>
    382330                                            <company>Netgsm</company>
    383                                             <usercode>'.$this->usercode.'</usercode>
    384                                             <password>'.$this->password.'</password>
    385                                             <appkey>'.$this->appkey.'</appkey>
    386                                             <startdate>'.date('dmYHi', time() - 60*60*24*30).'</startdate>
    387                                             <stopdate>'.date('dmYHi', time() + 60*60*24).'</stopdate>
     331                                            <usercode>' . $this->usercode . '</usercode>
     332                                            <password>' . $this->password . '</password>
     333                                            <appkey>' . $this->appkey . '</appkey>
     334                                            <startdate>' . date('dmYHi', time() - 60 * 60 * 24 * 30) . '</startdate>
     335                                            <stopdate>' . date('dmYHi', time() + 60 * 60 * 24) . '</stopdate>
    388336                                            <type>0</type>
    389337                                        </header>
    390338                                    </mainbody>');
    391         $response = wp_remote_post( 'https://api.netgsm.com.tr/sms/receive/xml', $xml );
     339        $response = wp_remote_post('https://api.netgsm.com.tr/sms/receive/xml', $xml);
    392340        return $this->inboxResponse($this->responseDecoder($response)['body']);
    393341    }
    394342
    395     public function phoneToUser($phone, $users){
     343    public function phoneToUser($phone, $users)
     344    {
    396345        $result = array();
    397346        foreach ($users as $user) {
    398             if($user->billing_phone==$phone){
     347            if ($user->billing_phone == $phone) {
    399348                $result = $user;
    400349                break;
    401             }
    402             else {
     350            } else {
    403351                $result = 0;
    404352            }
     
    414362    {
    415363        date_default_timezone_set('Europe/Istanbul');
    416         $startDate = date('dmYHi', time() - 60*60*24);
     364        $startDate = date('dmYHi', time() - 60 * 60 * 24);
    417365        $endDate = date('dmYHi', time());
    418366        $PostAdress = 'https://api.netgsm.com.tr/netsantral/report/xml';
     
    421369                <header>
    422370                    <company>Netgsm</company>
    423                     <usercode>".$this->usercode."</usercode>
    424                     <password>".$this->password."</password>
     371                    <usercode>" . $this->usercode . "</usercode>
     372                    <password>" . $this->password . "</password>
    425373                    <appkey>'.$this->appkey.'</appkey>
    426                     <startdate>".$startDate."</startdate>
    427                     <stopdate>".$endDate."</stopdate>
     374                    <startdate>" . $startDate . "</startdate>
     375                    <stopdate>" . $endDate . "</stopdate>
    428376                    <version>3</version>
    429377                </header>
    430378            </mainbody>");
    431         $results = wp_remote_post($PostAdress,$xml);
     379        $results = wp_remote_post($PostAdress, $xml);
    432380        $results = $this->responseDecoder($results)['body'];
    433381
    434         if ($results != '' && in_array(trim($results), [100,101])){
    435             $response = ['error'=>['code'=>trim($results), 'message'=>'Dakikada en fazla 2 kez sorgulanabilir.']];
    436             return json_encode($response,256);
    437         }
    438         if ($results != '' && in_array(trim($results), [40])){
    439             $response = ['error'=>['code'=>trim($results), 'message'=>'Son 24 saat içinde listelenecek kayıt yok.']];
    440             return json_encode($response,256);
    441         }
    442         if ($results != '' && in_array(trim($results), [30])){
    443             $response = ['error'=>['code'=>trim($results), 'message'=>'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izniniz yok.']];
    444             return json_encode($response,256);
    445         }
    446 
    447         if ($results != '' && in_array(trim($results), [50])){
    448             $response = ['error'=>['code'=>trim($results), 'message'=>'Tarih formatının hatalı.']];
    449             return json_encode($response,256);
    450         }
    451 
    452         if ($results != '' && in_array(trim($results), [60])){
    453             $response = ['error'=>['code'=>trim($results), 'message'=>'Zaman farkının 7 günden fazla']];
    454             return json_encode($response,256);
    455         }
    456 
    457         if ($results != '' && in_array(trim($results), [70])){
    458             $response = ['error'=>['code'=>trim($results), 'message'=>'Hatalı sorgulama.']];
    459             return json_encode($response,256);
    460         }
    461 
    462         if ($results != '' && in_array(trim($results), [80])){
    463             $response = ['error'=>['code'=>trim($results), 'message'=>'Netsantral hizmeti kullanılmıyor.']];
    464             return json_encode($response,256);
     382        if ($results != '' && in_array(trim($results), [100, 101])) {
     383            $response = ['error' => ['code' => trim($results), 'message' => 'Dakikada en fazla 2 kez sorgulanabilir.']];
     384            return json_encode($response, 256);
     385        }
     386        if ($results != '' && in_array(trim($results), [40])) {
     387            $response = ['error' => ['code' => trim($results), 'message' => 'Son 24 saat içinde listelenecek kayıt yok.']];
     388            return json_encode($response, 256);
     389        }
     390        if ($results != '' && in_array(trim($results), [30])) {
     391            $response = ['error' => ['code' => trim($results), 'message' => 'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izniniz yok.']];
     392            return json_encode($response, 256);
     393        }
     394
     395        if ($results != '' && in_array(trim($results), [50])) {
     396            $response = ['error' => ['code' => trim($results), 'message' => 'Tarih formatının hatalı.']];
     397            return json_encode($response, 256);
     398        }
     399
     400        if ($results != '' && in_array(trim($results), [60])) {
     401            $response = ['error' => ['code' => trim($results), 'message' => 'Zaman farkının 7 günden fazla']];
     402            return json_encode($response, 256);
     403        }
     404
     405        if ($results != '' && in_array(trim($results), [70])) {
     406            $response = ['error' => ['code' => trim($results), 'message' => 'Hatalı sorgulama.']];
     407            return json_encode($response, 256);
     408        }
     409
     410        if ($results != '' && in_array(trim($results), [80])) {
     411            $response = ['error' => ['code' => trim($results), 'message' => 'Netsantral hizmeti kullanılmıyor.']];
     412            return json_encode($response, 256);
    465413        }
    466414
     
    472420            $cdr = explode('|', $result);
    473421            $temp = [];
    474             if(isset($cdr[0]) && $cdr[0] != '') {
     422            if (isset($cdr[0]) && $cdr[0] != '') {
    475423                $temp['call_id'] = $cdr[0];
    476424                $temp['date'] = $cdr[1];
     
    483431            }
    484432        }
    485         $json['success'] = ['message'=>'Son 24 saatin kayıtları listeleniyor.'];
     433        $json['success'] = ['message' => 'Son 24 saatin kayıtları listeleniyor.'];
    486434        $json['data'] = $response;
    487435
    488         return json_encode($json,256);
     436        return json_encode($json, 256);
    489437    }
    490438
     
    496444    {
    497445        date_default_timezone_set('Europe/Istanbul');
    498         $startDate = date('dmYHi', time() - 60*60*24);
     446        $startDate = date('dmYHi', time() - 60 * 60 * 24);
    499447        $endDate = date('dmYHi', time());
    500448        $PostAdress = 'https://api.netgsm.com.tr/voice/report/xml';
     
    503451                <header>
    504452                    <company>Netgsm</company>
    505                     <usercode>".$this->usercode."</usercode>
    506                     <password>".$this->password."</password>
     453                    <usercode>" . $this->usercode . "</usercode>
     454                    <password>" . $this->password . "</password>
    507455                    <date></date>
    508456                    <direction>4</direction>
    509457                </header>
    510458            </mainbody>");
    511         $results = wp_remote_post($PostAdress,$xml);
     459        $results = wp_remote_post($PostAdress, $xml);
    512460        $results = $this->responseDecoder($results)['body'];
    513461
    514462
    515         if ($results != '' && in_array(trim($results), [100,101])){
    516             $response = ['error'=>['code'=>trim($results), 'message'=>'Dakikada en fazla 2 kez sorgulanabilir.']];
    517             return json_encode($response,256);
    518         }
    519         if ($results != '' && in_array(trim($results), [40])){
    520             $response = ['error'=>['code'=>trim($results), 'message'=>'Son 24 saat içinde listelenecek kayıt yok.']];
    521             return json_encode($response,256);
    522         }
    523         if ($results != '' && in_array(trim($results), [30])){
    524             $response = ['error'=>['code'=>trim($results), 'message'=>'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izniniz yok.']];
    525             return json_encode($response,256);
    526         }
    527 
    528         if ($results != '' && in_array(trim($results), [50])){
    529             $response = ['error'=>['code'=>trim($results), 'message'=>'Tarih formatının hatalı.']];
    530             return json_encode($response,256);
    531         }
    532 
    533         if ($results != '' && in_array(trim($results), [70])){
    534             $response = ['error'=>['code'=>trim($results), 'message'=>'Hatalı sorgulama.']];
    535             return json_encode($response,256);
     463        if ($results != '' && in_array(trim($results), [100, 101])) {
     464            $response = ['error' => ['code' => trim($results), 'message' => 'Dakikada en fazla 2 kez sorgulanabilir.']];
     465            return json_encode($response, 256);
     466        }
     467        if ($results != '' && in_array(trim($results), [40])) {
     468            $response = ['error' => ['code' => trim($results), 'message' => 'Son 24 saat içinde listelenecek kayıt yok.']];
     469            return json_encode($response, 256);
     470        }
     471        if ($results != '' && in_array(trim($results), [30])) {
     472            $response = ['error' => ['code' => trim($results), 'message' => 'Geçersiz kullanıcı adı, şifre veya kullanıcınızın API erişim izniniz yok.']];
     473            return json_encode($response, 256);
     474        }
     475
     476        if ($results != '' && in_array(trim($results), [50])) {
     477            $response = ['error' => ['code' => trim($results), 'message' => 'Tarih formatının hatalı.']];
     478            return json_encode($response, 256);
     479        }
     480
     481        if ($results != '' && in_array(trim($results), [70])) {
     482            $response = ['error' => ['code' => trim($results), 'message' => 'Hatalı sorgulama.']];
     483            return json_encode($response, 256);
    536484        }
    537485
     
    544492            $cdr = explode(' | ', $result);
    545493            $temp = [];
    546             if(isset($cdr[0]) && $cdr[0] != '') {
     494            if (isset($cdr[0]) && $cdr[0] != '') {
    547495                $temp['caller_number'] = $cdr[0];
    548496                $temp['date'] = $cdr[1];
     
    552500            }
    553501        }
    554         $json['success'] = ['message'=>'Bugünün kayıtları listeleniyor.'];
     502        $json['success'] = ['message' => 'Bugünün kayıtları listeleniyor.'];
    555503        $json['data'] = $response;
    556504
    557         return json_encode($json,256);
    558     }
    559 
    560     public function setContact($datas, $groupName = 'Opencart')
    561     {
    562         if (count($datas)>500){
    563             $contacts = array_chunk($datas, 500);
    564 
    565             foreach ($contacts as $key=>$contact) {
    566                 $this->addContacts($contact, $groupName);
    567             }
    568         } else {
    569             return $this->addContacts($datas, $groupName);
    570         }
    571         return true;
    572     }
    573 
    574 
    575 
    576     public function addContacts($datas, $groupName = 'Wordpress')
    577     {
    578         $body = '';
    579         $request_url = 'http://api.netgsm.com.tr/contacts/group/add';
    580         foreach ($datas as $data) {
    581             $telephone = $this->getphoneClear($data['telephone']);
    582             $body .= '<tel>
    583                 <ad><![CDATA['.$data['firstname'].']]></ad>
    584                 <soyad><![CDATA['.$data['lastname'].']]></soyad>
    585                 <telefon><![CDATA['.$telephone.']]></telefon>
    586             </tel>';
    587         }
    588 
    589 
    590         $xml = array('body'=> '<?xml version="1.0" encoding="iso-8859-9"?>
    591         <main>
    592             <usercode>'.$this->usercode.'</usercode>
    593             <pwd>'.$this->password.'</pwd>
    594             <appkey>'.$this->appkey.'</appkey>
    595             <grup>'.$groupName.'</grup>
    596            '.$body.'
    597         </main>');
    598 
    599         $response = wp_remote_post( $request_url, $xml );
    600         if (file_exists('tags.txt')) {
    601             unlink('tags.txt');
    602         }
    603         return $this->responseDecoder($response)['body'];
    604     }
    605 
    606     public function getphoneClear($phone){
    607         $unwanted = array(' ', '+', '(', ')', '.', '-', '&amp;', 'nbsp;'  );
    608         $replace    = array('', '', '', '', '', '', '', '' );
     505        return json_encode($json, 256);
     506    }
     507
     508   
     509
     510
     511
     512   
     513
     514    public function getphoneClear($phone)
     515    {
     516        $unwanted = array(' ', '+', '(', ')', '.', '-', '&amp;', 'nbsp;');
     517        $replace    = array('', '', '', '', '', '', '', '');
    609518        $result      = str_replace($unwanted, $replace, $phone);
    610519        return $result;
    611520    }
    612521
    613     public function timeconvert($time){
    614         if($time<60){
     522    public function timeconvert($time)
     523    {
     524        if ($time < 60) {
    615525            $second = ceil($time);
    616             if($second<10){
    617                 $second = '0'.$second;
    618             }
    619             return '00:00:'.$second;
    620         }
    621         $minute = floor($time/60);
    622         $second = $time%60;
    623         if($minute<60){
    624             if($minute<10){
    625                 $minute = '0'.$minute;
    626             }
    627             if($second<10){
    628                 $second = '0'.$second;
    629             }
    630             return '00:'.$minute.':'.$second;
    631         }
    632         $hour = floor($minute/60);
    633         $minute = $minute%60;
    634         if($hour<10){
    635             $hour = '0'.$hour;
    636         }
    637         if($minute<10){
    638             $minute = '0'.$minute;
    639         }
    640         if($second<10){
    641             $second = '0'.$second;
    642         }
    643         return $hour.':'.$minute.':'.$second;
     526            if ($second < 10) {
     527                $second = '0' . $second;
     528            }
     529            return '00:00:' . $second;
     530        }
     531        $minute = floor($time / 60);
     532        $second = $time % 60;
     533        if ($minute < 60) {
     534            if ($minute < 10) {
     535                $minute = '0' . $minute;
     536            }
     537            if ($second < 10) {
     538                $second = '0' . $second;
     539            }
     540            return '00:' . $minute . ':' . $second;
     541        }
     542        $hour = floor($minute / 60);
     543        $minute = $minute % 60;
     544        if ($hour < 10) {
     545            $hour = '0' . $hour;
     546        }
     547        if ($minute < 10) {
     548            $minute = '0' . $minute;
     549        }
     550        if ($second < 10) {
     551            $second = '0' . $second;
     552        }
     553        return $hour . ':' . $minute . ':' . $second;
    644554    }
    645555
    646556    private function responseDecoder($response)
    647557    {
    648         if (is_array($response) && !empty($response['body']))
    649         {
     558        if (is_array($response) && !empty($response['body'])) {
    650559            return $response;
    651560        }
     
    657566    public function iysadd($phone, $email, $date, $brandcode, $recipient_type, $type_array) //İYS'ye adres ekleme
    658567    {
    659         if($phone!='' || $email!='' ){
     568        if ($phone != '' || $email != '') {
    660569            $jsonarray = array(
    661570                "header" => array("username" => $this->usercode, "password" => $this->password, "brandCode" => $brandcode, "appkey" => $this->appkey),
    662571                "body" => array(
    663                     "data" => [
    664                     ]
    665                 ));
    666             foreach ($type_array as $typearray){
    667                 if ($typearray=='EPOSTA' && $email!=''){
    668                         $address = $email;
    669                         array_push($jsonarray['body']['data'], array(
    670                             "type" => $typearray,
    671                             "source" => "HS_WEB",
    672                             "recipient" => $address,
    673                             "status" => "ONAY",
    674                             "consentDate" => $date,
    675                             "recipientType" => $recipient_type
    676                         ));
     572                    "data" => []
     573                )
     574            );
     575            foreach ($type_array as $typearray) {
     576                if ($typearray == 'EPOSTA' && $email != '') {
     577                    $address = $email;
     578                    array_push($jsonarray['body']['data'], array(
     579                        "type" => $typearray,
     580                        "source" => "HS_WEB",
     581                        "recipient" => $address,
     582                        "status" => "ONAY",
     583                        "consentDate" => $date,
     584                        "recipientType" => $recipient_type
     585                    ));
    677586                }
    678                 if($typearray!='EPOSTA' && $phone!=''){
    679                         $address = $phone;
    680                         array_push($jsonarray['body']['data'], array(
    681                             "type" => $typearray,
    682                             "source" => "HS_WEB",
    683                             "recipient" => $address,
    684                             "status" => "ONAY",
    685                             "consentDate" => $date,
    686                             "recipientType" => $recipient_type
    687                         ));
    688 
     587                if ($typearray != 'EPOSTA' && $phone != '') {
     588                    $address = $phone;
     589                    array_push($jsonarray['body']['data'], array(
     590                        "type" => $typearray,
     591                        "source" => "HS_WEB",
     592                        "recipient" => $address,
     593                        "status" => "ONAY",
     594                        "consentDate" => $date,
     595                        "recipientType" => $recipient_type
     596                    ));
    689597                }
    690 
    691598            }
    692599
     
    700607            return $response;
    701608        }
    702 
    703     }
    704 
    705     public function netasistan_yenitoken($appkey,$userkey){
     609    }
     610
     611    public function netasistan_yenitoken($appkey, $userkey)
     612    {
    706613        $url = "http://www.netasistan.com/napi/v1/auth";
    707614        $response = wp_remote_post($url, array(
    708             'headers'   => array('Content-Type' => 'application/json; charset=utf-8',
    709                                  'app-key' => $appkey,
    710                                  'user-key' => $userkey
     615            'headers'   => array(
     616                'Content-Type' => 'application/json; charset=utf-8',
     617                'app-key' => $appkey,
     618                'user-key' => $userkey
    711619            ),
    712620            'sslverify' => FALSE,
     
    718626    }
    719627
    720     public function netasistan_ticket($ticket_name, $ticket_lastname, $ticket_number, $ticket_email, $ticket_header, $ticket_content,$ticket_etiketler, $token){
     628    public function netasistan_ticket($ticket_name, $ticket_lastname, $ticket_number, $ticket_email, $ticket_header, $ticket_content, $ticket_etiketler, $token)
     629    {
    721630
    722631        $jsonarray = array(
     
    733642        $url = "https://www.netasistan.com/napi/v1/ticket";
    734643        $response = wp_remote_post($url, array(
    735             'headers'   => array('Content-Type' => 'application/json; charset=utf-8',
    736                                   'username' => $this->usercode,
    737                                   'Authorization' => 'Bearer '.$token,
    738                                 ),
     644            'headers'   => array(
     645                'Content-Type' => 'application/json; charset=utf-8',
     646                'username' => $this->usercode,
     647                'Authorization' => 'Bearer ' . $token,
     648            ),
    739649            'sslverify' => FALSE,
    740650            'body'      => json_encode($jsonarray),
     
    743653
    744654        return $response;
    745 
    746655    }
    747656}
    748 
  • netgsm/trunk/index.php

    r3185627 r3191034  
    66Author: Netgsm
    77Author URI: www.netgsm.com.tr
    8 Version: 2.9.32
     8Version: 2.9.33
    99
    1010*/
     
    125125
    126126
    127 
    128         register_setting('netgsmoptions', 'netgsm_rehber_control');
    129         register_setting('netgsmoptions', 'netgsm_rehber_groupname');
    130127
    131128        register_setting('netgsmoptions', 'netgsm_orderstatus_change_customer_control');
     
    540537
    541538
    542             jQuery('#contactsMove').click(function () {
    543                 var groupName = jQuery('#contactsBulk').val();
    544                 if(groupName == ''){
    545                     swal({
    546                         title: "BAŞARISIZ!",
    547                         html: 'Aktarım için grup ismi girilmelidir.',
    548                         type: 'error',
    549                     });
    550                     return false;
    551                 }
    552                 showLoadingMessage('Kayıtlar aktarılıyor...');
    553                 var data = {
    554                     'action': 'netgsm_addtoGroup',
    555                     'copy' :1,
    556                     'groupName':groupName
    557                 };
    558                 jQuery.post(ajaxurl, data, function (response) {
    559                     var response = JSON.parse(response);
    560                     if (response['result']=='success') {
    561                         swal({
    562                             title: "BAŞARILI!",
    563                             html: response['resultmsg'],
    564                             type: response["result"],
    565                         });
    566                     }
    567                     else
    568                     {
    569                         swal({
    570                             title: "HATA!",
    571                             text:  response['resultmsg'],
    572                             type: response["result"],
    573                         });
    574                     }
    575                     hideLoadingMessage();
    576                 });
    577 
    578             })
     539           
    579540
    580541
     
    582543    }
    583544
    584     add_action( 'wp_ajax_netgsm_addtoGroup', 'netgsm_addtoGroup' );
    585     function netgsm_addtoGroup()
    586     {
    587         $users = get_users();
    588 
    589         $phone_meta = 'billing_phone';
    590         if (esc_html(get_option("netgsm_contact_meta_key") != '')){
    591             $phone_meta = esc_html(get_option("netgsm_contact_meta_key"));
    592         }
    593 
    594         $contacts = []; $tmp = [];
    595         foreach ($users as $result) {
    596             $tmp['telephone'] = sanitize_text_field(get_user_meta($result->ID, $phone_meta, true));
    597             if ($tmp['telephone'] == ''){
    598                 continue;
    599             }
    600            
    601             $tmp['firstname'] = sanitize_text_field($result->first_name);
    602             $tmp['lastname'] = sanitize_text_field($result->last_name);
    603 
    604             array_push($contacts, $tmp);
    605         }
    606 
    607         $netgsm = new Netgsmsms(sanitize_text_field(get_option("netgsm_user")), sanitize_text_field(get_option("netgsm_pass")), sanitize_text_field(get_option('netgsm_input_smstitle')), sanitize_text_field(get_option("netgsm_trChar")));
    608 
    609                 $groupName = 'Wordpress';
    610 
    611                 // Check if 'groupName' is set in POST request
    612                 if (isset($_POST['groupName'])) {
    613                     // Sanitize the input to remove harmful characters
    614                     $groupName = sanitize_text_field($_POST['groupName']);
    615                 }
    616 
    617 
    618                 // İşlem gerçekleştir
    619                 $moving = $netgsm->setContact($contacts, $groupName);
    620 
    621                 // JSON çıktısı verirken HTML etiketlerinden kaçının
    622                 $response = [
    623                     'result' => 'success',
    624                     'resultmsg' => sprintf(
    625                         'Toplam <b>%d</b> kullanıcı <b>%s</b> grubuna aktarıldı.',
    626                         count($contacts),
    627                         esc_html($groupName)
    628                     )
    629                 ];
    630 
    631                 echo json_encode($response);
    632                 wp_die();
    633             }
     545   
    634546
    635547    add_action( 'wp_ajax_netgsm_getNetsantral_Report', 'netgsm_getNetsantral_Report' );
     
    16551567    }
    16561568
    1657     function netgsm_add_contact($customer_id)
    1658     {
    1659         $grupcontrol    = esc_html(get_option('netgsm_rehber_control'));
    1660         $groupname      = esc_html(get_option('netgsm_rehber_groupname'));
    1661         $userinfo       = get_userdata($customer_id);
    1662         if(isset($grupcontrol) && !empty($grupcontrol) && $grupcontrol==1) {
    1663             $netgsm = new Netgsmsms(sanitize_text_field(get_option("netgsm_user")), sanitize_text_field(get_option("netgsm_pass")));
    1664             if($userinfo->first_name=="")
    1665                 $firstname = "nickname";
    1666             else
    1667                 $firstname = $userinfo->first_name;
    1668 
    1669             if($userinfo->last_name=="")
    1670                 $lastname = $userinfo->nickname;
    1671             else
    1672                 $lastname = $userinfo->last_name;
    1673             $replace = new ReplaceFunction();
    1674             $netgsm->addContact($firstname, $lastname, $replace->netgsm_spaceTrim($userinfo->billing_phone), $groupname);
    1675         }
    1676     }
     1569   
    16771570
    16781571    function netgsm_order_status_changed_sendSMS($order_id, $text, $this_status_transition_to)
     
    19761869                }
    19771870
    1978                 $contact_control = esc_html(get_option('netgsm_cf7_contact_control'));
    1979                 if (isset($contact_control) && !empty($contact_control) && $contact_control == 1) {
    1980                     $groupname = sanitize_text_field(get_option('netgsm_cf7_list_contact_' . $form_id));
    1981                     if ($groupname != '') {
    1982                         $netgsm = new Netgsmsms(get_option("netgsm_user"), get_option("netgsm_pass"));
    1983                         $firstname_key = sanitize_text_field(get_option('netgsm_cf7_list_contact_firstname_' . $form_id));
    1984                         $lastname_key = sanitize_text_field(get_option('netgsm_cf7_list_contact_lastname_' . $form_id));
    1985                         $other_keys = sanitize_text_field(get_option('netgsm_cf7_list_contact_other_' . $form_id));
    1986                         $firstname = $posted_data[$firstname_key];
    1987                         $lastname = $posted_data[$lastname_key];
    1988                         $phone_number = $posted_data['telephone'];
    1989 
    1990                         $others = explode(';', $other_keys);
    1991 
    1992                         $tags = [];
    1993                         foreach ($others as $other) {
    1994                             $item = explode(':', $other);
    1995                             $replace = new ReplaceFunction();
    1996                             $val = $replace->netgsm_cf7_replace_all_var($posted_data, $item[1]);
    1997                             $key = str_replace(['[',']'], "", $item[0]);
    1998                             $tags[$key] = $val;
    1999                         }
    2000 
    2001                         $netgsm->addContact($firstname, $lastname, $phone_number, $groupname, $tags);
    2002                     }
    2003                 }
     1871               
    20041872
    20051873            }
  • netgsm/trunk/pages/index.php

    r3185627 r3191034  
    985985                                            <p id="netgsm_tags_text7" style="display: none;">
    986986                                        </div>
    987                                         <div class="col-sm-9" id="netgsm_field7" style="<?php if ((get_option('netgsm_rehber_control')) != 1) { ?>display:none; <?php } ?>">
    988                                             <div class="row">
    989                                                 <div class="col-sm-12">
    990                                                     <div class="input-group">
    991                                                         <div class="input-group-addon">
    992                                                             <i class="fa fa-user-plus" style="color: #17A2B8;"></i>
    993                                                         </div>
    994                                                         <input name="netgsm_rehber_groupname" class="form-control" placeholder="Eklemek istediğiniz grup ismini giriniz." value="<?= esc_html(get_option("netgsm_rehber_groupname")) ?>">
    995                                                     </div>
    996                                                 </div>
    997                                             </div>
    998                                         </div>
     987                                       
    999988                                    </div>
    1000989                                </div>
  • netgsm/trunk/readme.txt

    r3185627 r3191034  
    55Requires at least: 3.0
    66Tested up to: 6.7
    7 Stable tag: 2.9.32
     7Stable tag: 2.9.33
    88Requires PHP: 8.0.1
    99License: GPLv2 or later
     
    8989
    9090== Changelog ==
     91= 2.9.33 =
     92* Hata düzeltmesi yapıldı.
    9193= 2.9.32 =
    9294* Hata düzeltmesi yapıldı.
Note: See TracChangeset for help on using the changeset viewer.