Ejemplo n.º 1
0
function sms_autosend_hook_playsmsd()
{
    global $core_config;
    $timenow = mktime();
    $db_query = "SELECT uid,time_id," . _DB_PREF_ . "_featureAutosend.autosend_id, autosend_message,autosend_number,autosend_time\n\t\t\t\t\t\t\tFROM " . _DB_PREF_ . "_featureAutosend\n\t\t\t\t\t\t\tINNER JOIN " . _DB_PREF_ . "_featureAutosend_time\n\t\t\t\t\t\t\tON " . _DB_PREF_ . "_featureAutosend.autosend_id =  " . _DB_PREF_ . "_featureAutosend_time.autosend_id\n\t\t\t\t\t\t\tWHERE UNIX_TIMESTAMP(" . _DB_PREF_ . "_featureAutosend_time.autosend_time) <= '{$timenow}'\n\t\t\t\t\t\t\tAND " . _DB_PREF_ . "_featureAutosend_time.sent='0'\n\t\t\t\t\t\t\tAND autosend_time != ''\n\t\t\t\t\t\t\tAND " . _DB_PREF_ . "_featureAutosend.autosend_enable='1'";
    $db_result = dba_query($db_query);
    while ($db_row = dba_fetch_array($db_result)) {
        $message = $db_row['autosend_message'];
        $c_uid = $db_row['uid'];
        $username = uid2username($c_uid);
        $sms_to = $db_row['autosend_number'];
        // we are sending to this number
        $autosend_id = $db_row['autosend_id'];
        $time_id = $db_row['time_id'];
        $unicode = 0;
        if (function_exists('mb_detect_encoding')) {
            $encoding = mb_detect_encoding($message, 'auto');
            if ($encoding != 'ASCII') {
                $unicode = 1;
            }
        }
        list($ok, $to, $smslog_id) = sendsms_pv($username, $sms_to, $message, 'text', $unicode);
        if ($ok[0]) {
            $db_query = "UPDATE " . _DB_PREF_ . "_featureAutosend_time SET sent='1' WHERE time_id = '{$time_id}'";
            $db_result = @dba_affected_rows($db_query);
        }
    }
}
Ejemplo n.º 2
0
function sms_command_handle($sms_datetime, $sms_sender, $command_keyword, $command_param = '')
{
    global $datetime_now, $plugin_config;
    $ok = false;
    $db_query = "SELECT command_exec,uid,command_return_as_reply FROM " . _DB_PREF_ . "_featureCommand WHERE command_keyword='{$command_keyword}'";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    $command_exec = $db_row['command_exec'];
    $sms_datetime = core_display_datetime($sms_datetime);
    $command_exec = str_replace("{SMSDATETIME}", "\"{$sms_datetime}\"", $command_exec);
    $command_exec = str_replace("{SMSSENDER}", "\"{$sms_sender}\"", $command_exec);
    $command_exec = str_replace("{COMMANDKEYWORD}", "\"{$command_keyword}\"", $command_exec);
    $command_exec = str_replace("{COMMANDPARAM}", "\"{$command_param}\"", $command_exec);
    $command_exec = $plugin_config['feature']['sms_command']['bin'] . "/" . $command_exec;
    $command_output = shell_exec(stripslashes($command_exec));
    $username = uid2username($db_row['uid']);
    if ($db_row['command_return_as_reply'] == 1) {
        sendsms_pv($username, $sms_sender, $command_output, 'text', 0);
    }
    $db_query = "\n\tINSERT INTO " . _DB_PREF_ . "_featureCommand_log\n\t(sms_sender,command_log_datetime,command_log_keyword,command_log_exec) \n\tVALUES\n\t('{$sms_sender}','{$datetime_now}','{$command_keyword}','{$command_exec}')\n    ";
    if ($new_id = @dba_insert_id($db_query)) {
        $ok = true;
    }
    return $ok;
}
Ejemplo n.º 3
0
function sms_board_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $board_keyword, $board_param = '')
{
    global $web_title, $email_service, $email_footer, $gateway_module, $datetime_now;
    $ok = false;
    if ($sms_sender && $board_keyword && $board_param) {
        // masked sender sets here
        $masked_sender = substr_replace($sms_sender, 'xxxx', -4);
        $db_query = "\n\t    INSERT INTO " . _DB_PREF_ . "_featureBoard_log \n\t    (in_gateway,in_sender,in_masked,in_keyword,in_msg,in_datetime) \n\t    VALUES ('{$gateway_module}','{$sms_sender}','{$masked_sender}','{$board_keyword}','{$board_param}','{$datetime_now}')\n\t";
        if ($cek_ok = @dba_insert_id($db_query)) {
            $db_query1 = "SELECT board_forward_email FROM " . _DB_PREF_ . "_featureBoard WHERE board_keyword='{$board_keyword}'";
            $db_result1 = dba_query($db_query1);
            $db_row1 = dba_fetch_array($db_result1);
            $email = $db_row1['board_forward_email'];
            if ($email) {
                // get name from c_uid's phonebook
                $c_username = uid2username($c_uid);
                $c_name = phonebook_number2name($sms_sender, $c_username);
                $sms_sender = $c_name ? $c_name . ' <' . $sms_sender . '>' : $sms_sender;
                $subject = "[SMSGW-" . $board_keyword . "] " . _('from') . " {$sms_sender}";
                $body = _('Forward WebSMS') . " ({$web_title})\n\n";
                $body .= _('Date and time') . ": {$sms_datetime}\n";
                $body .= _('Sender') . ": {$sms_sender}\n";
                $body .= _('Receiver') . ": {$sms_receiver}\n";
                $body .= _('Keyword') . ": {$board_keyword}\n\n";
                $body .= _('Message') . ":\n{$board_param}\n\n";
                $body .= $email_footer . "\n\n";
                sendmail($email_service, $email, $subject, $body);
            }
            $ok = true;
        }
    }
    return $ok;
}
Ejemplo n.º 4
0
function sms_quiz_handle($c_uid, $sms_datetime, $sms_sender, $quiz_keyword, $quiz_param = '')
{
    global $core_config, $datetime_now;
    $ok = false;
    $username = uid2username($c_uid);
    $sms_to = $sms_sender;
    // we are replying to this sender
    $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureQuiz WHERE quiz_keyword='{$quiz_keyword}'";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    if ($db_row['quiz_enable'] == 1) {
        if ($db_row['quiz_answer'] == strtoupper($quiz_param)) {
            $message = $db_row['quiz_msg_correct'];
        } else {
            $message = $db_row['quiz_msg_incorrect'];
        }
        $quiz_id = $db_row['quiz_id'];
        $answer = strtoupper($quiz_param);
        $db_query = "INSERT INTO " . _DB_PREF_ . "_featureQuiz_log (quiz_id,quiz_answer,quiz_sender,in_datetime) VALUES ('{$quiz_id}','{$answer}','{$sms_to}','{$datetime_now}')";
        if ($logged = @dba_insert_id($db_query)) {
            //list($ok,$to,$smslog_id) = sendsms_pv($username, $sms_to, $message);
            $unicode = 0;
            if (function_exists('mb_detect_encoding')) {
                $encoding = mb_detect_encoding($message, 'auto');
                if ($encoding != 'ASCII') {
                    $unicode = 1;
                }
            }
            $ret = sendsms($core_config['main']['cfg_gateway_number'], '', $sms_to, $message, $c_uid, 0, 'text', $unicode);
            // $ok = $ok[0];
            $ok = $ret['status'];
        }
    } else {
        if ($db_row['quiz_keyword'] == $quiz_keyword) {
            // returns true even if its logged as correct/incorrect answer
            // this situation happens when user answers a disabled quiz
            // returning false will make this SMS as unhandled SMS
            $ok = true;
        }
    }
    return $ok;
}
Ejemplo n.º 5
0
function sms_autoreply_handle($sms_datetime, $sms_sender, $c_uid, $autoreply_id, $autoreply_keyword, $autoreply_param = '')
{
    global $datetime_now;
    $ok = false;
    $autoreply_request = $autoreply_keyword . " " . $autoreply_param;
    $array_autoreply_request = explode(" ", $autoreply_request);
    for ($i = 0; $i < count($array_autoreply_request); $i++) {
        $autoreply_part[$i] = trim($array_autoreply_request[$i]);
        $tmp_autoreply_request .= trim($array_autoreply_request[$i]) . " ";
    }
    $autoreply_request = trim($tmp_autoreply_request);
    for ($i = 1; $i < 7; $i++) {
        $autoreply_scenario_param_list .= "autoreply_scenario_param{$i}='" . $autoreply_part[$i] . "' AND ";
    }
    $db_query = "\n\tSELECT autoreply_scenario_result FROM " . _DB_PREF_ . "_featureAutoreply_scenario \n\tWHERE autoreply_id='{$autoreply_id}' AND {$autoreply_scenario_param_list} 1=1\n    ";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    if ($autoreply_scenario_result = $db_row['autoreply_scenario_result']) {
        $db_query = "\n\t    INSERT INTO " . _DB_PREF_ . "_featureAutoreply_log\n\t    (sms_sender,autoreply_log_datetime,autoreply_log_keyword,autoreply_log_request) \n\t    VALUES\n\t    ('{$sms_sender}','{$datetime_now}','{$autoreply_keyword}','{$autoreply_request}')\n\t";
        if ($new_id = @dba_insert_id($db_query)) {
            $ok = true;
        }
    }
    if ($ok) {
        $ok = false;
        $c_username = uid2username($c_uid);
        //list($ok,$to,$smslog_id) = sendsms_pv($c_username,$sms_sender,$autoreply_scenario_result);
        //$ok = $ok[0];
        $unicode = 0;
        if (function_exists('mb_detect_encoding')) {
            $encoding = mb_detect_encoding($message, 'auto');
            if ($encoding != 'ASCII') {
                $unicode = 1;
            }
        }
        list($ok, $to, $smslog_id) = sendsms_pv($c_username, $sms_sender, $autoreply_scenario_result, 'text', $unicode);
        $ok = $ok[0];
    }
    return $ok;
}
Ejemplo n.º 6
0
function sms_custom_handle($sms_datetime, $sms_sender, $custom_keyword, $custom_param = '')
{
    global $datetime_now;
    $ok = false;
    $db_query = "SELECT custom_url,uid,custom_return_as_reply FROM " . _DB_PREF_ . "_featureCustom WHERE custom_keyword='{$custom_keyword}'";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    $custom_url = $db_row['custom_url'];
    $sms_datetime = core_display_datetime($sms_datetime);
    $custom_url = str_replace("{SMSDATETIME}", urlencode($sms_datetime), $custom_url);
    $custom_url = str_replace("{SMSSENDER}", urlencode($sms_sender), $custom_url);
    $custom_url = str_replace("{CUSTOMKEYWORD}", urlencode($custom_keyword), $custom_url);
    $custom_url = str_replace("{CUSTOMPARAM}", urlencode($custom_param), $custom_url);
    $username = uid2username($db_row['uid']);
    $debug = dba_query("INSERT INTO " . _DB_PREF_ . "_toolsDebug (value)VALUES('{$username}')");
    $url = parse_url($custom_url);
    if (!$url['port']) {
        $url['port'] = 80;
    }
    // fixme anton -deprecated when using PHP5
    //$connection = fsockopen($url['host'],$url['port'],&$error_number,&$error_description,60);
    //fixme Edward, change to file_get_contents
    $returns = file_get_contents($custom_url);
    if ($returns) {
        //fixme Edward, change to file_get_contents
        //socket_set_blocking($connection, false);
        //fputs($connection, "GET $custom_url HTTP/1.0\r\n\r\n");
        $username = uid2username($db_row['uid']);
        if ($db_row['custom_return_as_reply'] == 1) {
            sendsms_pv($username, $sms_sender, $returns, 'text', 0);
        }
        $db_query = "\n\t    INSERT INTO " . _DB_PREF_ . "_featureCustom_log\n\t    (sms_sender,custom_log_datetime,custom_log_keyword,custom_log_url) \n\t    VALUES\n\t    ('{$sms_sender}','{$datetime_now}','{$custom_keyword}','{$custom_url}')\n\t";
        if ($new_id = @dba_insert_id($db_query)) {
            $ok = true;
        }
    }
    return $ok;
}
Ejemplo n.º 7
0
function sms_survey_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $survey_keyword, $survey_param = '')
{
    global $core_config;
    $ok = false;
    // get survey data by keyword
    $data = sms_survey_getdatabykeyword($survey_keyword);
    if ($data['status'] == 1) {
        // survey enabled, accept incoming answers
        $session = $data['session'];
        $sid = $data['id'];
        $m = sms_survey_getmemberbymobile($sid, $sms_sender);
        // link_id is used to link each questions and answers
        if ($link_id = sms_survey_getlinkid($session, $sid, $m['id'])) {
            // get last question data from log
            $l = sms_survey_getoutlogs($link_id);
            $outlogs = $l[count($l) - 1];
            $qn = $outlogs['question_number'];
            $next_qn = $qn + 1;
            // save answer in log
            $log = "";
            $log['incoming'] = 1;
            $log['question_number'] = $qn;
            $log['link_id'] = $link_id;
            $log['in_datetime'] = $sms_datetime;
            $log['in_sender'] = $sms_sender;
            $log['in_receiver'] = $sms_receiver;
            $log['answer'] = $survey_param;
            $log['session'] = $session;
            if (sms_survey_savelog($log)) {
                // get next question
                $q = sms_survey_getquestions($sid);
                // stop when ran out questions
                if ($qn < count($q)) {
                    $c_message = $q[$qn]['question'];
                    // yes, not $next_qn, array questions start from 0
                    $c_username = uid2username($c_uid);
                    $c_keyword = $survey_keyword;
                    $c_sms_msg = $c_keyword . " " . $c_message;
                    $c_sms_to = $sms_sender;
                    logger_print("playsmsd send start next qn:" . $next_qn . " sid:" . $c_sid . " username:"******" to:" . $c_sms_to . " msg:" . $c_sms_msg, 3, "sms_survey");
                    // if member's mobile, question and username owned the survey exists
                    if ($c_sms_to && $c_sms_msg && $c_username) {
                        $type = 'text';
                        $unicode = '0';
                        // send next question to member
                        list($ok, $to, $smslog_id) = sendsms_pv($c_username, $c_sms_to, $c_sms_msg, $type, $unicode);
                        $ok = $ok[0] ? "true" : "false";
                        logger_print("playsmsd send finish sid:" . $c_sid . " smslog_id:" . $smslog_id[0] . " ok:" . $ok, 3, "sms_survey");
                        // save the log
                        $log = "";
                        $log['survey_id'] = $sid;
                        $log['question_id'] = $q[$qn]['id'];
                        $log['member_id'] = $m['id'];
                        $log['link_id'] = $link_id;
                        $log['smslog_id'] = $smslog_id[0];
                        $log['name'] = $m['name'];
                        $log['mobile'] = $m['mobile'];
                        $log['question'] = $q[$qn]['question'];
                        $log['question_number'] = $next_qn;
                        $log['creation_datetime'] = $core_config['datetime']['now'];
                        $log['session'] = $session;
                        sms_survey_savelog($log);
                    }
                }
                // set handled
                $ok = true;
            }
        }
    } else {
        // returns true even if its not handled since survey is disabled
        // returning false will make this SMS as unhandled SMS
        $ok = true;
    }
    return $ok;
}
Ejemplo n.º 8
0
 $db_query = "SELECT count(*) as count FROM " . _DB_PREF_ . "_tblUserInbox WHERE in_hidden='0'";
 $db_result = dba_query($db_query);
 $db_row = dba_fetch_array($db_result);
 $num_rows = $db_row['count'];
 $pages = ceil($num_rows / $line_per_page);
 $nav_pages = themes_navbar($pages, $nav, $max_nav, "index.php?app=menu&inc=all_inbox&op=all_inbox", $page);
 $limit = ($page - 1) * $line_per_page;
 $content = "\n\t    <h2>" . _('All Inbox') . "</h2>\n\t    <p>{$nav_pages}</p>\n\t    <form name=\"fm_inbox\" action=\"index.php?app=menu&inc=all_inbox&op=act_del\" method=post onSubmit=\"return SureConfirm()\">\n\t    <table cellpadding=1 cellspacing=2 border=0 width=100% class=\"sortable\">\n        <thead>\n\t    <tr>\n\t      <th align=center width=4>*</th>\n\t      <th align=center width=10%>" . _('User') . "</th>\n\t      <th align=center width=20%>" . _('Time') . "</th>\n\t      <th align=center width=10%>" . _('From') . "</th>\n\t      <th align=center width=60%>" . _('Message') . "</th>\n\t      <th align=center class=\"sorttable_nosort\">" . _('Action') . "</td>\n\t      <th width=4 class=\"sorttable_nosort\"><input type=checkbox onclick=CheckUncheckAll(document.fm_inbox)></td>\n\t    </tr>\n        </thead>\n        <tbody>\n\t";
 $db_query = "SELECT * FROM " . _DB_PREF_ . "_tblUserInbox WHERE in_hidden='0' ORDER BY in_id DESC LIMIT {$limit},{$line_per_page}";
 $db_result = dba_query($db_query);
 $i = $num_rows - $line_per_page * ($page - 1) + 1;
 $j = 0;
 while ($db_row = dba_fetch_array($db_result)) {
     $j++;
     $in_id = $db_row['in_id'];
     $in_username = uid2username($db_row['in_uid']);
     $in_sender = $db_row['in_sender'];
     $p_desc = phonebook_number2name($in_sender);
     $current_sender = $in_sender;
     if ($p_desc) {
         $current_sender = "{$in_sender}<br>({$p_desc})";
     }
     $in_msg = core_display_text($db_row['in_msg'], 25);
     $in_datetime = core_display_datetime($db_row['in_datetime']);
     $i--;
     $td_class = $i % 2 ? "box_text_odd" : "box_text_even";
     $content .= "\n\t\t<tr>\n\t          <td valign=top class={$td_class} align=left>{$i}.</td>\n\t          <td valign=top class={$td_class} align=center>{$in_username}</td>\n\t          <td valign=top class={$td_class} align=center>{$in_datetime}</td>\n\t          <td valign=top class={$td_class} align=center>{$current_sender}</td>\n\t          <td valign=top class={$td_class} align=left>{$in_msg}</td>\n\t          <td valign=top class={$td_class} align=center nowrap>\n\t\t    <!-- <a href=\"javascript: PopupReplySms('{$current_sender}', '" . urlencode($in_msg) . "')\">{$icon_reply}</a> -->\n\t\t    <!-- <a href=\"index.php?app=menu&inc=phone_add&op=add&phone={$current_sender}\">{$icon_phonebook}</a> -->\n\t\t    <a href=\"javascript: ConfirmURL('" . _('Are you sure you want to delete this SMS ?') . "','index.php?app=menu&inc=all_inbox&op=all_inbox_del&inid={$in_id}')\">{$icon_delete}</a>\n\t\t    \n\t\t  </td>\n\t\t<td class={$td_class} width=4>\n\t\t    <input type=hidden name=inid" . $j . " value=\"{$in_id}\">\n\t\t    <input type=checkbox name=chkid" . $j . ">\n\t\t</td>\t\t  \n\t\t</tr>\n\t    ";
 }
 $item_count = $j;
 $content .= "\n    </tbody>\n    </table>\n\t<table width=100% cellpadding=0 cellspacing=0 border=0>\n\t<tr>\n\t    <td width=100% colspan=2 align=right>\n\t\t<input type=hidden name=item_count value=\"{$item_count}\">\n\t\t<input type=submit value=\"" . _('Delete selection') . "\" class=button />\n\t    </td>\n\t</tr>\n\t</table>\t    \n    </form>\n    <p>{$nav_pages}</p>\n    ";
 if ($err) {
Ejemplo n.º 9
0
function simplerate_hook_rate_refund($smslog_id)
{
    $ok = false;
    logger_print("start smslog_id:" . $smslog_id, 3, "simplerate refund");
    $db_query = "SELECT p_dst,p_msg,uid FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE p_status='2' AND smslog_id='{$smslog_id}'";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        $p_dst = $db_row['p_dst'];
        $p_msg = $db_row['p_msg'];
        $uid = $db_row['uid'];
        if ($p_dst && $p_msg && $uid) {
            if (billing_rollback($smslog_id)) {
                $bill = billing_getdata($smslog_id);
                $rate = $bill['rate'];
                $status = $bill['status'];
                logger_print("rolling smslog_id:" . $smslog_id, 3, "simplerate refund");
                if ($status == '2') {
                    // here should be added a routine to check charset encoding
                    // utf8 devided by 140, ucs2 devided by 70
                    $count = ceil(strlen($p_msg) / 153);
                    $charge = $count * $rate;
                    $username = uid2username($uid);
                    $credit = rate_getusercredit($username);
                    $remaining = $credit + $charge;
                    if (rate_setusercredit($uid, $remaining)) {
                        logger_print("refund smslog_id:" . $smslog_id, 3, "simplerate refund");
                        $ok = true;
                    }
                }
            }
        }
    }
    return $ok;
}
Ejemplo n.º 10
0
function setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver = "")
{
    global $gateway_module, $core_config;
    // make sure sms_datetime is in supported format and in GMT+0
    $sms_datetime = core_adjust_datetime($sms_datetime);
    // incoming sms will be handled by plugin/tools/* first
    $ret_intercept = interceptincomingsms($sms_datetime, $sms_sender, $message, $sms_receiver);
    if ($ret_intercept['modified']) {
        $sms_datetime = $ret_intercept['param']['sms_datetime'] ? $ret_intercept['param']['sms_datetime'] : $sms_datetime;
        $sms_sender = $ret_intercept['param']['sms_sender'] ? $ret_intercept['param']['sms_sender'] : $sms_sender;
        $message = $ret_intercept['param']['message'] ? $ret_intercept['param']['message'] : $message;
        $sms_receiver = $ret_intercept['param']['sms_receiver'] ? $ret_intercept['param']['sms_receiver'] : $sms_receiver;
    }
    // if hooked function returns cancel=true then stop the processing incoming sms, return false
    if ($ret_intercept['cancel']) {
        logger_print("cancelled datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction");
        return false;
    }
    $c_uid = 0;
    $c_feature = "";
    $ok = false;
    $array_target_keyword = explode(" ", $message);
    $target_keyword = strtoupper(trim($array_target_keyword[0]));
    $message_full = $message;
    $message = $array_target_keyword[1];
    for ($i = 2; $i < count($array_target_keyword); $i++) {
        $message .= " " . $array_target_keyword[$i];
    }
    switch ($target_keyword) {
        case "BC":
            $c_uid = mobile2uid($sms_sender);
            $c_username = uid2username($c_uid);
            $c_feature = 'core';
            $array_target_group = explode(" ", $message);
            $target_group = strtoupper(trim($array_target_group[0]));
            $c_gpid = phonebook_groupcode2id($c_uid, $target_group);
            $message = $array_target_group[1];
            for ($i = 2; $i < count($array_target_group); $i++) {
                $message .= " " . $array_target_group[$i];
            }
            logger_print("username:"******" gpid:" . $c_gpid . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction bc");
            list($ok, $to, $queue) = sendsms_bc($c_username, $c_gpid, $message);
            $ok = true;
            break;
        case "PV":
            $c_feature = 'core';
            $array_target_user = explode(" ", $message);
            $target_user = strtoupper(trim($array_target_user[0]));
            $c_uid = username2uid($target_user);
            $message = $array_target_user[1];
            for ($i = 2; $i < count($array_target_user); $i++) {
                $message .= " " . $array_target_user[$i];
            }
            logger_print("datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user . " message:" . $message, 3, "setsmsincomingaction pv");
            if (insertsmstoinbox($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver)) {
                $ok = true;
            }
            break;
        default:
            for ($c = 0; $c < count($core_config['featurelist']); $c++) {
                $c_feature = $core_config['featurelist'][$c];
                $ret = x_hook($c_feature, 'setsmsincomingaction', array($sms_datetime, $sms_sender, $target_keyword, $message, $sms_receiver));
                if ($ok = $ret['status']) {
                    $c_uid = $ret['uid'];
                    logger_print("feature:" . $c_feature . " datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " keyword:" . $target_keyword . " message:" . $message, 3, "setsmsincomingaction");
                    break;
                }
            }
    }
    $c_status = $ok ? 1 : 0;
    if ($c_status == 0) {
        $c_feature = '';
        $target_keyword = '';
        $message = $message_full;
        // from interceptincomingsms(), force status as 'handled'
        if ($ret_intercept['hooked']) {
            $c_status = 1;
            logger_print("intercepted datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction");
        } else {
            logger_print("unhandled datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction");
        }
    }
    $db_query = "\n        INSERT INTO " . _DB_PREF_ . "_tblSMSIncoming \n        (in_uid,in_feature,in_gateway,in_sender,in_receiver,in_keyword,in_message,in_datetime,in_status)\n        VALUES\n        ('{$c_uid}','{$c_feature}','{$gateway_module}','{$sms_sender}','{$sms_receiver}','{$target_keyword}','{$message}','{$sms_datetime}','{$c_status}')\n    ";
    $db_result = dba_query($db_query);
    return $ok;
}
Ejemplo n.º 11
0
     }
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureAutoreply WHERE autoreply_id='{$autoreply_id}' {$query_user_only}";
     $db_result = dba_query($db_query);
     $db_row = dba_fetch_array($db_result);
     $manage_autoreply_keyword = $db_row['autoreply_keyword'];
     $o_uid = $db_row['uid'];
     if ($err) {
         $content = "<div class=error_string>{$err}</div>";
     }
     $content .= "\n\t    <h2>" . _('Manage autoreply') . "</h2>\n\t    <p>\n\t    <p>" . _('SMS autoreply keyword') . ": <b>{$manage_autoreply_keyword}</b>\n\t    <p>\n\t    <input type=button value=\"" . _('Add SMS autoreply scenario') . "\" onClick=\"javascript:linkto('index.php?app=menu&inc=feature_sms_autoreply&op=sms_autoreply_scenario_add&autoreply_id={$autoreply_id}')\" class=\"button\" />\n\t    <p>\n    <table cellpadding=1 cellspacing=2 border=0 width=100%>\n    <tr>\n        <td class=box_title width=5>*</td>\n        <td class=box_title width=100>" . _('Param') . "</td>\n        <td class=box_title>" . _('Return') . "</td>\n        <td class=box_title width=100>" . _('User') . "</td>\t\n        <td class=box_title width=75>" . _('Action') . "</td>\n    </tr>\t\t    \n\t";
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureAutoreply_scenario WHERE autoreply_id='{$autoreply_id}' ORDER BY autoreply_scenario_param1";
     $db_result = dba_query($db_query);
     $j = 0;
     while ($db_row = dba_fetch_array($db_result)) {
         $j++;
         $owner = uid2username($o_uid);
         $td_class = $i % 2 ? "box_text_odd" : "box_text_even";
         $list_of_param = "";
         for ($i = 1; $i <= 7; $i++) {
             $list_of_param .= $db_row['autoreply_scenario_param' . $i] . "&nbsp;";
         }
         $action = "<a href=index.php?app=menu&inc=feature_sms_autoreply&op=sms_autoreply_scenario_edit&autoreply_id={$autoreply_id}&autoreply_scenario_id=" . $db_row['autoreply_scenario_id'] . ">{$icon_edit}</a>";
         $action .= "<a href=\"javascript: ConfirmURL('" . _('Are you sure you want to delete this SMS autoreply scenario ?') . "','index.php?app=menu&inc=feature_sms_autoreply&op=sms_autoreply_scenario_del&autoreply_id={$autoreply_id}&autoreply_scenario_id=" . $db_row['autoreply_scenario_id'] . "')\">{$icon_delete}</a>";
         $content .= "\n    <tr>\n\t<td class={$td_class}>&nbsp;{$j}.</td>\n\t<td class={$td_class}>{$list_of_param}</td>\n\t<td class={$td_class}>" . $db_row['autoreply_scenario_result'] . "</td>\n\t<td class={$td_class}>{$owner}</td>\n\t<td class={$td_class} align=center>{$action}</td>\n    </tr>\n\t";
     }
     $content .= "\n    </table>\n\t    <p>\n\t    <input type=button value=\"" . _('Add SMS autoreply scenario') . "\" onClick=\"javascript:linkto('index.php?app=menu&inc=feature_sms_autoreply&op=sms_autoreply_scenario_add&autoreply_id={$autoreply_id}')\" class=\"button\" />\n\t    </form>\n\t";
     echo $content;
     break;
 case "sms_autoreply_del":
     $autoreply_id = $_REQUEST['autoreply_id'];
     $db_query = "SELECT autoreply_keyword FROM " . _DB_PREF_ . "_featureAutoreply WHERE autoreply_id='{$autoreply_id}'";
Ejemplo n.º 12
0
function sms_collect_handle($c_uid, $sms_datetime, $sms_sender, $collect_keyword, $collect_param = '', $sms_receiver)
{
    global $core_config;
    global $web_title, $email_service, $email_footer, $gateway_module;
    $ok = false;
    $collect_keyword = strtoupper($collect_keyword);
    $username = uid2username($c_uid);
    $sms_to = $sms_sender;
    // we are replying to this sender
    $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureCollect WHERE collect_keyword='{$collect_keyword}'";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        if (!$db_row['collect_enable']) {
            $message = _('Collect service inactive');
            //list($ok,$to,$smslog_id) = sendsms_pv($username, $sms_to, $message);
            //$ok = $ok[0];
            $unicode = 0;
            if (function_exists('mb_detect_encoding')) {
                $encoding = mb_detect_encoding($message, 'auto');
                if ($encoding != 'ASCII') {
                    $unicode = 1;
                }
            }
            $ret = sendsms($core_config['main']['cfg_gateway_number'], '', $sms_to, $message, $c_uid, 0, 'text', $unicode);
            $ok = $ret['status'];
            return $ok;
        }
    }
    $c_uid = $db_row['uid'];
    $collect_id = $db_row['collect_id'];
    $num_rows = dba_num_rows($db_query);
    if ($num_rows) {
        $msg1 = $db_row['collect_msg'];
        $db_query = "INSERT INTO " . _DB_PREF_ . "_featureCollect_member (collect_id,collect_msg,member_number,member_since) VALUES ('{$collect_id}','{$collect_param}','{$sms_to}',now())";
        $message = $msg1;
        $logged = dba_query($db_query);
        $ok = true;
        $unicode = core_detect_unicode($message);
        logger_print('to:' . $sms_to . ' m:' . $message, 3, "sms_collect_handle");
        list($ok, $to, $smslog_id, $queue) = sendsms($username, $sms_to, $message, 'text', $unicode);
        $ok = $ok[0];
        // Forward to email as well if enable
        $db_query = "SELECT collect_fwd_email FROM " . _DB_PREF_ . "_featureCollect WHERE collect_keyword='{$collect_keyword}'";
        $db_result = dba_query($db_query);
        $db_row = dba_fetch_array($db_result);
        if ($email = $db_row['collect_fwd_email']) {
            // get name from c_uid's phonebook
            $c_username = uid2username($c_uid);
            $c_name = phonebook_number2name($sms_sender, $c_username);
            $sms_sender = $c_name ? $c_name . ' <' . $sms_sender . '>' : $sms_sender;
            $subject = "[SMSGW-" . $collect_keyword . "] " . _('from') . " {$sms_sender}";
            $body = _('Forward WebSMS') . " ({$web_title})\n\n";
            $body .= _('Date and time') . ": {$sms_datetime}\n";
            $body .= _('Sender') . ": {$sms_sender}\n";
            $body .= _('Receiver') . ": {$sms_receiver}\n";
            $body .= _('Keyword') . ": {$collect_keyword}\n\n";
            $body .= _('Message') . ":\n{$collect_param}\n\n";
            $body .= $email_footer . "\n\n";
            sendmail($email_service, $email, $subject, $body);
            logger_print("fwd email to:" . $email, "3", "sms_collect_handle");
        }
        //$ok = true;
    } else {
        $ok = false;
    }
    return $ok;
}
Ejemplo n.º 13
0
function sms_subscribe_handle($c_uid, $sms_datetime, $sms_sender, $subscribe_keyword, $subscribe_param = '')
{
    global $core_config;
    $ok = false;
    $subscribe_param = strtoupper($subscribe_param);
    $subscribe_keyword = strtoupper($subscribe_keyword);
    $username = uid2username($c_uid);
    $sms_to = $sms_sender;
    // we are replying to this sender
    $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe WHERE subscribe_keyword='{$subscribe_keyword}'";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        if (!$db_row['subscribe_enable']) {
            $message = _('Subscribe service inactive');
            //list($ok,$to,$smslog_id) = sendsms_pv($username, $sms_to, $message);
            //$ok = $ok[0];
            $unicode = 0;
            if (function_exists('mb_detect_encoding')) {
                $encoding = mb_detect_encoding($message, 'auto');
                if ($encoding != 'ASCII') {
                    $unicode = 1;
                }
            }
            $ret = sendsms($core_config['main']['cfg_gateway_number'], '', $sms_to, $message, $c_uid, 0, 'text', $unicode);
            $ok = $ret['status'];
            return $ok;
        }
    }
    $c_uid = $db_row['uid'];
    $subscribe_id = $db_row['subscribe_id'];
    $num_rows = dba_num_rows($db_query);
    if ($num_rows) {
        $msg1 = $db_row['subscribe_msg'];
        $msg2 = $db_row['unsubscribe_msg'];
        $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe_member WHERE member_number='{$sms_to}' AND subscribe_id='{$subscribe_id}'";
        $db_result = dba_query($db_query);
        $db_row = dba_fetch_array($db_result);
        $num_rows = dba_num_rows($db_query);
        if ($num_rows == 0) {
            $member = false;
            $db_query = "INSERT INTO " . _DB_PREF_ . "_featureSubscribe_member (subscribe_id,member_number,member_since) VALUES ('{$subscribe_id}','{$sms_to}',now())";
            switch ($subscribe_param) {
                case "ON":
                    $message = $msg1;
                    $logged = dba_query($db_query);
                    $ok = true;
                    break;
                case "IN":
                    $message = $msg1;
                    $logged = dba_query($db_query);
                    $ok = true;
                    break;
                case "REG":
                    $message = $msg1;
                    $logged = dba_query($db_query);
                    $ok = true;
                    break;
                case "OFF":
                    $message = _('You are not a member');
                    $ok = true;
                    break;
                case "OUT":
                    $message = _('You are not a member');
                    $ok = true;
                    break;
                case "UNREG":
                    $message = _('You are not a member');
                    $ok = true;
                    break;
                default:
                    $message = _('Unknown SMS format');
                    $ok = true;
                    break;
            }
        } else {
            $member = true;
            $db_query = "DELETE FROM " . _DB_PREF_ . "_featureSubscribe_member WHERE member_number='{$sms_to}' AND subscribe_id='{$subscribe_id}'";
            switch ($subscribe_param) {
                case "OFF":
                    $message = $msg2;
                    $deleted = dba_query($db_query);
                    if ($deleted) {
                        $ok = true;
                    }
                    break;
                case "OUT":
                    $message = $msg2;
                    $deleted = dba_query($db_query);
                    if ($deleted) {
                        $ok = true;
                    }
                    break;
                case "UNREG":
                    $message = $msg2;
                    $deleted = dba_query($db_query);
                    if ($deleted) {
                        $ok = true;
                    }
                    break;
                case "ON":
                    $message = _('You already a member');
                    $ok = true;
                    break;
                case "IN":
                    $message = _('You already a member');
                    $ok = true;
                    break;
                case "REG":
                    $message = _('You already a member');
                    $ok = true;
                    break;
                default:
                    $message = _('Unknown sms format');
                    $ok = true;
                    break;
            }
        }
        list($ok, $to, $smslog_id) = sendsms_pv($username, $sms_to, $message);
        $ok = $ok[0];
    } else {
        $ok = false;
    }
    return $ok;
}
Ejemplo n.º 14
0
         $content .= "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td class={$td_class}>&nbsp;{$i}.</td>\n\t\t\t\t\t\t\t\t<td class={$td_class}>{$message}</td>\n\t\t\t\t\t\t\t\t<td class={$td_class}>{$repeat}</td>\n\t\t\t\t\t\t\t\t<td class={$td_class}>{$owner}</td>\n\t\t\t\t\t\t\t\t<td class={$td_class}>{$send_to}</td>\t\n\t\t\t\t\t\t\t\t<td class={$td_class}>{$autosend_status}</td>\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<td class={$td_class} align=center>{$action}</td>\n\t\t\t\t\t\t\t</tr>";
     }
     $content .= "</table>";
     echo $content;
     echo "\n\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t<input type=button value=\"" . _('Add SMS autosend') . "\" onClick=\"javascript:linkto('index.php?app=menu&inc=feature_sms_autosend&op=sms_autosend_add')\" class=\"button\" />\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t";
     break;
 case "sms_autosend_view":
     $autosend_id = $_REQUEST['autosend_id'];
     if ($err) {
         $content = "<div class=error_string>{$err}</div>";
     }
     $content .= "<h2>" . _('SMS autosend View') . "</h2>";
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureAutosend where autosend_id='{$autosend_id}'";
     $db_result = dba_query($db_query);
     $db_row = dba_fetch_array($db_result);
     $owner = uid2username($db_row['uid']);
     $send_to = $db_row['autosend_number'];
     $autosend_status = "<font color=red>" . _('Disabled') . "</font>";
     $message = $db_row['autosend_message'];
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureAutosend_time where autosend_id='{$autosend_id}'";
     $db_result = dba_query($db_query);
     $num_rows = dba_num_rows($db_query);
     $db_row = dba_fetch_array($db_result);
     $time = $db_row['autosend_time'];
     if ($num_rows > "1") {
         $repeat = $num_rows;
     } else {
         $repeat = _('Once');
     }
     $content .= "\n\t\t\t\t\t\t\t\t<table cellpadding=1 cellspacing=2 border=0 width=100%>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td width=150>Owner</td><td width=5>:</td><td>{$owner}</td>\t\t    \n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td width=150>Message</td><td width=5>:</td><td>{$message}</td>\t\t    \n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td width=150>Send to</td><td width=5>:</td><td>{$send_to}</td>\t\t    \n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>Repeat send</td><td width=5>:</td><td>{$repeat}</td>\t\t    \n\t\t\t\t\t\t\t\t\t</tr>";
     $db_result = dba_query($db_query);
Ejemplo n.º 15
0
         if (!$data[$i]['started']) {
             $c_started = $data[$i]['running'] == 2 ? "<a href='index.php?app=menu&inc=feature_sms_survey&op=start&sid=" . $c_sid . "'><font color='red'>" . _('restart') . "</font></a>" : "<a href='index.php?app=menu&inc=feature_sms_survey&op=start&sid=" . $c_sid . "'><font color='red'>" . _('no') . "</font></a>";
         }
         if (!$data[$i]['status']) {
             $c_started = _('N/A');
         }
         $c_members = count(sms_survey_getmembers($c_sid));
         $c_members = "<a href='index.php?app=menu&inc=feature_sms_survey&route=members&op=members&sid=" . $c_sid . "'>" . $c_members . "</a>";
         $c_questions = count(sms_survey_getquestions($c_sid));
         $c_questions = "<a href='index.php?app=menu&inc=feature_sms_survey&route=questions&op=questions&sid=" . $c_sid . "'>" . $c_questions . "</a>";
         $c_action = "<a href='index.php?app=menu&inc=feature_sms_survey&op=edit&sid=" . $c_sid . "'>" . $icon_edit . "</a> ";
         if (!$data[$i]['status']) {
             $c_action .= "<a href='index.php?app=menu&inc=feature_sms_survey&op=del&sid=" . $c_sid . "'>" . $icon_delete . "</a> ";
         }
         $td_class = ($i + 1) % 2 ? "box_text_odd" : "box_text_even";
         $content .= "\n\t\t\t\t<tr class='" . $td_class . "'>\n\t\t\t\t\t<td align='center'>" . ($i + 1) . ".</td>\n\t\t\t\t\t<td align='center'>" . uid2username($data[$i]['uid']) . "</td>\n\t\t\t\t\t<td align='center'>" . $data[$i]['keyword'] . "</td>\n\t\t\t\t\t<td align='center'>" . $data[$i]['title'] . "</td>\n\t\t\t\t\t<td align='center'>" . $c_members . "</td>\n\t\t\t\t\t<td align='center'>" . $c_questions . "</td>\n\t\t\t\t\t<td align='center'>" . $c_status . "</td>\n\t\t\t\t\t<td align='center'>" . $c_started . "</td>\n\t\t\t\t\t<td align='center'>" . $c_action . "</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $content .= "\n\t\t\t</table>\n\t\t\t<form method='post' action='index.php?app=menu&inc=feature_sms_survey&op=add'>\n\t\t\t<p><input class='button' type='submit' value='" . _('Add survey') . "'></p>\n\t\t\t</form>\n\t\t";
     echo $content;
     break;
 case 'add':
     $content = '<h2>' . _('SMS Survey') . '</h2><p />';
     if ($error_content) {
         $content .= '<p>' . $error_content . '</p>';
     }
     $content .= '<h3>' . _('Add survey') . '</h3><p />';
     $content .= "\n\t\t\t<form method='post' action='index.php?app=menu&inc=feature_sms_survey&op=add_submit'>\n\t\t\t<table cellpadding='1' cellspacing='2' border='0'>\n\t\t\t<tr><td>" . _('Keyword') . "</td><td>:</td><td><input type='text' name='keyword' maxlength='20' size='20'></td></tr>\n\t\t\t<tr><td>" . _('Title') . "</td><td>:</td><td><input type='text' name='title' maxlength='100' size='40'></td></tr>\n\t\t\t</table>\n\t\t\t<p><input class='button' type='submit' value='" . _('Submit') . "'></p>\n\t\t\t</form>\n\t\t";
     echo $content;
     break;
 case 'add_submit':
     $keyword = $_REQUEST['keyword'];
Ejemplo n.º 16
0
function inboxgroup_forwardcatchall($data, $log_in_id, $sms_sender, $message)
{
    global $core_config;
    logger_print("forwardcatchall id:" . $data['id'] . " s:" . $sms_sender . " r:" . $data['in_receiver'] . " m:" . $message, 3, "inboxgroup");
    if ($username = uid2username($data['uid'])) {
        $users = inboxgroup_getcatchall($data['id']);
        $continue = false;
        if ($data['exclusive']) {
            for ($i = 0; $i < count($users); $i++) {
                if ($sms_sender == $users[$i]['mobile']) {
                    $continue = true;
                }
            }
        } else {
            $continue = true;
        }
        if ($continue) {
            for ($i = 0; $i < count($users); $i++) {
                if (($sms_to = $users[$i]['mobile']) && $sms_to != $sms_sender) {
                    //list($ok, $to, $smslog_id) = sendsms_pv($username, $sms_to, $message, 'text', 0);
                    //logger_print("forwardcatchall sendsms smslog_id:".$smslog_id[0]." to:".$sms_to, 3, "inboxgroup");
                    //inboxgroup_saveoutlog($log_in_id, $smslog_id[0], 1, $users[$i]['uid']);
                    $c_username = uid2username($users[$i]['uid']);
                    insertsmstoinbox($core_config['datetime']['now'], $sms_sender, $c_username, $message, $data['in_receiver']);
                }
            }
        }
    }
}
Ejemplo n.º 17
0
function sendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid = 0, $sms_type = 'text', $unicode = 0)
{
    global $datetime_now, $core_config, $gateway_module;
    // make sure sms_datetime is in supported format and in GMT+0
    // timezone used for outgoing message is not module timezone, but gateway timezone
    // module gateway may have set already to +0000 (such kannel and clickatell)
    $sms_datetime = core_adjust_datetime($core_config['datetime']['now'], $core_config['main']['cfg_datetime_timezone']);
    // sent sms will be handled by plugin/tools/* first
    $ret_intercept = interceptsendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $sms_type, $unicode);
    if ($ret_intercept['modified']) {
        $sms_sender = $ret_intercept['param']['mobile_sender'] ? $ret_intercept['param']['mobile_sender'] : $sms_sender;
        $sms_footer = $ret_intercept['param']['sms_footer'] ? $ret_intercept['param']['sms_footer'] : $sms_footer;
        $sms_to = $ret_intercept['param']['sms_to'] ? $ret_intercept['param']['sms_to'] : $sms_to;
        $sms_msg = $ret_intercept['param']['sms_msg'] ? $ret_intercept['param']['sms_msg'] : $sms_msg;
        $uid = $ret_intercept['param']['uid'] ? $ret_intercept['param']['uid'] : $uid;
        $gpid = $ret_intercept['param']['gpid'] ? $ret_intercept['param']['gpid'] : $gpid;
        $sms_type = $ret_intercept['param']['sms_type'] ? $ret_intercept['param']['sms_type'] : $sms_type;
        $unicode = $ret_intercept['param']['unicode'] ? $ret_intercept['param']['unicode'] : $unicode;
    }
    // fixme anton - mobile number can be anything, screened by gateway
    // $sms_sender = sendsms_getvalidnumber($sms_sender);
    $ok = false;
    $username = uid2username($uid);
    $sms_to = sendsms_getvalidnumber($sms_to);
    logger_print("start", 3, "sendsms");
    if (rate_cansend($username, $sms_to)) {
        // fixme anton - its a total mess ! need another DBA
        $sms_footer = addslashes($sms_footer);
        $sms_msg = addslashes($sms_msg);
        // we save all info first and then process with gateway module
        // the thing about this is that message saved may not be the same since gateway may not be able to process
        // message with that length or certain characters in the message are not supported by the gateway
        $db_query = "\n    \t    INSERT INTO " . _DB_PREF_ . "_tblSMSOutgoing \n    \t    (uid,p_gpid,p_gateway,p_src,p_dst,p_footer,p_msg,p_datetime,p_sms_type,unicode) \n    \t    VALUES ('{$uid}','{$gpid}','{$gateway_module}','{$sms_sender}','{$sms_to}','{$sms_footer}','{$sms_msg}','{$sms_datetime}','{$sms_type}','{$unicode}')\n\t";
        logger_print("saving:{$uid},{$gpid},{$gateway_module},{$sms_sender},{$sms_to},{$sms_type},{$unicode}", 3, "sendsms");
        // continue to gateway only when save to db is true
        if ($smslog_id = @dba_insert_id($db_query)) {
            logger_print("smslog_id:" . $smslog_id . " saved", 3, "sendsms");
            // fixme anton - another mess !
            $sms_footer = stripslashes($sms_footer);
            $sms_msg = stripslashes($sms_msg);
            if (x_hook($gateway_module, 'sendsms', array($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $smslog_id, $sms_type, $unicode))) {
                // fixme anton - deduct user's credit as soon as gateway returns true
                rate_deduct($smslog_id);
                $ok = true;
            }
        }
    }
    $ret['status'] = $ok;
    $ret['smslog_id'] = $smslog_id;
    return $ret;
}
Ejemplo n.º 18
0
function processAutoreply($sms_datetime, $sms_sender, $message, $simple = true)
{
    global $datetime_now;
    // find the autoreply
    $match = matchAutoreply($message, $simple);
    if (!$match) {
        return false;
    }
    // save a log of the match
    $log = DB_DataObject::factory('playsms_featAutoreply_log');
    $log->sms_sender = $sms_sender;
    $log->autoreply_log_datetime = $datetime_now;
    $log->autoreply_log_code = $match['keywords'][0];
    $log->autoreply_log_request = $message;
    $ok = $log->insert();
    if (!$ok) {
        return $ok;
    }
    // send the autoreply
    $c_username = uid2username($match['uid']);
    $ok = websend2pv($c_username, $sms_sender, $match['autoreply_scenario_result']);
    if (!$ok) {
        return false;
    }
    // since unknown matches are
    // really error messages, we
    // count them as failures
    //
    if ($match[UNKNOWN]) {
        $ok = false;
    }
    return $ok;
}
Ejemplo n.º 19
0
    die("Intruder: IP " . $_SERVER['REMOTE_ADDR']);
}
$op = $_GET[op];
switch ($op) {
    case "sms_board_list":
        if ($err) {
            $content = "<p><font color=red>{$err}</font><p>";
        }
        $content .= "\n\t\t    <h2>List/Edit/Delete SMS boards</h2>\n\t\t    <p>\n\t\t    <a href=\"menu.php?inc=sms_board&op=sms_board_add\">[ Add SMS board ]</a>\n\t\t    <p>\n\t\t";
        if (!isadmin()) {
            $query_user_only = "WHERE uid='{$uid}'";
        }
        $db_query = "SELECT * FROM playsms_featBoard {$query_user_only} ORDER BY board_code";
        $db_result = dba_query($db_query);
        while ($db_row = dba_fetch_array($db_result)) {
            $owner = uid2username($db_row[uid]);
            $content .= "[<a href=menu.php?inc=sms_board&op=sms_board_view&board_id={$db_row['board_id']} target=_blank>v</a>] [<a href=menu.php?inc=sms_board&op=sms_board_edit&board_id={$db_row['board_id']}>e</a>] [<a href=\"javascript: ConfirmURL('Are you sure you want to delete SMS board `{$db_row['board_code']}` with all its messages ?','menu.php?inc=sms_board&op=sms_board_del&board_id={$db_row['board_id']}')\">x</a>] <b>Code:</b> {$db_row['board_code']} &nbsp;&nbsp;<b>Forward:</b> {$db_row['board_forward_email']} &nbsp;&nbsp;<b>User:</b> {$owner}<br>";
        }
        echo $content;
        echo "\n\t\t    <p>\n\t\t    <a href=\"menu.php?inc=sms_board&op=sms_board_add\">[ Add SMS board ]</a>\n\t\t";
        break;
    case "sms_board_view":
        $board_id = $_GET[board_id];
        $db_query = "SELECT board_code FROM playsms_featBoard WHERE board_id='{$board_id}'";
        $db_result = dba_query($db_query);
        $db_row = dba_fetch_array($db_result);
        $board_code = $db_row[board_code];
        header("Location: output.php?code={$board_code}");
        break;
    case "sms_board_edit":
        $board_id = $_GET[board_id];
Ejemplo n.º 20
0
     } else {
         header("Location: index.php?app=menu&inc=send_sms&op=sendsmstopv&message=" . urlencode($message) . "&err=" . urlencode(_('You must select receiver and your message should not be empty')));
     }
     break;
 case "sendsmstogr":
     $message = $_REQUEST['message'];
     $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>";
Ejemplo n.º 21
0
function makeAutoreplyList($selfurl)
{
    global $uid, $special_codes_notice, $br, $guiPlus, $guiMinus, $editText, $addText, $delText;
    $content .= "\n            <h2>List/Manage/Delete SMS autoreplies</h2>\n            <p>\n            <a href=\"{$selfurl}&op=add\">[ Add ]</a>\n            <a href=\"{$selfurl}&op=export\">[ Export ]</a>\n            <a href=\"{$selfurl}&op=import\">[ Import ]</a>\n            <a href=\"{$selfurl}&op=test\">[ Test ]</a>\n            <a href=\"{$selfurl}&op=help\">[ Help ]</a>\n            <hr><p>\n        ";
    $content .= genDelForm("delAutoreply", "{$selfurl}&op=delAutoreply");
    $content .= genDelForm("delScenario", "{$selfurl}&op=delScenario");
    $autoreplies = DB_DataObject::factory('playsms_featAutoreply');
    if (!isadmin()) {
        $autoreplies->uid = $uid;
    }
    $autoreplies->orderBy("autoreply_code");
    $autoreplies->find();
    while ($autoreplies->fetch()) {
        $owner = uid2username($autoreplies->uid);
        $autoreplyInfo = generateScenarios($selfurl, $autoreplies->autoreply_id, false);
        $showhideLink = "<a href=\"javascript:;\" onClick=\"javascript: toggleShow('{$autoreplies->autoreply_code}', this, '{$guiPlus}', '{$guiMinus}');\" title=\"Show/Hide\">{$guiPlus}</a>";
        $editLink = "<a href=\"{$selfurl}&op=edit&id={$autoreplies->autoreply_id}\" title=\"Edit\">{$editText}</a>";
        $deleteMsg = "Are you sure you want to delete SMS autoreply `{$autoreplies->autoreply_code}`? Note that this will delete all autoreply scenarios under this autoreply.";
        $deleteLink = "<a href=\"javascript: delAutoreply({$autoreplies->autoreply_id}, '{$deleteMsg}');\" title=\"Delete\">{$delText}</a>";
        $content .= "{$showhideLink} \n {$editLink} \n {$deleteLink} \n <b>{$autoreplies->autoreply_code} &nbsp;</b>" . "<span id='{$autoreplies->autoreply_code}' style='display: none;'>" . "<span><b>User:</b> {$owner}<br><hr/></span>" . "<span style='position:relative; left:30px;'>{$autoreplyInfo}</span>" . "<span><hr/></span>" . "</span> \n<br/>";
        $content .= "<br/>\n\n";
    }
    echo $content;
    echo "<hr><p/><b>Special codes:</b> {$br}{$special_codes_notice}";
}
Ejemplo n.º 22
0
 $db_query = "SELECT count(*) as count FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE flag_deleted='0'";
 $db_result = dba_query($db_query);
 $db_row = dba_fetch_array($db_result);
 $num_rows = $db_row['count'];
 $pages = ceil($num_rows / $line_per_page);
 $nav_pages = themes_navbar($pages, $nav, $max_nav, "index.php?app=menu&inc=all_outgoing&op=all_outgoing", $page);
 $limit = ($page - 1) * $line_per_page;
 $content = "\n\t    <h2>" . _('All outgoing SMS') . "</h2>\n\t    <p>{$nav_pages}</p>\n\t    <form name=\"fm_outgoing\" action=\"index.php?app=menu&inc=all_outgoing&op=act_del\" method=post onSubmit=\"return SureConfirm()\">\n\t    <table width=100% cellpadding=1 cellspacing=2 border=0 class=\"sortable\">\n        <thead>\n\t    <tr>\n\t      <th align=center width=4>*</th>\n\t      <th align=center width=10%>" . _('User') . "</th>\n\t      <th align=center width=20%>" . _('Time') . "</th>\n\t      <th align=center width=10%>" . _('Gateway') . "</th>\n\t      <th align=center width=10%>" . _('Receiver') . "</th>\n\t      <th align=center width=40%>" . _('Message') . "</th>\n\t      <th align=center width=10%>" . _('Status') . "</th>\n\t      <th align=center width=4>" . _('Group') . "</th>\n\t      <th align=center width=4 class=\"sorttable_nosort\">" . _('Action') . "</th>\n\t      <th width=4 class=\"sorttable_nosort\"><input type=checkbox onclick=CheckUncheckAll(document.fm_outgoing)></td>\n\t    </tr>\n        </thead>\n        <tbody>\n\t";
 $db_query = "SELECT * FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE flag_deleted='0' ORDER BY smslog_id DESC LIMIT {$limit},{$line_per_page}";
 $db_result = dba_query($db_query);
 $i = $num_rows - $line_per_page * ($page - 1) + 1;
 $j = 0;
 while ($db_row = dba_fetch_array($db_result)) {
     $j++;
     $current_slid = $db_row['smslog_id'];
     $p_username = uid2username($db_row['uid']);
     $p_dst = $db_row['p_dst'];
     $p_desc = phonebook_number2name($p_dst);
     $current_p_dst = $p_dst;
     if ($p_desc) {
         $current_p_dst = "{$p_dst}<br>({$p_desc})";
     }
     $hide_p_dst = $p_dst;
     if ($p_desc) {
         $hide_p_dst = "{$p_dst} ({$p_desc})";
     }
     $p_sms_type = $db_row['p_sms_type'];
     $hide_p_dst = str_replace("\\'", "", $hide_p_dst);
     $hide_p_dst = str_replace("\"", "", $hide_p_dst);
     $p_msg = core_display_text($db_row['p_msg'], 25);
     if (($p_footer = $db_row['p_footer']) && ($p_sms_type == "text" || $p_sms_type == "flash")) {
         $_SESSION['error_string'] = _('Keyword does not exists');
     }
     header("Location: index.php?app=menu&inc=feature_sms_survey&route=members&op=members&sid=" . $sid);
     exit;
     break;
 case 'members_delete':
     $content = '<h2>' . _('SMS Survey') . '</h2><p />';
     if ($error_content) {
         $content .= '<p>' . $error_content . '</p>';
     }
     $content .= '<h3>' . _('Remove member') . '</h3><p />';
     $sid = $_REQUEST['sid'];
     $data = sms_survey_getdatabyid($sid);
     $keyword = $data['keyword'];
     $title = $data['title'];
     $c_user = uid2username($data['uid']);
     $c_members = count(sms_survey_getmembers($sid));
     $c_members = "<a href='index.php?app=menu&inc=feature_sms_survey&route=members&op=members&sid=" . $sid . "'>" . $c_members . "</a>";
     $c_questions = count(sms_survey_getquestions($sid));
     $c_questions = "<a href='index.php?app=menu&inc=feature_sms_survey&route=questions&op=questions&sid=" . $sid . "'>" . $c_questions . "</a>";
     $c_status = $data['status'] ? "<font color='green'>" . _('enabled') . "</font>" : "<font color='red'>" . _('disabled') . "</font>";
     if ($data['status']) {
         $c_status = $data['running'] == 2 ? "<font color='blue'>" . _('completed') . "</font>" : "<font color='green'>" . _('enabled') . "</font>";
     }
     $c_started = $data['started'] ? "<font color='green'>" . _('yes') . "</font>" : "<font color='red'>" . _('no') . "</font>";
     if (!$data['started']) {
         $c_started = $data['running'] == 2 ? "<font color='red'>" . _('restart') . "</font>" : "<font color='red'>" . _('no') . "</font>";
     }
     $content .= "\n\t\t\t<table cellpadding='1' cellspacing='2' border='0'>\n\t\t\t<tr><td>" . _('User') . "</td><td>:</td><td>" . $c_user . "</td></tr>\n\t\t\t<tr><td>" . _('Keyword') . "</td><td>:</td><td>" . $keyword . "</td></tr>\n\t\t\t<tr><td>" . _('Title') . "</td><td>:</td><td>" . $title . "</td></tr>\n\t\t\t<tr><td>" . _('Members') . "</td><td>:</td><td>" . $c_members . "</td></tr>\n\t\t\t<tr><td>" . _('Questions') . "</td><td>:</td><td>" . $c_questions . "</td></tr>\n\t\t\t<tr><td>" . _('Status') . "</td><td>:</td><td>" . $c_status . "</td></tr>\n\t\t\t<tr><td>" . _('Started') . "</td><td>:</td><td>" . $c_started . "</td></tr>\n\t\t\t</table>\n\t\t";
     $list_of_members = '';
     // get members