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

ProgramCheck.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: template.php,v 1.3 2003/09/21 10:33:12 mikko Exp $ */
00003 /*
00004  * ImaComm - a web based photo album software
00005  * Copyright (C) 2003, Mikko Kokkonen
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or (at
00010  * your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 $__dir = realpath(dirname(__FILE__)."/../../");
00022 require_once "$__dir/platform.php";
00023 
00024 class ProgramCheck extends Check
00025 {
00030         var $programs;
00031         var $path;
00032         
00033         function ProgramCheck($path = null)
00034         {
00035                 $this->path = $path;
00036         }
00037         
00043         function Action()
00044         {
00045                 // This is easy...
00046                 // Do we have path?
00047                 if (!is_null($this->path))
00048                 {
00049                         foreach ($this->programs as $program)
00050                         {
00051                                 if (is_executable($this->path."/$program"))
00052                                 {
00053                                         $this->found[] = $program;
00054                                 }
00055                                 else
00056                                 {
00057                                         $this->missing[] = $program;
00058                                 }
00059                         }
00060                 }
00061                 else
00062                 {
00063                         // Start FS find...
00064                         foreach ($this->programs as $program)
00065                         {
00066                                 $pp = fs_find_executable($program);
00067                                 if ($pp != "")
00068                                 {
00069                                         $this->found[] = $pp;
00070                                 }
00071                                 else
00072                                 {
00073                                         $this->missing[] = $program;
00074                                 }
00075                         }
00076                 }
00077                 // Do status check...
00078                 $found = count($this->founded);
00079                 $notfound = count($this->missing);
00080                 $expect = count($this->programs);
00081                 
00082                 // Are we above warning level?
00083                 if ($found > $this->warn_level)
00084                 {
00085                         $this->status = STATUS_PASSED;
00086                 }
00087                 elseif ($found > $this->err_level)
00088                 {
00089                         $this->status = STATUS_WARNING;
00090                 }
00091                 elseif ($this->serious)
00092                 {
00093                         $this->status = STATUS_SERIOUS_ERROR;
00094                 }
00095                 else
00096                 {
00097                         $this->status = STATUS_ERROR;
00098                 }
00099         }
00100 
00108         function Result()
00109         {
00110                 return $this->missing;
00111         }
00112 }
00113 ?>

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