Location: PHPKode > projects > Tinbox > systemadmin/parsetest.php
<?php
//this is a basic test for speed of parsing
require('../config.php');
require(PPATH.INCLUDES."parsexml.php");

define ('SELECT_LIMIT', 10); //set limit for select
define ('ITERATIONS', 50);//set number of times to parse module
define ('OUTPUT_HTML', 0);//set if you want to output html

set_time_limit(0);

$link = mysql_connect(DB_SERVER, DB_USER, DB_PSW);
mysql_select_db(DB_DB);

echo "Starting parse test at ".strftime("%H:%M:%S",time())." using '".XML_SOURCE."' for XML_SOURCE<br>";

$start = time();

if(XML_SOURCE == "db")
        $sql = "select mo.xml_mod, mo.idx as mod_idx, mo.title as module, co.title as course, mo.chapter, co.idx as course_idx from course_modules mo, course_main co where mo.course_idx=co.idx limit ".SELECT_LIMIT;
else
        $sql = "select mo.idx as mod_idx, mo.title as module, co.title as course, mo.chapter, co.idx as course_idx from course_modules mo, course_main co where mo.course_idx=co.idx limit ".SELECT_LIMIT;
echo $sql."<br>";

$start = time();
for ($i=1;$i<ITERATIONS;$i++)
        {
        $result=mysql_query($sql);
        while($row = mysql_fetch_object($result))
                {
                $title = $row->course." - ".$row->chapter.". ".$row->module;
                $figURL = VPATH.COURSEWARE.$row->course_idx."/";
                $file=PPATH.COURSEWARE.$row->course_idx."/".$row->mod_idx;
                $theme="default";
                $HTMLheader = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head>";
                $HTMLheader .= "<title>".$title."</title>";
                $HTMLheader .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
                include(PPATH.THEMES.$theme."/css.php");
                $HTMLheader .= $css;
                $HTMLheader .= "</head>";
                $HTMLheader .= "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">";
                $HTMLheader .= "<center><img class=\"banner\" src=\"".VPATH.THEMES.$theme."/icons/mailbanner.gif\" alt=\"Logo\"></center><table class=\"box\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"700\">";
                $HTMLheader .= "<tr><td><div align=\"right\"><img class=\"banner\" src=\"".VPATH.THEMES.$theme."/icons/logo.gif\" alt=\"Logo\"></div>";
                $HTMLheader .= "<form action=\"".VPATH."student/?schedidx=".$schedidx."&db=".$db."\" method=\"post\">";
                $modidx=$row->mod_idx; //needed if figures (IMG)
                $mod=$row->chapter;
                if(XML_SOURCE == "db")
                        parsexml($title,$row->xml_mod);
                else
                        {
                        $XMLfile = COURSEWARE.$row->course_idx."/".$row->chapter;
                        if ($fp = fopen($XMLfile, "r"))
                                {
                                $XMLdata = fread($fp, filesize($XMLfile));
                                fclose($fp);
                                parsexml($title,$XMLdata);
                                }
                        else
                                $parsedXML="There was an error fetching this module, please report to the course administrator";
                        }
                $HTMLfooter .= "<table class=\"feedback\" width=\"95%\"><tr><td rowspan=\"2\"><em>How do you rate the quality of the content ?</em></td><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th></tr><tr><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"1\"></td><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"2\"></td><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"3\"></td><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"4\"></td><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"5\"></td><td width=\"5\"><input type=\"radio\" name=\"rating\" value=\"6\"></td></tr><tr><td colspan=\"7\"><b>Note:</b> Please use the following scale for rating:<br> 1.unacceptable, 2.very unsatisfactory, 3.unsatisfactory, 4.satisfactory, 5.very satisfactory, 6.excellent.</td></tr></table><input type=\"hidden\" name=\"NOQ\" value=\"". $qa."\"><div align=\"right\"><input type=\"image\" name=\"submit\" value=\"finished\" src=\"".VPATH.THEMES.$theme."/icons/done.gif\" class=\"done\"></div></form></td></tr></table></body></html>";
                }
        echo ". ";
        }
if (OUTPUT_HTML)
        echo $parsedXML;
echo "<br>Module: ".$row->module."<br>";
echo "Parsing ".(ITERATIONS*mysql_num_rows(mysql_query($sql)))." files took ".(time()-$start)." seconds";
echo "<br>";

echo "<br>Finished parse test at ".strftime("%H:%M:%S",time());
?>

Return current item: Tinbox