Exemplo n.º 1
0
 public function getConnection()
 {
     try {
         if (!$this->database) {
             $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
             $this->database = new PDO(Config::get('DB_TYPE') . ':host=' . Config::get('DB_HOST') . ';dbname=' . Config::get('DB_NAME') . ';port=' . Config::get('DB_PORT') . ';charset=' . Config::get('DB_CHARSET'), Config::get('DB_USER'), Config::get('DB_PASS'), $options);
         }
     } catch (PDOException $e) {
         throw new Exception("PDOException: " . $e->getMessage());
     }
     return $this->database;
 }
Exemplo n.º 2
0
 public function __construct($logger = 'default', $config = null)
 {
     //include the logger file that loads the log4php autoloader
     require_once Config::get('LOG4PHP_LOGGER_FILE');
     //configure log4php
     if ($config == null || !isset($config) || empty($config)) {
         $config = Config::get('LOG4PHP_CONFIG');
     }
     Logger::configure($config);
     //create a logger
     $this->logger = Logger::getLogger($logger);
 }
Exemplo n.º 3
0
 /**
  * Construct the (base) controller. This happens when a real controller is constructed, like in
  * the constructor of IndexController when it says: parent::__construct();
  */
 function __construct(LoggerInterface $logger = null)
 {
     // always initialize a session
     Session::init();
     // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
     if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
         header('location: ' . Config::get('URL') . 'login/loginWithCookie');
     }
     // create a view object to be able to use it inside a controller, like $this->View->render();
     $this->View = new View();
     //initialize the logger object
     $this->logger = $logger;
 }
Exemplo n.º 4
0
 public function __construct($title, $data, $headers, $sizes, $max_lengths)
 {
     parent::__construct();
     $this->header_text = $title;
     $this->footer_text = "Generated by [" . Session::get('user_name') . "] on [" . date("l jS \\of F Y h:i:s A") . "] - " . Config::get('VERSION');
     $this->data = $data;
     $this->col_headers = $headers;
     $this->col_sizes = $sizes;
     $this->col_max_lengs = $max_lengths;
     $this->SetTitle($title);
     $this->SetAuthor(Session::get('user_name'));
     $this->AliasNbPages();
     $this->SetFont('Arial', '', 8);
     $this->AddPage();
     $this->renderTable();
 }
Exemplo n.º 5
0
 /**
  * Gets a user's profile data, according to the given $user_id
  * @param int $user_id The user's id
  * @return mixed The selected user's profile
  */
 public static function getPublicProfileOfUser($user_id)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT user_id, user_name, user_email, user_active, user_has_avatar\n                FROM tbl_users WHERE user_id = :user_id LIMIT 1";
     $query = $database->prepare($sql);
     $query->execute(array(':user_id' => $user_id));
     $user = $query->fetch();
     if ($query->rowCount() == 1) {
         if (Config::get('USE_GRAVATAR')) {
             $user->user_avatar_link = AvatarModel::getGravatarLinkByEmail($user->user_email);
         } else {
             $user->user_avatar_link = AvatarModel::getPublicAvatarFilePathOfUser($user->user_has_avatar, $user->user_id);
         }
     } else {
         Session::add('feedback_negative', Text::get('FEEDBACK_USER_DOES_NOT_EXIST'));
     }
     return $user;
 }
Exemplo n.º 6
0
            ?>
&start_date=<?php 
            echo $message->calendar_date;
            ?>
&end_date=<?php 
            echo $message->calendar_date;
            ?>
"><?php 
            echo $message->service_id;
            ?>
</a></td>
						<?php 
        } else {
            ?>
						<a title="View Subscriptions" href="<?php 
            echo Config::get('URL');
            ?>
messages/subscriptions/?service_id=<?php 
            echo $message->service_id;
            ?>
&product_id=<?php 
            echo $message->product_id;
            ?>
&update_type=<?php 
            echo $message->update_type;
            ?>
&start_date=<?php 
            echo $this->start_date;
            ?>
&end_date=<?php 
            echo $this->end_date;
Exemplo n.º 7
0
 /**
  * Hook - can be used to forward data to an external system (realtime forwarders)
  *
  * @param $data mixed data to be processed
  * @return int array indicating the processing status and data after processing
  */
 protected function hook($data)
 {
     if (Config::get('INBOX_FORWARDER') == 1) {
         //forward
         //initialize the parameters
         $message_id = "";
         $sp_rev_id = "";
         $sp_re_password = "";
         $sp_id = "";
         $service_id = "";
         $link_id = "";
         $trace_unique_id = "";
         $correlator = "";
         $message = "";
         $sender_address = "";
         $dest_address = "";
         $date_time = "";
         //get the data from array
         if (isset($data['_lastInsertID'])) {
             $message_id = $data['_lastInsertID'];
         }
         if (isset($data['spRevId'])) {
             $sp_rev_id = $data['spRevId'];
         }
         if (isset($data['spRevpassword'])) {
             $sp_re_password = $data['spRevpassword'];
         }
         if (isset($data['spId'])) {
             $sp_id = $data['spId'];
         }
         if (isset($data['serviceId'])) {
             $service_id = $data['serviceId'];
         }
         if (isset($data['linkid'])) {
             $link_id = $data['linkid'];
         }
         if (isset($data['traceUniqueID'])) {
             $trace_unique_id = $data['traceUniqueID'];
         }
         if (isset($data['correlator'])) {
             $correlator = $data['correlator'];
         }
         if (isset($data['message'])) {
             $message = $data['message'];
         }
         if (isset($data['senderAddress'])) {
             $sender_address = $data['senderAddress'];
         }
         if (isset($data['smsServiceActivationNumber'])) {
             $dest_address = $data['smsServiceActivationNumber'];
         }
         if (isset($data['dateTime'])) {
             $date_time = $data['dateTime'];
         }
         // add some logic to handle exceptions in this script
         $database = null;
         try {
             //$database = SQLSRVDatabaseFactory::getFactory()->getConnection();
             $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
             $database = new PDO('sqlsrv:Server=SEMATEL-SERVER;Database=db_Sematel', 'sa', 'SematelServer2014', $options);
         } catch (Exception $ex) {
             return array('result' => 3, 'resultDesc' => 'Cannot connect to the database. Error: ' . $ex->getMessage());
         }
         try {
             $database->beginTransaction();
             $sql = "INSERT INTO tbl_inbound_messages (message_id, service_id, link_id, trace_unique_id, correlator, message, sender_address, dest_address, date_time, created_on) VALUES (:message_id, :service_id, :link_id, :trace_unique_id, :correlator, :message, :sender_address, :dest_address, :date_time, CURRENT_TIMESTAMP);";
             $query = $database->prepare($sql);
             $bind_patameters = array(':message_id' => $message_id, ':service_id' => $service_id, ':link_id' => $link_id, ':trace_unique_id' => $trace_unique_id, ':correlator' => $correlator, ':message' => $message, ':sender_address' => $sender_address, ':dest_address' => $dest_address, ':date_time' => $date_time);
             $this->logger->debug('{class_mame}|{method_name}|{service_id}|forwarding-hook|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
             if ($query->execute($bind_patameters)) {
                 $row_count = $query->rowCount();
                 $database->commit();
                 if ($row_count == 1) {
                     return array('result' => 0, 'resultDesc' => 'Forwarding successful', 'data' => $data);
                 }
             } else {
                 $this->logger->error('{class_mame}|{method_name}|{service_id}|error executing the query|{error}|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'error' => $database->errorCode(), 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
                 return array('result' => 5, 'resultDesc' => 'Error executing a query.');
             }
         } catch (PDOException $e) {
             return array('result' => 4, 'resultDesc' => 'Error executing a query. Error: ' . $e->getMessage());
         }
         return array("result" => "19", "resultDesc" => "Forwarding record failed ({$sql})" . $database->errorCode() . " " . $database->errorInfo(), "data" => $data);
     }
     return array("result" => "0", "resultDesc" => "Hook execution successful", "data" => $data);
 }
Exemplo n.º 8
0
 /**
  * Hook - can be used to forward data to an external system (realtime forwarders)
  *
  * @param $data mixed data to be processed
  * @return int array indicating the processing status and data after processing
  */
 protected function hook($data)
 {
     /* Update outgoing table with the parameters */
     //initialize the parameters
     $correlator = "";
     $dest_address = "";
     $delivery_status = "";
     $delivery_receipt_id = 0;
     //get the data from array
     if (isset($data['correlator'])) {
         $correlator = $data['correlator'];
     }
     if (isset($data['address'])) {
         $dest_address = $data['address'];
     }
     if (isset($data['deliveryStatus'])) {
         $delivery_status = $data['deliveryStatus'];
     }
     if (isset($data['_lastInsertID'])) {
         $delivery_receipt_id = $data['_lastInsertID'];
     }
     // add some logic to handle exceptions in this script
     $database = DatabaseFactory::getFactory()->getConnection();
     $database->beginTransaction();
     $sql = "UPDATE tbl_outbound_messages SET delivery_timestamp = NOW(), delivery_status=:delivery_status, delivery_notif_type=2, delivery_receipt_id =:delivery_receipt_id, last_updated_on=NOW() WHERE dest_address=:dest_address AND correlator=:correlator";
     // IMPORTANT - note dest_addresses in the where clause (to be visited later)
     $query = $database->prepare($sql);
     $query->execute(array(':delivery_status' => $delivery_status, ':delivery_receipt_id' => $delivery_receipt_id, ':dest_address' => $dest_address, ':correlator' => $correlator));
     $row_count = $query->rowCount();
     $data['_recordsUpdated'] = $row_count;
     $database->commit();
     if ($database->errorCode() != "0000") {
         //success
         return array("result" => "18", "resultDesc" => "Saving FAILED. Error: " . $database->errorCode(), "data" => $data);
     }
     //forward the request
     if (Config::get('DELIVERY_FORWARDER') == 1) {
         //
         //initialize the parameters
         $time_stamp = "";
         $sub_req_id = "";
         $trace_unique_id = "";
         $correlator = "";
         $dest_address = "";
         $delivery_status = "";
         $id = "";
         //get the data from array
         if (isset($data['timeStamp'])) {
             $time_stamp = $data['timeStamp'];
         }
         if (isset($data['subReqID'])) {
             $sub_req_id = $data['subReqID'];
         }
         if (isset($data['traceUniqueID'])) {
             $trace_unique_id = $data['traceUniqueID'];
         }
         if (isset($data['correlator'])) {
             $correlator = $data['correlator'];
         }
         if (isset($data['address'])) {
             $dest_address = $data['address'];
         }
         if (isset($data['deliveryStatus'])) {
             $delivery_status = $data['deliveryStatus'];
         }
         if (isset($data['_lastInsertID'])) {
             $id = $data['_lastInsertID'];
         }
         // add some logic to handle exceptions in this script
         $database = null;
         try {
             //$database = SQLSRVDatabaseFactory::getFactory()->getConnection();
             $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
             $database = new PDO('sqlsrv:Server=SEMATEL-SERVER;Database=db_Sematel', 'sa', 'SematelServer2014', $options);
         } catch (Exception $ex) {
             return array('result' => 3, 'resultDesc' => 'Cannot connect to the database. Error: ' . $ex->getMessage());
         }
         $bind_patameters = array();
         try {
             $database->beginTransaction();
             $sql = "INSERT INTO dbo.tbl_delivery_receipts (id, time_stamp, sub_req_id, trace_unique_id, correlator, dest_address, delivery_status, created_on) VALUES (:id, :time_stamp, :sub_req_id, :trace_unique_id, :correlator, :dest_address, :delivery_status, CURRENT_TIMESTAMP);";
             $query = $database->prepare($sql);
             $bind_patameters = array(':id' => $id, ':time_stamp' => $time_stamp, ':sub_req_id' => $sub_req_id, ':trace_unique_id' => $trace_unique_id, ':correlator' => $correlator, ':dest_address' => $dest_address, ':delivery_status' => $delivery_status);
             $this->logger->debug('{class_mame}|{method_name}|{service_id}|forwarding-hook|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
             if ($query->execute($bind_patameters)) {
                 $row_count = $query->rowCount();
                 $database->commit();
                 if ($row_count == 1) {
                     return array('result' => 0, 'resultDesc' => 'Forwarding successful', 'data' => $data);
                 }
             } else {
                 $this->logger->error('{class_mame}|{method_name}|{service_id}|error executing the query|{error}|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'error' => $database->errorCode(), 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
                 return array('result' => 5, 'resultDesc' => 'Error executing a query.');
             }
         } catch (PDOException $e) {
             $this->logger->error('{class_mame}|{method_name}|{service_id}|forwarding-hook|{query}|bind_parameters:{bind_params}|{error}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'query' => $sql, 'bind_params' => json_encode($bind_patameters), 'error' => $e->getMessage()));
             return array('result' => 4, 'resultDesc' => 'Error executing a query. Error: ' . $e->getMessage());
         }
         return array("result" => "19", "resultDesc" => "Forwarding record failed ({$sql})" . $database->errorCode() . " " . $database->errorInfo(), "data" => $data);
     }
     return array("result" => "0", "resultDesc" => "Hook execution successful", "data" => $data);
 }
Exemplo n.º 9
0
 /**
  * Hook - can be used to forward data to an external system (realtime forwarders)
  *
  * @param $data mixed data to be processed
  * @return int array indicating the processing status and data after processing
  */
 protected function hook($data)
 {
     if (Config::get('SUBSCRIPTION_FORWARDER') == 1) {
         //forward
         //initialize the parameters
         $id = "";
         $subscriber_id = "";
         $sp_id = "";
         $product_id = "";
         $service_id = "";
         $service_list = "";
         $update_type = "";
         $update_time = "";
         $update_desc = "";
         $effective_time = "";
         $expiry_time = "";
         $named_parameters = "";
         $keyword = "";
         //get the data from array
         if (isset($data['_lastInsertID'])) {
             $id = $data['_lastInsertID'];
         }
         if (isset($data['ID'])) {
             $subscriber_id = $data['ID'];
         }
         if (isset($data['spID'])) {
             $sp_id = $data['spID'];
         }
         if (isset($data['productID'])) {
             $product_id = $data['productID'];
         }
         if (isset($data['serviceID'])) {
             $service_id = $data['serviceID'];
         }
         if (isset($data['serviceList'])) {
             $service_list = $data['serviceList'];
         }
         if (isset($data['updateType'])) {
             $update_type = $data['updateType'];
         }
         if (isset($data['updateTime'])) {
             $update_time = $data['updateTime'];
         }
         if (isset($data['updateDesc'])) {
             $update_desc = $data['updateDesc'];
         }
         if (isset($data['effectiveTime'])) {
             $effective_time = $data['effectiveTime'];
         }
         if (isset($data['expiryTime'])) {
             $expiry_time = $data['expiryTime'];
         }
         if (isset($data['keyword'])) {
             $keyword = $data['keyword'];
         }
         // process named parameters - key value pairs
         if (isset($data['key'])) {
             $count = $data['repeatedParameters']['key'];
             $named_parameters_array = array($data['key'] => $data['value']);
             //initial key and value pair
             for ($i = 1; $i <= $count; $i++) {
                 if (isset($data['key' . $i]) && isset($data['value' . $i])) {
                     $named_parameters_array[$data['key' . $i]] = $data['value' . $i];
                 }
             }
             $named_parameters = json_encode($named_parameters_array);
             //encode into json string
         }
         // add some logic to handle exceptions in this script
         $database = null;
         try {
             //$database = SQLSRVDatabaseFactory::getFactory()->getConnection();
             $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
             $database = new PDO('sqlsrv:Server=SEMATEL-SERVER;Database=db_Sematel', 'sa', 'SematelServer2014', $options);
         } catch (Exception $ex) {
             return array('result' => 3, 'resultDesc' => 'Cannot connect to the database. Error: ' . $ex->getMessage());
         }
         try {
             $database->beginTransaction();
             //$sql=$sql="INSERT INTO dbo.tbl_Subscription_messages (id, subscriber_id, sp_id, product_id, service_id, service_list, update_type, update_desc, effective_time, expiry_time, created_on) VALUES (:id,:subscriber_id,:sp_id,:product_id,:service_id,:service_list,:update_type,:update_desc,:effective_time,:expiry_time,CURRENT_TIMESTAMP)";
             $sql = "INSERT INTO dbo.tbl_Subscription_messages (id, subscriber_id, sp_id, product_id, service_id, service_list, update_type, update_desc, effective_time, expiry_time, created_on, keyword) VALUES (:id,:subscriber_id,:sp_id,:product_id,:service_id,:service_list,:update_type,:update_desc,:effective_time,:expiry_time,CURRENT_TIMESTAMP,:keyword)";
             $query = $database->prepare($sql);
             $bind_patameters = array(':id' => $id, ':subscriber_id' => $subscriber_id, ':sp_id' => $sp_id, ':product_id' => $product_id, ':service_id' => $service_id, ':service_list' => $service_list, ':update_type' => $update_type, ':update_desc' => $update_desc, ':effective_time' => $effective_time, ':expiry_time' => $expiry_time, ':keyword' => $keyword);
             $this->logger->debug('{class_mame}|{method_name}|{service_id}|forwarding-hook|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
             if ($query->execute($bind_patameters)) {
                 $row_count = $query->rowCount();
                 $database->commit();
                 if ($row_count == 1) {
                     return array('result' => 0, 'resultDesc' => 'Forwarding successful', 'data' => $data);
                 }
             } else {
                 $this->logger->error('{class_mame}|{method_name}|{service_id}|error executing the query|{error}|{query}|bind_parameters:{bind_params}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'error' => $database->errorCode(), 'query' => $sql, 'bind_params' => json_encode($bind_patameters)));
                 return array('result' => 5, 'resultDesc' => 'Error executing a query.');
             }
         } catch (PDOException $e) {
             return array('result' => 4, 'resultDesc' => 'Error executing a query. Error: ' . $e->getMessage());
         }
         return array("result" => "19", "resultDesc" => "Forwarding record failed ({$sql})" . $database->errorCode() . " " . $database->errorInfo(), "data" => $data);
     }
     return array("result" => "0", "resultDesc" => "Successful - hook is off", "data" => $data);
 }
Exemplo n.º 10
0
 /**
  * Send the password reset mail
  *
  * @param string $user_name username
  * @param string $user_password_reset_hash password reset hash
  * @param string $user_email user email
  *
  * @return bool success status
  */
 public static function sendPasswordResetMail($user_name, $user_password_reset_hash, $user_email)
 {
     // create email body
     $body = Config::get('EMAIL_PASSWORD_RESET_CONTENT') . ' ' . Config::get('URL') . Config::get('EMAIL_PASSWORD_RESET_URL') . '/' . urlencode($user_name) . '/' . urlencode($user_password_reset_hash);
     // create instance of Mail class, try sending and check
     $mail = new Mail();
     $mail_sent = $mail->sendMail($user_email, Config::get('EMAIL_PASSWORD_RESET_FROM_EMAIL'), Config::get('EMAIL_PASSWORD_RESET_FROM_NAME'), Config::get('EMAIL_PASSWORD_RESET_SUBJECT'), $body);
     if ($mail_sent) {
         Session::add('feedback_positive', Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_SUCCESSFUL'));
         return true;
     }
     Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_ERROR') . $mail->getError());
     return false;
 }
Exemplo n.º 11
0
 /**
  * Handles what happens when user moves to URL/service/all. This returns all servives in the system. 
  */
 public function all()
 {
     /*
     	Initialize the request data
     */
     //get request data
     $service_id = Request::get('service_id');
     $service_type = Request::get('service_type');
     $short_code = Request::get('short_code');
     $page = null !== Request::get('page') ? (int) Request::get('page') : 1;
     //page - default is 1
     $rpp = (int) Config::get('RECORDS_PER_PAGE');
     //records per page
     $start_record = (int) (($page - 1) * $rpp);
     // start record
     //request data to be used in calling the model
     $data = array('service_id' => $service_id, 'service_type' => $service_type, 'short_code' => $short_code, 'page' => $page, 'rpp' => $rpp, 'start_record' => $start_record);
     //log the event
     $this->logger->debug('{class_mame}|{method_name}|{service_id}|request-request|{data}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'data' => json_encode($data)));
     $service_model = new ServiceModel($this->logger);
     $result = $service_model->getServices($service_id, $service_type, $short_code, $start_record, Config::get('RECORDS_PER_PAGE'));
     $data['result'] = $result;
     //add some pagination logic here
     $total_records = isset($result['_totalRecords']) ? $result['_totalRecords'] : 0;
     $pagination = new Pagination();
     $pagination->setCurrent($page);
     $pagination->setTotal($total_records);
     $markup = $pagination->parse();
     $data['markup'] = $markup;
     //success
     if ($result['result'] == 0) {
         $this->View->render('servicemanager/all', $data);
     } else {
         $this->View->render('error/loaderror', $result['resultDesc']);
     }
     //log the event
     $this->logger->debug('{class_mame}|{method_name}|{service_id}|result|{result}|{result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'result' => $result['result'], 'result_desc' => $result['resultDesc']));
 }
Exemplo n.º 12
0
 /**
  * Deletes the cookie
  * It's necessary to split deleteCookie() and logout() as cookies are deleted without logging out too!
  * Sets the remember-me-cookie to ten years ago (3600sec * 24 hours * 365 days * 10).
  * that's obviously the best practice to kill a cookie @see http://stackoverflow.com/a/686166/1114320
  */
 public static function deleteCookie()
 {
     setcookie('remember_me', false, time() - 3600 * 24 * 3650, Config::get('COOKIE_PATH'));
 }
Exemplo n.º 13
0
 /**
  * Data preprocessing before it can be saved. Enriching the message to be saved and forwarded.
  *
  * @param $data mixed data to be preprocessed
  * @return int array indicating the processing status and data after processing
  */
 protected function preProcess($data)
 {
     //check for required parameters
     if (!(isset($data['message']) && isset($data['sender_address']) && isset($data['dest_address']) && isset($data['service_id']))) {
         return array('result' => 13, 'resultDesc' => 'Expected parameters not found.', 'data' => $data);
     }
     //get the service data
     $response = $this->getService($data['service_id']);
     //print_r($response);
     if ($response['result'] != 0) {
         //retrieving service failed
         $this->logger->debug('{class_mame}|{method_name}|error-loading-service|{result}|{result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'request_data' => implode('|', $data), 'result' => $response['result'], 'sdp_result_desc' => $response['resultDesc']));
         return $response;
     }
     //extract service data from
     $service = $response['data'];
     //service data
     // Check service status configuration 0 - OFF and 1 - ON
     if ($service->status != 1) {
         return array('result' => 15, 'resultDesc' => 'Service with id ' . $data['service_id'] . ' is OFF or is not configured correctly.', 'data' => $data);
     }
     //resolve the end point
     $data['notify_endpoint'] = $service->delivery_notification_endpoint;
     if (!isset($data['notify_endpoint']) || empty($data['notify_endpoint'])) {
         //use default enmd point
         $data['notify_endpoint'] = Config::get('SEND_SMS_DEFAULT_DELIVERY_NOTIFICATION_ENDPOINT');
     }
     //check whether short code exists as part of the request data, if not, load service configuration file
     if (!isset($data['sender_address']) || empty($data['sender_address'])) {
         $data['sender_address'] = $service->short_code;
     }
     //send request to external server
     $send_response = SDP::sendSms($this->logger, $data['service_id'], $data['dest_address'], $data['correlator'], $data['sender_address'], $data['message'], $data['link_id']);
     //log the event
     $this->logger->debug('{class_mame}|{method_name}|sdp-result|{request_data}|{sdp_result}|{sdp_result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'request_data' => implode('|', $data), 'sdp_result' => $send_response['ResultCode'], 'sdp_result_desc' => $send_response['ResultDesc']));
     $data['sdp_sendsms_result'] = $send_response;
     //check send sms response code
     if ($send_response['ResultCode'] == 0) {
         // success
         //send the message to external system
         $data['send_ref_id'] = $send_response['ResultDetails']['result'];
         //ref id of SDP to be changed with API change
         $data['status'] = 2;
         //send sms successful
         $data['status_desc'] = 'SENT[Message sent]';
         //message sent
     } else {
         $data['status'] = 4;
         //sending failed
         $data['status_desc'] = 'FAIED[Sending failed. ' . $send_response['ResultCode'] . ' - ' . $send_response['ResultDesc'] . ': ' . $send_response['ResultDetails'] . ']';
         //message send failed
     }
     return array('result' => "0", 'resultDesc' => 'Preprocessing successful', 'data' => $data);
 }
Exemplo n.º 14
0
 public static function stopSmsNotification(LoggerInterface $logger, $kmp_service_id, $kmp_correlator)
 {
     $kmp_spid = Config::get('SP_ID');
     // sp id from configuration file
     $kmp_timestamp = date("YmdHis");
     //current timestamp
     $kmp_sppwd = self::generatePassword($kmp_timestamp);
     // password to be passed to SDP
     $bodyxml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.huawei.com.cn/schema/common/v2_1" xmlns:loc="http://www.csapi.org/schema/parlayx/sms/notification_manager/v2_3/local"><soapenv:Header><v2:RequestSOAPHeader><spId>' . $kmp_spid . '</spId><spPassword>' . $kmp_sppwd . '</spPassword><serviceId>' . $kmp_service_id . '</serviceId><timeStamp>' . $kmp_timestamp . '</timeStamp></v2:RequestSOAPHeader></soapenv:Header><soapenv:Body><loc:stopSmsNotification><correlator>' . $kmp_correlator . '</correlator></loc:stopSmsNotification></soapenv:Body></soapenv:Envelope>';
     //create the client
     $client = new nusoap_client(Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'), true);
     $bsoapaction = "";
     $client->soap_defencoding = 'utf-8';
     $client->useHTTPPersistentConnection();
     //send the request to the server
     $result = $client->send($bodyxml, $bsoapaction);
     //log the send request
     $logger->debug("{class_mame}|{method_name}|{service_id}|sending stop sms notification|{endpoint}|{soapaction}|{request}", array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'service_id' => $kmp_service_id, 'endpoint' => Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'), 'soapaction' => $bsoapaction, 'request' => $bodyxml));
     //check for fault and return
     if ($client->fault) {
         return array('ResultCode' => 1, 'ResultDesc' => 'SOAP Fault', 'ResultDetails' => $result, 'xml' => $bodyxml, 'endpoint' => Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'));
     }
     // check for errors and return
     $err = $client->getError();
     if ($err) {
         return array('ResultCode' => 2, 'ResultDesc' => 'Error', 'ResultDetails' => $err, 'xml' => $bodyxml, 'endpoint' => Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'));
     } else {
         //check for fault code
         if (isset($result['faultcode'])) {
             return array('ResultCode' => '3', 'ResultDesc' => 'Fault - ' . $result['faultcode'], 'ResultDetails' => $result['faultstring'], 'xml' => $bodyxml, 'endpoint' => Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'));
         }
         //return success
         return array('ResultCode' => 0, 'ResultDesc' => 'Operation Successful.', 'ResultDetails' => $result, 'xml' => $bodyxml, 'endpoint' => Config::get('SMS_NOTIFICATION_MANAGER_ENDPOINT'));
     }
 }
Exemplo n.º 15
0
 public function subscriptions_pdf()
 {
     /*
     	Initialize the request data
     */
     //get request data
     $subscriber_id = Request::get('subscriber_id');
     $service_id = Request::get('service_id');
     $product_id = Request::get('product_id');
     $update_type = Request::get('update_type');
     $start_date = Request::get('start_date');
     $end_date = Request::get('end_date');
     //set default start date - 1 month ago
     if (!isset($start_date) || $start_date == '') {
         $date = date_create(date('Y-m-d'));
         date_sub($date, date_interval_create_from_date_string('1 months'));
         $start_date = date_format($date, 'Y-m-d');
     }
     //set default end date  - current day
     if (!isset($end_date) || $end_date == '') {
         $end_date = date('Y-m-d');
     }
     //request data to be used in calling the model
     $data = array('subscriber_id' => $subscriber_id, 'service_id' => $service_id, 'product_id' => $product_id, 'update_type' => $update_type, 'start_date' => $start_date, 'end_date' => $end_date);
     //log the event
     $this->logger->debug('{class_mame}|{method_name}|request|request-data:{data}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'data' => json_encode($data)));
     //call the model
     $model = new MessageModel($this->logger);
     $result = $model->getSubscriptionMessages($start_date . ' 00:00:00', $end_date . ' 23:59:59', $subscriber_id, $service_id, $product_id, $update_type, 0, Config::get('MAX_RECORDS_PDF'));
     //add result
     $data['result'] = $result;
     //print_r($result);
     //request data to be used in calling the model
     $data = array('subscriber_id' => $subscriber_id, 'service_id' => $service_id, 'product_id' => $product_id, 'update_type' => $update_type, 'start_date' => $start_date, 'end_date' => $end_date);
     $title = "Subscription Requests Extract - Subscriber: {$subscriber_id}, Service ID: {$service_id}, Product ID: {$product_id}, Update Type: {$update_type}, Start Date: {$start_date}, End Date: {$end_date}";
     $headers = array('#', 'Subscriber', 'Service ID', 'Product ID', 'Update Type', 'Effective Time', 'Expiry Time', 'Processing Time');
     $sizes = array(15, 43, 40, 40, 35, 35, 35, 35);
     $max_sizes = array(10, 30, 28, 28, 30, 25, 25, 25);
     $data = array();
     $filename = __FUNCTION__ . '_' . Session::get('user_name') . '_' . date('YmdHis') . '.pdf';
     $i = 0;
     foreach ($result['messages'] as $message) {
         $data[$i] = array($message->id, $message->subscriber_id, $message->service_id, $message->product_id, $message->update_desc, $message->effective_time, $message->expiry_time, $message->created_on);
         $i++;
     }
     $pdf = new PDF($title, $data, $headers, $sizes, $max_sizes);
     $pdf->Output($filename, 'I');
     //log the event
     $this->logger->info('{class_mame}|{method_name}|result|{result}|result_desc:{result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'result' => $result['result'], 'result_desc' => $result['resultDesc']));
 }
Exemplo n.º 16
0
 /**
  * Disable service
  *
  * @param string $service_id service id
  * @return bool TRUE if enable is successful, FALSE if enable fails
  */
 public function disable($service_id)
 {
     //get the serivce parameters from the database
     $response = self::getService($service_id);
     //confirm the status of the service
     if ($response['result'] != 0) {
         return $response;
     }
     //extract service data
     $service_data = $response['service'];
     if ($service_data->status == Config::get('SMS_SERVICE_OFF')) {
         return array('result' => 9, 'resultDesc' => 'Service already disabled.', 'service' => $service_data);
     }
     //check whether the service requires sending a request to SDP for on demand service type
     if ($service_data->service_type == Config::get('SMS_ON_DEMAND_SERVICE_TYPE')) {
         //send request to SDP if application
         $response = self::sendStopSmsNotification($service_data);
         if ($response['result'] == 0) {
             $service_data->status = Config::get('SMS_SERVICE_OFF');
             // disable
         } else {
             return $response;
             // return as is
         }
     } else {
         $service_data->status = Config::get('SMS_SERVICE_OFF');
         // disable
     }
     $response['service'] = $service_data;
     //update the database
     $response = self::saveServiceStatus($response);
     //update the configuration file - Future task
     //return
     return $response;
 }