function svnQuickView ($host,$file,$needAuth=false) { // this block ? & etc.. if ($needAuth && !isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="SVN AUTH"'); header('HTTP/1.0 401 Unauthorized'); echo "You must enter a valid login ID and password to access this resource\n"; exit; } $request =$_SERVER['REQUEST_URI']; if (strlen($_SERVER['QUERY_STRING'])) { $request = substr($_SERVER['REQUEST_URI'] ,0, -1 * strlen($_SERVER['QUERY_STRING'] )); } if ($request != ($_SERVER['SCRIPT_NAME'] .@$_SERVER['PATH_INFO'])) { header("Location: {$_SERVER['SCRIPT_NAME']}/"); echo "REDIRECT? $request {$_SERVER['QUERY_STRING']}"; echo "
";print_r($_SERVER);
exit;
}
if (basename($_SERVER['SCRIPT_NAME']) != $file) {
header("Location: {$_SERVER['SCRIPT_NAME']}/");
echo "REDIRECT? 2 ";
exit;
}
if (empty($_SERVER['PATH_INFO'])) {
header("Location: {$_SERVER['SCRIPT_NAME']}/");
echo "REDIRECT? 3";
exit;
}
$url = $_SERVER['PATH_INFO'];
$url = str_replace('//','/',$url);
$bits = explode('/',$_SERVER['PATH_INFO']);
$last = array_pop($bits);
$lastbit = $last;
$bits[0] = 'ROOT';
$bits = array_reverse($bits);
$link = './';
foreach($bits as $sub) {
$last = "".htmlspecialchars($sub) . " / {$last}";
$link .= '../';
}
if ($url == '/' && $needAuth) {
if ($needAuth) {
$hhost = str_replace('http://','http://'.$_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW']."@",$host);
}
$data = @file_get_contents($hhost.$url);
if (!$data) {
header('WWW-Authenticate: Basic realm="SVN AUTH"');
header('HTTP/1.0 401 Unauthorized');
echo "You must enter a valid login ID and password to access this resource\n";
exit;
}
}
?>
= $lastbit ?>
Location: =$last ?>
From =htmlspecialchars($host.$url)?>
[View Viewers Source]
if ($needAuth) {
$host = str_replace('http://','http://'.$_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW']."@",$host);
}
$ext = '';
if (preg_match('#\.([a-z]+)$#i',basename($url),$matches)) {
$ext= $matches[1];
}
if (in_array($ext , explode(',','jpeg,jpg,gif,png') )) {
echo "
";
exit;
}
$data = file_get_contents($host.$url);
if (!$data && $url == '/') {
echo "EMPTY: FAIL AUTH AGAIN?";
}
if (!$ext) {
echo $data;
exit;
}
if ( in_array($ext,array('php','class')) && preg_match('/<\?/',$data)) {
highlight_string($data) ;
exit;
}
//echo "";print_R($matches);echo "
";
if (in_array(strtolower($ext) , explode(',','defs,c,h,sh,wddx,xml,css,sql,mysql,psql,txt,js,tc,jay,conf,xul,cpp,hpp,imc') )) {
echo "". htmlspecialchars($data) . "
";
exit;
}
if (in_array($ext , explode(',','tar,tgz,dia,zip') )) {
echo "CAN NOT DISPLAY THIS FILE TYPE
";
exit;
}
// usually dir listings..
echo $data;
}