Ejemplo n.º 1
0
 private function getLostBagLocation($tag = '')
 {
     if (!empty($tag)) {
         $sql = "SELECT * FROM log_check_lost_bag_inbox_notified LEFT JOIN airports USING (iata) WHERE tag_no = '{$tag}' AND contact_details = '{$this->phone_number}' \n";
     } else {
         $sql = "SELECT * FROM log_check_lost_bag_inbox_notified LEFT JOIN airports USING (iata) WHERE contact_details = '{$this->phone_number}' \n";
     }
     $q = mysql::i()->query($sql);
     if (mysql::i()->num_rows($q) == 0) {
         return;
     } elseif (mysql::i()->num_rows($q) == 1) {
         $array[] = mysql::i()->fetch_array($q);
         return $array;
     } else {
         while ($r = mysql::i()->fetch_array($q)) {
             if ($r['country'] == 'USA') {
                 continue;
             }
             if ($tag) {
                 $array[] = $r;
             } else {
                 $array[] = $r;
             }
         }
         return $array;
     }
 }
Ejemplo n.º 2
0
 private function cancelTag($tag)
 {
     echo $sql = "UPDATE tag_registered r left join customer c on r.customer_id=c.customer_id SET is_deleted=1 WHERE r.tag_no='{$tag}' AND telephone='{$this->phone_number}' \n";
     $q = mysql::i()->query($sql);
     if (mysql::i()->affected_rows($q) == 0) {
         $this->errors[$tag] = "Tag ({$tag}) was not cancelled. Please check and try again or call " . config::get('lost_bag_number');
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 3
0
 public function api()
 {
     //unfinished
     echo $sql = "SELECT clientMessageReference FROM log_outbound_sms WHERE received=false AND status='LIVE'  \n";
     //and clientMessageReference = 191
     $q = mysql::i()->query($sql);
     while ($r = mysql::i()->fetch_array($q)) {
         $class = utils::recursiveCall('getSMSStatus', $r, 1);
         //$class->
         sleep(1);
         //unset($class);
     }
 }
Ejemplo n.º 4
0
//print "<pre>";
if (!defined("PATH_SEPARATOR")) {
    if (strpos($_ENV["OS"], "Win") !== false) {
        define("PATH_SEPARATOR", ";");
    } else {
        define("PATH_SEPARATOR", ":");
    }
}
set_include_path('classes/log' . PATH_SEPARATOR . 'classes/api/textanywhere' . PATH_SEPARATOR . 'classes/api' . PATH_SEPARATOR . 'classes/parsers' . PATH_SEPARATOR . 'classes/textanywhere' . PATH_SEPARATOR . 'classes/database' . PATH_SEPARATOR . 'classes/library' . PATH_SEPARATOR . 'classes/exceptions' . PATH_SEPARATOR . 'classes/extract' . PATH_SEPARATOR . 'classes/datadictionary' . PATH_SEPARATOR . 'classes' . PATH_SEPARATOR);
function __autoload($class)
{
    if ($fh = @fopen("{$class}.inc.php", 'r', true)) {
        fclose($fh);
        require "{$class}.inc.php";
    } else {
        require "{$class}.class.php";
    }
}
try {
    config::setup();
    mysql::i(config::get('mysql_conn'));
} catch (dbException $e) {
    debug::output($e->getMessage());
    // any errors in this block then should probably exit
    exit;
} catch (Exception $e) {
    debug::output($e->getMessage());
    // any errors in this block then should probably exit
    exit;
}
Ejemplo n.º 5
0
 private function getValidTags()
 {
     debug::output("Get tags against phone number {$this->phone_number}...");
     echo $sql = "SELECT * FROM log_recognised_tags t left join group_tags g on t.tag_no = g.tag  WHERE phone_number = '{$this->phone_number}' AND activated=false \n";
     $q = mysql::i()->query($sql);
     if (mysql::i()->num_rows($q) == 0) {
         return false;
     } else {
         while ($r = mysql::i()->fetch_array($q)) {
             $this->tags[$r['tag_no']] = $r;
         }
         return true;
     }
 }
Ejemplo n.º 6
0
 protected function checkTagValidityDatabase($tag)
 {
     $q = parent::checkTagValidityGroup($tag);
     if ($q != false) {
         $r = mysql::i()->fetch_array($q);
         $this->tags[$tag] = $r;
         $this->cost = parent::getTagCost($r['tag_type']);
         $this->type = trim(strtoupper($r['tag_type']));
         return true;
     }
 }
Ejemplo n.º 7
0
 public function unLogValidTags($tag)
 {
     $sql = "UPDATE log_recognised_tags SET activated=true  WHERE tag_no = '{$tag}'  \n";
     mysql::i()->query($sql);
 }
Ejemplo n.º 8
0
 private function checkTagAlreadyLogged($tag)
 {
     $sql = "SELECT * FROM log_recognised_tags WHERE tag_no='{$tag}' \n";
     $q = mysql::i()->query($sql);
     if (mysql::i()->num_rows($q) > 0) {
         $r = mysql::i()->fetch_array($q);
         if ($r['phone_number'] == $this->phone_number) {
             //tag is pending activation and belongs to this mobile number. No need to create confusion. Better to validate and continue as if it's the first time it's been registered.
             return true;
         } else {
             $this->errors[$tag] = 'Tag ' . $tag . ' is pending activation against another mobile number. Please check and try again or call ' . config::get('customer_services');
             return false;
         }
     } else {
         //not previously registered according to this log
         return true;
     }
     return false;
 }
Ejemplo n.º 9
0
 public function release()
 {
     mysql::i()->query("delete from script_locks_sms where process_name = '{$this->process_name}' ");
 }
Ejemplo n.º 10
0
 private function get_message_avail_num($params)
 {
     $uid = $params['uid'];
     $sql = "select * from little_account where uid={$uid}";
     $row = mysql::i()->get_one($sql);
     echo $row['message_num'];
     exit;
 }
Ejemplo n.º 11
0
 protected function updateTagGroup($tag)
 {
     $sql = "UPDATE group_tags SET action='USED' WHERE tag = '{$tag}' \n";
     mysql::i()->query($sql);
 }
Ejemplo n.º 12
0
 private function fetchCustomerId($tag_id, $expirydate)
 {
     echo $sql = "SELECT * from tag_registered WHERE tag_id='{$tag_id}' AND date_expire = '{$expirydate}' \n";
     $result = mysql::i()->query($sql);
     $r = mysql::i()->fetch_object($result);
     return $r;
 }
Ejemplo n.º 13
0
 public function checkTagValidityDatabase($tags, $phone_number, $live)
 {
     foreach ($this->valid_tags as $tag) {
         $tag_no = utils::extractTagNo($tag);
         echo $sql = "SELECT * FROM group_tags WHERE tag = '{$tag_no}' \n";
         $q = mysql::i()->query($sql);
         $r = mysql::i()->fetch_array($q);
         if (empty($r)) {
             unset($this->valid_tags[$tag]);
             $this->invalid_tags[$tag] = $tag;
             $send['destinations'] = $phone_number;
             echo $send['body'] = 'Tag ' . $tag . ' is not recognised by our system please. Please check and try again or call ' . config::get('lost_bag_number');
             utils::recursiveCall('sendSMS', $send, 1, $live);
             $valid = false;
         }
         if ($r['action'] == 'USED') {
             unset($this->valid_tags[$tag]);
             $this->invalid_tags[$tag] = $tag;
             $send['destinations'] = $phone_number;
             echo $send['body'] = 'Tag ' . $tag . ' is already in use. Please check and try again or call ' . config::get('lost_bag_number');
             utils::recursiveCall('sendSMS', $send, 1, $live);
             $valid = false;
         }
         $type = $r['tag_type'];
         if ($type == 'paper') {
             $cost += '1.50';
         } else {
             $cost = 0;
         }
         $this->valid_tags[$tag] = $r;
         $this->valid_tags[$tag]['cost'] = $cost;
         //$this->tagData[$tag]['type'] = $type;
         //$this->tagData[$tag]['authorised'] = 1;
         unset($cost);
     }
     //foreach
     //$this->tagData['cost'] = $cost;
     return $valid;
 }
Ejemplo n.º 14
0
 mysql::i()->query("truncate airports");
 validator::loadDictionaries(array('AirDB'));
 $iata = array('BKN', 'AAS', 'BOO');
 $air = array();
 foreach ($csv as $row) {
     //print_r($row);
     validator::validateInput($row);
     $cleanData = validator::getCleanData();
     $errors = validator::getErrors();
     if (!empty($errors)) {
         print_r($errors);
         exit;
     }
     $cleanData['Airport'] = str_replace(']', '', str_replace('[', '', $cleanData['Airport']));
     $sql = "INSERT INTO airports (ICAO,IATA,place,state,airport,country) VALUES ('{$cleanData['ICAO']}','{$cleanData['IATA']}','{$cleanData['Place']}','{$cleanData['State']}','{$cleanData['Airport']}','{$cleanData['Country']}') ";
     mysql::i()->query($sql);
     //if(in_array($cleanData['IATA'], $iata))continue;
     //print_r($cleanData);
     //print_r($cleanData);
     /*
     		if(in_array($cleanData['IATA'], $air)){
     			if($air[$cleanData['IATA']]['Country'] == 'USA'){
     				$air[$cleanData['IATA']] = $cleanData;
     				
     			}
     		}else{
     			$air[$cleanData['IATA']] = $cleanData;
     			
     		}*/
 }
 /*
Ejemplo n.º 15
0
<?php

chdir('../');
include_once 'init.inc.php';
$lock = 'nolock';
config::set('process_name', "Inbox - Register Email Address Reminder");
include_once 'start.inc.php';
try {
    $sql = "SELECT * FROM customer WHERE email='' AND approved=1 AND telephone<>'' AND username<>'' \n";
    $q = mysql::i()->query($sql);
    while ($r = mysql::i()->fetch_array($q)) {
        $send['destinations'] = utils::formatPhoneNumber($r['telephone']);
        $send['body'] = "Account {$r['username']} does not have a valid email address to recieve lost bag reports. Please log on to example.com to update your details. Text PIN STOP to cancel";
        utils::recursiveCall('sendSMS', $send, 1);
    }
} catch (emailException $e) {
    debug::output($e->getMessage());
} catch (Exception $e) {
    debug::output($e->getMessage());
    //$status->status(CRITICAL);
}
include 'end.inc.php';
Ejemplo n.º 16
0
 private function logCheckLostBagTagInboxNotified($tag_no, $iata, $world_tracer_ref, $notified, $method, $contact_details)
 {
     $sql = "SELECT * FROM log_check_lost_bag_inbox_notified where tag_no = '{$tag_no}' ";
     $q = mysql::i()->query($sql);
     if (mysql::i()->num_rows($q) == 0) {
         $sql = "INSERT INTO log_check_lost_bag_inbox_notified (tag_no, iata, world_tracer_ref, notified, method, contact_details, datetime) VALUES ('{$tag_no}', '{$iata}', '{$world_tracer_ref}', {$notified}, '{$method}', '{$contact_details}' ,now() ) \n";
         mysql::i()->query($sql);
         $this->old_lost_tags_notified[$tag_no] = $tag_no;
         //in case of multiple reports for one tag in the inbox
         return mysql::i()->last_id();
     }
 }
Ejemplo n.º 17
0
 private function checkSuppressionList($originator)
 {
     $originator = utils::formatPhoneNumber($originator);
     $sql = "SELECT * FROM log_sms_suppression_list WHERE originator='{$originator}' \n";
     $q = mysql::i()->query($sql);
     $rows = mysql::i()->num_rows($q);
     if ($rows > 1) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 18
0
 public static function getIP($return_array = false)
 {
     $ip = null;
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
     }
     if (is_array($ip)) {
         if (count($ip) > 1) {
             $via_proxy = mysql::i()->escape_string(array_pop($ip));
             $via_proxy = trim($via_proxy);
         }
         $ip = mysql::i()->escape_string(array_pop($ip));
     }
     if (empty($ip)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     if (empty($via_proxy)) {
         $via_proxy = '';
     }
     $ip = trim($ip);
     $ip = array('ip' => $ip, 'via_proxy' => $via_proxy);
     if (false === $return_array) {
         if (is_array($ip)) {
             $iparray = $ip;
             return $iparray['ip'];
         } else {
             return $ip;
         }
     } else {
         return $ip;
     }
 }