Beispiel #1
0
function gnokii_hook_getsmsinbox()
{
    global $gnokii_param;
    $handle = @opendir($gnokii_param['path']);
    while ($sms_in_file = @readdir($handle)) {
        if (eregi("^ERR.in", $sms_in_file) && !eregi("^[.]", $sms_in_file)) {
            $fn = $gnokii_param['path'] . "/{$sms_in_file}";
            logger_print("infile:" . $fn, 3, "gnokii incoming");
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = trim($lines[0]);
            $sms_sender = trim($lines[1]);
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            @unlink($tobe_deleted);
            // continue process only when incoming sms file can be deleted
            if (!file_exists($tobe_deleted)) {
                // collected:
                // $sms_datetime, $sms_sender, $message, $sms_receiver
                setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver);
                logger_print("sender:" . $sms_sender . " receiver:" . $sms_receiver . " dt:" . $sms_datetime . " msg:" . $message, 3, "gnokii incoming");
            }
        }
    }
}
Beispiel #2
0
function gw_set_incoming_action()
{
    global $kannel_param;
    $handle = @opendir($kannel_param['path'] . "/cache/smsd");
    while ($sms_in_file = @readdir($handle)) {
        if (preg_match("/^ERR.in/i", $sms_in_file) && !preg_match("/^[.]/", $sms_in_file)) {
            $fn = $kannel_param['path'] . "/cache/smsd/{$sms_in_file}";
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = urldecode(trim($lines[0]));
            $sms_sender = urldecode(trim($lines[1]));
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            $array_target_code = explode(" ", urldecode($message));
            $target_code = strtoupper(trim($array_target_code[0]));
            $message = $array_target_code[1];
            for ($i = 2; $i < count($array_target_code); $i++) {
                $message .= " " . $array_target_code[$i];
            }
            // collected:
            // $sms_datetime, $sms_sender, $target_code, $message
            if (setsmsincomingaction($sms_datetime, $sms_sender, $target_code, $message)) {
                @unlink($tobe_deleted);
            }
        }
    }
}
Beispiel #3
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");
                setsmsincomingaction(core_display_datetime($sms_datetime), $sms_sender, $message, $sms_receiver, $smsc);
            }
        }
    }
}
Beispiel #4
0
function smstools_hook_getsmsinbox()
{
    global $smstools_param;
    $handle = @opendir($smstools_param['path'] . "/incoming");
    while ($sms_in_file = @readdir($handle)) {
        $fn = $smstools_param['path'] . "/incoming/{$sms_in_file}";
        logger_print("infile:" . $fn, 3, "smstools incoming");
        $tobe_deleted = $fn;
        $lines = @file($fn);
        $start = 0;
        for ($c = 0; $c < count($lines); $c++) {
            $c_line = $lines[$c];
            if (ereg('^From: ', $c_line)) {
                $sms_sender = '+' . trim(str_replace('From: ', '', trim($c_line)));
            } else {
                if (ereg('^Received: ', $c_line)) {
                    $sms_datetime = '20' . trim(str_replace('Received: ', '', trim($c_line)));
                } else {
                    if ($c_line == "\n") {
                        $start = $c + 1;
                        break;
                    }
                }
            }
        }
        @unlink($tobe_deleted);
        // continue process only when incoming sms file can be deleted
        if (!file_exists($tobe_deleted)) {
            if ($sms_sender && $sms_datetime && $start) {
                $message = "";
                for ($lc = $start; $lc < count($lines); $lc++) {
                    $message .= trim($lines[$lc]);
                }
                // collected:
                // $sms_datetime, $sms_sender, $message, $sms_receiver
                setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver);
            }
            logger_print("sender:" . $sms_sender . " receiver:" . $sms_receiver . " dt:" . $sms_datetime . " msg:" . $message, 3, "smstools incoming");
        }
    }
}
Beispiel #5
0
function gw_set_incoming_action()
{
    global $gnokii_param;
    $handle = @opendir("{$gnokii_param['path']}/cache/smsd");
    while ($sms_in_file = @readdir($handle)) {
        if (eregi("^ERR.in", $sms_in_file) && !eregi("^[.]", $sms_in_file)) {
            $fn = "{$gnokii_param['path']}/cache/smsd/{$sms_in_file}";
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = trim($lines[0]);
            $sms_sender = trim($lines[1]);
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            // collected:
            // $sms_datetime, $sms_sender, $target_code, $message
            if (setsmsincomingaction($sms_datetime, $sms_sender, $message)) {
                @unlink($tobe_deleted);
            }
        }
    }
}
Beispiel #6
0
$cb_charge = $_REQUEST['charge'];
$cb_apimsgid = $_REQUEST['apiMsgId'];
$cb_smsc = $_REQUEST['smsc'];
/*
 * $fc = "from: $cb_from - to: $cb_to - timestamp: $cb_timestamp - text: $cb_text - status: $cb_status - charge: $cb_charge - apimsgid: $cb_apimsgid\n"; $fn = "/tmp/infobip_callback"; umask(0); $fd = fopen($fn,"a+"); fputs($fd,$fc); fclose($fd); die();
 */
if ($cb_timestamp && $cb_from && $cb_text) {
    $cb_datetime = date($datetime_format, $cb_timestamp);
    $sms_datetime = trim($cb_datetime);
    $sms_sender = trim($cb_from);
    $message = trim($cb_text);
    $sms_receiver = trim($cb_to);
    logger_print("sender:" . $sms_sender . " receiver:" . $sms_receiver . " dt:" . $sms_datetime . " msg:" . $message, 3, "infobip incoming");
    // collected:
    // $sms_datetime, $sms_sender, $message, $sms_receiver
    setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver, $cb_smsc);
}
if ($cb_status && $cb_apimsgid) {
    $db_query = "\n\tSELECT " . _DB_PREF_ . "_tblSMSOutgoing.smslog_id AS smslog_id," . _DB_PREF_ . "_tblSMSOutgoing.uid AS uid \n\tFROM " . _DB_PREF_ . "_tblSMSOutgoing," . _DB_PREF_ . "_gatewayInfobip_apidata\n\tWHERE \n\t    " . _DB_PREF_ . "_tblSMSOutgoing.smslog_id=" . _DB_PREF_ . "_gatewayInfobip_apidata.smslog_id AND \n\t    " . _DB_PREF_ . "_gatewayInfobip_apidata.apimsgid='{$cb_apimsgid}'\n    ";
    $db_result = dba_query($db_query);
    $db_row = dba_fetch_array($db_result);
    $uid = $db_row['uid'];
    $smslog_id = $db_row['smslog_id'];
    if ($uid && $smslog_id) {
        $c_sms_status = 0;
        switch ($cb_status) {
            case "001":
            case "002":
            case "011":
                $c_sms_status = 0;
                break;
Beispiel #7
0
function gammu_hook_getsmsinbox()
{
    // IN20101017_091747_00_+628123423141312345_00.txt
    global $gammu_param;
    $handle = @opendir($gammu_param['path'] . "/inbox");
    while ($sms_in_file = @readdir($handle)) {
        if ($sms_in_file != "." && $sms_in_file != "..") {
            $fn = $gammu_param['path'] . "/inbox/{$sms_in_file}";
            logger_print("infile:" . $fn, 3, "gammu incoming");
            $the_fn = str_replace('IN', '', basename($fn));
            $arr_fn = explode('_', $the_fn);
            // let me know if you got better way :)
            $year = substr($arr_fn[0], 0, 4);
            $month = substr($arr_fn[0], 4, 2);
            $date = substr($arr_fn[0], 6, 2);
            $hour = substr($arr_fn[1], 0, 2);
            $minute = substr($arr_fn[1], 2, 2);
            $second = substr($arr_fn[1], 4, 2);
            $sms_datetime = $year . "-" . $month . "-" . $date . " " . $hour . ":" . $minute . ":" . $second;
            // sender
            $sms_sender = $arr_fn[3];
            // message is in UTF-16, need to convert it to UTF-8
            $message = file_get_contents($fn);
            $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) {
                    // collected:
                    // $sms_datetime, $sms_sender, $message, $sms_receiver
                    setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver);
                }
                logger_print("sender:" . $sms_sender . " receiver:" . $sms_receiver . " dt:" . $sms_datetime . " msg:" . $message, 3, "gammu incoming");
            }
        }
    }
    @closedir($handle);
}
Beispiel #8
0
if (!$called_from_hook_call) {
    chdir("../../../");
    include "init.php";
    include $apps_path['libs'] . "/function.php";
    chdir("plugin/gateway/kannel");
    $requests = $_REQUEST;
}
$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 != $kannel_param['bearerbox_host'])
if ($remote_addr != $kannel_param['bearerbox_host'] && $remote_host != $kannel_param['bearerbox_host']) {
    logger_print("exit remote_addr:" . $remote_addr . " remote_host:" . $remote_host . " bearerbox_host:" . $kannel_param['bearerbox_host'], 3, "kannel incoming");
    exit;
}
$t = trim($requests['t']);
// sms_datetime
$q = trim($requests['q']);
// sms_sender
$a = trim($requests['a']);
// message
$Q = trim($requests['Q']);
// sms_receiver
logger_print("addr:" . $remote_addr . " host:" . $remote_host . " t:" . $t . " q:" . $q . " a:" . $a . " Q:" . $Q, 3, "kannel incoming");
if ($t && $q && $a) {
    // collected:
    // $sms_datetime, $sms_sender, $message, $sms_receiver
    setsmsincomingaction($t, $q, $a, $Q);
}
Beispiel #9
0
<?php

chdir("../../../");
include "init.php";
include "{$apps_path['libs']}/function.php";
chdir("plugin/gateway/kannel");
$remote_addr = $_SERVER["REMOTE_ADDR"];
if ($remote_addr != $kannel_param['bearerbox_host']) {
    die;
}
$t = $_GET['t'];
$q = $_GET['q'];
$a = $_GET['a'];
// if there's no datetime param,
// then use the current date
if (empty($t)) {
    $t = date("Y-m-d H:i");
}
if ($t && $q && $a) {
    $sms_datetime = trim($t);
    $sms_sender = trim($q);
    $message = trim($a);
    setsmsincomingaction($sms_datetime, $sms_sender, $message);
}
Beispiel #10
0
function gw_set_incoming_action()
{
    global $kannel_param;
    $handle = @opendir($kannel_param['path'] . "/cache/smsd");
    while ($sms_in_file = @readdir($handle)) {
        if (eregi("^ERR.in", $sms_in_file) && !eregi("^[.]", $sms_in_file)) {
            $fn = $kannel_param['path'] . "/cache/smsd/{$sms_in_file}";
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = urldecode(trim($lines[0]));
            $sms_sender = urldecode(trim($lines[1]));
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            $messsage = urldecode($message);
            if (setsmsincomingaction($sms_datetime, $sms_sender, $message)) {
                @unlink($tobe_deleted);
            }
        }
    }
}
Beispiel #11
0
function gw_set_incoming_action()
{
    // global $uplink_param;
    // $sms_datetime	: incoming sms datetime
    // $target_code	: target code
    // $message		: incoming sms message
    // setsmsincomingaction($sms_datetime,$sms_sender,$target_code,$message)
    // you must retrieve all informations needed by setsmsincomingaction()
    // from incoming sms, have a look gnokii gateway module
    global $gnokii_param;
    $handle = @opendir("{$gnokii_param['path']}/cache/smsd");
    while ($sms_in_file = @readdir($handle)) {
        if (preg_match("/^ERR.in/i", $sms_in_file) && !preg_match("^[.]", $sms_in_file)) {
            $fn = "{$gnokii_param['path']}/cache/smsd/{$sms_in_file}";
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = trim($lines[0]);
            $sms_sender = trim($lines[1]);
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            $array_target_code = explode(" ", $message);
            $target_code = strtoupper(trim($array_target_code[0]));
            $message = $array_target_code[1];
            for ($i = 2; $i < count($array_target_code); $i++) {
                $message .= " " . $array_target_code[$i];
            }
            // collected:
            // $sms_datetime, $sms_sender, $target_code, $message
            if (setsmsincomingaction($sms_datetime, $sms_sender, $target_code, $message)) {
                @unlink($tobe_deleted);
            }
        }
    }
}
Beispiel #12
0
function gw_set_incoming_action()
{
    // global $uplink_param;
    // $sms_datetime	: incoming sms datetime
    // $target_code	: target code
    // $message		: incoming sms message
    // setsmsincomingaction($sms_datetime,$sms_sender,$target_code,$message)
    // you must retrieve all informations needed by setsmsincomingaction()
    // from incoming sms, have a look gnokii gateway module
    global $gnokii_param;
    $handle = @opendir("{$gnokii_param['path']}/cache/smsd");
    while ($sms_in_file = @readdir($handle)) {
        if (eregi("^ERR.in", $sms_in_file) && !eregi("^[.]", $sms_in_file)) {
            $fn = "{$gnokii_param['path']}/cache/smsd/{$sms_in_file}";
            $tobe_deleted = $fn;
            $lines = @file($fn);
            $sms_datetime = trim($lines[0]);
            $sms_sender = trim($lines[1]);
            $message = "";
            for ($lc = 2; $lc < count($lines); $lc++) {
                $message .= trim($lines[$lc]);
            }
            if (setsmsincomingaction($sms_datetime, $sms_sender, $message)) {
                @unlink($tobe_deleted);
            }
        }
    }
}