feat(legacy): update deprecated PHP code (#2789)

### Description
update deprecated code. It's mergeable with master without syntax
conflicts across php versions
remove deprecated((https://www.php.net/manual/fr/function.strftime.php))
and unsafe (https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=strftime)
**strftime** syntax

---------

Co-authored-by: mp3butcher <mp3butcher@gmail.com>
Co-authored-by: jo <ljonas@riseup.net>
Co-authored-by: Kyle Robbertze <kyle@paddatrapper.com>
This commit is contained in:
Julien Valentin 2025-03-13 00:19:18 +01:00 committed by GitHub
parent f9c0bd5a05
commit 3a8dcbce60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 66 additions and 64 deletions

View File

@ -370,13 +370,15 @@ class FileDataHelper
*/
public static function renderImage($file)
{
$im = @imagecreatefromjpeg($file);
$img = $im;
if ($file && file_exists($file)) {
$im = @imagecreatefromjpeg($file);
$img = $im;
if ($im) {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
if ($im) {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}
}
}

View File

@ -1,7 +1,7 @@
<?php
// This file generated by Propel 1.7.3-dev convert-conf target
// from XML runtime conf file /vagrant/legacy/build/runtime-conf.xml
// from XML runtime conf file /var/www/html/build/runtime-conf.xml
$conf = [
'datasources' => [
'airtime' => [

View File

@ -284,7 +284,7 @@ class ApiController extends Zend_Controller_Action
// default to the station timezone
$timezone = Application_Model_Preference::GetDefaultTimezone();
$userDefinedTimezone = strtolower($request->getParam('timezone'));
$userDefinedTimezone = strtolower($request->getParam('timezone') ?? '');
$upcase = false; // only upcase the timezone abbreviations
$this->updateTimezone($userDefinedTimezone, $timezone, $upcase);
@ -410,7 +410,7 @@ class ApiController extends Zend_Controller_Action
// default to the station timezone
$timezone = Application_Model_Preference::GetDefaultTimezone();
$userDefinedTimezone = strtolower($request->getParam('timezone'));
$userDefinedTimezone = strtolower($request->getParam('timezone') ?? '');
$upcase = false; // only upcase the timezone abbreviations
$this->updateTimezone($userDefinedTimezone, $timezone, $upcase);
@ -1640,7 +1640,7 @@ class ApiController extends Zend_Controller_Action
echo "Recalculated {$total} shows.";
}
final private function returnJsonOrJsonp($request, $result)
private function returnJsonOrJsonp($request, $result)
{
$callback = $request->getParam('callback');
$response = $this->getResponse();
@ -1667,7 +1667,7 @@ class ApiController extends Zend_Controller_Action
* @param mixed $status
* @param mixed $message
*/
final private function jsonError($status, $message)
private function jsonError($status, $message)
{
$this->getResponse()
->setHttpResponseCode($status)

View File

@ -50,13 +50,13 @@ class AudiopreviewController extends Zend_Controller_Action
$media = Application_Model_StoredFile::RecallById($audioFileID);
$uri = $baseUrl . 'api/get-media/file/' . $audioFileID;
$mime = $media->getPropelOrm()->getDbMime();
$this->view->audioFileArtist = htmlspecialchars($media->getPropelOrm()->getDbArtistName());
$this->view->audioFileTitle = htmlspecialchars($media->getPropelOrm()->getDbTrackTitle());
$this->view->audioFileArtist = htmlspecialchars($media->getPropelOrm()->getDbArtistName() ?? '');
$this->view->audioFileTitle = htmlspecialchars($media->getPropelOrm()->getDbTrackTitle() ?? '');
} elseif ($type == 'stream') {
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);
$uri = $webstream->getDbUrl();
$mime = $webstream->getDbMime();
$this->view->audioFileTitle = htmlspecialchars($webstream->getDbName());
$this->view->audioFileTitle = htmlspecialchars($webstream->getDbName() ?? '');
} else {
throw new Exception("Unknown type for audio preview!.Type={$type}");
}

View File

@ -63,8 +63,8 @@ class IndexController extends Zend_Controller_Action
$podcastEpisodesService = new Application_Service_PodcastEpisodeService();
$episodes = $podcastEpisodesService->getPodcastEpisodes($stationPodcastId, 0, 0, PodcastEpisodesPeer::PUBLICATION_DATE, 'DESC');
foreach ($episodes as $e => $v) {
$episodes[$e]['CcFiles']['track_title'] = htmlspecialchars($v['CcFiles']['track_title'], ENT_QUOTES);
$episodes[$e]['CcFiles']['artist_name'] = htmlspecialchars($v['CcFiles']['artist_name'], ENT_QUOTES);
$episodes[$e]['CcFiles']['track_title'] = htmlspecialchars($v['CcFiles']['track_title'] ?? '', ENT_QUOTES);
$episodes[$e]['CcFiles']['artist_name'] = htmlspecialchars($v['CcFiles']['artist_name'] ?? '', ENT_QUOTES);
$pubDate = explode(' ', $v['publication_date']);
$episodes[$e]['publication_date'] = $pubDate[0];

View File

@ -398,7 +398,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->showContent = $show->getShowListContent();
$this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml');
$this->view->showTitle = htmlspecialchars($show->getName());
$this->view->showTitle = htmlspecialchars($show->getName() ?? '');
unset($this->view->showContent);
}

View File

@ -235,8 +235,8 @@ SQL;
$row['orig_length'] = $formatter->format();
// XSS exploit prevention
$row['track_title'] = htmlspecialchars($row['track_title']);
$row['creator'] = htmlspecialchars($row['creator']);
$row['track_title'] = htmlspecialchars($row['track_title'] ?? '');
$row['creator'] = htmlspecialchars($row['creator'] ?? '');
}
return $rows;

View File

@ -282,8 +282,8 @@ SQL;
$row['orig_length'] = $formatter->format();
// XSS exploit prevention
$row['track_title'] = htmlspecialchars($row['track_title']);
$row['creator'] = htmlspecialchars($row['creator']);
$row['track_title'] = htmlspecialchars($row['track_title'] ?? '');
$row['creator'] = htmlspecialchars($row['creator'] ?? '');
}
return $rows;

View File

@ -232,7 +232,7 @@ class Application_Model_ShowBuilder
$row['endDate'] = $showEndDT->format('Y-m-d');
$row['endTime'] = $showEndDT->format('H:i');
$row['duration'] = floatval($showEndDT->format('U.u')) - floatval($showStartDT->format('U.u'));
$row['title'] = htmlspecialchars($p_item['show_name']);
$row['title'] = htmlspecialchars($p_item['show_name'] ?? '');
$row['instance'] = intval($p_item['si_id']);
$row['image'] = '';
@ -283,9 +283,9 @@ class Application_Model_ShowBuilder
$formatter = new LengthFormatter(Application_Common_DateHelper::secondsToPlaylistTime($run_time));
$row['runtime'] = $formatter->format();
$row['title'] = htmlspecialchars($p_item['file_track_title']);
$row['creator'] = htmlspecialchars($p_item['file_artist_name']);
$row['album'] = htmlspecialchars($p_item['file_album_title']);
$row['title'] = htmlspecialchars($p_item['file_track_title'] ?? '');
$row['creator'] = htmlspecialchars($p_item['file_artist_name'] ?? '');
$row['album'] = htmlspecialchars($p_item['file_album_title'] ?? '');
$row['cuein'] = $p_item['cue_in'];
$row['cueout'] = $p_item['cue_out'];

View File

@ -12,7 +12,7 @@ class CcBlock extends BaseCcBlock
/**
* Get the [optionally formatted] temporal [utime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (either date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -36,7 +36,7 @@ class CcBlock extends BaseCcBlock
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);
@ -45,7 +45,7 @@ class CcBlock extends BaseCcBlock
/**
* Get the [optionally formatted] temporal [mtime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (either date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -69,7 +69,7 @@ class CcBlock extends BaseCcBlock
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);

View File

@ -12,7 +12,7 @@ class CcPlaylist extends BaseCcPlaylist
/**
* Get the [optionally formatted] temporal [utime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -36,7 +36,7 @@ class CcPlaylist extends BaseCcPlaylist
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);
@ -45,7 +45,7 @@ class CcPlaylist extends BaseCcPlaylist
/**
* Get the [optionally formatted] temporal [mtime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -69,7 +69,7 @@ class CcPlaylist extends BaseCcPlaylist
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);

View File

@ -12,7 +12,7 @@ class CcSchedule extends BaseCcSchedule
/**
* Get the [optionally formatted] temporal [starts] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -36,7 +36,7 @@ class CcSchedule extends BaseCcSchedule
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);
@ -45,7 +45,7 @@ class CcSchedule extends BaseCcSchedule
/**
* Get the [optionally formatted] temporal [ends] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -69,7 +69,7 @@ class CcSchedule extends BaseCcSchedule
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);

View File

@ -12,7 +12,7 @@ class CcShowInstances extends BaseCcShowInstances
/**
* Get the [optionally formatted] temporal [starts] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -36,7 +36,7 @@ class CcShowInstances extends BaseCcShowInstances
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);
@ -45,7 +45,7 @@ class CcShowInstances extends BaseCcShowInstances
/**
* Get the [optionally formatted] temporal [ends] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -69,7 +69,7 @@ class CcShowInstances extends BaseCcShowInstances
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);
@ -78,7 +78,7 @@ class CcShowInstances extends BaseCcShowInstances
/**
* Get the [optionally formatted] temporal [last_scheduled] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
@ -102,7 +102,7 @@ class CcShowInstances extends BaseCcShowInstances
return $dt;
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
}
return $dt->format($format);

View File

@ -207,7 +207,7 @@ abstract class BaseCcAccess extends BaseObject implements Persistent
* Get the [optionally formatted] temporal [ts] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
@ -230,7 +230,7 @@ abstract class BaseCcAccess extends BaseObject implements Persistent
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
} else {
return $dt->format($format);
}

View File

@ -102,7 +102,7 @@ abstract class BaseCcBackup extends BaseObject implements Persistent
* Get the [optionally formatted] temporal [fromtime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
@ -125,7 +125,7 @@ abstract class BaseCcBackup extends BaseObject implements Persistent
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
} else {
return $dt->format($format);
}
@ -135,7 +135,7 @@ abstract class BaseCcBackup extends BaseObject implements Persistent
* Get the [optionally formatted] temporal [totime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
@ -158,7 +158,7 @@ abstract class BaseCcBackup extends BaseObject implements Persistent
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
} else {
return $dt->format($format);
}

View File

@ -428,7 +428,7 @@ abstract class BaseCcTrans extends BaseObject implements Persistent
* Get the [optionally formatted] temporal [start] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
@ -451,7 +451,7 @@ abstract class BaseCcTrans extends BaseObject implements Persistent
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
} else {
return $dt->format($format);
}
@ -461,7 +461,7 @@ abstract class BaseCcTrans extends BaseObject implements Persistent
* Get the [optionally formatted] temporal [ts] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* @param string $format The date/time format string (date()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
@ -484,7 +484,7 @@ abstract class BaseCcTrans extends BaseObject implements Persistent
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
throw new PropelException('strftime format not supported anymore');
} else {
return $dt->format($format);
}

View File

@ -135,7 +135,7 @@ class Application_Service_MediaService
*/
public static function areFilesStuckInPending()
{
$oneHourAgo = gmdate(DEFAULT_TIMESTAMP_FORMAT, microtime(true) - self::PENDING_FILE_TIMEOUT_SECONDS);
$oneHourAgo = gmdate(DEFAULT_TIMESTAMP_FORMAT, intval(microtime(true)) - self::PENDING_FILE_TIMEOUT_SECONDS);
self::$_pendingFiles = CcFilesQuery::create()
->filterByDbImportStatus(CcFiles::IMPORT_STATUS_PENDING)
->filterByDbUtime($oneHourAgo, Criteria::LESS_EQUAL)

View File

@ -292,7 +292,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
*/
public static function getStuckPendingImports()
{
$timeout = gmdate(DEFAULT_TIMESTAMP_FORMAT, microtime(true) - self::PENDING_EPISODE_TIMEOUT_SECONDS);
$timeout = gmdate(DEFAULT_TIMESTAMP_FORMAT, intval(microtime(true)) - self::PENDING_EPISODE_TIMEOUT_SECONDS);
$episodes = PodcastEpisodesQuery::create()
->filterByDbFileId()
->find();
@ -481,7 +481,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
// From the RSS spec best practices:
// 'An item's author element provides the e-mail address of the person who wrote the item'
'author' => $this->_buildAuthorString($item),
'description' => htmlspecialchars($item->get_description()),
'description' => htmlspecialchars($item->get_description() ?? ''),
'pub_date' => $item->get_gmdate(),
'link' => $url,
'enclosure' => $enclosure,

View File

@ -62,15 +62,15 @@ class Application_Service_PodcastService
$podcastArray = [];
$podcastArray['url'] = $feedUrl;
$podcastArray['title'] = htmlspecialchars($rss->get_title());
$podcastArray['description'] = htmlspecialchars($rss->get_description());
$podcastArray['link'] = htmlspecialchars($rss->get_link());
$podcastArray['language'] = htmlspecialchars($rss->get_language());
$podcastArray['copyright'] = htmlspecialchars($rss->get_copyright());
$podcastArray['title'] = htmlspecialchars($rss->get_title() ?? '');
$podcastArray['description'] = htmlspecialchars($rss->get_description() ?? '');
$podcastArray['link'] = htmlspecialchars($rss->get_link() ?? '');
$podcastArray['language'] = htmlspecialchars($rss->get_language() ?? '');
$podcastArray['copyright'] = htmlspecialchars($rss->get_copyright() ?? '');
$author = $rss->get_author();
$name = empty($author) ? '' : $author->get_name();
$podcastArray['creator'] = htmlspecialchars($name);
$podcastArray['creator'] = htmlspecialchars($name ?? '');
$categories = [];
if (is_array($rss->get_categories())) {
@ -432,7 +432,7 @@ class Application_Service_PodcastService
$imageUrl = Config::getPublicUrl() . 'api/station-logo';
$image = $channel->addChild('image');
$image->addChild('title', htmlspecialchars($podcast->getDbTitle()));
$image->addChild('title', htmlspecialchars($podcast->getDbTitle() ?? ''));
self::addEscapedChild($image, 'url', $imageUrl);
self::addEscapedChild($image, 'link', Config::getPublicUrl());

2
legacy/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "99a8bfaf51b5e36bb702f789ce200fea",
"content-hash": "3664fa9473d4b70e3c383b59ca794c82",
"packages": [
{
"name": "adbario/php-dot-notation",