roundcubemail/program/include/rcmail_output_html.php
public function set_assets_path($path, $fs_dir = null)
    {
        if (empty($path)) {
            return;
        }

        $path = rtrim($path, '/') . '/';

        // handle relative assets path
        if (!preg_match('|^https?://|', $path) && $path[0] != '/') {
            // save the path to search for asset files later
            $this->assets_dir = $path;

            $base = preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI']);
            $base = rtrim($base, '/');

            // remove url token if exists
            if ($len = intval($this->config->get('use_secure_urls'))) {
                $_base  = explode('/', $base);
                $last   = count($_base) - 1;
                $length = $len > 1 ? $len : 16; // as in rcube::get_secure_url_token()

                // we can't use real token here because it
                // does not exists in unauthenticated state,
                // hope this will not produce false-positive matches
                if ($last > -1 && preg_match('/^[a-f0-9]{' . $length . '}$/', $_base[$last])) {
                    $path = '../' . $path;
                }
            }
        }

        // set filesystem path for assets
        if ($fs_dir) {
            if ($fs_dir[0] != '/') {
                $fs_dir = realpath(RCUBE_INSTALL_PATH . $fs_dir);
            }
            // ensure the path ends with a slash
            $this->assets_dir = rtrim($fs_dir, '/') . '/';
        }

        $this->assets_path = $path;
        $this->set_env('assets_path', $path);
    }
public function set_assets_path($path, $fs_dir = null)
    {
        if (empty($path)) {
            return;
        }

        $path = rtrim($path, '/') . '/';

        // handle relative assets path
        if (!preg_match('|^https?://|', $path) && $path[0] != '/') {
            // save the path to search for asset files later
            $this->assets_dir = $path;

            $base = preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI']);
            $base = rtrim($base, '/');

            // remove url token if exists
            if ($len = intval($this->config->get('use_secure_urls'))) {
                $_base  = explode('/', $base);
                $last   = count($_base) - 1;
                $length = $len > 1 ? $len : 16; // as in rcube::get_secure_url_token()

                // we can't use real token here because it
                // does not exists in unauthenticated state,
                // hope this will not produce false-positive matches
                if ($last > -1 && preg_match('/^[a-f0-9]{' . $length . '}$/', $_base[$last])) {
                    $path = '../' . $path;
                }
            }
        }

        // set filesystem path for assets
        if ($fs_dir) {
            if ($fs_dir[0] != '/') {
                $fs_dir = realpath(RCUBE_INSTALL_PATH . $fs_dir);
            }
            // ensure the path ends with a slash
            $this->assets_dir = rtrim($fs_dir, '/') . '/';
        }

        $this->assets_path = $path;
        $this->set_env('assets_path', $path);
    }
public function set_assets_path ( $ path , $ fs_dir = null ) { if ( empty ( $ path ) ) { return ; } $ path = rtrim ( $ path , '/' ) . '/' ; // handle relative assets path if ( ! preg_match ( '|^https?://|' , $ path ) && $ path [ 0 ] != '/' ) { // save the path to search for asset files later $ this -> assets_dir = $ path ; $ base = preg_replace ( '/[?#&].*$/' , '' , $ _SERVER [ 'REQUEST_URI' ] ) ; $ base = rtrim ( $ base , '/' ) ; // remove url token if exists if ( $ len = intval ( $ this -> config -> get ( 'use_secure_urls' ) ) ) { $ _base = explode ( '/' , $ base ) ; $ last = count ( $ _base ) - 1 ; $ length = $ len > 1 ? $ len : 16 ; // as in rcube::get_secure_url_token() // we can't use real token here because it // does not exists in unauthenticated state, // hope this will not produce false-positive matches if ( $ last > - 1 && preg_match ( '/^[a-f0-9]{' . $ length . '}$/' , $ _base [ $ last ] ) ) { $ path = '../' . $ path ; } } } // set filesystem path for assets if ( $ fs_dir ) { if ( $ fs_dir [ 0 ] != '/' ) { $ fs_dir = realpath ( RCUBE_INSTALL_PATH . $ fs_dir ) ; } // ensure the path ends with a slash $ this -> assets_dir = rtrim ( $ fs_dir , '/' ) . '/' ; } $ this -> assets_path = $ path ; $ this -> set_env ( 'assets_path' , $ path ) ; }
Parse and set assets path

@param string $path   Assets path URL (relative or absolute)
@param string $fs_dif Assets path in filesystem
Parse and set assets path