Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

setup.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003  * ImaComm - a web based photo album software
00004  * Copyright (C) 2003, Mikko Kokkonen
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or (at
00009  * your option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  */
00020 
00021 $_setup_functions_prefix = realpath(dirname(__FILE__)."/../");
00022 require_once "$_setup_functions_prefix/platform.php";
00023 require_once "$_setup_functions_prefix/helper/common.php";
00024 require_once "$_setup_functions_prefix/setup/classes/Tests.php";
00025 require_once "$_setup_functions_prefix/setup/classes/Check.php";
00026 require_once "$_setup_functions_prefix/setup/classes/FunctionCheck.php";
00027 require_once "$_setup_functions_prefix/setup/classes/ProgramCheck.php";
00028 require_once "$_setup_functions_prefix/setup/classes/OptionCheck.php";
00029 require_once "$_setup_functions_prefix/classes/ProgressBar.php";
00030 
00031 define("INFO_ERROR", 0);
00032 define("INFO_WARNING", 1);
00033 define("INFO_PASSED", 2);
00034 
00035 // {{{ brainPart()
00039 function brainPart()
00040 {
00041         global $_page;
00042         
00043         // Get remain...
00044         $remain = explode(":", $_REQUEST['remain']);
00045         foreach ($remain as $r)
00046         {
00047                 $buf .= "<input type=\"hidden\" name=\"$r\" value=\"".$_REQUEST[$r]."\" />\n";
00048         }
00049         // Do we need load check-modules?
00050         if ($_page == 2 || $_page == 3 || $_page == 4 || $_page == 5 || $_page == 6)
00051         {
00052                 $d = dir("checks/");
00053                 while (false !== ($e = $d->read()))
00054                 {
00055                         if (preg_match('/\.php$/', $e))
00056                         {
00057                                  $files[] = $e;
00058                         }
00059                 }
00060                 sort($files); reset($files);
00061                 // Check modules loaded and sorted.
00062         }
00063         
00064         // What is our page? Do our page need any brains?
00065         if ($_page == 2)
00066         {
00067                 // {{{ Page 2: Settings auto-detect:
00068                 $_type = "text"; // text input or hidden input?
00069                 // We need automatic support...
00070                 foreach ($files as $mod)
00071                 {
00072                         // Load module...
00073                         $module = null;
00074                         include_once "checks/$mod";
00075                         
00076                         $id = $module['name'];
00077                         // What check do we use?
00078                         if ($module['type'] == "option")
00079                         {
00080                                 $value = ini_get($data['option']);
00081                                 if ($value == $data['expect'])
00082                                 {
00083                                         $out[$module['var']] = true;
00084                                         $ok++;
00085                                         $buf .= appendDataRow($id, $module['passed'], "p");
00086                                 }
00087                                 else
00088                                 {
00089                                         $out[$module['var']] = false;
00090                                         if ($module['serious'])
00091                                         {
00092                                                 $seriousErrors++;
00093                                                 $buf .= appendDataRow($id, $module['failed'], "se");
00094                                         }
00095                                         elseif ($module['error'])
00096                                         {
00097                                                 $errors++;
00098                                                 $buf .= appendDataRow($id, $module['failed'], "e");
00099                                         }
00100                                         else
00101                                         {
00102                                                 $warning++;
00103                                                 $buf .= appendDataRow($id, $module['notpassed'], "w");
00104                                         }
00105                                 }
00106                         }
00107                         elseif ($module['type'] == "program_check")
00108                         {
00109                                 $found = null;
00110                                 $programs = explode(":", $module['programs']);
00111                                 $found = prgFind($programs);
00112                                 // Get path...
00113                                 $out[$module['var']."_path"] = dirname($found[0]);
00114                                 // Strip paths from $found...
00115                                 $fnprgs = $found;
00116                                 array_walk($fnprgs, 'strip_path');
00117                                 $missing = array_diff($programs, $fnprgs);
00118                                 $missing = implode("<br />", $missing);
00119                                 if (count($found) <= $module['error'])
00120                                 {
00121                                         if ($module['serious'])
00122                                         {
00123                                                 $seriousErrors++;
00124                                                 $buf .= appendDataRow($id, $module['failed']."<br />Missing programs: $missing", "se");
00125                                         }
00126                                         else
00127                                         {
00128                                                 $errors++;
00129                                                 $buf .= appendDataRow($id, $module['failed']."<br />Missing programs: $missing", "e");
00130                                         }
00131                                 }
00132                                 elseif (count($found) < count($programs) && count($found) >= $module['warning'])
00133                                 {
00134                                         $warning++;
00135                                         $buf .= appendDataRow($id, $module['notpassed']."<br />Missing programs: $missing", "w");
00136                                 }
00137                                 elseif (count($found) == count($programs))
00138                                 {
00139                                         $ok++;
00140                                         $buf .= appendDataRow($id, $module['passed'], "p");
00141                                 }
00142                         }
00143                         elseif ($module['type'] == "function_check")
00144                         {
00145                                 $found = null;
00146                                 $functions = explode(":", $module['functions']);
00147                                 if (is_array($functions))
00148                                 {
00149                                         foreach ($functions as $func)
00150                                         {
00151                                                 if (function_exists($func))
00152                                                 {
00153                                                         $out[$func] = true;
00154                                                         $found[] = $func;
00155                                                 }
00156                                         }
00157                                 }
00158                                 $missing = array_diff($functions, $found);
00159                                 $missing = implode("<br />", $missing);
00160                                 if (count($found) <= $module['error'])
00161                                 {
00162                                         if ($module['serious'])
00163                                         {
00164                                                 $seriousErrors++;
00165                                                 $buf .= appendDataRow($id, $module['failed']."<br />Missing functions: $missing", "se");
00166                                         }
00167                                         else
00168                                         {
00169                                                 $errors++;
00170                                                 $buf .= appendDataRow($id, $module['failed']."<br />Missing functions: $missing", "e");
00171                                         }
00172                                 }
00173                                 elseif (count($found) < count($functions) && count($found) >= $module['warning'])
00174                                 {
00175                                         $warning++;
00176                                         $buf .= appendDataRow($id, $module['notpassed']."<br />Missing functions: $missing", "w");
00177                                 }
00178                                 elseif (count($found) == count($functions))
00179                                 {
00180                                         $ok++;
00181                                         $buf .= appendDataRow($id, $module['passed'], "p");
00182                                         $out[$module['var']] = true;
00183                                 }
00184                         }
00185                 }
00186                 // Print hidden inputs..
00187                 $remain = array_keys($out);
00188                 foreach ($out as $var => $value)
00189                 {
00190                         $buf .= "<input type=\"hidden\" name=\"$var\" value=\"$value\" />";
00191                 }
00192                 // }}}
00193         }
00194         elseif ($_page == 3)
00195         {
00196                 $_cache = null;
00197                 // {{{ Page 3: Path inqueries
00198                 // Loop every module and if it is program_check, ask for path...
00199                 $buf .= "<table border=\"0\" width=\"100%\">";
00200                 foreach ($files as $mod)
00201                 {
00202                         $module = null;
00203                         include "checks/$mod";
00204                         $id = $module['name'];
00205 
00206                         // Did we have this variable already?
00207                         if (@in_array($module['var'], $_cache))
00208                         {
00209                                 continue;
00210                         }
00211                         $_cache[] = $module['var'];
00212                         // Do we have program-check type...
00213                         if ($module['type'] == "program_check")
00214                         {
00215                                 $buf .= appendPathRow($module['name'], $module['var']."_path", $module['description']);
00216                         }
00217                         if ($module['type'] == "webpath")
00218                         {
00219                                 $remain[] = $module['var'];
00220                                 $buf .= appendPathRow($module['name'], $module['var'], $module['description'], $module['default']);
00221                         }
00222                         if ($module['type'] == "filecheck")
00223                         {
00224                                 $remain[] = $module['var'];
00225                                 $buf .= appendPathRow($module['name'], $module['var'], $module['description'], $module['default']);
00226                         }
00227                 }
00228                 $buf .= "</table>";
00229                 // }}}
00230         }
00231         elseif ($_page == 4)
00232         {
00233                 // {{{ And in page 4: Path checking...
00234                 $_cache = null;
00235                 $buf .= "<table border=\"0\">";
00236                 foreach ($files as $mod)
00237                 {
00238                         $module = null;
00239                         include "checks/$mod";
00240                         $id = $module['name'];
00241                         if (@in_array($module['var'], $_cache))
00242                         {
00243                                 continue;
00244                         }
00245                         $_cache[] = $module['var'];
00246                         if ($module['type'] == "program_check" && $_REQUEST[$module['var']."_path"] != "")
00247                         {
00248                                 // {{{ Program check...
00249                                 $found = null;
00250                                 $programs = explode(":", $module['programs']);
00251                                 $found = prgFind($programs, $_REQUEST[$module['var']."_path"], false);
00252                                 // Strip paths from $found...
00253                                 // Save founds...
00254                                 if (is_array($found))
00255                                 {
00256                                         $fnprogs = $found;
00257                                         @array_walk($fnprogs, 'strip_path');
00258                                         $missing = @array_diff($programs, $fnprogs);
00259                                         $missing = @implode("<br />", $missing);
00260                                         for ($p = 0; $p < count($found); $p++)
00261                                         {
00262                                                 $out[$fnprogs[$p]] = $found[$p];
00263                                         }
00264                                 }
00265                                 else
00266                                 {
00267                                         $missing = implode("<br />", $programs);
00268                                 }
00269                                 $count = count($found);
00270                                 
00271                                 if ($count < count($programs))
00272                                 {
00273                                         $buf .= appendInfoRow($id, "Path was incorrect!<br />Missing programs: $missing", INFO_ERROR);
00274                                 }
00275                                 else
00276                                 {
00277                                         $out[$module['var']] = true;
00278                                         $buf .= appendInfoRow($id, "Path is correct.", INFO_PASSED);
00279                                 }
00280                                 // }}}
00281                         }
00282                         elseif ($module['type'] == "webpath")
00283                         {
00284                                 // {{{ Web path
00285                                 $host = $_SERVER['HTTP_HOST']; // Our current server...
00286                                 // Do we have host?
00287                                 $uri = parse_url($_REQUEST[$module['var']]);
00288                                 if ($uri['host'] == "")
00289                                 {
00290                                         $uri['host'] = $host;
00291                                 }
00292                                 $urip = explode("/", $uri['path']);
00293                                 
00294                                 $spath = $_SERVER['PHP_SELF'];
00295                                 // Get our prefix (without ic... )
00296                                 $prefix = dirname($spath);
00297                                 // Array'ze it...
00298                                 $prefix = explode("/", $prefix);
00299                                 // And pop setup/ and ic/ out
00300                                 @array_pop($prefix); @array_pop($prefix);
00301                                 // And get difference...
00302                                 $diff = array_diff($urip, $prefix);
00303                                 $postfix = implode("/", $diff);
00304                                 $prefix = implode("/", $prefix);
00305                                 $url .= "$prefix/$postfix";
00306                                 $diff = "../../".implode("/", $diff);
00307 
00308                                 // Do we have albums...
00309                                 if (is_dir($diff))
00310                                 {
00311                                         // Can we write there...
00312                                         if (is_writable($diff))
00313                                         {
00314                                                 // {{{ Is Writable 
00315                                                 $ret = webCheck($diff, $url);
00316                                                 if ($ret == CHECK_OK)
00317                                                 {
00318                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm and accessible from Internet.");
00319                                                 }
00320                                                 elseif ($ret == CHECK_INTERNAL_ERROR)
00321                                                 {
00322                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm, accessible from Internet but something weird happened with test string comparasion.<br />ORiginal: $str<br />Readed: $data");
00323                                                 }
00324                                                 elseif ($ret == CHECK_NOT_FOUND)
00325                                                 {
00326                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm but is not accessible from Internet.", INFO_ERROR);
00327                                                 }
00328                                                 elseif ($ret == CHECK_NOT_WRITABLE)
00329                                                 {
00330                                                         $buf .= appendInfoRow($id, "Path is correct but is not writables.", INFO_ERROR);
00331                                                 }
00332                                                 // }}}
00333                                         }
00334                                         else
00335                                         {
00336                                                 // {{{ Is not writable
00337                                                 // Try to make it writable...
00338                                                 if (@chmod($diff, 0777))
00339                                                 {
00340                                                         $ret = webCheck($diff, $url);
00341                                                         if ($ret == CHECK_OK)
00342                                                         {
00343                                                                 $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm and accessible from Internet.");
00344                                                         }
00345                                                         elseif ($ret == CHECK_INTERNAL_ERROR)
00346                                                         {
00347                                                                 $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm, accessible from Internet but something weird happened with test string comparasion.<br />ORiginal: $str<br />Readed: $data");
00348                                                         }
00349                                                         elseif ($ret == CHECK_NOT_FOUND)
00350                                                         {
00351                                                                 $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm but is not accessible from Internet.", INFO_ERROR);
00352                                                         }
00353                                                         elseif ($ret == CHECK_NOT_WRITABLE)
00354                                                         {
00355                                                                 $buf .= appendInfoRow($id, "Path is correct but is not writables.", INFO_ERROR);
00356                                                         }
00357                                                 }
00358                                                 else
00359                                                 {
00360                                                         $buf .= appendInfoRow($id, "Path is correct but is not writable by ImaComm.", INFO_ERROR);
00361                                                 }
00362                                                 // }}}
00363                                         }
00364                                 }
00365                                 else
00366                                 {
00367                                         // Trying to create folder...
00368                                         if (@mkdir($diff, 0777))
00369                                         {
00370                                                 // Is it access from iNet?
00371                                                 $ret = webCheck($diff, $url);
00372                                                 if ($ret == CHECK_OK)
00373                                                 {
00374                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm and accessible from Internet.");
00375                                                 }
00376                                                 elseif ($ret == CHECK_INTERNAL_ERROR)
00377                                                 {
00378                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm, accessible from Internet but something weird happened with test string comparasion.<br />ORiginal: $str<br />Readed: $data");
00379                                                 }
00380                                                 elseif ($ret == CHECK_NOT_FOUND)
00381                                                 {
00382                                                         $buf .= appendInfoRow($id, "Path is correct, writable by ImaComm but is not accessible from Internet.", INFO_ERROR);
00383                                                 }
00384                                                 elseif ($ret == CHECK_NOT_WRITABLE)
00385                                                 {
00386                                                         $buf .= appendInfoRow($id, "Path is correct but is not writables.", INFO_ERROR);
00387                                                 }
00388 
00389                                         }
00390                                         else
00391                                         {
00392                                                 $buf .= appendInfoRow($id, "Path doesn't exists!", INFO_ERROR);
00393                                         }
00394                                 }
00395                                 // }}}
00396                         }
00397                         elseif ($module['type'] == "filecheck")
00398                         {
00399                                 // {{{ File check
00400                                 $remain[] = $module['var'];
00401                                 $path = $_REQUEST[$module['var']];
00402                                 if (file_exists("$path/".$module['file']))
00403                                 {
00404                                         $buf .= appendInfoRow($id, "Path is correct.", INFO_PASSED);
00405                                 }
00406                                 else
00407                                 {
00408                                         $buf .= appendInfoRow($id, "Path is incorrect.<br />Missing file: {$module['file']}", INFO_ERROR);
00409                                 }
00410                                 // }}}
00411                         }
00412                 }
00413                 $buf .= "</table>";
00414                 // Write hiddens outs...
00415                 foreach ($out as $key => $value)
00416                 {
00417                         $buf .= "<input type=\"hidden\" name=\"$key\" value=\"$value\" />";
00418                         $remain[] = $key;
00419                 }
00420                 // }}}
00421         }
00422         elseif ($_page == 5)
00423         {
00424                 // {{{ Page 5: Global settings, i.e. userdata module, graphics suite, etc.
00425                 $buf .= "<table border=\"0\">";
00426                 // Please select graphics suite...
00427                 // All 1-files are grap-suites...
00428                 foreach ($files as $mod)
00429                 {
00430                         $module = null;
00431                         if (preg_match('/^1.*?\.php$/', $mod))
00432                         {
00433                                 include "checks/$mod";
00434                                 if ($_REQUEST[$module['var']] == true)
00435                                 {
00436                                         $gd[$module['var']] = $module['name'];
00437                                 }
00438                         }
00439                         if (preg_match('/^2.*?\.php$/', $mod))
00440                         {
00441                                 include "checks/$mod";
00442                                 if ($_REQUEST[$module['var']] == true)
00443                                 {
00444                                         $exif[$module['var']] = $module['name'];
00445                                 }
00446                         }
00447                         if (preg_match('/^3.*\.php$/', $mod))
00448                         {
00449                                 include "checks/$mod";
00450                                 $mod = substr(basename($mod, ".php"), 1);
00451                                 if ($_REQUEST[$module['var']] != "")
00452                                 {
00453                                         $cfgmod[$mod] = $module['modname'];
00454                                 }
00455                         }
00456                         if (preg_match('/^5.*?\.php$/', $mod))
00457                         {
00458                                 include "checks/$mod";
00459                                 $mod = substr(basename($mod, ".php"), 1);
00460                                 if ($_REQUEST[$module['var']] != "")
00461                                 {
00462                                         $usrmod[$mod] = $module['modname'];
00463                                 }
00464                         }
00465                         if (preg_match('/^6.*?\.php$/', $mod))
00466                         {
00467                                 include "checks/$mod";
00468                                 $mod = substr(basename($mod, ".php"), 1);
00469                                 if ($_REQUEST[$module['var']] != "")
00470                                 {
00471                                         $commod[$mod] = $module['modname'];
00472                                 }
00473                         }
00474                 }
00475                 if (is_array($gd))
00476                 {
00477                         $remain[] = "gd";
00478                         $buf .= "<tr><td align=\"right\">Select graphics suite to use:</td><td><select name=\"gd\">";
00479                         foreach ($gd as $file => $name)
00480                         {
00481                                 $buf .= "<option value=\"$file\"";
00482                                 if ($_REQUEST['gd'] == $file)
00483                                 {
00484                                         $buf .= " selected";
00485                                 }
00486                                 $buf .= ">$name</option>";
00487                         }
00488                         $buf .= "</select></td></tr>\n";
00489                         $buf .= "<tr><td colspan=\"2\">Recommended graphics suite is NetPBM, if it is installed. GD Library is perhaps the most slowest suite to use.</td></tr>";
00490                         $buf .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
00491                 }
00492                 if (is_array($exif))
00493                 {
00494                         $remain[] = "exif";
00495                         $buf .= "<tr><td align=\"right\">Select EXIF reader to use:</td><td><select name=\"exif\">";
00496                         foreach ($exif as $key => $value)
00497                         {
00498                                 $buf .= "<option value=\"$key\"";
00499                                 if ($_REQUEST['exif'] == $key)
00500                                 {
00501                                         $buf .= " selected";
00502                                 }
00503                                 $buf .= ">$value</option>";
00504                         }
00505                         $buf .= "</select></td></tr>\n";
00506                         $buf .= "<tr><td colspan=\"2\">Please select EXIF reader to use. It it no big deal which one do you choose (if you have two opions to choose)</td></tr>";
00507                         $buf .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
00508                 }
00509                 if (is_array($cfgmod))
00510                 {
00511                         $remain[] = "cfgmod";
00512                         $buf .= "<tr><td align=\"right\">Select configuration module to use:</td><td><select name=\"cfgmod\">";
00513                         foreach ($cfgmod as $key => $value)
00514                         {
00515                                 $buf .= "<option value=\"$key\"";
00516                                 if ($_REQUEST['cfgmod'] == $key)
00517                                 {
00518                                         $buf .= " selected";
00519                                 }
00520                                 $buf .= ">$value</option>\n";
00521                         }
00522                         $buf .= "</select></td></tr>\n";
00523                         $buf .= "<tr><td colspan=\"2\">Select configuration module to use to save your configuration. THis is all options and albums, but not albums data (which photos, etc.), comments or user information. <b>Please notice:</b> changing configuration module is not at this moment possible without loosing every setting you have made!</td></tr>\n";
00524                         $buf .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
00525 
00526                 }
00527                 if (is_array($usrmod))
00528                 {
00529                         $remain[] = "usrmod";
00530                         $buf .= "<tr><td align=\"right\">Select userdata module to use:</td><td><select name=\"usrmod\">";
00531                         foreach ($usrmod as $key => $value)
00532                         {
00533                                 $buf .= "<option value=\"$key\"";
00534                                 if ($_REQUEST['usrmod'] == $key)
00535                                 {
00536                                         $buf .= " selected";
00537                                 }
00538                                 $buf .= ">$value</option>\n";
00539                         }
00540                         $buf .= "</select></td></tr>\n";
00541                         $buf .= "<tr><td colspan=\"2\">Please select module to use to write userdata to the disk. Userdata contains username, fullname, email address, etc.</td></tr>\n";
00542                         $buf .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
00543                 }
00544                 if (is_array($commod))
00545                 {
00546                         $remain[] = "commod";
00547                         $buf .= "<tr><td align=\"right\">Select commanets module to use:</td><td><select name=\"commod\">";
00548                         foreach ($commod as $key => $value)
00549                         {
00550                                 $buf .= "<option value=\"$key\">$value</option>\n";
00551                         }
00552                         $buf .= "</select></td></tr>\n";
00553                         $buf .= "<tr><td colspan=\"2\">Please select module to use to write comments to the disk. Some modules are faster to use than others, but some modules are easier to modify by hand than the others (e.g. XML Module)</td></tr>";
00554                         $buf .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
00555                 }
00556                 
00557                 $buf .= "</table>";
00558                 // }}}
00559         }
00560         elseif ($_page == 6)
00561         {
00562                 // {{{ Page 7: Save settings!
00563                 // Include Settings class...
00564                 require_once "../classes/settings.php";
00565                 require_once "../classes/users.php";
00566                 require_once "../classes/configuration.php";
00567                 
00568                 $settings = new Settings();
00569                 $settings->newFile();
00570 
00571                 // Blacklist
00572                 $ban = array("page", "next", "PHPSESSID", "remain");
00573                 extract($_REQUEST);
00574                 $k = array_keys($_REQUEST);
00575                 $vars = array_diff($k, $ban);
00576                 $vars = compact($vars);
00577 
00578                 foreach ($vars as $key => $value)
00579                 {
00580                         $settings->attribute($key, $value);
00581                 }
00582                 // Create default user...
00583                 $user = new Userdata(null, $_REQUEST['usrmod']);
00584                 $user->createFile();
00585                 $user->addUser("admin", crypt("admin"), "admin", array("fullname" => "Administrator"));
00586                 $settings->attribute("userdata_source", $user->file);
00587 
00588                 // Create default configuration
00589                 $config = new Configuration(null, $_REQUEST['cfgmod']);
00590                 $config->createFile();
00591                 $settings->attribute("config_source", $config->file);
00592                 
00593                 // And save file...
00594                 $settings->saveFile();
00595 
00596                 $buf .= "Congarulations! All your settings are now saved. All you need to do is go to the final page and start admiistrate your new ImaComm server!<br /><br />If you like to see your settings, those settings are saved as serialized Settings-object in <code>".realpath(dirname(__FILE__)."/../conf/settings")."</code> file.";
00597                 // }}}
00598         }
00599         if (is_array($remain))
00600         {
00601                 $buf .= "<input type=\"hidden\" name=\"remain\" value=\"".@implode(":", $remain)."\" />\n";
00602         }
00603         return $buf;
00604 }
00605 // }}}
00606 
00607 // {{{ Action!
00614 function action()
00615 {
00616         global $_page, $_setup_functions_prefix;
00617         $parts = array("common", "modules", "plugins");
00618         
00619         // Resolve our page...
00620         // Load all tests...
00621         ob_start();
00622         readfile("$_setup_functions_prefix/setup/tests/tests.dat");
00623         $ser = ob_get_contents();
00624         ob_end_clean();
00625         $tests = unserialize($ser);
00626         
00627         // Tests are loaded...
00628         $progress = new ProgressBar($tests->count, 1);
00629         $progress->Init();
00630         
00631         if ($_page == 1)
00632         {
00633                 // {{{ Page 1
00634                 // This is easy... We have nothing to do...
00635                 // }}} Page 1
00636         }
00637         elseif ($_page == 2)
00638         {
00639                 // {{{ Page 2
00640                 // Here we are going to launch automatic tests...
00641                 $buf .= "<table border=\"0\">";
00642                 foreach ($parts as $part)
00643                 {
00644                         $tsts = $tests->getTests($part);
00645                         for ($t = 0; $t < count($tsts); $t++)
00646                         {
00647                                 $test = $tsts[$t];
00648                                 $file = $test[0];
00649                                 $class = $test[1];
00650                                 // Load test module...
00651                                 require_once "$_setup_functions_prefix/setup/tests/$part/$file";
00652                                 $progress->status($class);
00653                                 // Let's launch an action...
00654                                 $tst = new $class();
00655                                 $tst->Action();
00656                                 $buf .= addStatusRow($tst->getTitle(), $tst->getDescription(),  $tst->getStatus(), $tst->getMissing());
00657                                 sleep(1);
00658                                 $progress->inc();
00659                         }
00660                 }
00661                 $buf .= "</table>";
00662                 $progress->hide();
00663                 // }}} Page 2
00664         }
00665         elseif ($_page == 3)
00666         {
00667                 // {{{ Page 3
00668                 // }}} Page 3
00669         }
00670         elseif ($_page == 4)
00671         {
00672                 // {{{ Page 4
00673                 // }}} Page 4
00674         }
00675         elseif ($_page == 5)
00676         {
00677                 // {{{ Page 5
00678                 // }}} Page 5
00679         }
00680         elseif ($_page == 6)
00681         {
00682                 // {{{ Page 6
00683                 // }}} Page 6
00684         }
00685         elseif ($_page == 7)
00686         {
00687                 // {{{ Page 7
00688                 // }}} Page 7
00689         }
00690 
00691         return $buf;
00692 }
00693 // }}} action
00694 
00695 // {{{ addStatusRow($title, $description, $status)
00696 function addStatusRow($title, $description, $status, $info = null)
00697 {
00698         $buf = "<tr>";
00699         $buf .= "<td valign=\"top\" class=\"title\" width=\"80%\">$title</td><td width=\"15\">&nbsp;</td><td rowspan=\"2\" valign=\"top\">";
00700         if ($status == STATUS_PASSED)
00701         {
00702                 $buf .= "<span class=\"passed\">Passed</span>$info";
00703         }
00704         elseif ($status == STATUS_WARNING)
00705         {
00706                 $buf .= "<span class=\"warning\">Warning!<br /></span><br />$info";
00707         }
00708         elseif ($status == STATUS_ERROR)
00709         {
00710                 $buf .= "<span class=\"error\">Error!</span><br />$info";
00711         }
00712         elseif ($status == STATUS_SERIOUS_ERROR)
00713         {
00714                 $buf .= "<span class=\"serious_error\">Serious error!</span><br />$info";
00715         }
00716         $buf .= "</td></tr>\n";
00717         $buf .= "<tr><td class=\"decription\">$description</td></tr>\n";
00718         $buf .= "<tr><td colspan=\"3\"><hr height=\"0\" size=\"0\" noshade /></td><tr>\n";
00719         return $buf;
00720 }
00721 // }}}
00722 ?>

Generated on Sun Oct 19 11:08:00 2003 for ImaComm by doxygen1.3