Esempio n. 1
0
function sendsms_manipulate_prefix($number, $user)
{
    global $core_config;
    _log('before prefix manipulation:[' . $number . ']', 3, 'sendsms_manipulate_prefix');
    if (is_array($user)) {
        $prefix = core_sanitize_numeric($user['replace_zero']);
        $local_length = (int) $user['local_length'];
        // if prefix exists then replace prefix 0 with supplied prefix
        if ($prefix) {
            $number = preg_replace('/^0/', $prefix, $number);
        }
        // if length of number is equal to $local_length then add supplied prefix
        if ($local_length > 0 && strlen(core_sanitize_numeric($number)) == $local_length) {
            $number = $prefix . $number;
        }
        // remove plus sign
        if ($core_config['main']['plus_sign_remove']) {
            $number = str_replace('+', '', $number);
        }
        // remove plus sign then add single plus sign
        if ($core_config['main']['plus_sign_add']) {
            $number = str_replace('+', '', $number);
            $number = '+' . $number;
        }
    }
    _log('after prefix manipulation:[' . $number . ']', 3, 'sendsms_manipulate_prefix');
    return $number;
}
Esempio n. 2
0
/**
 * Add country
 * @param string $name Country name
 * @param string $code Country code
 * @param string $prefix Country prefix
 * @return boolean
 */
function country_add($name, $code, $prefix = '')
{
    $ret = FALSE;
    if (!$name) {
        return FALSE;
    }
    $code = substr(0, 2, core_sanitize_alpha(strtolower(trim($code))));
    if (!$code) {
        return FALSE;
    }
    $prefix = trim($prefix) ? core_sanitize_numeric($prefix) : '';
    $db_table = _DB_PREF_ . '_tblCountry';
    if (dba_isavail($db_table, array('country_name' => $name, 'country_code' => $code))) {
        $items = array('name' => $name, 'code' => $code, 'prefix' => $prefix);
        if ($result = dba_add($db_table, $items)) {
            logger_print('id:' . $result . ' name:' . $name . ' code:' . $code . ' prefix:' . $prefix, 3, 'country_add');
            $ret = TRUE;
        }
    }
    return $ret;
}
Esempio n. 3
0
            $select_smsc .= "<option>" . $smsc_name . "</option>";
        }
        $select_smsc .= "</select>";
        $content .= "\n\t\t\t<h2>" . _('Route outgoing SMS') . "</h2>\n\t\t\t<h3>" . _('Add route') . "</h3>\n\t\t\t<form action='index.php?app=main&inc=feature_outgoing&op=outgoing_add_yes' method='post'>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('User') . "</td><td>" . $select_users . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _mandatory(_('Destination name')) . "</td><td><input type='text' maxlength='30' name='add_dst' value=\"{$add_dst}\" required></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _mandatory(_('Prefix')) . "</td><td><input type='text' maxlength=8 name='add_prefix' value=\"{$add_prefix}\" required> " . _hint(_('Maximum 8 digits numeric only')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('SMSC') . "</td><td>" . $select_smsc . "</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<input type='submit' class='button' value='" . _('Save') . "'>\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_outgoing&op=outgoing_list');
        _p($content);
        break;
    case "outgoing_add_yes":
        $add_uid = $_REQUEST['add_uid'];
        if ($add_uid) {
            $add_username = user_uid2username($add_uid);
            if (!$add_username) {
                $add_uid = 0;
            }
        }
        $add_dst = $_POST['add_dst'];
        $add_prefix = $_POST['add_prefix'];
        $add_prefix = core_sanitize_numeric($add_prefix);
        $add_prefix = (string) substr($add_prefix, 0, 8);
        $add_smsc = $_POST['add_smsc'] ? $_POST['add_smsc'] : 'blocked';
        if ($add_dst) {
            $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featureOutgoing (uid,dst,prefix,smsc)\n\t\t\t\t\tVALUES ('{$add_uid}','{$add_dst}','{$add_prefix}','{$add_smsc}')";
            if ($new_uid = @dba_insert_id($db_query)) {
                $_SESSION['error_string'] = _('Route has been added') . " (" . _('destination') . ": {$add_dst}, " . _('prefix') . ": {$add_prefix})";
            }
        } else {
            $_SESSION['error_string'] = _('You must fill all fields');
        }
        header("Location: " . _u('index.php?app=main&inc=feature_outgoing&op=outgoing_add'));
        exit;
        break;
}
Esempio n. 4
0
     break;
 case "outgoing_add_yes":
     $add_uid = $_REQUEST['add_uid'];
     if ($add_uid) {
         $add_username = user_uid2username($add_uid);
         if (!$add_username) {
             $add_uid = 0;
         }
     }
     $add_dst = $_POST['add_dst'];
     // sanitize prefixes
     $add_prefix = $_POST['add_prefix'];
     $prefixes = explode(',', $add_prefix);
     $add_prefix = '';
     foreach ($prefixes as $c_prefix) {
         $c_prefix = core_sanitize_numeric($c_prefix);
         if ($c_prefix = (string) substr($c_prefix, 0, 8)) {
             $add_prefix .= '[' . $c_prefix . '],';
         }
     }
     $add_prefix = rtrim(trim($add_prefix), ',');
     $add_smsc = $_POST['add_smsc'] ? $_POST['add_smsc'] : 'blocked';
     if ($add_dst) {
         $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featureOutgoing (uid,dst,prefix,smsc)\n\t\t\t\t\tVALUES ('{$add_uid}','{$add_dst}','{$add_prefix}','{$add_smsc}')";
         if ($new_uid = @dba_insert_id($db_query)) {
             $_SESSION['dialog']['info'][] = _('Route has been added') . " (" . _('destination') . ": {$add_dst}, " . _('prefix') . ": " . outgoing_display_prefix($add_prefix) . ")";
         } else {
             $_SESSION['dialog']['danger'][] = _('Fail to add route') . " (" . _('destination') . ": {$add_dst}, " . _('prefix') . ": " . outgoing_display_prefix($add_prefix) . ")";
         }
     } else {
         $_SESSION['dialog']['danger'][] = _('You must fill all fields');
Esempio n. 5
0
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;
}
Esempio n. 6
0
function outgoing_mobile2smsc($mobile, $uid = 0)
{
    $mobile = core_sanitize_numeric($mobile);
    if (strlen($mobile) < 8) {
        $prefix = substr($mobile, 0, strlen($mobile));
    } else {
        $prefix = substr($mobile, 0, 8);
    }
    for ($i = 8; $i > 0; $i--) {
        $c_prefix = substr($mobile, 0, $i);
        if ($smsc = outgoing_prefix2smsc($c_prefix, $uid)) {
            $ret = $smsc;
            break;
        } else {
            if ($smsc = outgoing_prefix2smsc($c_prefix)) {
                $ret = $smsc;
                break;
            }
        }
    }
    return $ret;
}