Exemplo n.º 1
0
 public function getDecodeJson($key, $default = null)
 {
     ErrorHandler::start();
     $params = json_decode($this->getParam($key), $default);
     ErrorHandler::stop();
     return (array) $params;
 }
Exemplo n.º 2
0
 public function onSubmit()
 {
     ErrorHandler::stop();
     $config = Engine::getConfig();
     $config->setConfigFilename(TEMP_CONFIG_FILE);
     $done_config = $config->save(true);
     $done_htaccess = file_put_contents($this->htaccessFilename, "Options -Indexes\r\nRewriteEngine On\r\n#RewriteBase /\r\n#RewriteCond %{HTTPS} !on\r\n#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\r\n\r\nRewriteCond %{REQUEST_FILENAME} -f\r\nRewriteRule \\.(jp[e]?g|gif|png|css|js|ttf|woff|ico|bmp|pdf|doc[x]?)\$ - [L]\r\n\r\n#Redirect all files not match index.php\r\nRewriteCond %{REQUEST_FILENAME} !(.*)/index\\.php\$\r\nRewriteRule ^.*\$ index.php?current_engine_page=\$0 [L,NC,QSA]");
     if (!$done_htaccess || !$done_config || !in_array('mod_rewrite', apache_get_modules())) {
         $this->sendStatus(true, array($this->addName('write-error')));
     }
 }
Exemplo n.º 3
0
 /**
  * Use the glob function provided by the system.
  *
  * @param  string  $pattern
  * @param  int     $flags
  * @return array
  * @throws Exception\RuntimeException
  */
 protected static function systemGlob($pattern, $flags)
 {
     if ($flags) {
         $flagMap = array(self::GLOB_MARK => GLOB_MARK, self::GLOB_NOSORT => GLOB_NOSORT, self::GLOB_NOCHECK => GLOB_NOCHECK, self::GLOB_NOESCAPE => GLOB_NOESCAPE, self::GLOB_BRACE => GLOB_BRACE, self::GLOB_ONLYDIR => GLOB_ONLYDIR, self::GLOB_ERR => GLOB_ERR);
         $globFlags = 0;
         foreach ($flagMap as $internalFlag => $globFlag) {
             if ($flags & $internalFlag) {
                 $globFlags |= $globFlag;
             }
         }
     } else {
         $globFlags = 0;
     }
     ErrorHandler::start();
     $res = glob($pattern, $globFlags);
     $err = ErrorHandler::stop();
     if ($res === false) {
         throw new Exception\RuntimeException("glob('{$pattern}', {$globFlags}) failed", 0, $err);
     }
     return $res;
 }
Exemplo n.º 4
0
 public static function splitMessage($message, &$headers, &$body, $EOL = Mime\Mime::LINEEND, $strict = false)
 {
     if ($message instanceof Headers) {
         $message = $message->toString();
     }
     // check for valid header at first line
     $firstline = strtok($message, "\n");
     if (!preg_match('%^[^\\s]+[^:]*:%', $firstline)) {
         $headers = array();
         // TODO: we're ignoring \r for now - is this function fast enough and is it safe to assume noone needs \r?
         $body = str_replace(array("\r", "\n"), array('', $EOL), $message);
         return;
     }
     // see @ZF2-372, pops the first line off a message if it doesn't contain a header
     if (!$strict) {
         $parts = explode(':', $firstline, 2);
         if (count($parts) != 2) {
             $message = substr($message, strpos($message, $EOL) + 1);
         }
     }
     // find an empty line between headers and body
     // default is set new line
     if (strpos($message, $EOL . $EOL)) {
         list($headers, $body) = explode($EOL . $EOL, $message, 2);
         // next is the standard new line
     } elseif ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
         list($headers, $body) = explode("\r\n\r\n", $message, 2);
         // next is the other "standard" new line
     } elseif ($EOL != "\n" && strpos($message, "\n\n")) {
         list($headers, $body) = explode("\n\n", $message, 2);
         // at last resort find anything that looks like a new line
     } else {
         ErrorHandler::start(E_NOTICE | E_WARNING);
         list($headers, $body) = preg_split("%([\r\n]+)\\1%U", $message, 2);
         ErrorHandler::stop();
     }
     $headers = Headers::fromString($headers, $EOL);
 }