Beispiel #1
0
 /**
  * Search for array keys in a string and replaces them with the value
  */
 public static function render($value = "", $pairs = [], $open = "", $close = "")
 {
     $value = Sanitize::toString($value);
     $pairs = Sanitize::toArray($pairs);
     $open = self::value($open, "%");
     $close = self::value($close, "%");
     foreach ($pairs as $k => $v) {
         $value = str_replace($open . $k . $close, $v, $value);
     }
     return $value;
 }
Beispiel #2
0
 /**
  * Make sure all the globals are set
  */
 private function _cleanGlobals()
 {
     $_GET = Sanitize::toArray(@$_GET);
     $_POST = Sanitize::toArray(@$_POST);
     $_FILES = Sanitize::toArray(@$_FILES);
     $_COOKIE = Sanitize::toArray(@$_COOKIE);
     $_REQUEST = array_merge($_GET, $_POST);
 }
Beispiel #3
0
 /**
  * Send default response depending on request method and response type
  */
 public function sendDefault($status, $response = null, $data = [])
 {
     if (Connection::isMethod("GET")) {
         if (is_object($response)) {
             $this->sendView($status, $response);
         }
         if (is_array($response)) {
             $this->sendText($status, print_r($response, true));
         }
         if (is_string($response)) {
             if (is_file($response)) {
                 $this->sendTemplate($status, $response, $data);
             }
             $this->sendText($status, $response);
         }
         $this->sendText($status, "Empty response.");
     }
     $this->sendJson($status, array_merge(Sanitize::toArray($response), $data));
 }