Reply to Re: Problem with frameset in index.htm

Your name:

Reply:


Posted by Toby Inkster on 05/22/06 21:56

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация