Example #1
0
 /**
  * Creates a new instance of this builder element.
  */
 public static function create()
 {
     $o = new self();
     $o->setFileExtensions('php');
     $o->setFiles('${sourcesDir}');
     $o->setReportFullFile($GLOBALS['project']->getReportsWorkingDir() . CINTIENT_PHPCODESNIFFER_REPORT_FULL_FILE);
     $o->setReportXmlFile($GLOBALS['project']->getReportsWorkingDir() . CINTIENT_PHPCODESNIFFER_REPORT_XML_FILE);
     $o->setStandard('Zend');
     return $o;
 }
Example #2
0
 /**
  * Get an HTML-escaped Minify URI for a group or set of files
  * 
  * @param string|array $keyOrFiles a group key or array of filepaths/URIs
  * @param array $opts options:
  *   'farExpires' : (default true) append a modified timestamp for cache revving
  *   'debug' : (default false) append debug flag
  *   'charset' : (default 'UTF-8') for htmlspecialchars
  *   'minAppUri' : (default '/min') URI of min directory
  *   'rewriteWorks' : (default true) does mod_rewrite work in min app?
  *   'groupsConfigFile' : specify if different
  * @return string
  */
 public static function getUri($keyOrFiles, $opts = array())
 {
     $opts = array_merge(array('farExpires' => true, 'debug' => false, 'charset' => 'UTF-8', 'minAppUri' => '/min', 'rewriteWorks' => true, 'groupsConfigFile' => ''), $opts);
     $h = new self();
     $h->minAppUri = $opts['minAppUri'];
     $h->rewriteWorks = $opts['rewriteWorks'];
     $h->groupsConfigFile = $opts['groupsConfigFile'];
     if (is_array($keyOrFiles)) {
         $h->setFiles($keyOrFiles, $opts['farExpires']);
     } else {
         $h->setGroup($keyOrFiles, $opts['farExpires']);
     }
     $uri = $h->getRawUri($opts['farExpires'], $opts['debug']);
     return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
 }
Example #3
0
 /**
  * @param wfWAFRequest|null $request
  * @return wfWAFRequest
  */
 public static function createFromGlobals($request = null)
 {
     if ($request === null) {
         if (version_compare(phpversion(), '5.3.0') > 0) {
             $class = get_called_class();
             $request = new $class();
         } else {
             $request = new self();
         }
     }
     $request->setAuth(array());
     $request->setCookies(array());
     $request->setFileNames(array());
     $request->setFiles(array());
     $request->setHeaders(array());
     $request->setHost('');
     $request->setIP('');
     $request->setMethod('');
     $request->setPath('');
     $request->setProtocol('');
     $request->setTimestamp('');
     $request->setURI('');
     $request->setBody(wfWAFUtils::stripMagicQuotes($_POST));
     $request->setQueryString(wfWAFUtils::stripMagicQuotes($_GET));
     $request->setCookies(wfWAFUtils::stripMagicQuotes($_COOKIE));
     $request->setFiles(wfWAFUtils::stripMagicQuotes($_FILES));
     if (!empty($_FILES)) {
         $fileNames = array();
         foreach ($_FILES as $input => $file) {
             $fileNames[$input] = wfWAFUtils::stripMagicQuotes($file['name']);
         }
         $request->setFileNames($fileNames);
     }
     if (is_array($_SERVER)) {
         //All of these depend on $_SERVER being non-null and an array
         $auth = array();
         if (array_key_exists('PHP_AUTH_USER', $_SERVER)) {
             $auth['user'] = wfWAFUtils::stripMagicQuotes($_SERVER['PHP_AUTH_USER']);
         }
         if (array_key_exists('PHP_AUTH_PW', $_SERVER)) {
             $auth['password'] = wfWAFUtils::stripMagicQuotes($_SERVER['PHP_AUTH_PW']);
         }
         $request->setAuth($auth);
         if (array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
             $timestamp = $_SERVER['REQUEST_TIME_FLOAT'];
         } else {
             if (array_key_exists('REQUEST_TIME', $_SERVER)) {
                 $timestamp = $_SERVER['REQUEST_TIME'];
             } else {
                 $timestamp = time();
             }
         }
         $request->setTimestamp($timestamp);
         $headers = array();
         foreach ($_SERVER as $key => $value) {
             if (wfWAFUtils::strpos($key, 'HTTP_') === 0) {
                 $header = wfWAFUtils::substr($key, 5);
                 $header = str_replace(array(' ', '_'), array('', ' '), $header);
                 $header = ucwords(wfWAFUtils::strtolower($header));
                 $header = str_replace(' ', '-', $header);
                 $headers[$header] = wfWAFUtils::stripMagicQuotes($value);
             }
         }
         if (array_key_exists('CONTENT_TYPE', $_SERVER)) {
             $headers['Content-Type'] = wfWAFUtils::stripMagicQuotes($_SERVER['CONTENT_TYPE']);
         }
         if (array_key_exists('CONTENT_LENGTH', $_SERVER)) {
             $headers['Content-Length'] = wfWAFUtils::stripMagicQuotes($_SERVER['CONTENT_LENGTH']);
         }
         $request->setHeaders($headers);
         $host = '';
         if (array_key_exists('Host', $headers)) {
             $host = $headers['Host'];
         } else {
             if (array_key_exists('SERVER_NAME', $_SERVER)) {
                 $host = wfWAFUtils::stripMagicQuotes($_SERVER['SERVER_NAME']);
             }
         }
         $request->setHost($host);
         $request->setMethod(array_key_exists('REQUEST_METHOD', $_SERVER) ? wfWAFUtils::stripMagicQuotes($_SERVER['REQUEST_METHOD']) : 'GET');
         $request->setProtocol(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
         $request->setUri(array_key_exists('REQUEST_URI', $_SERVER) ? wfWAFUtils::stripMagicQuotes($_SERVER['REQUEST_URI']) : '');
         $uri = parse_url($request->getURI());
         if (is_array($uri) && array_key_exists('path', $uri)) {
             $path = $uri['path'];
         } else {
             $path = $request->getURI();
         }
         $request->setPath($path);
     }
     return $request;
 }