<?
/*
VMLMAT: VM Linux Management and Archival Tool.
Copyright (c) 2007, Ronnie Michael, BMC Software Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the BMC Software Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#
# This module is designed to create and del the hostname machines.
#
/* if they bookmark this throw them out if not already validated through auth.php */
session_start();
$user=$_SESSION['user'];
if (empty($user)){
#issue error message
$_SESSION['errmsg']="autherr";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
exit;
}
if (isset($_REQUEST['cancel'])) {
#issue error message
$_SESSION['errmsg']="cancel";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
exit;
}
# get parmfile variables needed
include '/var/clone/bkinc.php';
#
#
#make sure they didn't put a white space the variable
$host = $_REQUEST['host'];
$test=explode(" ",$host);
if (!empty($test[1])) {
#issue error message
$_SESSION['errmsg']="serr";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
exit;
}
if ($case == "UPPER") {$host = strtoupper($host);}
else {$host = strtolower($host);}
$auth=false;
$filen="archive/authfile";
#lets spin until we get file lock
while (file_exists($filen."_lock")) {}
touch($filen."_lock");
$fp = fopen($filen, 'r' );
$file_data = fread( $fp, filesize( $filen ) );
fclose( $fp );
unlink($filen."_lock");
$lines = explode ( "\n", $file_data );
foreach ( $lines as $line ) {
list( $hostn, $owner, $func ) = explode( ':', $line );
if (strtoupper($hostn) == "ZMACHINE" && strtoupper($owner) == strtoupper($user)) {
$auth=true;
}
if (strtoupper($hostn) == "ZADMIN" && strtoupper($owner) == strtoupper($user)) {
$auth=true;
}
}
if (! $auth) {
#issue error message
$_SESSION['errmsg']="unauthm";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
exit;
}
#
# get parmfile variables needed
include '/var/clone/bkinc.php';
#
$fln=$host;
$ffln=$fln . ".php";
$pfln=$wwwpath . "/zmachines/" . $ffln;
#
#
if (!isset($_REQUEST['del'])) {
$fhw = fopen($pfln,'w');
$nl = "\n";
$wdata ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<html><head><title>' . $fln . ' - Process Your System</title>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<link rel="stylesheet" type="text/css" href="/templates/astyle.css" title="standard"/>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</head><body>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<div id="banner"><a name="top"></a><h1><a href="/index.php">' . $fln . '</a></h1><h2> Linux Management System </h2>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</div>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<div id="commentcontent">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<p> next entry: <a href="/index.php" target="_self">Return</a>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<p>Fill out below to process image <br />' . $nl;
fwrite($fhw, $wdata);
$wdata ='<br />' . $nl;
fwrite($fhw, $wdata);
$wdata ='Allows user to bring up or down the above listed system.<br />' . $nl;
fwrite($fhw, $wdata);
$wdata ='<br />' . $nl;
fwrite($fhw, $wdata);
$wdata ='<br />' . $nl;
fwrite($fhw, $wdata);
$wdata ='</p>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<p><p>Must Fill out the info below</p><a name="comm"></a></p>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<p><a name="#comments"></a><a name="#bottom"></a><form method="post" action="../submit.php"
name="form" >' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="hostname" value="'. $fln .'">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="tarfile" value="tarfile">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="ohost" value="ohost">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="oip" value="oip">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="userid" value="dummy">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="comment" value="comment">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="hidden" name="url" value=self.location>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<table border=0 cellspacing=0 cellpadding=0 width="640">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<tr>' . $nl;
fwrite($fhw, $wdata);
$wdata =' <td>Email:</td>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<?' . $nl;
fwrite($fhw, $wdata);
$wdata ='session_start();' . $nl;
fwrite($fhw, $wdata);
$wdata ='$umail=$_SESSION["umail"];' . $nl;
fwrite($fhw, $wdata);
$wdata ='print "<td><input name=email type=text value=" . $umail . " size=40></td></tr><tr>";' . $nl;
fwrite($fhw, $wdata);
$wdata ='?>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</table>' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="submit" name="up" value="Up" style="border: 1px inset black;">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="submit" name="down" value="Down" style="border: 1px inset black;">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<input type="submit" name="cancel" value="Cancel" style="border: 1px inset black;">' . $nl;
fwrite($fhw, $wdata);
$wdata ='<br><br>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</form></p>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</div>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</body>' . $nl;
fwrite($fhw, $wdata);
$wdata ='</html>' . $nl;
fwrite($fhw, $wdata);
fclose($fhw);
#issue error message
$_SESSION['errmsg']="mok";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
}
if (isset($_REQUEST['del'])) {
if (file_exists($pfln)) {
system("rm " . $pfln);
#issue error message
$_SESSION['errmsg']="mdel";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
} else {
#issue error message
$_SESSION['errmsg']="mnok";
session_write_close();
header("Location: http://".$_SERVER['HTTP_HOST']."/errmsg.php");
}
}
?>