コード例 #1
0
ファイル: incoming.php プロジェクト: amoskarugaba/playSMS
     break;
 case "incoming_save":
     // form pre rules
     // scan message for @username
     $pre_rules['match_username'] = (int) $_REQUEST['incoming_match_username'];
     $items['incoming_match_username'] = $pre_rules['match_username'];
     // scan message for #groupcode
     $pre_rules['match_groupcode'] = (int) $_REQUEST['incoming_match_groupcode'];
     $items['incoming_match_groupcode'] = $pre_rules['match_groupcode'];
     // form post rules
     // sandbox match receiver number and sender ID
     $post_rules['match_sender_id'] = (int) $_REQUEST['sandbox_match_sender_id'];
     $items['sandbox_match_sender_id'] = $post_rules['match_sender_id'];
     // sandbox prefix
     $post_rules['insert_prefix'] = trim(strtoupper(core_sanitize_alphanumeric($_REQUEST['sandbox_prefix'])));
     if ($post_rules['insert_prefix'] && keyword_isavail($post_rules['insert_prefix'])) {
         $_SESSION['dialog']['info'][] = _('Fail to insert keyword') . ' (' . _('keyword') . ': ' . $post_rules['insert_prefix'] . ')';
         $post_rules['insert_prefix'] = '';
     }
     $items['sandbox_prefix'] = $post_rules['insert_prefix'];
     // sandbox forward to users
     $post_rules['forward_to'] = serialize(array_unique($_REQUEST['uids']));
     $items['sandbox_forward_to'] = $post_rules['forward_to'];
     // sandbox forward to url
     $post_rules['forward_to_url'] = $_REQUEST['forward_to_url'];
     $items['sandbox_forward_to_url'] = $post_rules['forward_to_url'];
     // form settings
     // settings to leave copy on sandbox
     $items['settings_leave_copy_sandbox'] = (int) $_REQUEST['settings_leave_copy_sandbox'];
     // settings to match with all approved sender ID
     $items['settings_match_all_sender_id'] = (int) $_REQUEST['settings_match_all_sender_id'];
コード例 #2
0
ファイル: sms_custom.php プロジェクト: 10corp/playSMS
     exit;
     break;
 case "sms_custom_add":
     $content .= _dialog() . "\n\t\t\t<h2>" . _('Manage custom') . "</h2>\n\t\t\t<h3>" . _('Add SMS custom') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_custom&op=sms_custom_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _mandatory(_('Service name')) . "</td><td><input type=text size=30 maxlength=255 name=add_service_name value=\"" . _lastpost('add_service_name') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('SMS custom keywords')) . "</td><td><input type=text size=30 maxlength=255 name=add_custom_keyword value=\"" . _lastpost('add_custom_keyword') . "\"> " . _hint('Multiple keywords seperated by space') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Receiver number') . "</td><td><input type=text size=30 maxlength=20 name=add_sms_receiver value=\"" . _lastpost('add_sms_receiver') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>" . _('Pass these parameters to custom URL field') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t" . _('Pass these parameters to custom URL field') . "\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>{SERVICENAME} " . _('will be replaced by service name') . "</li>\n\t\t\t\t\t\t\t<li>{SMSDATETIME} " . _('will be replaced by SMS incoming date/time') . "</li>\n\t\t\t\t\t\t\t<li>{SMSSENDER} " . _('will be replaced by sender number') . "</li>\n\t\t\t\t\t\t\t<li>{SMSRECEIVER} " . _('will be replaced by receiver number') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMKEYWORD} " . _('will be replaced by custom keyword') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMPARAM} " . _('will be replaced by custom parameter passed to server from SMS') . "</li>\n\t\t\t\t\t\t\t<li>{CUSTOMRAW} " . _('will be replaced by SMS raw message') . "</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t" . _('Example of SMS custom URL') . "\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>" . htmlspecialchars('http://someserver.somedomain/handler.php?service={SERVICENAME}&datetime={SMSDATETIME}&sender={SMSSENDER}&receiver={SMSRECEIVER}&keyword={CUSTOMKEYWORD}&param={CUSTOMPARAM}&raw={CUSTOMRAW}') . "</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _mandatory(_('SMS custom URL')) . "</td><td><input type=text maxlength=255 name=add_custom_url value=\"" . _lastpost('add_custom_url') . "\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Make return as reply') . "</td><td><input type=checkbox name=add_custom_return_as_reply></td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_custom&op=sms_custom_list');
     _p($content);
     break;
 case "sms_custom_add_yes":
     $add_service_name = trim($_POST['add_service_name']);
     $add_sms_receiver = trim($_POST['add_sms_receiver']);
     $add_custom_return_as_reply = $_POST['add_custom_return_as_reply'] == 'on' ? '1' : '0';
     $add_custom_url = $_POST['add_custom_url'];
     $add_custom_keyword = strtoupper($_POST['add_custom_keyword']);
     $c_keywords = explode(' ', $add_custom_keyword);
     foreach ($c_keywords as $keyword) {
         if ($keyword) {
             if (keyword_isavail($keyword, $add_sms_receiver)) {
                 $keywords .= core_sanitize_alphanumeric($keyword) . ' ';
             } else {
                 $_SESSION['dialog']['danger'][] = sprintf(_('Keyword %s is not available'), $keyword);
             }
         }
     }
     $keywords = trim($keywords);
     if ($add_service_name && $keywords && $add_custom_url) {
         $db_query = "INSERT INTO " . _DB_PREF_ . "_featureCustom (uid,service_name,custom_keyword,sms_receiver,custom_url,custom_return_as_reply) VALUES ('" . $user_config['uid'] . "','{$add_service_name}','{$keywords}','{$add_sms_receiver}','{$add_custom_url}','{$add_custom_return_as_reply}')";
         if ($new_uid = @dba_insert_id($db_query)) {
             $_SESSION['dialog']['info'][] = sprintf(_('SMS custom with keyword %s has been added'), $keywords);
             _lastpost_empty();
         } else {
             $_SESSION['dialog']['danger'][] = _('Fail to add SMS custom');
         }
コード例 #3
0
ファイル: sms_board.php プロジェクト: 10corp/playSMS
         }
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_board&op=sms_board_list'));
     exit;
     break;
 case "sms_board_add":
     $content = _dialog() . "\n\t\t\t<h2>" . _('Manage board') . "</h2>\n\t\t\t<h3>" . _('Add SMS board') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_board&op=sms_board_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table cellpadding=1 cellspacing=2 border=0>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('SMS board keyword') . "</td><td><input type=text maxlength=30 name=add_board_keyword value=\"{$add_board_keyword}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Forward to email') . "</td><td><input type=text name=add_email value=\"{$add_email}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('CSS URL') . "</td><td><input type=text name=add_css value=\"{$add_css}\"></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_board&op=sms_board_list');
     _p($content);
     break;
 case "sms_board_add_yes":
     $add_board_keyword = strtoupper($_POST['add_board_keyword']);
     $add_email = $_POST['add_email'];
     $add_css = $_POST['add_css'];
     $add_template = $_POST['add_template'];
     if ($add_board_keyword) {
         if (keyword_isavail($add_board_keyword)) {
             if (!$add_template) {
                 $add_template = "<div class=sms_board_row>\n";
                 $add_template .= "\t<div class=sender>{SENDER}</div>\n";
                 $add_template .= "\t<div class=datetime>{DATETIME}</div>\n";
                 $add_template .= "\t<div class=message>{MESSAGE}</div>\n";
                 $add_template .= "</div>\n";
             }
             $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featureBoard (uid,board_keyword,board_forward_email,board_css,board_pref_template)\n\t\t\t\t\tVALUES ('" . $user_config['uid'] . "','{$add_board_keyword}','{$add_email}','{$add_css}','{$add_template}')";
             if ($new_uid = @dba_insert_id($db_query)) {
                 $_SESSION['dialog']['info'][] = _('SMS board has been added') . " (" . _('keyword') . ": {$add_board_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS board') . " (" . _('keyword') . ": {$add_board_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS keyword already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_board_keyword})";
コード例 #4
0
ファイル: fn.php プロジェクト: 10corp/playSMS
/**
 * Intercept on before-process stage for incoming SMS
 *
 * @param $sms_datetime incoming
 *        SMS date/time
 * @param $sms_sender incoming
 *        SMS sender
 * @param $message incoming
 *        SMS message before interepted
 * @param $sms_receiver receiver
 *        number that is receiving incoming SMS
 * @param $reference_id reference_id
 *        data
 * @return array $ret
 */
function incoming_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver, $reference_id)
{
    $ret = array();
    $found_bc = FALSE;
    $found_pv = FALSE;
    // continue only when keyword does not exists
    $m = explode(' ', $message);
    if (!keyword_isavail($m[0])) {
        return $ret;
    }
    // get settings
    $settings = incoming_settings_get();
    // get post rules
    $pre_rules = incoming_pre_rules_get();
    // scan for #<sender's phonebook group code> and @<username> according to pre rules
    $msg = explode(' ', $message);
    if (count($msg) > 0) {
        $bc = array();
        $pv = array();
        for ($i = 0; $i < count($msg); $i++) {
            $c_text = trim($msg[$i]);
            // scan message for @username
            if ($pre_rules['match_username']) {
                if (substr($c_text, 0, 1) === '@') {
                    $pv[] = strtolower(substr($c_text, 1));
                    $found_pv = TRUE;
                }
            }
            // scan message for #groupcode
            if ($pre_rules['match_groupcode']) {
                if (substr($c_text, 0, 1) === '#') {
                    $bc[] = strtoupper(substr($c_text, 1));
                    $found_bc = TRUE;
                }
            }
        }
    }
    if ($found_bc || $found_pv) {
        _log("recvsms_intercept dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
    }
    if ($found_bc) {
        $groups = array_unique($bc);
        foreach ($groups as $key => $c_group_code) {
            $c_uid = user_mobile2uid($sms_sender);
            $list = phonebook_search_group($c_uid, $c_group_code, '', TRUE);
            $c_gpid = $list[0]['gpid'];
            if ($c_uid && $c_gpid) {
                $c_username = user_uid2username($c_uid);
                _log("bc g:" . phonebook_code_clean($c_group_code) . " gpid:" . $c_gpid . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:" . $message, 3, 'incoming recvsms_intercept');
                sendsms_bc($c_username, $c_gpid, $message);
                _log("bc end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            }
        }
    }
    if ($found_pv) {
        $users = array_unique($pv);
        foreach ($users as $key => $c_username) {
            $c_username = core_sanitize_username($c_username);
            if ($c_uid = user_username2uid($c_username)) {
                _log("pv u:" . $c_username . " uid:" . $c_uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:[" . $message . "] reference_id:" . $reference_id, 3, 'incoming recvsms_intercept');
                recvsms_inbox_add($sms_datetime, $sms_sender, $c_username, $message, $sms_receiver, $reference_id);
                _log("pv end", 3, 'incoming recvsms_intercept');
                $ret['uid'] = $c_uid;
                $ret['hooked'] = true;
            }
        }
    }
    return $ret;
}
コード例 #5
0
ファイル: sms_autoreply.php プロジェクト: kothsada/playSMS
         $select_reply_smsc = "<tr><td>" . _('SMSC') . "</td><td>" . gateway_select_smsc('smsc') . "</td></tr>";
     }
     $content .= "\n\t\t\t<h2>" . _('Manage autoreply') . "</h2>\n\t\t\t<h3>" . _('Add SMS autoreply') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _mandatory(_('SMS autoreply keyword')) . "</td>\n\t\t\t\t\t<td><input type=text size=10 maxlength=10 name=add_autoreply_keyword value=\"{$add_autoreply_keyword}\"></td>\n\t\t\t\t</tr>\n\t\t\t\t" . $select_reply_smsc . "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value='" . _('Save') . "'></p>\n\t\t\t</form>\n\t\t\t<p>" . _back('index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_list');
     if ($err = TRUE) {
         _p(_dialog());
     }
     _p($content);
     break;
 case "sms_autoreply_add_yes":
     // max keyword is 10 chars
     $add_autoreply_keyword = substr(trim(strtoupper($_POST['add_autoreply_keyword'])), 0, 10);
     if (auth_isadmin()) {
         $smsc = $_POST['smsc'];
     }
     if ($add_autoreply_keyword) {
         if (keyword_isavail($add_autoreply_keyword)) {
             $db_query = "INSERT INTO " . _DB_PREF_ . "_featureAutoreply (uid,autoreply_keyword,smsc) VALUES ('" . $user_config['uid'] . "','{$add_autoreply_keyword}','{$smsc}')";
             if ($new_uid = @dba_insert_id($db_query)) {
                 $_SESSION['dialog']['info'][] = _('SMS autoreply keyword has been added') . " (" . _('keyword') . ": {$add_autoreply_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS autoreply') . " (" . _('keyword') . ": {$add_autoreply_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS keyword already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_autoreply_keyword})";
         }
     } else {
         $_SESSION['dialog']['info'][] = _('All mandatory fields must be filled');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_autoreply&op=sms_autoreply_add'));
     exit;
     break;
コード例 #6
0
ファイル: sms_quiz.php プロジェクト: 10corp/playSMS
         $content = _dialog();
     }
     $content .= "\n\t\t\t<h2>" . _('Manage quiz') . "</h2>\n\t\t\t<h3>" . _('Add SMS quiz') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_quiz&op=sms_quiz_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('SMS quiz keyword') . "</td><td><input type=text size=10 maxlength=10 name=add_quiz_keyword value=\"{$add_quiz_keyword}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('SMS quiz question') . "</td><td><input type=text maxlength=100 name=add_quiz_question value=\"{$add_quiz_question}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('SMS quiz answer') . "</td><td><input type=text maxlength=100 name=add_quiz_answer value=\"{$add_quiz_answer}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Reply message on correct') . "</td><td><input type=text maxlength=100 name=add_quiz_msg_correct value=\"{$add_quiz_msg_correct}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Reply message on incorrect') . "</td><td><input type=text maxlength=100 name=add_quiz_msg_incorrect value=\"{$add_quiz_msg_incorrect}\"></td>\n\t\t\t</tr>\n\t\t\t" . $select_reply_smsc . "\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_quiz&op=sms_quiz_list');
     _p($content);
     break;
 case "sms_quiz_add_yes":
     $add_quiz_keyword = strtoupper($_POST['add_quiz_keyword']);
     $add_quiz_question = $_POST['add_quiz_question'];
     $add_quiz_answer = strtoupper($_POST['add_quiz_answer']);
     $add_quiz_msg_correct = $_POST['add_quiz_msg_correct'];
     $add_quiz_msg_incorrect = $_POST['add_quiz_msg_incorrect'];
     if (auth_isadmin()) {
         $smsc = $_REQUEST['smsc'];
     }
     if ($add_quiz_keyword && $add_quiz_answer) {
         if (keyword_isavail($add_quiz_keyword)) {
             $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featureQuiz (uid,quiz_keyword,quiz_question,quiz_answer,quiz_msg_correct,quiz_msg_incorrect,smsc)\n\t\t\t\t\tVALUES ('" . $user_config['uid'] . "','{$add_quiz_keyword}','{$add_quiz_question}','{$add_quiz_answer}','{$add_quiz_msg_correct}','{$add_quiz_msg_incorrect}','{$smsc}')";
             if ($new_uid = @dba_insert_id($db_query)) {
                 $_SESSION['dialog']['info'][] = _('SMS quiz has been added') . " (" . _('keyword') . ": {$add_quiz_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS quiz') . " (" . _('keyword') . ": {$add_quiz_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS quiz already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_quiz_keyword})";
         }
     } else {
         $_SESSION['dialog']['info'][] = _('You must fill all field');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_quiz&op=sms_quiz_add'));
     exit;
     break;
コード例 #7
0
ファイル: sms_poll.php プロジェクト: 10corp/playSMS
     $content .= "\n\t\t\t<h2>" . _('Manage poll') . "</h2>\n\t\t\t<h3>" . _('Add SMS poll') . "</h3>\n\t\t\t<form action=\"index.php?app=main&inc=feature_sms_poll&op=sms_poll_add_yes\" method=\"post\">\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t<tr>\n\t\t\t\t<td class=label-sizer>" . _('SMS poll keyword') . "</td><td><input type=text size=10 maxlength=10 name=add_poll_keyword value=\"{$add_poll_keyword}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('SMS poll title') . "</td><td><input type=text maxlength=100 name=add_poll_title value=\"{$add_poll_title}\"></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('SMS poll access code') . "</td><td><input type=text maxlength=40 name=add_poll_access_code value=\"{$add_poll_access_code}\"> " . _hint(_('SMS poll access code used mainly by webservices')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Vote option') . "</td><td>" . _select('add_poll_option_vote', $option_vote) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Reply message on out of vote option') . "</td><td><textarea maxlength=160 name=\"add_poll_message_option\">{$add_poll_message_option}</textarea></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Reply message on valid vote') . "</td><td><textarea maxlength=160 name=\"add_poll_message_valid\">{$add_poll_message_valid}</textarea></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . _('Reply message on invalid vote') . "</td><td><textarea maxlength=160 name=\"add_poll_message_invalid\">{$add_poll_message_invalid}</textarea></td>\n\t\t\t</tr>\n\t\t\t" . $select_reply_smsc . "\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_poll&op=sms_poll_list');
     _p($content);
     break;
 case "sms_poll_add_yes":
     $add_poll_keyword = strtoupper($_POST['add_poll_keyword']);
     $add_poll_title = $_POST['add_poll_title'];
     $add_poll_access_code = $_POST['add_poll_access_code'];
     $add_poll_option_vote = (int) $_POST['add_poll_option_vote'];
     $add_poll_message_option = $_POST['add_poll_message_option'];
     $add_poll_message_valid = $_POST['add_poll_message_valid'];
     $add_poll_message_invalid = $_POST['add_poll_message_invalid'];
     if (auth_isadmin()) {
         $add_smsc = $_POST['add_smsc'];
     }
     if ($add_poll_title && $add_poll_keyword && $add_poll_message_valid && $add_poll_message_invalid) {
         if (keyword_isavail($add_poll_keyword)) {
             $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featurePoll (uid,poll_keyword,poll_title,poll_access_code,poll_option_vote,poll_message_option,poll_message_valid,poll_message_invalid,smsc)\n\t\t\t\t\tVALUES ('" . $user_config['uid'] . "','{$add_poll_keyword}','{$add_poll_title}','{$add_poll_access_code}','{$add_poll_option_vote}','{$add_poll_message_option}','{$add_poll_message_valid}','{$add_poll_message_invalid}','{$add_smsc}')";
             if ($new_poll_id = @dba_insert_id($db_query)) {
                 $_SESSION['dialog']['info'][] = _('SMS poll has been added') . " (" . _('keyword') . ": {$add_poll_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS poll') . " (" . _('keyword') . ": {$add_poll_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS poll already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_poll_keyword})";
         }
     } else {
         $_SESSION['dialog']['info'][] = _('You must fill all fields');
     }
     if ($new_poll_id) {
         header("Location: " . _u('index.php?app=main&inc=feature_sms_poll&op=sms_poll_edit&poll_id=' . $new_poll_id));
     } else {
コード例 #8
0
ファイル: sms_subscribe.php プロジェクト: 10corp/playSMS
 case "sms_subscribe_add_yes":
     $add_subscribe_keyword = strtoupper($_POST['add_subscribe_keyword']);
     $add_subscribe_msg = $_POST['add_subscribe_msg'];
     $add_unsubscribe_msg = $_POST['add_unsubscribe_msg'];
     $add_subscribe_param = strtoupper($_POST['add_subscribe_param']);
     $add_unsubscribe_param = strtoupper($_POST['add_unsubscribe_param']);
     $add_forward_param = strtoupper($_POST['add_forward_param'] ? $_POST['add_forward_param'] : 'BC');
     $add_unknown_format_msg = $_POST['add_unknown_format_msg'];
     $add_already_member_msg = $_POST['add_already_member_msg'];
     $add_expire_msg = $_POST['add_expire_msg'];
     $add_duration = (int) $_POST['add_duration'];
     if (auth_isadmin()) {
         $smsc = $_REQUEST['smsc'];
     }
     if ($add_subscribe_keyword && $add_subscribe_msg && $add_unsubscribe_msg && $add_forward_param && $add_unknown_format_msg && $add_already_member_msg) {
         if (keyword_isavail($add_subscribe_keyword)) {
             $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_featureSubscribe (uid,subscribe_keyword,subscribe_msg,unsubscribe_msg, subscribe_param, unsubscribe_param, forward_param, unknown_format_msg, already_member_msg,smsc,duration,expire_msg)\n\t\t\t\t\tVALUES ('" . $user_config['uid'] . "','{$add_subscribe_keyword}','{$add_subscribe_msg}','{$add_unsubscribe_msg}','{$add_subscribe_param}','{$add_unsubscribe_param}','{$add_forward_param}','{$add_unknown_format_msg}','{$add_already_member_msg}','{$smsc}','{$add_duration}','{$add_expire_msg}')";
             if ($new_uid = @dba_insert_id($db_query)) {
                 $_SESSION['dialog']['info'][] = _('SMS subscribe has been added') . " (" . _('keyword') . ": {$add_subscribe_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS subscribe') . " (" . _('keyword') . ": {$add_subscribe_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS subscribe already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_subscribe_keyword})";
         }
     } else {
         $_SESSION['dialog']['info'][] = _('You must fill all fields');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_subscribe&op=sms_subscribe_add'));
     exit;
     break;
コード例 #9
0
ファイル: sync.php プロジェクト: RobinKarlsen/playSMS
$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 (keyword_isavail == 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 (keyword_isavail($c_m)) {
            _log("forwarded to inbox uid:" . $c_uid . " message_id:" . $message_id, 3, "sms_sync sync");
            $message = "@" . user_uid2username($c_uid) . " " . $message;
        }
        // route it
        if ($recvsms_id = recvsms($sms_datetime, $sms_sender, $message, $sms_receiver)) {
            $items = array('uid' => $c_uid, 'message_id' => $message_id, 'recvsms_id' => $recvsms_id);
            dba_add($db_table, $items);
            _log("saved uid:" . $c_uid . " message_id:" . $message_id . " recvsms_id:" . $recvsms_id, 3, "sms_sync sync");
            $ret = array('payload' => array('success' => "true", 'error' => NULL));
            $ok = TRUE;
        } else {
            $error_string = "fail to save uid:" . $c_uid . " message_id:" . $message_id;
            _log($error_string, 3, "sms_sync sync");
        }
    } else {
コード例 #10
0
ファイル: fn.php プロジェクト: 10corp/playSMS
function inboxgroup_dataedit($rid, $keywords, $description, $exclusive)
{
    $db_query = "SELECT keywords FROM " . _DB_PREF_ . "_featureInboxgroup WHERE id='{$rid}'";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    $orig_keywords = explode(',', $db_row['keywords']);
    $exclusive = $exclusive ? 1 : 0;
    $keywords = str_replace(' ', '', $keywords);
    $keywords = trim(strtoupper($keywords));
    $keywords = explode(',', $keywords);
    $k = '';
    for ($i = 0; $i < count($keywords); $i++) {
        if (keyword_isavail($keywords[$i])) {
            $k .= $keywords[$i] . ',';
        } else {
            for ($j = 0; $j < count($orig_keywords); $j++) {
                if ($keywords[$i] == $orig_keywords[$j]) {
                    $k .= $keywords[$i] . ',';
                }
            }
        }
    }
    if ($keywords = substr($k, 0, -1)) {
        $db_query = "UPDATE " . _DB_PREF_ . "_featureInboxgroup SET c_timestamp='" . mktime() . "',keywords='{$keywords}',description='{$description}',exclusive='{$exclusive}' WHERE deleted='0' AND id='{$rid}'";
        $db_result = dba_affected_rows($db_query);
    } else {
        $db_result = true;
    }
    return $db_result;
}
コード例 #11
0
ファイル: sms_command.php プロジェクト: 10corp/playSMS
     if ($err = TRUE) {
         $content = _dialog();
     }
     $content .= "\n\t\t\t<h2>" . _('Manage command') . "</h2>\n\t\t\t<h3>" . _('Add SMS command') . "</h3>\n\t\t\t<form action=index.php?app=main&inc=feature_sms_command&op=sms_command_add_yes method=post>\n\t\t\t" . _CSRF_FORM_ . "\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=label-sizer>" . _('SMS command keyword') . "</td><td><input type=text size=10 maxlength=10 name=add_command_keyword value=\"{$add_command_keyword}\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('SMS command exec path') . "</td><td>" . $sms_command_bin . '/' . $user_config['uid'] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>" . _('Pass these parameter to command exec field') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>{SMSDATETIME} " . _('will be replaced by SMS incoming date/time') . "</li>\n\t\t\t\t\t\t\t<li>{SMSSENDER} " . _('will be replaced by sender number') . "</li>\n\t\t\t\t\t\t\t<li>{COMMANDKEYWORD} " . _('will be replaced by command keyword') . "</li>\n\t\t\t\t\t\t\t<li>{COMMANDPARAM} " . _('will be replaced by command parameter passed to server from SMS') . "</li>\n\t\t\t\t\t\t\t<li>{COMMANDRAW} " . _('will be replaced by SMS raw message') . "</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('SMS command exec') . "</td><td><input type=text maxlength=200 name=add_command_exec value=\"{$add_command_exec}\"></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . _('Make return as reply') . "</td><td><input type=checkbox name=add_command_return_as_reply></td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p><input type=submit class=button value=\"" . _('Save') . "\">\n\t\t\t</form>\n\t\t\t" . _back('index.php?app=main&inc=feature_sms_command&op=sms_command_list');
     _p($content);
     break;
 case "sms_command_add_yes":
     $add_command_return_as_reply = $_POST['add_command_return_as_reply'] == 'on' ? '1' : '0';
     $add_command_keyword = strtoupper($_POST['add_command_keyword']);
     $add_command_exec = $_POST['add_command_exec'];
     if ($add_command_keyword && $add_command_exec) {
         $add_command_exec = $add_command_exec;
         $add_command_exec = str_replace("/", "", $add_command_exec);
         $add_command_exec = str_replace("|", "", $add_command_exec);
         $add_command_exec = str_replace("\\", "", $add_command_exec);
         if (keyword_isavail($add_command_keyword)) {
             $db_query = "INSERT INTO " . _DB_PREF_ . "_featureCommand (uid,command_keyword,command_exec,command_return_as_reply) VALUES ('" . $user_config['uid'] . "','{$add_command_keyword}','{$add_command_exec}','{$add_command_return_as_reply}')";
             if ($new_uid = @dba_insert_id($db_query)) {
                 $c_dir = $sms_command_bin . "/" . $user_config['uid'];
                 @shell_exec("mkdir -p \"" . $c_dir . "\"");
                 $_SESSION['dialog']['info'][] = _('SMS command has been added') . " (" . _('keyword') . " {$add_command_keyword})";
             } else {
                 $_SESSION['dialog']['info'][] = _('Fail to add SMS command') . " (" . _('keyword') . ": {$add_command_keyword})";
             }
         } else {
             $_SESSION['dialog']['info'][] = _('SMS command already exists, reserved or use by other feature') . " (" . _('keyword') . ": {$add_command_keyword})";
         }
     } else {
         $_SESSION['dialog']['info'][] = _('You must fill all fields');
     }
     header("Location: " . _u('index.php?app=main&inc=feature_sms_command&op=sms_command_add'));
コード例 #12
0
ファイル: sync.php プロジェクト: 10corp/playSMS
$sms_sync_enable = $list['feature']['sms_sync']['enable'];
$message_id = trim($r['message_id']);
$sms_datetime = core_display_datetime(core_get_datetime());
$sms_sender = trim($r['from']);
$message = trim($r['message']);
$sms_receiver = trim($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 (keyword_isavail == TRUE)
        // then prefix the message with an @username so that it will be routed to $c_uid's inbox
        $m = explode(' ', $message);
        if (keyword_isavail($m[0])) {
            _log("forwarded to inbox uid:" . $c_uid . " message_id:" . $message_id, 3, "sms_sync sync");
            $message = "@" . user_uid2username($c_uid) . " " . $message;
        }
        // route it
        if ($recvsms_id = recvsms($sms_datetime, $sms_sender, $message, $sms_receiver)) {
            $items = array('uid' => $c_uid, 'message_id' => $message_id, 'recvsms_id' => $recvsms_id);
            dba_add($db_table, $items);
            _log("saved uid:" . $c_uid . " message_id:" . $message_id . " recvsms_id:" . $recvsms_id, 3, "sms_sync sync");
            $ret = array('payload' => array('success' => "true", 'error' => NULL));
            $ok = TRUE;
        } else {
            $error_string = "fail to save uid:" . $c_uid . " message_id:" . $message_id;
            _log($error_string, 3, "sms_sync sync");
        }
    } else {
コード例 #13
0
ファイル: fn_keyword.php プロジェクト: RobinKarlsen/playSMS
/**
 * Opposite of keyword_isavail()
 *
 * @param string $keyword
 *        Keyword
 * @param string $sms_receiver
 *        Receiver number
 * @return boolean TRUE if keyword already exists
 */
function keyword_isexists($keyword, $sms_receiver = '')
{
    return !keyword_isavail($keyword, $sms_receiver);
}