cw_addons_add_css('altskin.css');
    }
}
if (!$data && $current_domain) {
    $data = cw_func_call('cw_md_domain_get', array('domain_id' => $current_domain));
}
$host_value = cw_md_get_host();
$domain_full_host = $HTTPS ? $data['https_host'] : $data['http_host'];
// if use alias
if ($host_value != $domain_full_host) {
    global $http_location, $https_location, $current_location, $current_host_location;
    global $smarty, $app_config_file, $var_dirs_web, $app_dirs, $HTTPS;
    $http_location = 'http://' . $host_value . $app_config_file['web']['web_dir'];
    $https_location = 'https://' . $host_value . $app_config_file['web']['web_dir'];
    $current_location = $HTTPS ? $https_location : $http_location;
    $current_host_location = ($HTTPS ? 'https://' : 'http://') . $host_value;
    $smarty->assign('current_location', $current_location);
    $smarty->assign('current_host_location', $current_host_location);
    $app_catalogs = array();
    $app_catalogs_secure = array();
    foreach ($app_dirs as $k => $v) {
        $app_catalogs[$k] = $current_location . ($v ? with_leading_slash($v) : '');
        $app_catalogs_secure[$k] = $https_location . ($v ? with_leading_slash($v) : '');
    }
    $smarty->assign('catalogs', $app_catalogs);
    $smarty->assign('catalogs_secure', $app_catalogs_secure);
}
# kornev, it will work faster in comparison with the additional table join
global $domain_attributes;
cw_load('attributes');
$domain_attributes = cw_func_call('cw_attributes_get_attributes_by_field', array('field' => 'domains'));
/**
 * Format path with leading slash and without trailing to make concatenation easier
 */
function with_leading_slash_only($path, $root_slash_for_empty = false)
{
    if (empty($path) && !$root_slash_for_empty) {
        return '';
    }
    return with_leading_slash(without_slash($path));
}
Exemplo n.º 3
0
function cw_include($file, $mode = INCLUDE_RW_GLOBALS)
{
    global $app_main_dir;
    global $includesManager;
    return $includesManager->trigger($app_main_dir . with_leading_slash($file), $mode);
}
function cw_md_cleanup_skin($dir, $dir_, $int = '')
{
    global $app_dir;
    $int = with_leading_slash($int);
    if (!cw_allowed_path($app_dir, $dir . $int)) {
        return false;
    }
    if (!cw_allowed_path($app_dir, $dir_ . $int)) {
        return false;
    }
    $status = array();
    if (is_dir($dir . $int)) {
        if ($handle = opendir($dir . $int)) {
            while ($file = readdir($handle)) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                $full = $int . $file;
                $is_dir = is_dir($dir . $full);
                if ($is_dir) {
                    $status = array_merge($status, cw_md_cleanup_skin($dir, $dir_, with_slash($full)));
                    if (cw_is_empty_dir($dir_ . $full)) {
                        cw_rm_dir($dir_ . $full);
                        $status[] = '[ ] Dir ' . $dir_ . $full . ' removed';
                    }
                } elseif (in_array(pathinfo($full, PATHINFO_EXTENSION), array('tpl', 'css', 'js', 'gif', 'png', 'jpg', 'jpeg', 'bmp'), true)) {
                    if (file_exists($dir_ . $full)) {
                        $md5 = md5_file($dir . $full);
                        $md5_ = md5_file($dir_ . $full);
                        $same = $md5 == $md5_;
                        if ($same) {
                            if (!unlink($dir_ . $full)) {
                                $status[] = '[!] Can\'t remove file: ' . $dir_ . $full;
                            } else {
                                $status[] = '[ ] File ' . $dir_ . $full . ' removed';
                            }
                        } else {
                            $status[] = '[*] File ' . $dir_ . $full . ' differs';
                        }
                    }
                }
            }
            closedir($handle);
        } else {
            $status[] = '[!] Can\'t open ' . $dir . $int . " directory  (need to check permissions)";
        }
    }
    return $status;
}