Random Logo PHP - Security Issue?
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #1
Random Logo PHP - Security Issue?
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:
1
2
3
4
5
6
7
8
9
10
<?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?

05-13-2012 10:56 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Random Logo PHP - Security Issue?
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.


My Blog
05-13-2012 12:31 PM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #3
RE: Random Logo PHP - Security Issue?
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']}" />


Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
(This post was last modified: 05-13-2012 01:47 PM by Sama34.)
05-13-2012 01:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: