コード例 #1
0
ファイル: fn.php プロジェクト: RobinKarlsen/playSMS
function phonebook_tags_clean($tags)
{
    $arr_tags = explode(' ', $tags);
    $arr_tags = array_unique($arr_tags);
    $tags = '';
    foreach ($arr_tags as $tag) {
        if ($tag) {
            $tag = strtolower(core_sanitize_alphanumeric($tag));
            if (strlen($tags) + strlen($tag) + 1 <= 250) {
                $tags .= $tag . ' ';
            } else {
                break;
            }
        }
    }
    $tags = trim($tags);
    return $tags;
}
コード例 #2
0
ファイル: fn_core.php プロジェクト: RobinKarlsen/playSMS
/**
 * Sanitize SMS sender
 */
function core_sanitize_sender($text)
{
    $text = core_sanitize_alphanumeric($text);
    $text = substr($text, 0, 16);
    if (preg_match("/^[A-Za-z]/", $text) == TRUE) {
        $text = substr($text, 0, 11);
    }
    return $text;
}
コード例 #3
0
ファイル: sms_custom.php プロジェクト: 10corp/playSMS
     break;
 case "sms_custom_add":
     $content .= _dialog() . "\n\t\t\t<h2>" . _('Manage custom') . "</h2>\n\t\t\t<h3>" . _('Add SMS custom') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_custom&op=sms_custom_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _mandatory(_('Service name')) . "</td><td><input type=text size=30 maxlength=255 name=add_service_name value=\"" . _lastpost('add_service_name') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('SMS custom keywords')) . "</td><td><input type=text size=30 maxlength=255 name=add_custom_keyword value=\"" . _lastpost('add_custom_keyword') . "\"> " . _hint('Multiple keywords seperated by space') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Receiver number') . "</td><td><input type=text size=30 maxlength=20 name=add_sms_receiver value=\"" . _lastpost('add_sms_receiver') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>" . _('Pass these parameters to custom URL field') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t" . _('Pass these parameters to custom URL field') . "\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>{SERVICENAME} " . _('will be replaced by service name') . "</li>\n\t\t\t\t\t\t\t<li>{SMSDATETIME} " . _('will be replaced by SMS incoming date/time') . "</li>\n\t\t\t\t\t\t\t<li>{SMSSENDER} " . _('will be replaced by sender number') . "</li>\n\t\t\t\t\t\t\t<li>{SMSRECEIVER} " . _('will be replaced by receiver number') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMKEYWORD} " . _('will be replaced by custom keyword') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMPARAM} " . _('will be replaced by custom parameter passed to server from SMS') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMRAW} " . _('will be replaced by SMS raw message') . "</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t" . _('Example of SMS custom URL') . "\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>" . htmlspecialchars('http://someserver.somedomain/handler.php?service={SERVICENAME}&datetime={SMSDATETIME}&sender={SMSSENDER}&receiver={SMSRECEIVER}&keyword={CUSTOMKEYWORD}&param={CUSTOMPARAM}&raw={CUSTOMRAW}') . "</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('SMS custom URL')) . "</td><td><input type=text maxlength=255 name=add_custom_url value=\"" . _lastpost('add_custom_url') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Make return as reply') . "</td><td><input type=checkbox name=add_custom_return_as_reply></td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_custom&op=sms_custom_list');
     _p($content);
     break;
 case "sms_custom_add_yes":
     $add_service_name = trim($_POST['add_service_name']);
     $add_sms_receiver = trim($_POST['add_sms_receiver']);
     $add_custom_return_as_reply = $_POST['add_custom_return_as_reply'] == 'on' ? '1' : '0';
     $add_custom_url = $_POST['add_custom_url'];
     $add_custom_keyword = strtoupper($_POST['add_custom_keyword']);
     $c_keywords = explode(' ', $add_custom_keyword);
     foreach ($c_keywords as $keyword) {
         if ($keyword) {
             if (keyword_isavail($keyword, $add_sms_receiver)) {
                 $keywords .= core_sanitize_alphanumeric($keyword) . ' ';
             } else {
                 $_SESSION['dialog']['danger'][] = sprintf(_('Keyword %s is not available'), $keyword);
             }
         }
     }
     $keywords = trim($keywords);
     if ($add_service_name && $keywords && $add_custom_url) {
         $db_query = "INSERT INTO " . _DB_PREF_ . "_featureCustom (uid,service_name,custom_keyword,sms_receiver,custom_url,custom_return_as_reply) VALUES ('" . $user_config['uid'] . "','{$add_service_name}','{$keywords}','{$add_sms_receiver}','{$add_custom_url}','{$add_custom_return_as_reply}')";
         if ($new_uid = @dba_insert_id($db_query)) {
             $_SESSION['dialog']['info'][] = sprintf(_('SMS custom with keyword %s has been added'), $keywords);
             _lastpost_empty();
         } else {
             $_SESSION['dialog']['danger'][] = _('Fail to add SMS custom');
         }
     } else {
コード例 #4
0
ファイル: mailsms_user.php プロジェクト: RobinKarlsen/playSMS
defined('_SECURE_') or die('Forbidden');
if (!auth_isvalid()) {
    auth_block();
}
switch (_OP_) {
    case "mailsms_user":
        $items_global = registry_search(0, 'features', 'mailsms');
        $items = registry_search($user_config['uid'], 'features', 'mailsms_user');
        // option enable
        $option_enable = _options(array(_('yes') => 1, _('no') => 0), $items['features']['mailsms_user']['enable']);
        $tpl = array('name' => 'mailsms_user', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'FORM_TITLE' => _('My email to SMS'), 'ACTION_URL' => _u('index.php?app=main&inc=feature_mailsms&route=mailsms_user&op=mailsms_user_save'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_PASSWORD' => _hint(_('Fill the password field to change password')), 'Email to SMS address' => _('Email to SMS address'), 'PIN for email to SMS' => _mandatory(_('PIN for email to SMS'))), 'injects' => array('option_enable', 'items_global', 'items'));
        _p(tpl_apply($tpl));
        break;
    case "mailsms_user_save":
        $continue = FALSE;
        $pin = core_sanitize_alphanumeric(substr(trim($_REQUEST['pin']), 0, 40));
        if ($pin) {
            $continue = TRUE;
        } else {
            $_SESSION['dialog']['info'][] = _('PIN is empty');
            $_SESSION['dialog']['info'][] = _('Fail to save email to SMS PIN');
        }
        if ($continue) {
            $items = array('pin' => $pin);
            registry_update($user_config['uid'], 'features', 'mailsms_user', $items);
            $items_global = registry_search(0, 'features', 'mailsms');
            if ($items_global['features']['mailsms']['enable_fetch']) {
                $enabled = 'enabled';
                $_SESSION['dialog']['info'][] = _('Email to SMS PIN has been saved');
            } else {
                $enabled = 'disabled';
コード例 #5
0
ファイル: incoming.php プロジェクト: amoskarugaba/playSMS
     _p(tpl_apply($tpl));
     break;
 case "incoming_save":
     // form pre rules
     // scan message for @username
     $pre_rules['match_username'] = (int) $_REQUEST['incoming_match_username'];
     $items['incoming_match_username'] = $pre_rules['match_username'];
     // scan message for #groupcode
     $pre_rules['match_groupcode'] = (int) $_REQUEST['incoming_match_groupcode'];
     $items['incoming_match_groupcode'] = $pre_rules['match_groupcode'];
     // form post rules
     // sandbox match receiver number and sender ID
     $post_rules['match_sender_id'] = (int) $_REQUEST['sandbox_match_sender_id'];
     $items['sandbox_match_sender_id'] = $post_rules['match_sender_id'];
     // sandbox prefix
     $post_rules['insert_prefix'] = trim(strtoupper(core_sanitize_alphanumeric($_REQUEST['sandbox_prefix'])));
     if ($post_rules['insert_prefix'] && keyword_isavail($post_rules['insert_prefix'])) {
         $_SESSION['dialog']['info'][] = _('Fail to insert keyword') . ' (' . _('keyword') . ': ' . $post_rules['insert_prefix'] . ')';
         $post_rules['insert_prefix'] = '';
     }
     $items['sandbox_prefix'] = $post_rules['insert_prefix'];
     // sandbox forward to users
     $post_rules['forward_to'] = serialize(array_unique($_REQUEST['uids']));
     $items['sandbox_forward_to'] = $post_rules['forward_to'];
     // sandbox forward to url
     $post_rules['forward_to_url'] = $_REQUEST['forward_to_url'];
     $items['sandbox_forward_to_url'] = $post_rules['forward_to_url'];
     // form settings
     // settings to leave copy on sandbox
     $items['settings_leave_copy_sandbox'] = (int) $_REQUEST['settings_leave_copy_sandbox'];
     // settings to match with all approved sender ID
コード例 #6
0
ファイル: fn.php プロジェクト: yrahman/playSMS
function themes_select_users_single($select_field_name, $selected_value = '', $tag_params = array(), $css_id = '', $css_class = '')
{
    global $user_config;
    $ret = '';
    if (core_themes_get()) {
        $ret = core_hook(core_themes_get(), 'themes_select_users_single', array($select_field_name, $selected_value, $tag_params, $css_id, $css_class));
    }
    if (!$ret) {
        if (!is_array($selected_value)) {
            $selected_value = array($selected_value);
        }
        if (auth_isadmin()) {
            $admins = user_getallwithstatus(2);
            $users = user_getallwithstatus(3);
        }
        $subusers = user_getsubuserbyuid($user_config['uid']);
        $option_user .= '<option value="0">' . _('Select users') . '</option>';
        if (count($admins) > 0) {
            $option_user .= '<optgroup label="' . _('Administrators') . '">';
            foreach ($admins as $admin) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($admin['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $admin['uid'] . '" ' . $selected . '>' . $admin['name'] . ' (' . $admin['username'] . ') - ' . _('Administrator') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        if (count($users) > 0) {
            $option_user .= '<optgroup label="' . _('Users') . '">';
            foreach ($users as $user) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($user['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $user['uid'] . '" ' . $selected . '>' . $user['name'] . ' (' . $user['username'] . ') - ' . _('User') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        if (count($subusers) > 0) {
            $option_user .= '<optgroup label="' . _('Subusers') . '">';
            foreach ($subusers as $subuser) {
                $selected = '';
                foreach ($selected_value as $sv) {
                    if ($subuser['uid'] == $sv) {
                        $selected = 'selected';
                        break;
                    }
                }
                $option_user .= '<option value="' . $subuser['uid'] . '"' . $selected . '>' . $subuser['name'] . ' (' . $subuser['username'] . ') - ' . _('Subuser') . '</option>';
            }
            $option_user .= '</optgroup>';
        }
        $css_id = trim($css_id) ? trim($css_id) : 'playsms-select-users-single-' . core_sanitize_alphanumeric($select_field_name);
        if (is_array($tag_params)) {
            foreach ($tag_params as $key => $val) {
                $params .= ' ' . $key . '="' . $val . '"';
            }
        }
        $placeholder = $tag_params['placeholder'] ? $tag_params['placeholder'] : _('Select users');
        $width = $tag_params['width'] ? $tag_params['width'] : 'resolve';
        $js = '
			<script language="javascript" type="text/javascript">
				$(document).ready(function() {
					$("#' . $css_id . '").select2({
						placeholder: "' . $placeholder . '",
						width: "' . $width . '",
						separator: [\',\'],
						tokenSeparators: [\',\'],
					});
				});
			</script>
		';
        $ret = $js . PHP_EOL . '<select name="' . $select_field_name . '" id="' . $css_id . '" class="playsms-select ' . $css_class . '" ' . $params . '>' . $option_user . '</select>';
        return $ret;
    }
}
コード例 #7
0
ファイル: gateway.php プロジェクト: yrahman/playSMS
     $c_gateway = $_REQUEST['gateway'];
     $dv = $plugin_config[$c_gateway]['_smsc_config_'] ? $plugin_config[$c_gateway]['_smsc_config_'] : array();
     foreach ($dv as $key => $val) {
         $dynamic_variables[] = array('key' => $key, 'title' => $val);
     }
     $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';
コード例 #8
0
ファイル: group.php プロジェクト: RobinKarlsen/playSMS
                 $_SESSION['dialog']['danger'][] = _('Group code already exists') . " (" . _('code') . ": {$group_code})";
             } else {
                 $_SESSION['dialog']['danger'][] = _('Unable to add group') . " (" . _('code') . ": {$group_code})";
             }
         }
     } else {
         $_SESSION['dialog']['danger'][] = _('You must fill all field');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_phonebook&route=group&op=add'));
     exit;
     break;
 case 'edit':
     $gpid = $_POST['gpid'];
     $group_name = $_POST['group_name'];
     $group_code = strtoupper(trim($_POST['group_code']));
     $group_code = core_sanitize_alphanumeric($group_code);
     $flag_sender = (int) $_POST['flag_sender'];
     $uid = $user_config['uid'];
     if ($gpid && $group_name && $group_code) {
         $db_query = "SELECT code FROM " . _DB_PREF_ . "_featurePhonebook_group WHERE uid='{$uid}' AND code='{$group_code}' AND NOT id='{$gpid}'";
         $db_result = dba_query($db_query);
         if ($db_row = dba_fetch_array($db_result)) {
             $_SESSION['dialog']['danger'][] = _('No changes have been made');
         } else {
             $string_group_edit = _('Group has been edited');
             // check whether or not theres a group code with the same name and flag_sender <> 0
             if ($flag_sender > 0) {
                 $db_query = "SELECT flag_sender FROM " . _DB_PREF_ . "_featurePhonebook_group WHERE code='{$group_code}' AND flag_sender<>0 AND NOT id='{$gpid}'";
                 $db_result = dba_query($db_query);
                 if ($db_row = dba_fetch_array($db_result)) {
                     $flag_sender = 0;
コード例 #9
0
ファイル: fn.php プロジェクト: RobinKarlsen/playSMS
/**
 * Intercept on before-process stage for incoming SMS
 *
 * @param $sms_datetime incoming
 *        SMS date/time
 * @param $sms_sender incoming
 *        SMS sender
 * @param $message incoming
 *        SMS message before interepted
 * @param $sms_receiver receiver
 *        number that is receiving incoming SMS
 * @param $reference_id reference_id
 *        data
 * @return array $ret
 */
function incoming_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver, $reference_id)
{
    $ret = array();
    $found_bc = FALSE;
    $found_pv = FALSE;
    // continue only when keyword does not exists
    $m = explode(' ', $message);
    if (!keyword_isavail($m[0])) {
        return $ret;
    }
    // get settings
    $settings = incoming_settings_get();
    // get post rules
    $pre_rules = incoming_pre_rules_get();
    // scan for #<sender's phonebook group code> and @<username> according to pre rules
    $msg = explode(' ', $message);
    if (count($msg) > 0) {
        $bc = array();
        $pv = array();
        for ($i = 0; $i < count($msg); $i++) {
            $c_text = trim($msg[$i]);
            // scan message for @username
            if ($pre_rules['match_username']) {
                if (substr($c_text, 0, 1) === '@') {
                    $pv[] = strtolower(substr($c_text, 1));
                    $found_pv = TRUE;
                }
            }
            // scan message for #groupcode
            if ($pre_rules['match_groupcode']) {
                if (substr($c_text, 0, 1) === '#') {
                    $bc[] = strtoupper(substr($c_text, 1));
                    $found_bc = TRUE;
                }
            }
        }
    }
    if ($found_bc || $found_pv) {
        _log("recvsms_intercept dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
    }
    if ($found_bc) {
        $groups = array_unique($bc);
        foreach ($groups as $key => $c_group_code) {
            $c_group_code = strtoupper($c_group_code);
            $c_group_code = core_sanitize_alphanumeric($c_group_code);
            $c_uid = user_mobile2uid($sms_sender);
            $list = phonebook_search_group($c_uid, $c_group_code, '', TRUE);
            $c_gpid = $list[0]['gpid'];
            if ($c_uid && $c_gpid) {
                $c_username = user_uid2username($c_uid);
                _log("bc g:" . $c_group_code . " gpid:" . $c_gpid . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
                sendsms_bc($c_username, $c_gpid, $message);
                _log("bc end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            }
        }
    }
    if ($found_pv) {
        $users = array_unique($pv);
        foreach ($users as $key => $c_username) {
            $c_username = core_sanitize_username($c_username);
            if ($c_uid = user_username2uid($c_username)) {
                _log("pv u:" . $c_username . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:[" . $message . "] reference_id:" . $reference_id, 3, 'incoming recvsms_intercept');
                recvsms_inbox_add($sms_datetime, $sms_sender, $c_username, $message, $sms_receiver, $reference_id);
                _log("pv end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            }
        }
    }
    return $ret;
}
コード例 #10
0
ファイル: fn.php プロジェクト: yrahman/playSMS
/**
 * Intercept on before-process stage for incoming SMS
 *
 * @param $sms_datetime incoming
 *        	SMS date/time
 * @param $sms_sender incoming
 *        	SMS sender
 * @param $message incoming
 *        	SMS message before interepted
 * @param $sms_receiver receiver
 *        	number that is receiving incoming SMS
 * @param $reference_id reference_id
 *        	data
 * @return array $ret
 */
function incoming_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver, $reference_id)
{
    $ret = array();
    $found_bc = FALSE;
    $found_pv = FALSE;
    // continue only when keyword does not exists
    $m = explode(' ', $message);
    if (!checkavailablekeyword($m[0])) {
        return $ret;
    }
    // get settings
    $settings = incoming_settings_get();
    // get post rules
    $pre_rules = incoming_pre_rules_get();
    // scan for #<sender's phonebook group code> and @<username> according to pre rules
    $msg = explode(' ', $message);
    if (count($msg) > 0) {
        $bc = array();
        $pv = array();
        for ($i = 0; $i < count($msg); $i++) {
            $c_text = trim($msg[$i]);
            // scan message for @username
            if ($pre_rules['match_username']) {
                if (substr($c_text, 0, 1) === '@') {
                    $pv[] = strtolower(substr($c_text, 1));
                    $found_pv = TRUE;
                }
            }
            // scan message for #groupcode
            if ($pre_rules['match_groupcode']) {
                if (substr($c_text, 0, 1) === '#') {
                    $bc[] = strtoupper(substr($c_text, 1));
                    $found_bc = TRUE;
                }
            }
        }
    }
    if ($found_bc || $found_pv) {
        _log("recvsms_intercept dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
    }
    if ($found_bc) {
        $groups = array_unique($bc);
        foreach ($groups as $key => $c_group_code) {
            $c_group_code = strtoupper($c_group_code);
            $c_group_code = core_sanitize_alphanumeric($c_group_code);
            $c_uid = user_mobile2uid($sms_sender);
            if ($c_uid && ($c_gpid = phonebook_groupcode2id($c_uid, $c_group_code))) {
                $c_username = user_uid2username($c_uid);
                _log("bc g:" . $c_group_code . " gpid:" . $c_gpid . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
                sendsms_bc($c_username, $c_gpid, $message);
                _log("bc end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            } else {
                // check the group_code for flag_sender<>0
                $db_query = "SELECT id,uid,flag_sender FROM " . _DB_PREF_ . "_featurePhonebook_group WHERE code='{$c_group_code}' AND flag_sender<>0";
                $db_result = dba_query($db_query);
                if ($db_row = dba_fetch_array($db_result)) {
                    $c_gpid = $db_row['id'];
                    $c_uid = $db_row['uid'];
                    $c_flag_sender = $db_row['flag_sender'];
                    if ($c_flag_sender == 2) {
                        $c_username = user_uid2username($c_uid);
                        _log("bc mobile flag_sender:" . $c_flag_sender . " username:" . $c_username . " uid:" . $c_uid . " g:" . $c_group_code . " gpid:" . $c_gpid . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
                        $sender = trim(phonebook_number2name($sms_sender, $c_username));
                        $sender = $sender ? $sender : $sms_sender;
                        sendsms_bc($c_username, $c_gpid, $sender . ":" . $message);
                        _log("bc mobile end", 3, 'incoming recvsms_intercept');
                        $ret['uid'] = $c_uid;
                        $ret['hooked'] = true;
                    } else {
                        if ($c_flag_sender == 1) {
                            // check whether sms_sender belongs to c_group_code
                            $db_query = "SELECT B.id AS id FROM " . _DB_PREF_ . "_featurePhonebook AS A\n\t\t\t\t\t\t\t\tLEFT JOIN playsms.playsms_featurePhonebook_group_contacts AS C ON A.id=C.pid\n\t\t\t\t\t\t\t\tLEFT JOIN playsms.playsms_featurePhonebook_group AS B ON B.id=C.gpid\n\t\t\t\t\t\t\t\tWHERE A.mobile LIKE '%" . substr($sms_sender, 3) . "' AND B.code='" . $c_group_code . "'";
                            $db_result = dba_query($db_query);
                            if ($db_row = dba_fetch_array($db_result)) {
                                $c_username = user_uid2username($c_uid);
                                _log("bc mobile flag_sender:" . $c_flag_sender . " username:" . $c_username . " uid:" . $c_uid . " g:" . $c_group_code . " gpid:" . $c_gpid . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
                                $sender = trim(phonebook_number2name($sms_sender, $c_username));
                                $sender = $sender ? $sender : $sms_sender;
                                sendsms_bc($c_username, $c_gpid, $sender . ":" . $message);
                                _log("bc mobile end", 3, 'incoming recvsms_intercept');
                                $ret['uid'] = $c_uid;
                                $ret['hooked'] = true;
                            }
                        }
                    }
                }
            }
        }
    }
    if ($found_pv) {
        $users = array_unique($pv);
        foreach ($users as $key => $c_username) {
            $c_username = core_sanitize_username($c_username);
            if ($c_uid = user_username2uid($c_username)) {
                _log("pv u:" . $c_username . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:[" . $message . "] reference_id:" . $reference_id, 3, 'incoming recvsms_intercept');
                recvsms_inbox_add($sms_datetime, $sms_sender, $c_username, $message, $sms_receiver, $reference_id);
                _log("pv end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            }
        }
    }
    return $ret;
}