+
+
+ // load plugin functions
+ include_once(SM_PATH . 'functions/plugin.php');
+
+ // turn on output buffering in order to prevent output of new lines
+ ob_start();
+ foreach ($plugins as $name) {
+ use_plugin($name);
+
+ // get output and remove whitespace
+ $output = trim(ob_get_contents());
+
+ // if plugin outputs more than newlines and spacing, stop script execution.
+ if (!empty($output)) {
+ $plugin_load_error = 'Some output was produced when plugin <i>' . $name . '</i> was loaded. Usually this means there is an error in the plugin\'s setup or configuration file. The output was: '.htmlspecialchars($output);
+ do_err($plugin_load_error);
+ }
+ }
+ ob_end_clean();
+
+
+ /**
+ * Check the contents of the static plugin hooks array file against
+ * the plugin setup file, which may have changed in an upgrade, etc.
+ * This helps remind admins to re-run the configuration utility when
+ * a plugin has been changed or upgraded.
+ */
+ $static_squirrelmail_plugin_hooks = $squirrelmail_plugin_hooks;
+ $squirrelmail_plugin_hooks = array();
+ foreach ($plugins as $name) {
+ $function = "squirrelmail_plugin_init_$name";
+ if (function_exists($function)) {
+ $function();
+
+ // now iterate through each hook and make sure the
+ // plugin is registered on the correct ones in the
+ // static plugin configuration file
+ //
+ foreach ($squirrelmail_plugin_hooks as $hook_name => $hooked_plugins)
+ foreach ($hooked_plugins as $hooked_plugin => $hooked_function)
+ if ($hooked_plugin == $name
+ && (empty($static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin])
+ || $static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin] != $hooked_function))
+ do_err('The plugin <i>' . $name . '</i> is supposed to be registered on the <i>' . $hook_name . '</i> hook, but it is not. You need to re-run the configuration utility and re-save your configuration file.', FALSE);
+ }
+ }
+ $squirrelmail_plugin_hooks = $static_squirrelmail_plugin_hooks;
+
+
+ /**
+ * Print plugin versions
+ */
+ echo $IND . "Plugin versions...<br />\n";
+ foreach ($plugins as $name) {
+ $plugin_version = get_plugin_version($name);
+ $english_name = get_plugin_requirement($name, 'english_name');
+ echo $IND . $IND . (empty($english_name) ? $name . ' ' : $english_name . ' (' . $name . ') ') . (empty($plugin_version) ? '??' : $plugin_version) . "<br />\n";
+
+ // check if this plugin has any other plugin
+ // dependencies and if they are satisfied
+ //
+ $failed_dependencies = check_plugin_dependencies($name);
+ if ($failed_dependencies === SQ_INCOMPATIBLE) {
+ do_err($name . ' is NOT COMPATIBLE with this version of SquirrelMail', FALSE);
+ }
+ else if (is_array($failed_dependencies)) {
+ $missing_plugins = '';
+ $incompatible_plugins = '';
+ foreach ($failed_dependencies as $depend_name => $depend_requirements) {
+ if ($depend_requirements['version'] == SQ_INCOMPATIBLE)
+ $incompatible_plugins .= ', ' . $depend_name;
+ else
+ $missing_plugins .= ', ' . $depend_name . ' (version ' . $depend_requirements['version'] . ', ' . ($depend_requirements['activate'] ? 'must be activated' : 'need not be activated') . ')';
+ }
+ $error_string = (!empty($incompatible_plugins) ? $name . ' cannot be activated at the same time as the following plugins: ' . trim($incompatible_plugins, ', ') : '')
+ . (!empty($missing_plugins) ? (!empty($incompatible_plugins) ? '. ' . $name . ' is also ' : $name . ' is ') . 'missing some dependencies: ' . trim($missing_plugins, ', ') : '');
+ do_err($error_string, FALSE);
+ }
+
+ }
+
+
+ /**
+ * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
+ * message and return TRUE if there are any errors in its setup/configuration.
+ */
+ $plugin_err = boolean_hook_function('configtest', $null, 1);
+ if($plugin_err) {
+ do_err('Some plugin tests failed.');
+ } else {
+ echo $IND . "Plugins OK.<br />\n";
+ }