Skip to content

Commit

Permalink
Fixed PHP 8.2 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrissyx committed Dec 12, 2023
1 parent 714bf84 commit 61132bc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
9 changes: 5 additions & 4 deletions news.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@
include('newsscript/smilies.php');
else
{
include_once('newsscript/functions.php');
//Smilies: ID, Synonym, Bild
$smilies = array_map('trim', (substr($smilies, -4) != '.var' ? array_slice(file($smilies), 1) : array_map('utf8_encode', file($smilies))));
$smilies = array_map('trim', (substr($smilies, -4) != '.var' ? array_slice(file($smilies), 1) : array_map('utf8Encode', file($smilies))));
$towrite = "<?php\n//Auto-generated config!\n\$smilies = array();\n";
foreach($smilies as $value)
{
Expand All @@ -148,7 +149,7 @@
//Mehr Smilies
if($action == 'smilies')
{
include('newsscript/functions.php');
include_once('newsscript/functions.php');
newsHead('CHS - Newsscript: Mehr Smilies', 'Newsscript, CHS, Mehr Smilies, Chrissyx', 'Mehr Smilies des Newsscript von CHS');
$i=0;
foreach($smilies as $key => $value)
Expand Down Expand Up @@ -192,7 +193,7 @@
//Admin Login
elseif($action == 'admin')
{
include('newsscript/functions.php');
include_once('newsscript/functions.php');
include('newsscript/language_login.php');
$_SESSION['dispall'] = false;
$user = @array_map('trim', array_slice(file($newspwsdat), 1)) or die($lang['login']['nouser']);
Expand Down Expand Up @@ -314,7 +315,7 @@
//Rechte checken
if(in_array($action, array('delete', 'delcomment', 'edit')))
{
include('newsscript/functions.php');
include_once('newsscript/functions.php');
$user = @array_map('trim', array_slice(file($newspwsdat), 1)) or die($lang['news']['nouser']);
if(($user = getUser($user, $_SESSION['newsname'])) == false)
die($lang['news']['unknown']);
Expand Down
13 changes: 12 additions & 1 deletion newsscript/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function newsCreateThumbnail($image, $thumb, $width, $height, $imageOld)
break;

case IMAGETYPE_PNG:
imagecopyresampled($imageNew, imagecreatefrompng($image), 0, 0, 0, 0, $width, $height, $imageOld[0], $imageOld[1]);
imagecopyresampled($imageNew, @imagecreatefrompng($image), 0, 0, 0, 0, $width, $height, $imageOld[0], $imageOld[1]);
imagepng($imageNew, $thumb);
break;

Expand All @@ -423,4 +423,15 @@ function newsCreateThumbnail($image, $thumb, $width, $height, $imageOld)
imagedestroy($imageNew);
return true;
}

/**
* Ersatz für PHPs {@link utf8_encode()} um von ISO-8859-1 Kodierung nach UTF-8 umzuwandeln.
*
* @param string $string ISO-8859-1 enkodierte Zeichenkette
* @return string UTF-8 enkodiertes Gegenstück
*/
function utf8Encode(string $string): string
{
return @utf8_encode($string);
}
?>
2 changes: 1 addition & 1 deletion newsscript/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ function fillForm(key)
</div>
<div style="border:medium double #000000; margin-left:10px; padding:5px; float:left;">
<p>CHS - Newsscript<br />
<?php echo($lang['help']['version'] . ' ' . getNewsVersion()); ?><br />
<?php echo($lang['help']['version'] . ' ' . getNewsVersion() . newsFont(1)); ?> / PHP: <?php echo(phpversion()); ?></span><br />
&copy; 2008&ndash;2023 by Chrissyx<br />
<a href="https://www.chrissyx.com/" target="_blank">https://www.chrissyx.com/</a></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion newsscript/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function unicodeUpdate()
*/
function checkConvertUtf8($string)
{
return mb_check_encoding($string, 'UTF-8') ? $string : utf8_encode($string);
return mb_check_encoding($string, 'UTF-8') ? $string : utf8Encode($string);
}

newsHead('CHS - Newsscript: ' . $lang['news']['update'], 'Newsscript, CHS, ' . $lang['news']['update'] . ', Chrissyx', $lang['news']['title'] . ' des Newsscript von CHS', $lang['news']['charset'], $lang['news']['code']);
Expand Down

0 comments on commit 61132bc

Please sign in to comment.