if (is_array($requests)) { foreach ($requests as $key => $val) { $log .= $key . ':' . $val . ' '; } _log("pushed " . $log, 2, "jasmin callback"); } $remote_smslog_id = $requests['id']; $message_status = $requests['message_status']; // delivery receipt if ($remote_smslog_id && $message_status) { $db_query = "SELECT local_smslog_id FROM " . _DB_PREF_ . "_gatewayJasmin_log WHERE remote_smslog_id='{$remote_smslog_id}'"; $db_result = dba_query($db_query); $db_row = dba_fetch_array($db_result); $smslog_id = $db_row['local_smslog_id']; if ($smslog_id) { $data = sendsms_get_sms($smslog_id); $uid = $data['uid']; $p_status = $data['p_status']; switch ($message_status) { case "ESME_ROK": $p_status = 3; break; // delivered // delivered default: $p_status = 2; break; // failed } _log("dlr uid:" . $uid . " smslog_id:" . $smslog_id . " message_id:" . $remote_smslog_id . " status:" . $status, 2, "jasmin callback"); dlr($smslog_id, $uid, $p_status);
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; $d = sendsms_get_sms($smslog_id); $sms_datetime = core_sanitize_numeric($d['p_datetime']); $sms_id = $sms_datetime . '.' . $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; }