public function __construct(array $additional_uri_arguments)
 {
     //	Input
     //
     //		Request array
     //
     $request_parameters = $_REQUEST;
     $this->additional_uri_arguments = $additional_uri_arguments;
     //		JSON input
     //
     $posted_parameters = file_get_contents("php://input");
     if (isset($posted_parameters)) {
         $decoded_parameters = json_decode($posted_parameters, true);
         if (isset($decoded_parameters) && is_array($decoded_parameters)) {
             $request_parameters = array_merge($request_parameters, $decoded_parameters);
         }
     }
     //	Clean input
     //
     foreach ($request_parameters as $key => $value) {
         Cleaner::cleanInput($value);
     }
     foreach ($this->additional_uri_arguments as $value) {
         Cleaner::cleanInput($value);
     }
     //	Set property
     //
     $this->variables_array = $request_parameters;
     //  Notification controller
     //
     $this->notificationController = new NotificationController();
 }
 public static function cleanInput($input)
 {
     $clean_input = array();
     if (is_array($input)) {
         foreach ($input as $key => $value) {
             $clean_input[$key] = Cleaner::cleanInput($value);
         }
     } else {
         $clean_input = trim(strip_tags($input));
     }
     return $clean_input;
 }
 public function __construct($request_uri, $query_string = null, $origin)
 {
     /*
      *	Set header data
      */
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE');
     /*
      *	Set properties
      */
     $this->inputter = new Inputter(explode('/', rtrim($request_uri, '/')));
     $this->outputter = new JSONOutputter();
     $this->request_noun = strtolower(array_shift($this->inputter->additional_uri_arguments));
     /*
      *		Request verb
      *		
      *		If there is one additional argument which isn't numeric...
      */
     if (array_key_exists(0, $this->inputter->additional_uri_arguments) && !is_numeric($this->inputter->additional_uri_arguments[0])) {
         /*
          * ...Then assume it's the REST verb and remove it from the additional arguments
          */
         $this->request_verb = strtolower(array_shift($this->inputter->additional_uri_arguments));
     }
     /*
      *		HTTP method
      */
     $this->http_method = strtoupper($_SERVER[SERVER_REQUEST_METHOD]);
     if ($this->http_method == HTTP_METHOD_POST && array_key_exists(SERVER_HTTP_X_HTTP_METHOD, $_SERVER)) {
         if ($_SERVER[SERVER_HTTP_X_HTTP_METHOD] == HTTP_METHOD_DELETE) {
             $this->http_method = strtoupper(HTTP_METHOD_DELETE);
         } else {
             if ($_SERVER[SERVER_HTTP_X_HTTP_METHOD] == HTTP_METHOD_PUT) {
                 $this->http_method = strtoupper(HTTP_METHOD_PUT);
             } else {
                 throw new Exception('Unexpected header');
             }
         }
     }
     switch ($this->http_method) {
         case HTTP_METHOD_DELETE:
         case HTTP_METHOD_POST:
             $this->request = Cleaner::cleanInput($_POST);
             break;
         case HTTP_METHOD_GET:
             $this->request = Cleaner::cleanInput($_GET);
             break;
         case HTTP_METHOD_PUT:
             $this->request = Cleaner::cleanInput($_GET);
             break;
         default:
             $this->outputter->print_error(HTTP::http_status_description_for_http_status_code(HTTP_METHOD_NOT_ALLOWED), HTTP_METHOD_NOT_ALLOWED);
             break;
     }
 }