sanitize($_SERVER['PATH_INFO']); } else { $viewsvn->trigger->error($viewsvn->lang->string('Your server does not support type-2 path management')); } if (!$path) { $viewsvn->trigger->error($viewsvn->lang->string('Invalid path sent')); } return $path; } // ################################################################### /** * Returns the name of the repository from a upath * * @access public * * @param string Universal path * * @return string Repository name */ function fetch_repos($path) { $temp = preg_split('#/#', $path, -1, PREG_SPLIT_NO_EMPTY); return $temp[0]; } // ################################################################### /** * Returns the path without the repository from a upath * * @access public * * @param string Universal path * @param bool Preceding slash * * @return string Relative path */ function fetch_path($path, $doslash = false) { $temp = preg_split('#/#', $path, -1, PREG_SPLIT_NO_EMPTY); unset($temp[0]); return ($doslash ? '/' : '') . implode('/', $temp); } // ################################################################### /** * Fetches any URL parameters a link has * * @access public * * @param string Original URL * * @return array Two-element array: base path (no trailing '?'), arguments */ function fetch_arguments($url) { $return = array(); $bits = parse_url($url); if (isset($bits['query'])) { $return[0] = $bits['path']; $return[1] = $bits['query']; } else { $return[0] = $bits['path']; $return[1] = ''; } return $return; } // ################################################################### /** * Determines if the root path has been reached * * @access public * * @param string Universal path * * @return bool Root of path? */ function is_root_path($path) { $path = Paths::fetch_path($path); $temp = preg_split('#/#', $path, -1, PREG_SPLIT_NO_EMPTY); if (sizeof($temp) > 0) { return false; } else { return true; } } // ################################################################### /** * Returns the current sanitized revision * * @access public * * @param bool High-low or not * @param mixed High revision (or regular) * @param mixed Low revision * * @return mixed Revision number or HEAD */ function fetch_rev_num($highlow = false, $high = null, $low = null) { global $viewsvn; if ($highlow) { if (isset($viewsvn->in['high']) AND is_null($high)) { $high = SVNCommon::rev($viewsvn->in['high']); } else if (is_null($high)) { $high = 'HEAD'; } if (isset($viewsvn->in['low']) AND is_null($low)) { $low = SVNCommon::rev($viewsvn->in['low']); } else if (is_null($low)) { $low = 0; } if ($low == 'HEAD') { $low = 0; } if (is_int($high) AND is_int($low) AND $low > $high) { $temp = $high; $high = $low; $low = $temp; } return array('high' => $high, 'low' => $low); } else { if (isset($viewsvn->in['rev']) AND is_null($high)) { $rev = SVNCommon::rev($viewsvn->in['rev']); } else if (is_null($high)) { $rev = 'HEAD'; } else { $rev = $high; } return $rev; } } // ################################################################### /** * Returns a GET string with sanitized revision data * * @access public * * @param bool High-low or not * @param mixed High revision (or regular) * @param mixed Low revision * * @return string Revision GET data */ function fetch_rev_str($highlow = false, $high = null, $low = null) { $rev = Paths::fetch_rev_num($highlow, $high, $low); if ($highlow) { return '?low=' . $rev['low'] . '&high=' . $rev['high']; } else { return '?rev=' . $rev; } } // ################################################################### /** * Sanitizes a path for passing * * @access private * * @param string Path * * @return string Cleaned string */ function sanitize($path) { return preg_replace('#[^a-z0-9\./\-_]*#i', '', $path); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>