本文整理汇总了PHP中dlr函数的典型用法代码示例。如果您正苦于以下问题:PHP dlr函数的具体用法?PHP dlr怎么用?PHP dlr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dlr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openvox_hook_sendsms
function openvox_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "openvox_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
if ($plugin_config['openvox']['gateway_host'] && $plugin_config['openvox']['gateway_port'] && $sms_to && $sms_msg) {
$query_string = "username=" . $plugin_config['openvox']['username'] . "&password=" . $plugin_config['openvox']['password'] . "&phonenumber=" . urlencode($sms_to) . "&message=" . urlencode($sms_msg) . "&report=JSON&smslog_id=" . $smslog_id;
$url = 'http://' . $plugin_config['openvox']['gateway_host'] . ":" . $plugin_config['openvox']['gateway_port'] . '/sendsms?' . $query_string;
_log("url:[" . $url . "]", 3, "openvox outgoing");
$resp = json_decode(file_get_contents($url), true);
$data = $resp['report'][0][0][0];
$data['message'] = $resp['message'];
_log('response result:' . $data['result'] . ' port:' . $data['port'] . ' to:' . $data['phonenumber'] . ' time:' . $data['time'], 3, 'openvox_hook_sendsms');
if ($data['result'] == 'success') {
$p_status = 1;
dlr($smslog_id, $uid, $p_status);
} else {
$p_status = 2;
dlr($smslog_id, $uid, $p_status);
}
}
return TRUE;
}
示例2: nexmo_hook_sendsms
function nexmo_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "nexmo_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
if ($plugin_config['nexmo']['module_sender']) {
$sms_sender = $plugin_config['nexmo']['module_sender'];
}
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$ok = false;
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
if ($sms_sender && $sms_to && $sms_msg) {
$unicode = "";
if ($unicode) {
if (function_exists('mb_convert_encoding')) {
// $sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto");
$sms_msg = mb_convert_encoding($sms_msg, "UCS-2", "auto");
$unicode = "&type=unicode";
// added at the of query string if unicode
}
}
$query_string = "api_key=" . $plugin_config['nexmo']['api_key'] . "&api_secret=" . $plugin_config['nexmo']['api_secret'] . "&to=" . urlencode($sms_to) . "&from=" . urlencode($sms_sender) . "&text=" . urlencode($sms_msg) . $unicode . "&status-report-req=1&client-ref=" . $smslog_id;
$url = $plugin_config['nexmo']['url'] . "?" . $query_string;
_log("url:[" . $url . "]", 3, "nexmo outgoing");
// fixme anton
// rate limit to 1 second per submit - nexmo rule
sleep(1);
$resp = json_decode(file_get_contents($url), true);
if ($resp['message-count']) {
$c_status = $resp['messages'][0]['status'];
$c_message_id = $resp['messages'][0]['message-id'];
$c_network = $resp['messages'][0]['network'];
$c_error_text = $resp['messages'][0]['error-text'];
_log("sent smslog_id:" . $smslog_id . " message_id:" . $c_message_id . " status:" . $c_status . " error:" . $c_error_text, 2, "nexmo outgoing");
$db_query = "\n\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayNexmo (local_smslog_id,remote_smslog_id,status,network,error_text)\n\t\t\t\tVALUES ('{$smslog_id}','{$c_message_id}','{$c_status}','{$c_network}','{$c_error_text}')";
$id = @dba_insert_id($db_query);
if ($id && $c_status == 0) {
$ok = true;
$p_status = 1;
dlr($smslog_id, $uid, $p_status);
}
} else {
// even when the response is not what we expected we still print it out for debug purposes
$resp = str_replace("\n", " ", $resp);
$resp = str_replace("\r", " ", $resp);
_log("failed smslog_id:" . $smslog_id . " resp:" . $resp, 2, "nexmo outgoing");
}
}
if (!$ok) {
$p_status = 2;
dlr($smslog_id, $uid, $p_status);
}
return $ok;
}
示例3: blocked_hook_sendsms
function blocked_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "blocked_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$p_status = 2;
dlr($smslog_id, $uid, $p_status);
return TRUE;
}
示例4: dev_hook_sendsms
function dev_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
$ok = false;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "dev_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
if ($plugin_config['dev']['enable_outgoing']) {
$p_status = 3;
dlr($smslog_id, $uid, $p_status);
$ok = true;
}
return $ok;
}
示例5: msgtoolbox_hook_sendsms
function msgtoolbox_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
// global $plugin_config; // global all variables needed, eg: varibles from config.php
// ...
// ...
// return true or false
// return $ok;
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "msgtoolbox_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
if ($plugin_config['msgtoolbox']['module_sender']) {
$sms_sender = $plugin_config['msgtoolbox']['module_sender'];
}
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$ok = false;
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
if ($sms_to && $sms_msg) {
if ($unicode) {
if (function_exists('mb_convert_encoding')) {
// $sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto");
$sms_msg = mb_convert_encoding($sms_msg, "UCS-2", "auto");
$unicode = "&coding=unicode";
// added at the of query string if unicode
}
}
// fixme anton - from playSMS v0.9.5.1 references to input.php replaced with index.php?app=webservices
// I should add autodetect, if its below v0.9.5.1 should use input.php
$query_string = "username=" . $plugin_config['msgtoolbox']['username'] . "&password=" . $plugin_config['msgtoolbox']['password'] . "&to=" . urlencode($sms_to) . "&from=" . urlencode($sms_sender) . "&message=" . urlencode($sms_msg) . $unicode . "&route=" . $plugin_config['msgtoolbox']['route'];
$url = $plugin_config['msgtoolbox']['url'] . "?" . $query_string;
/*
* not used if ($additional_param = $plugin_config['msgtoolbox']['additional_param']) { $additional_param = "&".$additional_param; } $url .= $additional_param; $url = str_replace("&&", "&", $url);
*/
logger_print($url, 3, "msgtoolbox outgoing");
$fd = @implode('', file($url));
if ($fd) {
$response = explode(",", $fd);
if (trim($response[0]) == "1") {
$remote_smslog_id = trim($response[1]);
if ($remote_smslog_id) {
// this is for callback, if callback not used then the status would be sent or failed only
// local_smslog_id is local SMS log id (local smslog_id)
// remote_smslog_id is remote SMS log id (in API doc its referred to smsid or messageid)
// status=10 delivered to gateway
$db_query = "\n\t\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayMsgtoolbox (local_smslog_id,remote_smslog_id,status)\n\t\t\t\t\t\tVALUES ('{$smslog_id}','{$remote_smslog_id}','10')\n\t\t\t\t\t ";
$id = @dba_insert_id($db_query);
if ($id) {
$ok = true;
$p_status = 1;
// sms sent
dlr($smslog_id, $uid, $p_status);
}
}
}
logger_print("sent smslog_id:" . $smslog_id . " response:" . $fd, 2, "msgtoolbox outgoing");
} else {
// even when the response is not what we expected we still print it out for debug purposes
$fd = str_replace("\n", " ", $fd);
$fd = str_replace("\r", " ", $fd);
logger_print("failed smslog_id:" . $smslog_id . " response:" . $fd, 2, "msgtoolbox outgoing");
}
}
if (!$ok) {
$p_status = 2;
dlr($smslog_id, $uid, $p_status);
}
return $ok;
}
示例6: uplink_hook_getsmsstatus
function uplink_hook_getsmsstatus($gpid = 0, $uid = "", $smslog_id = "", $p_datetime = "", $p_update = "")
{
// global $plugin_config;
// p_status :
// 0 = pending
// 1 = delivered
// 2 = failed
// dlr($smslog_id,$uid,$p_status);
global $plugin_config;
$db_query = "SELECT * FROM " . _DB_PREF_ . "_gatewayUplink WHERE up_local_smslog_id='{$smslog_id}'";
$db_result = dba_query($db_query);
if ($db_row = dba_fetch_array($db_result)) {
$local_smslog_id = $db_row['up_local_smslog_id'];
$remote_smslog_id = $db_row['up_remote_smslog_id'];
$remote_queue_code = $db_row['up_remote_queue_code'];
$dst = $db_row['up_dst'];
if ($local_smslog_id && ($remote_smslog_id || $remote_queue_code && $dst)) {
$ws = new Playsms\Webservices();
$ws->url = $plugin_config['uplink']['master'] . '/index.php?app=ws';
$ws->username = $plugin_config['uplink']['username'];
$ws->token = $plugin_config['uplink']['token'];
$ws->smslog_id = $remote_smslog_id;
$ws->queue = $remote_queue_code;
$ws->count = 1;
$ws->getOutgoing();
// _log('url:'.$ws->getWebservicesUrl(), 3, 'uplink getsmsstatus');
$response = $ws->getData()->data[0];
if ($response->status == 2) {
$p_status = 2;
dlr($local_smslog_id, $uid, $p_status);
} else {
if ($p_status = (int) $response->status) {
dlr($local_smslog_id, $uid, $p_status);
}
}
}
}
}
示例7: playnet_hook_webservices_output
function playnet_hook_webservices_output($operation, $requests, $returns)
{
global $plugin_config;
$go = $requests['go'];
$smsc = $requests['s'];
$username = $requests['u'];
$password = $requests['p'];
if (!($operation == 'playnet' && $go && $smsc && $username && $password)) {
return FALSE;
}
$c_plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
// auth remote
if (!($c_plugin_config['playnet']['local_playnet_username'] && $c_plugin_config['playnet']['local_playnet_password'] && $c_plugin_config['playnet']['local_playnet_username'] == $username && $c_plugin_config['playnet']['local_playnet_password'] == $password)) {
$content['status'] = 'ERROR';
$content['error_string'] = 'Authentication failed';
$returns['modified'] = TRUE;
$returns['param']['content'] = json_encode($content);
$returns['param']['content-type'] = 'text/json';
return $returns;
}
switch ($go) {
case 'get_outgoing':
$conditions = array('flag' => 1, 'smsc' => $smsc);
$extras = array('ORDER BY' => 'id', 'LIMIT' => $c_plugin_config['playnet']['poll_limit']);
$list = dba_search(_DB_PREF_ . '_gatewayPlaynet_outgoing', '*', $conditions, '', $extras);
foreach ($list as $data) {
$rows[] = array('smsc' => $data['smsc'], 'smslog_id' => $data['smslog_id'], 'uid' => $data['uid'], 'sender_id' => $data['sender_id'], 'sms_to' => $data['sms_to'], 'message' => $data['message'], 'sms_type' => $data['sms_type'], 'unicode' => $data['unicode']);
// update flag
$items = array('flag' => 2);
$condition = array('flag' => 1, 'id' => $data['id']);
dba_update(_DB_PREF_ . '_gatewayPlaynet_outgoing', $items, $condition, 'AND');
// update dlr
$p_status = 1;
dlr($data['smslog_id'], $data['uid'], $p_status);
}
if (count($rows)) {
$content['status'] = 'OK';
$content['data'] = $rows;
} else {
$content['status'] = 'ERROR';
$content['error_string'] = 'No data';
}
break;
}
$returns['modified'] = TRUE;
$returns['param']['content'] = json_encode($content);
$returns['param']['content-type'] = 'text/json';
return $returns;
}
示例8: twilio_hook_sendsms
function twilio_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "twilio_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
if ($plugin_config['twilio']['module_sender']) {
$sms_sender = $plugin_config['twilio']['module_sender'];
}
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$ok = false;
logger_print("sendsms start", 3, "twilio_hook_sendsms");
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
if ($sms_sender && $sms_to && $sms_msg) {
$url = $plugin_config['twilio']['url'] . '/2010-04-01/Accounts/' . $plugin_config['twilio']['account_sid'] . '/SMS/Messages.json';
$data = array('To' => $sms_to, 'From' => $sms_sender, 'Body' => $sms_msg);
if (trim($plugin_config['twilio']['callback_url'])) {
$data['StatusCallback'] = trim($plugin_config['twilio']['callback_url']);
}
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, $plugin_config['twilio']['account_sid'] . ':' . $plugin_config['twilio']['auth_token']);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$returns = curl_exec($ch);
curl_close($ch);
logger_print("url:" . $url . " callback:" . $plugin_config['twilio']['callback_url'], 3, "twilio outgoing");
$resp = json_decode($returns);
if ($resp->status) {
$c_status = $resp->status;
$c_message_id = $resp->sid;
$c_error_text = $c_status . '|' . $resp->code . '|' . $resp->message;
logger_print("sent smslog_id:" . $smslog_id . " message_id:" . $c_message_id . " status:" . $c_status . " error:" . $c_error_text, 2, "twilio outgoing");
$db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayTwilio (local_smslog_id,remote_smslog_id,status,error_text)\n\t\t\t\t\tVALUES ('{$smslog_id}','{$c_message_id}','{$c_status}','{$c_error_text}')";
$id = @dba_insert_id($db_query);
if ($id && $c_status == 'queued') {
$ok = true;
$p_status = 0;
} else {
$p_status = 2;
}
dlr($smslog_id, $uid, $p_status);
} else {
// even when the response is not what we expected we still print it out for debug purposes
$resp = str_replace("\n", " ", $resp);
$resp = str_replace("\r", " ", $resp);
logger_print("failed smslog_id:" . $smslog_id . " resp:" . $resp, 2, "twilio outgoing");
}
} else {
logger_print("fail to sendsms due to missing PHP curl functions", 3, "twilio_hook_sendsms");
}
}
if (!$ok) {
$p_status = 2;
dlr($smslog_id, $uid, $p_status);
}
logger_print("sendsms end", 3, "twilio_hook_sendsms");
return $ok;
}
示例9: gammu_hook_sendsms
function gammu_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "gammu_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$date = date('Ymd', time());
$time = date('Gis', time());
if ($plugin_config['gammu']['dlr']) {
$option_dlr = 'd';
} else {
$option_dlr = '';
}
// OUT<priority><date>_<time>_<serialno>_<phone_number>_<anything>.<ext><options>
$sms_id = 'A' . $date . '_' . $time . '_00_' . $sms_to . '_' . $smslog_id . '10001' . $uid . '10001' . $gpid . '.txt' . $option_dlr;
if ($sms_type == 'flash') {
$sms_id .= 'f';
}
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
// no need to do anything on unicoded messages since InboxFormat and OutboxFormat is already set to unicode
// meaning gammu will take care of it
/*
* if ($unicode) { if (function_exists('mb_convert_encoding')) { $sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto"); } }
*/
$fn = $plugin_config['gammu']['path'] . "/outbox/OUT" . $sms_id;
logger_print("saving outfile:" . $fn, 2, "gammu outgoing");
umask(0);
$fd = @fopen($fn, "w+");
@fputs($fd, $sms_msg);
@fclose($fd);
$ok = false;
if (file_exists($fn)) {
$ok = true;
$p_status = 0;
logger_print("saved outfile:" . $fn, 2, "gammu outgoing");
} else {
$p_status = 2;
logger_print("fail to save outfile:" . $fn, 2, "gammu outgoing");
}
dlr($smslog_id, $uid, $p_status);
return $ok;
}
示例10: smstools_hook_sendsms
function smstools_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log('enter smsc:' . $smsc . ' smslog_id:' . $smslog_id . ' uid:' . $uid . ' to:' . $sms_to, 3, 'smstools_hook_sendsms');
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
$the_msg = 'From: ' . $sms_sender . "\n";
$the_msg .= 'To: ' . $sms_to . "\n";
$the_msg .= "Report: yes\n";
if ($sms_type == 'flash') {
$the_msg .= "Flash: yes\n";
}
if ($unicode) {
if (function_exists('mb_convert_encoding')) {
$the_msg .= "Alphabet: UCS\n";
$sms_msg = mb_convert_encoding($sms_msg, 'UCS-2BE', 'auto');
}
// $sms_msg = str2hex($sms_msg);
}
// final message file content
$the_msg .= "\n" . $sms_msg;
// outfile
$gpid = (int) $gpid ? (int) $gpid : 0;
$uid = (int) $uid ? (int) $uid : 0;
$smslog_id = (int) $smslog_id ? (int) $smslog_id : 0;
$sms_id = $gpid . '.' . $uid . '.' . $smslog_id;
$outfile = 'out.' . $sms_id;
$fn = $plugin_config['smstools']['queue'] . '/' . $outfile;
if ($fd = @fopen($fn, 'w+')) {
@fputs($fd, $the_msg);
@fclose($fd);
_log('saving outfile:' . $fn . ' smsc:[' . $smsc . ']', 3, 'smstools_hook_sendsms');
}
$ok = false;
if (file_exists($fn)) {
$ok = true;
$p_status = 0;
_log('saved outfile:' . $fn . ' smsc:[' . $smsc . ']', 2, 'smstools_hook_sendsms');
} else {
$p_status = 2;
_log('fail to save outfile:' . $fn . ' smsc:[' . $smsc . ']', 2, 'smstools_hook_sendsms');
}
dlr($smslog_id, $uid, $p_status);
return $ok;
}
示例11: playnet_hook_webservices_output
function playnet_hook_webservices_output($operation, $requests, $returns)
{
global $plugin_config;
$go = $requests['go'];
$smsc = $requests['smsc'];
$username = $requests['u'];
$password = $requests['p'];
if (!($operation == 'playnet' && $go && $smsc && $username && $password)) {
return FALSE;
}
$c_plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
// auth remote
if (!($c_plugin_config['playnet']['local_playnet_username'] && $c_plugin_config['playnet']['local_playnet_password'] && $c_plugin_config['playnet']['local_playnet_username'] == $username && $c_plugin_config['playnet']['local_playnet_password'] == $password)) {
$content['status'] = 'ERROR';
$content['error_string'] = 'Authentication failed';
$returns['modified'] = TRUE;
$returns['param']['content'] = json_encode($content);
$returns['param']['content-type'] = 'text/json';
return $returns;
}
switch ($go) {
case 'get_outgoing':
$conditions = array('flag' => 1, 'smsc' => $smsc);
$extras = array('ORDER BY' => 'id', 'LIMIT' => $c_plugin_config['playnet']['poll_limit']);
$list = dba_search(_DB_PREF_ . '_gatewayPlaynet_outgoing', '*', $conditions, '', $extras);
foreach ($list as $data) {
$rows[] = array('smsc' => $data['smsc'], 'smslog_id' => $data['smslog_id'], 'uid' => $data['uid'], 'sender_id' => $data['sender_id'], 'sms_to' => $data['sms_to'], 'message' => $data['message'], 'sms_type' => $data['sms_type'], 'unicode' => $data['unicode']);
// update flag
$items = array('flag' => 2);
$condition = array('flag' => 1, 'id' => $data['id']);
dba_update(_DB_PREF_ . '_gatewayPlaynet_outgoing', $items, $condition, 'AND');
// update dlr
$p_status = 1;
dlr($data['smslog_id'], $data['uid'], $p_status);
}
if (count($rows)) {
$content['status'] = 'OK';
$content['data'] = $rows;
} else {
$content['status'] = 'ERROR';
$content['error_string'] = 'No outgoing data';
}
break;
case 'set_incoming':
$payload = json_decode(stripslashes($requests['payload']), 1);
if ($payload['message']) {
$sms_sender = $payload['sms_sender'];
$message = $payload['message'];
$sms_receiver = $payload['sms_receiver'];
if ($id = recvsms(core_get_datetime(), $sms_sender, $message, $sms_receiver, $smsc)) {
$content['status'] = 'OK';
$content['data'] = array('recvsms_id' => $id);
} else {
$content['status'] = 'ERROR';
$content['error_string'] = 'Unable to save incoming data';
}
} else {
$content['status'] = 'ERROR';
$content['error_string'] = 'No incoming data';
}
}
$returns['modified'] = TRUE;
$returns['param']['content'] = json_encode($content);
$returns['param']['content-type'] = 'text/json';
if ($content['status'] == 'OK') {
_log('accessed param_go:[' . $go . '] param_smsc:[' . $smsc . '] param_u:[' . $username . '] param_p:[' . $password . ']', 3, 'playnet_hook_webservices_output');
}
return $returns;
}
示例12: telerivet_hook_sendsms
function telerivet_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
$ok = false;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 2, "telerivet_hook_sendsms");
# Initialize CURL context
$api_key = $plugin_config['telerivet']['api_key'];
$project_id = $plugin_config['telerivet']['project_id'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.telerivet.com/v1/projects/{$project_id}/messages/outgoing");
curl_setopt($curl, CURLOPT_USERPWD, "{$api_key}:");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
# override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
# Pre-process parameters
$sms_sender = stripslashes($sms_sender);
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg) . $sms_footer;
# Build data array
$data = array();
$data['to_number'] = $sms_to;
$data['content'] = $sms_msg;
if (trim($plugin_config['telerivet']['status_url'])) {
$data['status_url'] = trim($plugin_config['telerivet']['status_url']);
}
if (trim($plugin_config['telerivet']['status_secret'])) {
$data['status_secret'] = trim($plugin_config['telerivet']['status_secret']);
}
# Build API query
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
_log('building http query', 3, 'telerivet_query');
# Send query to API and get result
$json = curl_exec($curl);
$network_error = curl_error($curl);
curl_close($curl);
# Catch query error
if ($network_error) {
_log('curl error:' . $network_error, 2, 'telerivet_query');
dlr($smslog_id, $uid, 2);
} else {
# Save JSON reply
$res = json_decode($json, true);
if (is_array($res)) {
foreach ($res as $key => $val) {
$log .= $key . ':' . $val . ' ';
}
_log('api response:' . $log, 3, 'telerivet_query');
}
# Catch API errors
if (isset($res['error'])) {
_log('api error' . $res['error_message'], 2, 'telerivet_query');
dlr($smslog_id, $uid, 2);
} else {
_log('api success: id:' . $res['id'] . ' status:' . $res['status'] . ' source:' . $res['source'], 2, 'telerivet_query');
}
$c_remote_id = $res['id'];
$c_status = $res['status'];
$c_phone_id = $res['phone_id'];
$c_message_type = $res['message_type'];
$c_source = $res['source'];
$c_error = $res['error_message'];
# Ref: https://telerivet.com/api/webhook#send_status
# Available status:
# sent the message has been successfully sent to the mobile network
# queued the message has not been sent yet
# failed the message has failed to send
# failed_queued the message has failed to send, but Telerivet will try to send it again later
# delivered the message has been delivered to the recipient phone (if delivery reports are enabled)
# not_delivered the message could not be delivered (if delivery reports are enabled)
# cancelled the message was cancelled by the user
# Reminder delivery status
# $p_status = 0 --> pending
# $p_status = 1 --> sent
# $p_status = 2 --> failed
# $p_status = 3 --> delivered
if ($c_remote_id && $c_status) {
$db_query = '
INSERT INTO ' . _DB_PREF_ . '_gatewayTelerivet (local_slid, remote_slid, status, phone_id, message_type, source, error_text)
VALUES (' . $smslog_id . ',"' . $c_remote_id . '","' . $c_status . '","' . $c_phone_id . '","' . $c_message_type . '","' . $c_source . '","' . $c_error . '")';
_log('sql:' . $db_query, 3, 'telerivet query');
if ($id = @dba_insert_id($db_query) && $c_status) {
switch ($c_status) {
case "queued":
$ok = true;
$p_status = 0;
break;
case "sent":
$ok = true;
$p_status = 1;
break;
case "delivered":
$ok = true;
$p_status = 3;
break;
case "failed":
case "failed_queued":
case "not_delivered":
case "cancelled":
default:
$p_status = 2;
//.........这里部分代码省略.........
示例13: bulksms_hook_sendsms
function bulksms_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
// Based on http://www.bulksms.com/int/docs/eapi/submission/send_sms/
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "bulksms_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
if ($plugin_config['bulksms']['module_sender']) {
$sms_sender = $plugin_config['bulksms']['module_sender'];
}
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$sms_from = $sms_sender;
$sms_dca = "7bit";
$sms_class = "2";
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
switch ($sms_type) {
case "flash":
$sms_class = "0";
break;
case "logo":
case "picture":
case "ringtone":
case "rtttl":
$sms_dca = "8bit";
break;
default:
$sms_dca = "7bit";
$sms_class = "2";
}
// Automatically setting the unicode flag if necessary
//if (!$unicode) {
// $unicode = core_detect_unicode($sms_msg);
//}
if ($unicode) {
$unicode = 1;
$sms_dca = "16bit";
}
// fixme anton - if sms_from is not set in gateway_number and global number, we cannot pass it to bulksms
$set_sms_from = $sms_from == $sms_sender ? '' : "&sender=" . urlencode($sms_from);
// $query_string = "submission/send_sms/2/2.0?username=" . $plugin_config['bulksms']['username'] . "&password=" . $plugin_config['bulksms']['password'] . "&msisdn=" . urlencode($sms_to) . "&msg_class=$sms_class&message=" . urlencode($sms_msg) . "&dca=" . $sms_dca . $set_sms_from;
// $url = $plugin_config['bulksms']['send_url'] . "/" . $query_string;
// if ($additional_param = $plugin_config['bulksms']['additional_param']) {
// $additional_param = "&" . $additional_param;
// } else {
// $additional_param = "routing_group=1&repliable=0";
// }
// $url .= $additional_param;
// $url = str_replace("&&", "&", $url);
// logger_print("url:" . $url, 3, "bulksms outgoing");
// $fd = @implode('', file($url));
$fd = buklsms_multiple_sms($sms_to, $sms_class, $sms_msg, $sms_dca, $set_sms_from, $unicode);
$ok = false;
// failed
$p_status = 2;
if ($fd) {
$response = explode("|", $fd);
if (count($response) == 3) {
$status_code = trim($response[0]);
$apimsgid = trim($response[2]);
bulksms_setsmsapimsgid($smslog_id, $apimsgid);
if ($status_code == '1') {
list($c_sms_credit, $c_sms_status) = bulksms_getsmsstatus($smslog_id);
// pending
$p_status = 0;
if ($c_sms_status) {
$p_status = $c_sms_status;
}
} else {
// sent
$p_status = 1;
}
logger_print("smslog_id:" . $smslog_id . " charge:" . $c_sms_credit . " sms_status:" . $p_status . " response:" . $response[0] . " " . $response[1] . " " . $response[2], 2, "bulksms outgoing");
} else {
// even when the response is not what we expected we still print it out for debug purposes
$fd = str_replace("\n", " ", $fd);
$fd = str_replace("\r", " ", $fd);
logger_print("smslog_id:" . $smslog_id . " response:" . $fd, 2, "bulksms outgoing");
}
$ok = true;
}
dlr($smslog_id, $uid, $p_status);
return $ok;
}
示例14: smstools_hook_sendsms
function smstools_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0)
{
global $plugin_config;
_log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "smstools_hook_sendsms");
// override plugin gateway configuration by smsc configuration
$plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
$sms_sender = stripslashes($sms_sender);
$sms_footer = stripslashes($sms_footer);
$sms_msg = stripslashes($sms_msg);
$sms_id = "{$gpid}.{$uid}.{$smslog_id}";
if (empty($sms_id)) {
$sms_id = mktime();
}
if ($sms_footer) {
$sms_msg = $sms_msg . $sms_footer;
}
$the_msg = "From: {$sms_sender}\n";
$the_msg .= "To: {$sms_to}\n";
$the_msg .= "Report: yes\n";
if ($sms_type == 'flash') {
$the_msg .= "Flash: yes\n";
}
if ($unicode) {
if (function_exists('mb_convert_encoding')) {
$the_msg .= "Alphabet: UCS\n";
$sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto");
}
// $sms_msg = str2hex($sms_msg);
}
$the_msg .= "\n{$sms_msg}";
// try to backup outgoing file first
$fn_bak = $plugin_config['smstools']['spool_bak'] . "/outgoing/out.{$sms_id}";
if (is_dir($plugin_config['smstools']['spool_bak'] . '/outgoing')) {
umask(0);
$fd = @fopen($fn_bak, 'w+');
@fputs($fd, $the_msg);
@fclose($fd);
}
// copy from backup if exists, or create new one in spool dir
$fn = $plugin_config['smstools']['spool_dir'] . "/outgoing/out.{$sms_id}";
if (file_exists($fn_bak)) {
logger_print("outfile backup:" . $fn_bak, 2, "smstools outgoing");
@shell_exec('cp ' . $fn_bak . ' ' . $fn);
} else {
umask(0);
$fd = @fopen($fn, 'w+');
@fputs($fd, $the_msg);
@fclose($fd);
}
logger_print("saving outfile:" . $fn, 2, "smstools outgoing");
$ok = false;
if (file_exists($fn)) {
$ok = true;
$p_status = 0;
logger_print("saved outfile:" . $fn, 2, "smstools outgoing");
} else {
$p_status = 2;
logger_print("fail to save outfile:" . $fn, 2, "smstools outgoing");
}
dlr($smslog_id, $uid, $p_status);
return $ok;
}
示例15: switch
if ($uid && $smslog_id) {
$c_sms_status = 0;
switch ($cb_status) {
case "0":
$c_sms_status = 0;
break;
// pending
// pending
case "10":
case "12":
$c_sms_status = 1;
break;
// sent
// sent
case "11":
$c_sms_status = 3;
break;
// delivered
// delivered
default:
$c_sms_status = 2;
}
// $c_sms_credit = ceil($cb_charge);
// pending
$p_status = 0;
if ($c_sms_status) {
$p_status = $c_sms_status;
}
dlr($smslog_id, $uid, $p_status);
}
}