Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bulk_moves.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
if ( $idField == "DeviceID" ) {
$dev->DeviceID = $row["DeviceID"];
if ( ! $dev->GetDevice() ) {
error_log( "DeviceID = ${DeviceID} not found." );
error_log( "DeviceID = {$DeviceID} not found." );
$rowError = true;
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions classes/Cabinet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
For further details on the license, see http://www.gnu.org/licenses
*/

#[AllowDynamicProperties]
class Cabinet {
/* Cabinet: The workhorse logical container for DCIM. This can be a 2-post rack, a 4-post open rack,
or an enclosed cabinet. The height is variable. Devices are attached to cabinets, and
Expand Down Expand Up @@ -65,7 +66,7 @@ function MakeSafe() {
$this->Keylock=sanitize($this->Keylock);
$this->MaxKW=float_sqlsafe(floatval($this->MaxKW));
$this->MaxWeight=intval($this->MaxWeight);
$this->InstallationDate=date("Y-m-d", strtotime($this->InstallationDate));
$this->InstallationDate=($test=$this->InstallationDate)?date("Y-m-d", strtotime($test)):"";
$this->MapX1=abs((is_numeric($this->MapX1)?$this->MapX1:0));
$this->MapY1=abs((is_numeric($this->MapY1)?$this->MapY1:0));
$this->MapX2=abs((is_numeric($this->MapX2)?$this->MapX2:0));
Expand Down Expand Up @@ -110,7 +111,7 @@ static function RowToObject($dbRow,$filterrights=true){
$cab->Notes=$dbRow["Notes"];
$cab->U1Position=$dbRow["U1Position"];

switch($config->ParameterArray["AssignCabinetLabels"]){
switch(($test=$config->ParameterArray["AssignCabinetLabels"])?$test:""){
case "OwnerName":
$dept=new Department($cab->AssignedTo);
$dept->GetDeptByID();
Expand Down
4 changes: 2 additions & 2 deletions classes/DataCenter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@ function GetDCStatistics(){
$sql="SELECT AVG(NULLIF(a.Temperature, 0)) as AvgTemp FROM fac_SensorReadings a, fac_Cabinet b, fac_Device c
WHERE a.DeviceID=c.DeviceID and c.Cabinet=b.CabinetID AND c.BackSide=0 AND
b.DataCenterID=$this->DataCenterID;";
$dcStats["AvgTemp"]=($test=round($this->query($sql)->fetchColumn()))?$test:0;
$dcStats["AvgTemp"]=round($test=($this->query($sql)->fetchColumn())?$test:0);

$sql="SELECT AVG(NULLIF(a.Humidity, 0)) as AvgHumidity FROM fac_SensorReadings a, fac_Cabinet b, fac_Device c
WHERE a.DeviceID=c.DeviceID and c.BackSide=0 and c.Cabinet=b.CabinetID AND
b.DataCenterID=$this->DataCenterID;";
$dcStats["AvgHumidity"]=($test=round($this->query($sql)->fetchColumn()))?$test:0;
$dcStats["AvgHumidity"]=round($test=($this->query($sql)->fetchColumn())?$test:0);

$pdu=new PowerDistribution();
$dcStats["MeasuredWatts"]=$pdu->GetWattageByDC($this->DataCenterID);
Expand Down
1 change: 1 addition & 0 deletions classes/Device.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
For further details on the license, see http://www.gnu.org/licenses
*/

#[AllowDynamicProperties]
class Device {
/* Device: Assets within the data center, at the most granular level. There are three basic
groupings of information kept about a device: asset tracking, virtualization
Expand Down
2 changes: 2 additions & 0 deletions classes/DeviceTemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

For further details on the license, see http://www.gnu.org/licenses
*/

#[AllowDynamicProperties]
class DeviceTemplate {
var $TemplateID;
var $ManufacturerID;
Expand Down
6 changes: 3 additions & 3 deletions classes/LogActions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function val_comp($v1, $v2) {
$return=true;

// If a retention period has been set, trim the logs for this ObjectID prior to making this entry
if ( $config->ParameterArray["logretention"] > 0 ) {
if ( isset($config->ParameterArray["logretention"]) && $config->ParameterArray["logretention"] > 0 ) {
LogActions::Prune( $config->ParameterArray["logretention"], $log->ObjectID );
}

Expand Down Expand Up @@ -378,14 +378,14 @@ function MakeSafe(){
// If we want to really sanitize this list uncomment the function below
// $this->UserID=(ArraySearchRecursive($this->UserID,$p->GetUserList(),'UserID'))?$this->UserID:'';
$this->UserID=sanitize($this->UserID);
$this->Class=(class_exists($this->Class,true))?$this->Class:'';
$this->Class=$this->Class===null?'':((class_exists($this->Class,true))?$this->Class:'');
$this->ObjectID=sanitize($this->ObjectID);
$this->ChildID=sanitize($this->ChildID);
$this->Action=sanitize($this->Action);
$this->Property=sanitize($this->Property);
$this->OldVal=sanitize($this->OldVal);
$this->NewVal=sanitize($this->NewVal);
$this->Time=date("Y-m-d", strtotime($this->Time));
$this->Time=$this->Time===null?'':date("Y-m-d H:i:s", strtotime($this->Time));
}

function ListUnique($sqlcolumn){
Expand Down
4 changes: 2 additions & 2 deletions classes/Zone.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ function GetZoneStatistics(){
fac_Device b, fac_Cabinet c WHERE a.DeviceID=b.DeviceID AND b.BackSide=0 and
b.Cabinet=c.CabinetID AND a.DeviceID IN (SELECT b.DeviceID FROM fac_Device
WHERE ZoneID=$this->ZoneID);";
$zoneStats["AvgTemp"]=($test=round($this->query($sql)->fetchColumn()))?$test:0;
$zoneStats["AvgTemp"]=round($test=($this->query($sql)->fetchColumn())?$test:0);

$sql="SELECT AVG(NULLIF(Humidity, 0)) AS AvgHumdity FROM fac_SensorReadings a,
fac_Device b, fac_Cabinet c WHERE a.DeviceID=b.DeviceID AND b.BackSide=0 and
b.Cabinet=c.CabinetID AND a.DeviceID IN (SELECT b.DeviceID FROM fac_Device
WHERE ZoneID=$this->ZoneID);";
$zoneStats["AvgHumidity"]=($test=round($this->query($sql)->fetchColumn()))?$test:0;
$zoneStats["AvgHumidity"]=round($test=($this->query($sql)->fetchColumn())?$test:0);

$sql = "select count(*) from fac_Cabinet where ZoneID=" . intval($this->ZoneID);
$zoneStats["TotalCabinets"]=($test=$this->query($sql)->fetchColumn())?$test:0;
Expand Down
3 changes: 2 additions & 1 deletion configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ function formatOffset($offset) {
$tzmenu.="\t<li>$country\n\t\t<ul>";
foreach($cityarray as $key => $city){
$z=new DateTimeZone($city);
$c=new DateTime(null, $z);
$c=new DateTime();
$c->setTimeZone($z);
$adjustedtime=$c->format('H:i a');
$offset=formatOffset($z->getOffset($c));
$tzmenu.="\t\t\t<li><a href=\"#\" data=\"$city\">$adjustedtime - $offset $city</a></li>\n";
Expand Down
4 changes: 2 additions & 2 deletions devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ function updatedevice($devid){
$cab->GetCabinet();
if($person->canWrite($cab->AssignedTo)){
$wattage=$pdu->LogManualWattage($_POST["currwatts"]);
$wattage->LastRead=strftime("%c",strtotime($wattage->LastRead));
$wattage->LastRead=date("Y-m-d H:i:s",strtotime($wattage->LastRead));
}
}
header('Content-Type: application/json');
Expand Down Expand Up @@ -825,7 +825,7 @@ function updatedevice($devid){

$lastreading=$pdu->GetLastReading();
$LastWattage=($lastreading)?$lastreading->Wattage:0;
$LastRead=($lastreading)?strftime("%c",strtotime($lastreading->LastRead)):"Never";
$LastRead=($lastreading)?date("Y-m-d H:i:s",strtotime($lastreading->LastRead)):"Never";
}
}

Expand Down
2 changes: 1 addition & 1 deletion facilities.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
ini_set('date.timezone', 'America/Chicago');
}

if ( isset( $config ) && property_exists( $config, "ParameterArray" ) ){
if ( isset( $config ) && property_exists( $config, "ParameterArray" ) && isset( $config->ParameterArray['timezone'] )){
date_default_timezone_set($config->ParameterArray['timezone']);
} elseif ( getenv("TZ") != "" ) {
date_default_timezone_set( getenv("TZ"));
Expand Down
15 changes: 13 additions & 2 deletions fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,22 @@ function __construct($orientation='P', $unit='mm', $size='A4')
$this->DefOrientation = 'P';
$this->w = $size[0];
$this->h = $size[1];
if($this->w > $this->h) { // Ensure the page is portrait
$temp = $this->w;
$this->w = $this->h
$this->h = $temp;
}
}
elseif($orientation=='l' || $orientation=='landscape')
{
$this->DefOrientation = 'L';
$this->w = $size[1];
$this->h = $size[0];
if($this->w < $this->h) { // Ensure the page is landscape
$temp = $this->w;
$this->w = $this->h
$this->h = $temp;
}
}
else
$this->Error('Incorrect orientation: '.$orientation);
Expand Down Expand Up @@ -575,8 +585,9 @@ function AcceptPageBreak()

function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
$txt=utf8_decode($txt); // Comment this line and uncomment the next line to use TrueType fonts from loadfonts.php
// $txt=iconv("UTF-8","Windows-1251",$txt);
if($txt === null) $txt = "";
$txt=iconv("UTF-8","Windows-1251",$txt); // Comment this line and uncomment the next line to not use TrueType fonts from loadfonts.php
//$txt=utf8_decode($txt);
// Output a cell
$k = $this->k;
if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

$StatsDevices=number_format($row['Devices']);
$StatsServers=number_format($row['Servers']);
$StatsSize=number_format($row['Size']);
$StatsSize=number_format($row['Size'] ? $row['Size'] : 0);
$StatsVM=number_format($row['VMcount']);
$StatsHost=number_format($row["VMhosts"]);
$StatsCabinet=number_format($row["CabinetCount"]);
Expand Down
14 changes: 7 additions & 7 deletions power_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

if(isset($_POST["action"])&&(($_POST["action"]=="Create")||($_POST["action"]=="Update")||($_POST["action"]=="Map"))){
foreach($panel as $prop => $val){
$panel->$prop=trim($_POST[$prop]);
$panel->$prop=isset($_POST[$prop])?trim($_POST[$prop]):'';
}
// Coordinates aren't displayed on this page and the loop above is looking
// for every attribute on the panel model. This will load the original object
Expand Down Expand Up @@ -76,7 +76,7 @@ function FindTicks(&$decimalplaces,$panelCap,&$dataMajorTicks){
$panelCap=1;
}
for ( $i = 0; ($i - $panelCap) < 1; $i+=( $panelCap / 10 ) ) {
$tick = sprintf( "%.0${decimalplaces}lf ", $i / 1000 );
$tick = sprintf( "%.0{$decimalplaces}lf ", $i / 1000 );
if(preg_match("/$tick/",$dataMajorTicks)){
$err=true;
break;
Expand All @@ -90,16 +90,16 @@ function FindTicks(&$decimalplaces,$panelCap,&$dataMajorTicks){
$dataMajorTicks = "";
}

$dataMaxValue = sprintf( "%.0${decimalplaces}lf", $panelCap / 1000 );
$dataMaxValue = sprintf( "%.0{$decimalplaces}lf", $panelCap / 1000 );

$dataHighlights = sprintf( "0 %d #eee, %d %d #fffacd, %d %d #eaa", $panelCap / 1000 * .6, $panelCap / 1000 * .6, $panelCap / 1000 * .8, $panelCap / 1000 * .8, $panelCap / 1000);

$mtarray=implode(",",explode(" ",$dataMajorTicks));
$hilights = sprintf( "{from: 0, to: %.0${decimalplaces}lf, color: '#eee'}, {from: %.0${decimalplaces}lf, to: %.0${decimalplaces}lf, color: '#fffacd'}, {from: %.0${decimalplaces}lf, to: %.0${decimalplaces}lf, color: '#eaa'}", $panelCap / 1000 * .6, $panelCap / 1000 * .6, $panelCap / 1000 * .8, $panelCap / 1000 * .8, $panelCap / 1000);
$hilights = sprintf( "{from: 0, to: %.0{$decimalplaces}lf, color: '#eee'}, {from: %.0{$decimalplaces}lf, to: %.0{$decimalplaces}lf, color: '#fffacd'}, {from: %.0{$decimalplaces}lf, to: %.0{$decimalplaces}lf, color: '#eaa'}", $panelCap / 1000 * .6, $panelCap / 1000 * .6, $panelCap / 1000 * .8, $panelCap / 1000 * .8, $panelCap / 1000);

$panelLoad = sprintf( "%.0${decimalplaces}lf", PowerPanel::getInheritedLoad($panel->PanelID) / 1000 );
$msrLoad = sprintf( "%.0${decimalplaces}lf", $panel->getPanelLoad() / 1000 );
$estLoad = sprintf( "%.0${decimalplaces}lf", PowerPanel::getEstimatedLoad($panel->PanelID) / 1000 );
$panelLoad = sprintf( "%.0{$decimalplaces}lf", PowerPanel::getInheritedLoad($panel->PanelID) / 1000 );
$msrLoad = sprintf( "%.0{$decimalplaces}lf", $panel->getPanelLoad() / 1000 );
$estLoad = sprintf( "%.0{$decimalplaces}lf", PowerPanel::getEstimatedLoad($panel->PanelID) / 1000 );

// Generate JS for load display

Expand Down
4 changes: 2 additions & 2 deletions preflight.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function get_base_url() {
}

$locales=array();
foreach(explode("\n",trim(shell_exec('locale -a | grep -i utf'))) as $line){
foreach(explode("\n",trim(($temp=shell_exec('locale -a | grep -i utf'))?$temp:'')) as $line){
$locales[]=substr($line, 0, strpos($line, '.'));
}
if(count($locales)>1){
Expand Down Expand Up @@ -281,7 +281,7 @@ function get_base_url() {
rewrite ^(.*) /opendcim/api/test/index.php last;
}</pre>";
$tests['api_test']['state']="fail";
$tests['api_test']['message']="Apache does not appear to be rewriting URLs correctly. Check your AllowOverride directive and change to 'AllowOverride All'";
$tests['api_test']['message']="Nginx does not appear to be rewriting URLs correctly. Check your AllowOverride directive and change to 'AllowOverride All'";

}else{
$tests['web_server']['state']="fail";
Expand Down
4 changes: 2 additions & 2 deletions rackrequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
$req->RequestedAction=$_POST['requestedaction'];
$req->Label=$_POST['label'];
$req->SerialNo=$_POST['serialno'];
$req->MfgDate=date('Y-m-d',strtotime($_POST["mfgdate"]));
$req->MfgDate=isset($_POST["mfgdate"])?date('Y-m-d',strtotime($_POST["mfgdate"])):"";
$req->AssetTag=$_POST['assettag'];
$req->Hypervisor=$_POST['hypervisor'];
$req->Owner=$_POST['owner'];
Expand Down Expand Up @@ -370,7 +370,7 @@
</div>
<div>
<div><label for="mfgdate">',__("Manufacture Date"),'</label></div>
<div><input type="text" name="mfgdate" id="mfgdate" size="20" value="',date('Y-m-d',strtotime($req->MfgDate)),'"></div>
<div><input type="text" name="mfgdate" id="mfgdate" size="20" value="',($req->MfgDate!==null)?date('Y-m-d',strtotime($req->MfgDate)):"",'"></div>
</div>
<div>
<div><label for="assettag">',__("Asset Tag"),'</label></div>
Expand Down
3 changes: 2 additions & 1 deletion report_asset_Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ function formatWSColumns($worksheet, $columns)
*/
function cmpDevPos($a, $b)
{
return (intval($a->Position) > intval($b->Position));
if($a == $b) return 0
return (intval($a->Position) > intval($b->Position))?1:-1;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion report_audit_frequency.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function _putcatalog()
$pdf->Cell( $cellWidths[0], 6, $period, $borders, 0, 'L', $fill );
$pdf->Cell( $cellWidths[1], 6, $value, $borders, 0, 'C', $fill );
// Silencing the next line because i'm too lazy to validate the data properly
@$pdf->Cell( $cellWidths[2], 6, sprintf( "%.2f%%", $value / $totalAudits * 100 ), $borders, 0, 'C', $fill );
@$pdf->Cell( $cellWidths[2], 6, sprintf( "%.2f%%", ($totalAudits==0)?0:($value / $totalAudits * 100) ), $borders, 0, 'C', $fill );
$pdf->Ln();

$fill =! $fill;
Expand Down
6 changes: 6 additions & 0 deletions report_network_map.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
do {
require_once "db.inc.php";
require_once "facilities.inc.php";

Expand Down Expand Up @@ -267,6 +268,10 @@
$devList[$deviceType][$devid] = $n_dev_label;
}
}
if(count($portList)==0) {
$body = "No ports found as connected. Please connect ports before generating a network map";
break;
}
# create a lookup table for colors on the fly. This helps make sure that
# the random colors we select (for colors we can't match) stay consistent
$myCableColorList = array();
Expand Down Expand Up @@ -581,6 +586,7 @@
exit;
}
}
} while(false);
?>
<!doctype html>
<html>
Expand Down
14 changes: 11 additions & 3 deletions report_sensors.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,21 @@ function redraw(){
<?php
print ("$tableheader");
foreach( $devList as $d ) {
$Temperature = "n/a";
$Humidity = "n/a";
$LastRead = "n/a";
if isset($sensorReadings[$d->DeviceID]) {
$Temperature = $sensorReadings[$d->DeviceID]->Temperature;
$Humidity = $sensorReadings[$d->DeviceID]->Humidity;
$LastRead = $sensorReadings[$d->DeviceID]->LastRead;
}
print ("\t\t<tr>
<td>{$dcList[$cabList[$d->Cabinet]->DataCenterID]->Name}</td>
<td>{$cabList[$d->Cabinet]->Location}</td>
<td>{$d->Label}</td>
<td>{$sensorReadings[$d->DeviceID]->Temperature}</td>
<td>{$sensorReadings[$d->DeviceID]->Humidity}</td>
<td>{$sensorReadings[$d->DeviceID]->LastRead}</td>
<td>$Temperature</td>
<td>$Humidity</td>
<td>$LastRead</td>
</tr>\n");
}
?>
Expand Down
2 changes: 1 addition & 1 deletion report_supply_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="50%" style="color:#0000BB;"><span style="font-weight: bold; font-size: 14pt;">'.$config->ParameterArray["OrgName"].'</span></td>
<td width="50%" style="text-align: right;">'.__("Date").':<span style="font-weight: bold; font-size: 12pt;">'.strftime("%x").'</span></td>
<td width="50%" style="text-align: right;">'.__("Date").':<span style="font-weight: bold; font-size: 12pt;">'.date("Y-m-d H-i-s").'</span></td>
</tr></table>
</htmlpageheader>

Expand Down
11 changes: 6 additions & 5 deletions report_vendor_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@
$templateList = $dt->Search();

if ( sizeof($templateList) > 0 ) {
$sheet = $workBook->createSheet(null);
$sheet->setTitle( $mfg->Name );
$sheet = $workBook->createSheet(null);
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
$sheet->setTitle( preg_replace("/[*:\\/\\\\?[\\]]+/","_",$mfg->Name) );

foreach( $columnList as $fieldName=>$columnName ) {
$cellAddr = $columnName."1";
Expand Down Expand Up @@ -237,13 +238,13 @@

if ( $d->Cabinet == -1 ) {
$sheet->setCellValue( $columnList["Cabinet"].$currRow, "Storage" );
$sheet->setCellValue( $columnList["DataCenter"].$currRow, $dcList[$d->Position]->Name);
$sheet->setCellValue( $columnList["DataCenter"].$currRow, isset($dcList[$d->Position])?$dcList[$d->Position]->Name:"");
} else {
$thisCab = $cabList[$d->Cabinet];
$sheet->setCellValue( $columnList["Cabinet"].$currRow, $thisCab->Location);
$sheet->setCellValue( $columnList["DataCenter"].$currRow, $dcList[$thisCab->DataCenterID]->Name);
$sheet->setCellValue( $columnList["DataCenter"].$currRow, isset($dcList[$thisCab->DataCenterID])?$dcList[$thisCab->DataCenterID]->Name:"");
}
$sheet->setCellValue( $columnList["Department"].$currRow, $depList[$d->Owner]->Name );
$sheet->setCellValue( $columnList["Department"].$currRow, isset($depList[$d->Owner])?$depList[$d->Owner]->Name:"" );

$currRow++;
}
Expand Down
1 change: 1 addition & 0 deletions rightscheck.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if(file_exists("db.inc.php")) require_once("db.inc.php"); ?>
<!doctype html>
<html>
<head>
Expand Down
2 changes: 2 additions & 0 deletions scripts/ajax_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
require_once( "../facilities.inc.php" );

class Response {
var $SessionID;
var $Percentage;
var $Status;
}

$resp = new Response();
Expand Down
Loading