diff --git a/installer.php b/installer.php new file mode 100644 index 000000000..7c39df060 --- /dev/null +++ b/installer.php @@ -0,0 +1,646 @@ + +\nOpen db.inc.php with a text editor and fill in the blanks for user, pass, database, and server."; + exit; + } + + require_once( "db.inc.php" ); +// Functions for upgrade / installing db objects + $successlog=""; + +function applyupdate ($updatefile){ + //Make sure the upgrade file exists. + if(file_exists($updatefile)){ + $file=fopen($updatefile, 'r'); + $sql=array(); + while(feof($file)===false){ + $sql[]=fgets($file); + } + $sqlstring=""; + foreach($sql as $key => $value){ + // I really need a better way to filter out comments but this works. + if(substr($value,0,1)=='-'){ + }else{ + $sqlstring.=trim($value); + } + } + fclose($file); + $sql=explode(";",$sqlstring); + unset($sql[count($sql)-1]); + $result=0; + foreach($sql as $key => $value){ + echo $value."
\n"; + if(!mysql_query($value)){ + //something broke log it + @$errormsg.=mysql_error(); + $result=1; + } + } + if($result){ + if(!isset($errormsg)){ + $errormsg="An error has occured while applying $updatefile. Please consult the server logs for more details."; + } + }else{ + $successlog="$updatefile: Database updates applied.\n
"; + } + }else{ + $errormsg="Seems you're at 1.0 but you're missing the db updates to goto 1.1. Are you sure that db-1.0-to-1.1.sql unpacked from the archive?"; + } + $temp=array(); + if(isset($errormsg)){ + $temp[1]=$errormsg; + }else{ + $temp[0]=$successlog; + } + return $temp; +} + $upgrade=false; +// Check to see if we are doing an upgrade or an install + $result=mysql_query("SHOW TABLES;"); + if(mysql_num_rows($result)==0){ // No tables in the DB so try to install. + $results[]=applyupdate("create.sql"); + $upgrade=true; + } +// test for openDCIM version + $result=mysql_query("SELECT Value FROM fac_Config WHERE Parameter='Version' LIMIT 1;"); + if(mysql_num_rows($result)==0){// Empty result set means this is either 1.0 or 1.1. Surely the check above caught all 1.0 instances. + $results[]=applyupdate("db-1.1-to-1.2.sql"); + $upgrade=true; + }else{ + $version=mysql_result($result,0);//sets version number + } + if($version=="1.2"){ // Do 1.2 to 1.3 Update +// $upgrade=true; + } + if($upgrade==true){ //If we're doing an upgrade don't call the rest of the installer. +?> + + + +Upgrade + + + + $value){ + foreach($value as $status => $message){ + if($status==1){$class="error";}else{$class="success";} + print "

$message

"; + } + } + print "

If all updates have completed. Please remove upgrade.php to return to normal functionality

"; +}else{ + echo '

All is well. Please remove upgrade.php to return to normal functionality

'; +} +?> + + + + +ParameterArray as $key=>$value){ + if($key=="ClassList"){ + $List=explode(", ",$_REQUEST[$key]); + $config->ParameterArray[$key]=$List; + }else{ + $config->ParameterArray[$key]=$_REQUEST[$key]; + } + } + $config->UpdateConfig($facDB); + } + +// Departments Form Submission + if(isset($_REQUEST['deptid'])&&($_REQUEST['deptid']>0)){ + $dept->DeptID = $_REQUEST['deptid']; + $dept->GetDeptByID( $facDB ); + } + + if(isset($_REQUEST['deptaction'])&& (($_REQUEST['deptaction']=='Create') || ($_REQUEST['deptaction']=='Update'))){ + $dept->DeptID = $_REQUEST['deptid']; + $dept->Name = $_REQUEST['name']; + $dept->ExecSponsor = $_REQUEST['execsponsor']; + $dept->SDM = $_REQUEST['sdm']; + $dept->Classification = $_REQUEST['classification']; + + if($_REQUEST['deptaction']=='Create'){ + if($dept->Name != '' && $dept->Name != null) + $dept->CreateDepartment($facDB); + }else{ + $dept->UpdateDepartment($facDB); + } + } + $result=mysql_query("SELECT * FROM fac_Department LIMIT 1;"); + if(mysql_num_rows($result)==0){ // No departments defined + $nodept="

Create a department

"; + $nodeptdrop="readonly"; + }else{ + $nodept=$nodeptdrop=""; + } + +// Data Centers Form Submission + if(isset($_REQUEST['dcaction']) && (($_REQUEST['dcaction']=='Create')||($_REQUEST['dcaction']=='Update'))){ + $dc->DataCenterID = $_REQUEST['datacenterid']; + $dc->Name = $_REQUEST['name']; + $dc->SquareFootage = $_REQUEST['squarefootage']; + $dc->DeliveryAddress = $_REQUEST['deliveryaddress']; + $dc->Administrator = $_REQUEST['administrator']; + $dc->DrawingFileName = $_REQUEST['drawingfilename']; + + if($_REQUEST['dcaction']=='Create'){ + $dc->CreateDataCenter($facDB); + }else{ + $dc->UpdateDataCenter($facDB); + } + } + + if(isset($_REQUEST['datacenterid']) && $_REQUEST['datacenterid'] >0){ + $dc->DataCenterID=$_REQUEST['datacenterid']; + $dc->GetDataCenter($facDB); + } + $dcList=$dc->GetDCList($facDB); + $result=mysql_query("SELECT * FROM fac_DataCenter LIMIT 1;"); + if(mysql_num_rows($result)==0){ // No data centers configured disable cabinets and complete options + $nodc="

Define a data center

"; + $nodccab="

You must create a Data Center before you can create cabinets in it.

"; + $nodcfield="disabled"; + $nodcdrop="readonly"; + }else{ + $nodc=$nodccab=$nodcfield=$nodcdrop=""; + } + +//Cabinet Form Submission + if(isset($_REQUEST['cabinetid'])){ + $cab->CabinetID=$_REQUEST['cabinetid']; + $cab->GetCabinet($facDB); + } + + if(isset($_REQUEST['cabaction'])){ + if(($cab->CabinetID >0)&&($_REQUEST['cabaction']=='Update')){ + $cab->DataCenterID=$_REQUEST['datacenterid']; + $cab->Location=$_REQUEST['location']; + $cab->AssignedTo=$_REQUEST['assignedto']; + $cab->CabinetHeight=$_REQUEST['cabinetheight']; + $cab->Model=$_REQUEST['model']; + $cab->MaxKW=$_REQUEST['maxkw']; + $cab->MaxWeight=$_REQUEST['maxweight']; + $cab->InstallationDate=$_REQUEST['installationdate']; + $cab->UpdateCabinet($facDB); + }elseif($_REQUEST['cabaction']=='Create'){ + $cab->DataCenterID=$_REQUEST['datacenterid']; + $cab->Location=$_REQUEST['location']; + $cab->AssignedTo=$_REQUEST['assignedto']; + $cab->CabinetHeight=$_REQUEST['cabinetheight']; + $cab->Model=$_REQUEST['model']; + $cab->MaxKW=$_REQUEST['maxkw']; + $cab->MaxWeight=$_REQUEST['maxweight']; + $cab->InstallationDate=$_REQUEST['installationdate']; + $cab->CreateCabinet($facDB); + } + } + if($nodccab==""){ // only attempt to check for racks in the db if a data center has already been created + $result=mysql_query("SELECT * FROM fac_Cabinet LIMIT 1;"); + if(mysql_num_rows($result)==0){ // No racks defined disable complete option + $nodccab="

Create a rack for equipment to be housed in

"; + $nocabdrop="readonly"; + $nocab="error"; + }else{ + $nocab=$nocabdrop=$nodccab=""; + } + } + +//Installation Complete + if($nodept=="" && $nodc=="" && $nocab==""){ // All three primary sections have had at least one item created + //enable the finish menu option + $complete=true; + } + +?> + + + + + openDCIM Installer + + + + + + + + + + + +
+ + + +
+

ParameterArray["OrgName"]; ?>

+

Data Center Configuration

+

Database Version: ParameterArray["Version"]; ?>

+
+
?conf" method="POST"> + + +
+

Parameter

Value

+ParameterArray as $key=>$value){ + + if ( strpos( $key, "Color" ) ) { + $class='class="color-picker"'; + $cssfix1='
'; + $cssfix2='
'; + } else { + $cssfix1=$cssfix2=$class=''; + } + + if ($key =="ClassList"){ + $numItems=count($config->ParameterArray[$key]); + $i=0; + $valueStr=""; + foreach($config->ParameterArray[$key] as $item){ + $valueStr .= $item; + if($i+1 != $numItems){ + $valueStr.=", "; + } + $i++; + } + print "
\n"; + print "
$key:
\n"; + print "
\n"; + print "
\n"; + } elseif ( $key != "Version" ) { + print "
\n"; + print "
$key:
\n"; + print "
$cssfix1ParameterArray[$key]}\">$cssfix2
\n"; + print "
\n"; + } + } +?> +
+
+
+
+
+
+ +
+GetDepartmentList( $facDB ); +?> + + +
+ + + +
+

ParameterArray['OrgName']; ?>

+

Data Center Department Detail

+ +
+
+
+
+
Department
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +DeptID > 0){ + echo ''; + echo "DeptID)\" value=\"Assign Contacts\">"; +// print "DeptID'\" value=\"Assign Contacts\">"; +// print "DeptID', 'popup')\" value=\"Assign Contacts\">"; + } +?> +
+
+
+ +
+
+
+
+ + + +
+ + + +
+

ParameterArray['OrgName']; ?>

+

Data Center Detail

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+DataCenterID >0){ + echo ' '; + }else{ + echo ' '; + } +?> +
+
+
+
+
+
+ +CabinetID >0){ + $cab->GetCabinet($facDB); + }else{ + $cab->CabinetID=null; + $cab->DataCenterID=null; + $cab->Location=null; + $cab->CabinetHeight=null; + $cab->Model=null; + $cab->MaxKW=null; + $cab->MaxWeight=null; + $cab->InstallationDate=date('m/d/Y'); + } + + $deptList=$dept->GetDepartmentList($facDB); + $cabList=$cab->ListCabinets($facDB); +?> + +
+ +
+

ParameterArray['OrgName']; ?>

+

Data Center Cabinet Inventory

+ +
+
?cab' method='POST'> +
+
+
Cabinet
+
+
+
+
Data Center
+
GetDCSelectList($facDB); ?>
+
+
+
Location
+
>
+
+
+
Assigned To:
+
+
+
+
+
Cabinet Height (U)
+
>
+
+
+
Model
+
>
+
+
+
Maximum kW
+
>
+
+
+
Maximum Weight
+
>
+
+
+
Date of Installation
+
InstallationDate)); ?>' >
+
+'; + if($cab->CabinetID >0){ + echo ' '; + }else{ + echo ' '; + } + echo '
'; + } +?> +
+ +
+
+
+ +
+ +
+

ParameterArray['OrgName']; ?>

+

Installation Complete

+ +
+ +

You have completed the basic configuration for openDCIM. At this time please goto the wiki for additional questions that you might have or join our mailing list at [insert link here].

+

To start normal operation of openDCIM please delete install.php from the installation directory

+ + +
+
+
+ + + + + +