コード例 #1
0
/**
 * 
 * @param string $content
 * @return string
 */
function doFilterFrontendJs($sContent)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        global $database, $wb;
        $sql = 'SELECT DISTINCT `module` FROM `' . TABLE_PREFIX . 'sections` ' . 'WHERE `page_id` = ' . (int) $wb->page['page_id'];
        if ($oModuleList = $database->query($sql)) {
            while ($aModules = $oModuleList->fetchRow(MYSQLI_ASSOC)) {
                $sFrontendJsFile = '/modules/' . $aModules['module'] . '/frontend.js';
                if (!is_readable(WB_PATH . $sFrontendJsFile)) {
                    $sFrontendJsFile = '/modules/' . $aModules['module'] . '/js/frontend.js';
                    if (!is_readable(WB_PATH . $sFrontendJsFile)) {
                        continue;
                    }
                }
                $sPattern = '/<head.*?<script.*?src\\s*?=\\s*?\\"' . preg_quote(WB_URL . $sFrontendJsFile, '/') . '\\"[^>]*?>.*?<\\/head>/si';
                if (preg_match($sPattern, $sContent)) {
                    continue;
                }
                $sPattern = '/(<head.*<\\/script>)(.*?<\\/head>)/si';
                $sReplacement = '$1' . "\n" . '<script src="' . WB_URL . $sFrontendJsFile . '" type="text/javascript"></script>' . '$2';
                $sContent = preg_replace($sPattern, $sReplacement, $sContent);
            }
        }
    }
    return $sContent;
}
コード例 #2
0
/**
 * moves all css definitions from <body> into <head> section
 * @copyright       Manuela v.d.Decken <*****@*****.**>
 * @author          Manuela v.d.Decken <*****@*****.**>
 * @param string $content
 * @return string
 */
function doFilterCssToHead($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        // move css definitions into head section
        $pattern1 = '/(?:<body.*?)(<link[^>]*?\\"text\\/css\\".*?\\/>)/si';
        $pattern2 = '/(?:<body.*?)(<style[^>]*?\\"text\\/css\\"[^>]*?>.*?<\\/style>)/si';
        while (preg_match($pattern1, $content, $matches) == 1) {
            // loop through all linked CSS
            $insert = $matches[1];
            $content = str_replace($insert, '', $content);
            $insert = "\n" . $insert . "\n</head>\n<body";
            $content = preg_replace('/<\\/head>.*?<body/si', $insert, $content);
        }
        while (preg_match($pattern2, $content, $matches) == 1) {
            // loop through all inline CSS
            $insert = $matches[1];
            $content = str_replace($insert, '', $content);
            $insert = "\n" . $insert . "\n</head>\n<body";
            $content = preg_replace('/<\\/head>.*?<body/si', $insert, $content);
        }
    }
    return $content;
}
コード例 #3
0
/**
 * Convert full qualified, local URLs into relative URLs
 * @copyright       Manuela v.d.Decken <*****@*****.**>
 * @author          Manuela v.d.Decken <*****@*****.**>
 * @param string $sContent
 * @return string
 */
function doFilterRelUrl($sContent)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        $sAppUrl = rtrim(str_replace('\\', '/', WB_URL), '/') . '/';
        $sAppPath = rtrim(str_replace('\\', '/', WB_PATH), '/') . '/';
        $sContent = preg_replace_callback('/((?:href|src)\\s*=\\s*")([^\\?\\"]+?)/isU', function ($aMatches) use($sAppUrl, $sAppPath) {
            $sAppRel = preg_replace('/^https?:\\/\\/[^\\/]*(.*)$/is', '$1', $sAppUrl);
            $aMatches[2] = str_replace('\\', '/', $aMatches[2]);
            $aMatches[2] = preg_replace('/^' . preg_quote($sAppUrl, '/') . '/is', '', $aMatches[2]);
            $aMatches[2] = preg_replace('/(\\.+\\/)|(\\/+)/', '/', $aMatches[2]);
            if (!is_readable($sAppPath . $aMatches[2])) {
                // in case of death link show original link
                return $aMatches[0];
            } else {
                return $aMatches[1] . $sAppRel . $aMatches[2];
            }
        }, $sContent);
        // restore canonical relation links
        $sContent = preg_replace_callback('/<link\\s[^>]*?\\"canonical\\"[^>]*?>/isU', function ($aMatches) use($sAppUrl) {
            return preg_replace('/(href\\s*=\\s*\\")([^\\"]*?)/siU', '\\1' . rtrim($sAppUrl, '/') . '\\2', $aMatches[0]);
        }, $sContent);
    }
    return $sContent;
}
コード例 #4
0
function doFilterOpF($content, $sOptions)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        global $database;
        $aOptions = array();
        // Load OutputFilter functions
        $sOpfFile = WB_PATH . '/modules/outputfilter_dashboard/functions.php';
        if (is_readable($sOpfFile)) {
            if (!function_exists('opf_apply_filters')) {
                require $sOpfFile;
            }
            parse_str($sOptions, $aOptions);
            $aPresets = array('arg' => 'page', 'module' => '', 'page_id' => 0, 'section_id' => 0);
            $aOptions = array_merge($aPresets, $aOptions);
            // use 'cache' instead of 'nocache' to enable page-cache.
            // Do not use 'cache' in case you use dynamic contents (e.g. snippets)!
            if (!isset($GLOBALS['opf_FILTERS'])) {
                // initialize filter at first run
                opf_controller('init');
            }
            $content = opf_controller($aOptions['arg'], $content, $aOptions['module'], $aOptions['page_id'], $aOptions['section_id']);
        }
    }
    return $content;
}
コード例 #5
0
/**
 * Replaces {SYSVAR:MEDIAREL} tags with it's real path
 * @copyright       Manuela v.d.Decken <*****@*****.**>
 * @author          Manuela v.d.Decken <*****@*****.**>
 * @param string $sContent
 * @return string
 */
function doFilterSysvarMedia($sContent)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        $sMediaUrl = WB_URL . MEDIA_DIRECTORY;
        $sContent = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl, $sContent);
    }
    return $sContent;
}
コード例 #6
0
/**
 * 
 * @param string $content
 * @return string
 */
function doFilterScriptVars($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        if (!preg_match('/<head.*<.*src=\\".*\\/domReady.js.*>.*<\\/head/siU', $content)) {
            $scriptLink = "<script type=\"text/javascript\">" . "<!--\n" . "var URL = '" . WB_URL . "';\n" . "var WB_URL = '" . WB_URL . "';\n" . "var THEME_URL = '" . THEME_URL . "';\n" . "var TEMPLATE_DIR = '" . TEMPLATE_DIR . "';\n" . "var TEMPLATE = '" . TEMPLATE . "';\n" . "var EDITOR = '" . WYSIWYG_EDITOR . "';\n" . "-->\n" . "</script>\n";
            $regex = '/(.*)(<\\s*?\\/\\s*?head\\s*>.*)/isU';
            $replace = '$1' . $scriptLink . '$2';
            $content = preg_replace($regex, $replace, $content);
        }
    }
    return $content;
}
コード例 #7
0
/**
 * execute droplets
 * @copyright       Manuela v.d.Decken <*****@*****.**>
 * @author          Manuela v.d.Decken <*****@*****.**>
 * @param string $content
 * @return string
 */
function doFilterDroplets($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        if (file_exists(WB_PATH . '/modules/droplets/droplets.php')) {
            include_once WB_PATH . '/modules/droplets/droplets.php';
            if (function_exists('evalDroplets')) {
                $content = evalDroplets($content);
            }
        }
    }
    return $content;
}
コード例 #8
0
/**
 * 
 * @param string $content
 * @return string
 */
function doFilterLoadOnFly($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        if (!preg_match('/<head.*<.*src=\\".*\\/domReady.js.*>.*<\\/head/siU', $content)) {
            $scriptLink = '<script src="' . WB_URL . '/include/jquery/domReady.js" type="text/javascript"></script>' . "\n";
            $scriptLink .= '<script src="' . WB_URL . '/include/jquery/LoadOnFly.js" type="text/javascript"></script>' . "\n";
            $regex = '/(.*)(<\\s*?\\/\\s*?head\\s*>.*)/isU';
            $replace = '$1' . $scriptLink . '$2';
            $content = preg_replace($regex, $replace, $content);
        }
    }
    return $content;
}
コード例 #9
0
/**
 * execute the frontend output filter to modify email addresses
 * @param string actual content
 * @return string modified content
 */
function executeFrontendOutputFilter($content)
{
    // get output filter settings from database
    $filter_settings = getOutputFilterSettings();
    $sFilterDirectory = str_replace('\\', '/', dirname(__FILE__)) . '/filters/';
    $output_filter_mode = 0;
    $output_filter_mode |= $filter_settings['email_filter'] * pow(2, 0);
    // n | 2^0
    $output_filter_mode |= $filter_settings['mailto_filter'] * pow(2, 1);
    // n | 2^1
    if (!defined('OUTPUT_FILTER_AT_REPLACEMENT')) {
        define('OUTPUT_FILTER_AT_REPLACEMENT', $filter_settings['at_replacement']);
    }
    if (!defined('OUTPUT_FILTER_DOT_REPLACEMENT')) {
        define('OUTPUT_FILTER_DOT_REPLACEMENT', $filter_settings['dot_replacement']);
    }
    /* ### filter type: execute droplets filter ################################# */
    if (file_exists($sFilterDirectory . 'filterDroplets.php')) {
        require_once $sFilterDirectory . 'filterDroplets.php';
        $content = doFilterDroplets($content);
    }
    /* ### filter type: protect email addresses ################################# */
    if ($output_filter_mode & pow(2, 0) || $output_filter_mode & pow(2, 1)) {
        if (file_exists($sFilterDirectory . 'filterEmail.php')) {
            require_once $sFilterDirectory . 'filterEmail.php';
            $content = doFilterEmail($content, $output_filter_mode);
        }
    }
    /* ### filter type: change [wblinkxx] into real URLs ######################## */
    if (file_exists($sFilterDirectory . 'filterWbLink.php')) {
        require_once $sFilterDirectory . 'filterWbLink.php';
        $content = doFilterWbLink($content);
    }
    /* ### filter type: full qualified URLs to relative URLs##################### */
    if ($filter_settings['sys_rel'] == 1) {
        if (file_exists($sFilterDirectory . 'filterRelUrl.php')) {
            require_once $sFilterDirectory . 'filterRelUrl.php';
            $content = doFilterRelUrl($content);
        }
    }
    /* ### filter type: moves css definitions from <body> into <head> ########### */
    if (file_exists($sFilterDirectory . 'filterCssToHead.php')) {
        require_once $sFilterDirectory . 'filterCssToHead.php';
        $content = doFilterCssToHead($content);
    }
    /* ### end of filters ####################################################### */
    return $content;
}
コード例 #10
0
/**
 * protect email addresses (replace '@' and '.' and obfuscate address
 * @param string $content
 * @return string
 */
function doFilterJquery($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        if (!preg_match('/<head.*<.*src=\\".*\\/jquery-min.js.*>.*<\\/head/siU', $content)) {
            $scriptLink = '<script src="' . WB_URL . '/include/jquery/jquery-min.js" type="text/javascript"></script>' . "\n";
            $scriptLink .= '<script src="' . WB_URL . '/include/jquery/jquery-insert.js" type="text/javascript"></script>' . "\n";
            $scriptLink .= '<script src="' . WB_URL . '/include/jquery/jquery-include.js" type="text/javascript"></script>' . "\n";
            $sJqueryThemeRel = '/templates/' . TEMPLATE . '/jquery/jquery_theme.js';
            $scriptLink .= file_exists(WB_PATH . $sJqueryThemeRel) ? '<script src="' . WB_URL . $sJqueryThemeRel . '" type="text/javascript"></script>' . "\n" : '<script src="' . WB_URL . '/include/jquery/jquery_theme.js" type="text/javascript"></script>' . "\n";
            $regex = '/(.*)(<\\s*?\\/\\s*?head\\s*>.*)/isU';
            $replace = '$1' . $scriptLink . '$2';
            $content = preg_replace($regex, $replace, $content);
        }
    }
    return $content;
}
コード例 #11
0
function doFilterWbLink($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        global $database;
        $pattern = '/\\[wblink([0-9]+)\\]/isU';
        if (preg_match_all($pattern, $content, $aMatches, PREG_SET_ORDER)) {
            $aSearchReplaceList = array();
            foreach ($aMatches as $aMatch) {
                // collect matches formatted like '[wblink123]' => 123
                $aSearchReplaceList[strtolower($aMatch[0])] = $aMatch[1];
            }
            // build list of PageIds for SQL query
            $sPageIdList = implode(',', $aSearchReplaceList);
            // '123,124,125'
            // replace all PageIds with '#' (stay on page death link)
            array_walk($aSearchReplaceList, function (&$value, $index) {
                $value = '#';
            });
            $sql = 'SELECT `page_id`, `link` FROM `' . TABLE_PREFIX . 'pages` ' . 'WHERE `page_id` IN(' . $sPageIdList . ')';
            if ($oPages = $database->query($sql)) {
                while ($aPage = $oPages->fetchRow(MYSQLI_ASSOC)) {
                    $aPage['link'] = $aPage['link'] ? PAGES_DIRECTORY . $aPage['link'] . PAGE_EXTENSION : '#';
                    // collect all search-replace pairs with valid links
                    if (is_readable(WB_PATH . $aPage['link'])) {
                        // replace death link with found and valide link
                        $aSearchReplaceList['[wblink' . $aPage['page_id'] . ']'] = WB_URL . $aPage['link'];
                    }
                }
            }
            // replace all found [wblink**] tags with their urls
            $content = str_ireplace(array_keys($aSearchReplaceList), $aSearchReplaceList, $content);
        }
    }
    return $content;
}
コード例 #12
0
/**
 * Convert full qualified, local URLs into relative URLs
 * @copyright       Manuela v.d.Decken <*****@*****.**>
 * @author          Manuela v.d.Decken <*****@*****.**>
 * @param string $sContent
 * @return string
 */
function doFilterCanonical($sContent)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        $sAppUrl = rtrim(str_replace('\\', '/', WB_URL), '/');
        /**
        * 
                   // restore canonical relation links
                   $pattern = '/(<link\s*?.*?(?:rel\s*?=\s*?"canonical"\s*?)?.*?href\s*?=\s*?")([^\"]*?)(\"\s*?.*?(?:rel\s*?=\s*?"canonical"\s*?)?[^>]*?>)/isU'; 
                   $replace = '\1'.rtrim($sAppUrl,'/').'\2\3'; 
                   $sContent = preg_replace( $pattern, $replace, $sContent );
        */
        // restore canonical relation links
        $sContent = preg_replace_callback('/(<link\\s*?.*?(?:rel\\s*?=\\s*?"canonical"\\s*?)?.*?href\\s*?=\\s*?")' . '([^\\"]*?)(\\"\\s*?.*?(?:rel\\s*?=\\s*?"canonical"\\s*?)?[^>]*?>)/siU', function ($aMatches) use($sAppUrl) {
            $aMatches[2] = str_replace('\\', '/', $aMatches[2]);
            if (mb_substr($aMatches[2], 0, 1) == '/') {
                return '$1' . rtrim($sAppUrl, '/') . '$2$3';
            }
            return $aMatches[0];
        }, $sContent);
    }
    return $sContent;
}
コード例 #13
0
/**
 * protect email addresses (replace '@' and '.' and obfuscate address
 * @param string $content
 * @return string
 */
function doFilterEmail($content)
{
    $aFilterSettings = getOutputFilterSettings();
    $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', __FILE__);
    if ($aFilterSettings[$key]) {
        if ($aFilterSettings['OutputFilterMode'] == 0 && $aFilterSettings['at_replacement'] == '@' && $aFilterSettings['dot_replacement'] == '.') {
            return $content;
        }
        // test if js-decryption is installed
        if (preg_match('/<head.*<.*src=\\".*\\/mdcr.js.*>.*<\\/head/siU', $content)) {
            $aFilterSettings['OutputFilterMode'] |= pow(2, 2);
            // n | 2^2
        } else {
            // try to insert js-decrypt into <head> if available
            $script = str_replace('\\', '/', str_replace(WB_PATH, '', dirname(__DIR__)) . '/js/mdcr.js');
            if (is_readable(WB_PATH . $script)) {
                $scriptLink = '<script src="' . WB_URL . $script . '" type="text/javascript"></script>' . "\n";
                $regex = '/(.*)(<\\s*?\\/\\s*?head\\s*>.*)/isU';
                $replace = '$1' . $scriptLink . '$2';
                $content = preg_replace($regex, $replace, $content);
                $aFilterSettings['OutputFilterMode'] |= pow(2, 2);
                // n | 2^2
            }
        }
        /* *** obfuscate mailto addresses by js:mdcr *** */
        // work out the defined output filter mode: possible output filter modes: [0], 1, 2, 3, 6, 7
        // 2^0 * (0.. disable, 1.. enable) filtering of mail addresses in text
        // 2^1 * (0.. disable, 1.. enable) filtering of mail addresses in mailto links
        // 2^2 * (0.. disable, 1.. enable) Javascript mailto encryption (only if mailto filtering enabled)
        // first search part to find all mailto email addresses
        $pattern = '#(<a[^<]*href\\s*?=\\s*?"\\s*?mailto\\s*?:\\s*?)([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,4})([^"]*?)"([^>]*>)(.*?)</a>';
        // second part to find all non mailto email addresses
        $pattern .= '|(value\\s*=\\s*"|\')??\\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,4})\\b#i';
        /*
        (<a[^<]*href\s*?=\s*?"\s*?mailto\s*?:\s*?)([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})([^"]*?)"([^>]*>)(.*?)</a>|(value\s*=\s*"|\')??\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b
                Sub 1:\b(<a.[^<]*href\s*?=\s*?"\s*?mailto\s*?:\s*?)            -->    "<a id="yyy" class="xxx" href = " mailto :" ignoring white spaces
                Sub 2:([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})            -->    the email address in the mailto: part of the mail link
                Sub 3:([^"]*?)"                                                --> possible ?Subject&cc... stuff attached to the mail address
                Sub 4:([^>]*>)                                                --> all class or id statements after the mailto but before closing ..>
                Sub 5:(.*?)</a>\b                                            --> the mailto text; all characters between >xxxxx</a>
                Sub 6:|\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b        --> email addresses which may appear in the text (require word boundaries)
        */
        // find all email addresses embedded in the content and filter them using a callback function
        $content = preg_replace_callback($pattern, function ($match) use($aFilterSettings) {
            // check if required arguments are defined
            $search = array('@', '.');
            $replace = array($aFilterSettings['at_replacement'], $aFilterSettings['dot_replacement']);
            // check if the match contains the expected number of subpatterns (6|8)
            switch (count($match)) {
                case 8:
                    /** OUTPUT FILTER FOR EMAIL ADDRESSES EMBEDDED IN TEXT **/
                    // 1.. text mails only, 3.. text mails + mailto (no JS), 7 text mails + mailto (JS)
                    if (!in_array($aFilterSettings['OutputFilterMode'], array(1, 3, 5, 7))) {
                        return $match[0];
                    }
                    // do not filter mail addresses included in input tags (<input ... value = "test@mail)
                    if (strpos($match[6], 'value') !== false) {
                        return $match[0];
                    }
                    // filtering of non mailto email addresses enabled
                    return str_replace($search, $replace, $match[0]);
                    break;
                case 6:
                    /** OUTPUT FILTER FOR EMAIL ADDRESSES EMBEDDED IN MAILTO LINKS **/
                    // 2.. mailto only (no JS), 3.. text mails + mailto (no JS), 6.. mailto only (JS), 7.. all filters active
                    if (!in_array($aFilterSettings['OutputFilterMode'], array(2, 3, 6, 7))) {
                        return $match[0];
                    }
                    // check if last part of the a href link: >xxxx</a> contains a email address we need to filter
                    $pattern = '#[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,4}#i';
                    if (preg_match_all($pattern, $match[5], $matches)) {
                        foreach ($matches as $submatch) {
                            foreach ($submatch as $value) {
                                // replace all . and all @ in email address parts by (dot) and (at) strings
                                $match[5] = str_replace($value, str_replace($search, $replace, $value), $match[5]);
                            }
                        }
                    }
                    // check if Javascript encryption routine is enabled
                    if (in_array($aFilterSettings['OutputFilterMode'], array(6, 7))) {
                        /** USE JAVASCRIPT ENCRYPTION FOR MAILTO LINKS **/
                        // extract possible class and id attribute from ahref link
                        preg_match('/class\\s*?=\\s*?("|\')(.*?)\\1/ix', $match[0], $class_attr);
                        $class_attr = empty($class_attr) ? '' : 'class="' . $class_attr[2] . '" ';
                        preg_match('/id\\s*?=\\s*?("|\')(.*?)\\1/ix', $match[0], $id_attr);
                        $id_attr = empty($id_attr) ? '' : 'id="' . $id_attr[2] . '" ';
                        // preprocess mailto link parts for further usage
                        $search = array('@', '.', '_', '-');
                        $replace = array('F', 'Z', 'X', 'K');
                        $email_address = str_replace($search, $replace, strtolower($match[2]));
                        $email_subject = rawurlencode(html_entity_decode($match[3]));
                        // create a random encryption key for the Caesar cipher
                        mt_srand((double) microtime() * 1000000);
                        // (PHP < 4.2.0)
                        $shift = mt_rand(1, 25);
                        // encrypt the email using an adapted Caesar cipher
                        $encrypted_email = "";
                        for ($i = strlen($email_address) - 1; $i > -1; $i--) {
                            if (preg_match('#[FZXK0-9]#', $email_address[$i], $characters)) {
                                $encrypted_email .= $email_address[$i];
                            } else {
                                $encrypted_email .= chr((ord($email_address[$i]) - 97 + $shift) % 26 + 97);
                            }
                        }
                        $encrypted_email .= chr($shift + 97);
                        // build the encrypted Javascript mailto link
                        $mailto_link = "<a {$class_attr}{$id_attr}href=\"javascript:mdcr('{$encrypted_email}','{$email_subject}')\">" . $match[5] . "</a>";
                        return $mailto_link;
                    } else {
                        /** DO NOT USE JAVASCRIPT ENCRYPTION FOR MAILTO LINKS **/
                        // as minimum protection, replace @ in the mailto part by (at)
                        // dots are not transformed as this would transform my.name@domain.com into: my(dot)name(at)domain(dot)com
                        // rebuild the mailto link from the subpatterns (at the missing characters " and </a>")
                        return $match[1] . str_replace('@', $aFilterSettings['at_replacement'], $match[2]) . $match[3] . '"' . $match[4] . $match[5] . '</a>';
                        // if you want to protect both, @ and dots, comment out the line above and remove the comment from the line below
                        // return $match[1] .str_replace($search, $replace, $match[2]) .$match[3] .'"' .$match[4] .$match[5] .'</a>';
                    }
                    break;
                default:
                    // number of subpatterns do not match the requirements ... do nothing
                    return $match[0];
                    break;
            }
        }, $content);
    }
    return $content;
}
コード例 #14
0
// PARSE FORM TEMPLATE
// *******************
$tpl->parse('form', 'main_block', true);
$tpl->pparse('output', 'form');
// Initialize js to toggle customer/shipping state text field/select list
if ($_SESSION['bakery']['ship_form']) {
    echo "<script type='text/javascript'>\n\t\t<!--\n\t\tmod_bakery_toggle_state_f('{$select_shop_country}', 'cust', 0);\n\t\tmod_bakery_toggle_state_f('{$select_shop_country}', 'ship', 0);\n\t\t-->\n\t</script>\n\t";
} else {
    echo "<script type='text/javascript'>\n\t\t<!--\n\t\tmod_bakery_toggle_state_f('{$select_shop_country}', 'cust', 0);\n\t\t-->\n\t</script>\n\t";
}
// Code below is deprecated and stoped droplets working (only used for WB < 2.8.1)
if (version_compare(WB_VERSION, '2.8.1') < 0) {
    // Obtain the settings of the output filter module
    if (file_exists(WB_PATH . '/modules/output_filter/filter-routines.php')) {
        include_once WB_PATH . '/modules/output_filter/filter-routines.php';
        if (function_exists('getOutputFilterSettings')) {
            $filter_settings = getOutputFilterSettings();
        } else {
            $filter_settings = get_output_filter_settings();
        }
    } else {
        // No output filter used, define default settings
        $filter_settings['email_filter'] = 0;
    }
    // NOTE:
    // With ob_end_flush() the output filter will be disabled for Bakery address form page
    // If you are using e.g. ob_start in the index.php of your template it is possible that you will indicate problems
    if ($filter_settings['email_filter'] && !($filter_settings['at_replacement'] == '@' && $filter_settings['dot_replacement'] == '.')) {
        ob_end_flush();
    }
}
コード例 #15
0
 function register_frontend_modfiles($file_id = "css")
 {
     // sanity check of parameter passed to the function
     $file_id = strtolower($file_id);
     $aAllowedAction = array('css', 'script', 'js', 'jquery', 'javascript');
     if (!in_array($file_id, $aAllowedAction)) {
         return false;
     }
     global $wb, $database, $include_head_link_css, $include_head_links, $page_id;
     // define default baselink and filename for optional module javascript and stylesheet files
     $head_links = "";
     $base_file = '';
     $base_link = '';
     switch ($file_id) {
         case 'css':
             $base_link = '<link href="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.css"';
             $base_link .= ' rel="stylesheet" type="text/css" media="screen" />';
             $base_file = "frontend.css";
             if (!empty($include_head_link_css)) {
                 $head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
                 $include_head_link_css = '';
             }
             break;
         case 'jquery':
             $aFilterSettings = getOutputFilterSettings();
             $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', 'filterJquery.inc');
             $bLoadJquery = !isset($aFilterSettings[$key]);
             $bLoadJquery = @(!$aFilterSettings[$key]) ?: $bLoadJquery;
             if ($bLoadJquery) {
                 $head_links .= bind_jquery($file_id);
             }
             break;
         case 'js':
             //                $base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
             //                $base_file = "frontend.js";
             //                if(!empty($include_head_links))
             //                {
             //                  $head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
             //                  $include_head_links = '';
             //                }
             break;
         case 'script_old':
             break;
         default:
             break;
     }
     if ($file_id != 'jquery_old') {
         // gather information for all models embedded on actual page
         //            $page_id = $wb->page_id;
         $sql = 'SELECT `module` FROM `' . TABLE_PREFIX . 'sections` ' . 'WHERE `page_id` = ' . (int) $page_id;
         if ($oModules = $database->query($sql)) {
             while ($row = $oModules->fetchRow(MYSQLI_ASSOC)) {
                 // check if page module directory contains a frontend.js or frontend.css file
                 if (file_exists(WB_PATH . "/modules/" . $row['module'] . "/{$base_file}")) {
                     // create link with frontend.js or frontend.css source for the current module
                     $tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
                     // define constant indicating that the register_frontent_files was invoked
                     if ($file_id == 'css') {
                         if (!defined('MOD_FRONTEND_CSS_REGISTERED')) {
                             define('MOD_FRONTEND_CSS_REGISTERED', true);
                         }
                     } else {
                         if (!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) {
                             define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
                         }
                     }
                     // ensure that frontend.js or frontend.css is only added once per module type
                     if ($tmp_link && strpos($head_links, $tmp_link) === false) {
                         $head_links .= $tmp_link . "\n";
                     }
                 }
             }
         }
     }
     print $head_links;
 }
コード例 #16
0
        // request settings from database
        $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'mod_output_filter`';
        if ($res = $database->query($sql)) {
            if ($rec = $res->fetchRow()) {
                $settings = $rec;
                $settings['at_replacement'] = $admin->strip_slashes($settings['at_replacement']);
                $settings['dot_replacement'] = $admin->strip_slashes($settings['dot_replacement']);
            }
        }
        // return array with filter settings
        return $settings;
    }
}
$msg = '';
// getting old Data
$data = getOutputFilterSettings();
// Set old values if exists otherwise go for default
Settings::Set('wb_suppress_old_opf', 0, false);
Settings::Set('opf_droplets', 1, false);
Settings::Set('opf_droplets_be', 1, false);
Settings::Set('opf_wblink', 1, false);
Settings::Set('opf_auto_placeholder', 1, false);
Settings::Set('opf_insert', 1, false);
//backend
Settings::Set('opf_insert_be', 1);
Settings::Set('opf_css_to_head_be', 1);
if (isset($data["sys_rel"])) {
    Settings::Set('opf_sys_rel', $data["sys_rel"], false);
} else {
    Settings::Set('opf_sys_rel', 1, false);
}