MyBB Hacks

Full Version: Random Logo PHP - Security Issue?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,
I'm trying to insert a random logo code into my header template (using Zingas awesome PHP in Templates plugin) but when trying to save the template, MyBB gives me an error about the code being a potential security risk.

Here is the code i'm using:

Code:
<?php
$Img1 = "{$theme['logo']}";

$Img2 = "/images/theme/logo2.png";

$num = rand (1,2);

$Image = ${'Img'.$num};

echo "<a href=\""{$mybb->settings['bburl']}/portal.php"\"><img src=\"".$Image."\" title=\""{$mybb->settings['bbname']}"\" width=\""700"\" height=\""150"\" alt=\""{$mybb->settings['bbname']}"\" /</a>"; ? >


Does anyone know how I could fix that?

Try making the images into an array, eg

PHP Code:
 $images=array(...);
$image=$images[rand(0,count($images)-1)];


Maybe you'll need to assign the random number seperately.

What about this:
http://mybbhacks.zingaburga.com/showthread.php?tid=776

PHP Code:
<img src="images/rand_images/{$theme['imgdir']}/logos/<?=mt_rand(1,9)?>.png" alt="{$mybb->settings['bbname']}" />

Reference URL's