[solved] Sendsms intercept, how to prevent playsms from send outgoing sms?

I´ve created a plugin to do some checks on outgoing sms, and, based on a condition (invalid dst number), not send some sms.

The plugin is being executed, but the sms is always been sent. My plugin name is check_dst.

Do I have to put something else on return to get what I need?

My function is:

function check_dst_hook_sendsms_intercept($sms_sender,$sms_footer,$sms_to,$sms_msg,$uid,$gpid=0,$sms_type='text',$unicode=0) {

                $validNumber = sendsms_validatenumber($sms_to);
                // $validNumber = false;
                if(!$validNumber) {
                        $ret['cancel'] = true;
                        $ret['hooked'] = true;
                        $ret['modified'] = true;
                        logger_print("destino invalido " . $sms_to, 3, "check_dst");
                }

                return $ret;
}

Thanks in advance.

Seems that this code on sendsms/fn.php is not working:

    // if hooked function returns cancel=true then stop the sending, return false
    if ($ret_intercept['cancel']) {
            _log("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;
    }

Thanks in advance,

Edilson

Solved.

Found that $ret[‘cancel’] was overwritten by plugins executed after mine.

However, sms cancelled are not shown by reports, right? Then, I prefer route them to blocked gateway.

Thanks.

how do you set the smsc to blocked ?

anton

Hi Anton,

function zcheck_dst_hook_sendsms_intercept($sms_sender,$sms_footer,$sms_to,$sms_msg,$uid,$gpid=0,$sms_type=‘text’,$unicode=0) {

            $validNumber = sendsms_validatenumber($sms_to);

            if(!$validNumber) {
                    $ret['hooked'] = true;
                    $ret['modified'] = true;
                    $ret['param']['smsc'] = 'blocked';

                    logger_print("invalid destination " . $sms_to, 3, "check_dst");
            }

            return $ret;

}

And renamed my plugin to zcheck_dst

2 Likes