Example #1
0
 /**
  * Direct invocation of the constructor is not permitted.
  */
 protected function __construct(array $config)
 {
     $this->_dir = \RX_BASEDIR . 'files/cache/store';
     if (!Storage::isDirectory($this->_dir)) {
         Storage::createDirectory($this->_dir);
     }
 }
Example #2
0
 /**
  * Direct invocation of the constructor is not permitted.
  */
 protected function __construct()
 {
     $dir = \RX_BASEDIR . 'files/cache/store';
     if (!Storage::isDirectory($dir)) {
         Storage::createDirectory($dir);
     }
     $key = substr(hash_hmac('sha256', $dir, config('crypto.authentication_key')), 0, 32);
     $filename = "{$dir}/{$key}.db";
     if (Storage::exists($filename)) {
         $this->_connect($filename);
     } else {
         $this->_connect($filename);
         for ($i = 0; $i < 32; $i++) {
             $this->_dbh->exec('CREATE TABLE cache_' . $i . ' (k TEXT PRIMARY KEY, v TEXT, exp INT)');
         }
     }
 }
Example #3
0
 /**
  * Get an instance of HTMLPurifier.
  * 
  * @return object
  */
 public static function getHTMLPurifier()
 {
     // Create an instance with reasonable defaults.
     if (self::$_htmlpurifier === null) {
         // Get the default configuration.
         $config = \HTMLPurifier_Config::createDefault();
         // Customize the default configuration.
         $config->set('Attr.AllowedFrameTargets', array('_blank'));
         $config->set('Attr.DefaultImageAlt', '');
         $config->set('Attr.EnableID', true);
         $config->set('Attr.IDPrefix', 'user_content_');
         $config->set('AutoFormat.AutoParagraph', false);
         $config->set('AutoFormat.DisplayLinkURI', false);
         $config->set('AutoFormat.Linkify', false);
         $config->set('Core.Encoding', 'UTF-8');
         $config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
         $config->set('HTML.FlashAllowFullScreen', true);
         $config->set('HTML.MaxImgLength', null);
         $config->set('CSS.MaxImgLength', null);
         $config->set('CSS.Proprietary', true);
         $config->set('Output.FlashCompat', true);
         $config->set('Output.Newline', "\n");
         $config->set('URI.MakeAbsolute', false);
         // Allow embedding of external multimedia content.
         $config->set('HTML.SafeEmbed', true);
         $config->set('HTML.SafeIframe', true);
         $config->set('HTML.SafeObject', true);
         $config->set('URI.SafeIframeRegexp', MediaFilter::getIframeWhitelistRegex());
         // Set the serializer path.
         $config->set('Cache.SerializerPath', \RX_BASEDIR . 'files/cache/htmlpurifier');
         Storage::createDirectory(\RX_BASEDIR . 'files/cache/htmlpurifier');
         // Modify the HTML definition to support editor components and widgets.
         $def = $config->getHTMLDefinition(true);
         $def->addAttribute('img', 'editor_component', 'Text');
         $def->addAttribute('div', 'editor_component', 'Text');
         $def->addAttribute('img', 'rx_encoded_properties', 'Text');
         $def->addAttribute('div', 'rx_encoded_properties', 'Text');
         // Support HTML5 and CSS3.
         self::_supportHTML5($config);
         self::_supportCSS3($config);
         // Cache our instance of HTMLPurifier.
         self::$_htmlpurifier = new \HTMLPurifier($config);
     }
     // Return the cached instance.
     return self::$_htmlpurifier;
 }