Exemplo n.º 1
0
<?php

//Check if referrer is Clickatell
//if($_SERVER['REMOTE_ADDR'] == '196.5.254.33')
//{
//Bootstrap!
require '../includes/master.inc.php';
//check for all required CLICKATELL vars
if (!empty($_REQUEST['api_id']) && !empty($_REQUEST['apiMsgId']) && !empty($_REQUEST['timestamp']) && !empty($_REQUEST['to']) && !empty($_REQUEST['status']) && !empty($_REQUEST['charge'])) {
    //first check the api_id
    $ua = new UserApi();
    if ($aUserApi = $ua->checkApi($_REQUEST['api_id'])) {
        //Fire up tracker
        $t = new Tracker2();
        //first look for existing msg_id
        if ($_REQUEST['status'] !== 4 && ($tid = $t->checkMsg($_REQUEST['apiMsgId']))) {
            //just update status (should check for existing status?)
            $t->select($tid);
            $t->timestamp = $_REQUEST['timestamp'];
            $t->status = $_REQUEST['status'];
            $t->internal_timestamp = time();
            $t->update();
        } else {
            //Store tracker
            $t = new Tracker2();
            $t->api_id = $_REQUEST['api_id'];
            $t->user_id = 1;
            $t->msg_id = $_REQUEST['apiMsgId'];
            $t->user_msg_id = !empty($_REQUEST['cliMsgId']) ? $_REQUEST['cliMsgId'] : '';
            $t->charge = $_REQUEST['charge'];
            $t->to = $_REQUEST['to'];