// include the module language file depending on the backend language of the current user if (!(include get_module_language_file($mod_dir))) { return; } // load outputfilter-functions require_once dirname(__FILE__) . '/functions.php'; // create media-dir opf_io_mkdir(WB_PATH . MEDIA_DIRECTORY . '/opf_plugins'); opf_db_run_query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_outputfilter_dashboard`"); opf_db_run_query("CREATE TABLE `" . TABLE_PREFIX . "mod_outputfilter_dashboard` (\n `id` INT NOT NULL AUTO_INCREMENT,\n `userfunc` TINYINT NOT NULL DEFAULT '0',\n `position` INT NOT NULL DEFAULT '0',\n `active` TINYINT NOT NULL DEFAULT '1',\n `allowedit` TINYINT NOT NULL DEFAULT '0',\n `allowedittarget` TINYINT NOT NULL DEFAULT '0',\n `name` VARCHAR(249) NOT NULL,\n `func` TEXT NOT NULL,\n `type` VARCHAR(255) NOT NULL,\n `file` VARCHAR(255) NOT NULL,\n `csspath` VARCHAR(255) NOT NULL,\n `funcname` VARCHAR(255) NOT NULL,\n `configurl` VARCHAR( 255 ) NOT NULL,\n `plugin` VARCHAR( 255 ) NOT NULL,\n `helppath` TEXT NOT NULL,\n `modules` TEXT NOT NULL,\n `desc` LONGTEXT NOT NULL,\n `pages` TEXT NOT NULL,\n `pages_parent` TEXT NOT NULL,\n `additional_values` LONGTEXT NOT NULL,\n `additional_fields` TEXT NOT NULL,\n `additional_fields_languages` TEXT NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE (`name`),\n INDEX (`type`)\n) ENGINE = MYISAM"); opf_io_rmdir(dirname(__FILE__) . '/naturaldocs_txt'); // install example plugins $install_file = '/plugin_install.php'; $info_file = 'plugin_info.php'; $install_dir = dirname(__FILE__) . '/plugins/'; $plugins = array('cachecontrol', 'correct_date_format'); foreach ($plugins as $plugin_dir) { // run install-script if (file_exists($install_dir . $plugin_dir . $install_file)) { require $install_dir . $plugin_dir . $install_file; } } // run install scripts of already present module filters foreach (preg_grep('/\\/install.php/', opf_io_filelist(WB_PATH . '/modules')) as $installer) { if (strpos($installer, 'outputfilter_dashboard') === FALSE) { $contents = file_get_contents($installer); if (preg_match('/opf_register_filter/', $contents)) { require $installer; } } }
if (version_compare($old_version, $new_version, '>')) { $upload_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_ALREADY_INSTALLED']); opf_io_rmdir($temp_unzip); @unlink($temp_dir . $temp_file); return; } } // Cleanup temp opf_io_rmdir($temp_unzip); $plugin_dir = $install_dir . $plugin_directory . '/'; opf_io_mkdir($plugin_dir); // unzip plugin directly to $plugin_dir $list = $archive->extract(PCLZIP_OPT_PATH, $plugin_dir); if (!$list) { $upload_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_UNZIP_FAILED']); @unlink($temp_dir . $temp_file); return; } // delete archive @unlink($temp_dir . $temp_file); // chmod new files foreach (opf_io_filelist($plugin_dir) as $file) { opf_io_chmod($file); } // run install-script if (file_exists($plugin_dir . $install_file)) { require $plugin_dir . $install_file; } $upload_message = $LANG['MOD_OPF']['TXT_PLUGIN_UPLOAD_SUCCESS']; $upload_ok = TRUE; return;
function opf_io_filelist($dir, $depth = OPF_FILELIST_DEPTH, $dirs = OPF_FILELIST_NODIRS, $files = array()) { if (!is_dir($dir)) { return $files; } $dir = rtrim($dir, '/'); $dh = opendir($dir); while ($file = readdir($dh)) { if ($file == '.' || $file == '..') { continue; } if (is_dir($dir . '/' . $file)) { if ($dirs) { $files[] = $dir . '/' . $file . '/'; } if ($depth) { $files = opf_io_filelist($dir . '/' . $file, $depth, $dirs, $files); } } else { $files[] = $dir . '/' . $file; } } closedir($dh); return $files; }