function sendmail($mail_from, $mail_to, $mail_subject = "", $mail_body = "") { global $core_config; $ok = false; for ($c = 0; $c < count($core_config['toolslist']); $c++) { if (x_hook($core_config['toolslist'][$c], 'sendmail', array($mail_from, $mail_to, $mail_subject, $mail_body))) { logger_print("sent from:" . $mail_from . " to:" . $mail_to . " subject:" . $mail_subject, 3, "sendmail"); $ok = true; break; } } return $ok; }
/** * Get billing data or information for specific SMS log ID * @param integer $smslog_id SMS log ID * @return array Billing information */ function billing_getdata($smslog_id) { global $core_config; $ret = array(); if ($smslog_id) { for ($c = 0; $c < count($core_config['toolslist']); $c++) { if ($ret = x_hook($core_config['toolslist'][$c], 'billing_getdata', array($smslog_id))) { break; } } } return $ret; }
function rate_refund($smslog_id) { global $core_config; $ok = false; if ($smslog_id) { for ($c = 0; $c < count($core_config['toolslist']); $c++) { if (x_hook($core_config['toolslist'][$c], 'rate_refund', array($smslog_id))) { $ok = true; break; } } } return $ok; }
function uplink_hook_playsmsd() { // force to check p_status=1 (sent) as getsmsstatus only check for p_status=0 (pending) //$db_query = "SELECT * FROM "._DB_PREF_."_tblSMSOutgoing WHERE p_status=0 OR p_status=1"; $db_query = "SELECT * FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE p_status='1' AND p_gateway='uplink'"; $db_result = dba_query($db_query); while ($db_row = dba_fetch_array($db_result)) { $uid = $db_row['uid']; $smslog_id = $db_row['smslog_id']; $p_datetime = $db_row['p_datetime']; $p_update = $db_row['p_update']; $gpid = $db_row['p_gpid']; x_hook('uplink', 'getsmsstatus', array($gpid, $uid, $smslog_id, $p_datetime, $p_update)); } }
function geturl($cp_ext = '', $arr_mgame = array()) { $url = x_hook($cp_ext, 'get_url', $arr_mgame); return $url; }
include $fn; } break; case 'call': // $app=call to access subroutine in a plugin // can be used to replace callback.php in clickatell or dlr.php and geturl.php in kannel // plugin's category such as feature, tools or gateway $cat = trim($_REQUEST['cat']); // plugin's name such as kannel, sms_board or sms_subscribe $plugin = trim($_REQUEST['plugin']); if (function_exists('bindtextdomain')) { bindtextdomain('messages', $apps_path['plug'] . '/' . $cat . '/' . $plugin . '/language/'); bind_textdomain_codeset('messages', 'UTF-8'); textdomain('messages'); } x_hook($plugin, 'call', array($_REQUEST)); break; case 'page': // $app=page to access a page inside themes // by default this is used for displaying 'forgot password' page and 'register an account' page // login, logout, register, forgot password, noaccess switch ($op) { case 'auth_login': case 'auth_logout': case 'auth_forgot': case 'auth_register': if (function_exists($op)) { call_user_func($op); } break; default:
function playsmsd() { global $core_config, $gateway_module; // plugin tools for ($c = 0; $c < count($core_config['toolslist']); $c++) { x_hook($core_config['toolslist'][$c], 'playsmsd'); } // plugin feature for ($c = 0; $c < count($core_config['featurelist']); $c++) { x_hook($core_config['featurelist'][$c], 'playsmsd'); } // plugin gateway x_hook($gateway_module, 'playsmsd'); }
function webservices_output($ta, $requests) { $ta = strtolower($ta); $ret = x_hook($ta, 'webservices_output', array($ta, $requests)); return $ret; }
function phonebook_getgroupbyuid($uid, $orderby = "") { global $core_config; $ret = array(); for ($c = 0; $c < count($core_config['toolslist']); $c++) { if ($ret = x_hook($core_config['toolslist'][$c], 'phonebook_getgroupbyuid', array($uid, $orderby))) { break; } } return $ret; }
function sendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid = 0, $sms_type = 'text', $unicode = 0) { global $core_config, $gateway_module; $user = user_getdatabyuid($uid); $username = $user['username']; $sms_to = sendsms_getvalidnumber($sms_to); $sms_to = sendsms_manipulate_prefix($sms_to, $user); // make sure sms_datetime is in supported format and in GMT+0 // timezone used for outgoing message is not module timezone, but default timezone // module gateway may have set already to +0000 (such kannel and clickatell) $sms_datetime = core_adjust_datetime($core_config['datetime']['now'], $core_config['main']['cfg_datetime_timezone']); // sent sms will be handled by plugin/tools/* first $ret_intercept = interceptsendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $sms_type, $unicode); if ($ret_intercept['modified']) { $sms_sender = $ret_intercept['param']['sms_sender'] ? $ret_intercept['param']['sms_sender'] : $sms_sender; $sms_footer = $ret_intercept['param']['sms_footer'] ? $ret_intercept['param']['sms_footer'] : $sms_footer; $sms_to = $ret_intercept['param']['sms_to'] ? $ret_intercept['param']['sms_to'] : $sms_to; $sms_msg = $ret_intercept['param']['sms_msg'] ? $ret_intercept['param']['sms_msg'] : $sms_msg; $uid = $ret_intercept['param']['uid'] ? $ret_intercept['param']['uid'] : $uid; $gpid = $ret_intercept['param']['gpid'] ? $ret_intercept['param']['gpid'] : $gpid; $sms_type = $ret_intercept['param']['sms_type'] ? $ret_intercept['param']['sms_type'] : $sms_type; $unicode = $ret_intercept['param']['unicode'] ? $ret_intercept['param']['unicode'] : $unicode; } // if hooked function returns cancel=true then stop the sending, return false if ($ret_intercept['cancel']) { logger_print("cancelled:{$uid},{$gpid},{$gateway_module},{$sms_sender},{$sms_to},{$sms_type},{$unicode}", 3, "sendsms"); $ret['status'] = false; return $ret; } // fixme anton - mobile number can be anything, screened by gateway // $sms_sender = sendsms_getvalidnumber($sms_sender); $ok = false; logger_print("start", 3, "sendsms"); if (rate_cansend($username, $sms_to)) { // fixme anton - its a total mess ! need another DBA - we dont need this anymore //$sms_footer = addslashes(trim($sms_footer)); //$sms_msg = addslashes($sms_msg); // we save all info first and then process with gateway module // the thing about this is that message saved may not be the same since gateway may not be able to process // message with that length or certain characters in the message are not supported by the gateway $db_query = "\n\t\t\tINSERT INTO " . _DB_PREF_ . "_tblSMSOutgoing \n\t\t\t(uid,p_gpid,p_gateway,p_src,p_dst,p_footer,p_msg,p_datetime,p_sms_type,unicode) \n\t\t\tVALUES ('{$uid}','{$gpid}','{$gateway_module}','{$sms_sender}','{$sms_to}','{$sms_footer}','{$sms_msg}','{$sms_datetime}','{$sms_type}','{$unicode}')\n\t\t"; logger_print("saving:{$uid},{$gpid},{$gateway_module},{$sms_sender},{$sms_to},{$sms_type},{$unicode}", 3, "sendsms"); // continue to gateway only when save to db is true if ($smslog_id = @dba_insert_id($db_query)) { logger_print("smslog_id:" . $smslog_id . " saved", 3, "sendsms"); // fixme anton - another mess with slashes! also trim $sms_footer and prefix it with a space $sms_footer = ' ' . stripslashes(trim($sms_footer)); $sms_msg = stripslashes($sms_msg); if (x_hook($gateway_module, 'sendsms', array($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $smslog_id, $sms_type, $unicode))) { // fixme anton - deduct user's credit as soon as gateway returns true rate_deduct($smslog_id); $ok = true; } } } logger_print("end", 3, "sendsms"); $ret['status'] = $ok; $ret['smslog_id'] = $smslog_id; return $ret; }