当前位置: 首页>>代码示例>>PHP>>正文


PHP core_detect_unicode函数代码示例

本文整理汇总了PHP中core_detect_unicode函数的典型用法代码示例。如果您正苦于以下问题:PHP core_detect_unicode函数的具体用法?PHP core_detect_unicode怎么用?PHP core_detect_unicode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了core_detect_unicode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: teltree_handle

function teltree_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $teltree_keyword, $teltree_param = '', $smsc = '', $raw_message = '')
{
    $ps = explode(" ", $raw_message, 2);
    $kk = strtoupper($ps[0]);
    $username = "admin";
    if ($teltree_keyword == 'DAFTAR') {
        $pecah = preg_split("/#/", $ps[1], null, PREG_SPLIT_NO_EMPTY);
        $data = array();
        $data['name'] = trim($pecah[0]);
        $data['username'] = trim($pecah[0]);
        $data['mobile'] = $sms_sender;
        $data['email'] = str_replace(' ', '', $data['name']) . "@noreply.org";
        $data['parent_uid'] = 1;
        //----- ini parentnya admin
        $data['status'] = 4;
        //---ini artinya ditambahkan ke sub user
        $ret = user_add($data);
        $ok = $ret['status'] ? TRUE : FALSE;
        if ($ok) {
            echo "okee";
            $items = array('uid' => 1, 'name' => $data['name'], 'mobile' => $data['mobile'], 'email' => $data['email'], 'tags' => $tags);
            if ($c_pid = dba_add(_DB_PREF_ . '_featurePhonebook', $items)) {
                $save_to_group = TRUE;
                _log('Success to add contact pid:' . $c_pid . ' m:' . $data['mobile'] . ' n:' . $data['name'] . ' e:' . $data['email'] . ' tags:[' . $data['tags'] . ']', 2, 'teltree');
            } else {
                _log('Fail to add contact pid:' . $c_pid . ' m:' . $data['mobile'] . ' n:' . $data['name'] . ' e:' . $data['email'] . ' tags:[' . $data['tags'] . ']', 2, 'teltree');
            }
            $balasan = "Selamat anda telah terdaftar di Telephone Tree";
            $gagal = "Maaf Sistem sedang mengalami gangguan, silahkan coba beberapa saat lagi";
            if ($save_to_group) {
                $unicode = core_detect_unicode($balasan);
                $balasan = addslashes($balasan);
                // $username = "admin";
                //$smsc = "dev";
                _log("returns:" . $balasan, 2, "teltree");
                sendsms_helper($username, $sms_sender, $balasan, 'text', $unicode, $smsc);
            } else {
                $unicode = core_detect_unicode($gagal);
                $balasan = addslashes($gagal);
                _log("returns:" . $gagal, 2, "teltree");
                sendsms_helper($username, $sms_sender, $balasan, 'text', $unicode, $smsc);
                _log_print("returns empty", 2, "teltree");
            }
        } else {
            echo "gagal";
        }
        return $ret;
        //$ok = true;
    } elseif ($kk == 'GABUNG') {
        /*$gpids = dba_search(_DB_PREF_ . '_featurePhonebook_group','code',array(
        			
        		));*/
        $uid = user_mobile2uid($sms_sender);
        $group_code = strtoupper($ps[1]);
        $list = dba_search(_DB_PREF_ . '_featurePhonebook', 'id', array('uid' => 1, 'mobile' => $sms_sender));
        if ($group_code && $sms_sender) {
            /*--dummy code--*/
            $c_pid = dba_search(_DB_PREF_ . '_featurePhonebook', 'id', array('uid' => 1, 'mobile' => $sms_sender));
            $gpids = dba_search(_DB_PREF_ . '_featurePhonebook_group', 'id', array('uid' => 1, 'code' => $group_code));
            foreach ($gpids as $gpid) {
                foreach ($gpid as $key => $val) {
                    $items = array('gpid' => $val, 'pid' => $c_pid[0]['id']);
                    if (dba_isavail(_DB_PREF_ . '_featurePhonebook_group_contacts', $items, 'AND')) {
                        if (dba_add(_DB_PREF_ . '_featurePhonebook_group_contacts', $items)) {
                            $list = dba_search(_DB_PREF_ . '_featurePhonebook_group', 'code', array('uid' => 1));
                            _log('contact added to group gpid:' . $gpid . ' pid:' . $c_pid . ' m:' . $mobile . ' n:' . $name . ' e:' . $email, 2, 'phonebook_edit');
                            if ($iid = $c_pid[0]['id']) {
                                $bal_grup = "selamat anda telah tergabung di grup" . $list[$iid]['code'];
                                $unicode = core_detect_unicode($bal_grup);
                                $bal_grup = addslashes($bal_grup);
                                _log("returns:" . $bal_grup, 2, "telek");
                                sendsms_helper($username, $sms_sender, $bal_grup, 'text', $unicode, $smsc);
                                _log("returns empty", 2, "sms custom");
                            }
                        } else {
                            _log('contact edited but fail to save in group gpid:' . $gpid . ' pid:' . $c_pid . ' m:' . $mobile . ' n:' . $name . ' e:' . $email, 2, 'phonebook_edit');
                        }
                    }
                }
            }
        }
        //$ok = true;
    } elseif ($kk == 'KELUAR') {
        $uid = user_mobile2uid($sms_sender);
        $group_code = strtoupper($ps[1]);
        //_log($sms_sender . ' '. $group_code, 2 , 'test');
        if ($group_code && $sms_sender) {
            //		_log($sms_sender . ' '. $group_code, 2 , 'test');
            $c_pid = dba_search(_DB_PREF_ . '_featurePhonebook', 'id', array('uid' => 1, 'mobile' => $sms_sender));
            $gpids = dba_search(_DB_PREF_ . '_featurePhonebook_group', 'id', array('uid' => 1, 'code' => $group_code));
            foreach ($gpids as $gpid) {
                foreach ($gpid as $key => $val) {
                    $items = array('gpid' => $val, 'pid' => $c_pid[0]['id']);
                    //				_log($sms_sender . ' '. $group_code, 2 , 'test');
                    if (!dba_isavail(_DB_PREF_ . '_featurePhonebook_group_contacts', $items, 'AND')) {
                        if (dba_remove(_DB_PREF_ . '_featurePhonebook_group_contacts', $items)) {
                            if ($iid = $c_pid[0]['id']) {
                                $bal_grup = "anda telah keluar dari grup" . $list[$iid]['code'];
                                $unicode = core_detect_unicode($bal_grup);
                                $bal_grup = addslashes($bal_grup);
//.........这里部分代码省略.........
开发者ID:pr4ka5a,项目名称:telek,代码行数:101,代码来源:fn.php

示例2: sms_survey_hook_playsmsd

function sms_survey_hook_playsmsd()
{
    global $core_config;
    // get enabled and started survey, but not running yet
    $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSurvey WHERE deleted='0' AND status='1' AND started='1' AND running='0'";
    $db_result = dba_query($db_query);
    while ($db_row = dba_fetch_array($db_result)) {
        $c_sid = $db_row['id'];
        // set survey as running survey
        $session = md5($c_sid . mktime());
        $db_query1 = "UPDATE " . _DB_PREF_ . "_featureSurvey SET session='{$session}',running='1' WHERE id='{$c_sid}'";
        if ($db_result1 = dba_affected_rows($db_query1)) {
            // get current survey data
            $s = sms_survey_getdatabyid($c_sid);
            $c_uid = $s['uid'];
            $c_username = uid2username($c_uid);
            $c_keyword = $s['keyword'];
            // get current survey questions, focus only on first question, index 0
            $q = sms_survey_getquestions($c_sid);
            $c_message = $q[0]['question'];
            $c_sms_msg = $c_keyword . " " . $c_message;
            // get current survey members
            $m = sms_survey_getmembers($c_sid);
            for ($i = 0; $i < count($m); $i++) {
                // if member's mobile exists
                if ($c_sms_to = $m[$i]['mobile']) {
                    logger_print("playsmsd send start qn:1 sid:" . $c_sid . " username:" . $c_username . " to:" . $c_sms_to . " msg:" . $c_sms_msg, 3, "sms_survey");
                    // if member's mobile, question and username owned the survey exists
                    if ($c_sms_to && $c_sms_msg && $c_username) {
                        $type = 'text';
                        // $unicode = '0';
                        // send message to member
                        // list($ok,$to,$smslog_id,$queue) = sendsms($c_username,$c_sms_to,$c_sms_msg,$type,$unicode);
                        $unicode = core_detect_unicode($message);
                        list($ok, $to, $smslog_id, $queue) = sendsms($c_username, $c_sms_to, $c_sms_msg, 'text', $unicode);
                        $ok[0] = $ok[0] ? "true" : "false";
                        logger_print("playsmsd send finish sid:" . $c_sid . " smslog_id:" . $smslog_id[0] . " ok:" . $ok[0], 2, "sms_survey");
                        // save the log
                        $log = "";
                        $log['survey_id'] = $c_sid;
                        $log['question_id'] = $q[0]['id'];
                        $log['member_id'] = $m[$i]['id'];
                        $log['link_id'] = sms_survey_getlinkid($session, $c_sid, $m[$i]['id']);
                        $log['smslog_id'] = $smslog_id[0];
                        $log['name'] = $m[$i]['name'];
                        $log['mobile'] = $m[$i]['mobile'];
                        $log['question'] = $q[0]['question'];
                        $log['question_number'] = 1;
                        $log['creation_datetime'] = $core_config['datetime']['now'];
                        $log['session'] = $session;
                        sms_survey_savelog($log);
                    }
                }
            }
        }
        // set survey as completed
        $db_query2 = "UPDATE " . _DB_PREF_ . "_featureSurvey SET status='1',started='0',running='2' WHERE id='{$c_sid}'";
        $db_result2 = dba_affected_rows($db_query2);
    }
}
开发者ID:erdincay,项目名称:playSMS-extra-plugin,代码行数:60,代码来源:fn.php

示例3: sms_quiz_handle

function sms_quiz_handle($list, $sms_datetime, $sms_sender, $quiz_keyword, $quiz_param = '', $sms_receiver = '', $smsc = '', $raw_message = '')
{
    global $core_config;
    $ok = false;
    $sms_to = $sms_sender;
    // we are replying to this sender
    $quiz_keyword = strtoupper(trim($quiz_keyword));
    $quiz_param = strtoupper(trim($quiz_param));
    if (($quiz_enable = $list['quiz_enable']) && $quiz_param) {
        if (strtoupper($list['quiz_answer']) == $quiz_param) {
            $message = $list['quiz_msg_correct'];
        } else {
            $message = $list['quiz_msg_incorrect'];
        }
        $quiz_id = $list['quiz_id'];
        $answer = strtoupper($quiz_param);
        $db_query = "INSERT INTO " . _DB_PREF_ . "_featureQuiz_log (quiz_id,quiz_answer,quiz_sender,in_datetime) VALUES ('{$quiz_id}','{$answer}','{$sms_to}','" . core_get_datetime() . "')";
        if ($logged = @dba_insert_id($db_query)) {
            if ($message && ($username = user_uid2username($list['uid']))) {
                $unicode = core_detect_unicode($message);
                $message = addslashes($message);
                list($ok, $to, $smslog_id, $queue) = sendsms_helper($username, $sms_to, $message, 'text', $unicode, $smsc);
            }
            $ok = true;
        }
    }
    return $ok;
}
开发者ID:10corp,项目名称:playSMS,代码行数:28,代码来源:fn.php

示例4: xlate_hook_recvsms_intercept

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;
}
开发者ID:yrahman,项目名称:playSMS,代码行数:56,代码来源:fn.php

示例5: myauto_hook_interceptincomingsms

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");
}
开发者ID:erdincay,项目名称:playSMS-extra-plugin,代码行数:13,代码来源:fn.php

示例6: autorespond_hook_recvsms_intercept_after

function autorespond_hook_recvsms_intercept_after($sms_datetime, $sms_sender, $message, $sms_receiver, $feature, $status, $uid, $smsc)
{
    $ret = array();
    $hooked = FALSE;
    // process only when the previous feature is not 'incoming'
    if ($feature != 'incoming' && $status) {
        return $ret;
    }
    if ($message) {
        $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureAutorespond WHERE flag_deleted='0'";
        $db_result = dba_query($db_query);
        while ($db_row = dba_fetch_array($db_result)) {
            $continue = TRUE;
            // only check sms receiver if set
            if ($db_row['sms_receiver']) {
                if ($sms_receiver != $db_row['sms_receiver']) {
                    $continue = FALSE;
                }
            }
            if ($continue) {
                // match SMS with regex
                if (preg_match($db_row['regex'], $message)) {
                    // match found, send respond
                    $c_uid = $db_row['uid'];
                    $c_username = user_uid2username($c_uid);
                    $c_message = $db_row['message'];
                    if (core_detect_unicode($c_message)) {
                        $unicode = 1;
                    }
                    $smsc = gateway_decide_smsc($smsc, $db_row['smsc']);
                    _log("match found dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " uid:" . $c_uid . " username:" . $c_username . " service:[" . $db_row['service_name'] . "] regex:[" . $db_row['regex'] . "] m:[" . $message . "] smsc:" . $smsc, 3, "autorespond");
                    sendsms_helper($c_username, $sms_sender, $c_message, 'text', $unicode, $smsc);
                    // log it
                    $hooked = TRUE;
                    // found then stop
                    break;
                }
            }
        }
    }
    if ($c_uid && $hooked) {
        _log("hooked dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " uid:" . $c_uid . " username:" . $c_username . " service:[" . $db_row['service_name'] . "] regex:[" . $db_row['regex'] . "] m:[" . $message . "] smsc:" . $smsc, 3, "autorespond");
        $ret['modified'] = TRUE;
        $ret['param']['feature'] = 'autorespond';
        $ret['param']['status'] = 1;
        $ret['uid'] = $c_uid;
        $ret['hooked'] = $hooked;
    }
    return $ret;
}
开发者ID:christophercaburog,项目名称:plugin-autorespond,代码行数:50,代码来源:fn.php

示例7: sms_autosend_hook_playsmsd

function sms_autosend_hook_playsmsd()
{
    global $core_config;
    $timenow = mktime();
    $db_query = "SELECT uid,time_id," . _DB_PREF_ . "_featureAutosend.autosend_id, autosend_message,autosend_number,autosend_time\n\t\t\t\t\t\t\tFROM " . _DB_PREF_ . "_featureAutosend\n\t\t\t\t\t\t\tINNER JOIN " . _DB_PREF_ . "_featureAutosend_time\n\t\t\t\t\t\t\tON " . _DB_PREF_ . "_featureAutosend.autosend_id =  " . _DB_PREF_ . "_featureAutosend_time.autosend_id\n\t\t\t\t\t\t\tWHERE UNIX_TIMESTAMP(" . _DB_PREF_ . "_featureAutosend_time.autosend_time) <= '{$timenow}'\n\t\t\t\t\t\t\tAND " . _DB_PREF_ . "_featureAutosend_time.sent='0'\n\t\t\t\t\t\t\tAND autosend_time != ''\n\t\t\t\t\t\t\tAND " . _DB_PREF_ . "_featureAutosend.autosend_enable='1'";
    $db_result = dba_query($db_query);
    while ($db_row = dba_fetch_array($db_result)) {
        $message = $db_row['autosend_message'];
        $c_uid = $db_row['uid'];
        $username = uid2username($c_uid);
        $sms_to = $db_row['autosend_number'];
        // we are sending to this number
        $autosend_id = $db_row['autosend_id'];
        $time_id = $db_row['time_id'];
        $unicode = core_detect_unicode($message);
        list($ok, $to, $smslog_id, $queue) = sendsms($username, $sms_to, $message, 'text', $unicode);
        if ($ok[0]) {
            $db_query = "UPDATE " . _DB_PREF_ . "_featureAutosend_time SET sent='1' WHERE time_id = '{$time_id}'";
            $db_result = @dba_affected_rows($db_query);
        }
    }
}
开发者ID:erdincay,项目名称:playSMS-extra-plugin,代码行数:22,代码来源:fn.php

示例8: sms_custom_handle

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;
}
开发者ID:yrahman,项目名称:playSMS,代码行数:38,代码来源:fn.php

示例9: sms_command_handle

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;
}
开发者ID:yrahman,项目名称:playSMS,代码行数:37,代码来源:fn.php

示例10: recvsms_inbox_add

function recvsms_inbox_add($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver = "", $reference_id = '')
{
    global $core_config;
    // sms to inbox will be handled by plugins first
    $ret_intercept = recvsms_inbox_add_intercept($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver, $reference_id);
    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;
        $reference_id = $ret_intercept['param']['reference_id'] ? $ret_intercept['param']['reference_id'] : $reference_id;
    }
    $ok = FALSE;
    if ($sms_sender && $target_user && $message) {
        $user = user_getdatabyusername($target_user);
        if ($uid = $user['uid']) {
            // discard if banned
            if (user_banned_get($uid)) {
                logger_print("user banned, message ignored uid:" . $uid, 2, "recvsms_inbox_add");
                return FALSE;
            }
            // get name from target_user's phonebook
            $c_name = '';
            if (substr($sms_sender, 0, 1) == '@') {
                $c_username = str_replace('@', '', $sms_sender);
                $c_name = user_getfieldbyusername($c_username, 'name');
            } else {
                $c_name = phonebook_number2name($uid, $sms_sender);
            }
            $sender = $c_name ? $c_name . ' (' . $sms_sender . ')' : $sms_sender;
            // forward to Inbox
            if ($fwd_to_inbox = $user['fwd_to_inbox']) {
                $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_tblSMSInbox\n\t\t\t\t\t(in_sender,in_receiver,in_uid,in_msg,in_datetime,reference_id)\n\t\t\t\t\tVALUES ('{$sms_sender}','{$sms_receiver}','{$uid}','{$message}','" . core_adjust_datetime($sms_datetime) . "','{$reference_id}')\n\t\t\t\t";
                logger_print("saving sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user . " reference_id:" . $reference_id, 2, "recvsms_inbox_add");
                if ($inbox_id = @dba_insert_id($db_query)) {
                    logger_print("saved id:" . $inbox_id . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user, 2, "recvsms_inbox_add");
                    $ok = TRUE;
                }
            }
            // forward to email, consider site config too
            if ($parent_uid = user_getparentbyuid($uid)) {
                $site_config = site_config_get($parent_uid);
            }
            $web_title = $site_config['web_title'] ? $site_config['web_title'] : $core_config['main']['web_title'];
            $email_service = $site_config['email_service'] ? $site_config['email_service'] : $core_config['main']['email_service'];
            $email_footer = $site_config['email_footer'] ? $site_config['email_footer'] : $core_config['main']['email_footer'];
            $sms_receiver = $sms_receiver ? $sms_receiver : '-';
            if ($fwd_to_email = $user['fwd_to_email']) {
                if ($email = $user['email']) {
                    $subject = _('Message from') . " " . $sender;
                    $body = $web_title . "\n\n";
                    $body .= _('Message received at') . " " . $sms_receiver . " " . _('on') . " " . $sms_datetime . "\n\n";
                    $body .= _('From') . " " . $sender . "\n\n";
                    $body .= $message . "\n\n--\n";
                    $body .= $email_footer . "\n\n";
                    $body = stripslashes($body);
                    logger_print("send email from:" . $email_service . " to:" . $email . " message:[" . $message . "]", 3, "recvsms_inbox_add");
                    $data = array('mail_from_name' => $web_title, 'mail_from' => $email_service, 'mail_to' => $email, 'mail_subject' => $subject, 'mail_body' => $body);
                    sendmail($data);
                    logger_print("sent email from:" . $email_service . " to:" . $email, 3, "recvsms_inbox_add");
                }
            }
            // forward to mobile
            if ($fwd_to_mobile = $user['fwd_to_mobile']) {
                if ($mobile = $user['mobile']) {
                    // fixme anton
                    $c_message = $message . ' ' . $sender;
                    if ($sender_uid = user_mobile2uid($sms_sender)) {
                        if ($sender_username = user_uid2username($sender_uid)) {
                            $c_message = $message . ' ' . '@' . $sender_username;
                        }
                    }
                    $message = $c_message;
                    $unicode = core_detect_unicode($message);
                    $nofooter = TRUE;
                    logger_print("send to mobile:" . $mobile . " from:" . $sms_sender . " user:" . $target_user . " message:" . $message, 3, "recvsms_inbox_add");
                    list($ok, $to, $smslog_id, $queue) = sendsms($target_user, $mobile, $message, 'text', $unicode, '', $nofooter);
                    if ($ok[0] == 1) {
                        logger_print("sent to mobile:" . $mobile . " from:" . $sms_sender . " user:" . $target_user, 2, "recvsms_inbox_add");
                    }
                }
            }
        }
    }
    return $ok;
}
开发者ID:10corp,项目名称:playSMS,代码行数:87,代码来源:fn.php

示例11: core_smslen

/**
 * SMS strlen() based on unicode status
 *
 * @param string $text        
 * @param string $encoding        
 * @return integer Length of text
 */
function core_smslen($text, $encoding = "")
{
    if (function_exists('mb_strlen') && core_detect_unicode($text)) {
        if ($encoding = trim($encoding)) {
            $len = mb_strlen($text, $encoding);
        } else {
            $len = mb_strlen($text, "UTF-8");
        }
    } else {
        if (core_detect_unicode($text)) {
            $len = strlen(utf8_decode($text));
        } else {
            $len = strlen($text);
        }
    }
    return (int) $len;
}
开发者ID:RobinKarlsen,项目名称:playSMS,代码行数:24,代码来源:fn_core.php

示例12: dba_query

 $db_query = "SELECT msg 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);
 $message = addslashes($db_row['msg']);
 $counter = $db_row['counter'];
 $db_query = "SELECT member_number FROM " . _DB_PREF_ . "_featureSubscribe_member WHERE subscribe_id='{$subscribe_id}'";
 $db_result = dba_query($db_query);
 $sms_to = '';
 if ($message && $subscribe_id) {
     while ($db_row = dba_fetch_array($db_result)) {
         if ($member_number = $db_row['member_number']) {
             $sms_to[] = $member_number;
         }
     }
     if ($sms_to[0]) {
         $unicode = core_detect_unicode($message);
         $message = addslashes($message);
         list($ok, $to, $smslog_id, $queue) = sendsms_helper($username, $sms_to, $message, 'text', $unicode, $smsc);
         if ($ok[0]) {
             $counter++;
             dba_update(_DB_PREF_ . '_featureSubscribe_msg', array('counter' => $counter), array('subscribe_id' => $subscribe_id, 'msg_id' => $msg_id));
             $_SESSION['error_string'] .= _('Your SMS has been delivered to queue') . "<br>";
         } else {
             $_SESSION['error_string'] .= _('Fail to send SMS') . "<br>";
         }
     } else {
         $_SESSION['error_string'] = _('You have no member');
     }
 } else {
     $_SESSION['error_string'] = _('You must fill all fields');
 }
开发者ID:yrahman,项目名称:playSMS,代码行数:31,代码来源:sms_subscribe.php

示例13: playnet_hook_playsmsd

function playnet_hook_playsmsd()
{
    global $core_config, $plugin_config;
    if (!core_playsmsd_timer($plugin_config['playnet']['poll_interval'])) {
        return;
    }
    $smscs = gateway_getall_smsc_names('playnet');
    foreach ($smscs as $smsc) {
        $c_plugin_config = gateway_apply_smsc_config($smsc, $plugin_config);
        $is_master = (bool) ($c_plugin_config['playnet']['local_playnet_username'] && $c_plugin_config['playnet']['local_playnet_password']);
        if ((int) $c_plugin_config['playnet']['remote_on'] && !$is_master) {
            // fetch from remote
            $ws = $c_plugin_config['playnet']['remote_playsms_url'] . '/index.php?app=ws&op=playnet';
            $ws .= '&go=get_outgoing';
            $ws .= '&s=' . $c_plugin_config['playnet']['remote_playnet_smsc'];
            $ws .= '&u=' . $c_plugin_config['playnet']['remote_playnet_username'];
            $ws .= '&p=' . $c_plugin_config['playnet']['remote_playnet_password'];
            $response_raw = @file_get_contents($ws);
            $response = json_decode($response_raw, 1);
            // validate response
            if (strtoupper($response['status']) == 'OK') {
                if (is_array($response['data'])) {
                    foreach ($response['data'] as $data) {
                        $remote_smsc = $data['smsc'];
                        $remote_smslog_id = $data['smslog_id'];
                        $remote_uid = $data['uid'];
                        $username = $c_plugin_config['playnet']['sendsms_username'];
                        $sms_to = $data['sms_to'];
                        $message = $data['message'];
                        $unicode = core_detect_unicode($message);
                        $sms_type = $data['sms_type'];
                        $sms_sender = $data['sender_id'];
                        _log('sendsms remote_smsc:' . $remote_smsc . ' remote_smslog_id:' . $remote_smslog_id . ' remote_uid:' . $remote_uid . ' u:' . $username . ' sender_id:' . $sms_sender . ' to:' . $sms_to . ' m:[' . $message . '] unicode:' . $unicode, 3, 'playnet_hook_playsmsd');
                        sendsms_helper($username, $sms_to, $message, $sms_type, $unicode, '', 1, '', $sms_sender);
                    }
                }
            }
        }
    }
}
开发者ID:playsms,项目名称:plugin-playnet,代码行数:40,代码来源:fn.php

示例14: gammu_hook_getsmsinbox

function gammu_hook_getsmsinbox()
{
    // filename
    // IN20101017_091747_00_+628123423141312345_00.txt
    global $plugin_config;
    $handle = @opendir($plugin_config['gammu']['path'] . "/inbox");
    $messages = array();
    $files = array();
    while ($sms_in_file = @readdir($handle)) {
        if ($sms_in_file != "." && $sms_in_file != "..") {
            $files[] = $sms_in_file;
        }
    }
    sort($files);
    foreach ($files as $sms_in_file) {
        $fn = $plugin_config['gammu']['path'] . "/inbox/{$sms_in_file}";
        $matches = array();
        preg_match('/IN(\\d{4})(\\d{2})(\\d{2})_(\\d{2})(\\d{2})(\\d{2})_(\\d+)_([+]*\\w+)_(\\d+)/', basename($fn), $matches);
        list($s, $year, $month, $date, $hour, $minute, $second, $serial, $sms_sender, $seq) = $matches;
        $sms_datetime = $year . "-" . $month . "-" . $date . " " . $hour . ":" . $minute . ":" . $second;
        // message is in UTF-16, need to convert it to UTF-8
        $message = file_get_contents($fn);
        // if the message is unicode then convert it to UTF-8
        if (core_detect_unicode($message)) {
            $message = mb_convert_encoding($message, "UTF-8", "UTF-16");
        }
        @unlink($fn);
        // continue process only when incoming sms file can be deleted
        if (!file_exists($fn)) {
            if ($sms_sender && $sms_datetime) {
                // adding message parts to existing array
                if (array_key_exists($sms_sender, $messages) && (int) $seq > 0) {
                    $messages[$sms_sender][] = array("fn" => $fn, "message" => $message, "msg_datetime" => $sms_datetime);
                } else {
                    if (!array_key_exists($sms_sender, $messages) || array_key_exists($sms_sender, $messages) && (int) $seq == 0) {
                        if (count($messages) > 0) {
                            // saving concatenated message parts
                            $parts_sender = 0;
                            foreach ($messages as $sender => $message_parts) {
                                $parts_message = "";
                                $parts_sender = $sender;
                                foreach ($message_parts as $part) {
                                    $parts_message .= $part['message'];
                                }
                            }
                            $parts_datetime = $messages[$parts_sender][0]['msg_datetime'];
                            recvsms($parts_datetime, $parts_sender, $parts_message, $sms_receiver, 'gammu');
                            logger_print("sender:" . $parts_sender . " receiver:" . $sms_receiver . " dt:" . $parts_datetime . " msg:" . $parts_message, 3, "gammu incoming");
                            unset($messages);
                        }
                        // new message parts array
                        $messages[$sms_sender] = array(array("fn" => $fn, "message" => $message, "msg_datetime" => $sms_datetime));
                    }
                }
            }
        }
    }
    if (count($messages) > 0) {
        // saving last concatenated message parts
        $parts_sender = 0;
        foreach ($messages as $sender => $message_parts) {
            $parts_message = "";
            $parts_sender = $sender;
            foreach ($message_parts as $part) {
                $parts_message .= $part['message'];
            }
        }
        $parts_datetime = $messages[$parts_sender][0]['msg_datetime'];
        recvsms($parts_datetime, $parts_sender, $parts_message, $sms_receiver, $smsc);
        logger_print("sender:" . $parts_sender . " receiver:" . $sms_receiver . " dt:" . $parts_datetime . " msg:" . $_parts_message, 3, "gammu incoming");
        unset($messages);
    }
    @closedir($handle);
}
开发者ID:yrahman,项目名称:playSMS,代码行数:74,代码来源:fn.php

示例15: sms_autoreply_handle

function sms_autoreply_handle($c_uid, $sms_datetime, $sms_sender, $sms_receiver, $autoreply_id, $autoreply_keyword, $autoreply_param = '', $smsc = '', $raw_message = '')
{
    $ok = false;
    $autoreply_keyword = strtoupper(trim($autoreply_keyword));
    $autoreply_param = strtoupper(trim($autoreply_param));
    $autoreply_request = $autoreply_keyword . " " . $autoreply_param;
    $array_autoreply_request = preg_split('/[\\s]+/', $autoreply_request);
    for ($i = 0; $i < count($array_autoreply_request); $i++) {
        $autoreply_part[$i] = trim($array_autoreply_request[$i]);
        $tmp_autoreply_request .= trim($array_autoreply_request[$i]) . " ";
    }
    $autoreply_request = trim($tmp_autoreply_request);
    for ($i = 1; $i < 7; $i++) {
        $autoreply_scenario_param_list .= "autoreply_scenario_param{$i}='" . $autoreply_part[$i] . "' AND ";
    }
    $db_query = "\n\t\tSELECT autoreply_scenario_result FROM " . _DB_PREF_ . "_featureAutoreply_scenario \n\t\tWHERE autoreply_id='{$autoreply_id}' AND {$autoreply_scenario_param_list} 1=1";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    if ($autoreply_scenario_result = $db_row['autoreply_scenario_result']) {
        $ok = false;
        $c_username = user_uid2username($c_uid);
        $unicode = core_detect_unicode($autoreply_scenario_result);
        $autoreply_scenario_result = addslashes($autoreply_scenario_result);
        list($ok, $to, $smslog_id, $queue) = sendsms_helper($c_username, $sms_sender, $autoreply_scenario_result, 'text', $unicode, $smsc);
        $ok = $ok[0];
    }
    return $ok;
}
开发者ID:RobinKarlsen,项目名称:playSMS,代码行数:28,代码来源:fn.php


注:本文中的core_detect_unicode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。