include_once WB_PATH . '/framework/module.functions.php'; // 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'; // obtain module directory $mod_dir = basename(dirname(__FILE__)); require WB_PATH . '/modules/' . $mod_dir . '/info.php'; // include module.functions.php include_once WB_PATH . '/framework/module.functions.php'; // load outputfilter-functions require_once dirname(__FILE__) . "/functions.php"; opf_io_mkdir(__OPF_UPLOAD_DIRNAME); opf_io_mkdir(WB_PATH . MEDIA_DIRECTORY . '/opf_plugins'); opf_io_unlink($mod_dir . '/debug_config.php'); opf_io_unlink($mod_dir . '/config_init.php'); opf_io_unlink($mod_dir . '/precheck.php'); if (file_exists(WB_PATH . '/modules/practical_module_functions/pmf.php')) { // load Practical Module Functions include_once WB_PATH . '/modules/practical_module_functions/pmf.php'; $opf = pmf_init(0, basename(dirname(__FILE__))); // unregister this module since we do not use pmf anymore pmf_mod_unregister($opf, basename(dirname(__FILE__))); } opf_db_run_query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_outputfilter_dashboard_settings`"); opf_io_rmdir(dirname(__FILE__) . '/naturaldocs_txt'); // install or upgrade example plugins $install_file = '/plugin_install.php'; $info_file = 'plugin_info.php';
} // Check version if (file_exists($install_dir . $plugin_directory)) { $old_version = opf_plugin_info_read($install_dir . $plugin_directory . '/' . $info_file, 'plugin_version'); $new_version = opf_plugin_info_read($temp_unzip . $info_file, 'plugin_version'); 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)) {
$filter = str_replace(WB_URL, '{SYSVAR:WB_URL}', $filter); if ($filter['plugin'] == '' && $filter['userfunc'] == 0) { $export_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_NO_EXPORT']); return FALSE; } if ($filter['plugin'] != '' && !file_exists($plugin_dir . $filter['plugin'])) { $export_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_NO_SUCH_DIR']); return FALSE; } // get name for zip-archive if ($filter['plugin'] != '') { $temp_file = 'opf_export_' . $filter['plugin'] . '.zip'; } else { $temp_file = 'opf_export_' . $temp_name . '.zip'; } opf_io_mkdir($temp_dir . $temp_name); // Setup PclZip $archive = new PclZip($temp_dir . $temp_file); // plugin-filter if ($filter['plugin'] != '') { // get human readable dump $filter_dump = opf_dump_var($filter); // get filter-data serialised $filter_ser = serialize($filter); $filter_ser = opf_escape_string($filter_ser); $file_install = <<<EOD <?php if(!defined('WB_PATH')) die(header('Location: index.php')); // experimental feature, export human-readable: opf_register_filter({$filter_dump}) // if this fails to import, try the serialized version:
function opf_upload_check($field, $fileext = array('.jpg', '.png', '.gif'), $type = 'image', $maxsize = 0) { global $LANG; if (!is_array($fileext)) { $fileext = explode(',', $fileext); } // check for error if (!isset($_FILES[$field]) || empty($_FILES[$field]['tmp_name'])) { return array('status' => FALSE, 'result' => $LANG['MOD_OPF']['TXT_ERR_NO_UPLOAD']); } if ($_FILES[$field]['error'] || !is_uploaded_file($_FILES[$field]['tmp_name'])) { return array('status' => FALSE, 'result' => sprintf($LANG['MOD_OPF']['TXT_ERR_PHP_ERR'], $_FILES[$field]['error'])); } // get cleaned filename $filename = opf_clean_filename($_FILES[$field]['name']); // check user-supplied args if ($maxsize > 0 && $_FILES[$field]['size'] > $maxsize) { return array('status' => FALSE, 'result' => sprintf($LANG['MOD_OPF']['TXT_ERR_UPLOAD_SIZE'], $maxsize)); } if (!empty($fileext)) { $ext = ''; if (!is_array($fileext)) { $fileext = array($fileext); } preg_match('~\\.\\w+$~D', $filename, $match); if (isset($match[0])) { $ext = strtolower($match[0]); } if (!in_array($ext, $fileext)) { return array('status' => FALSE, 'result' => sprintf($LANG['MOD_OPF']['TXT_ERR_UPLOAD_EXT'], $fileext)); } } if ($type && is_string($type)) { if (function_exists('__opf_upload_check_' . $type)) { $filter = '__opf_upload_check_' . $type; } elseif (function_exists('opf_upload_usercheck_' . $type)) { $filter = 'opf_upload_usercheck_' . $type; } else { die(sprintf($LANG['MOD_OPF']['TXT_ERR_SECURITY_BREACH'], 'opf_upload_check')); } $res = $filter($_FILES[$field]); if (!$res) { return array('status' => FALSE, 'result' => sprintf($LANG['MOD_OPF']['TXT_ERR_UPLOAD_TYPE'], $type)); } } else { die(sprintf($LANG['MOD_OPF']['TXT_ERR_SECURITY_BREACH'], 'opf_upload_check')); } // store info in DB and move file $section_id = 0; $id = uniqid(mt_rand(100000000, 999999999), TRUE); opf_io_mkdir(__OPF_UPLOAD_DIRNAME); $dest = __OPF_UPLOAD_DIRNAME . $id; if (move_uploaded_file($_FILES[$field]['tmp_name'], $dest)) { return array('status' => TRUE, 'result' => $id); } return array('status' => FALSE, 'result' => $LANG['MOD_OPF']['TXT_ERR_UPLOAD_FAILED']); }
} if ($filter['plugin'] != '') { $filter_file = $filter['file']; $filter_file = str_replace('{OPF:PLUGIN_PATH}', OPF_PLUGINS_PATH . $filter['plugin'], $filter_file); $filter_file = str_replace('{SYSVAR:WB_PATH}', WB_PATH, $filter_file); if (file_exists($filter_file)) { $filter['func'] = file_get_contents($filter_file); $filter['file'] = ''; rm_full_dir($plugin_dir . $filter['plugin']); $filter['plugin'] = ''; } else { $convert_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_NO_SUCH_DIR']); return FALSE; } } else { if (file_exists($plugin_dir . $plugin_name) || !opf_io_mkdir($plugin_dir . $plugin_name) || !is_writable($plugin_dir . $plugin_name)) { $convert_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_WRITE_DENIED'], $plugin_dir . $plugin_name); return FALSE; } // create a plugin-filter $filter['plugin'] = $plugin_name; // get human readable dump $filter_func = $filter['func']; $filter['func'] = ''; $filter['file'] = '{OPF:PLUGIN_PATH}/filter.php'; $filter_dump = opf_dump_var($filter); // get filter-data serialised $filter_ser = serialize($filter); $filter_ser = opf_escape_string($filter_ser); $file_info = <<<EOD <?php