コード例 #1
0
ファイル: fn_dlr.php プロジェクト: yrahman/playSMS
function getsmsstatus()
{
    $smsc = core_smsc_get();
    $smsc_data = gateway_get_smscbyname($smsc);
    $gateway = $smsc_data['gateway'];
    $db_query = "SELECT * FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE p_status='0' AND p_gateway='{$smsc}'";
    $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'];
        core_hook($gateway, 'getsmsstatus', array($gpid, $uid, $smslog_id, $p_datetime, $p_update));
    }
}
コード例 #2
0
ファイル: fn.php プロジェクト: 10corp/playSMS
function getsmsinbox()
{
    $smscs = gateway_getall_smsc_names();
    foreach ($smscs as $smsc) {
        $smsc_data = gateway_get_smscbyname($smsc);
        $gateways[] = $smsc_data['gateway'];
    }
    if (is_array($gateways)) {
        $gateways = array_unique($gateways);
        foreach ($gateways as $gateway) {
            core_hook($gateway, 'getsmsinbox');
        }
    }
}
コード例 #3
0
ファイル: fn.php プロジェクト: yrahman/playSMS
function sendsms_process($smslog_id, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid = 0, $sms_type = 'text', $unicode = 0, $queue_code = '', $smsc = '')
{
    global $user_config;
    $ok = false;
    $user = $user_config;
    if ($uid && $user['uid'] != $uid) {
        $user = user_getdatabyuid($uid);
    }
    $username = $user['username'];
    $sms_to = sendsms_getvalidnumber($sms_to);
    // now on sendsms()
    // $sms_to = sendsms_manipulate_prefix($sms_to, $user);
    $sms_datetime = core_get_datetime();
    // sent sms will be handled by plugins first
    $ret_intercept = sendsms_intercept($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $sms_type, $unicode, $smsc);
    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;
        $smsc = $ret_intercept['param']['smsc'] ? $ret_intercept['param']['smsc'] : $smsc;
    }
    // if hooked function returns cancel=true then stop the sending, return false
    if ($ret_intercept['cancel']) {
        logger_print("end with cancelled smslog_id:" . $smslog_id . " uid:" . $uid . " gpid:" . $gpid . " smsc:" . $smsc . " s:" . $sms_sender . " to:" . $sms_to . " type:" . $sms_type . " unicode:" . $unicode, 2, "sendsms_process");
        $ret['status'] = false;
        return $ret;
    }
    // get active gateway module as default gateway
    if (!$smsc) {
        $smsc = core_smsc_get();
    }
    // set no gateway if no default gateway selected
    if (!$smsc) {
        $smsc = 'blocked';
    }
    // a hack to remove \r from \r\n
    // the issue begins with ENTER being \r\n and detected as 2 chars
    // and since the javascript message counter can't detect it as 2 chars
    // thus the message length counts is inaccurate
    $sms_msg = str_replace("\r\n", "\n", $sms_msg);
    // just to make sure its length, we need to stripslashes message before enter other procedures
    $sms_sender = stripslashes($sms_sender);
    $sms_msg = stripslashes($sms_msg);
    $sms_footer = stripslashes($sms_footer);
    // fixme anton - mobile number can be anything, screened by gateway
    // $sms_sender = sendsms_getvalidnumber($sms_sender);
    // fixme anton - add a space in front of $sms_footer
    if (trim($sms_footer)) {
        $sms_footer = ' ' . trim($sms_footer);
    }
    logger_print("start", 2, "sendsms_process");
    if (rate_cansend($username, strlen($sms_msg . $sms_footer), $unicode, $sms_to)) {
        $p_status = 0;
    } else {
        logger_print("end with fail not enough credit smslog_id:" . $smslog_id, 2, "sendsms_process");
        $ret['status'] = true;
        // set TRUE to stop queue
        $ret['to'] = $sms_to;
        $ret['smslog_id'] = $smslog_id;
        $ret['p_status'] = 2;
        // set failed
        return $ret;
    }
    // message entering this proc already stripslashed, we need to addslashes it before saving to db
    $sms_sender = addslashes($sms_sender);
    $sms_msg = addslashes($sms_msg);
    $sms_footer = addslashes($sms_footer);
    // 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\tINSERT INTO " . _DB_PREF_ . "_tblSMSOutgoing \n\t\t(smslog_id,uid,p_gpid,p_gateway,p_src,p_dst,p_footer,p_msg,p_datetime,p_status,p_sms_type,unicode,queue_code) \n\t\tVALUES ('{$smslog_id}','{$uid}','{$gpid}','{$smsc}','{$sms_sender}','{$sms_to}','{$sms_footer}','{$sms_msg}','{$sms_datetime}','{$p_status}','{$sms_type}','{$unicode}','{$queue_code}')";
    logger_print("saving smslog_id:" . $smslog_id . " u:" . $uid . " g:" . $gpid . " smsc:" . $smsc . " s:" . $sms_sender . " d:" . $sms_to . " type:" . $sms_type . " unicode:" . $unicode . " status:" . $p_status, 2, "sendsms");
    // continue to gateway only when save to db is true
    if ($id = @dba_insert_id($db_query)) {
        logger_print("saved smslog_id:" . $smslog_id . " id:" . $id, 2, "sendsms_process");
        if ($p_status == 0) {
            $smsc = gateway_get_smscbyname($smsc);
            logger_print("final smslog_id:" . $smslog_id . " gw:" . $smsc['gateway'] . " smsc:" . $smsc['name'] . " message:" . $sms_msg . $sms_footer . " len:" . strlen($sms_msg . $sms_footer), 3, "sendsms");
            if (core_hook($smsc['gateway'], 'sendsms', array($smsc['name'], $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;
            } else {
                logger_print("fail no hook for sendsms", 2, "sendsms_process");
            }
        }
    } else {
        logger_print("fail to save in db table smslog_id:" . $smslog_id, 2, "sendsms_process");
    }
    logger_print("end", 2, "sendsms_process");
    $ret['status'] = $ok;
    $ret['to'] = $sms_to;
    $ret['smslog_id'] = $smslog_id;
    $ret['p_status'] = $p_status;
    return $ret;
}
コード例 #4
0
ファイル: fn_core.php プロジェクト: RobinKarlsen/playSMS
/**
 * Get default gateway based on default SMSC
 *
 * @global array $core_config
 * @return string
 */
function core_gateway_get()
{
    global $core_config;
    $ret = core_call_hook();
    if (!$ret) {
        $smsc = core_smsc_get();
        $smsc_data = gateway_get_smscbyname($smsc);
        $gateway = $smsc_data['gateway'];
        return $gateway;
    }
    return $ret;
}
コード例 #5
0
ファイル: fn.php プロジェクト: RobinKarlsen/playSMS
function gateway_decide_smsc($smsc_supplied, $smsc_configured)
{
    // default is the supplied
    $smsc = $smsc_supplied;
    // decision logic
    if ($smsc_configured) {
        if ($smsc_configured == '_smsc_routed_') {
            $smsc = '';
        } else {
            if ($smsc_configured == '_smsc_supplied_') {
                $smsc = $smsc_supplied;
            } else {
                $smsc = $smsc_configured;
            }
        }
    }
    // validate
    if ($smsc) {
        $smsc_data = gateway_get_smscbyname($smsc);
        $smsc = $smsc_data['name'] ? $smsc_data['name'] : 'blocked';
    }
    // log it
    _log('SMSC supplied:[' . $smsc_supplied . '] configured:[' . $smsc_configured . '] decided smsc:[' . $smsc . ']', 3, 'gateway_decide_smsc');
    return $smsc;
}
コード例 #6
0
ファイル: fn_webservices.php プロジェクト: 10corp/playSMS
function webservices_output($operation, $requests, $returns)
{
    global $core_config;
    // default returns
    $returns = array('modified' => TRUE, 'param' => array('operation' => $operation, 'content' => '', 'content-type' => 'text/json', 'charset' => 'utf-8'));
    // plugin feature
    for ($c = 0; $c < count($core_config['plugins']['list']['feature']); $c++) {
        if ($ret_intercept = core_hook($core_config['plugins']['list']['feature'][$c], 'webservices_output', array($operation, $requests, $returns))) {
            if ($ret_intercept['modified']) {
                $returns['modified'] = TRUE;
                $returns['param']['operation'] = $ret_intercept['param']['operation'] ? $ret_intercept['param']['operation'] : $returns['param']['operation'];
                $returns['param']['content'] = $ret_intercept['param']['content'] ? $ret_intercept['param']['content'] : $returns['param']['content'];
                $returns['param']['content-type'] = $ret_intercept['param']['content-type'] ? $ret_intercept['param']['content-type'] : $returns['param']['content-type'];
                $returns['param']['charset'] = $ret_intercept['param']['charset'] ? $ret_intercept['param']['charset'] : $returns['param']['charset'];
            }
        }
    }
    // plugin gateway
    $smscs = gateway_getall_smsc_names();
    foreach ($smscs as $smsc) {
        $smsc_data = gateway_get_smscbyname($smsc);
        $gateways[] = $smsc_data['gateway'];
    }
    if (is_array($gateways)) {
        $gateways = array_unique($gateways);
        foreach ($gateways as $gateway) {
            if ($ret_intercept = core_hook($gateway, 'webservices_output', array($operation, $requests, $returns))) {
                if ($ret_intercept['modified']) {
                    $returns['modified'] = TRUE;
                    $returns['param']['operation'] = $ret_intercept['param']['operation'] ? $ret_intercept['param']['operation'] : $returns['param']['operation'];
                    $returns['param']['content'] = $ret_intercept['param']['content'] ? $ret_intercept['param']['content'] : $returns['param']['content'];
                    $returns['param']['content-type'] = $ret_intercept['param']['content-type'] ? $ret_intercept['param']['content-type'] : $returns['param']['content-type'];
                    $returns['param']['charset'] = $ret_intercept['param']['charset'] ? $ret_intercept['param']['charset'] : $returns['param']['charset'];
                }
            }
        }
    }
    // plugin themes
    if ($ret_intercept = core_hook(core_themes_get(), 'webservices_output', array($operation, $requests, $returns))) {
        if ($ret_intercept['modified']) {
            $returns['modified'] = TRUE;
            $returns['param']['operation'] = $ret_intercept['param']['operation'] ? $ret_intercept['param']['operation'] : $returns['param']['operation'];
            $returns['param']['content'] = $ret_intercept['param']['content'] ? $ret_intercept['param']['content'] : $returns['param']['content'];
            $returns['param']['content-type'] = $ret_intercept['param']['content-type'] ? $ret_intercept['param']['content-type'] : $returns['param']['content-type'];
            $returns['param']['charset'] = $ret_intercept['param']['charset'] ? $ret_intercept['param']['charset'] : $returns['param']['charset'];
        }
    }
    return $returns;
}
コード例 #7
0
ファイル: gateway.php プロジェクト: yrahman/playSMS
     }
     $tpl = array('name' => 'gateway_add_smsc', 'vars' => array('FORM_TITLE' => _('Add SMSC'), 'ACTION_URL' => 'index.php?app=main&inc=core_gateway&op=add_smsc_save', 'GATEWAY' => $c_gateway, 'BACK' => _back('index.php?app=main&inc=core_gateway&op=gateway_list'), 'Gateway' => _('Gateway'), 'SMSC name' => _mandatory(_('SMSC name')), 'Save' => _('Save')), 'loops' => array('dynamic_variables' => $dynamic_variables));
     $content = tpl_apply($tpl);
     break;
 case 'add_smsc_save':
     $c_gateway = gateway_valid_name($_REQUEST['gateway']);
     // do not add dev and blocked
     $continue = FALSE;
     if (!($c_gateway == 'dev' || $c_gateway == 'blocked')) {
         $continue = TRUE;
     }
     $c_name = core_sanitize_alphanumeric(strtolower($_REQUEST['name']));
     if (!$c_name) {
         $c_name = mktime();
     }
     $smsc = gateway_get_smscbyname($c_name);
     if ($smsc['name']) {
         $_SESSION['error_string'] = _('SMSC already exists');
     } else {
         if ($c_name && $c_gateway) {
             $dv = $plugin_config[$c_gateway]['_smsc_config_'] ? $plugin_config[$c_gateway]['_smsc_config_'] : array();
             $dynamic_variables = array();
             foreach ($dv as $key => $val) {
                 $dynamic_variables[$key] = $_REQUEST[$key];
             }
             $items = array('created' => core_get_datetime(), 'name' => $c_name, 'gateway' => $c_gateway, 'data' => json_encode($dynamic_variables));
             $db_table = _DB_PREF_ . '_tblGateway';
             if ($new_id = dba_add($db_table, $items)) {
                 $_SESSION['error_string'] = _('New SMSC has been added');
             } else {
                 $_SESSION['error_string'] = _('Fail to add new SMSC');
コード例 #8
0
ファイル: fn.php プロジェクト: yrahman/playSMS
function getsmsinbox()
{
    $smsc = core_smsc_get();
    $smsc_data = gateway_get_smscbyname($smsc);
    $gateway = $smsc_data['gateway'];
    core_hook($gateway, 'getsmsinbox');
}