registerAutoload() public static method

"Pre-registers" our autoloader on the SPL stack.
public static registerAutoload ( )
示例#1
0
 protected function _initAutoload()
 {
     require_once 'htmlpurifier/HTMLPurifier/Bootstrap.php';
     HTMLPurifier_Bootstrap::registerAutoload();
     $moduleLoader = new Zend_Application_Module_Autoloader(array('namespace' => 'App', 'basePath' => APPLICATION_PATH));
     return $moduleLoader;
 }
示例#2
0
 public function _initFilter()
 {
     HTMLPurifier_Bootstrap::registerAutoload();
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Attr.EnableID', true);
     $config->set('HTML.Strict', true);
     Zend_Registry::set('purifier', new HTMLPurifier($config));
 }
示例#3
0
 public function __construct($options = null)
 {
     HTMLPurifier_Bootstrap::registerAutoload();
     $config = HTMLPurifier_Config::createDefault();
     $config->set('HTML.Strict', true);
     $config->set('Attr.EnableID', true);
     $config->set('Attr.IDPrefix', 'MyPrefix_');
     $this->purifier = new HTMLPurifier($config);
 }
示例#4
0
 public function init()
 {
     HTMLPurifier_Bootstrap::registerAutoload();
     $config = HTMLPurifier_Config::createDefault();
     foreach ($this->getOptions() as $k => $item) {
         $config->set(str_replace('_', '.', $k), $item);
     }
     Zend_Registry::set('HTMLPurifier', new HTMLPurifier($config));
 }
示例#5
0
 public function __construct($options = null)
 {
     // lista de chaves para $config->set($key, $value)
     HTMLPurifier_Bootstrap::registerAutoload();
     $config = HTMLPurifier_Config::createDefault();
     $config->set('HTML.Strict', true);
     $config->set('Attr.EnableID', true);
     $config->set('HTML.TargetBlank', true);
     // vídeos do youtube e object's do HTML
     $config->set('HTML.SafeObject', true);
     $config->set('Output.FlashCompat', true);
     $this->purifier = new HTMLPurifier($config);
 }
示例#6
0
 public function __construct($options = array())
 {
     if (self::$purifier !== null) {
         return;
     }
     \HTMLPurifier_Bootstrap::registerAutoload();
     $config = \HTMLPurifier_Config::createDefault();
     foreach ($options as $key => $val) {
         if ($val === '1' || $val === '') {
             $val = (bool) $val;
         }
         $config->set(str_replace('_', '.', $key), $val);
     }
     self::$purifier = new \BasePurifier($config);
 }
示例#7
0
 /**
  * Returns the singleton HTMLPurifier or a mock object
  *
  * @return HTMLPurifier|Piwik_HTMLPurifier
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         if (file_exists(PIWIK_INCLUDE_PATH . '/libs/HTMLPurifier.php')) {
             if (!class_exists('HTMLPurifier_Bootstrap', false)) {
                 HTMLPurifier_Bootstrap::registerAutoload();
             }
             $config = HTMLPurifier_Config::createDefault();
             $config->set('Cache.SerializerPath', PIWIK_USER_PATH . '/tmp/purifier');
             self::$instance = new HTMLPurifier($config);
         } else {
             $c = __CLASS__;
             self::$instance = new $c();
         }
     }
     return self::$instance;
 }
示例#8
0
<?php

/**
 * @file
 * Convenience file that registers autoload handler for HTML Purifier.
 * It also does some sanity checks.
 */
if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
    // We need unregister for our pre-registering functionality
    HTMLPurifier_Bootstrap::registerAutoload();
    if (function_exists('__autoload')) {
        // Be polite and ensure that userland autoload gets retained
        spl_autoload_register('__autoload');
    }
} elseif (!function_exists('__autoload')) {
    function __autoload($class)
    {
        return HTMLPurifier_Bootstrap::autoload($class);
    }
}
if (ini_get('zend.ze1_compatibility_mode')) {
    trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
}
// vim: et sw=4 sts=4
示例#9
0
function clear_xss($val)
{
    if ($GLOBALS['logged']['admin']) {
        return $val;
    }
    // HTML Purifier plugin
    global $oHtmlPurifier;
    require_once BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php';
    if (!isset($oHtmlPurifier)) {
        HTMLPurifier_Bootstrap::registerAutoload();
        $oConfig = HTMLPurifier_Config::createDefault();
        $oConfig->set('Cache.SerializerPath', rtrim(BX_DIRECTORY_PATH_CACHE, '/'));
        $oConfig->set('Cache.SerializerPermissions', 0777);
        $oConfig->set('HTML.SafeObject', 'true');
        $oConfig->set('Output.FlashCompat', 'true');
        $oConfig->set('HTML.FlashAllowFullScreen', 'true');
        if (getParam('sys_antispam_add_nofollow')) {
            $sHost = parse_url(BX_DOL_URL_ROOT, PHP_URL_HOST);
            $oConfig->set('URI.Host', $sHost);
            $oConfig->set('HTML.Nofollow', 'true');
        }
        if ($sSafeIframeRegexp = getParam('sys_safe_iframe_regexp')) {
            $oConfig->set('HTML.SafeIframe', 'true');
            $oConfig->set('URI.SafeIframeRegexp', $sSafeIframeRegexp);
        }
        $oConfig->set('Filter.Custom', array(new HTMLPurifier_Filter_LocalMovie(), new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe(), new HTMLPurifier_Filter_AddBxLinksClass()));
        $oDef = $oConfig->getHTMLDefinition(true);
        $oDef->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
        $oHtmlPurifier = new HTMLPurifier($oConfig);
    }
    return $oHtmlPurifier->purify($val);
}
示例#10
0
 public function getComments($parentId)
 {
     try {
         require_once 'HTMLPurifier/Bootstrap.php';
         if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
             // We need unregister for our pre-registering functionality
             HTMLPurifier_Bootstrap::registerAutoload();
             if (function_exists('__autoload')) {
                 // Be polite and ensure that userland autoload gets retained
                 spl_autoload_register('__autoload');
             }
         } elseif (!function_exists('__autoload')) {
             function __autoload($class)
             {
                 return HTMLPurifier_Bootstrap::autoload($class);
             }
         }
         $config = HTMLPurifier_Config::createDefault();
         $config->set('Core', 'Encoding', 'UTF-8');
         $config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
         $config->set('AutoFormat', 'RemoveEmpty', true);
         $config->set('AutoFormat', 'Linkify', false);
         $config->set('HTML', 'AllowedElements', array('a', 'ul', 'li', 'img'));
         $config->set('Cache', 'SerializerPath', $this->_controller->getEnv()->getMyTempDir() . '/HTMLPurifier');
         $table = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTable();
         $tableName = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTableName();
         $usersTableName = $this->_controller->getPermiso()->getUsersTableName();
         $select = $table->select()->setIntegrityCheck(false)->from($table)->from($usersTableName, array('name', 'firstname', 'lastname', 'nickname'))->where("{$tableName}.uid = {$usersTableName}.id")->where("parentId = '" . $parentId . "'")->where("approve = '1'")->order('cdate DESC');
         $items = $table->fetchAll($select);
         $list = array();
         foreach ($items as $item) {
             $row = $item->toArray();
             $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $parentId, Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS_SHARP);
             $row['uriDelete'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $purifier = new HTMLPurifier($config);
             $row['comment'] = $purifier->purify($item->comment);
             $list[] = $row;
         }
         return $list;
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Posts/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Posts_Exception('comment list section error', $exception);
     }
 }
示例#11
0
function clear_xss($val)
{
    if ($GLOBALS['logged']['admin']) {
        return $val;
    }
    // HTML Purifier plugin
    global $oHtmlPurifier;
    require_once BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php';
    if (!isset($oHtmlPurifier)) {
        HTMLPurifier_Bootstrap::registerAutoload();
        $oConfig = HTMLPurifier_Config::createDefault();
        $oConfig->set('HTML.SafeObject', 'true');
        $oConfig->set('Output.FlashCompat', 'true');
        $oConfig->set('HTML.FlashAllowFullScreen', 'true');
        $oConfig->set('Filter.Custom', array(new HTMLPurifier_Filter_LocalMovie()));
        $oConfig->set('Filter.Custom', array(new HTMLPurifier_Filter_YouTube()));
        $oConfig->set('Filter.Custom', array(new HTMLPurifier_Filter_YoutubeIframe()));
        $oDef = $oConfig->getHTMLDefinition(true);
        $oDef->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
        $oHtmlPurifier = new HTMLPurifier($oConfig);
    }
    return $oHtmlPurifier->purify($val);
}
示例#12
0
function clear_xss($val)
{
    // HTML Purifier plugin
    global $oHtmlPurifier;
    if (!isset($oHtmlPurifier) && !$GLOBALS['logged']['admin']) {
        require_once BX_DIRECTORY_PATH_PLUGINS . 'htmlpurifier/HTMLPurifier.standalone.php';
        HTMLPurifier_Bootstrap::registerAutoload();
        $oConfig = HTMLPurifier_Config::createDefault();
        $oConfig->set('Cache.SerializerPath', rtrim(BX_DIRECTORY_PATH_CACHE, '/'));
        $oConfig->set('Cache.SerializerPermissions', 0777);
        $oConfig->set('HTML.SafeObject', 'true');
        $oConfig->set('Output.FlashCompat', 'true');
        $oConfig->set('HTML.FlashAllowFullScreen', 'true');
        if (getParam('sys_antispam_add_nofollow')) {
            $sHost = parse_url(BX_DOL_URL_ROOT, PHP_URL_HOST);
            $oConfig->set('URI.Host', $sHost);
            $oConfig->set('HTML.Nofollow', 'true');
        }
        if ($sSafeIframeRegexp = getParam('sys_safe_iframe_regexp')) {
            $oConfig->set('HTML.SafeIframe', 'true');
            $oConfig->set('URI.SafeIframeRegexp', $sSafeIframeRegexp);
        }
        $oConfig->set('Filter.Custom', array(new HTMLPurifier_Filter_LocalMovie(), new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe(), new HTMLPurifier_Filter_AddBxLinksClass()));
        $oConfig->set('HTML.DefinitionID', 'html5-definitions');
        $oConfig->set('HTML.DefinitionRev', 1);
        if ($def = $oConfig->maybeGetRawHTMLDefinition()) {
            $def->addElement('section', 'Block', 'Flow', 'Common');
            $def->addElement('nav', 'Block', 'Flow', 'Common');
            $def->addElement('article', 'Block', 'Flow', 'Common');
            $def->addElement('aside', 'Block', 'Flow', 'Common');
            $def->addElement('header', 'Block', 'Flow', 'Common');
            $def->addElement('footer', 'Block', 'Flow', 'Common');
            $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array('src' => 'URI', 'type' => 'Text', 'width' => 'Length', 'height' => 'Length', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool'));
            $def->addElement('source', 'Block', 'Flow', 'Common', array('src' => 'URI', 'type' => 'Text'));
        }
        $oHtmlPurifier = new HTMLPurifier($oConfig);
    }
    if (!$GLOBALS['logged']['admin']) {
        $val = $oHtmlPurifier->purify($val);
    }
    $oZ = new BxDolAlerts('system', 'clear_xss', 0, 0, array('oHtmlPurifier' => $oHtmlPurifier, 'return_data' => &$val));
    $oZ->alert();
    return $val;
}