Location: PHPKode > scripts > HostingBenchmark > hostingbenchmark/index.php
<?php

/***************************************************************
*  (c) 2006-2007 Askywhale (hosting[a]askywhale.com)
*  All rights reserved
*
*  This script is part of HostingBenchmark.com. This project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
***************************************************************/

//session : lang, forms/t/.., tests/t/.., currentPass, currentTest, results

ini_set('display_errors','On');
error_reporting(E_ALL);

require_once("includes/view.php");

$nView = "start";
$error = "";

$availableTest = getAvailableTests();
session_start();
require_once('language/lang_'.getLang().'/lang_hostingbench.php');


if(!isset($_SESSION['language']))
  $nView = "chooselanguage";

$action= "";
if(isset($_REQUEST['action'])) {
  $action = $_REQUEST['action'];
  if(isset($_POST['action']))
    $_SESSION['forms'][$_POST['action']] = $_POST;
}

if($action=='chooselanguage') {
  if(isset($_REQUEST['language']))
    $_SESSION['language'] = $_REQUEST['language'];
  $nView = 'start';
}  

if($action=="start") {
  $nView = 'selecttests';
  if(isset($_POST['use_parameters'])&&$_POST['use_parameters']!='') {
    setStringParameters($_POST['parameters']);
    if(count($_SESSION['tests'])==0)
      addError($lang['no_test_selected']);    
    $nView = 'test';          
  }
}
  
if($action=="selecttests") {
  $_SESSION['tests'] = array();  
  foreach($_POST as $k=>$v)
    if(strstr($k,'Test')!==false&&isset($availableTest[$k])) 
      $_SESSION['tests'][] = $availableTest[$k];
  if(count($_SESSION['tests'])==0)
    addError($lang['no_test_selected']);
}

if($action=="setparameters") {
  $_SESSION['tests'][$_REQUEST['test']]->setParametersFromPost();  
}

if($action=="selecttests"||$action=="setparameters"||$action=="restart") {   
  $nView = 'setmainparameters';
  foreach($_SESSION['tests'] as $k=>$test)
    if($action!="setparameters"||$k>$_POST['test']){
      $formParameters = $_SESSION['tests'][$k]->getParametersForm();
      if($formParameters!=''/*&&$_SESSION['tests'][$k]->parameters==''*/) {
        $nView = 'setparameters';
        $parametersTest = $k;
        break;
      }      
  }  
}

if($action=="setmainparameters") {
  /*if(!isset($_REQUEST['ignoreworst']))
    $_SESSION['forms']['setmainparameters']['ignoreworst'] = 'off';*/
  resetResults();
  $nView = 'test';
}

if($action=="test") {
  do {
    $_SESSION['currentTest']++;
    if($_SESSION['currentTest']>=count($_SESSION['tests'])) {
      $_SESSION['currentPass']++;
      $_SESSION['currentTest']=0;
    }
    $nView = 'test';
    $nomore = $_SESSION['currentPass']>=$_SESSION['forms']['setmainparameters']['pass'];
  } while(!$nomore && 
    ($_SESSION['currentPass']>0 && 
      !$_SESSION['tests'][$_SESSION['currentTest']]->isBenchmark()));
  if($nomore)
    $nView = 'showresults';
}

if($error=="")
  $view = $nView;
else
  $view = $action;
showView($nView);

?>
Return current item: HostingBenchmark