Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5e4e256
fix: PHP 8.2 compatibility for end(explode()) usage in ESX
alex001x Dec 28, 2025
8f225c0
fix: PHP 8.2 safe iteration over object properties
alex001x Dec 28, 2025
a12b27a
fix: PHP 8.2 safe iteration over object properties
alex001x Dec 28, 2025
a764416
fix: PHP 8.2 safe iteration is-iterable
alex001x Dec 28, 2025
50f8fc0
fix: PHP 8.2 safe guarding PDO::query()
alex001x Dec 28, 2025
97c2d9d
fix: PHP 8.2 compatibility (mine detection, iterable, guards)
alex001x Dec 28, 2025
e9ad15b
fix: PHP 8.2 compatibility in Cabinet.class
alex001x Dec 28, 2025
34b6468
fix: PHP 8.2 compatibility in Device.class
alex001x Dec 28, 2025
0a1da74
fix: PHP 8.2 clean ternary op OSS_SMNP in Device.class
alex001x Dec 29, 2025
0fb63ed
fix: PHP 8.2 compatibility clean Container.class
alex001x Dec 29, 2025
2eb37a6
fix: PHP 8.2 compatibility clean Container.class
alex001x Dec 29, 2025
06a9e51
fix: PHP 8.2 compatibility clean Zone.class
alex001x Dec 29, 2025
af47f69
fix: PHP 8.2 compatibility clean CabRow.class
alex001x Dec 29, 2025
79589ba
fix: PHP 8.2 compatibility clean BinAudits.class
alex001x Dec 29, 2025
7caccad
fix: PHP 8.2 compatibility clean BinContents.class
alex001x Dec 29, 2025
a7d805b
fix: PHP 8.2 compatibility clean CabinetAudit.class
alex001x Dec 29, 2025
5479c5d
fix: bug ) ./refresh_idp_metadata.php
alex001x Dec 29, 2025
2a70977
fix: PHP 8.2 compatibility clean CabinetMetrics.class
alex001x Dec 29, 2025
5d400f2
fix: PHP 8.2 compatibility clean CabinetTemps.class
alex001x Dec 29, 2025
53d4e8d
fix: PHP 8.2 compatibility clean CabRow.class
alex001x Dec 29, 2025
ed7170a
fix: PHP 8.2 compatibility clean CDUInfo.class
alex001x Dec 29, 2025
157c683
fix: PHP 8.2 compatibility clean CDUTemplate.class
alex001x Dec 29, 2025
3f897f5
fix: PHP 8.2 compatibility clean ColorCoding.class
alex001x Dec 29, 2025
99a9923
fix: PHP 8.2 compatibility clean ConnectionPath.class
alex001x Dec 29, 2025
f9df007
fix: PHP 8.2 compatibility clean DCIMMail.class
alex001x Dec 29, 2025
d3f7a4e
fix: PHP 8.2 compatibility clean Department.class
alex001x Dec 29, 2025
0b671c8
fix: PHP 8.2 compatibility clean DeviceCustomAttribute.class
alex001x Dec 29, 2025
04dbf75
fix: PHP 8.2 compatibility clean DevicePorts.class
alex001x Dec 29, 2025
b709e59
fix: PHP 8.2 compatibility clean DeviceStatus.inc.class
alex001x Dec 29, 2025
f407959
fix: PHP 8.2 compatibility clean DeviceTemplate.class
alex001x Dec 29, 2025
08cfe3f
fix: PHP 8.2 compatibility clean Escalations.class
alex001x Dec 29, 2025
f27ae4f
fix: PHP 8.2 compatibility clean EscalationTimes.class
alex001x Dec 29, 2025
737e0c7
fix: PHP 8.2 compatibility clean LogActions.class
alex001x Dec 29, 2025
257c97e
fix: PHP 8.2 compatibility clean Manufacturer.class
alex001x Dec 29, 2025
e6b91c9
fix: PHP 8.2 compatibility clean MediaTypes.class
alex001x Dec 29, 2025
f19d123
fix: PHP 8.2 compatibility clean PanelSchedule.class
alex001x Dec 29, 2025
0e608d9
fix: PHP 8.2 compatibility clean PDUStats.class
alex001x Dec 29, 2025
44d38ec
fix: PHP 8.2 compatibility clean People.class
alex001x Dec 29, 2025
f2d0e8a
fix: PHP 8.2 compatibility clean PlannedPath.class
alex001x Dec 29, 2025
fc4b6a4
fix: PHP 8.2 compatibility clean Pmox.class
alex001x Dec 29, 2025
9ffedde
fix: PHP 8.2 compatibility clean PowerConnection.class
alex001x Dec 29, 2025
7662960
fix: PHP 8.2 compatibility clean PowerDistribution.class
alex001x Dec 29, 2025
3b82446
fix: PHP 8.2 compatibility clean PowerPanel.class
alex001x Dec 29, 2025
9206bf6
fix: PHP 8.2 compatibility clean PowerPorts.class
alex001x Dec 29, 2025
d49d26a
fix: PHP 8.2 compatibility clean Projects.class
alex001x Dec 29, 2025
3e181a6
fix: PHP 8.2 compatibility clean PUEView.class
alex001x Dec 29, 2025
a36576b
fix: PHP 8.2 compatibility clean RackRequest.class
alex001x Dec 29, 2025
c6074fb
fix: PHP 8.2 compatibility clean RCI.class
alex001x Dec 29, 2025
9e5a4ce
fix: PHP 8.2 compatibility clean SensorReadings.class
alex001x Dec 29, 2025
364922d
fix: PHP 8.2 compatibility clean SensorTemplate.class
alex001x Dec 29, 2025
80e729c
fix: PHP 8.2 compatibility clean Slot.class
alex001x Dec 29, 2025
43daa81
fix: PHP 8.2 compatibility clean Supplies.class
alex001x Dec 29, 2025
5ca528c
fix: PHP 8.2 compatibility clean SupplyBin.class
alex001x Dec 29, 2025
9907ec5
fix: PHP 8.2 compatibility clean SwitchInfo.class
alex001x Dec 29, 2025
4dc2b9f
fix: PHP 8.2 compatibility clean Tag.class
alex001x Dec 29, 2025
1f83abd
fix: PHP 8.2 compatibility TemplatePorts.class
alex001x Dec 29, 2025
dc1cb85
fix: PHP 8.2 compatibility TemplatePowerPorts.class
alex001x Dec 29, 2025
6917f45
fix: PHP 8.2 compatibility VM.class
alex001x Dec 29, 2025
f097433
Fix project list indexing by ProjectID
alex001x Dec 29, 2025
5f31f9b
Merge branch 'opendcim:master' into fix/php82-cleanup
alex001x Jan 23, 2026
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
9 changes: 7 additions & 2 deletions classes/BinAudits.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BinAudits {

function MakeSafe(){
$this->BinID=intval($this->BinID);
$this->UserID=sanitize($this->UserID);
$this->UserID=trim($this->UserID);
$this->AuditStamp=sanitize($this->AuditStamp);
}

Expand All @@ -48,7 +48,12 @@ function AddAudit(){
$this->MakeSafe();

$sql="INSERT INTO fac_BinAudits SET BinID=$this->BinID, UserID=\"$this->UserID\", AuditStamp=\"$this->AuditStamp\";";
$this->exec($sql);
if ( $this->exec($sql) === false ) {
$info = $GLOBALS['dbh']->errorInfo();
error_log("BinAudits::AddAudit PDO Error: {$info[2]} SQL=$sql");
return false;
}
return true;
}

public static function RedactUser($UserID) {
Expand Down
3 changes: 2 additions & 1 deletion classes/BinContents.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function exec($sql){
}

function AddContents(){
$this->MakeSafe();
$sql="INSERT INTO fac_BinContents SET BinID=$this->BinID, SupplyID=$this->SupplyID, Count=$this->Count;";
return $this->exec($sql);
}
Expand Down Expand Up @@ -92,7 +93,7 @@ function UpdateCount(){
$sql="UPDATE fac_BinContents SET Count=$this->Count WHERE BinID=$this->BinID
AND SupplyID=$this->SupplyID;";

return $this->query($sql);
return $this->exec($sql);
}

function RemoveContents(){
Expand Down
8 changes: 4 additions & 4 deletions classes/CDUInfo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ static private function BasicTests($DeviceID){

// If the device doesn't have an SNMP community set,
// check and see if we have a global one
$dev->SNMPCommunity=($dev->SNMPCommunity=="")?$config->ParameterArray["SNMPCommunity"]:$dev->SNMPCommunity;
$dev->SNMPCommunity=($dev->SNMPCommunity=="")?($config->ParameterArray["SNMPCommunity"] ?? ''):$dev->SNMPCommunity;

// Make this false faster
$dev->SNMPCommunity=trim($dev->SNMPCommunity);
$dev->SNMPCommunity=trim((string)$dev->SNMPCommunity);
if($dev->SNMPCommunity==""){return false;}

// We've passed all the repeatable tests, return the device object for digging
Expand All @@ -58,8 +58,8 @@ static private function BasicTests($DeviceID){
static private function OSS_SNMP_Lookup($dev,$snmplookup,$portid=null,$baseOID=null){
// This is find out the name of the function that called this to
// make the error logging more descriptive
$caller=debug_backtrace();
$caller=$caller[1]['function'];
$trace=debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$caller=$trace[1]['function'] ?? 'unknown';

// Since we don't really let the user specify the version right now here's a stop gap
// Try the default version of 2c first
Expand Down
75 changes: 39 additions & 36 deletions classes/CDUTemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,43 +75,43 @@ function MakeSafe(){
}

function MakeDisplay(){
$this->Model=stripslashes($this->Model);
$this->VersionOID=stripslashes($this->VersionOID);
$this->OutletNameOID=stripslashes($this->OutletNameOID);
$this->OutletDescOID=stripslashes($this->OutletDescOID);
$this->OutletCountOID=stripslashes($this->OutletCountOID);
$this->OutletStatusOID=stripslashes($this->OutletStatusOID);
$this->OutletStatusOn=stripslashes($this->OutletStatusOn);
$this->OID1=stripslashes($this->OID1);
$this->OID2=stripslashes($this->OID2);
$this->OID3=stripslashes($this->OID3);
$this->ATSStatusOID=stripslashes($this->ATSStatusOID);
$this->ATSDesiredResult=stripslashes($this->ATSDesiredResult);
$this->Model=stripslashes((string)$this->Model);
$this->VersionOID=stripslashes((string)$this->VersionOID);
$this->OutletNameOID=stripslashes((string)$this->OutletNameOID);
$this->OutletDescOID=stripslashes((string)$this->OutletDescOID);
$this->OutletCountOID=stripslashes((string)$this->OutletCountOID);
$this->OutletStatusOID=stripslashes((string)$this->OutletStatusOID);
$this->OutletStatusOn=stripslashes((string)$this->OutletStatusOn);
$this->OID1=stripslashes((string)$this->OID1);
$this->OID2=stripslashes((string)$this->OID2);
$this->OID3=stripslashes((string)$this->OID3);
$this->ATSStatusOID=stripslashes((string)$this->ATSStatusOID);
$this->ATSDesiredResult=stripslashes((string)$this->ATSDesiredResult);
}

static function RowToObject($row){
$template=new CDUTemplate();
$template->TemplateID=$row["TemplateID"];
$template->ManufacturerID=$row["ManufacturerID"];
$template->Model=$row["Model"];
$template->Managed=$row["Managed"];
$template->ATS=$row["ATS"];
$template->VersionOID=$row["VersionOID"];
$template->OutletNameOID=$row["OutletNameOID"];
$template->OutletDescOID=$row["OutletDescOID"];
$template->OutletCountOID=$row["OutletCountOID"];
$template->OutletStatusOID=$row["OutletStatusOID"];
$template->OutletStatusOn=$row["OutletStatusOn"];
$template->Multiplier=$row["Multiplier"];
$template->OID1=$row["OID1"];
$template->OID2=$row["OID2"];
$template->OID3=$row["OID3"];
$template->ATSStatusOID=$row["ATSStatusOID"];
$template->ATSDesiredResult=$row["ATSDesiredResult"];
$template->ProcessingProfile=$row["ProcessingProfile"];
$template->Voltage=$row["Voltage"];
$template->Amperage=$row["Amperage"];
$template->NumOutlets=$row["NumOutlets"];
$template->TemplateID=$row["TemplateID"] ?? null;
$template->ManufacturerID=$row["ManufacturerID"] ?? null;
$template->Model=$row["Model"] ?? null;
$template->Managed=$row["Managed"] ?? null;
$template->ATS=$row["ATS"] ?? null;
$template->VersionOID=$row["VersionOID"] ?? null;
$template->OutletNameOID=$row["OutletNameOID"] ?? null;
$template->OutletDescOID=$row["OutletDescOID"] ?? null;
$template->OutletCountOID=$row["OutletCountOID"] ?? null;
$template->OutletStatusOID=$row["OutletStatusOID"] ?? null;
$template->OutletStatusOn=$row["OutletStatusOn"] ?? null;
$template->Multiplier=$row["Multiplier"] ?? null;
$template->OID1=$row["OID1"] ?? null;
$template->OID2=$row["OID2"] ?? null;
$template->OID3=$row["OID3"] ?? null;
$template->ATSStatusOID=$row["ATSStatusOID"] ?? null;
$template->ATSDesiredResult=$row["ATSDesiredResult"] ?? null;
$template->ProcessingProfile=$row["ProcessingProfile"] ?? null;
$template->Voltage=$row["Voltage"] ?? null;
$template->Amperage=$row["Amperage"] ?? null;
$template->NumOutlets=$row["NumOutlets"] ?? null;

$template->MakeDisplay();

Expand All @@ -125,8 +125,10 @@ function GetTemplateList(){
a.ManufacturerID=b.ManufacturerID ORDER BY b.Name ASC,a.Model ASC;";

$tmpList=array();
foreach($dbh->query($sql) as $row){
$tmpList[]=CDUTemplate::RowToObject($row);
if($stmt=$dbh->query($sql)){
foreach($stmt as $row){
$tmpList[]=CDUTemplate::RowToObject($row);
}
}

return $tmpList;
Expand All @@ -139,7 +141,8 @@ function GetTemplate(){

$sql="SELECT * FROM fac_CDUTemplate WHERE TemplateID=$this->TemplateID";

if($row=$dbh->query($sql)->fetch()){
$stmt=$dbh->query($sql);
if($stmt && ($row=$stmt->fetch())){
foreach(CDUTemplate::RowToObject($row) as $prop => $value){
$this->$prop=$value;
}
Expand Down
58 changes: 35 additions & 23 deletions classes/CabRow.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ function MakeSafe() {
}

function MakeDisplay(){
$this->Name=stripslashes($this->Name);
$this->Name=stripslashes((string)$this->Name);
}

static function RowToObject($row){
$cabrow=new CabRow();
$cabrow->CabRowID=$row["CabRowID"];
$cabrow->Name=$row["Name"];
$cabrow->DataCenterID=$row["DataCenterID"];
$cabrow->ZoneID=$row["ZoneID"];
$cabrow->CabRowID=$row["CabRowID"] ?? null;
$cabrow->Name=$row["Name"] ?? null;
$cabrow->DataCenterID=$row["DataCenterID"] ?? null;
$cabrow->ZoneID=$row["ZoneID"] ?? null;
$cabrow->MakeDisplay();

return $cabrow;
Expand Down Expand Up @@ -134,8 +134,10 @@ function GetCabRow(){

$sql="SELECT * FROM fac_CabRow WHERE CabRowID=$this->CabRowID;";

if($row=$this->query($sql)->fetch()){
foreach(CabRow::RowToObject($row) as $prop => $value){
$stmt=$this->query($sql);
if($stmt && ($row=$stmt->fetch())){
$tmp = CabRow::RowToObject($row);
foreach (get_object_vars($tmp) as $prop => $value) {
$this->$prop=$value;
}
return true;
Expand All @@ -150,8 +152,10 @@ function GetCabRowsByZones(){
$sql="SELECT * FROM fac_CabRow WHERE ZoneID=$this->ZoneID ORDER BY Name;";

$cabrowList=array();
foreach($this->query($sql) as $row){
$cabrowList[]=CabRow::RowToObject($row);
if($stmt=$this->query($sql)){
foreach($stmt as $row){
$cabrowList[]=CabRow::RowToObject($row);
}
}

return $cabrowList;
Expand All @@ -166,18 +170,23 @@ function GetCabRowsByDC($nozone=false){
$sql="SELECT * FROM fac_CabRow WHERE DataCenterID=$this->DataCenterID AND $sqladdon ORDER BY Name;";

$cabrowList=array();
foreach($this->query($sql) as $row){
$cabrowList[]=CabRow::RowToObject($row);
if($stmt=$this->query($sql)){
foreach($stmt as $row){
$cabrowList[]=CabRow::RowToObject($row);
}
}

return $cabrowList;
}
function GetCabRowList(){
$this->MakeSafe();
$sql="SELECT * FROM fac_CabRow ORDER BY Name ASC;";

$cabrowList=array();
foreach($this->query($sql) as $row){
$cabrowList[]=CabRow::RowToObject($row);
if($stmt=$this->query($sql)){
foreach($stmt as $row){
$cabrowList[]=CabRow::RowToObject($row);
}
}

return $cabrowList;
Expand All @@ -203,8 +212,9 @@ function GetCabRowFrontEdge($layout=""){
CabRowID=$this->CabRowID$layout GROUP BY FrontEdge ORDER BY CabCount DESC
LIMIT 1;";

if($cabinetRow=$this->query($sql)->fetch()){
return $cabinetRow["FrontEdge"];
$stmt=$this->query($sql);
if($stmt && ($cabinetRow=$stmt->fetch())){
return $cabinetRow["FrontEdge"] ?? "";
}

return "";
Expand All @@ -213,8 +223,8 @@ function GetCabRowFrontEdge($layout=""){
function Search($indexedbyid=false,$loose=false){
$o=new stdClass();
// Store any values that have been added before we make them safe
foreach($this as $prop => $val){
if(isset($val)){
foreach (get_object_vars($this) as $prop => $val) {
if ($val !== null) {
$o->$prop=$val;
}
}
Expand All @@ -233,11 +243,13 @@ function Search($indexedbyid=false,$loose=false){

$rowList=array();

foreach($this->query($sql) as $row){
if($indexedbyid){
$rowList[$row["CabRowID"]]=CabRow::RowToObject($row);
}else{
$rowList[]=CabRow::RowToObject($row);
if($stmt=$this->query($sql)){
foreach($stmt as $row){
if($indexedbyid){
$rowList[$row["CabRowID"] ?? null]=CabRow::RowToObject($row);
}else{
$rowList[]=CabRow::RowToObject($row);
}
}
}

Expand All @@ -249,4 +261,4 @@ function LooseSearch($indexedbyid=false){
return $this->Search($indexedbyid,true);
}
}
?>
?>
35 changes: 23 additions & 12 deletions classes/Cabinet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ private function FilterRights(){
if($this->Rights=='None'){
// ZoneID and CabRowID are probably both not important but meh
$publicfields=array('CabinetID','DataCenterID','Location','LocationSortable','ZoneID','CabRowID','Rights','AssignedTo','U1Position');
foreach($this as $prop => $value){
if(!in_array($prop,$publicfields)){
$this->$prop=null;
foreach (get_object_vars($this) as $prop => $value) {
if (!in_array($prop, $publicfields, true)) {
$this->$prop = null;
}
}
}
Expand Down Expand Up @@ -254,8 +254,9 @@ function GetCabinet(){
$sql="SELECT * FROM fac_Cabinet WHERE CabinetID=$this->CabinetID;";

if($cabinetRow=$dbh->query($sql)->fetch()){
foreach(Cabinet::RowToObject($cabinetRow) as $prop => $value){
$this->$prop=$value;
$tmp = Cabinet::RowToObject($cabinetRow);
foreach (get_object_vars($tmp) as $prop => $value) {
$this->$prop = $value;
}
return true;
}else{
Expand Down Expand Up @@ -539,15 +540,16 @@ function Search($indexedbyid=false,$loose=false){

// This will store all our extended sql
$sqlextend="";
foreach($this as $prop => $val){
$epochDate=date("Y-m-d",0);
foreach (get_object_vars($this) as $prop => $val) {
// We force the following values to knowns in makesafe
if($prop=="FrontEdge" && $val=="Top" && $ot!="Top"){
continue;
}
if($prop=="U1Position" && $val=="Default" && $op!="Default") {
continue;
}
if($val && $val!=date("Y-m-d", strtotime(0))){
if($val && $val !== $epochDate){
extendsql($prop,$val,$sqlextend,$loose);
}
}
Expand Down Expand Up @@ -580,9 +582,14 @@ function SearchByCustomTag( $tag=null ) {

$cabinetList=array();

foreach ( $dbh->query( $sql ) as $cabinetRow ) {
$cabID=$cabinetRow["CabinetID"];
$cabinetList[$cabID]=Cabinet::RowToObject($cabinetRow);
$stmt = $dbh->query($sql);
if ( $stmt === false ) {
return $cabinetList;
}

foreach ( $stmt as $cabinetRow ) {
$cabID = $cabinetRow['CabinetID'];
$cabinetList[$cabID] = Cabinet::RowToObject($cabinetRow);
}
return $cabinetList;
}
Expand All @@ -594,9 +601,13 @@ function GetTags() {

$tags = array();

foreach ( $dbh->query( $sql ) as $row ) {
$tags[]=Tags::FindName($row[0]);
$stmt = $dbh->query($sql);
if ( $stmt === false ) {
return $tags;
}
foreach ( $stmt as $row ) {
$tags[] = Tags::FindName($row[0]);
}

return $tags;
}
Expand Down
Loading