Q:

Scripting for random load with criteria set

I'm designing a site for users who want to discover new things. I would like to know whether it's possible to auto-load pages one after the other with a set criteria for the script once a user has landed on site (after functions below have exceeded than for the script to stop). Criteria:

Total surf time on site: At random between 4-14 seconds (including landing page)
Total pages surfed on site: At random between 0-3 pages surfed (excluding landing page or 1-4 including landing page)
Total time spent on each page in on site: At random between 4-8 seconds each page (including landing page)

I have had a look at executing random page from .txt list and works well however, cannot understand how to implement this to meet the criteria above.
Will provide more information if needed, currently have this (site url removed, also have a url id parameter once random site exploded)
if ($is_redirect == TRUE)
{
    $random_num = rand(1000,30000);
    $random_num = str_replace(Array('/','+','='),Array('$','_3_','_G_'),base64_encode($random_num.'_tt_'.microtime(true)));
    $random_link_text = @file_get_contents('http://.com/random__link.txt');
    $random_link_text = @trim($random_link_text);
    $random_link = array_filter(explode(',',$random_link_text));
    $random_links_array = Array();
    if (is_array($random_link))
    {
        foreach ($random_link as $k=>$link)
            $random_links_array[] = trim($link);
    }
    if (!empty($random_links_array))
    {
        $rand_keys = array_rand($random_links_array, 1);

        //$selected_link = urldecode($random_links_array[$rand_keys]);
        $der=explode('&e=',$random_links_array[$rand_keys]);

        $selected_link = $random_links_array[$rand_keys];

A:

I would write all the sites into one page, to improve performance, then use js to fake redirects between them, trough changing the displayed url, and then show the contents:
The php to prijt multiple files into one file:
<div class="hidden" id="<?php echo somerandomtext;?>">
 <?php
   echo file_get_contents(somerandomtext);
 ?>
</div>

Repeat this four times. Then do the following css to hide:
.hidden{display:none;}

And js:
 window.onload=function(){
 var counter=4*Math.random();//show maximum four pages
 var interval=setInterval(function(){
  if(!--counter){
   clearInterval(interval);//stop the redirecting after a few redirects
  }
   var hidden=document.getElementsByClassName("hidden");
  //hide all
  for(key in hidden){
    hidden[key].style.display="none";
  }
  //get a random el
   var el=hidden[Math.random()*(hidden.length-1)];
 //show it
 el.style.display="block";
 //fake redirect
 location.pushState({},"MySite",el.id);

},Math.random()*4+4);//repeat in a random interval between 4 and 8
};

