| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|---|
| 4 | |
|---|
| 5 | // +-------------------------------------------------------------------+ |
|---|
| 6 | // | WiFiDog Authentication Server | |
|---|
| 7 | // | ============================= | |
|---|
| 8 | // | | |
|---|
| 9 | // | The WiFiDog Authentication Server is part of the WiFiDog captive | |
|---|
| 10 | // | portal suite. | |
|---|
| 11 | // +-------------------------------------------------------------------+ |
|---|
| 12 | // | PHP version 5 required. | |
|---|
| 13 | // +-------------------------------------------------------------------+ |
|---|
| 14 | // | Homepage: http://www.wifidog.org/ | |
|---|
| 15 | // | Source Forge: http://sourceforge.net/projects/wifidog/ | |
|---|
| 16 | // +-------------------------------------------------------------------+ |
|---|
| 17 | // | This program is free software; you can redistribute it and/or | |
|---|
| 18 | // | modify it under the terms of the GNU General Public License as | |
|---|
| 19 | // | published by the Free Software Foundation; either version 2 of | |
|---|
| 20 | // | the License, or (at your option) any later version. | |
|---|
| 21 | // | | |
|---|
| 22 | // | This program is distributed in the hope that it will be useful, | |
|---|
| 23 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 24 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|---|
| 25 | // | GNU General Public License for more details. | |
|---|
| 26 | // | | |
|---|
| 27 | // | You should have received a copy of the GNU General Public License | |
|---|
| 28 | // | along with this program; if not, contact: | |
|---|
| 29 | // | | |
|---|
| 30 | // | Free Software Foundation Voice: +1-617-542-5942 | |
|---|
| 31 | // | 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
|---|
| 32 | // | Boston, MA 02111-1307, USA gnu@gnu.org | |
|---|
| 33 | // | | |
|---|
| 34 | // +-------------------------------------------------------------------+ |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * @package WiFiDogAuthServer |
|---|
| 38 | * @copyright 2006-2007 Benoit Grégoire, Technologies Coeus inc. |
|---|
| 39 | * @version Subversion $Id: $ |
|---|
| 40 | * @link http://www.wifidog.org/ |
|---|
| 41 | */ |
|---|
| 42 | |
|---|
| 43 | // Detect Gettext support |
|---|
| 44 | if (!function_exists('gettext')) { |
|---|
| 45 | /** |
|---|
| 46 | * Load Locale class if Gettext support is not available |
|---|
| 47 | */ |
|---|
| 48 | require_once ('classes/Locale.php'); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | require_once ('classes/Utils.php'); |
|---|
| 52 | |
|---|
| 53 | /** |
|---|
| 54 | * This class checks the existence of components required by WiFiDog. |
|---|
| 55 | * Note that it implicitely depends on the defines in include/path_defines_base.php |
|---|
| 56 | * |
|---|
| 57 | * @package WiFiDogAuthServer |
|---|
| 58 | * @author Philippe April |
|---|
| 59 | * @author Max Horváth <max.horvath@freenet.de> |
|---|
| 60 | * @author Benoit Grégoire <bock@step.polymtl.ca> |
|---|
| 61 | * @copyright 2005-2007 Philippe April |
|---|
| 62 | * @copyright 2005-2007 Max Horváth, Horvath Web Consulting |
|---|
| 63 | * @copyright 2006-2007 Benoit Grégoire, Technologies Coeus inc. |
|---|
| 64 | */ |
|---|
| 65 | |
|---|
| 66 | /** |
|---|
| 67 | * Load required classes |
|---|
| 68 | */ |
|---|
| 69 | /*WARNING: You must NOT require anything, or extend anything except Dependency.php. DependenciesList is used from the install script.*/ |
|---|
| 70 | require_once ('classes/Dependency.php'); |
|---|
| 71 | require_once ('classes/GenericDataObject.php'); |
|---|
| 72 | |
|---|
| 73 | class DependenciesList extends GenericDataObject |
|---|
| 74 | { |
|---|
| 75 | public static function &getObject($id) |
|---|
| 76 | { |
|---|
| 77 | $retval = new self(); |
|---|
| 78 | return $retval; |
|---|
| 79 | } |
|---|
| 80 | /** Retreives the admin interface of this object. |
|---|
| 81 | * @return The HTML fragment for this interface, or null. |
|---|
| 82 | * If it returns null, this object does not support new object creation */ |
|---|
| 83 | public function getAdminUI($userData = null) { |
|---|
| 84 | return self::getAdminUIStatic($userData); |
|---|
| 85 | } |
|---|
| 86 | /** Retreives the admin interface of this object. |
|---|
| 87 | * @return The HTML fragment for this interface, or null. |
|---|
| 88 | * If it returns null, this object does not support new object creation */ |
|---|
| 89 | static public function getAdminUIStatic($userData = null) { |
|---|
| 90 | |
|---|
| 91 | $html = ''; |
|---|
| 92 | /* PHP version check */ |
|---|
| 93 | $okMsg = '<td ALIGN="CENTER" STYLE="background:lime;">OK</td>'; |
|---|
| 94 | $errorMsg = '<td ALIGN="CENTER" STYLE="background:red;">ERROR</td>'; |
|---|
| 95 | $warningMsg = '<td ALIGN="CENTER" STYLE="background:yellow;">Warning</td>'; |
|---|
| 96 | |
|---|
| 97 | $html .= "<table BORDER=\"1\">"; |
|---|
| 98 | |
|---|
| 99 | /* PHP version check */ |
|---|
| 100 | $requiredPHPVersion = '5.0'; |
|---|
| 101 | $phpVersion = phpversion(); |
|---|
| 102 | $html .= "<tr><td>PHP</td>"; |
|---|
| 103 | if (version_compare($phpVersion, $requiredPHPVersion, ">=")) { |
|---|
| 104 | $html .= "$okMsg<td>$phpVersion</td>"; // Version 5.0.0 or later |
|---|
| 105 | } |
|---|
| 106 | else { |
|---|
| 107 | $html .= "$errorMsg<td>".sprintf(_("Version %s needed"), $requiredPHPVersion)."</td>"; // Version < 5.0.0 |
|---|
| 108 | $userData['error'] = 1; |
|---|
| 109 | } |
|---|
| 110 | $html .= "</tr>"; |
|---|
| 111 | |
|---|
| 112 | //Be carefull, postgres version check will fail if there wasn't a db connexion yet. |
|---|
| 113 | $pgVersionArray = @pg_version(); |
|---|
| 114 | $pgVersionArray?$pgVersion=$pgVersionArray['server']:$pgVersion=null; |
|---|
| 115 | if($pgVersion){ |
|---|
| 116 | $postgresRecommendedVersion = '8.0'; |
|---|
| 117 | $postgresRequiredVersion = '7.4'; |
|---|
| 118 | $html .= "<tr><td>PostgreSQL</td>"; |
|---|
| 119 | if (version_compare($pgVersion, $postgresRecommendedVersion, ">=")) { |
|---|
| 120 | $html .= "$okMsg<td>$pgVersion</td>"; // Version 5.0.0 or later |
|---|
| 121 | } |
|---|
| 122 | else if (version_compare($pgVersion, $postgresRequiredVersion, ">=")) { |
|---|
| 123 | $html .= "$warningMsg<td>".sprintf(_("%s may work, but version %s is recommended"), $pgVersion, $postgresRecommendedVersion)."</td>"; // Version < 5.0.0 |
|---|
| 124 | } |
|---|
| 125 | else { |
|---|
| 126 | $html .= "$errorMsg<td>".sprintf(_("%s is too old, version %s needed"),$pgVersion, $postgresRecommendedVersion)."</td>"; // Version < 5.0.0 |
|---|
| 127 | $userData['error'] = 1; |
|---|
| 128 | } |
|---|
| 129 | } |
|---|
| 130 | $html .= "</tr>"; |
|---|
| 131 | $html .= "</table>"; |
|---|
| 132 | |
|---|
| 133 | $components = Dependency::getDependency(); |
|---|
| 134 | $html .= "<table BORDER=\"1\">\n"; |
|---|
| 135 | $html .= "<tr><th>"._("Component").'<br/>'._("Click for the component's website")."</th>\n"; |
|---|
| 136 | $html .= "<th>"._("Type")."</th>\n"; |
|---|
| 137 | $html .= "<th>"._("Status")."</th>\n"; |
|---|
| 138 | $html .= "<th>"._("Description")."</th>\n"; |
|---|
| 139 | $html .= "<th>"._("Message")."</th>\n"; |
|---|
| 140 | $html .= "</tr>\n"; |
|---|
| 141 | |
|---|
| 142 | foreach ($components as $dependency) { |
|---|
| 143 | $html .= "<tr>\n"; |
|---|
| 144 | $websiteUrl = $dependency->getWebsiteURL(); |
|---|
| 145 | $component_key = $dependency->getId(); |
|---|
| 146 | $description = $dependency->getDescription(); |
|---|
| 147 | $mandatory = $dependency->isMandatory(); |
|---|
| 148 | $type = $dependency->getType(); |
|---|
| 149 | if($websiteUrl){ |
|---|
| 150 | $html .= "<td><A HREF=\"$websiteUrl\">$component_key</A></td>\n"; |
|---|
| 151 | } |
|---|
| 152 | else{ |
|---|
| 153 | $html .= "<td>$component_key</td>\n"; |
|---|
| 154 | } |
|---|
| 155 | $html .= "<td>$type</td>\n"; |
|---|
| 156 | $available = Dependency::check($component_key, $message); |
|---|
| 157 | if ($available) { |
|---|
| 158 | $html .= "$okMsg<td>$description</td><td> </td></tr>\n"; |
|---|
| 159 | } |
|---|
| 160 | else { |
|---|
| 161 | if ($mandatory) { |
|---|
| 162 | $html .= "$errorMsg<td>$description</td><td>$message</td></tr>\n"; |
|---|
| 163 | $error = 1; |
|---|
| 164 | } |
|---|
| 165 | else { |
|---|
| 166 | $html .= "$warningMsg<td>$description</td><td>$message</td></tr>\n"; |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | } |
|---|
| 170 | $html .= "</table>\n"; |
|---|
| 171 | |
|---|
| 172 | return $html; |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | /** Process admin interface of this object. |
|---|
| 176 | */ |
|---|
| 177 | public function processAdminUI() { |
|---|
| 178 | return null; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | /** Menu hook function */ |
|---|
| 182 | static public function hookMenu() { |
|---|
| 183 | $items = array(); |
|---|
| 184 | $server = Server::getServer(); |
|---|
| 185 | if(Security::hasPermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), $server)) |
|---|
| 186 | { |
|---|
| 187 | $items[] = array('path' => 'server/dependencies', |
|---|
| 188 | 'title' => _("Dependencies"), |
|---|
| 189 | 'url' => BASE_URL_PATH."admin/generic_object_admin.php?object_class=DependenciesList&action=edit&object_id=DUMMY" |
|---|
| 190 | ); |
|---|
| 191 | } |
|---|
| 192 | return $items; |
|---|
| 193 | } |
|---|
| 194 | }//End class |
|---|
| 195 | |
|---|
| 196 | /* |
|---|
| 197 | * Local variables: |
|---|
| 198 | * tab-width: 4 |
|---|
| 199 | * c-basic-offset: 4 |
|---|
| 200 | * c-hanging-comment-ender-p: nil |
|---|
| 201 | * End: |
|---|
| 202 | */ |
|---|