Файл: id2759/PHP Version/fileman/source.php
Строк: 141
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Aquonics File Manager |
// +----------------------------------------------------------------------+
// | Copyright (c) 2001 Aquonics Scripting |
// +----------------------------------------------------------------------+
// | You may not remove the copyright or redistribute the script in any |
// | form. This program is Freeware, please read the license at |
// | http://www.aquonics.com/license.php |
// | |
// | Visit www.aquonics.com for more top scripts, free and custom. |
// +----------------------------------------------------------------------+
// | Authors: Stephen Ball <stephen@aquonics.com> |
// +----------------------------------------------------------------------+
//
// $Id$
error_reporting(0); /* Turn off ugly error messages */
set_time_limit(60); /* Ensure the script doesn't time out */
// Try to include important files
// or die with an error message
if (!(include("./common.lib.php"))) {
die("<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the library file.</b></center></font></body></html>");
}
if (!(include("./settings.inc.php"))) {
die("<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the settings file.</b></center></font></body></html>");
}
$username = $HTTP_COOKIE_VARS["username"];
$password = $HTTP_COOKIE_VARS["password"];
// Find out the starttime
$starttime = starttime();
// Print the page header
html_header("Source Code");
// Ensure the user selects a file to view
if (empty($QUERY_STRING)) {
echo " <tr>rn";
echo " <th align="left" bgcolor="#4682B4" valign="middle"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#FFFFFF">Notice</font></th>rn";
echo " </tr>rn";
echo " <tr>rn";
echo " <td align="left" bgcolor="#F5F5F5" valign="middle"><font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">Please choose a file to highlight.</font></td>rn";
echo " </tr>rn";
}
else {
$fullpath = cleanpath(rawurldecode($QUERY_STRING));
$fullpath = $root_dir . $QUERY_STRING;
$file = basename($fullpath);
if (validate_user($username, $password) == 0) {
// Ensure the user is allowed access
$code = "<font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">You are not authorized to access this file.</font>";
$file = "Please Log in";
}
else if (file_exists($fullpath) == 0) {
// Ensure the file exists
$code = "<font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">$file does not exist.</font>"; # Ensure the file has some content
}
else if (ereg($root_dir, $fullpath) == false) {
// Ensure the file is within the allowed path
$code = "<font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">You can not access this file!</font>";
}
else if (filesize($fullpath) == 0) {
// Ensure the file has some content
$code = "<font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">$file is empty.</font>"; # Ensure the file has some content
}
else {
ob_start(); # Start the output buffer
show_source($fullpath); # Highlight the file
$code = ob_get_contents(); # Collect the content of the buffer
ob_end_clean(); # Empty the buffer, and end
$code = str_replace("<br>", "<br />", $code); # Fix the HTML code to make it XHTML compatiable
}
// Print out the content
echo " <tr>rn";
echo " <th align="left" bgcolor="#4682B4" valign="middle"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#FFFFFF">$file</font></th>rn";
echo " </tr>rn";
echo " <tr>rn";
echo " <td align="left" bgcolor="#F5F5F5" valign="middle">$code</td>rn";
echo " </tr>rn";
}
// Print the page footer
html_footer($starttime);
?>