dorayme wrote:
> I think there can be trouble if the memory manager is just so and
> memory gets gobbled up by frames that load framesets that have
> many frames that in turn have many and so on...
The following PHP file is fun.
It generates a frameset consisting of two frames (canvas divided
horizontally) and loads into each a frameset consisting of two more
frames (divided vertically), thus splitting the canvas into four
rectangles. The total number of pages loaded now is 3.
Into each of these it loads a frameset splitting the frame horizontally
into three smaller frames (pages loaded: 7), and each of those is further
divided into three smaller frames vertically (pages loaded: 19). Your
canvas should now be divided into 1 x 4 x 9 = 36 rectangles.
Each of these 36 frames is then given a frameset (pages loaded: 55) that
horizontally subdivides it into 4 frames (pages loaded: 199), each of
which is subdivided into four frames vertically. 1 x 4 x 9 x 16 = 576
rectangles.
At this point, an artificial limit comes in and stops recursion from going
any further, but at this point the browser has downloaded close to 800
pages according to my calculations!
<?php
# $limit allows us to limit how far this page recurs.
# To be nasty, set $limit = 0.
$limit = 4;
$nframes = (int)$_GET['nframes'];
if ($nframes < 1)
$nframes = 2;
$ftype='rows';
if ($_GET['ftype']=='cols')
$ftype = 'cols';
if ($limit && $nframes>$limit)
{
# safety feature
print "ARGH!";
exit;
}
# Generate frameset
$n = $nframes;
while ($n>0)
{
$f[]='*';
$n--;
}
$f = implode(',', $f);
$frameset = sprintf('%s="%s"', $ftype, $f);
# Generate URL to load in each frame
$new_ftype = 'cols';
$new_nframes = $nframes;
if ($ftype=='cols')
{
$new_ftype = 'rows';
$new_nframes = $nframes + 1;
}
$url = sprintf('%s?nframes=%s&ftype=%s'
,$_SERVER['REQUEST_URI']
,$new_nframes
,$new_ftype
);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Nasty Frames</title>
</head>
<frameset <?= $frameset ?>>
<?php
for ($i=0; $i<$nframes; $i++)
printf("<frame src=\"%s\">", htmlentities($url));
?>
</frameset>
</html>
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
|
|