Show techsupport.php syntax highlighted
<?php
/*
Tech Support script by Jason Morriss <stormtrooper@psychostats.com>
This script should only be used when asked by "Stormtrooper" any other "offical" psychostats helper.
By default this script is disabled to prevent malicious use by others. To enable this script see the
instructions below.
*/
// To enable this script comment out the line below (put # or // in front of the line)
//die("Access to this file is restricted. View the file source to learn how to enable this script.");
// ------------------------------------------ DO NOT EDIT ANYTHING BELOW THIS LINE ---------------------------------------
define("VALID_PAGE", 1);
define("NOTIMER", 1);
define("NOSESSION", 1);
define("NOTHEME", 1);
require(dirname(__FILE__) . "/includes/common.php");
require(DOCROOT . "includes/class_db.php");
$version = "1.0";
$scandirs = array(
catfile($conf['template_dir'], $conf['theme']),
catfile($conf['compile_dir']),
catfile($conf['statsroot']),
);
// Taken directly from http://us2.php.net/manual/en/function.fileperms.php
function fperms($file) {
$perms = fileperms($file);
$o = @fileowner($file);
$o = ($o !== FALSE) ? @posix_getpwuid($o) : array();
$g = @filegroup($file);
$g = ($g !== FALSE) ? @posix_getgrgid($g) : array();
$owner = $o['name'];
$group = $g['name'];
if (($perms & 0xC000) == 0xC000) { // Socket
$info = 's';
} elseif (($perms & 0xA000) == 0xA000) { // Symbolic Link
$info = 'l';
} elseif (($perms & 0x8000) == 0x8000) { // Regular
$info = '-';
} elseif (($perms & 0x6000) == 0x6000) { // Block special
$info = 'b';
} elseif (($perms & 0x4000) == 0x4000) { // Directory
$info = 'd';
} elseif (($perms & 0x2000) == 0x2000) { // Character special
$info = 'c';
} elseif (($perms & 0x1000) == 0x1000) { // FIFO pipe
$info = 'p';
} else { // Unknown
$info = 'u';
}
// Owner
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
// Group
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
// World
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
if ($owner) $info .= str_replace(" ", " ", sprintf(" %-10s", $owner));
if ($group) $info .= str_replace(" ", " ", sprintf(" %-10s", $group));
return $info;
}
// starts at the first directory given and shows the permissions for it and each parent directory above it
function dirperms($_dir, $prefix="<li>") {
$dir = $_dir;
$lastdir = '';
$output = '';
while ($dir != $lastdir) {
$output .= $prefix . fperms($dir) . " $dir\n";
$lastdir = $dir;
$dir = dirname($dir);
}
return $output;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PsychoStats Tech Support Diagnostic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
BODY {
background: white;
font-family: Arial;
font-size: 12pt;
color: black;
}
A, A:visited {
text-decoration: none;
color: blue;
font-size: 12pt;
}
A:hover {
text-decoration: underline;
}
.hdr1 {
color: darkred;
border: 2px solid darkred;
padding: 5px;
font-weight: bold;
}
.box {
border: 1px solid black;
padding: 3px;
}
.file {
font-family: Terminal;
font-size: 10pt;
}
</style>
</head>
<body>
<a name="top"></a>
<div class="hdr1" align="center">
PsychoStats Techsupport Diagnostic v<?php echo $version;?>
</div><br>
<a link="conf"></a>
<fieldset id="conf" class="box">
<legend><b>Your Configuration</b></legend>
<ul>
<?php
foreach ($conf as $key => $value) {
if (!is_array($conf[$key])) {
$val = ($key === 'dbpass') ? "<u><secret></u>" : htmlentities($value);
printf("<li><b>%s</b> = \"%s\"\n", htmlentities($key), $val);
} else {
print "<li><b>$key</b>\n<ul>\n";
foreach ($conf[$key] as $key2 => $value2) {
printf("<li>\"%s\"\n", htmlentities($value2));
}
print "</ul>\n";
}
}
?>
</ul>
</fieldset>
<br>
<a link="dirs"></a>
<fieldset id="dirs" class="box">
<legend><b>Directory Scan</b></legend>
<ul>
<?php
foreach ($scandirs as $dir) {
print "<li class=\"file\"><b>$dir</b>\n<ul>\n" . dirperms($dir) . "</ul>\n";
}
?>
</ul>
</fieldset>
<br>
<a link="db"></a>
<fieldset id="db" class="box">
<legend><b>Database Test</b></legend>
<blockquote>
<?php
$db = new DB($conf);
if ($db) {
$info = $db->server_info();
print "Connected to server (" . $info['version'] . ") database <B>" . $conf['dbname'] . "</b> as user <b>" . $conf['dbuser'] . "</b> (" . $info['current_user'] . ") successfully.<br>";
}
?>
</blockquote>
</fieldset>
<br>
</body>
</html>
See more files for this project here