Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Prima Recharge Script
- * Recharge Prima from
- * given postpaid number
- *
- * script migrated to smsapp.mtel.bg
- * cluster on date 19.01.2012 year
- *
- * Changes:
- * Added CRM Auto Notification log 19.01.2012 (i.stoyanov@mobiltel.bg)
- * Added recognition for 6 and 06 lv. on 26.01.2012 (i.stoyanov@mobiltel.bg)
- * Added Global Blacklist functionality on 30.01.2012
- * Changed M13 reply sms text via e-mail request from Zhulieta Blazheva (i.stoyanov@mobiltel.bg)
- * Due Shafran project sms texts change done on 30.08.2012
- */
- ini_set ( "max_execution_time", 100 ); # sets max_execution_time to bigger than default (30 sec) value.
- ini_set('soap.wsdl_cache_enabled', '0');
- define ( MAX_SMS_LEN, 160 ); //number of chars per SMS
- define ( INFO, "Za poveche informacia se obadete na 1010" );
- define ( M1, 'Zdraveyte, izpratili ste SMS s nekorektno sadarzhanie. Izpratete tekst "08XXXXXXXX,YY", kato 08XXXXXXXX e nomerat na karta za Predplatena usluga, a YY - suma za zarezhdane: 6, 10 ili 15' );
- define ( M2, "Zdraveyte, dostignahte limita za zarezhdane na karta za Predplatena usluga chrez SMS: do 1 zarezhdane na chas i do 2 na 24 chasa. Molya, opitayte otnovo po-kasno. A1" );
- define ( M3, "Zdraveyte, vazmozhnostta za zarezhdane na karta za Predplatena usluga chrez SMS se predlaga samo za klienti s dogovor. Za poveche informatsia: *88. A1" );
- define ( M4, "Zdraveyte, za da zaredite karta za Predplatena usluga chrez SMS, e neobhodimo da ste klient na A1 poveche ot 3 mesetsa. Molya, opitayte otnovo sled tozi srok. A1" );
- define ( M5, "Zdraveyte, dostignahte kreditnia limit za Vashia nomer i nyama vazmozhnost da zaredite karta za Predplatena usluga s posochenata suma. Za informatsia i po-visok limit: *88. A1" );
- define ( M6, "Zdraveyte, nomerat, koyto pozhelahte da zaredite, ne e karta za Predplatena usluga. Molya, proverete nomera i opitayte otnovo. A1" );
- define ( M7, "Zdraveyte, Vie zaredihte karta za Predplatena usluga nomer " );
- define ( M71, " s " );
- define ( M72, " lv. Tazi suma shte se otrazi v sledvashtata Vi mesechna smetka. A1" );
- define ( M8, "Your Prepaid service Card Has Just Been Recharged With YY BGN, VAT Inclusive, From Customer With Mobile Number " );
- define ( M9, "Zdraveyte, v momenta uslugata e nedostapna. Molya da ni izvinite! Mozhe da zaredite karta za Predplatena usluga, kato zakupite hartien vaucher. A1" );
- define ( M10, "Zdraveyte, Vashiyat nomer nyama vazmozhnost da zarezhda karta za Predplatena usluga chrez SMS. Za poveche informatsia: *88. A1" );
- define ( M11, "Zdraveyte, v momenta uslugata e nedostapna. Molya da ni izvinite! Mozhe da zaredite karta za Predplatena usluga, kato zakupite hartien vaucher. A1" );
- define ( M12, "Zdraveyte, Vie se otkazahte ot informatsionnite saobshtenia za niska suma po smetkata na nomera na karta za Predplatena usluga, koyto zarezhdate. Za da gi poluchavate otnovo: *88. A1" );
- define ( M13, 'Zdraveyte, izpratili ste SMS s nekorektno sadarzhanie. Izpratete tekst "08XXXXXXXX,YY", kato 08XXXXXXXX e nomerat na karta za Predplatena usluga, a YY - suma za zarezhdane: 6, 10 ili 15' );
- define ( M14, "Prez A1 Menu-to na telefona si mozhete da prezarezhdate karta za Predplatena usluga s 6, 10 ili 15 lv. Opitayte otnovo" );
- # before Shafran
- //define ( INFO, "Za poveche informacia se obadete na 1010" );
- //define ( M1, "Greshen format. Molya izpolzvayte sledniyat format: 088XXXXXXX,YY kadeto YY e stoynostta na sumata za zarezhdane - 6,10 ili 15. Blagodarim vi! Ekipat na Mtel." );
- //define ( M2, "Uvazhaemi klienti,Vie dostignahte limita si za zarezhdane - do 1 zarezhdane na chas, do 2 zarezhdania dnevno.Molya izchakayte i opitayte otnovo.Ekipat na Mtel." );
- //define ( M3, "Uvazhemi klienti, uslugata Zarezhdane na Prima chrez SMS mozhe da se izpolzva samo ot klienti na M-Tel s mesechen abonamenten dogovor. Ekipat na Mtel." );
- //define ( M4, "Zdraveyte,za da zarezhdate Prima chrez SMS, e neobhodimo da ste klient na M-Tel poveche ot 3 mesetsa.Molya opitayte otnovo,kogato tozi srok bade izpalnen.Mtel." );
- //define ( M5, "Uvazhaemi klienti, Vie dostignahte kreditnia si limit I zayavkata ne mozhe da bade izpalnena. Molya, uvelichete limita si na *88 ili vnesete depozit. Mtel." );
- //define ( M6, "Uvazhaemi klienti, nomerat, koyto ste posochili za zarezhdane, ne e klient na Prima. Molya opitayte otnovo. Ekipat na Mtel." );
- //define ( M7, "Uvazhaemi klienti, Vie uspeshno zaredihte Prima nomer " );
- //define ( M71, " s " );
- //define ( M72, " lv. s DDS. Tazi suma shte se otrazi v sledvashtata vi mesechna smetka.Ekipat na Mtel." );
- //define ( M8, "Your Prima Card Has Just Been Recharged With YY BGN, VAT Inclusive, From Customer With Mobile Number " );
- //define ( M9, "Uvazhaemi klienti, v momenta uslugata e nedostapna. Molya, opitayte po-kasno. Blagodarim Vi za razbiraneto. Ekipat na Mtel." );
- //define ( M10, "Uvazhaemi klienti, Vashiyat nomer ima zabrana za izpolzvane na uslugata Zarezhdane na Prima s SMS. Za poveche informatsia pozvanete na *88. Ekipat na Mtel." );
- //define ( M11, "Uslugata e vremenno nedostapna,molya opitayte otnovo sled 72 chasa.Mozhete da zaredite Prima kartata vednaga s hartien voucher. Blagodarim za razbiraneto!Mtel." );
- //define ( M12, "Zdraveyte, Vie uspeshno se otkazahte ot uslugata, koyato Vi informira za niska nalichnost po smetkata na nomera, koyto zarezhdate. Ekipat na Mtel" );
- //define ( M13, "Greshen format. Molya izpolzvayte slednia format: 088XXXXXXX,YY kadeto YY e stoynostta na sumata za zarezhdane - 6, 10 ili 15. Ekipat na Mtel" );
- //define ( M14, "Prez Mtel Menu-to na telefona si mozhete da prezarezhdate Prima s 6, 10 ili 15 lv. Opitayte otnovo" );
- # Get Subscriber type service WSDL
- define ('SUBSRIBER_TYPE_SERVICE_USER', 'subscrprd');
- define ('SUBSRIBER_TYPE_SERVICE_PASS', 'sub_prd');
- define ('SUBSRIBER_TYPE_SERVICE_WSDL','http://b2b.mtel.bg:8181/com_mtel_subscriber/Processes/Services/SubscriberService/Interface/SubscriberService.serviceagent?wsdl');
- define ( 'SUBSCRIBER_MESSAGING_SERVICE_UNIQUE_ID', 'dma_1616' . date ( "y" ) );
- # prod service config
- define ('SUBSCRIBER_MESSAGING_WSDL', 'https://soa.mtel.bg:9090/bs/SubscriberMessagingBS?wsdl' );
- define ('SUBSCRIBER_MESSAGING_LOCATION', 'https://soa.mtel.bg:9090/bs/SubscriberMessagingBS');
- define ('SUBSCRIBER_MESSAGING_LOGIN', 'soa');
- define ('SUBSCRIBER_MESSAGING_PASSWORD', 'mt3ls0@');
- #test service config
- //define ( 'SUBSCRIBER_MESSAGING_WSDL', 'https://soatest.mtel.bg:9090/bs/SubscriberMessagingBS?wsdl' );
- //define ( 'SUBSCRIBER_MESSAGING_LOCATION', 'https://soatest.mtel.bg:9090/bs/SubscriberMessagingBS' );
- //define ( 'SUBSCRIBER_MESSAGING_LOGIN', 'mtel' );
- //define ( 'SUBSCRIBER_MESSAGING_PASSWORD', 'password' );
- # configuration for pico-push page
- define ( 'PICO_PUSH_LOGIN','pbelev');
- define ( 'PICO_PUSH_USER', 'paFkaTa');
- define ( 'PICO_PUSH_WSDL', 'http://wsdl.mtel.bg/pico-push/?wsdl' );
- define ( 'PICO_PUSH_PAGE', 'MTEL_PRIMA_RECHARGE_LOCAL');
- # Web Service for Global Blacklist
- define ('GBL_SERVICE_USER', 'web1616' );
- define ('GBL_SERVICE_PASS', 'bgfseEW#');
- define ('GBL_SERVICE_WSDL', 'http://sms.mtel.bg/gbl/1.0/?wsdl');
- define ('GBL_SERVICE_CHANNEL', 'sms');
- define ('GBL_SERVICE_CATEGORY', 'notification');
- require ("/home/sms/inc/PrimaRecharge/subscriberinformation.php");
- require ("/home/sms/inc/sql_wrap.php");
- require ("/home/sms/inc/PrimaRecharge/bam.lib.php");
- //Settings for SMSPrimaRecharge
- $SMSPrimaRecharge_db ["db"] = "SMSPrimaRecharge";
- $SMSPrimaRecharge_db ["host"] = "10.250.246.61";
- $SMSPrimaRecharge_db ["user"] = "prima_rech_user";
- $SMSPrimaRecharge_db ["pass"] = "sk343df64jsr6c";
- //Settings for "PrepaidMMSBilling"
- $PrepaidMMSBilling_db ["db"] = "PrepaidMMSBilling";
- $PrepaidMMSBilling_db ["host"] = "213.226.6.50"; # localhost
- $PrepaidMMSBilling_db ["user"] = "prima_rech_user";
- $PrepaidMMSBilling_db ["pass"] = "kjldncuisfhs89fsd";
- //Settings for "cdrs"
- $cdrs_db ["db"] = "cdrs";
- $cdrs_db ["host"] = "10.250.246.61";
- $cdrs_db ["user"] = "prima_rech_user";
- $cdrs_db ["pass"] = "sk343df64jsr6c";
- $current_year = date ( "Y" );
- $bank_api_codes [0] = 'OK';
- $bank_api_codes [13] = 'Not valid amount for recharge';
- $bank_api_codes [14] = 'Invalid Prepaid MSISDN';
- $bank_api_codes [42] = 'Not enough deposit (prepaid resalers)';
- $bank_api_codes [80] = 'Request cannot be completed currently';
- $bank_api_codes [94] = 'Duplicated transaction ID';
- $bank_api_codes [96] = 'General error';
- //------------------------------------------------------------------------------------------------
- function log_sent($gsmnum, $smstext, $sms_id = 0)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $sql = "INSERT INTO SendLog_" . $current_year . "(input_log_id,destination,gsmnum,tstamp,sms_text) VALUES($sms_id,'" . $_GET ["receiver"] . "','$gsmnum',NOW(),'$smstext')";
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- $my_db->close ();
- return true;
- } //end log_sent
- //------------------------------------------------------------------------------------------------
- function log_em_all($destination, $gsmnum, $input)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $sql = "INSERT INTO InputLog_" . $current_year . "(destination,gsmnum,input,tstamp,stk_menu) VALUES('$destination','$gsmnum','$input',NOW(), ('$input' REGEXP ',stk$'))";
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- $ins_id = $my_db->insert_id ();
- $my_db->close ();
- return $ins_id;
- } //end log_em_all
- //------------------------------------------------------------------------------------------------
- function sendsms($smstext, $gsmnum, $sms_id = 0)
- {
- Header ( "X-Kannel-DLR-Mask: 3" );
- Header ( "X-Kannel-DLR-Url: http://smsapp.mtel.bg/dlr/1616.php?smsid=$sms_id&sender=%p&tstamp=%T&dlr_status=%d&receiver=%P&message_id=" . $sms_id );
- Header ( "X-Kannel-SMSC: " . $_GET ["smscid"] );
- print $smstext;
- log_sent ( $gsmnum, $smstext, $sms_id );
- # add sms to CRM Automatic Notifications
- register_mt_to_crm ( $gsmnum, 1616, $smstext, $sms_id );
- } //end sendsms
- //------------------------------------------------------------------------------------------------
- function check_parallel_transaction($gsmnum, $sms_id)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $sql = "SELECT count(i.id) As opened_trans FROM InputLog_" . $current_year . " i LEFT JOIN SendLog_" . $current_year . " s ON (i.id=s.input_log_id) WHERE i.gsmnum = $gsmnum AND i.id!=$sms_id AND (i.tstamp > now() - interval 5 minute) AND s.id IS NULL";
- #print $sql."<br>";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- $my_db->close ();
- if ($res [0] ["opened_trans"] == 0)
- { #niama zapochnali i nezavarsheni zarejdania za tozi MSISDN
- return false;
- } else
- {
- return true; #ima in SMS, no oshte niama out SMS - t.e. in SMS-a se processva vse oshte ot scripta za tozi MSISDN
- }
- } //end check_parallel_transaction
- //------------------------------------------------------------------------------------------------
- function check_flood($gsmnum)
- {
- global $SMSPrimaRecharge_db, $current_year;
- /*
- # for tests
- if ($gsmnum==359888618754 || $gsmnum==359886850873 || $gsmnum==359888500783 || $gsmnum==359888500949 || $gsmnum==359886224422 || $gsmnum==359888618772 || $gsmnum==359888618778 || $gsmnum==359888500814 ||
- $gsmnum==359888700783 || $gsmnum==359885035951) return false;
- */
- $hourly_tries = 1;
- $daily_tries = 2;
- $sql = "SELECT count(id) As tries FROM PrimaRechargeHistory_" . $current_year . " WHERE mo_msisdn = $gsmnum AND (recharge_date > now() - interval 60 minute)";
- #print $sql."<br>";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- if ($my_db->errno ())
- {
- $my_db->close ();
- return true;
- }
- if ($res [0] ["tries"] >= $hourly_tries)
- {
- $my_db->close ();
- return true;
- }
- $sql = "SELECT count(id) As tries FROM PrimaRechargeHistory_" . $current_year . " WHERE mo_msisdn = $gsmnum AND (recharge_date > now() - interval 1 day)";
- #print $sql."<br>";
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- if ($my_db->errno ())
- {
- $my_db->close ();
- return true;
- }
- if ($res [0] ["tries"] >= $daily_tries)
- {
- $my_db->close ();
- return true;
- }
- $my_db->close ();
- return false;
- } //end check_flood
- //------------------------------------------------------------------------------------------------
- function make_PrimaRechargeHistory($gsmnum, $prima, $sum, $sms_id, $postpaid_primary_id, $recharge_date)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $sql = "INSERT INTO PrimaRechargeHistory_" . $current_year . "(input_log_id, mo_msisdn, recharged_msisdn, recharge_sum, recharge_date, postpaid_primary_id) VALUES($sms_id, $gsmnum, $prima, $sum, '".$recharge_date."', $postpaid_primary_id)";
- #print $sql."\n";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- $my_db->close ();
- } //end make_PrimaRechargeHistory
- //------------------------------------------------------------------------------------------------
- function make_cdr($gsmnum, $prima, $sum, $amount, $recharge_dte)
- {
- global $cdrs_db;
- $sql = "INSERT INTO cdrs.cdr_" . date ( "Ym" ) . "(software_version, switch_type, call_transaction, subscriber_type, caller_msisdn, other_party_type, receiving_party, service_type, dte, duration, amount, gw_name, application_id, processed_dte) VALUES(DEFAULT, 'S', 'Y', '1', $gsmnum, ' ', '#$sum#$prima', '34', $recharge_dte, DEFAULT, $amount, 'MISC', 1, DEFAULT)";
- #print $sql."\n";
- $my_db = new Db ( $cdrs_db ["host"], $cdrs_db ["user"], $cdrs_db ["pass"] );
- $my_db->execute ( $cdrs_db ["db"], $sql );
- #print_r($my_db);
- $rows = $my_db->rows ();
- $my_db->close ();
- return $rows;
- } //end make_cdr
- //------------------------------------------------------------------------------------------------
- function uni2iso($uniline)
- {
- $tmp = chunk_split ( $uniline, 4, ";" );
- $tmp = explode ( ";", $tmp );
- for($i = 0; $i < count ( $tmp ); $i ++)
- {
- $cnt = $tmp [$i];
- $cnt = base_convert ( $cnt, 16, 10 );
- $uni = str_pad ( $cnt, 4, "0", STR_PAD_LEFT );
- $str .= ($cnt > 174) ? chr ( $cnt - 1040 + 176 ) : chr ( $cnt );
- }
- return convert_cyr_string ( $str, "i", "w" ); //$str;//
- } //end uni2iso
- //------------------------------------------------------------------------------------------------
- function str_to_lower($src)
- {
- $dst = "";
- $num = strlen ( $src );
- for($i = 0; $i < $num; $i ++)
- {
- $char = $src [$i];
- $ord = ord ( $char );
- if ($ord >= 65 && $ord <= 90)
- {
- $ord = $ord + 32;
- $dst .= chr ( $ord );
- } elseif ($ord >= 192 && $ord <= 223)
- {
- $ord = $ord + 32;
- $dst .= chr ( $ord );
- } elseif (($ord >= 97 && $ord <= 122) || ($ord >= 224 && $ord <= 255) || ($ord >= 48 && $ord <= 57))
- {
- $dst .= $char;
- } else
- {
- break; //chars not in a-zA-Z�-��-� are skipped - break after first word
- }
- }
- return $dst;
- } //end str_to_lower
- //------------------------------------------------------------------------------------------------
- function utf8win1251($s)
- {
- $out = "";
- $c1 = "";
- $byte2 = false;
- for($c = 0; $c < strlen ( $s ); $c ++)
- {
- $i = ord ( $s [$c] );
- if ($i <= 127)
- {
- $out .= $s [$c];
- }
- if ($byte2)
- {
- $new_c2 = ($c1 & 3) * 64 + ($i & 63);
- $new_c1 = ($c1 >> 2) & 5;
- $new_i = $new_c1 * 256 + $new_c2;
- if ($new_i == 1025)
- $out_i = 168;
- else if ($new_i == 1105)
- $out_i = 184;
- else
- $out_i = $new_i - 848;
- $out .= chr ( $out_i );
- $byte2 = false;
- }
- if (($i >> 5) == 6)
- {
- $c1 = $i;
- $byte2 = true;
- }
- }
- return $out;
- }
- //end utf8win1251
- //------------------------------------------------------------------------------------------------
- function is_postpaid($msisdn)
- {
- /*
- global $PrepaidMMSBilling_db;
- $sql = "SELECT count(msisdn) As ok FROM PrepaidMMSBilling.postpaid WHERE msisdn = $msisdn";
- #print $sql."<br>";
- $my_db = new Db ( $PrepaidMMSBilling_db ["host"], $PrepaidMMSBilling_db ["user"], $PrepaidMMSBilling_db ["pass"] );
- $res = & $my_db->execute ( $PrepaidMMSBilling_db ["db"], $sql );
- #print $my_db->error();
- $my_db->close ();
- if ($res [0] ["ok"] > 0)
- {
- return true;
- } else
- {
- return false;
- }
- */
- $result = null;
- $params = new stdClass ();
- $params->RequestHeader = new StdClass ();
- $params->RequestBody = new StdClass ();
- $params->RequestBody->Msisdn = $msisdn;
- $params->RequestBody->CheckSubscriberStatus = false;
- $service_options = array(
- 'soap_version' => 'SOAP_1_2',
- 'authentication' => SOAP_AUTHENTICATION_BASIC,
- 'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
- 'login' => SUBSRIBER_TYPE_SERVICE_USER,
- 'password' => SUBSRIBER_TYPE_SERVICE_PASS,
- 'encoding' => "utf-8"
- );
- try {
- $soap_client = new SoapClient (SUBSRIBER_TYPE_SERVICE_WSDL, $service_options);
- $result = $soap_client->GetSubscriberType($params);
- } catch (Exception $exception) {
- var_dump("<pre>", $exception);
- return false;
- }
- return $result->ResponseBody->SubscriberType;
- }
- //------------------------------------------------------------------------------------------------
- function get_subscriberinfo($msisdn, $sms_id)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $result = SubscriberInformation ( $msisdn );
- $sql = "INSERT INTO SubscriberInfoLog_" . $current_year . "(input_log_id, MSISDN, LogDate, Response) VALUES($sms_id, $msisdn, now(), '" . addslashes ( serialize ( $result ) ) . "')";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $rez = $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- #print "<pre>"; var_dump($my_db);die;
- $my_db->close ();
- return $result;
- } //end get_subscriberinfo
- //---------------------------------------------------------------------------------
- function is_prepaid($prima, $price, $sms_id)
- {
- global $SMSPrimaRecharge_db, $current_year, $stk_flag, $tid, $tiddate;
- $params_header = new stdClass ( );
- $params_header->UserName = 'MTELPROD';
- $params_header->Password = 'feldkhun';
- if ($stk_flag == 1)
- { # ako stk_flag e 1 polzvam Source 3 - STK, v protiven sluchai 1 - SMS
- $source = 3;
- } else
- {
- $source = 1;
- }
- $params = new stdClass ( );
- $params->Source = $source;
- $params->MSISDN = $prima;
- $params->TID = $tid;
- $params->TIDDate = $tiddate;
- $params->Amount = $price;
- $params->Language = 0;
- ini_set ( "default_socket_timeout", 10 );
- $soap_client = new SoapClient ( '/home/sms/inc/wsdls/BankInterface.wsdl', array ('trace' => 1, 'connection_timeout' => 5 ) );
- $header = new SoapHeader ( 'http://www.mtel.bg', 'SOAPAuthenticationHeader', $params_header );
- $soap_client->__setSoapHeaders ( array ($header ) );
- try
- {
- $res = $soap_client->CheckPrima ( $params );
- } catch ( SoapFault $exception )
- {
- $res = false;
- $result ["CheckPrimaResult"] = - 1;
- $result ["SOAPStatus"] = $exception->getMessage ();
- $result ["RAmount"] = 0;
- $result ["Source"] = $source;
- $result ["TID"] = $tid;
- $result ["TIDDate"] = $tiddate;
- #return false;
- }
- $sql = "INSERT INTO PrimaLog_" . $current_year . "(input_log_id, LogDate, Request, Response) VALUES($sms_id, now(), '" . addslashes ( $soap_client->__getLastRequest () ) . "', '" . addslashes ( $soap_client->__getLastResponse () ) . "')";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $rez = $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- #print "<pre>"; var_dump($my_db);die;
- $my_db->close ();
- if (! $res)
- return $result;
- // Return the result
- $result ["CheckPrimaResult"] = $res->CheckPrimaResult;
- $result ["SOAPStatus"] = "OK";
- $result ["RAmount"] = $res->RAmount;
- $result ["Source"] = $source;
- $result ["TID"] = $tid;
- $result ["TIDDate"] = $tiddate;
- return $result;
- } //end is_prepaid
- //---------------------------------------------------------------------------------
- function recharge_prima($prima, $mo_msisdn, $params_arr, $sms_id)
- {
- global $SMSPrimaRecharge_db, $current_year;
- $params_header = new stdClass ( );
- $params_header->UserName = 'MTELPROD';
- $params_header->Password = 'feldkhun';
- $params = new stdClass ( );
- $params->Source = $params_arr ["Source"];
- $params->MSISDN = $prima;
- $params->TID = $params_arr ["TID"];
- $params->TIDDate = $params_arr ["TIDDate"];
- $params->Card = $mo_msisdn;
- $params->Amount = $params_arr ["RAmount"];
- $params->Ref = 0;
- ini_set ( "default_socket_timeout", 35 );
- $soap_client = new SoapClient ( '/home/sms/inc/wsdls/BankInterface.wsdl', array ('trace' => 1, 'connection_timeout' => 5 ) );
- $header = new SoapHeader ( 'http://www.mtel.bg', 'SOAPAuthenticationHeader', $params_header );
- $soap_client->__setSoapHeaders ( array ($header ) );
- try
- {
- $res = $soap_client->PayPrima ( $params );
- } catch ( SoapFault $exception )
- {
- #don't return here result must be logged into DB
- #return false;
- }
- $sql = "INSERT INTO PrimaLog_" . $current_year . "(input_log_id, LogDate, Request, Response) VALUES($sms_id, now(), '" . addslashes ( $soap_client->__getLastRequest () ) . "', '" . addslashes ( $soap_client->__getLastResponse () ) . "')";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $rez = $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- #print "<pre>"; var_dump($my_db);die;
- $my_db->close ();
- if (isset ( $res->PayPrimaResult ) && ($res->PayPrimaResult == 0))
- return true;
- else
- return false;
- } //end recharge_prima
- //-------------------------------------------------------------------------------
- /**
- * Function call TIBCO web service
- * in order to register service in
- * CRM Automatic Notification tab
- *
- * @param unknown_type $msisdn - gsm number
- * @param unknown_type $short_number - short number
- * @param unknown_type $sms_text - text of the message
- * @param unknown_type $message_id - sms id value
- * @return boolean
- */
- function register_mt_to_crm($msisdn, $short_number, $sms_text, $message_id)
- {
- $msisdn = '0' . substr ( $msisdn, 3 );
- $service_options = array ('soap_version' => 'SOAP_1_2', 'authentication' => SOAP_AUTHENTICATION_BASIC, 'User-Agent' => 'User-Agent: Jakarta Commons-HttpClient/3.1', 'trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'login' => SUBSCRIBER_MESSAGING_LOGIN, 'password' => SUBSCRIBER_MESSAGING_PASSWORD, 'location' => SUBSCRIBER_MESSAGING_LOCATION, 'uri' => "http://mtel.bg/SubscriberMessaging/BusinessServices/MessagingService", 'encoding' => "utf-8", 'connection_timeout' => 10 );
- $params = new stdClass ( );
- $params->InterfaceRequestHeader = new StdClass ( ); # * empty tibco header
- $params->RequestBody = new StdClass ( );
- # MessageID must be unique, so use "dma_" application name unique_id (max length 20)
- $params->RequestBody->MessageID = SUBSCRIBER_MESSAGING_SERVICE_UNIQUE_ID . '_' . $message_id;
- # CorrelationID is used for mapping with sms_delivery_report.delivery_report_id
- $params->RequestBody->CorrelationID = SUBSCRIBER_MESSAGING_SERVICE_UNIQUE_ID . '_' . $message_id;
- $params->RequestBody->Sender = $short_number;
- $params->RequestBody->Receiver = $msisdn;
- $params->RequestBody->Priority = 0;
- # options are Text, WAP-Push, MMS
- $params->RequestBody->PayloadType = 'Text';
- $params->RequestBody->StartDate = date ( "c", time () );
- $params->RequestBody->EndDate = date ( "c", time () );
- $params->RequestBody->Text = $sms_text;
- # SMSC or MMSC
- $params->RequestBody->BackEnd = 'SMSC';
- #
- $params->RequestBody->SchedulerTemplate = 'WeekDays';
- $params->RequestBody->Status = 'Sent'; # Delivered
- # Marin Bodichev for more information
- $params->RequestBody->TemplateID = 'SMSGEN'; # SASCM1
- try
- {
- //@error_log ( var_export ( $params, true ), 3, '/tmp/1616_6lv_voucher.log' );
- $soap_client = new SoapClient ( SUBSCRIBER_MESSAGING_WSDL, $service_options );
- $result = $soap_client->InsertSMSLog ( $params );
- // @error_log ( var_export ( $result, true ), 3, '/tmp/1616_6lv_voucher.log' );
- } catch ( Exception $exception )
- {
- //@error_log ( var_export ( $exception, true ), 3, '/tmp/1616_6lv_voucher.log' );
- return false;
- }
- debugLog($service_options);
- debugLog($params);
- debugLog($result);
- return $result->RequestBody->returnMsg;
- }
- function debugLog($sting)
- {
- //@error_log ( var_export($sting, true), 3, '/tmp/1616_6lv_voucher.log' );
- }
- /*
- all params are (with example values):
- if (!isset($origin)){
- $stype="";
- $origin="11359888618754";
- $destination="311616";
- $class=0;
- $pid=0;
- $priority=0;
- $dcs=0;
- $smtext="0886218875,10";
- }
- */
- //if(!isset($_GET["test_web"])) exit("Interface not permitted.");
- //if($_GET["info"]=="true") exit("Params:test_web; sender (postpaid msisdn), text (prepaid_msisdn,recharge_sum); Example: ?test_web&sender=+359882203685&text=0888123123,10");
- $gsmnum = substr ( $_GET ["sender"], 1 );
- $input = trim ( urldecode ( $_GET ["text"] ) );
- #$original_input = $input;
- $sum = 0;
- $prima = 0;
- if ($_GET ["charset"] != "ISO-8859-1")
- {
- $input = iconv ( $_GET ["charset"], 'windows-1251//IGNORE', $input );
- }
- $input = strtolower ( $input );
- $sms_id = log_em_all ( $destination, $gsmnum, $input );
- #skip spaces
- $input = str_replace ( " ", "", $input );
- $tidtime = time ();
- $tiddate = date ( "Y-m-d", $tidtime ) . 'T' . date ( "H:i:s", $tidtime );
- # GLB
- if (preg_match ( '/^stop$/i', strtolower ( $input ) ))
- {
- ini_set ( "default_socket_timeout", 5 );
- ini_set ( "soap.wsdl_cache_enabled", 1 );
- $input = new stdClass ( );
- $input->auth->username = GBL_SERVICE_USER;
- $input->auth->password = GBL_SERVICE_PASS;
- $input->channel->channelName = GBL_SERVICE_CHANNEL;
- $input->category->categoryName = GBL_SERVICE_CATEGORY;
- $input->service->serviceName = "1616";
- $input->a_party = "mtel";
- $input->b_party = "msisdn_{$gsmnum}";
- try
- {
- $soap_client = new SoapClient ( GBL_SERVICE_WSDL, array ("connection_timeout" => 5 ) );
- $result = $soap_client->addBlock ( $input );
- } catch ( SoapFault $exception )
- {
- }
- debugLog($input);
- debugLog($soap_client);
- debugLog($result);
- sendsms ( M12, $gsmnum, $sms_id);
- exit ();
- }
- # 18.01.2012 STK channel have to handle 5 lv and 6 lv vaucher,
- # while SMS channel must handle only 6 lv voucher (i.stoyanov@mobiltel.bg)
- #miro 20131004
- //if (! preg_match_all ( "/^(08[7-9]{1}[0-9]{1}[0-9]{6}),((6|06|10|15{1})|(5|05|6|06|10|15)(,stk))$/", $input, $matches ))
- if (! preg_match_all ( "/^(0[8-9]{1}[7-9]{1}[0-9]{1}[0-9]{6}),((6|06|10|15{1})|(5|05|6|06|10|15)(,stk))$/", $input, $matches ))
- //if (! preg_match_all ( "/^(08[7-9]{1}[2-9]{1}[0-9]{6}),(5|05|10|15{1})(,stk)?$/", $input, $matches ))
- {
- //if (!preg_match_all("/^(08[7-9]{1}[2-9]{1}[0-9]{6}),(5|05|6|06|10|15{1})(,stk)?$/", $input, $matches)){
- #mail('jgmec@mtel.net', 'SMS Error', '<pre>' .print_r($matches, true). '</pre>');
- $tid = date ( "YmdHis", $tidtime ) . '01' . str_pad ( $sms_id, 10, '0', STR_PAD_LEFT );
- # $my_bam = new BAM ( $tid, 'SMS1616', 'prod', 'SMS' );
- # $my_bam->SendEvent ( 'SMSGW', 'SMS Received', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => 'Unknown', 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'SME number' => $_GET ["receiver"], 'SMS tstamp' => date ( "Y-m-d H:i:s", $_GET ["tstamp"] ), 'In SMS Message' => iconv ( 'windows-1251', 'UTF-8//IGNORE', $input ), 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'SMS Syntax Check', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => 'Unknown', 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'SMS Syntax Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => 'Unknown', 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- #$my_bam->SendEvent('SMS PRIMA Recharge Application', 'SMS Syntax Not Valid', array('Step'=>'end', 'RequestID'=>$sms_id, 'MSISDNPrepaid'=>'Unknown', 'MSISDNPostpaid'=>'+'.$gsmnum, 'RAmount'=>($sum*100), 'State'=>'NOTOK', 'Out SMS Message' => M1, 'RequestDateTime' => $my_bam->udate("Y-m-d H:i:s.u")));
- $sql = "SELECT `postpaid_msisdn` as msisdn FROM `CRMRechargeCampaigns` WHERE `postpaid_msisdn`='{$gsmnum}'";
- $my_db = new Db ( $SMSPrimaRecharge_db ["host"], $SMSPrimaRecharge_db ["user"], $SMSPrimaRecharge_db ["pass"] );
- $res = & $my_db->execute ( $SMSPrimaRecharge_db ["db"], $sql );
- $my_db->close ();
- if (! empty ( $res [0] ["msisdn"] ))
- {
- #ima
- sendsms ( M13, $gsmnum, $sms_id );
- } else
- {
- #niama
- sendsms ( M1, $gsmnum, $sms_id );
- }
- die ();
- } else
- {
- #var_dump($matches);
- $prima = $matches [1] [0];
- $sum = ( int ) $matches [2] [0];
- $stk_flag = ($matches [5] [0] == ",stk") ? 1 : 0;
- $channel = ($matches [5] [0] == ",stk") ? 'STK' : 'SMS';
- debugLog($prima);
- debugLog($sum);
- debugLog($channel);
- # New feature. Start pico-push script for update STK menu, so clients
- # to be able to use new 6 lv voucher via STK channel
- # date 18.01.2012 i.stoyanov@mobiltel.bg
- if ($channel == 'STK' and $sum == 5)
- {
- $service_options = array ('soap_version' => 'SOAP_1_2',
- 'authentication' => SOAP_AUTHENTICATION_BASIC,
- 'trace' => 1,
- 'exceptions' => true,
- 'cache_wsdl' => WSDL_CACHE_MEMORY, # WSDL_CACHE_NONE
- 'login' => PICO_PUSH_LOGIN,
- 'password' => PICO_PUSH_USER,
- 'encoding' => "utf-8",
- 'connection_timeout' => 3 );
- # call pico-push service
- try{
- $soap = new SoapClient(PICO_PUSH_WSDL, $service_options);
- $params = new StdClass();
- $params->to_msisdn = $gsmnum;
- $params->page = PICO_PUSH_PAGE;
- $params->text = M14;
- #use web service of mtel contact
- $res = $soap->sendPage($params);
- #$res == "200 OK" SIM card is supported, not supported in other cases
- debugLog($service_options);
- debugLog($params);
- debugLog($res);
- if ($res == '200 OK')
- {
- #STK platform start communication with msisdn
- log_sent($gsmnum, M14, $sms_id );
- exit;
- }
- }catch(Exception $exception){
- //var_dump($exception);
- debugLog($exception->getMessage());
- }
- }
- if ($stk_flag == 1)
- { # ako stk_flag e 1 polzvam Source 3 - STK, v protiven sluchai 1 - SMS
- $tid = date ( "YmdHis", $tidtime ) . '03' . str_pad ( $sms_id, 10, '0', STR_PAD_LEFT );
- } else
- {
- $tid = date ( "YmdHis", $tidtime ) . '01' . str_pad ( $sms_id, 10, '0', STR_PAD_LEFT );
- }
- # $my_bam = new BAM ( $tid, 'SMS1616', 'prod', $channel );
- # $my_bam->SendEvent ( 'SMSGW', 'SMS Received', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'SME number' => $_GET ["receiver"], 'SMS tstamp' => date ( "Y-m-d H:i:s", $_GET ["tstamp"] ), 'In SMS Message' => iconv ( 'windows-1251', 'UTF-8//IGNORE', $input ), 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'SMS Syntax Check', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'SMS Syntax Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- }
- #$my_bam->SendEvent ( 'Postpaid Check DB', 'Postpaid Validity Check', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- //@error_log ( 'is_postpaid for gsm: '. $gsmnum . is_postpaid ( $gsmnum )."\n", 3, '/tmp/1616_6lv_voucher.log' );
- if (! is_postpaid ( $gsmnum ))
- {
- #$my_bam->SendEvent ( 'Postpaid Check DB', 'Postpaid Validity Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Number not found in Postpaid Check DB.', 'Out SMS Message' => M3, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M3, $gsmnum, $sms_id );
- die ();
- } else
- {
- #$my_bam->SendEvent ( 'Postpaid Check DB', 'Postpaid Validity Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- }
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- $subscriberinfo = get_subscriberinfo ( $gsmnum, $sms_id );
- debugLog($subscriberinfo);
- if (! $subscriberinfo || count ( $subscriberinfo ) < 1)
- {
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'SubscriberInformation error. Error Fetching http headers.', 'Out SMS Message' => M9, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M9, $gsmnum, $sms_id );
- die ();
- }
- //@error_log ( 'check_flood:' . check_flood ( $gsmnum ), 3, '/tmp/1616_6lv_voucher.log' );
- if ($subscriberinfo ["primarechargeunlimited"] == "No" && check_flood ( $gsmnum ))
- {
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Recharge limit reached - 1 per hour 2 per day', 'Out SMS Message' => M2, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M2, $gsmnum, $sms_id );
- die ();
- }
- if ((( int ) $subscriberinfo ["primary_id"] < 1) || (( int ) $subscriberinfo ["status"] != 1))
- {
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Not a valid postpaid number or inactive status.', 'Out SMS Message' => M3, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M3, $gsmnum, $sms_id );
- die ();
- }
- if ($subscriberinfo ["recharge_allowed"] != "Yes")
- {
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'SMS Prima Recharge not allowed.', 'Out SMS Message' => M10, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M10, $gsmnum, $sms_id );
- die ();
- }
- if ($subscriberinfo ["subscriber_type"] != "Business" && strtotime ( substr ( $subscriberinfo ["effective_date_from3"], 0, 10 ) ) > mktime ( 0, 0, 0, date ( "m" ) - 3, date ( "d" ), date ( "Y" ) ))
- {
- # $my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Residential subscriber without 3 months of history.', 'Out SMS Message' => M4, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M4, $gsmnum, $sms_id );
- die ();
- }
- if (((( float ) $subscriberinfo ["non_billed_balance"] + ( float ) $sum) > (( float ) $subscriberinfo ["credit_limit"] + ( float ) $subscriberinfo ["subscriber_deposit"])) && ($subscriberinfo ["usage_never_stop"] == "No"))
- {
- # $my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Not enough balance/credit limit.', 'Out SMS Message' => M5, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M5, $gsmnum, $sms_id );
- die ();
- }
- #$my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Validity Check', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- $check_prima = is_prepaid ( "359" . substr ( $prima, 1 ), ($sum * 100), $sms_id );
- if ($check_prima ["CheckPrimaResult"] == - 1)
- { #some error occurred with WS call
- #$my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- #$my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Validity Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Error during Prepaid Check. ' . $check_prima ["SOAPStatus"], 'Out SMS Message' => M9, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M9, $gsmnum, $sms_id );
- die ();
- } else
- {
- #$my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Validity Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- }
- if ($check_prima ["CheckPrimaResult"] != 0)
- { #not a valid prima
- # $my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Validity Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Prepaid recharge not possible - ' . $bank_api_codes [$check_prima ["CheckPrimaResult"]], 'Out SMS Message' => M6, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M6, $gsmnum, $sms_id );
- die ();
- }
- #added for very fast SMS senders:)))
- if (check_parallel_transaction ( $gsmnum, $sms_id ))
- {
- sleep ( mt_rand ( 20, 30 ) ); #wait between 20 and 30 seconds
- }
- #added for fast SMS senders:)))))
- if ($subscriberinfo ["primarechargeunlimited"] == "No" && check_flood ( $gsmnum ))
- {
- # $my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'NOTOK', 'StatusDescription' => 'Recharge limit reached - 1 per hour 2 per day', 'Out SMS Message' => M2, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M2, $gsmnum, $sms_id );
- die ();
- } else
- {
- # $my_bam->SendEvent ( 'TIBCO', 'Postpaid Recharge Service Allowance Check', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- }
- #$my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Recharge Request', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- # miroslav biliarski 2013-10-04
- # OnProd Comment this 3 lines !!
- #echo "Test ok";
- #echo "Rrecharge_prima ( \"359\" . substr ( $prima, 1 ), $gsmnum, $check_prima, $sms_id )";
- #exit(0);
- if (recharge_prima ( "359" . substr ( $prima, 1 ), $gsmnum, $check_prima, $sms_id ))
- { #request is accepted
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Recharge Request', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- #$my_bam->SendEvent('TIBCO', 'Recharge Request Pre-Processing', array('Step'=>'end', 'RequestID'=>$sms_id, 'MSISDNPrepaid'=>"+359".substr($prima, 1), 'MSISDNPostpaid'=>'+'.$gsmnum, 'RAmount'=>($sum*100), 'Amount'=>$check_prima["RAmount"], 'State'=>'OK'));
- make_PrimaRechargeHistory ( $gsmnum, $prima, $sum, $sms_id, $subscriberinfo ["primary_id"], substr ( $check_prima ["TID"], 0, 14 ));
- #make CDR
- # $my_bam->SendEvent ( 'CDR DB', 'Postpaid CDR Generation', array ('Step' => 'start', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'OK', 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- if (make_cdr ( $gsmnum, $prima, $sum, $check_prima ["RAmount"], substr ( $check_prima ["TID"], 0, 14 ) ))
- {
- # $my_bam->SendEvent ( 'CDR DB', 'Postpaid CDR Generation', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'OK', 'Out SMS Message' => M7 . $prima . M71 . $sum . M72, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- } else
- {
- # $my_bam->SendEvent ( 'CDR DB', 'Postpaid CDR Generation', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'NOTOK', 'StatusDescription' => 'CDR Not recorded.', 'Out SMS Message' => M7 . $prima . M71 . $sum . M72, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- }
- #send SMS notification
- sendsms ( M7 . $prima . M71 . $sum . M72, $gsmnum, $sms_id );
- die ();
- } else
- { #some error occurred
- # $my_bam->SendEvent ( 'SMS PRIMA Recharge Application', 'Prepaid Recharge Request', array ('Step' => 'end', 'RequestID' => $sms_id, 'MSISDNPrepaid' => "+359" . substr ( $prima, 1 ), 'MSISDNPostpaid' => '+' . $gsmnum, 'RAmount' => ($sum * 100), 'Amount' => $check_prima ["RAmount"], 'State' => 'NOTOK', 'StatusDescription' => 'Recharge not accepted', 'Out SMS Message' => M9, 'RequestDateTime' => $my_bam->udate ( "Y-m-d H:i:s.u" ) ) );
- sendsms ( M9, $gsmnum, $sms_id );
- die ();
- }
- die ();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement