1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

PHP8 fixes.

This commit is contained in:
Cameron 2021-01-14 11:32:02 -08:00
parent 3a166c253b
commit 7e90b791ba
2 changed files with 57 additions and 42 deletions

View File

@ -16,29 +16,36 @@
* @subpackage banner * @subpackage banner
*/ */
class banner_shortcodes extends e_shortcode class banner_shortcodes extends e_shortcode
{ {
// $parm now can be array, old campaign $parm still allowed.... // $parm now can be array, old campaign $parm still allowed....
function sc_banner($parm='') function sc_banner($parm = '')
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
mt_srand ((double) microtime() * 1000000); mt_srand((double) microtime() * 1000000);
$seed = mt_rand(1,2000000000); $seed = mt_rand(1, 2000000000);
$time = time(); $time = time();
$campaign = (is_array($parm)?$parm['campaign']:$parm); $campaign = (isset($parm['campaign']) ? $parm['campaign'] : $parm);
$query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)".($campaign ? " AND banner_campaign='".$tp->toDB($campaign)."'" : '')."
AND banner_active IN (".USERCLASS_LIST.") "; $query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)" . ($campaign ? " AND banner_campaign='" . $tp->toDB($campaign) . "'" : '') . "
AND banner_active IN (" . USERCLASS_LIST . ") ";
if($tags = e107::getRegistry('core/form/related')) if($tags = e107::getRegistry('core/form/related'))
{ {
$tags_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'"; $tags_regexp = "'(^|,)(" . str_replace(",", "|", $tags) . ")(,|$)'";
$query .= " AND banner_keywords REGEXP ".$tags_regexp; $query .= " AND banner_keywords REGEXP " . $tags_regexp;
} }
$query .= " ORDER BY RAND($seed) LIMIT 1"; $query .= " ORDER BY RAND($seed) LIMIT 1";
if($sql->select('banner', 'banner_id, banner_image, banner_clickurl, banner_description', $query)) if($sql->select('banner', 'banner_id, banner_image, banner_clickurl, banner_description', $query))
{ {
$row = $sql->fetch(); $row = $sql->fetch();
return $this->renderBanner($row, $parm); return $this->renderBanner($row, $parm);
} }
else else
@ -50,54 +57,56 @@ class banner_shortcodes extends e_shortcode
// Also used by banner_menu.php // Also used by banner_menu.php
public function renderBanner($row, $parm = null) public function renderBanner($row, $parm = null)
{ {
$sql = e107::getDb('banner'); $sql = e107::getDb('banner');
$tp = e107::getParser(); $tp = e107::getParser();
if(!$row['banner_image']) if(!$row['banner_image'])
{ {
return "<a href='".e_HTTP.'banner.php?'.$row['banner_id']."' rel='external'>".BANNERLAN_39."</a>"; return "<a href='" . e_HTTP . 'banner.php?' . $row['banner_id'] . "' rel='external'>" . BANNERLAN_39 . "</a>";
} }
$fileext1 = substr(strrchr($row['banner_image'], '.'), 1); $fileext1 = substr(strrchr($row['banner_image'], '.'), 1);
$sql->update('banner', 'banner_impressions=banner_impressions+1 WHERE banner_id='.(int)$row['banner_id']); $sql->update('banner', 'banner_impressions=banner_impressions+1 WHERE banner_id=' . (int) $row['banner_id']);
switch ($fileext1) switch($fileext1)
{ {
case 'swf': case 'swf':
return " return "
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"468\" height=\"60\">\n <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"468\" height=\"60\">\n
<param name=\"movie\" value=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\">\n <param name=\"movie\" value=\"" . e_IMAGE_ABS . "banners/" . $row['banner_image'] . "\">\n
<param name=\"quality\" value=\"high\">\n <param name=\"quality\" value=\"high\">\n
<param name=\"SCALE\" value=\"noborder\">\n <param name=\"SCALE\" value=\"noborder\">\n
<embed src=\"".e_IMAGE_ABS."banners/".$row['banner_image']."\" width=\"468\" height=\"60\" scale=\"noborder\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed> <embed src=\"" . e_IMAGE_ABS . "banners/" . $row['banner_image'] . "\" width=\"468\" height=\"60\" scale=\"noborder\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object> </object>
"; ";
break; break;
case 'html':
case 'js':
case 'php': // Code - may 'echo' text, or may return it as a value
$file_data = file_get_contents(e_IMAGE.'banners/'.$row['banner_image']);
return $file_data;
break;
default:
$class = empty($parm['class']) ? "e-banner img-responsive img-fluid" : $parm['class']; case 'html':
$ban_ret = $tp->toImage($row['banner_image'], array('class'=> $class , 'alt'=>basename($row['banner_image']), 'legacy'=>'{e_IMAGE}banners')); case 'js':
case 'php': // Code - may 'echo' text, or may return it as a value
$file_data = file_get_contents(e_IMAGE . 'banners/' . $row['banner_image']);
return $file_data;
break;
default:
$class = empty($parm['class']) ? "e-banner img-responsive img-fluid" : $parm['class'];
$ban_ret = $tp->toImage($row['banner_image'], array('class' => $class, 'alt' => basename($row['banner_image']), 'legacy' => '{e_IMAGE}banners'));
break; break;
} }
$start = "<a class='e-tip' href='".e_HTTP.'banner.php?'.$row['banner_id']."' rel='external' title=\"".$tp->toAttribute(varset($row['banner_tooltip'],''))."\">"; $start = "<a class='e-tip' href='" . e_HTTP . 'banner.php?' . $row['banner_id'] . "' rel='external' title=\"" . $tp->toAttribute(varset($row['banner_tooltip'], '')) . "\">";
$end = '</a>'; $end = '</a>';
$text = $start.$ban_ret.$end; $text = $start . $ban_ret . $end;
if(!empty($row['banner_description']))
{
$text .= "<div class='e-banner-description'>".$start.$tp->toHTML($row['banner_description'], true).$end. "</div>";
}
return $text; if(!empty($row['banner_description']))
{
$text .= "<div class='e-banner-description'>" . $start . $tp->toHTML($row['banner_description'], true) . $end . "</div>";
}
return $text;
} }
} }

View File

@ -101,7 +101,10 @@ class social_shortcodes extends e_shortcode
$tmp = explode(",",$parm['type']); $tmp = explode(",",$parm['type']);
foreach($tmp as $v) foreach($tmp as $v)
{ {
$newList[$v] = $social[$v]; if(isset($social[$v]))
{
$newList[$v] = $social[$v];
}
} }
@ -387,7 +390,10 @@ class social_shortcodes extends e_shortcode
$tmp = explode(",",$parm['type']); $tmp = explode(",",$parm['type']);
foreach($tmp as $v) foreach($tmp as $v)
{ {
$newlist[$v] = $opt[$v]; if(isset($opt[$v]))
{
$newlist[$v] = $opt[$v];
}
} }
$opt = $newlist; $opt = $newlist;