function index()
 {
     $variables = ORM::factory('private_gateway')->find_all();
     foreach ($variables as $variable) {
         $phonenumber = $variable->phonenumber_variable;
         $message = $variable->message_variable;
     }
     if (isset($_GET['key'])) {
         $private_gateway_key = $_GET['key'];
     }
     if (isset($_GET[$phonenumber])) {
         $message_from = $_GET[$phonenumber];
         // Remove non-numeric characters from string
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
     }
     if (isset($_GET[$message])) {
         $message_description = $_GET[$message];
     }
     if (!empty($private_gateway_key) and !empty($message_from) and !empty($message_description)) {
         // Is this a valid sync Key?
         $keycheck = ORM::factory('private_gateway')->where('private_gateway_key', $private_gateway_key)->find(1);
         if ($keycheck->loaded == TRUE) {
             sms::add($message_from, $message_description);
         }
     }
 }
Exemplo n.º 2
0
 function index()
 {
     $secret = "";
     if (isset($this->request['secret'])) {
         $secret = $this->request['secret'];
     }
     if (isset($this->request['from'])) {
         $message_from = $this->request['from'];
         // Remove non-numeric characters from string
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
     }
     if (isset($this->request['message'])) {
         $message_description = $this->request['message'];
     }
     if (!empty($message_from) and !empty($message_description)) {
         $secret_match = TRUE;
         // Is this a valid Secret?
         $smssync = ORM::factory('smssync')->find(1);
         if ($smssync->loaded) {
             $smssync_secret = $smssync->secret;
             if ($smssync_secret and $secret != $smssync_secret) {
                 // A Secret has been set and they don't match
                 $secret_match = FALSE;
             }
         } else {
             // Can't load table
             $secret_match = FALSE;
         }
         if ($secret_match) {
             sms::add($message_from, $message_description);
         }
     }
 }
Exemplo n.º 3
0
 function index()
 {
     $xmlstr = file_get_contents('php://input');
     $messagein = new SimpleXMLElement($xmlstr);
     $message_from = $messagein->From;
     $message_to = $messagein->To;
     $message_txt = $messagein->MessageText;
     sms::add($message_from, "{$message_txt}");
 }
Exemplo n.º 4
0
	function index()
	{
		$secret = "";		
		if (isset($this->request['secret']))
		{
			$secret = $this->request['secret'];
		}
		
		if (isset($this->request['from']))
		{
			$message_from = $this->request['from'];
			// Remove non-numeric characters from string
			$message_from = preg_replace("#[^0-9]#", "", $message_from);
		}
		
		if (isset($this->request['message']))
		{
			$message_description = $this->request['message'];
		}
		
		if ( ! empty($message_from) AND ! empty($message_description))
		{
			$secret_match = TRUE;
			
			// Is this a valid Secret?
			$smssync = ORM::factory('smssync_settings')
				->find(1);
			
			if ($smssync->loaded)
			{
				$smssync_secret = $smssync->smssync_secret;
				if ($smssync_secret AND $secret != $smssync_secret)
				{ // A Secret has been set and they don't match
					$secret_match = FALSE;
				}
			}
			else
			{ // Can't load table
				$secret_match = FALSE;
			}
			
			if ($secret_match)
			{
				sms::add($message_from, $message_description);
				echo json_encode(array("payload" => array("success" => "true")));
			}
			else
			{
				echo json_encode(array("payload" => array("success" => "false")));
			}
		}
		else
		{
			echo json_encode(array("payload" => array("success" => "false")));
		}
	}
Exemplo n.º 5
0
 private function _receive()
 {
     $secret = "";
     $success = "false";
     //Sometimes user send blank SMSs or GSM operators will
     //send promotional SMSs with no phone number, so this way
     //these messages will always end up on the backend and not float around
     //on the phones forever.
     $message_description = Kohana::lang("ui_main.empty");
     $message_from = "00000000";
     $non_numeric_source = false;
     if (isset($this->request['secret'])) {
         $secret = $this->request['secret'];
     }
     if (isset($this->request['from']) && strlen($this->request['from']) > 0) {
         $message_from = $this->request['from'];
         $original_from = $message_from;
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
         if (strlen($message_from) == 0) {
             $message_from = "00000000";
             $non_numeric_source = true;
         }
     }
     if (isset($this->request['message']) && strlen($this->request['message']) > 0) {
         $message_description = $this->request['message'];
     }
     if ($non_numeric_source) {
         $message_description = '<div style="color:red;">' . Kohana::lang("ui_main.message_non_numeric_source") . " \"" . $original_from . "\" </div>" . $message_description;
     }
     if (!empty($message_from) and !empty($message_description)) {
         $secret_match = TRUE;
         // Is this a valid Secret?
         $smssync = ORM::factory('smssync_settings')->find(1);
         if ($smssync->loaded) {
             $smssync_secret = $smssync->smssync_secret;
             if ($smssync_secret and $secret != $smssync_secret) {
                 // A Secret has been set and they don't match
                 $secret_match = FALSE;
             }
         } else {
             // No Secret Set
             $secret_match = TRUE;
         }
         if ($secret_match) {
             sms::add($message_from, $message_description);
             $success = "true";
         }
     }
     echo json_encode(array("payload" => array("success" => $success)));
 }
 /**
  * Processes incoming messages
  */
 public function inbound()
 {
     // Get the received data
     $data = array_merge($_GET, $_POST);
     // Verify the API key and incoming messageId parameters
     if (!empty($data['key']) and !empty($data['messageId']) and Nexmo_Model::is_valid_api_key($data['key'], 'inbound_message_key')) {
         // Extract fields from the submitted data
         $log_data = array('message_id' => $data['messageId'], 'message_type' => 1, 'message_sender' => $data['msisdn']);
         // Initialize model for updating the internal nexmo message log
         $log_entry = new Nexmo_Message_Log_Model();
         if ($log_entry->validate($log_data)) {
             // Success, save
             $log_entry->save();
         }
         //  Add entry to the main messages list
         sms::add($data['msisdn'], $data['text']);
     } else {
         Kohana::log('error', Kohana::lang('nexmo.invalid_url_auth_key'));
     }
 }
Exemplo n.º 7
0
 function index()
 {
     if (isset($_GET['key'])) {
         $frontlinesms_key = $_GET['key'];
     }
     if (isset($_GET['s'])) {
         $message_from = $_GET['s'];
         // Remove non-numeric characters from string
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
     }
     if (isset($_GET['m'])) {
         $message_description = $_GET['m'];
     }
     if (!empty($frontlinesms_key) and !empty($message_from) and !empty($message_description)) {
         // Is this a valid FrontlineSMS Key?
         $keycheck = ORM::factory('frontlinesms')->where('frontlinesms_key', $frontlinesms_key)->find(1);
         if ($keycheck->loaded == TRUE) {
             sms::add($message_from, $message_description);
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Clickatell 2 way callback handler
  * @param string $key (Unique key that prevents unauthorized access)
  * @return void
  */
 function index($key = NULL)
 {
     if (isset($this->request['from'])) {
         $message_from = $this->request['from'];
         // Remove non-numeric characters from string
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
     }
     if (isset($this->request['to'])) {
         $message_to = $this->request['to'];
         // Remove non-numeric characters from string
         $message_to = preg_replace("#[^0-9]#", "", $message_to);
     }
     if (isset($this->request['text'])) {
         $message_description = $this->request['text'];
     }
     if (!empty($message_from) and !empty($message_description)) {
         // Is this a valid Clickatell Key?
         $keycheck = ORM::factory('clickatell')->where('clickatell_key', $key)->find(1);
         if ($keycheck->loaded == TRUE) {
             sms::add($message_from, $message_description, $message_to);
         }
     }
 }
 /**
  * Receive SMS's via FrontlineSMS or via Mobile Phone Native Apps
  *
  * @return string
  */
 public function sms()
 {
     $reponse = array();
     // Validate User
     // Should either be authenticated or have app_key
     $username = isset($this->request['username']) ? $this->request['username'] : "";
     $password = isset($this->request['password']) ? $this->request['password'] : "";
     $app_key = isset($this->request['key']) ? $this->request['key'] : "";
     if ($user_id = $this->_login($username, $password)) {
         // Process POST
         // setup and initialize form field names
         $form = array('message_from' => '', 'message_description' => '', 'message_date' => '');
         /**
          * Instantiate Validation,
          * use $post, so we don't overwrite $_POST fields with our
          * own things
          */
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         /**
          * Add some rules, the input field, followed by a list of
          * checks, carried out in order.
          */
         $post->add_rules('message_from', 'required', 'numeric', 'length[6,20]');
         $post->add_rules('message_description', 'required', 'length[3,300]');
         $post->add_rules('message_date', 'date_mmddyyyy');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             sms::add($post->message_from, $post->message_description);
             // success!
             $reponse = array("payload" => array("domain" => $this->domain, "success" => "true"), "error" => $this->api_service->get_error_msg(0));
         } else {
             // Required parameters are missing or invalid
             $reponse = array("payload" => array("domain" => $this->domain, "success" => "false"), "error" => $this->api_service->get_error_msg(02));
         }
     } else {
         // Authentication Failed. Invalid User or App Key
         $reponse = array("payload" => array("domain" => $this->domain, "success" => "false"), "error" => $this->api_service->get_error_msg(05));
     }
     // Set the response data
     $this->response_data = $this->response_type == 'json' ? $this->array_as_json($reponse) : $this->array_as_xml($reponse, array());
 }