Location: PHPKode > scripts > Random Image Rotator > readme.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML; 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>PHP Random Image script - README</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* Style sheet and XHTML code
Author: Mauricio Samy Silva http://www.maujor.com/ A Web Standard evangelist site
City: Rio de Janeiro - Brazil
Contact: maujorcss[at]maujor[dot]com
Date: 2006-05-11
*/
body {
        margin:5px 0;
        padding:0;
        background:#eee;
        color: black;
        font : 68.8%/1.5 Verdana, Geneva, Arial, Helvetica, sans-serif;
        text-align:center;
        }
#wrapper {
        width:700px;
        background:#fff;
        margin:0 auto;
        text-align:left;
        border:1px solid #ccc;
        padding:10px 20px;
        }
h1 {
        font-size:1.5em;
        }
h2 {
        font-size:1.2em;
        border-top:1px solid #999;
        padding-top:1.8em;
        }
h3 {
        font-size:1.0em;
        }
span.dest { color:#f00;}
span.tip { color:#008000; font-weight:bold;}
p {
        color : black;
        font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
        font-size: 1.0em;
        }
address {
        font-weight:bold;
        font-style:normal;
        }
ul.nobullets {
        margin:0 0 1.0em;
        padding:0;
        list-style:none;
        }
ol li {margin-bottom:1.0em;}
samp, code {
        font-size:1.3em;
        font-weight:bold;
        }
a:hover {
        color : red;
        background:#ccc;
        text-decoration : none;
        }
table#installation {
        border-collapse:collapse;
        margin: 5px 15px 10px -25px;
        border: 2px solid #999;
        }
table#installation thead {
        text-align:center;
        text-transform:uppercase;
        }
table#installation tr td, table#installation tr th {
        padding: 2px 5px;
        border: 1px solid #ccc;
        }
table#installation tr th {
        border-bottom-width:2px;
        border-bottom-color:#999;
        }

table#installation tr td var {
        font-weight:bold;
        font-style:normal;
        }
table#installation tr.odd {
        background: #fafafa;
        }

table.code
{
 color: #000000;
 background-color: #f1f1f1;
 font-size: 100%;
 padding:0px;
 border-top: 1px solid gray;
 border-left: 1px solid gray;
 border-bottom: 0px solid gray;
 border-right: 0px solid gray;
}
table.code th, table.code td
{
 padding-bottom:2px;
 border-top: 0px solid gray;
 border-left: 0px solid gray;
 border-bottom: 1px solid gray;
 border-right: 1px solid gray;
}
pre
{
 font-family:"Courier New",monospace;
 font-size:110%;
 margin-left: 0;
 margin-bottom: 0;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="main">
<h1><span class="dest">RandIm</span><br />
PHP random image script</h1>

<ul class="nobullets">
<li>Random Image (RandIm)</li>
<li>Version: 1.0 from 3rd January 2009</li>
<li>Author: Klemen Stirn</li>
<li><a href="http://www.phpjunkyard.com" target="_blank">PHPJunkYard.com - Free PHP scripts</a></li>
<li><a href="http://www.phpjunkyard.com/random-image.php" target="_blank">Random image</a></li>
<li><a href="http://developers.phpjunkyard.com/" target="_blank">Support and developers forum</a></li>
</ul>

<p><b>PLEASE NOTE:</b> I <span class="dest">cannot</span> provide free installation support for this free script! Please contact me ONLY about possible bug reports, suggestions or comments! Thank you!</p>

<h2>INDEX</h2>

<ul class="nobullets">
    <li><a href="#copy">Copyright notice and license</a></li>
    <li><a href="#desc">Description &amp; requirements</a></li>
    <li><a href="#install">Installation</a></li>
    <li><a href="#links">Link to RandIm</a></li>
    <li><a href="#help">HELP and Troubleshooting</a></li>
    <li><a href="#other">Newsletter, rating this script and other</a></li>
</ul>

<h2 id="copy">COPYRIGHT NOTICE</h2>

<p>Copyright 2009 Klemen Stirn. All Rights Reserved.</p>

<p>This script may be used and modified free of charge by anyone
AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
By using this code you agree to indemnify Klemen Stirn from any
liability that might arise from it's use.</p>

<p>Using this script requires attribution. In other words: if you are using this
script you are required to place a link to PHPJunkyard on your website.
You will find some link suggestions <a href="#links">here</a>.</p>

<p>Selling the code for this program, in part or full, without prior
written consent is expressly forbidden.</p>

<p>Obtain permission before redistributing this software over the Internet
or in any other medium. In all cases copyright and header must remain
intact. This Copyright is in full effect in any country that has
International Trade Agreements with the United States of America or
with the European Union.</p>

<h2 id="desc">DESCRIPTION</h2>

<p>RandIm is a simple PHP random image rotator script. You can use it to display random images from a folder of your choice. RandIm supports file extension filtering so
it can be used to randomly pick other file types too, not just images!</p>

<h2>REQUIREMENTS</h2>

<ul>
    <li>Any server with working PHP 4.3 (or newer)</li>
    <li>FTP access and a FTP program</li>
</ul>

<h2 id="install">&raquo; Installation</h2>

<p style="font-weight:bold"><span class="dest">Please take 5 minutes time and read installation instructions carefully and completely! This will ensure a proper and easy installation.</span></p>

<p style="font-weight:bold"><span class="dest">If you have problems/questions see the &quot;Troubleshooting and HELP&quot; section further down.</span></p>

<p><b>-&gt; Quick install</b></p>

<ol>
<li>
<p>FTP to the public folder of your server (where the rest of your website is;
usually called &quot;public_html&quot;, &quot;www&quot; or &quot;site&quot;) and create
a folder where you will install RandIm (for example named &quot;randim&quot;).<br />
Example: /public_html/randim<br />
Corresponding URL: http://www.yourdomain.com/randim</p>
<p><span class="tip">TIP:</span> If you don't know how to FTP files read my simple
<a href="http://www.phpjunkyard.com/ftp-chmod-tutorial.php" target="_blank">FTP tutorial</a></p>
</li>
<li>
<p>Upload all RandIm files and folders to your server. PHP files should be transferred in ASCII mode, images in binary mode.</p>
</li>
</ol>

<p>That's it. To test if RandIm works fine on your server open <i>randim/test.php</i> in your browser, for example:<br />
http://www.yourdomain.com/randim/test.php</p>

<p>Your browser should show a sample page with 4 random images displayed. Try refreshing the page to see images change.</p>

<p>Got an error message? A few solutions can be found below under <a href="#help">HELP and Troubleshooting</a>.</p>

<p><b>-&gt; Using random image script</b></p>

<p>Now that the script is up and running it's time to choose the images that should be randomly displayed.
You can do so by uploading all your images to your &quot;randim/images&quot; folder.</p>

<p>Alternatively you can set RandIm to use images from any other folder of your choice by changing
the default settings (read more about it further down).</p>

<p>To display a random image on your website using the default settings simply use the URL of <b>randim.php</b>
as image SRC (source) address, for example:</p>

<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;http://yourdomain.com/randim/randim.php&quot; /&gt;</pre>
</td>
</tr>
</table>

<p>As simple as that. By default, RandIm will randomly choose from any <b>.jpg</b>, <b>.gif</b> or <b>.png</b>
files located in the &quot;randim/images&quot; folder.</p>

<p><span class="dest"><b>Important!</b></span> Using this script requires attribution. In other words: if you are using this
script you are required to place a link to PHPJunkyard on your website.
This is all I require in exchange for this free script, please support my work
by placing a link on your website. You will find some link suggestions <a href="#links">here</a>.</p>

<p><b>-&gt; Modifying default settings</b></p>

<p>To modify default settings open <b>randim.php</b> in a plain text editor (like Notepad or Wordpad on Windows, DO NOT use Microsoft Word!)
and scroll down to where it says SETTINGS. Available settings are:</p>

<ol>

<table id="installation" summary="This is a simple two columns table - the first column names a variable and in second one has a descripton and the settings for the varible">
<thead>
<tr>
<th>Variable</th>
<th>Description/Setup</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td valign="top" nowrap="nowrap"><var>$settings['img_folder']</var></td>
<td>Name of the folder where RandIm will choose images (files) from by default.
You can set it to any folder on your server, use relative or absolute (root) path
to the folder you wish.<br /><br />
For example if your images are located in a folder called &quot;photos&quot;
located outside the &quot;randim&quot; folder, you would set it to:<br />
$settings['img_folder'] = '../photos/';</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><var>$settings['img_ext']</var></td>
<td>File types (extensions) RandIm will choose from. You can add new extensions
by adding <b>,'.extension'</b> to the list.<br /><br />
Examples:<br /><br />
<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>$settings['img_ext'] = array('.jpg');</pre>
</td>
</tr>
</table>
Effect: RandIm will choose from JPG files only<br /><br />
<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>$settings['img_ext'] = array('.jpg','.gif','.png','.tga','.bmp');</pre>
</td>
</tr>
</table>
Effect: RandIm will choose from JPG, GIF, PNG, TGA and BMP file types<br /><br />
<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>$settings['img_ext'] = array('.doc', '.pdf');</pre>
</td>
</tr>
</table>
Effect: RandIm will choose DOC and PDF files<br /><br />
</td>
</tr>
<tr class="odd">
<td valign="top" nowrap="nowrap"><var>$settings['display_type']</var></td>
<td>If set to <b>1</b> RandIm will redirect to the chosen file.
This is useful when you use RandIm from HTML pages as shown before (&lt;img src=&quot;randim.php&quot; /&gt;).
It can also be used to create random file downloads if used in an anchor link, like this:<br /><br />
<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;a href=&quot;http://yourdomain.com/randim/randim.php&quot;&gt;Random file&lt;/a&gt;</pre>
</td>
</tr>
</table>
<br /><br />
If set to <b>0</b> RandIm will print path to the selected file. This mode should be used if
you are using RandIm on a PHP page and want to use RandIm as a PHP include, for example: <br /><br />
<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;&lt;?php include 'randim.php'; ?&gt;&quot;&gt;</pre>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><var>$settings['allow_otf']</var></td>
<td>If set to <b>1</b> RandIm will allow <b>Changing settings on-the-fly</b> (see below).
Set to <b>0</b> to only allow hard-coded settings (as set in the randim.php file).<br /><br />
For security purposes if $settings['allow_otf'] is set to <b>1</b> RandIm will
only work with local folders and not remote ones (so people can't use your script
to for example display images from their folder).</td>
</tr>
</tbody>
</table>

</ol>

<p>Save changes and upload the edited randim.php file to your server.</p>

<p><b>-&gt; Changing settings on-the-fly</b></p>

<p>You can also modify RandIm settings on-the-fly simply by passing proper values to the script
using query string (when using RandIm as URL) or variables (when using RandIm as a PHP include).</p>

<p>For changing settings on-the-fly to work variable <var>$settings['allow_otf']</var>
must be set to <b>1</b> (see above)!</p>

<p>Operating mode ($settings['display_type']) can be changed using $_GET['type'] variable
and images folder using $_GET['folder'] variable. This might sound a bit confusing,
but here are a few examples:</p>

<p>If you want to display one random image from folder "images" and one from folder "images2"
you could use this code:</p>

<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;http://yourdomain.com/randim/randim.php?folder=images&quot; /&gt;
&lt;img src=&quot;http://yourdomain.com/randim/randim.php?folder=images2&quot; /&gt;</pre>
</td>
</tr>
</table>

<p>The same thing if you are using RandIm as a PHP include:</p>

<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;&lt;?php $_GET['folder'] = 'images'; include 'randim.php'; ?&gt;&quot;&gt;
&lt;img src=&quot;&lt;?php $_GET['folder'] = 'images2'; include 'randim.php'; ?&gt;&quot;&gt;</pre>
</td>
</tr>
</table>

<p>If your <var>$settings['display_type']</var> is set to <b>1</b> and default folder
set to &quot;images&quot; but you would like to also
use randim.php as include and choose a file from folder
&quot;../photos&quot; try this:</p>

<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;&lt;?php $_GET['type'] = 0; $_GET['folder'] = '../photos'; include 'randim.php'; ?&gt;&quot;&gt;</pre>
</td>
</tr>
</table>

<p>And if your display_type is set to 0 by default (using RandIm as a PHP include) you can
override the default settings and use randim.php as an URL too:</p>

<table width="100%" border="1" class="code" cellspacing="0">
<tr>
<td>
<pre>&lt;img src=&quot;http://yourdomain.com/randim/randim.php?type=1&amp;folder=../photos&quot; /&gt;</pre>
</td>
</tr>
</table>

<p>The same code is used in the <b>test.php</b> file, have a look if interested.</p>

<h2 id="links">&raquo; Link to RandIm</h2>

<p>A lot of time and effort went into developing RandIm and other PHPJunkyard scripts.
That's why this script requires attribution. In other words: if you are using this
script you are required to place a link to PHPJunkyard on your website.
This is all I require in exchange for this free script, please support my work
by placing a link on your website. It can be as simple as a short text link.</p>

<p><b>-&gt; Don't want to place a link?</b></p>

<p>If you want to use RandIm but would prefer (for any reason) not to place a link
to PHPJunkyard on your website you can attribute by sending a
<a href="http://www.phpjunkyard.com/donations/donations.php" target="_blank">small donation</a>.
Any amount. Donations help keep PHPJunkyard website and scripts alive.</p>

<p><b>-&gt; Link suggestions</b></p>

<p>1. Simple text link<br>
<a href="http://www.phpjunkyard.com/random-image.php">Random image</a><br>
<textarea cols="40" rows="3" onclick="this.focus();this.select()">&lt;a href=&quot;http://www.phpjunkyard.com/random-image.php&quot;&gt;Random image&lt;/a&gt;</textarea></p>

<p>2 &quot;Powered by&quot; simple text link<br>
Powered by <a href="http://www.phpjunkyard.com/random-image.php">Random image</a><br>
<textarea cols="40" rows="3" onclick="this.focus();this.select()">Powered by &lt;a href=&quot;http://www.phpjunkyard.com/random-image.php&quot;&gt;Random image&lt;/a&gt;</textarea></p>

<p>3. Text link with description<br>
<a href="http://www.phpjunkyard.com/random-image.php">Random image</a> - get this and other free PHP scripts from PHPJunkyard.<br>
<textarea cols="40" rows="3" onclick="this.focus();this.select()">&lt;a href=&quot;http://www.phpjunkyard.com/random-image.php&quot;&gt;Random image&lt;/a&gt; - get this and other free PHP scripts from PHPJunkyard.</textarea></p>

<p><span class="tip">TIP:</span> You can use one of the PHPJunkyard banners that come with RandIm (check inside <b>images</b> folder) for the link
or get more link suggestions on the <a href="http://www.phpjunkyard.com/link2us.php">PHPJunkyard link to us</a> page!</p>

<h2 id="help">&raquo; HELP and Troubleshooting</h2>

<h3>1. What is CHMOD and FTP?</h3>

<p>I have prepared a simple <a href="http://www.phpjunkyard.com/ftp-chmod-tutorial.php" target="_blank">FTP
and CHMOD tutorial</a> which will help you FTP files to your server and set correct CHMOD settings.</p>

<h3>2. Images won't show! I'm getting a NO IMAGES FOUND message?</h3>

<p>Make sure that:</p>

<ol>
<li>the path to your images folder is correct (check <var>$settings['img_folder']</var>)</li>
<li>there are images in your images folder</li>
<li>image types are allowed (check <var>$settings['img_ext']</var>)</li>
<li>you are using correct display_type (1 if using RandIm as URL, 0 if as PHP include. Check <var>$settings['display_type']</var>)</li>
</ol>

<h3>3. The on-the-fly changes have no effect</h3>

<p>Make sure you have <var>$settings['allow_otf']</var> set to <b>1</b> and are
passing correct values to the script. If you pass invalid values the default settings
will be used</p>

<p>&nbsp;</p>

<p>Since these scripts are free no support is guaranteed. If you can't get the script to work please go
through this readme file again carefully and repeat the installation step-by-step (also delete old
files and folders from the server). Also please feel free to post any questions or problems you might have
in <a href="http://developers.phpjunkyard.com">PHPJunkyard forum</a>!</p>

<h2 id="other">&raquo; Stay updated!</h2>

<p>Join my FREE newsletter and you will be notified about new scripts, new versions of the existing scripts and other important news from PHPJunkYard.<br />
<a href="http://www.phpjunkyard.com/newsletter.php" target="_blank">Click here for more info</a></p>

<h2>&raquo; Please rate this script</h2>

<p>If you like this script please rate it or even write a review at:</p>

<p><a href="http://www.hotscripts.com/Detailed/86736.html" target="_blank" rel="nofollow">Rate
this Script @ Hot Scripts</a></p>

<p><a href="http://php.resourceindex.com/rate?07942" target="_blank" rel="nofollow">Rate
this Script @ The PHP Resource Index</a></p>

<p>Best regards,</p>
<address>Klemen Stirn<br />
PHP JunkYard<br />
<a href="http://www.phpjunkyard.com">http://www.PHPJunkYard.com</a></address>

</div>
</div>
</body>
</html>
Return current item: Random Image Rotator