| 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 |
| | 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 | /** |
| | 52 | * This class checks the existence of components required by WiFiDog. |
| | 53 | * Note that it implicitely depends on the defines in include/path_defines_base.php |
| | 54 | * |
| | 55 | * @package WiFiDogAuthServer |
| | 56 | * @author Philippe April |
| | 57 | * @author Max Horváth <max.horvath@freenet.de> |
| | 58 | * @author Benoit Grégoire <bock@step.polymtl.ca> |
| | 59 | * @copyright 2005-2007 Philippe April |
| | 60 | * @copyright 2005-2007 Max Horváth, Horvath Web Consulting |
| | 61 | * @copyright 2006-2007 Benoit Grégoire, Technologies Coeus inc. |
| | 62 | */ |
| | 63 | |
| | 64 | /** |
| | 65 | * Load required classes |
| | 66 | */ |
| | 67 | /*WARNING: You must NOT require anything, or extend anything except Dependency.php. DependenciesList is used from the install script.*/ |
| | 68 | require_once ('classes/Dependency.php'); |
| | 69 | require_once ('classes/GenericDataObject.php'); |
| | 70 | |
| | 71 | class DependenciesList extends GenericDataObject |
| | 72 | { |
| | 73 | public static function &getObject($id) |
| | 74 | { |
| | 75 | $retval = new self(); |
| | 76 | return $retval; |
| | 77 | } |
| | 78 | /** Retreives the admin interface of this object. |
| | 79 | * @return The HTML fragment for this interface, or null. |
| | 80 | * If it returns null, this object does not support new object creation */ |
| | 81 | public function getAdminUI($userData = null) { |
| | 82 | return self::getAdminUIStatic($userData); |
| | 83 | } |
| | 84 | /** Retreives the admin interface of this object. |
| | 85 | * @return The HTML fragment for this interface, or null. |
| | 86 | * If it returns null, this object does not support new object creation */ |
| | 87 | static public function getAdminUIStatic($userData = null) { |
| | 88 | |
| | 89 | $html = ''; |
| | 90 | /* PHP version check */ |
| | 91 | $okMsg = '<td ALIGN="CENTER" STYLE="background:lime;">OK</td>'; |
| | 92 | $errorMsg = '<td ALIGN="CENTER" STYLE="background:red;">ERROR</td>'; |
| | 93 | $warningMsg = '<td ALIGN="CENTER" STYLE="background:yellow;">Warning</td>'; |
| | 94 | |
| | 95 | $html .= "<table BORDER=\"1\">"; |
| | 96 | |
| | 97 | /* PHP version check */ |
| | 98 | $requiredPHPVersion = '5.0'; |
| | 99 | $phpVersion = phpversion(); |
| | 100 | $html .= "<tr><td>PHP</td>"; |
| | 101 | if (version_compare($phpVersion, $requiredPHPVersion, ">=")) { |
| | 102 | $html .= "$okMsg<td>$phpVersion</td>"; // Version 5.0.0 or later |
| | 103 | } |
| | 104 | else { |
| | 105 | $html .= "$errorMsg<td>".sprintf(_("Version %s needed"), $requiredPHPVersion)."</td>"; // Version < 5.0.0 |
| | 106 | $userData['error'] = 1; |
| | 107 | } |
| | 108 | $html .= "</tr>"; |
| | 109 | |
| | 110 | if(function_exists('pg_version')){ |
| | 111 | //Be carefull, postgres version check will also fail if there wasn't a db connexion yet. |
| | 112 | $pgVersionArray = @pg_version(); |
| | 113 | $pgVersionArray?$pgVersion=$pgVersionArray['server']:$pgVersion=null; |
| | 114 | if($pgVersion){ |
| | 115 | $postgresRecommendedVersion = '8.0'; |
| | 116 | $postgresRequiredVersion = '7.4'; |
| | 117 | $html .= "<tr><td>PostgreSQL</td>"; |
| | 118 | if (version_compare($pgVersion, $postgresRecommendedVersion, ">=")) { |
| | 119 | $html .= "$okMsg<td>$pgVersion</td>"; // Version 5.0.0 or later |
| | 120 | } |
| | 121 | else if (version_compare($pgVersion, $postgresRequiredVersion, ">=")) { |
| | 122 | $html .= "$warningMsg<td>".sprintf(_("%s may work, but version %s is recommended"), $pgVersion, $postgresRecommendedVersion)."</td>"; // Version < 5.0.0 |
| | 123 | } |
| | 124 | else { |
| | 125 | $html .= "$errorMsg<td>".sprintf(_("%s is too old, version %s needed"),$pgVersion, $postgresRecommendedVersion)."</td>"; // Version < 5.0.0 |
| | 126 | $userData['error'] = 1; |
| | 127 | } |
| | 128 | $html .= "</tr>"; |
| | 129 | } |
| | 130 | } |
| | 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; |
| 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 | | */ |
| | 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 | */ |