Subversion Repositories oidplus

Rev

Rev 801 | Rev 811 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 801 Rev 806
Line 1061... Line 1061...
1061
 
1061
 
1062
        public static function isSSL() {
1062
        public static function isSSL() {
1063
                return isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on');
1063
                return isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on');
1064
        }
1064
        }
1065
 
1065
 
-
 
1066
        /**
1066
        /* $mode == self::PATH_RELATIVE */
1067
         * Returns the URL of the system.
-
 
1068
         * @param int $mode If true or OIDplus::PATH_RELATIVE, the returning path is relative to the currently executed
1067
        /* $mode == self::PATH_ABSOLUTE */
1069
         *                  PHP script (i.e. index.php , not the plugin PHP script!). False or OIDplus::PATH_ABSOLUTE is
1068
        /* $mode == self::PATH_ABSOLUTE_CANONICAL */
1070
         *                  results in an absolute URL. OIDplus::PATH_ABSOLUTE_CANONICAL is an absolute URL,
-
 
1071
         *                  but a canonical path (set by base config setting CANONICAL_SYSTEM_URL) is preferred.
-
 
1072
         * @return string|false The URL, with guaranteed trailing path delimiter for directories
-
 
1073
         */
1069
        private static function getSystemUrl($mode) {
1074
        private static function getSystemUrl($mode) {
1070
                $relative = $mode == self::PATH_RELATIVE;
1075
                if ($mode === self::PATH_RELATIVE) {
1071
                $canonical_sysurl = $mode == self::PATH_ABSOLUTE_CANONICAL;
-
 
1072
 
-
 
1073
                if ($canonical_sysurl) {
-
 
1074
                        $tmp = OIDplus::baseConfig()->getValue('CANONICAL_SYSTEM_URL', '');
-
 
1075
                        if ($tmp !== '') {
-
 
1076
                                return rtrim($tmp,'/').'/';
-
 
1077
                        }
-
 
1078
                }
-
 
1079
 
-
 
1080
                if ($relative) {
-
 
1081
                        $steps_up = self::getExecutingScriptPathDepth();
1076
                        $steps_up = self::getExecutingScriptPathDepth();
1082
                        if ($steps_up === false) {
1077
                        if ($steps_up === false) {
1083
                                return false;
1078
                                return false;
1084
                        } else {
1079
                        } else {
1085
                                return str_repeat('../', $steps_up);
1080
                                return str_repeat('../', $steps_up);
1086
                        }
1081
                        }
1087
                } else {
1082
                } else {
-
 
1083
                        if ($mode === self::PATH_ABSOLUTE_CANONICAL) {
1088
                        $res = OIDplus::baseConfig()->getValue('EXPLICIT_ABSOLUTE_SYSTEM_URL', '');
1084
                                $tmp = OIDplus::baseConfig()->getValue('CANONICAL_SYSTEM_URL', '');
1089
                        if ($res !== '') {
1085
                                if ($tmp) {
1090
                                return rtrim($res,'/').'/';
1086
                                        return rtrim($tmp,'/').'/';
-
 
1087
                                }
1091
                        }
1088
                        }
1092
 
1089
 
1093
                        if (PHP_SAPI == 'cli') {
1090
                        if (PHP_SAPI == 'cli') {
1094
                                try {
1091
                                try {
1095
                                        return OIDplus::config()->getValue('last_known_system_url', false);
1092
                                        return OIDplus::config()->getValue('last_known_system_url', false);
Line 1385... Line 1382...
1385
        }
1382
        }
1386
 
1383
 
1387
        /**
1384
        /**
1388
         * Gets a URL pointing to a resource
1385
         * Gets a URL pointing to a resource
1389
         * @param string $target Target resource (file or directory must exist), or null to get the OIDplus base directory
1386
         * @param string $target Target resource (file or directory must exist), or null to get the OIDplus base directory
-
 
1387
         * @param int|boolean $mode If true or OIDplus::PATH_RELATIVE, the returning path is relative to the currently executed
1390
         * @param int|mixed $mode If true or 1, the returning path is relative to the currently executed PHP script (i.e. index.php , not the plugin PHP script!). False or 2 is an absolute URL. 3 is an absolute URL, but a canonical path is preferred.
1388
         *                          PHP script (i.e. index.php , not the plugin PHP script!). False or OIDplus::PATH_ABSOLUTE is
-
 
1389
         *                          results in an absolute URL. OIDplus::PATH_ABSOLUTE_CANONICAL is an absolute URL,
-
 
1390
         *                          but a canonical path (set by base config setting CANONICAL_SYSTEM_URL) is preferred.
1391
         * @return string|false The URL, with guaranteed trailing path delimiter for directories
1391
         * @return string|false The URL, with guaranteed trailing path delimiter for directories
1392
         */
1392
         */
1393
        public static function webpath($target=null, $mode=self::PATH_ABSOLUTE) {
1393
        public static function webpath($target=null, $mode=self::PATH_ABSOLUTE_CANONICAL) {
1394
 
1394
 
1395
                // backwards compatibility
1395
                // backwards compatibility
1396
                if ($mode === true) $mode = self::PATH_RELATIVE;
1396
                if ($mode === true) $mode = self::PATH_RELATIVE;
1397
                if ($mode === false) $mode = self::PATH_ABSOLUTE;
1397
                if ($mode === false) $mode = self::PATH_ABSOLUTE;
1398
 
1398