Changeset 1287

Show
Ignore:
Timestamp:
09/08/07 21:22:31 (1 year ago)
Author:
benoitg
Message:
  • Dependencies installation: Improve layout, add embryo of unified install sytem (currently works for tarballs). Improve error output.
  • Add dependencies for future OpenId? support
  • AbstractDb?: Make sure to throw an exception, avoiding a blank page when trying to access the index page on a auth server that hasn't been setup. Patch by Mathieu Bruno.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1285 r1287  
    11# $Id$ 
     22007-09-08 Benoit Grégoire  <bock@step.polymtl.ca> 
     3        * Dependencies installation:  Improve layout, add embryo of unified install sytem (currently works for tarballs).  Improve error output. 
     4        * Add dependencies for future OpenId support 
     5        * AbstractDb:  Make sure to throw an exception, avoiding a blank page when trying to access the index page on a auth server that hasn't been setup.  Patch by Mathieu Bruno. 
     6 
    272007-09-04 Benoit Grégoire  <bock@step.polymtl.ca> 
    38        * cron/page.php:  Improve script to output what it did. 
  • trunk/wifidog-auth/wifidog/classes/AbstractDb.php

    r1262 r1287  
    4343 * @link       http://www.wifidog.org/ 
    4444 */ 
    45  
     45require_once('classes/Dependency.php'); 
    4646/** 
    4747 * Database Abstraction class, deprecated, this should be transitioned to PDO over time 
     
    9090        $conn_string = "host=".CONF_DATABASE_HOST." dbname=$db_name user=".CONF_DATABASE_USER." password=".CONF_DATABASE_PASSWORD.""; 
    9191        // Try connecting and hide warning, errors 
     92        if ( !dependency::check('pgsql') ) 
     93        throw new Exception(_("It appears the postgresql module isn't loaded")); 
     94         
    9295        $ptr_connexion = @ pg_pconnect($conn_string); 
    9396 
  • trunk/wifidog-auth/wifidog/classes/DependenciesList.php

    r1282 r1287  
    136136           $html .= "<th>"._("Type")."</th>\n"; 
    137137           $html .= "<th>"._("Status")."</th>\n"; 
    138            $html .= "<th>"._("Description")."</th>\n"; 
    139            $html .= "<th>"._("Message")."</th>\n"; 
     138           $html .= "<th>"._("Information")."</th>\n"; 
    140139           $html .= "</tr>\n"; 
    141              
     140 
    142141           foreach ($components as $dependency) { 
    143142               $html .= "<tr>\n"; 
     
    154153               } 
    155154               $html .= "<td>$type</td>\n"; 
     155               $instalMessage = null; 
     156               $dependency->processInstallUI($instalMessage); 
     157                 
     158               $message = null; 
    156159               $available = Dependency::check($component_key, $message); 
    157160               if ($available) { 
    158                    $html .=  "$okMsg<td>$description</td><td>&nbsp;</td></tr>\n"; 
     161                   $html .=  "$okMsg\n"; 
    159162               } 
    160163               else { 
    161164                   if ($mandatory) { 
    162                        $html .=  "$errorMsg<td>$description</td><td>$message</td></tr>\n"; 
     165                       $html .=  "$errorMsg\n"; 
    163166                       $error = 1; 
    164167                   } 
    165168                   else { 
    166                        $html .=  "$warningMsg<td>$description</td><td>$message</td></tr>\n"; 
    167                    } 
    168                } 
     169                       $html .=  "$warningMsg\n"; 
     170                   } 
     171               } 
     172               $html .= "<td>\n"; 
     173               $html .= "<em>"._("Description").":</em> $description<br/>\n"; 
     174                 
     175               if($instalMessage) { 
     176                   $html .= "<em>"._("Install message").":</em> $instalMessage<br/>\n"; 
     177               } 
     178               if($message){ 
     179                   $html .= "<em>"._("Detection message").":</em> $message<br/>\n"; 
     180               } 
     181               if (!$available) { 
     182                   $html .= "<em>"._("To install").":</em> ".$dependency->getInstallUI()."<br/>\n"; 
     183               } 
     184               $html .= "</td></tr>\n"; 
    169185           } 
    170186           $html .=  "</table>\n"; 
    171              
     187 
    172188           return $html; 
    173189       } 
  • trunk/wifidog-auth/wifidog/classes/Dependency.php

    r1249 r1287  
    4646 */ 
    4747 
    48 // Detect Gettext support 
    49 if (!function_exists('gettext')) { 
    50     /** 
    51      * Load Locale class if Gettext support is not available 
    52      */ 
    53     require_once ('classes/Locale.php'); 
    54 
    55  
    56 require_once ('classes/Utils.php'); 
    57  
    58 /** 
    59  * This class checks the existence of components required by WiFiDog. 
    60  * Note that it implicitely depends on the defines in include/path_defines_base.php 
    61  * 
    62  * @package    WiFiDogAuthServer 
    63  * @author     Philippe April 
    64  * @author     Max Horváth <max.horvath@freenet.de> 
    65  * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    66  * @copyright  2005-2007 Philippe April 
    67  * @copyright  2005-2007 Max Horváth, Horvath Web Consulting 
    68  * @copyright  2006-2007 Benoit Grégoire, Technologies Coeus inc. 
    69  */ 
    70 class Dependency 
    71 
    72         /** 
    73          * List of components used by WiFiDog 
    74          * 
    75          * @var array 
    76          */ 
    77         private static $_components = array( 
    78                 /* 
    79                  * PHP extensions (mandatory) 
    80                  */ 
    81                 'mbstring' => array ( 
    82                         'mandatory' => 1, 
    83                         "type" => "phpExtension", 
    84                         'description' => 'Required for core auth-server and RSS support' 
    85                 ), 
    86                 'session' => array ( 
    87                         'mandatory' => 1, 
    88                         "type" => "phpExtension", 
    89                         'description' => 'Required for core auth-server' 
    90                 ), 
    91                 'pgsql' => array ( 
    92                         'mandatory' => 1, 
    93                         "type" => "phpExtension", 
    94                         'description' => 'Required for auth-server to connect to Postgresql database' 
    95                 ), 
    96  
    97                 /* 
    98                  * PHP extensions (optional) 
    99                  */ 
    100                 'gettext' => array ( 
    101                         "type" => "phpExtension", 
    102                         'description' => 'Almost essential: Without gettext, the auth-server will still work, but you will loose internationalization' 
    103                 ), 
    104                 'dom' => array ( 
    105                         "type" => "phpExtension", 
    106                         'description' => 'Required to export the list of HotSpots as a RSS feed and for the geocoders' 
    107                 ), 
    108                 'libxml' => array ( 
    109                         "type" => "phpExtension", 
    110                         'description' => 'Required to export the list of HotSpots as a RSS feed and for the geocoders' 
    111                 ), 
    112                 'mcrypt' => array ( 
    113                         "type" => "phpExtension", 
    114                         'description' => 'Required by the optional Radius Authenticator' 
    115                 ), 
    116                 'mhash' => array ( 
    117                         "type" => "phpExtension", 
    118                         'description' => 'Required by the optional Radius Authenticator' 
    119                 ), 
    120                 'xmlrpc' => array ( 
    121                         "type" => "phpExtension", 
    122                         'description' => 'Required by the optional Radius Authenticator' 
    123                 ), 
    124                 "ldap" => array ( 
    125                         "type" => "phpExtension", 
    126                         'description' => "Required by the optional LDAP Authenticator" 
    127                 ), 
    128                 'xml' => array ( 
    129                         "type" => "phpExtension", 
    130                         'description' => 'Required for RSS support' 
    131                 ), 
    132                 'curl' => array ( 
    133                         "type" => "phpExtension", 
    134                         'description' => 'Allows faster RSS support and required if you want to use Phlickr' 
    135                 ), 
    136                 'gd' => array ( 
    137                         "type" => "phpExtension", 
    138                         'description' => 'Required if you want to generate graphical statistics' 
    139                 ), 
    140                 'xsl' => array ( 
    141                         "type" => "phpExtension", 
    142                         'description' => 'Required if you want to generate a node list using XSLT stylesheets' 
    143                 ), 
    144                 /* 
    145                  * Pecl libraries 
    146                  */ 
    147                 "radius" => array ( 
    148                         "type" => "peclStandard", 
    149                         'description' => "Required by the optional Radius Authenticator" 
    150                 ), 
    151  
    152                 /* 
    153                  * Locally installed libraries 
    154                  */ 
    155                 "Smarty" => array ( 
    156                         "type" => "localLib", 
    157                         "detectFiles" => "lib/smarty/Smarty.class.php", 
    158                         'description' => "Required for all parts of wifidog", 
    159                         'website' => "http://smarty.php.net/" 
    160                 ), 
    161                 "FCKeditor" => array ( 
    162                         "type" => "localLib", 
    163                         "detectFiles" => "lib/FCKeditor/fckeditor.php", 
    164                         'description' => "Required by content type FCKEditor (WYSIWYG HTML)", 
    165                         'website' => "http://www.fckeditor.net/" 
    166                 ), 
    167                 "FPDF" => array ( 
    168                         "type" => "localLib", 
    169                         "detectFiles" => "lib/fpdf/fpdf.php", 
    170                         'description' => "Required if you want to be able to export the node list as a PDF file", 
    171                         'website' => "http://www.fpdf.org/" 
    172                 ), 
    173  
    174                 /* 
    175                  * PEAR libraries 
    176                  */ 
    177                 'Auth_RADIUS' => array ( 
    178                         "type" => "pearStandard", 
    179                         "detectFiles" => "Auth/RADIUS.php", 
    180                         'description' => "Required by the optional Radius Authenticator" 
    181                 ), 
    182                 'Crypt_CHAP' => array ( 
    183                         "type" => "pearStandard", 
    184                         "detectFiles" => "Crypt/CHAP.php", 
    185                         'description' => "Required by the optional Radius Authenticator" 
    186                 ), 
    187                 "Cache" => array ( 
    188                         "type" => "pearStandard", 
    189                         "detectFiles" => "Cache/Lite.php", 
    190                         'description' => "Required if you want to turn on the experimental USE_CACHE_LITE in config.php" 
    191                 ), 
    192                 "HTML_Safe" => array ( 
    193                         "type" => "pearStandard", 
    194                         "detectFiles" => "HTML/Safe.php", 
    195                         'description' => "Optional for content type Langstring (and subtypes) to better strip out dangerous HTML" 
    196                 ), 
    197                 "Image_Graph" => array ( 
    198                         "type" => "pearStandard", 
    199                         "detectFiles" => "Image/Graph.php", 
    200                         'description' => "Required if you want to generate graphical statistics" 
    201                 ), 
    202                 "Image_Canvas" => array ( 
    203                         "type" => "pearStandard", 
    204                         "detectFiles" => "Image/Canvas.php", 
    205                         'description' => "Required if you want to generate graphical statistics" 
    206                 ), 
    207                 "Image_Color" => array ( 
    208                         "type" => "pearStandard", 
    209                         "detectFiles" => "Image/Color.php", 
    210                         'description' => "Required if you want to generate graphical statistics" 
    211                 ), 
    212  
    213                 /* 
    214                  * PHP extensions (custom installations) 
    215                  */ 
    216                 "Phlickr" => array ( 
    217                         "type" => "pearCustom", 
    218                         "detectFiles" => "Phlickr/Api.php", 
    219                         'description' => "Required by content type FlickrPhotostream", 
    220                         'website' => "http://drewish.com/projects/phlickr/" 
    221                 ), 
    222         ); 
    223  
    224         /** 
    225          * Object cache for the object factory (getObject()) 
    226          */ 
    227         private static $instanceArray = array(); 
    228  
    229         private $_id; 
    230  
    231         /** 
    232          * Constructor 
    233          */ 
    234         private function __construct($component) { 
    235                 $this->_id = $component; 
    236         } 
    237  
    238         /** 
    239          * Get the entire array of Dependency 
    240          * 
    241          * @return boolean Returns whether the file has been found or not. 
    242          */ 
    243         public static function getDependency() 
    244         { 
    245                 $retval = array(); 
    246  
    247                 foreach (self::$_components as $component_key=>$component_info) { 
    248                         $retval[] = self::getObject($component_key); 
    249                 } 
    250  
    251                 return $retval; 
    252         } 
    253  
    254         /** 
    255          * Checks if a file exists, including checking in the include path 
    256          * 
    257          * @param string $file Path or name of a file 
    258          * 
    259          * @return boolean Returns whether the file has been found or not. 
    260          * 
    261          * @author Aidan Lister <aidan@php.net> 
    262          * @link http://aidanlister.com/repos/v/function.file_exists_incpath.php 
    263          * 
    264          * @static 
    265          */ 
    266         public static function file_exists_incpath($file) 
    267         { 
    268                 $_paths = explode(PATH_SEPARATOR, get_include_path()); 
    269  
    270                 foreach ($_paths as $_path) { 
    271                         // Formulate the absolute path 
    272                         $_fullPath = $_path . DIRECTORY_SEPARATOR . $file; 
    273  
    274                         // Check it 
    275                         if (file_exists($_fullPath)) { 
    276                                 return $_fullPath; 
    277                         } 
    278                 } 
    279  
    280                 return false; 
    281         } 
    282  
    283         /** 
    284          * Checks if a component is available. 
    285          * 
    286          * This function checks, if a specific component is available to be used 
    287          * by Wifidog. 
    288          * 
    289          * @param string $component Name of component to be checked. 
    290          * @param string $errmsg    Reference of a string which would contain an 
    291          *                          error message. 
    292          * 
    293          * @return boolean Returns whether the component has been found or not. 
    294          * 
    295          * @static 
    296          */ 
    297         public static function check($component, &$errmsg = null) 
    298         { 
    299                 // Init values 
    300                 $_returnValue = false; 
    301  
    302                 // Check, if the requested component can be found. 
    303                 if (isset(self::$_components[$component])) { 
    304                         // What are we checking for? 
    305                         if (self::$_components[$component]["type"] == "phpExtension" || self::$_components[$component]["type"] == "peclStandard") { 
    306                                 // Warning: extension_loaded(string) is case sensitive 
    307                                 $_returnValue = extension_loaded($component); 
    308                         } else if (self::$_components[$component]["type"] == "localLib") { 
    309                                 if (is_array(self::$_components[$component]["detectFiles"])) { 
    310                                         $_singleReturns = true; 
    311  
    312                                         foreach (self::$_components[$component]["detectFiles"] as $_fileNames) { 
    313                                                 $_filePath = WIFIDOG_ABS_FILE_PATH . $_fileNames; 
    314  
    315                                                 if (!file_exists($_filePath)) { 
    316                                                         $_singleReturns = false; 
    317  
    318                                                         if (!is_null($errmsg)) { 
    319                                                                 // The component has NOT been found. Return error message. 
    320                                                                 $errmsg = sprintf(_("Component %s is not installed (not found in %s)"), $component, $_filePath); 
    321                                                         } 
    322                                                 } 
    323                                         } 
    324  
    325                                         $_returnValue = $_singleReturns; 
    326                                 } else { 
    327                                         $_filePath = WIFIDOG_ABS_FILE_PATH . self::$_components[$component]["detectFiles"]; 
    328  
    329                                         if (file_exists($_filePath)) { 
    330                                                 // The component has been found. 
    331                                                 $_returnValue = true; 
    332                                         } else { 
    333                                                 if (!is_null($errmsg)) { 
    334                                                         // The component has NOT been found. Return error message. 
    335                                                         $errmsg = sprintf(_("Component %s is not installed (not found in %s)"), $component, $_filePath); 
    336                                                 } 
    337                                         } 
    338                                 } 
    339                         } else if (self::$_components[$component]["type"] == "standardLib" || self::$_components[$component]["type"] == "pearStandard" || self::$_components[$component]["type"] == "pearCustom") { 
    340                                 if (is_array(self::$_components[$component]["detectFiles"])) { 
    341                                         $_singleReturns = true; 
    342  
    343                                         foreach (self::$_components[$component]["detectFiles"] as $_fileNames) { 
    344                                                 // We need to use a custom file_exists to also check in the include path 
    345                                                 if (!self::file_exists_incpath($_fileNames)) { 
    346                                                         $_singleReturns = false; 
    347  
    348                                                         if (!is_null($errmsg)) { 
    349                                                                 // The component has NOT been found. Return error message. 
    350                                                                 $errmsg = sprintf(_("Component %s is not installed (not found in %s)"), $component, get_include_path()); 
    351                                                         } 
    352                                                 } 
    353                                         } 
    354  
    355                                         $_returnValue = $_singleReturns; 
    356                                 } else { 
    357                                         // We need to use a custom file_exists to also check in the include path 
    358                                         if (self::file_exists_incpath(self::$_components[$component]["detectFiles"])) { 
    359                                                 // The component has been found. 
    360                                                 $_returnValue = true; 
    361                                         } else { 
    362                                                 if (!is_null($errmsg)) { 
    363                                                         // The component has NOT been found. Return error message. 
    364                                                         $errmsg = sprintf(_("Component %s is not installed (not found in %s)"), $component, get_include_path()); 
    365                                                 } 
    366                                         } 
    367                                 } 
    368                         } else { 
    369                                 throw new Exception(sprintf("Unknown component type: %s", self::$_components[$component]["type"])); 
    370                         } 
    371                 } else { 
    372                         // The requested component has not been defined in this class. 
    373                         throw new Exception("Component not found"); 
    374                 } 
    375  
    376                 return $_returnValue; 
    377         } 
    378  
    379         /** 
    380          * Retreives the id of the object 
    381          * 
    382          * @return The id, a string 
    383          */ 
    384         public function getId() { 
    385                 return $this->_id; 
    386         } 
    387  
    388         /** 
    389          * Get an instance of the object 
    390          * 
    391          * @param string $id The object id 
    392          * 
    393          * @return mixed The Content object, or null if there was an error 
    394          *               (an exception is also thrown) 
    395          * 
    396          * @see GenericObject 
    397          * @static 
    398          * @access public 
    399          */ 
    400         public static function &getObject($id) 
    401         { 
    402                 if(!isset(self::$instanceArray[$id])) { 
    403                         self::$instanceArray[$id] = new self($id); 
    404                 } 
    405  
    406                 return self::$instanceArray[$id]; 
    407         } 
    408  
    409         /** 
    410          * Get website URL for the dependency (if available) 
    411          * 
    412          * @return URL or null 
    413          */ 
    414         public function getWebsiteURL() 
    415         { 
    416                 $retval = null; 
    417  
    418                 if(self::$_components[$this->_id]["type"] == "phpExtension") { 
    419                         $retval = "http://www.php.net/" . $this->_id . "/"; 
    420                 } else if(self::$_components[$this->_id]["type"] == "pearStandard") { 
    421                         $retval = "http://pear.php.net/package/" . $this->_id . "/"; 
    422                 } else if(self::$_components[$this->_id]["type"] == "peclStandard") { 
    423                         $retval = "http://pecl.php.net/package/" . $this->_id . "/"; 
    424                 } else { 
    425                         if(!empty(self::$_components[$this->_id]['website'])) { 
    426                                 $retval = self::$_components[$this->_id]['website']; 
    427                         } 
    428                 } 
    429  
    430                 return $retval; 
    431         } 
    432  
    433         /** 
    434          * Get the description of the dependency (if available) 
    435          * 
    436          * @return String or null 
    437          */ 
    438         public function getDescription() 
    439         { 
    440                 $retval = null; 
    441  
    442                 if(!empty(self::$_components[$this->_id]['description'])) { 
    443                         $retval = self::$_components[$this->_id]['description']; 
    444                 } 
    445  
    446                 return $retval; 
    447         } 
    448  
    449         /** 
    450          * Get the type of the dependency 
    451          * 
    452          * @return String 
    453          */ 
    454         public function getType() 
    455         { 
    456                 return self::$_components[$this->_id]['type']; 
    457         } 
    458  
    459         /** 
    460          * Get the type of the dependency 
    461          * 
    462          * @return String 
    463          */ 
    464         public function isMandatory() 
    465         { 
    466                 $retval = null; 
    467  
    468                 if(!empty(self::$_components[$this->_id]['mandatory'])) { 
    469                         $retval = true; 
    470                 } 
    471  
    472                 return $retval; 
    473         } 
    474  
    475 
    476  
    477 /* 
    478  * Local variables: 
    479  * tab-width: 4 
    480  * c-basic-offset: 4 
    481  * c-hanging-comment-ender-p: nil 
    482  * End: 
    483  */ 
     48 // Detect Gettext support 
     49 if (!function_exists('gettext')) { 
     50     /** 
     51      * Load Locale class if Gettext support is not available 
     52      */ 
     53      require_once ('classes/Locale.php'); 
     54 } 
     55 
     56 require_once ('classes/Utils.php'); 
     57       define('OPENID_PATH', WIFIDOG_ABS_FILE_PATH.'lib/php-openid-2.0.0-rc2/'); 
     58 /** 
     59  * This class checks the existence of components required by WiFiDog. 
     60  * Note that it implicitely depends on the defines in include/path_defines_base.php 
     61  * 
     62  * @package    WiFiDogAuthServer 
     63  * @author     Philippe April 
     64  * @author     Max Horváth <max.horvath@freenet.de> 
     65  * @author     Benoit Grégoire <bock@step.polymtl.ca> 
     66  * @copyright  2005-2007 Philippe April 
     67  * @copyright  2005-2007 Max Horváth, Horvath Web Consulting 
     68  * @copyright  2006-2007 Benoit Grégoire, Technologies Coeus inc. 
     69  */ 
     70  class Dependency 
     71  { 
     72      /** 
     73       * List of components used by WiFiDog 
     74       * 
     75       * @var array 
     76       */ 
     77 
     78       private static $_components = array( 
     79       /* PHP extensions (mandatory) */ 
     80       'mbstring' => array ( 
     81       'mandatory' => 1, 
     82       "type" => "phpExtension", 
     83       'description' => 'Required for core auth-server and RSS support' 
     84       ), 
     85       'session' => array ( 
     86       'mandatory' => 1, 
     87       "type" => "phpExtension", 
     88       'description' => 'Required for core auth-server' 
     89       ), 
     90       'pgsql' => array ( 
     91       'mandatory' => 1, 
     92       "type" => "phpExtension", 
     93       'description' => 'Required for auth-server to connect to Postgresql database' 
     94       ), 
     95 
     96       /* PHP extensions (optional) */ 
     97       'gettext' => array ( 
     98       "type" => "phpExtension", 
     99       'description' => 'Almost essential: Without gettext, the auth-server will still work, but you will loose internationalization' 
     100       ), 
     101       'dom' => array ( 
     102       "type" => "phpExtension", 
     103       'description' => 'Required to export the list of HotSpots as a RSS feed and for the geocoders' 
     104       ), 
     105       'libxml' => array ( 
     106       "type" => "phpExtension", 
     107       'description' => 'Required to export the list of HotSpots as a RSS feed and for the geocoders' 
     108       ), 
     109       'mcrypt' => array ( 
     110       "type" => "phpExtension", 
     111       'description' => 'Required by the optional Radius Authenticator' 
     112       ), 
     113       'mhash' => array ( 
     114       "type" => "phpExtension", 
     115       'description' => 'Required by the optional Radius Authenticator' 
     116       ), 
     117       'xmlrpc' => array ( 
     118       "type" => "phpExtension", 
     119       'description' => 'Required by the optional Radius Authenticator' 
     120       ), 
     121       "ldap" => array ( 
     122       "type" => "phpExtension", 
     123       'description' => "Required by the optional LDAP Authenticator" 
     124       ), 
     125       'xml' => array ( 
     126       "type" => "phpExtension", 
     127       'description' => 'Required for RSS support' 
     128       ), 
     129       'curl' => array ( 
     130       "type" => "phpExtension", 
     131       'description' => 'Allows faster RSS support and required if you want to use Phlickr' 
     132       ), 
     133       'gd' => array ( 
     134       "type" => "phpExtension", 
     135       'description' => 'Required if you want to generate graphical statistics' 
     136       ), 
     137       'xsl' => array ( 
     138       "type" => "phpExtension", 
     139       'description' => 'Required if you want to generate a node list using XSLT stylesheets' 
     140       ), 
     141       /* Pecl libraries */ 
     142       "radius" => array ( 
     143       "type" => "peclStandard", 
     144       'description' => "Required by the optional Radius Authenticator" 
     145       ), 
     146 
     147       /* Locally installed libraries */ 
     148       "Smarty" => array ( 
     149       "type" => "localLib", 
     150       "detectFiles" => "lib/smarty/Smarty.class.php", 
     151       'description' => "Required for all parts of wifidog", 
     152       'website' => "http://smarty.php.net/" 
     153       ), 
     154       "FCKeditor" => array ( 
     155       "type" => "localLib", 
     156       "detectFiles" => "lib/FCKeditor/fckeditor.php", 
     157       'description' => "Required by content type FCKEditor (WYSIWYG HTML)", 
     158       'website' => "http://www.fckeditor.net/" 
     159       ), 
     160       "FPDF" => array ( 
     161       "type" => "localLib", 
     162       "detectFiles" => "lib/fpdf/fpdf.php", 
     163       'description' => "Required if you want to be able to export the node list as a PDF file", 
     164       'website' => "http://www.fpdf.org/" 
     165       ), 
     166       "php-openid" => array ( 
     167       "type" => "localLib", 
     168       "detectFiles" => "lib/php-openid-2.0.0-rc2/CHANGELOG", 
     169       'description' => "Required for OpenID support (both as a consumer and Identity provider)", 
     170       'website' => "http://www.openidenabled.com/php-openid/", 
     171       'installSourceUrl' => "http://openidenabled.com/files/php-openid/packages/php-openid-2.0.0-rc2.tar.bz2", 
     172       'installMethod' => "tarball", 
     173       'installDestination' => "/" 
     174       ), 
     175       'gmp' => array ( 
     176       "type" => "phpExtension", 
     177       'description' => 'Required for good OpenID support (otherwise, BCmath will be used, which is MUCH slower)' 
     178       ), 
     179       'BCmath' => array ( 
     180       "type" => "phpExtension", 
     181       'description' => 'Required for OpenID support, but ONLY if GMP above is not available' 
     182       ), 
     183       /* PEAR libraries */ 
     184       'Auth_RADIUS' => array ( 
     185       "type" => "pearStandard", 
     186       "detectFiles" => "Auth/RADIUS.php", 
     187       'description' => "Required by the optional Radius Authenticator" 
     188       ), 
     189       'Crypt_CHAP' => array ( 
     190       "type" => "pearStandard", 
     191       "detectFiles" => "Crypt/CHAP.php", 
     192       'description' => "Required by the optional Radius Authenticator" 
     193       ), 
     194       "Cache" => array ( 
     195       "type" => "pearStandard", 
     196       "detectFiles" => "Cache/Lite.php", 
     197       'description' => "Required if you want to turn on the experimental USE_CACHE_LITE in config.php" 
     198       ), 
     199       "HTML_Safe" => array ( 
     200       "type" => "pearStandard", 
     201       "detectFiles" => "HTML/Safe.php", 
     202       'description' => "Optional for content type Langstring (and subtypes) to better strip out dangerous HTML" 
     203       ), 
     204       "Image_Graph" => array ( 
     205       "type" => "pearStandard", 
     206       "detectFiles" => "Image/Graph.php", 
     207       'description' => "Required if you want to generate graphical statistics" 
     208       ), 
     209       "Image_Canvas" => array ( 
     210       "type" => "pearStandard", 
     211       "detectFiles" => "Image/Canvas.php", 
     212       'description' => "Required if you want to generate graphical statistics" 
     213       ), 
     214       "Image_Color" => array ( 
     215       "type" => "pearStandard", 
     216       "detectFiles" => "Image/Color.php", 
     217       'description' => "Required if you want to generate graphical statistics" 
     218       ), 
     219 
     220       /* PHP extensions (custom installations) */ 
     221       "Phlickr" => array ( 
     222       "type" => "pearCustom", 
     223       "detectFiles" => "Phlickr/Api.php", 
     224       'description' => "Required by content type FlickrPhotostream", 
     225       'website' => "http://drewish.com/projects/phlickr/", 
     226       'installSourceUrl' => "http://superb-east.dl.sourceforge.net/sourceforge/phlickr/Phlickr-0.2.7.tgz" 
     227       ), 
     228       ); 
     229 
     230       /** 
     231        * Object cache for the object factory (getObject()) 
     232        */ 
     233        private static $instanceArray = array(); 
     234 
     235        private $_id; 
     236 
     237        /** 
     238         * Constructor 
     239         */ 
     240         private function __construct($component) { 
     241             $this->_id = $component; 
     242         } 
     243 
     244         /** 
     245          * Get the entire array of Dependency 
     246          * 
     247          * @return boolean Returns whether the file has been found or not. 
     248          */ 
     249          public static function getDependency() 
     250          { 
     251              $retval = array(); 
     252 
     253              foreach (self::$_components as $component_key=>$component_info) { 
     254                  $retval[] = self::getObject($component_key); 
     255              } 
     256 
     257              return $retval; 
     258          } 
     259 
     260          /** Use PHP internal functions to execute a command 
     261            @return: Return value of the command*/ 
     262          function execVerbose($command, & $output, & $return_var, &$errMsg = null) { 
     263              $errMsg .= "Executing: $command <br/>"; 
     264              exec($command.'  2>&1', $output, $return_var); 
     265              if ($return_var != 0) 
     266              $errMsg .= "<p style='color:red'><em>Error:</em>  Command did not complete successfully  (returned $return_var): <br/>\n"; 
     267              else 
     268              $errMsg .= "<p style='color:green'><em>Command completed successfully</em>  (returned $return_var): <br/>\n"; 
     269 
     270              if (($return_var != 0) && $output) { 
     271                  foreach ($output as $output_line) 
     272                  $errMsg .= " $output_line <br/>\n"; 
     273              } 
     274              $errMsg .= "</p>\n"; 
     275              return $return_var; 
     276          } 
     277 
     278          /** 
     279           * Checks if a file exists, including checking in the include path 
     280           * 
     281           * @param string $file Path or name of a file 
     282           * 
     283           * @return boolean Returns whether the file has been found or not. 
     284           * 
     285           * @author Aidan Lister <aidan@php.net> 
     286           * @link http://aidanlister.com/repos/v/function.file_exists_incpath.php 
     287           */ 
     288           public static function file_exists_incpath($file) 
     289           { 
     290               $_paths = explode(PATH_SEPARATOR, get_include_path()); 
     291 
     292               foreach ($_paths as $_path) { 
     293                   // Formulate the absolute path 
     294                   $_fullPath = $_path . DIRECTORY_SEPARATOR . $file; 
     295 
     296                   // Check it 
     297                   if (file_exists($_fullPath)) { 
     298                       return $_fullPath; 
     299                   } 
     300               } 
     301 
     302               return false; 
     303           } 
     304 
     305           /** 
     306            * Checks if a component is available. 
     307            * 
     308            * This function checks, if a specific component is available to be used 
     309            * by Wifidog. 
     310            * 
     311            * @param string $component Name of component to be checked. 
     312            * @param string $errmsg    Reference of a string which would contain an 
     313            *                          error message. 
     314            * 
     315            * @return boolean Returns whether the component has been found or not. 
     316            */ 
     317            public static function check($component, &$errmsg = null) 
     318            { 
     319                // Init values 
     320                $returnValue = false; 
     321 
     322                // Check, if the requested component can be found. 
     323                if (isset(self::$_components[$component])) { 
     324                    // What are we checking for? 
     325                    if (self::$_components[$component]["type"] == "phpExtension" || self::$_components[$component]["type"] == "peclStandard") { 
     326                        // Warning: extension_loaded(string) is case sensitive 
     327                        $returnValue = extension_loaded($component); 
     328                    } 
     329                    else if (self::$_components[$component]["type"] == "localLib") { 
     330                        if (is_array(self::$_components[$component]["detectFiles"])) { 
     331                            $_singleReturns = true; 
     332                            foreach (self::$_components[$component]["detectFiles"] as $_fileNames) { 
     333                                $filePath = WIFIDOG_ABS_FILE_PATH . $_fileNames; 
     334 
     335                                if (!file_exists($filePath)) { 
     336                                    echo "TEST"; 
     337                                    $_singleReturns = false; 
     338                                    // The component has NOT been found. Return error message. 
     339                                    $errmsg .= sprintf(_("File %s not found"), $filePath); 
     340                                    break; 
     341                                } 
     342                            } 
     343 
     344                            $returnValue = $_singleReturns; 
     345                        } 
     346                        else { 
     347                            $filePath = WIFIDOG_ABS_FILE_PATH . self::$_components[$component]["detectFiles"]; 
     348 
     349                            if (file_exists($filePath)) { 
     350                                // The component has been found. 
     351                                $returnValue = true; 
     352                            } 
     353                            else { 
     354                                // The component has NOT been found. Return error message. 
     355                                $errmsg .= sprintf(_("File %s not found"), $filePath); 
     356                            } 
     357                        } 
     358                    } 
     359                    else if (self::$_components[$component]["type"] == "pearStandard" || self::$_components[$component]["type"] == "pearCustom") { 
     360                        if (is_array(self::$_components[$component]["detectFiles"])) { 
     361                            $_singleReturns = true; 
     362 
     363                            foreach (self::$_components[$component]["detectFiles"] as $_fileNames) { 
     364                            &nbs