Beispiel #1
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;
                $sms_datetime = core_display_datetime($sms_datetime);
                $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;
}
Beispiel #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;
}
Beispiel #3
0
function pvat_hook_interceptincomingsms($sms_datetime, $sms_sender, $message, $sms_receiver)
{
    $msg = explode(" ", $message);
    $ret = array();
    if (count($msg) > 1) {
        $pv = trim($msg[0]);
        if (substr($pv, 0, 1) == '@') {
            $c_username = substr($pv, 1);
            $new_message = "PV " . $c_username . " ";
            if (username2uid($c_username)) {
                for ($i = 1; $i < count($msg); $i++) {
                    $new_message .= $msg[$i] . " ";
                }
                $new_message = substr($new_message, 0, -1);
                // set 1 to param_modified to let parent function modify param values
                $ret['modified'] = true;
                // this time only message param changed
                $ret['param']['message'] = $new_message;
                $sms_datetime = core_display_datetime($sms_datetime);
                logger_print("dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message . " mod:" . $ret['param']['message'], 3, "pvat");
                // do not forget to tell parent that this SMS has been hooked
                $ret['hooked'] = true;
            }
        }
    }
    return $ret;
}
Beispiel #4
0
function sms_custom_handle($sms_datetime, $sms_sender, $custom_keyword, $custom_param = '')
{
    global $datetime_now;
    $ok = false;
    $db_query = "SELECT custom_url 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);
    $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);
    $connection = fsockopen($url['host'], $url['port'], $error_number, $error_description, 60);
    if ($connection) {
        socket_set_blocking($connection, false);
        fputs($connection, "GET {$custom_url} HTTP/1.0\r\n\r\n");
        $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;
}
Beispiel #5
0
function xlate_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver)
{
    global $core_config;
    $msg = explode(" ", $message);
    $ret = array();
    if (count($msg) > 1) {
        $keyword = trim($msg[0]);
        if (substr($keyword, 0, 1) == '@') {
            $xlate = substr($keyword, 1);
            $xlate = explode('2', $xlate);
            $xlate_from = $xlate[0];
            $xlate_to = $xlate[1];
            if ($xlate_from && $xlate_to && strlen($xlate_from) == 2 && strlen($xlate_to) == 2) {
                for ($i = 1; $i < count($msg); $i++) {
                    $words .= $msg[$i] . " ";
                }
                $words = trim($words);
                // contact google
                $lib = $core_config['apps_path']['plug'] . '/feature/xlate/lib/GoogleTranslate';
                // load JSON.php for PHP version lower than 5.2.x
                require_once $lib . '/JSON.php';
                require_once $lib . '/googleTranslate.class.php';
                if ($gt = new GoogleTranslateWrapper()) {
                    /* Translate */
                    $xlate_words = $gt->translate($words, $xlate_to, $xlate_from);
                    // incoming sms is handled
                    $ret['hooked'] = true;
                    /* Was translation successful */
                    $sms_datetime = core_display_datetime($sms_datetime);
                    if ($gt->isSuccess()) {
                        $reply = '@' . $xlate_from . '2' . $xlate_to . ' ' . $words . ' => ' . $xlate_words;
                        logger_print("success dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " w:" . $words . " from:" . $xlate_from . " to:" . $xlate_to . " xlate:" . $xlate_words, 2, "xlate");
                    } else {
                        $reply = '@' . $xlate_from . '2' . $xlate_to . ' ' . _("unable to translate") . ': ' . $words;
                        logger_print("failed dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " w:" . $words . " from:" . $xlate_from . " to:" . $xlate_to, 2, "xlate");
                    }
                    // detect reply message, set unicode if not ASCII
                    $unicode = core_detect_unicode($reply);
                    // send reply SMS using admin account
                    // should add a web menu in xlate.php to choose which account will be used to send reply SMS
                    // usualy we inspect the result of sendsms, but not this time
                    logger_print("send reply encoding:" . $encoding, 2, "xlate");
                    $reply = addslashes($reply);
                    list($ok, $to, $smslog_id, $queue) = sendsms_helper('admin', $sms_sender, $reply, 'text', $unicode);
                    // do not forget to tell parent that this SMS has been hooked
                    $ret['hooked'] = true;
                } else {
                    // unable to load the class, set incoming sms unhandled
                    $ret['hooked'] = false;
                    logger_print("class not exists or fail to load", 2, "xlate");
                }
            }
        }
    }
    return $ret;
}
Beispiel #6
0
function myauto_hook_interceptincomingsms($sms_datetime, $sms_sender, $message, $sms_receiver)
{
    global $core_config;
    // reply message
    $reply = 'Thank you for your message';
    // detect reply message, set unicode if not ASCII
    $unicode = core_detect_unicode($reply);
    // send reply
    list($ok, $to, $smslog_id, $queue) = sendsms('admin', $sms_sender, $reply, 'text', $unicode);
    // log it
    $sms_datetime = core_display_datetime($sms_datetime);
    logger_print("dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " autorespon:" . $reply, 2, "myauto");
}
Beispiel #7
0
function myauto_hook_interceptincomingsms($sms_datetime, $sms_sender, $message, $sms_receiver)
{
    global $core_config;
    // reply message
    $reply = 'Thank you for your message';
    // detect reply message, set unicode if not ASCII
    $unicode = 0;
    if (function_exists('mb_detect_encoding')) {
        $encoding = mb_detect_encoding($reply, 'auto');
        if ($encoding != 'ASCII') {
            $unicode = 1;
        }
    }
    // send reply
    list($ok, $to, $smslog_id) = sendsms_pv('admin', $sms_sender, $reply, 'text', $unicode);
    // log it
    $sms_datetime = core_display_datetime($sms_datetime);
    logger_print("dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " autorespon:" . $reply, 3, "myauto");
}
Beispiel #8
0
function recvsmsd()
{
    global $core_config;
    $core_config['recvsmsd_limit'] = (int) $core_config['recvsmsd_limit'] ? (int) $core_config['recvsmsd_limit'] : 200;
    $list = dba_search(_DB_PREF_ . '_tblRecvSMS', '*', array('flag_processed' => 1), '', array('LIMIT' => $core_config['recvsmsd_limit']));
    $j = 0;
    for ($j = 0; $j < count($list); $j++) {
        if ($id = $list[$j]['id']) {
            $sms_datetime = $list[$j]['sms_datetime'];
            $sms_sender = $list[$j]['sms_sender'];
            $message = $list[$j]['message'];
            $sms_receiver = $list[$j]['sms_receiver'];
            $smsc = $list[$j]['smsc'];
            if (dba_update(_DB_PREF_ . '_tblRecvSMS', array('flag_processed' => 2), array('id' => $id))) {
                logger_print("id:" . $id . " dt:" . core_display_datetime($sms_datetime) . " sender:" . $sms_sender . " m:" . $message . " receiver:" . $sms_receiver . " smsc:" . $smsc, 3, "recvsmsd");
                recvsms_process(core_display_datetime($sms_datetime), $sms_sender, $message, $sms_receiver, $smsc);
            }
        }
    }
}
Beispiel #9
0
function sms_custom_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $custom_keyword, $custom_param = '', $smsc = '', $raw_message = '')
{
    $ok = false;
    $custom_keyword = strtoupper(trim($custom_keyword));
    $custom_param = trim($custom_param);
    $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'];
    $username = user_uid2username($db_row['uid']);
    $custom_return_as_reply = $db_row['custom_return_as_reply'];
    if ($custom_keyword && $custom_url && $username) {
        $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);
        $custom_url = str_replace("{CUSTOMRAW}", urlencode($raw_message), $custom_url);
        logger_print("custom_url:" . $custom_url, 3, "sms custom");
        $parsed_url = parse_url($custom_url);
        $opts = array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'content' => $parsed_url['query']));
        $context = stream_context_create($opts);
        $server_url = explode('?', $custom_url);
        $returns = file_get_contents($server_url[0], false, $context);
        if ($custom_return_as_reply == 1) {
            if ($returns = trim($returns)) {
                $unicode = core_detect_unicode($returns);
                $returns = addslashes($returns);
                logger_print("returns:" . $returns, 3, "sms custom");
                sendsms_helper($username, $sms_sender, $returns, 'text', $unicode, $smsc);
            } else {
                logger_print("returns empty", 3, "sms custom");
            }
        }
        $ok = true;
    }
    return $ok;
}
Beispiel #10
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;
}
Beispiel #11
0
function sms_command_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $command_keyword, $command_param = '', $smsc = '', $raw_message = '')
{
    global $plugin_config;
    $ok = false;
    $command_keyword = strtoupper(trim($command_keyword));
    $command_param = trim($command_param);
    $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'];
    $command_return_as_reply = $db_row['command_return_as_reply'];
    $username = user_uid2username($db_row['uid']);
    if ($command_keyword && $command_exec && $username) {
        $sms_datetime = core_display_datetime($sms_datetime);
        $command_exec = str_replace("{SMSDATETIME}", "\"{$sms_datetime}\"", $command_exec);
        $command_exec = str_replace("{SMSSENDER}", escapeshellarg($sms_sender), $command_exec);
        $command_exec = str_replace("{COMMANDKEYWORD}", escapeshellarg($command_keyword), $command_exec);
        $command_exec = str_replace("{COMMANDPARAM}", escapeshellarg($command_param), $command_exec);
        $command_exec = str_replace("{COMMANDRAW}", escapeshellarg($raw_message), $command_exec);
        $command_exec = str_replace("/", "", $command_exec);
        $command_exec = $plugin_config['sms_command']['bin'] . "/" . $db_row['uid'] . "/" . $command_exec;
        $command_exec = escapeshellcmd($command_exec);
        logger_print("command_exec:" . addslashes($command_exec), 3, "sms command");
        $command_output = shell_exec($command_exec);
        if ($command_return_as_reply == 1) {
            $unicode = core_detect_unicode($command_output);
            if ($command_output = addslashes(trim($command_output))) {
                logger_print("command_output:" . $command_output, 3, "sms command");
                sendsms_helper($username, $sms_sender, $command_output, 'text', $unicode, $smsc);
            } else {
                logger_print("command_output is empty", 3, "sms command");
            }
        }
        $ok = true;
    }
    return $ok;
}
Beispiel #12
0
function insertsmstoinbox($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver = "")
{
    global $core_config, $web_title, $email_service, $email_footer;
    // sms to inbox will be handled by plugin/tools/* first
    $ret_intercept = interceptsmstoinbox($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver);
    if ($ret_intercept['param_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;
        $target_user = $ret_intercept['param']['target_user'] ? $ret_intercept['param']['target_user'] : $target_user;
        $message = $ret_intercept['param']['message'] ? $ret_intercept['param']['message'] : $message;
        $sms_receiver = $ret_intercept['param']['sms_receiver'] ? $ret_intercept['param']['sms_receiver'] : $sms_receiver;
    }
    $ok = false;
    if ($sms_sender && $target_user && $message) {
        $user = user_getdatabyusername($target_user);
        if ($uid = $user['uid']) {
            // forward to Inbox
            if ($fwd_to_inbox = $user['fwd_to_inbox']) {
                $db_query = "\n\t\t    INSERT INTO " . _DB_PREF_ . "_tblUserInbox\n\t\t    (in_sender,in_receiver,in_uid,in_msg,in_datetime) \n\t\t    VALUES ('{$sms_sender}','{$sms_receiver}','{$uid}','{$message}','{$sms_datetime}')\n\t\t";
                logger_print("saving sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user, 3, "insertsmstoinbox");
                if ($cek_ok = @dba_insert_id($db_query)) {
                    logger_print("saved sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user, 3, "insertsmstoinbox");
                }
            }
            // forward to email
            if ($fwd_to_email = $user['fwd_to_email']) {
                if ($email = $user['email']) {
                    // make sure sms_datetime is in supported format and in user's timezone
                    $sms_datetime = core_display_datetime($sms_datetime);
                    // get name from target_user's phonebook
                    $c_name = phonebook_number2name($sms_sender, $target_user);
                    $sender = $c_name ? $c_name . ' <' . $sms_sender . '>' : $sms_sender;
                    // fixme anton - slash maddess
                    $message = stripslashes($message);
                    $subject = "[SMSGW-PV] " . _('from') . " {$sms_sender}";
                    $body = _('Forward Private WebSMS') . " ({$web_title})\n\n";
                    $body .= _('Date time') . ": {$sms_datetime}\n";
                    $body .= _('Sender') . ": {$sender}\n";
                    $body .= _('Receiver') . ": {$sms_receiver}\n\n";
                    $body .= _('Message') . ":\n{$message}\n\n";
                    $body .= $email_footer . "\n\n";
                    logger_print("send email from:" . $email_service . " to:" . $email, 3, "insertsmstoinbox");
                    sendmail($email_service, $email, $subject, $body);
                    logger_print("sent email from:" . $email_service . " to:" . $email, 3, "insertsmstoinbox");
                }
                $ok = true;
            }
            // forward to mobile
            if ($fwd_to_mobile = $user['fwd_to_mobile']) {
                if ($mobile = $user['mobile']) {
                    $unicode = 0;
                    if (function_exists('mb_detect_encoding')) {
                        $encoding = mb_detect_encoding($message, 'auto');
                        if ($encoding != 'ASCII') {
                            $unicode = 1;
                        }
                    }
                    $message = $sender . ' ' . $message;
                    logger_print("send to mobile:" . $mobile . " from:" . $sender . " user:"******"insertsmstoinbox");
                    list($ok, $to, $smslog_id) = sendsms_pv($target_user, $mobile, $message, 'text', $unicode);
                    if ($ok[0]) {
                        logger_print("sent to mobile:" . $mobile . " from:" . $sender . " user:"******"insertsmstoinbox");
                    }
                }
            }
        }
    }
    return $ok;
}
Beispiel #13
0
 $nav = themes_nav_session();
 $search = themes_search_session();
 $go = $_REQUEST['go'];
 switch ($go) {
     case 'export':
         $conditions = array('A.uid' => $user_config['uid'], 'A.flag_deleted' => 0);
         if ($queue_code = trim($_REQUEST['queue_code'])) {
             $conditions['A.queue_code'] = $queue_code;
         }
         $table = _DB_PREF_ . '_tblSMSOutgoing';
         $join = "INNER JOIN " . _DB_PREF_ . "_tblUser AS B ON B.flag_deleted='0' AND A.uid=B.uid";
         $list = dba_search($table . ' AS A', 'A.p_datetime, A.p_dst, A.p_msg, A.p_footer, A.p_status', $conditions, $search['dba_keywords'], '', $join);
         $data[0] = array(_('Time'), _('To'), _('Message'), _('Status'));
         for ($i = 0; $i < count($list); $i++) {
             $j = $i + 1;
             $data[$j] = array(core_display_datetime($list[$i]['p_datetime']), $list[$i]['p_dst'], $list[$i]['p_msg'] . $list[$i]['p_footer'], $list[$i]['p_status']);
         }
         $content = core_csv_format($data);
         if ($queue_code) {
             $fn = 'user_outgoing-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '-' . $queue_code . '.csv';
         } else {
             $fn = 'user_outgoing-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '.csv';
         }
         core_download($content, $fn, 'text/csv');
         break;
     case 'delete':
         for ($i = 0; $i < $nav['limit']; $i++) {
             $checkid = $_POST['checkid' . $i];
             $itemid = $_POST['itemid' . $i];
             if ($checkid == "on" && $itemid) {
                 $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
Beispiel #14
0
     }
     _p($content);
     break;
 case "actions":
     $nav = themes_nav_session();
     $search = themes_search_session();
     $go = $_REQUEST['go'];
     switch ($go) {
         case 'export':
             $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0, 'in_status' => 1);
             $extras = array('AND in_keyword' => '!= ""');
             $list = dba_search(_DB_PREF_ . '_tblSMSIncoming', 'in_sender, in_keyword, in_datetime, in_feature, in_message', $conditions, $search['dba_keywords'], $extras);
             $data[0] = array(_('Time'), _('From'), _('Keyword'), _('Content'), _('Feature'));
             for ($i = 0; $i < count($list); $i++) {
                 $j = $i + 1;
                 $data[$j] = array(core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_keyword'], $list[$i]['in_message'], $list[$i]['in_feature']);
             }
             $content = core_csv_format($data);
             $fn = 'user_incoming-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '.csv';
             core_download($content, $fn, 'text/csv');
             break;
         case 'delete':
             for ($i = 0; $i < $nav['limit']; $i++) {
                 $checkid = $_POST['checkid' . $i];
                 $itemid = $_POST['itemid' . $i];
                 if ($checkid == "on" && $itemid) {
                     $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
                     dba_update(_DB_PREF_ . '_tblSMSIncoming', $up, array('in_uid' => $user_config['uid'], 'in_id' => $itemid));
                 }
             }
             $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
Beispiel #15
0
     break;
 case "actions":
     $nav = themes_nav_session();
     $search = themes_search_session();
     $go = $_REQUEST['go'];
     switch ($go) {
         case 'export':
             $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0);
             if ($in_sender = trim($_REQUEST['in_sender'])) {
                 $conditions['in_sender'] = $in_sender;
             }
             $list = dba_search(_DB_PREF_ . '_tblSMSInbox', 'in_datetime, in_sender, in_msg', $conditions, $search['dba_keywords']);
             $data[0] = array(_('Time'), _('From'), _('Message'));
             for ($i = 0; $i < count($list); $i++) {
                 $j = $i + 1;
                 $data[$j] = array(core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_msg']);
             }
             $content = core_csv_format($data);
             if ($in_sender) {
                 $fn = 'user_inbox-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '-' . $in_sender . '.csv';
             } else {
                 $fn = 'user_inbox-' . $user_config['username'] . '-' . $core_config['datetime']['now_stamp'] . '.csv';
             }
             core_download($content, $fn, 'text/csv');
             break;
         case 'delete':
             for ($i = 0; $i < $nav['limit']; $i++) {
                 $checkid = $_POST['checkid' . $i];
                 $itemid = $_POST['itemid' . $i];
                 if ($checkid == "on" && $itemid) {
                     $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
Beispiel #16
0
function schedule_hook_playsmsd()
{
    global $core_config;
    // fetch every minutes
    if (!core_playsmsd_timer(60)) {
        return;
    }
    // mark a start
    //_log('start scheduler', 2, 'schedule_hook_playsmsd');
    // get current server time
    $current_datetime = core_display_datetime(core_get_datetime());
    $current_timestamp = strtotime($current_datetime);
    // collect active schedules
    $conditions = array('flag_active' => 1, 'flag_deleted' => 0);
    $schedules = dba_search(_DB_PREF_ . '_featureSchedule', '*', $conditions);
    foreach ($schedules as $sch) {
        $schedule_id = $sch['id'];
        $uid = $sch['uid'];
        $schedule_name = $sch['name'];
        $schedule_rule = (int) $sch['schedule_rule'];
        // collect destinations
        $conditions = array('schedule_id' => $schedule_id);
        $destinations = dba_search(_DB_PREF_ . '_featureSchedule_dst', '*', $conditions, '', $extras);
        foreach ($destinations as $dst) {
            $id = $dst['id'];
            $name = $dst['name'];
            $schedule_message = str_ireplace('#NAME#', $name, $sch['message']);
            $destination = $dst['destination'];
            $schedule = $dst['schedule'] ? core_display_datetime($dst['schedule']) : '0000-00-00 00:00:00';
            $scheduled = $dst['scheduled'] ? core_display_datetime($dst['scheduled']) : '0000-00-00 00:00:00';
            if (!$scheduled || $scheduled == '0000-00-00 00:00:00') {
                $scheduled = $schedule;
            }
            $scheduled_timestamp = strtotime($scheduled);
            //_log('uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' current:[' . $current_datetime . '] schedule:[' . $schedule . '] scheduled:[' . $scheduled . ']', 2, 'schedule_hook_playsmsd');
            $continue = FALSE;
            if ($current_timestamp >= $scheduled_timestamp) {
                switch ($schedule_rule) {
                    // once
                    case '0':
                        //$scheduled = '2038-01-19 10:14:07';
                        $scheduled = '2030-01-19 10:14:07';
                        $scheduled = core_adjust_datetime($scheduled);
                        $scheduled_timestamp = strtotime($current_datetime);
                        $scheduled_display = $current_datetime;
                        $continue = TRUE;
                        break;
                        // Annually
                    // Annually
                    case '1':
                        $current_schedule = date('Y', $current_timestamp) . '-' . date('m-d H:i:s', strtotime($schedule));
                        $next = '';
                        if ($current_timestamp > strtotime($current_schedule)) {
                            $next = '+1 year';
                        }
                        $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule));
                        $scheduled = core_adjust_datetime($scheduled);
                        $scheduled_timestamp = strtotime($scheduled);
                        $scheduled_display = core_display_datetime($scheduled);
                        $continue = TRUE;
                        break;
                        // Monthly
                    // Monthly
                    case '2':
                        $current_schedule = date('Y-m', $current_timestamp) . '-' . date('d H:i:s', strtotime($schedule));
                        $next = '';
                        if ($current_timestamp > strtotime($current_schedule)) {
                            $next = '+1 month';
                        }
                        $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule));
                        $scheduled = core_adjust_datetime($scheduled);
                        $scheduled_timestamp = strtotime($scheduled);
                        $scheduled_display = core_display_datetime($scheduled);
                        $continue = TRUE;
                        break;
                        // Weekly
                    // Weekly
                    case '3':
                        $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule));
                        $current_day = date('l', strtotime($current_schedule));
                        $next = '';
                        if ($current_timestamp > strtotime($current_schedule)) {
                            $next = 'next ' . $current_day;
                        }
                        $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule));
                        $scheduled = core_adjust_datetime($scheduled);
                        $scheduled_timestamp = strtotime($scheduled);
                        $scheduled_display = core_display_datetime($scheduled);
                        $continue = TRUE;
                        break;
                        // Daily
                    // Daily
                    case '4':
                        $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule));
                        $next = '';
                        if ($current_timestamp > strtotime($current_schedule)) {
                            $next = '+1 day';
                        }
                        $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule));
                        $scheduled = core_adjust_datetime($scheduled);
                        $scheduled_timestamp = strtotime($scheduled);
                        $scheduled_display = core_display_datetime($scheduled);
                        $continue = TRUE;
                        break;
                }
            }
            if ($continue) {
                // set scheduled to next time
                $items = array('c_timestamp' => mktime(), 'scheduled' => $scheduled);
                $conditions = array('schedule_id' => $schedule_id, 'id' => $id);
                if (dba_update(_DB_PREF_ . '_featureSchedule_dst', $items, $conditions, 'AND')) {
                    // if the interval is under an hour then go ahead, otherwise expired
                    $interval = $current_timestamp - $scheduled_timestamp;
                    if ($interval <= 3600) {
                        _log('sendsms uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd');
                        $username = user_uid2username($uid);
                        sendsms_helper($username, $destination, $schedule_message, 'text', $unicode);
                    } else {
                        _log('expired uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . '] interval:' . $interval, 2, 'schedule_hook_playsmsd');
                    }
                } else {
                    _log('fail update uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd');
                }
            }
        }
    }
    // mark an end
    //_log('end scheduler', 2, 'schedule_hook_playsmsd');
}
Beispiel #17
0
 $content = _dialog() . "\n\t\t\t<h2>" . _('View SMS queue') . "</h2>";
 $count = queuelog_countall();
 if ($count) {
     $content .= "<p><a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to delete ALL queues")) . " ?','" . _u('index.php?app=main&inc=feature_queuelog&op=queuelog_delete_all') . "')\">" . $icon_config['delete'] . _("Delete ALL queues") . " ({$count})</a></p>";
 }
 $content .= "<div align=center>" . $nav['form'] . "</div>\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t";
 if (auth_isadmin()) {
     $content .= "\n\t\t\t\t<th width=20%>" . _('Queue Code') . "</th>\n\t\t\t\t<th width=15%>" . _('User') . "</th>\n\t\t\t";
 } else {
     $content .= "\n\t\t\t\t<th width=30%>" . _('Queue Code') . "</th>\n\t\t\t";
 }
 $content .= "\n\t\t\t\t<th width=15%>" . _('Scheduled') . "</th>\n\t\t\t\t<th width=10%>" . _('Count') . "</th>\n\t\t\t\t<th width=30%>" . _('Message') . "</th>\n\t\t\t\t<th width=10%>" . _('Action') . "</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t";
 $data = queuelog_get($nav['limit'], $nav['offset']);
 for ($c = count($data) - 1; $c >= 0; $c--) {
     $c_queue_code = $data[$c]['queue_code'];
     $c_datetime_scheduled = core_display_datetime($data[$c]['datetime_scheduled']);
     $c_username = user_uid2username($data[$c]['uid']);
     // total number of SMS in queue
     $c_count = $data[$c]['sms_count'];
     $c_message = stripslashes(core_display_text($data[$c]['message']));
     $c_action = "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to delete queue")) . " " . $c_queue_code . " ?','" . _u('index.php?app=main&inc=feature_queuelog&op=queuelog_delete&queue=' . $c_queue_code) . "')\">" . $icon_config['delete'] . "</a>";
     $content .= "\n\t\t\t\t<tr>\n\t\t\t";
     if (auth_isadmin()) {
         $content .= "\n\t\t\t\t\t<td>" . $c_queue_code . "</td>\n\t\t\t\t\t<td>" . $c_username . "</td>\n\t\t\t\t";
     } else {
         $content .= "\n\t\t\t\t\t<td>" . $c_queue_code . "</td>\n\t\t\t\t";
     }
     $content .= "\n\t\t\t\t\t<td>" . $c_datetime_scheduled . "</td>\n\t\t\t\t\t<td>" . $c_count . "</td>\n\t\t\t\t\t<td>" . $c_message . "</td>\n\t\t\t\t\t<td>" . $c_action . "</td>\n\t\t\t\t</tr>\n\t\t\t";
 }
 $content .= "\n\t\t\t</tbody></table>\n\t\t\t</div>\n\t\t\t<div align=center>" . $nav['form'] . "</div>\n\t\t";
 _p($content);
Beispiel #18
0
/**
 * Counter for throttle limit
 *
 * @param integer $uid
 *        User ID
 * @param integer $count
 *        (default is 1)
 *        Sent SMS
 * @return boolean TRUE of successful counter
 */
function sendsms_throttle_count($uid, $count = 1, $limit = 0, $period = 60)
{
    global $core_config;
    $limit = (int) $limit ? (int) $limit : $core_config['main']['sms_limit_per_hour'];
    $period = (int) $period ? (int) $period * 60 : 3600;
    if (!$limit) {
        // no limit no over limit
        return FALSE;
    }
    // get start time, UTC
    $reg = registry_search($uid, 'core', 'sendsms', 'throttle_start');
    $start = $reg['core']['sendsms']['throttle_start'];
    if ($start) {
        // get sum of sent SMS over the hour
        $reg = registry_search($uid, 'core', 'sendsms', 'throttle_sum');
        $sum = $reg['core']['sendsms']['throttle_sum'];
        _log('throttle bucket exists start:' . core_display_datetime($start) . ' sum:' . $sum . ' limit:' . $limit, 3, 'sendsms_throttle_count');
    } else {
        $start = core_get_datetime();
        $sum = 0;
        if (registry_update($uid, 'core', 'sendsms', array('throttle_start' => $start, 'throttle_sum' => $sum))) {
            _log('throttle bucket started start:' . core_display_datetime($start) . ' limit:' . $limit, 3, 'sendsms_throttle_count');
        } else {
            _log('fail to start throttle bucket', 3, 'sendsms_throttle_count');
            return FALSE;
        }
    }
    // check bucket expired
    if (strtotime($start) + $period < strtotime(core_get_datetime())) {
        // expired, create new
        $start = core_get_datetime();
        $sum = 0;
        _log('expired start:' . core_display_datetime($start), 3, 'sendsms_throttle_count');
    } else {
        //_log('not expired', 3, 'sendsms_throttle_count');
        // not expired
        if ((int) $sum <= $limit) {
            // add to bucket
            $sum += $count;
            //_log('add to bucket sum:' . $sum, 3, 'sendsms_throttle_count');
        } else {
            _log('overlimit sum:' . $sum . ' limit:' . $limit, 3, 'sendsms_throttle_count');
            return FALSE;
        }
    }
    // save in registry
    if (registry_update($uid, 'core', 'sendsms', array('throttle_start' => $start, 'throttle_sum' => $sum))) {
        return TRUE;
    }
    return FALSE;
}
Beispiel #19
0
     exit;
     break;
 case "msg_list":
     if ($err = $_SESSION['error_string']) {
         $content = "<div class=error_string>{$err}</div>";
     }
     $content .= "\n\t\t\t<h2>" . _('Manage subscribe') . "</h2>\n\t\t\t<h3>" . _('SMS messages list for keyword') . " {$subscribe_name}</h3>\n\t\t\t<p>" . _button('index.php?app=main&inc=feature_sms_subscribe&op=msg_add&&subscribe_id=' . $subscribe_id, _('Add message')) . "\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t<thead><tr>\n\t\t\t\t<th width=40%>" . _('Message') . "</th>\n\t\t\t\t<th width=20%>" . _('Created') . "</th>\n\t\t\t\t<th width=20%>" . _('Last update') . "</th>\n\t\t\t\t<th width=10%>" . _('Sent') . "</th>\n\t\t\t\t<th width=10%>" . _('Action') . "</th>\n\t\t\t</tr></thead>\n\t\t\t<tbody>";
     $i = 0;
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe_msg WHERE subscribe_id='{$subscribe_id}'";
     $db_result = dba_query($db_query);
     while ($db_row = dba_fetch_array($db_result)) {
         $action = "<a href=\"" . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_view&subscribe_id=' . $db_row['subscribe_id'] . '&msg_id=' . $db_row['msg_id']) . "\">" . $icon_config['view'] . "</a>&nbsp;";
         $action .= "<a href=\"" . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_edit&subscribe_id=' . $subscribe_id . '&msg_id=' . $db_row['msg_id']) . "\">" . $icon_config['edit'] . "</a>&nbsp;";
         $action .= "<a href=\"javascript: ConfirmURL('" . _('Are you sure you want to delete this message?') . "','" . _u('index.php?app=main&inc=feature_sms_subscribe&op=msg_del&subscribe_id=' . $subscribe_id . '&msg_id=' . $db_row['msg_id']) . "')\">" . $icon_config['delete'] . "</a>";
         $i++;
         $content .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . $db_row['msg'] . "</td>\n\t\t\t\t\t<td>" . core_display_datetime($db_row['create_datetime']) . "</td>\n\t\t\t\t\t<td>" . core_display_datetime($db_row['update_datetime']) . "</td>\n\t\t\t\t\t<td>" . $db_row['counter'] . "</td>\n\t\t\t\t\t<td>{$action}</td>\n\t\t\t\t\t</tr>";
     }
     $content .= "\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\t<p>" . _button('index.php?app=main&inc=feature_sms_subscribe&op=msg_add&&subscribe_id=' . $subscribe_id, _('Add message')) . "\n\t\t\t<p>" . _back('index.php?app=main&inc=feature_sms_subscribe&op=sms_subscribe_list');
     _p($content);
     break;
 case "msg_edit":
     $msg_id = $_REQUEST['msg_id'];
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe_msg WHERE subscribe_id='{$subscribe_id}' AND msg_id = '{$msg_id}'";
     $db_result = dba_query($db_query);
     $db_row = dba_fetch_array($db_result);
     $edit_mbr_msg = $db_row['msg'];
     if ($err = $_SESSION['error_string']) {
         $content = "<div class=error_string>{$err}</div>";
     }
     $content .= "\n\t\t\t<h2>" . _('Manage subscribe') . "</h2>\n\t\t\t<h3>" . _('Edit message') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_subscribe&op=msg_edit_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<input type=hidden value={$subscribe_id} name=subscribe_id>\n\t\t\t<input type=hidden value={$msg_id} name=msg_id>\n\t\t\t<table class=playsms-table>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('SMS subscribe keyword') . "</td><td>{$subscribe_name}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2>\n\t\t\t\t\t" . _('Message body') . "<br />\n\t\t\t\t\t<textarea name=edit_mbr_msg rows=5 cols=60>{$edit_mbr_msg}</textarea>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t<p>" . _back('index.php?app=main&inc=feature_sms_subscribe&op=msg_list&subscribe_id=' . $subscribe_id);
     _p($content);
Beispiel #20
0
function webservices_inject($c_username, $from, $msg, $recvnum = '', $smsc = '')
{
    $ret = '';
    if ($from && $msg) {
        if ($c_username) {
            // inject message
            $sms_datetime = core_display_datetime(core_get_datetime());
            recvsms($sms_datetime, $from, $msg, $recvnum, $smsc);
            $json['status'] = 'OK';
            $json['error'] = '0';
        } else {
            $json['status'] = 'ERR';
            $json['error'] = '601';
        }
    } else {
        $json['status'] = 'ERR';
        $json['error'] = '602';
    }
    return $json;
}
Beispiel #21
0
         unset($conditions['uid']);
     }
     $keywords = $search['dba_keywords'];
     $count = dba_count(_DB_PREF_ . '_tblRegistry', $conditions, $keywords);
     $nav = themes_nav($count, $search['url']);
     $extras = array('ORDER BY' => 'uid', 'LIMIT' => $nav['limit'], 'OFFSET' => $nav['offset']);
     $list = dba_search(_DB_PREF_ . '_tblRegistry', '*', $conditions, $keywords, $extras);
     $sender_id_list = array();
     $i = $nav['top'];
     $j = 0;
     for ($j = 0; $j < count($list); $j++) {
         $username = auth_isadmin() ? user_uid2username($list[$j]['uid']) : '';
         $status = $list[$j]['registry_value'] == 1 ? "<span class=status_enabled></span>" : "<span class=status_disabled></span>";
         $toggle_status = auth_isadmin() ? "<a href='" . _u('index.php?app=main&inc=core_sender_id&op=toggle_status&id=' . $list[$j]['id']) . "'>" . $status . "</a>" : $status;
         $action = "\n\t\t\t\t<a href='" . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $list[$j]['id']) . "'>" . $icon_config['edit'] . "</a>\n\t\t\t\t<a href=\"javascript: ConfirmURL('" . addslashes(_('Are you sure you want to delete sender ID') . ' ? (' . _('Sender ID') . ': ' . $list[$j]['registry_key'] . ')') . "','" . _u('index.php?app=main&inc=core_sender_id&op=sender_id_delete&id=' . $list[$j]['id']) . "')\">" . $icon_config['delete'] . "</a>\n\t\t\t";
         $sender_id_list[] = array('username' => $username, 'sender_id' => core_sanitize_sender($list[$j]['registry_key']), 'sender_id_description' => sender_id_description($list[$j]['uid'], $list[$j]['registry_key']), 'lastupdate' => core_display_datetime(core_convert_datetime($list[$j]['c_timestamp'])), 'status' => $toggle_status, 'action' => $action);
     }
     $tpl = array('name' => 'sender_id', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'SEARCH_FORM' => $search['form'], 'NAV_FORM' => $nav['form'], 'FORM_TITLE' => _('Manage sender ID'), 'ADD_URL' => _u('index.php?app=main&inc=core_sender_id&op=sender_id_add'), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_STATUS' => _hint(_('Click the status button to enable or disable status')), 'Sender ID' => _('Sender ID'), 'Username' => _('Username'), 'Last update' => _('Last update')), 'ifs' => array('isadmin' => auth_isadmin()), 'loops' => array('sender_id_list' => $sender_id_list), 'injects' => array('icon_config'));
     _p(tpl_apply($tpl));
     break;
 case "sender_id_add":
     $nav = themes_nav_session();
     $search = themes_search_session();
     if ($nav['url']) {
         $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
     } else {
         $ref = 'index.php?app=main&inc=core_sender_id&op=sender_id_list';
     }
     if (auth_isadmin()) {
         $select_approve = _yesno('approved', 0);
         $select_users = themes_select_users_single('uid', $user_config['uid']);
Beispiel #22
0
             }
         }
         // remove user except those who still have subusers
         $subusers = user_getsubuserbyuid($list[$i]['uid']);
         if (count($subusers) > 0) {
             $action .= _hint(_('Please remove all subusers from this user to delete'));
         } else {
             $action .= "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to delete user")) . " " . $list[$i]['username'] . " ?','" . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_del&uname=' . $list[$i]['username']) . "&view=" . $view . "')\">" . $icon_config['user_delete'] . "</a>";
         }
         // subuser shows parent column
         if ($list[$i]['status'] == 4) {
             $isadmin = user_getfieldbyuid($list[$i]['parent_uid'], 'status') == 2 ? $icon_config['admin'] : '';
             $parent_column_row = "<td>" . user_uid2username($list[$i]['parent_uid']) . " " . $isadmin . "</td>";
         }
         $j--;
         $content .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . core_display_datetime($list[$i]['register_datetime']) . "</td>\n\t\t\t\t\t" . $parent_column_row . "\n\t\t\t\t\t<td>" . $banned_icon . "" . $list[$i]['username'] . " </td>\n\t\t\t\t\t<td>" . $list[$i]['name'] . "</td>\n\t\t\t\t\t<td>" . $list[$i]['mobile'] . "</td>\n\t\t\t\t\t<td>" . rate_getusercredit($list[$i]['username']) . "</td>\n\t\t\t\t\t<td>" . acl_getnamebyuid($list[$i]['uid']) . "</td>\n\t\t\t\t\t<td>" . $action . "</td>\n\t\t\t\t</tr>";
     }
     $content .= "\n\t\t\t</tbody></table>\n\t\t\t</div>\n\t\t\t<div class=pull-right>" . $nav['form'] . "</div>";
     _p($content);
     break;
 case "user_add":
     if ($err = TRUE) {
         $content = _dialog();
     }
     $add_datetime_timezone = $_REQUEST['add_datetime_timezone'];
     $add_datetime_timezone = $add_datetime_timezone ? $add_datetime_timezone : core_get_timezone();
     // get language options
     $lang_list = '';
     for ($i = 0; $i < count($core_config['languagelist']); $i++) {
         $language = $core_config['languagelist'][$i];
         $c_language_title = $plugin_config[$language]['title'];
Beispiel #23
0
 case "dst_edit":
     $id = $_REQUEST['id'];
     // destination ID
     $schedule_id = $_REQUEST['schedule_id'];
     // schedule ID
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSchedule WHERE uid='" . $user_config['uid'] . "' AND id='{$schedule_id}' AND flag_deleted='0'";
     $db_result = dba_query($db_query);
     $db_row = dba_fetch_array($db_result);
     $schedule_name = $db_row['name'];
     $schedule_message = $db_row['message'];
     if ($id && $schedule_id && $schedule_name && $schedule_message) {
         $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSchedule_dst WHERE schedule_id='{$schedule_id}' AND id='{$id}'";
         $db_result = dba_query($db_query);
         $db_row = dba_fetch_array($db_result);
         $schedule = $db_row['schedule'];
         $schedule = $schedule ? core_display_datetime($schedule) : '0000-00-00 00:00:00';
         $name = $db_row['name'];
         $destination = $db_row['destination'];
         $content = _dialog() . "\n\t\t\t\t<h2>" . _('Schedule messages') . "</h2>\n\t\t\t\t<h3>" . _('Manage schedule') . "</h3>\n\t\t\t\t<h4>" . _('Edit destination') . "</h4>\n\t\t\t\t<form action=index.php?app=main&inc=feature_schedule&route=manage&op=dst_edit_yes method=post>\n\t\t\t\t" . _CSRF_FORM_ . "\n\t\t\t\t<input type=hidden name=schedule_id value='" . $schedule_id . "'>\n\t\t\t\t<input type=hidden name=id value='" . $id . "'>\n\t\t\t\t<table class=playsms-table cellpadding=1 cellspacing=2 border=0>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _('Schedule name') . "</td><td>" . $schedule_name . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Scheduled message') . "</td><td>" . $schedule_message . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('Name')) . "</td><td><input type=text maxlength=250 name=name value='" . $name . "'></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('Destination')) . "</td><td><input type=text maxlength=20 name=destination value='" . $destination . "'> " . _hint(_('Separate by comma for multiple destinations')) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('Schedule')) . "</td><td><input type=text maxlength=19 name=schedule value='" . $schedule . "'> " . _hint(_('Format YYYY-MM-DD hh:mm')) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t\t</form>\n\t\t\t\t" . _back('index.php?app=main&inc=feature_schedule&route=manage&op=list&id=' . $schedule_id);
     } else {
         auth_block();
     }
     _p($content);
     break;
 case "dst_edit_yes":
     $id = $_REQUEST['id'];
     // destination ID
     $schedule_id = $_REQUEST['schedule_id'];
     // schedule ID
     $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSchedule WHERE uid='" . $user_config['uid'] . "' AND id='{$schedule_id}' AND flag_deleted='0'";
     $db_result = dba_query($db_query);
Beispiel #24
0
 $nav = themes_nav_session();
 $search = themes_search_session();
 $go = $_REQUEST['go'];
 switch ($go) {
     case 'export':
         $conditions = array('flag_deleted' => 0);
         // only if users
         if ($user_config['status'] == 3) {
             $conditions['parent_uid'] = $user_config['uid'];
             $conditions['status'] = 4;
         }
         $list = dba_search($db_table, '*', $conditions, $search['dba_keywords']);
         $data[0] = array(_('User'), _('Transaction datetime'), _('Amount'));
         for ($i = 0; $i < count($list); $i++) {
             $j = $i + 1;
             $data[$j] = array($list[$i]['username'], core_display_datetime($list[$i]['create_datetime']), $list[$i]['amount']);
         }
         $content = core_csv_format($data);
         $fn = 'credit-' . $core_config['datetime']['now_stamp'] . '.csv';
         core_download($content, $fn, 'text/csv');
         break;
     case 'delete':
         for ($i = 0; $i < $nav['limit']; $i++) {
             $checkid = $_POST['checkid' . $i];
             $itemid = $_POST['itemid' . $i];
             if ($checkid == "on" && $itemid) {
                 $up = array('c_timestamp' => mktime(), 'delete_datetime' => core_get_datetime(), 'flag_deleted' => '1');
                 // only if users
                 if ($user_config['status'] == 3) {
                     $up['parent_uid'] = $user_config['uid'];
                     $up['status'] = 4;
Beispiel #25
0
 $nav = themes_nav_session();
 $search = themes_search_session();
 $go = $_REQUEST['go'];
 switch ($go) {
     case 'export':
         $conditions = array('A.flag_deleted' => 0);
         if ($queue_code = trim($_REQUEST['queue_code'])) {
             $conditions['A.queue_code'] = $queue_code;
         }
         $table = _DB_PREF_ . '_tblSMSOutgoing';
         $join = "INNER JOIN " . _DB_PREF_ . "_tblUser AS B ON B.flag_deleted='0' AND A.uid=B.uid";
         $list = dba_search($table . ' AS A', 'B.username, A.p_gateway, A.p_smsc, A.p_datetime, A.p_dst, A.p_msg, A.p_footer, A.p_status', $conditions, $search['dba_keywords'], '', $join);
         $data[0] = array(_('User'), _('Gateway'), _('SMSC'), _('Time'), _('To'), _('Message'), _('Status'));
         for ($i = 0; $i < count($list); $i++) {
             $j = $i + 1;
             $data[$j] = array($list[$i]['username'], $list[$i]['p_gateway'], $list[$i]['p_smsc'], core_display_datetime($list[$i]['p_datetime']), $list[$i]['p_dst'], $list[$i]['p_msg'] . $list[$i]['p_footer'], $list[$i]['p_status']);
         }
         $content = core_csv_format($data);
         if ($queue_code) {
             $fn = 'all_outgoing-' . $core_config['datetime']['now_stamp'] . '-' . $queue_code . '.csv';
         } else {
             $fn = 'all_outgoing-' . $core_config['datetime']['now_stamp'] . '.csv';
         }
         core_download($content, $fn, 'text/csv');
         break;
     case 'delete':
         for ($i = 0; $i < $nav['limit']; $i++) {
             $checkid = $_POST['checkid' . $i];
             $itemid = $_POST['itemid' . $i];
             if ($checkid == "on" && $itemid) {
                 $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
Beispiel #26
0
}
$remote_addr = $_SERVER['REMOTE_ADDR'];
// srosa 20100531: added var below
$remote_host = $_SERVER['HTTP_HOST'];
// srosa 20100531: changed test below to allow hostname in bearerbox_host instead of ip
// if ($remote_addr != $plugin_config['kannel']['bearerbox_host'])
if ($remote_addr != $plugin_config['kannel']['bearerbox_host'] && $remote_host != $plugin_config['kannel']['bearerbox_host']) {
    logger_print("exit remote_addr:" . $remote_addr . " remote_host:" . $remote_host . " bearerbox_host:" . $plugin_config['kannel']['bearerbox_host'], 2, "kannel incoming");
    exit;
}
// if the arrival time is in UTC then we need to adjust it with this:
if ($plugin_config['kannel']['local_time']) {
    $t = trim($_REQUEST['t']);
} else {
    // in UTC
    $t = core_display_datetime($_REQUEST['t']);
}
$q = trim($_REQUEST['q']);
// sms_sender
$a = trim($_REQUEST['a']);
// message
$Q = trim($_REQUEST['Q']);
// sms_receiver
$smsc = trim($_REQUEST['smsc']);
// SMSC
logger_print("addr:" . $remote_addr . " host:" . $remote_host . " t:" . $t . " q:" . $q . " a:" . $a . " Q:" . $Q . " smsc:[" . $smsc . "]", 3, "kannel incoming");
if ($t && $q && $a) {
    // collected:
    // $sms_datetime, $sms_sender, $message, $sms_receiver
    recvsms($t, $q, $a, $Q, $smsc);
}
Beispiel #27
0
error_reporting(0);
if (!$called_from_hook_call) {
    chdir("../../../");
    // ignore CSRF
    $core_config['init']['ignore_csrf'] = TRUE;
    include "init.php";
    include $core_config['apps_path']['libs'] . "/function.php";
    chdir("plugin/feature/sms_sync/");
}
$r = $_REQUEST;
$c_uid = $r['uid'];
$list = registry_search($c_uid, 'feature', 'sms_sync');
$sms_sync_secret = $list['feature']['sms_sync']['secret'];
$sms_sync_enable = $list['feature']['sms_sync']['enable'];
$message_id = $r['message_id'];
$sms_datetime = core_display_datetime(core_get_datetime());
$sms_sender = $r['from'];
$message = $r['message'];
$sms_receiver = $r['sent_to'];
$ok = FALSE;
if ($sms_sync_enable && $c_uid && $r['secret'] == $sms_sync_secret && $message_id && $sms_sender && $message) {
    $db_table = _DB_PREF_ . '_featureSmssysnc';
    $conditions = array('uid' => $c_uid, 'message_id' => $message_id);
    if (dba_isavail($db_table, $conditions, 'AND')) {
        _log("saving uid:" . $c_uid . " dt:" . $sms_datetime . " ts:" . $r['sent_timestamp'] . " message_id:" . $message_id . " s:" . $sms_sender . " m:" . $message . " r:" . $sms_receiver, 3, "sms_sync sync");
        // if keyword does not exists (checkavailablekeyword == TRUE)
        // then prefix the message with an @username so that it will be routed to $c_uid's inbox
        $m = explode(' ', $message);
        $c_m = str_replace('#', '', $m[0]);
        if (checkavailablekeyword($c_m)) {
            _log("forwarded to inbox uid:" . $c_uid . " message_id:" . $message_id, 3, "sms_sync sync");
Beispiel #28
0
     $tpl['name'] = 'user_inbox';
     $content = tpl_apply($tpl);
     _p($content);
     break;
 case "actions":
     $nav = themes_nav_session();
     $search = themes_search_session();
     $go = $_REQUEST['go'];
     switch ($go) {
         case 'export':
             $conditions = array('in_uid' => $user_config['uid'], 'flag_deleted' => 0);
             $list = dba_search(_DB_PREF_ . '_tblUser_inbox', '*', $conditions, $search['dba_keywords']);
             $data[0] = array(_('User'), _('Time'), _('From'), _('Message'));
             for ($i = 0; $i < count($list); $i++) {
                 $j = $i + 1;
                 $data[$j] = array(user_uid2username($list[$i]['in_uid']), core_display_datetime($list[$i]['in_datetime']), $list[$i]['in_sender'], $list[$i]['in_msg']);
             }
             $content = core_csv_format($data);
             $fn = 'user_inbox-' . $core_config['datetime']['now_stamp'] . '.csv';
             core_download($content, $fn, 'text/csv');
             break;
         case 'delete':
             for ($i = 0; $i < $nav['limit']; $i++) {
                 $checkid = $_POST['checkid' . $i];
                 $itemid = $_POST['itemid' . $i];
                 if ($checkid == "on" && $itemid) {
                     $up = array('c_timestamp' => mktime(), 'flag_deleted' => '1');
                     dba_update(_DB_PREF_ . '_tblUser_inbox', $up, array('in_uid' => $user_config['uid'], 'in_id' => $itemid));
                 }
             }
             $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
Beispiel #29
0
 $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")) {
     $p_msg = $p_msg . " {$p_footer}";
 }
 $p_datetime = core_display_datetime($db_row['p_datetime']);
 $p_gateway = $db_row['p_gateway'];
 $p_update = $db_row['p_update'];
 $p_status = $db_row['p_status'];
 $p_gpid = $db_row['p_gpid'];
 // 0 = pending
 // 1 = sent
 // 2 = failed
 // 3 = delivered
 if ($p_status == "1") {
     $p_status = "<p><font color=green>" . _('Sent') . "</font></p>";
 } else {
     if ($p_status == "2") {
         $p_status = "<p><font color=red>" . _('Failed') . "</font></p>";
     } else {
         if ($p_status == "3") {
Beispiel #30
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with playSMS. If not, see <http://www.gnu.org/licenses/>.
 */
defined('_SECURE_') or die('Forbidden');
if (!auth_isadmin()) {
    auth_block();
}
switch (_OP_) {
    case "simulate":
        $sender = '629876543210';
        $receiver = '1234';
        $datetime = core_get_datetime();
        $content .= _dialog() . "\n\t\t\t<h2>" . _('Simulate incoming SMS') . "</h2>\n\t\t\t<form action=\"index.php?app=main&inc=gateway_dev&route=simulate&op=simulate_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><td class=label-sizer>" . _('Message') . "</td><td><input type=text name=message value=\"{$message}\" maxlength=250></td></tr>\n\t\t\t\t<tr><td>" . _('Sender') . "</td><td><input type=text name=sender value=\"{$sender}\" maxlength=20></td></tr>\n\t\t\t\t<tr><td>" . _('Receiver') . "</td><td><input type=text name=receiver value=\"{$receiver}\" maxlength=20></td></tr>\n\t\t\t\t<tr><td>" . _('Date/Time') . "</td><td><input type=text name=datetime value=\"" . core_display_datetime($datetime) . "\" maxlength=20></td></tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Submit') . "\">\n\t\t\t</form>";
        _p($content);
        break;
    case "simulate_yes":
        $sms_sender = $_REQUEST['sender'] ? $_REQUEST['sender'] : '629876543210';
        $sms_receiver = $_REQUEST['receiver'] ? $_REQUEST['receiver'] : '1234';
        $sms_datetime = $_REQUEST['datetime'] ? $_REQUEST['datetime'] : core_get_datetime();
        $message = $_REQUEST['message'] ? $_REQUEST['message'] : _('This is a test incoming SMS message');
        $message = htmlspecialchars_decode($message);
        if (trim($sms_sender) && trim($sms_receiver) && trim($sms_datetime) && trim($message)) {
            recvsms($sms_datetime, $sms_sender, $message, $sms_receiver, 'dev');
            $err[] = "Sender ID: " . $sms_sender;
            $err[] = "Receiver number: " . $sms_receiver;
            $err[] = "Sent: " . $sms_datetime;
            $err[] = "Message: " . stripslashes($message);
            _log(print_r($err, TRUE), 3, "dev incoming");