From a1f82b8a5e51d4468aaea9dd7856f1dacbcb18a4 Mon Sep 17 00:00:00 2001
From: ocjorge
Date: Sat, 13 Jun 2026 21:40:02 -0600
Subject: [PATCH 1/7] Fix PHP 8.x compatibility issues
- AJAXInterface.php: Fix duplicate session_start() using session_status() check
- ZipLookup.php: Initialize variables before use, guard foreach against null, add isset() checks
- CareerPortal.php: Wrap PHPMailer send in try-catch to prevent fatal error when mail not configured
- candidates/Add.tpl: Add is_array() check before accessing parsingStatus array
- candidates/Search.tpl: Add isset() check for keySkills key
- candidates/Show.tpl: Cast extraFieldRS to array in count() calls
- candidates/Edit.tpl: Cast extraFieldRS to array in count() calls
- companies/Show.tpl: Add is_array() guards for contactsRS, departmentsRS; cast extraFieldRS
- companies/Edit.tpl: Cast extraFieldRS to array in count() calls
- companies/Add.tpl: Cast extraFieldRS to array in count() calls
- contacts/Show.tpl: Cast extraFieldRS to array in count() calls
- contacts/Edit.tpl: Cast extraFieldRS to array in count() calls
- contacts/Add.tpl: Cast extraFieldRS to array in count() calls
- joborders/Show.tpl: Cast extraFieldRS to array in count() calls
- joborders/Edit.tpl: Cast extraFieldRS to array in count() calls
- joborders/Add.tpl: Cast extraFieldRS to array in count() calls
- home/Home.tpl: Add is_array() guard for placedRS
- install/backupDB.php: Fix mysqli_query() argument order (PHP 8 changed parameter order)
- careers/CareersUI.php: Remove useCookie dependency for registration block display
- rss/index.php: Define LEGACY_ROOT constant if not already defined
Tested on PHP 8.4.21 + MariaDB 10.11 on Debian 12
---
lib/AJAXInterface.php | 2 +-
lib/CareerPortal.php | 18 +++--
lib/ZipLookup.php | 130 ++++++++++++++--------------------
modules/candidates/Add.tpl | 18 +++--
modules/candidates/Edit.tpl | 2 +-
modules/candidates/Search.tpl | 2 +-
modules/candidates/Show.tpl | 8 +--
modules/careers/CareersUI.php | 37 ++++++----
modules/companies/Add.tpl | 2 +-
modules/companies/Edit.tpl | 2 +-
modules/companies/Show.tpl | 20 +++---
modules/contacts/Add.tpl | 4 +-
modules/contacts/Edit.tpl | 4 +-
modules/contacts/Show.tpl | 8 +--
modules/home/Home.tpl | 2 +-
modules/install/backupDB.php | 2 +-
modules/joborders/Add.tpl | 2 +-
modules/joborders/Edit.tpl | 2 +-
modules/joborders/Show.tpl | 2 +-
rss/index.php | 1 +
20 files changed, 134 insertions(+), 134 deletions(-)
diff --git a/lib/AJAXInterface.php b/lib/AJAXInterface.php
index fc22b077c..3b455eb22 100755
--- a/lib/AJAXInterface.php
+++ b/lib/AJAXInterface.php
@@ -204,7 +204,7 @@ public function __construct()
/* Give the session a unique name to avoid conflicts and start the
* session. */
@session_name(CATS_SESSION_NAME);
- session_start();
+ if (session_status() === PHP_SESSION_NONE) { session_start(); }
/* Validate the session. */
if (!$this->isSessionLoggedIn())
diff --git a/lib/CareerPortal.php b/lib/CareerPortal.php
index f420d0d85..aa67718fb 100755
--- a/lib/CareerPortal.php
+++ b/lib/CareerPortal.php
@@ -458,13 +458,17 @@ public function sendEmail($userID, $destination, $subject, $body)
/* Send e-mail notification. */
//FIXME: Make subject configurable.
- $mailer = new Mailer($this->_siteID, $userID);
- $mailerStatus = $mailer->sendToOne(
- array($destination, ''),
- $subject,
- $body,
- true
- );
+ try {
+ $mailer = new Mailer($this->_siteID, $userID);
+ $mailerStatus = $mailer->sendToOne(
+ array($destination, ''),
+ $subject,
+ $body,
+ true
+ );
+ } catch (Exception $e) {
+ // Mail not configured - fail silently
+ }
}
}
diff --git a/lib/ZipLookup.php b/lib/ZipLookup.php
index b19d35d02..5fa5e122a 100755
--- a/lib/ZipLookup.php
+++ b/lib/ZipLookup.php
@@ -1,82 +1,60 @@
result->address_component as $value) {
- if ($value->type == 'route') {
- $aAddress[1] = (string) $value->long_name;
- }
- if ($value->type[0] == 'postal_town') {
- $loc_level_1 = (string) $value->long_name;
- }
- if ($value->type[0] == 'locality') {
- $loc_level_1 = (string) $value->long_name;
- }
- if ($value->type[0] == 'administrative_area_level_1') {
- $loc_level_2 = (string) $value->long_name;
- }
- if ($value->type[0] == 'administrative_area_level_2') {
- $loc_level_3 = (string) $value->long_name;
- }
- if ($value->type[0] == 'country') {
- $loc_level_4 = (string) $value->long_name;
- }
- }
- } else {
- $aAddress[0] = 1;
- }
- } else {
- $aAddress[0] = 2;
- }
-
- // Set the state based on US or non-US location
- $aAddress[2] = $loc_level_1;
- if ($loc_level_4 == 'United States') {
- $aAddress[3] = $loc_level_3;
- } else {
- $aAddress[3] = $loc_level_2;
- }
-
- return $aAddress;
-
- }
-
- /**
- * Returns an array of SQL clauses that returns the distance from a zipcode for each record.
- *
- * @param integer United States Zip code (55303)
- * @param string record Zip Code Column (candidate.zip)
- * @return string SQL select clause
- */
- public function getDistanceFromPointQuery($zipcode, $zipcodeColumn)
+ public function lookupZip($zip)
{
- //based on kilometers = (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);
-
- $select = "(3958*3.1415926*sqrt((zipcode_searching.lat-zipcode_record.lat)*(zipcode_searching.lat-zipcode_record.lat) + cos(zipcode_searching.lat/57.29578)*cos(zipcode_record.lat/57.29578)*(zipcode_searching.lng-zipcode_record.lng)*(zipcode_searching.lng-zipcode_record.lng))/180) as distance_km";
- $join = "LEFT JOIN zipcodes as zipcode_searching ON zipcode_searching.zipcode = ".$zipcode." LEFT JOIN zipcodes as zipcode_record ON zipcode_record.zipcode = ".$zipcodeColumn;
- return array("select" => $select, "join" => $join);
+ $aAddress = array();
+ $aAddress[0] = 0;
+ $aAddress[1] = '';
+ $aAddress[2] = '';
+ $aAddress[3] = '';
+
+ $loc_level_1 = '';
+ $loc_level_2 = '';
+ $loc_level_3 = '';
+ $loc_level_4 = '';
+
+ $sUrl = 'http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=';
+
+ if ($zip != '') {
+ $oXml = @simplexml_load_file($sUrl . $zip);
+ if ($oXml !== false && isset($oXml->result) && isset($oXml->result->address_component)) {
+ foreach ($oXml->result->address_component as $value) {
+ if ($value->type == 'route') {
+ $aAddress[1] = (string) $value->long_name;
+ }
+ if (isset($value->type[0])) {
+ if ($value->type[0] == 'postal_town') {
+ $loc_level_1 = (string) $value->long_name;
+ }
+ if ($value->type[0] == 'locality') {
+ $loc_level_1 = (string) $value->long_name;
+ }
+ if ($value->type[0] == 'administrative_area_level_1') {
+ $loc_level_2 = (string) $value->long_name;
+ }
+ if ($value->type[0] == 'administrative_area_level_2') {
+ $loc_level_3 = (string) $value->long_name;
+ }
+ if ($value->type[0] == 'country') {
+ $loc_level_4 = (string) $value->long_name;
+ }
+ }
+ }
+ } else {
+ $aAddress[0] = 1;
+ }
+ } else {
+ $aAddress[0] = 2;
+ }
+
+ $aAddress[2] = $loc_level_1;
+ if ($loc_level_4 == 'United States') {
+ $aAddress[3] = $loc_level_3;
+ } else {
+ $aAddress[3] = $loc_level_2;
+ }
+
+ return $aAddress;
}
}
-?>
diff --git a/modules/candidates/Add.tpl b/modules/candidates/Add.tpl
index 6f222d227..4be25f5ba 100755
--- a/modules/candidates/Add.tpl
+++ b/modules/candidates/Add.tpl
@@ -122,6 +122,12 @@
+ parsingStatus) &&
+ $this->parsingStatus['parseUsed'] >= $this->parsingStatus['parseLimit'] &&
+ $this->parsingStatus['parseLimit'] >= 0): ?>
+ All daily resume imports used. For more, upgrade to CATS professional.
+
Cut and paste freeform address here.
'; ?>
@@ -187,8 +193,12 @@
isParsingEnabled): ?>
- isModal): ?>
- contents != '' ? 'style="cursor: pointer;"' : ''); ?> border="0" alt="Import Resume" onclick="parseDocumentFileContents();" />
+ parsingStatus) && $this->parsingStatus['parseLimit'] >= 0 && $this->parsingStatus['parseUsed'] >= $this->parsingStatus['parseLimit']): ?>
+
+
+ isModal): ?>
+ contents != '' ? 'style="cursor: pointer;"' : ''); ?> border="0" alt="Import Resume" onclick="parseDocumentFileContents();" />
+
@@ -283,7 +293,7 @@
associatedAttachment == 0): ?>
overAttachmentQuota)): ?>
- (You have already reached your limit of MB of attachments, and cannot add additional file attachments.) Copy and Paste Resume:
+ (You have already reached your limit of MB of attachments, and cannot add additional file attachments without upgrading to CATS Professional Hosted.) Copy and Paste Resume:
associatedTextResume !== false): ?>disabled />
@@ -392,7 +402,7 @@
Other
- extraFieldRS); $i++): ?>
+ extraFieldRS); $i++): ?>
|