Esempio n. 1
0
function simplerate_hook_rate_getcharges($sms_len, $unicode, $sms_to)
{
    global $core_config;
    // get sms count
    $length = $unicode ? 70 : 160;
    $count = 1;
    if ($core_config['main']['sms_max_count'] > 1) {
        if ($sms_len > $length) {
            $count = ceil($sms_len / ($length - 7));
        }
    }
    // calculate charges
    $rate = rate_getbyprefix($sms_to);
    $charge = $count * $rate;
    return array($count, $rate, $charge);
}
Esempio n. 2
0
function simplerate_hook_rate_getcharges($uid, $sms_len, $unicode, $sms_to)
{
    global $user_config;
    // default length per SMS
    $length = $unicode ? 70 : 160;
    // connector pdu length
    $minus = $unicode ? 3 : 7;
    // count unicodes as normal SMS
    $user = user_getdatabyuid($uid);
    if ($unicode && $user['opt']['enable_credit_unicode']) {
        $length = 140;
    }
    // get sms count
    $count = 1;
    if ($sms_len > $length) {
        $count = ceil($sms_len / ($length - $minus));
    }
    // calculate charges
    $rate = rate_getbyprefix($sms_to);
    $charge = $count * $rate;
    _log('uid:' . $uid . ' u:' . $user['username'] . ' len:' . $sms_len . ' unicode:' . $unicode . ' to:' . $sms_to . ' enable_credit_unicode:' . (int) $user['opt']['enable_credit_unicode'] . ' count:' . $count . ' rate:' . $rate . ' charge:' . $charge, 3, 'simplerate_hook_rate_getcharges');
    return array($count, $rate, $charge);
}