Example #1
0
}
if (intval($_GET['step']) == 9) {
    $content = step_9();
}
if (intval($_GET['step']) == 10) {
    $content = step_10();
}
$css_url = 'install.php?type=css';
$css_url_2 = 'install.php?type=css_2';
$logo_url = 'install.php?type=logo';
if (is_null($DEFAULT_FORUM)) {
    $DEFAULT_FORUM = 'ocf';
}
// Shouldn't happen, but who knows
require_code('tempcode_compiler');
$css_nocache = _do_template('default', '/css/', 'no_cache', 'no_cache', 'EN', '.css');
$out_final = do_template('INSTALLER_WRAP', array('_GUID' => '29aa056c05fa360b72dbb01c46608c4b', 'CSS_NOCACHE' => $css_nocache, 'DEFAULT_FORUM' => $DEFAULT_FORUM, 'PASSWORD_PROMPT' => $password_prompt, 'CSS_URL' => $css_url, 'CSS_URL_2' => $css_url_2, 'LOGO_URL' => $logo_url, 'STEP' => integer_format(intval($_GET['step'])), 'CONTENT' => $content, 'VERSION' => $VERSION));
unset($css_nocache);
unset($content);
$out_final->evaluate_echo();
global $MYFILE;
if (@is_resource($MYFILE)) {
    if (intval($_GET['step']) == 10 && !is_suexec_like()) {
        $conn = false;
        $domain = trim(post_param('ftp_domain'));
        $port = 21;
        if (strpos($domain, ':') !== false) {
            list($domain, $_port) = explode(':', $domain, 2);
            $port = intval($_port);
        }
        if (function_exists('ftp_ssl_connect')) {
Example #2
0
/**
 * Get a tempcoded version of a normal XHTML template. It is perhaps the most common ocPortal function to load up templates using do_template, and then attach them together either as parameters to each other, or via the tempcode attach method.
 *
 * @param  ID_TEXT			The codename of the template being loaded
 * @param  ?array				A map of parameters for the template (key to value) (NULL: no parameters)
 * @param  ?LANGUAGE_NAME 	The language to load the template in (templates can embed language references) (NULL: users own language)
 * @param  boolean			Whether to not produce a stack dump if the template is missing
 * @param  ?ID_TEXT			Alternate template to use if the primary one does not exist (NULL: none)
 * @param  string				File type suffix of template file (e.g. .tpl)
 * @param  string				Subdirectory type to look in
 * @set    templates css
 * @param  ID_TEXT			Theme to use
 * @return tempcode			The tempcode for this template
 */
function do_template($codename, $parameters = NULL, $lang = NULL, $light_error = false, $fallback = NULL, $suffix = '.tpl', $type = 'templates', $theme = NULL)
{
    if (is_null($lang) || $lang == '') {
        global $USER_LANG_CACHED;
        $lang = isset($USER_LANG_CACHED) ? $USER_LANG_CACHED : (function_exists('user_lang') ? user_lang() : 'EN');
    }
    if ($GLOBALS['SEMI_DEBUG_MODE']) {
        if ($codename != 'tempcode_test' && $codename != 'handle_conflict_resolution' && strtoupper($codename) != strtoupper($codename)) {
            fatal_exit('Template names should be in upper case, and the files should be stored in upper case.');
        }
        if (substr($codename, -7) == '_SCREEN' || $codename == 'POOR_XHTML_WRAPPER' || $codename == 'OCF_WRAPPER') {
            $GLOBALS['SCREEN_TEMPLATE_CALLED'] = $codename;
        }
    }
    if (is_null($parameters)) {
        $parameters = array();
    }
    global $RECORD_TEMPLATES_USED, $FILE_ARRAY, $MEM_CACHE, $CACHE_TEMPLATES, $KEEP_MARKERS, $SHOW_EDIT_LINKS, $XHTML_SPIT_OUT, $TEMPLATE_CACHE, $MOBILE, $FORUM_DRIVER;
    $special_treatment = ($KEEP_MARKERS || $SHOW_EDIT_LINKS) && is_null($XHTML_SPIT_OUT);
    // Is it already loaded?
    if ($RECORD_TEMPLATES_USED) {
        global $RECORDED_TEMPLATES_USED;
        $RECORDED_TEMPLATES_USED[] = $codename;
    }
    // Variables we'll need
    if (!isset($theme)) {
        $theme = isset($FORUM_DRIVER) && is_object($FORUM_DRIVER) && method_exists($FORUM_DRIVER, 'get_theme') ? filter_naughty($FORUM_DRIVER->get_theme()) : 'default';
    }
    $_codename = $MOBILE ? $codename . '_mobile' : $codename;
    if (isset($TEMPLATE_CACHE[$theme][$codename][$lang])) {
        $_data = $TEMPLATE_CACHE[$theme][$codename][$lang]->bind($parameters, $codename);
        // Copy and pasted to remove need for an function call
        if ($special_treatment) {
            if ($KEEP_MARKERS) {
                $__data = make_string_tempcode('<!-- START-TEMPLATE=' . $codename . ' -->');
                $__data->attach($_data);
                $__data->attach('<!-- END-TEMPLATE=' . $codename . ' -->');
                $_data = $__data;
            }
            if ($SHOW_EDIT_LINKS) {
                $edit_url = build_url(array('page' => 'admin_themes', 'theme' => $FORUM_DRIVER->get_theme(), 'template' => $codename), 'adminzone');
                $_data->attach('<br /><a href="' . escape_html($edit_url->evaluate()) . '">' . do_lang('EDIT') . ' ' . $codename . '</a>');
            }
        }
        return $_data;
    }
    // Is it structurally cached on disk yet?
    $data = mixed();
    if ($CACHE_TEMPLATES) {
        if (!is_null($MEM_CACHE)) {
            $data = persistant_cache_get(array('TEMPLATE', $theme, $lang, $_codename));
            if (!is_null($data)) {
                $_data = new ocp_tempcode();
                $_data->from_assembly($data);
                if ($_data->bits == array()) {
                    $data = false;
                }
                // Corrupt somehow
            } else {
                $data = false;
            }
        } elseif (is_null($data)) {
            $_data = new ocp_tempcode();
            $tcp_path = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang . '/' . $_codename . $suffix . '.tcd';
            $data = @file_get_contents($tcp_path, FILE_BINARY);
            if ($data === '') {
                $data = false;
            }
            // '' needed for PHP4 - weird
            if ($data !== false) {
                $_data->from_assembly($data);
                if ($_data->bits == array()) {
                    $data = false;
                }
                // Corrupt somehow
            }
        }
    } else {
        $data = false;
    }
    if ($data === false) {
        if (!isset($FILE_ARRAY)) {
            $_data = NULL;
            $prefix_default = get_file_base() . '/themes/';
            $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/';
            if (file_exists($prefix . $theme . '/' . $type . '_custom/' . $_codename . $suffix)) {
                $_data = _do_template($theme, '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif (file_exists($prefix . $theme . '/' . $type . '/' . $_codename . $suffix)) {
                $_data = _do_template($theme, '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif (!is_null($GLOBALS['CURRENT_SHARE_USER']) && $theme != 'default' && file_exists($prefix_default . $theme . '/' . $type . '_custom/' . $_codename . $suffix)) {
                $_data = _do_template($theme, '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif (!is_null($GLOBALS['CURRENT_SHARE_USER']) && $theme != 'default' && file_exists($prefix_default . $theme . '/' . $type . '/' . $_codename . $suffix)) {
                $_data = _do_template($theme, '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif (file_exists($prefix_default . 'default' . '/' . $type . '_custom/' . $_codename . $suffix)) {
                $_data = _do_template('default', '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif (file_exists($prefix_default . 'default' . '/' . $type . '/' . $_codename . $suffix)) {
                $_data = _do_template('default', '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme);
            } elseif ($codename != $_codename) {
                if (file_exists($prefix . $theme . '/' . $type . '_custom/' . $codename . $suffix)) {
                    $_data = _do_template($theme, '/' . $type . '_custom/', $codename, $_codename, $lang, $suffix, $theme);
                } elseif (file_exists($prefix . $theme . '/' . $type . '/' . $codename . $suffix)) {
                    $_data = _do_template($theme, '/' . $type . '/', $codename, $_codename, $lang, $suffix, $theme);
                } elseif (file_exists($prefix_default . 'default' . '/' . $type . '_custom/' . $codename . $suffix)) {
                    $_data = _do_template('default', '/' . $type . '_custom/', $codename, $_codename, $lang, $suffix, $theme);
                } elseif (file_exists($prefix_default . 'default' . '/' . $type . '/' . $codename . $suffix)) {
                    $_data = _do_template('default', '/' . $type . '/', $codename, $_codename, $lang, $suffix, $theme);
                }
            }
            if (is_null($_data)) {
                if (is_null($fallback)) {
                    if ($light_error) {
                        return paragraph(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)));
                    }
                    fatal_exit(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)));
                } else {
                    $result = do_template($fallback, $parameters, $lang);
                    $TEMPLATE_CACHE[$theme][$codename][$lang] = $TEMPLATE_CACHE[$fallback][$lang];
                    return $result;
                }
            }
        } else {
            $_data = _do_template('default', '/' . $type . '/', $codename, $codename, $lang, $suffix, $theme);
        }
    }
    $TEMPLATE_CACHE[$theme][$codename][$lang] = $_data;
    $ret = $_data->bind($parameters, $codename);
    if ($special_treatment) {
        if ($KEEP_MARKERS) {
            $__data = new ocp_tempcode();
            $__data->attach('<!-- START-TEMPLATE=' . $codename . ' -->');
            $__data->attach($ret);
            $__data->attach('<!-- END-TEMPLATE=' . $codename . ' -->');
            $ret = $__data;
        }
        if ($SHOW_EDIT_LINKS && $codename != 'PARAM_INFO') {
            $param_info = do_template('PARAM_INFO', array('MAP' => $parameters));
            $edit_url = build_url(array('page' => 'admin_themes', 'theme' => $FORUM_DRIVER->get_theme(), 'template' => $codename), 'adminzone');
            $SHOW_EDIT_LINKS = false;
            $ret = do_template('TEMPLATE_EDIT_LINK', array('_GUID' => '511ae911d31a5b237a4371ff22fc78fd', 'PARAM_INFO' => $param_info, 'CONTENTS' => $ret, 'CODENAME' => $codename, 'EDIT_URL' => $edit_url));
            $SHOW_EDIT_LINKS = true;
        }
    }
    return $ret;
}
Example #3
0
/**
 * This is a less-revealing alternative to fatal_exit, that is used for user-errors/common-corruption-scenarios
 *
 * @param  mixed			The error message
 */
function warn_exit($text)
{
    // To break any looping of errors
    global $EXITING;
    if (!is_null($EXITING) || !class_exists('ocp_tempcode')) {
        if (get_domain() == 'localhost' || function_exists('get_member') && has_specific_permission(get_member(), 'see_stack_dump')) {
            die_html_trace($text);
        } else {
            critical_error('RELAY', is_object($text) ? $text->evaluate() : escape_html($text));
        }
    }
    $EXITING = 1;
    $title = get_page_title('ERROR_OCCURRED');
    $echo = new ocp_tempcode();
    $echo->attach(do_template('WARN_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'PROVIDE_BACK' => false)));
    $css_url = 'install.php?type=css';
    $css_url_2 = 'install.php?type=css_2';
    $logo_url = 'install.php?type=logo';
    $version = strval(ocp_version());
    $version .= (is_numeric(ocp_version_minor()) ? '.' : ' ') . ocp_version_minor();
    if (!array_key_exists('step', $_GET)) {
        $_GET['step'] = 1;
    }
    require_code('tempcode_compiler');
    $css_nocache = _do_template('default', '/css/', 'no_cache', 'no_cache', 'EN', '.css');
    $out_final = do_template('INSTALLER_WRAP', array('CSS_NOCACHE' => $css_nocache, 'DEFAULT_FORUM' => '', 'PASSWORD_PROMPT' => '', 'CSS_URL' => $css_url, 'CSS_URL_2' => $css_url_2, 'LOGO_URL' => $logo_url, 'STEP' => integer_format(intval($_GET['step'])), 'CONTENT' => $echo, 'VERSION' => $version));
    $out_final->evaluate_echo();
    exit;
}
Example #4
0
/**
 * Get a tempcoded version of a normal XHTML template. It is perhaps the most common ocPortal function to load up templates using do_template, and then attach them together either as parameters to each other, or via the tempcode attach method.
 *
 * @param  ID_TEXT			The codename of the template being loaded
 * @param  ?array				A map of parameters for the template (key to value) (NULL: no parameters)
 * @param  ?LANGUAGE_NAME 	The language to load the template in (templates can embed language references) (NULL: users own language)
 * @param  boolean			Whether to not produce a stack dump if the template is missing
 * @param  ?ID_TEXT			Alternate template to use if the primary one does not exist (NULL: none)
 * @param  string				File type suffix of template file (e.g. .tpl)
 * @param  string				Subdirectory type to look in
 * @set    templates css
 * @param  ?ID_TEXT			Theme to use (NULL: current theme)
 * @return tempcode			The tempcode for this template
 */
function do_template($codename, $parameters = NULL, $lang = NULL, $light_error = false, $fallback = NULL, $suffix = '.tpl', $type = 'templates', $theme = NULL)
{
    if (!isset($lang) || $lang == '') {
        global $USER_LANG_CACHED;
        $lang = isset($USER_LANG_CACHED) ? $USER_LANG_CACHED : (function_exists('user_lang') ? user_lang() : 'EN');
    }
    if ($GLOBALS['SEMI_DEBUG_MODE']) {
        if ($codename == strtolower($codename) && $type != 'css' && $codename != 'tempcode_test' && $codename != 'handle_conflict_resolution') {
            fatal_exit('Template names should be in upper case, and the files should be stored in upper case.');
        }
        if (substr($codename, -7) == '_SCREEN' || substr($codename, -8) == '_OVERLAY' || $codename == 'POOR_XHTML_WRAPPER' || $codename == 'OCF_WRAPPER') {
            $GLOBALS['SCREEN_TEMPLATE_CALLED'] = $codename;
        }
    }
    global $TEMPLATE_PREVIEW_OP, $RECORD_TEMPLATES_USED, $RECORDED_TEMPLATES_USED, $FILE_ARRAY, $MEM_CACHE, $KEEP_MARKERS, $SHOW_EDIT_LINKS, $XHTML_SPIT_OUT, $CACHE_TEMPLATES, $FORUM_DRIVER, $POSSIBLY_IN_SAFE_MODE, $CACHED_THEME, $CACHED_FOUND, $LOADED_TPL_CACHE;
    $special_treatment = ($KEEP_MARKERS || $SHOW_EDIT_LINKS) && is_null($XHTML_SPIT_OUT);
    if ($RECORD_TEMPLATES_USED) {
        $RECORDED_TEMPLATES_USED[] = $codename;
    }
    // Variables we'll need
    if (!isset($theme)) {
        $theme = isset($CACHED_THEME) ? $CACHED_THEME : (isset($FORUM_DRIVER) && is_object($FORUM_DRIVER) && method_exists($FORUM_DRIVER, 'get_theme') ? filter_naughty($FORUM_DRIVER->get_theme()) : 'default');
    }
    $prefix_default = get_file_base() . '/themes/';
    $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/';
    // Is it structurally cached on disk yet?
    if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
        $loaded_this_once = false;
    } else {
        $loaded_this_once = true;
    }
    $_data = false;
    if ($CACHE_TEMPLATES && !$TEMPLATE_PREVIEW_OP && (!$POSSIBLY_IN_SAFE_MODE || !in_safe_mode())) {
        $tcp_path = $prefix . $theme . '/templates_cached/' . $lang . '/' . $codename . $suffix . '.tcp';
        if ($loaded_this_once) {
            if (isset($LOADED_TPL_CACHE[$codename][$theme])) {
                $_data = $LOADED_TPL_CACHE[$codename][$theme];
            } else {
                $_data = new ocp_tempcode();
                $test = $_data->from_assembly_executed($tcp_path, array($codename, $codename, $lang, $theme, $suffix, $type, $fallback));
                if (!$test) {
                    $_data = false;
                }
                // failed
            }
        } else {
            global $SITE_INFO;
            $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0';
            if ($support_smart_decaching) {
                if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
                    $found = find_template_place($codename, $lang, $theme, $suffix, $type);
                    $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type] = $found;
                } else {
                    $found = $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type];
                }
                if (!is_null($found)) {
                    if (isset($GLOBALS['CURRENT_SHARE_USER'])) {
                        $file_path = get_custom_file_base() . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                        if (!is_file($file_path)) {
                            $file_path = get_file_base() . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                        }
                    } else {
                        $file_path = ($theme == 'default' && $suffix != '.css' ? get_file_base() : get_custom_file_base()) . '/themes/' . $found[0] . $found[1] . $codename . $suffix;
                    }
                    $tcp_time = @filemtime($tcp_path);
                } else {
                    $tcp_time = false;
                }
            }
            if (!$support_smart_decaching || $tcp_time !== false && is_file($file_path) && $found !== NULL) {
                if (!$support_smart_decaching || filemtime($file_path) < $tcp_time) {
                    $_data = new ocp_tempcode();
                    $test = $_data->from_assembly_executed($tcp_path, array($codename, $codename, $lang, $theme, $suffix, $type, $fallback));
                    if (!$test) {
                        $_data = false;
                    }
                    // failed
                }
            }
        }
    }
    if ($_data === false) {
        if (!isset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type])) {
            $found = find_template_place($codename, $lang, $theme, $suffix, $type);
            $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type] = $found;
        } else {
            $found = $CACHED_FOUND[$codename][$lang][$theme][$suffix][$type];
        }
        unset($CACHED_FOUND[$codename][$lang][$theme][$suffix][$type]);
        if (is_null($found)) {
            if (is_null($fallback)) {
                if ($light_error) {
                    return paragraph(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)), '34rwefwfdee');
                }
                fatal_exit(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename)));
            } else {
                $result = do_template($fallback, $parameters, $lang);
                return $result;
            }
        } else {
            require_code('tempcode_compiler');
            $_data = _do_template($found[0], $found[1], $codename, $codename, $lang, $suffix, $theme);
        }
    }
    if ($loaded_this_once) {
        // On 3rd load (and onwards) it will be fully cached
        $LOADED_TPL_CACHE[$codename][$theme] = $_data;
    }
    if (!isset($parameters)) {
        $out = new ocp_tempcode();
        $out->codename = $codename;
        $out->code_to_preexecute = $_data->code_to_preexecute;
        $out->preprocessable_bits = $_data->preprocessable_bits;
        $out->seq_parts = $_data->seq_parts;
        foreach ($out->seq_parts as $i => $bit) {
            if ($bit[1] != array()) {
                $out->seq_parts[$i][1] = array();
            }
        }
        return $out;
    }
    $ret = $_data->bind($parameters, $codename);
    if ($special_treatment) {
        $ret->codename = '(mixed)';
        // Stop optimisation that assumes the codename represents the sole content of it
    }
    if ($special_treatment) {
        if ($KEEP_MARKERS) {
            $__data = new ocp_tempcode();
            $__data->attach('<!-- START-TEMPLATE=' . escape_html($codename) . ' -->');
            $__data->attach($ret);
            $__data->attach('<!-- END-TEMPLATE=' . escape_html($codename) . ' -->');
            $ret = $__data;
        }
        if ($SHOW_EDIT_LINKS && $codename != 'PARAM_INFO') {
            $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => $codename), 'adminzone');
            $parameters2 = array();
            foreach ($parameters as $k => $v) {
                if (is_array($v)) {
                    $parameters2[$k] = '(array)';
                } elseif (!is_object($v)) {
                    $parameters2[$k] = $v;
                } else {
                    $parameters2[$k] = $v->evaluate();
                    if (strlen($parameters2[$k]) > 100) {
                        $parameters2[$k] = substr($parameters2[$k], 0, 100) . '...';
                    }
                }
            }
            $param_info = do_template('PARAM_INFO', array('MAP' => $parameters2));
            $SHOW_EDIT_LINKS = false;
            $ret = do_template('TEMPLATE_EDIT_LINK', array('_GUID' => '511ae911d31a5b237a4371ff22fc78fd', 'PARAM_INFO' => $param_info, 'CONTENTS' => $ret, 'CODENAME' => $codename, 'EDIT_URL' => $edit_url));
            $SHOW_EDIT_LINKS = true;
        }
    }
    return $ret;
}
Example #5
0
/**
 * Return a specific compiled CSS file.
 *
 * @param  ID_TEXT		The theme the file is being loaded for
 * @param  string			Theme name
 * @param  string			The CSS file required
 * @param  PATH			Full path to CSS file (file is in uncompiled Tempcode format)
 * @param  boolean		Whether to also do minification
 * @return array			A pair: success status, The text of the compiled file
 */
function _css_compile($active_theme, $theme, $c, $fullpath, $minify = true)
{
    global $KEEP_MARKERS, $SHOW_EDIT_LINKS;
    $keep_markers = $KEEP_MARKERS;
    $show_edit_links = $SHOW_EDIT_LINKS;
    $KEEP_MARKERS = false;
    $SHOW_EDIT_LINKS = false;
    if ($theme != 'default' && !is_file($fullpath)) {
        $theme = 'default';
    }
    if ($GLOBALS['RECORD_TEMPLATES_USED']) {
        global $RECORDED_TEMPLATES_USED;
        $RECORDED_TEMPLATES_USED[] = $c . '.css';
    }
    require_code('tempcode_compiler');
    global $ATTACHED_MESSAGES_RAW;
    $num_msgs_before = count($ATTACHED_MESSAGES_RAW);
    $css = _do_template($theme, strpos($fullpath, '/css_custom/') !== false ? '/css_custom/' : '/css/', $c, $c, user_lang(), '.css', $active_theme);
    $out = $css->evaluate();
    $num_msgs_after = count($ATTACHED_MESSAGES_RAW);
    global $CSS_COMPILE_ACTIVE_THEME;
    $CSS_COMPILE_ACTIVE_THEME = $active_theme;
    $out = preg_replace_callback('#\\@ocp\\_include\\(\'?(\\w+)/(\\w+)/(\\w+)\'?\\);#', '_css_ocp_include', $out);
    $out = preg_replace('#/\\*\\s*\\*/#', '', $out);
    // strip empty comments (would have encapsulated Tempcode comments)
    if (get_custom_file_base() != get_file_base()) {
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_base_url(true) . '/themes/')) . '#', '../../../../../../themes/', $out);
        // make URLs relative. For SSL and myocp
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_base_url(false) . '/themes/')) . '#', '../../../../../../themes/', $out);
        // make URLs relative. For SSL and myocp
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_custom_base_url(true) . '/themes/')) . '#', '../../../../themes/', $out);
        // make URLs relative. For SSL and myocp
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_custom_base_url(false) . '/themes/')) . '#', '../../../../themes/', $out);
        // make URLs relative. For SSL and myocp
    } else {
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_base_url(true))) . '#', '../../../..', $out);
        // make URLs relative. For SSL and myocp
        $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', get_base_url(false))) . '#', '../../../..', $out);
        // make URLs relative. For SSL and myocp
    }
    $cdn = get_value('cdn');
    if (!is_null($cdn)) {
        $cdn_parts = explode(',', $cdn);
        foreach ($cdn_parts as $cdn_part) {
            $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', preg_replace('#://' . str_replace('#', '\\#', preg_quote(get_domain())) . '([/:])#', '://' . $cdn_part . '${1}', get_base_url(true)))) . '#', '../../../..', $out);
            // make URLs relative. For SSL and myocp
            $out = preg_replace('#' . preg_quote(str_replace('#', '\\#', preg_replace('#://' . str_replace('#', '\\#', preg_quote(get_domain())) . '([/:])#', '://' . $cdn_part . '${1}', get_base_url(false)))) . '#', '../../../..', $out);
            // make URLs relative. For SSL and myocp
        }
    }
    if ($minify) {
        $out = css_minify($out);
    }
    $KEEP_MARKERS = $keep_markers;
    $SHOW_EDIT_LINKS = $show_edit_links;
    if ($c != 'no_cache') {
        if ($out != '') {
            $out = '/* DO NOT EDIT. THIS IS A CACHE FILE AND WILL GET OVERWRITTEN RANDOMLY.' . chr(10) . 'INSTEAD EDIT THE CSS FROM WITHIN THE ADMIN ZONE, OR BY MANUALLY EDITING A CSS_CUSTOM OVERRIDE. */' . chr(10) . chr(10) . $out;
        }
    }
    if ($num_msgs_after > $num_msgs_before) {
        return array(false, $out);
    }
    return array(true, $out);
}