Example #1
0
function websend2group($username, $gp_code, $message, $sms_type = "text", $unicode = "0")
{
    global $apps_path;
    global $datetime_now, $gateway_module;
    $uid = username2uid($username);
    $mobile_sender = username2mobile($username);
    $sms_footer = username2footer($username);
    $sms_msg = cleanSmsMessage(appendFooter($message, $sms_footer));
    if (is_array($gp_code)) {
        $array_gp_code = $gp_code;
    } else {
        $array_gp_code[0] = $gp_code;
    }
    $j = 0;
    for ($i = 0; $i < count($array_gp_code); $i++) {
        $c_gp_code = strtoupper($array_gp_code[$i]);
        $gpid = gpcode2gpid($uid, $c_gp_code);
        $dbPhonebook = DB_DataObject::factory(playsms_tblUserPhonebook);
        $dbPhonebook->gpid = $gpid;
        $dbPhonebook->find();
        while ($dbPhonebook->fetch()) {
            $sms_to = $dbPhonebook->p_num;
            $to[$j] = $sms_to;
            $ok[$j] = 0;
            $db = DB_DataObject::factory(playsms_tblSMSOutgoing);
            $db->uid = $uid;
            $db->p_gateway = $gateway_module;
            $db->p_src = $mobile_sender;
            $db->p_dst = $sms_to;
            $db->p_footer = $sms_footer;
            $db->p_msg = $sms_msg;
            $db->p_datetime = $datetime_now;
            $db->p_sms_type = $sms_type;
            $db->unicode = $unicode;
            $db->send_tries = 1;
            $db->p_status = DLR_PENDING;
            // default to failure
            if ($db->insert()) {
                if (gw_send_sms($mobile_sender, $sms_to, $sms_msg, $c_gp_code, $uid, $db->smslog_id, $sms_type, $unicode)) {
                    $ok[$j] = $sms_to;
                }
            }
            $j++;
        }
    }
    return array($ok, $to);
}
Example #2
0
 $rows = phonebook_getgroupbyuid($uid, "gp_name");
 foreach ($rows as $key => $db_row) {
     $c_count = phonebook_getmembercountbyid($db_row['gpid']);
     $list_of_group .= "<option value=\"" . $db_row['gpid'] . "\" {$selected}>" . $db_row['gp_name'] . " (" . $db_row['gp_code'] . ")(" . $c_count . ")</option>";
 }
 // add shared group
 $rows = phonebook_getsharedgroup($uid);
 foreach ($rows as $key => $db_row) {
     $c_uid = $db_row['uid'];
     $c_username = uid2username($c_uid);
     $c_count = phonebook_getmembercountbyid($db_row['gpid']);
     $list_of_group .= "<option value=\"" . $db_row['gpid'] . "\" {$selected}>" . $db_row['gp_name'] . " (" . $db_row['gp_code'] . ")(" . $c_count . ") - " . _('shared by') . " " . $c_username . "</option>";
 }
 $sms_from = sendsms_get_sender($username);
 $max_length = $core_config['smsmaxlength'];
 if ($sms_footer = username2footer($username)) {
     $max_length = $max_length - strlen($sms_footer);
 } else {
     $sms_footer = "<i>" . _('not set') . "</i>";
 }
 // WWW
 $db_query2 = "SELECT * FROM " . _DB_PREF_ . "_tblSMSTemplate WHERE uid='{$uid}'";
 $db_result2 = dba_query($db_query2);
 $j = 0;
 $option_values = "<option value=\"\" default>--" . _('Please select') . "--</option>";
 while ($db_row = dba_fetch_array($db_result2)) {
     $j++;
     $option_values .= "<option value=\"" . $db_row['t_text'] . "\">" . $db_row['t_title'] . "</option>";
     $input_values .= "<input type=\"hidden\" name=\"content_{$j}\" value=\"" . $db_row['t_text'] . "\">";
 }
 // document.fm_sendsms.message.value = document.fm_smstemplate.content_num.value;
Example #3
0
     } else {
         if ($del_uid == $uid) {
             $error_string = _('Currently logged in user is immune to deletion');
         }
     }
     header("Location: index.php?app=menu&inc=user_mgmnt&op=user_list&err=" . urlencode($error_string));
     break;
 case "user_edit":
     $uname = $_REQUEST['uname'];
     $uid = username2uid($uname);
     $mobile = username2mobile($uname);
     $email = username2email($uname);
     $name = username2name($uname);
     $status = username2status($uname);
     $sender = username2sender($uname);
     $footer = username2footer($uname);
     $timezone = username2timezone($uname);
     $language_module = username2lang($uname);
     // get language options
     for ($i = 0; $i < count($core_config['languagelist']); $i++) {
         $language = $core_config['languagelist'][$i];
         if ($language == $language_module) {
             $selected = "selected";
         }
         $option_language_module .= "<option value=\"{$language}\" {$selected}>{$language}</option>";
         $selected = "";
     }
     $credit = rate_getusercredit($uname);
     if ($err) {
         $content = "<p><font color='red'>{$err}</font><p>";
     }
Example #4
0
function sendsms_bc($username, $gpid, $message, $sms_type = 'text', $unicode = 0)
{
    global $apps_path, $core_config, $gateway_module;
    $uid = username2uid($username);
    $sms_sender = sendsms_get_sender($username);
    $max_length = $unicode ? $core_config['smsmaxlength_unicode'] : $core_config['smsmaxlength'];
    if ($sms_footer = username2footer($username)) {
        $max_length = $max_length - strlen($sms_footer) - 1;
    }
    if (strlen($message) > $max_length) {
        $message = substr($message, 0, $max_length);
    }
    $sms_msg = $message;
    // \r and \n is ok - http://smstools3.kekekasvi.com/topic.php?id=328
    //$sms_msg = str_replace("\r","",$sms_msg);
    //$sms_msg = str_replace("\n","",$sms_msg);
    $sms_msg = str_replace("\"", "'", $sms_msg);
    // destination group should be an array, if single then make it array of 1 member
    if (is_array($gpid)) {
        $array_gpid = $gpid;
    } else {
        $array_gpid[0] = $gpid;
    }
    // create a queue
    $queue_code = sendsms_queue_create($sms_sender, $sms_footer, $sms_msg, $uid, $sms_type, $unicode);
    if (!$queue_code) {
        // when unable to create a queue then immediately returns FALSE, no point to continue
        return FALSE;
    }
    $j = 0;
    for ($i = 0; $i < count($array_gpid); $i++) {
        $c_gpid = strtoupper($array_gpid[$i]);
        $rows = phonebook_getdatabyid($c_gpid);
        foreach ($rows as $key => $db_row) {
            $p_num = $db_row['p_num'];
            $sms_to = $p_num;
            $sms_to = str_replace("\\'", "", $sms_to);
            $sms_to = str_replace("\"", "", $sms_to);
            $ok[$j] = 0;
            $to[$j] = $sms_to;
            $queue[$j] = $queue_code;
            // fill the queue with destination numbers
            if ($ret = sendsms_queue_push($queue_code, $sms_to)) {
                $ok[$j] = $ret['status'];
            }
            $j++;
        }
    }
    if (!$core_config['issendsmsd']) {
        sendsmsd($queue_code);
    }
    return array($ok, $to, $queue);
}
Example #5
0
function sendsms_bc($username, $gpid, $message, $sms_type = 'text', $unicode = 0)
{
    global $apps_path, $core_config;
    global $datetime_now, $gateway_module;
    $uid = username2uid($username);
    $sms_sender = sendsms_get_sender($username);
    $max_length = $core_config['smsmaxlength'];
    if ($sms_footer = username2footer($username)) {
        $max_length = $max_length - strlen($sms_footer) - 1;
    }
    if (strlen($message) > $max_length) {
        $message = substr($message, 0, $max_length - 1);
    }
    $sms_msg = $message;
    // \r and \n is ok - http://smstools3.kekekasvi.com/topic.php?id=328
    //$sms_msg = str_replace("\r","",$sms_msg);
    //$sms_msg = str_replace("\n","",$sms_msg);
    $sms_msg = str_replace("\"", "'", $sms_msg);
    // destination group should be an array, if single then make it array of 1 member
    if (is_array($gpid)) {
        $array_gpid = $gpid;
    } else {
        $array_gpid[0] = $gpid;
    }
    $j = 0;
    for ($i = 0; $i < count($array_gpid); $i++) {
        $c_gpid = strtoupper($array_gpid[$i]);
        $rows = phonebook_getdatabyid($c_gpid);
        foreach ($rows as $key => $db_row) {
            $p_num = $db_row['p_num'];
            $sms_to = $p_num;
            $sms_to = str_replace("\\'", "", $sms_to);
            $sms_to = str_replace("\"", "", $sms_to);
            $to[$j] = $sms_to;
            $ok[$j] = 0;
            if ($ret = sendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $c_gpid, $sms_type, $unicode)) {
                $ok[$j] = $ret['status'];
                $smslog_id[$i] = $ret['smslog_id'];
            }
            $j++;
        }
    }
    return array($ok, $to, $smslog_id);
}