Text
|
|
|
|
<? /* Simple random quote
** Francesco Toscan, fathom@unixlover.com
*/
function quote_of($file)
{
if (stristr($file,"/")) die("Illegal file format");
define("INCDIR","docs/quotes/");
$char = "%";
$lines = file(INCDIR.$file);
$end = count($lines);
mt_srand((double)microtime() * 1000000);
$num = mt_rand("0", $end);
$i = $num;
while (!stristr($lines[$i],$char))
{
$i++;
if ($i == $end) $i = mt_rand("0", $end);
}
$j = $i +1;
while (!stristr($lines[$j],$char))
{
$str .= $lines[$j];
$j++;
}
return $str;
} ?>
|
|
|
Usage Example
|
<!-- various HTML here -->
<pre>
<? print(quote_of("file.txt")); ?>
</pre>
<!-- The rest of your HTML -->
|
|
|
Rate This Script
|
|
|
|