function lang_load($postfix = null) { global $fp_config; $pluginpath = ''; // checks if we already loaded this lang file $vals = explode('.', $postfix); // my.file.name ---> my, file, name $old_lang =& $GLOBALS['lang']; if (!$old_lang) { $old_lang = array(); } if ($postfix) { if (strpos($postfix, 'plugin:') === 0) { $pluginpath = substr($postfix, 7); } $file = "lang.{$postfix}.php"; } else { $postfix = 'default'; $file = "lang.default.php"; } $fpath = LANG_DIR . "{$fp_config['locale']['lang']}/{$file}"; $fallback = LANG_DIR . LANG_DEFAULT . "/{$file}"; $path = ''; $plugin = $pluginpath; if ($pluginpath) { if (($n = strpos($pluginpath, '/')) !== false) { $plugin = substr($plugin, 0, $n - 1); $path = substr($plugin, $n + 1); $path = str_replace('/', '.', $path); } $dir = plugin_getdir($plugin); $fpath = $dir . "lang/lang.{$fp_config['locale']['lang']}{$path}.php"; $fallback = $dir . "lang/lang." . LANG_DEFAULT . "{$path}.php"; } if (!file_exists($fpath)) { /* if file does not exist, we fall back on English */ if (!file_exists($fallback)) { trigger_error("No suitable language file was found <b>{$postfix}</b>", E_USER_WARNING); return; } $fpath = $fallback; } /* load $lang from file */ /* * utf encoded files may output whitespaces known as BOM, we must * capture this chars */ ob_start(); include_once $fpath; if (!isset($lang)) { return $GLOBALS['lang']; } ob_end_clean(); $GLOBALS['lang'] = array_merge_recursive($lang, $old_lang); return $GLOBALS['lang']; }
function admin_getpaneldir($id) { global $fpadminpanels; if (array_intersect($fpadminpanels, array(array($id, true)))) { // is plugin return ABS_PATH . plugin_getdir($id); } else { return ABS_PATH . ADMIN_DIR . $id; } }
function plugin_getinfo($plugin) { $plugin_data = io_load_file(plugin_getdir($plugin) . "plugin.{$plugin}.php"); preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name); preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri); preg_match("|Description:(.*)|i", $plugin_data, $description); preg_match("|Author:(.*)|i", $plugin_data, $author_name); preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri); if (preg_match("|Version:(.*)|i", $plugin_data, $version)) { $version = trim($version[1]); } else { $version = ''; } $description = wptexturize(trim($description[1])); $name = $plugin_name[1]; $name = trim($name); $plugin = $name; if ('' != $plugin_uri[1] && '' != $name) { // '" title="'.__('Visit plugin homepage').'">'. $plugin = '<a href="' . trim($plugin_uri[1]) . $plugin . '</a>'; } if ('' == $author_uri[1]) { $author = trim($author_name[1]); } else { // . '" title="'.__('Visit author homepage'). $author = '<a href="' . trim($author_uri[1]) . '">' . trim($author_name[1]) . '</a>'; } global $smarty; $smarty->assign(array('name' => $name, 'title' => $plugin, 'description' => $description, 'author' => $author, 'version' => $version, 'template' => $template[1])); }
<?php /* Plugin Name: BBCode Version: 1.5 Plugin URI: http://flatpress.sf.net Description: Allows using <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> markup; provides automatic integration with lightbox. Author: Hydra, NoWhereMan Author URI: http://flatpress.sf.net */ require plugin_getdir('bbcode') . '/inc/stringparser_bbcode.class.php'; require plugin_getdir('bbcode') . '/panels/admin.plugin.panel.bbcode.php'; /** * Setups the plugin. */ function plugin_bbcode_startup() { // defintions part // load options $bbconf = plugin_getoptions('bbcode'); // get defaults if not configured define('BBCODE_ALLOW_HTML', isset($bbconf['escape-html']) ? $bbconf['escape-html'] : true); define('BBCODE_ENABLE_COMMENTS', isset($bbconf['comments']) ? $bbconf['comments'] : false); define('BBCODE_USE_EDITOR', isset($bbconf['editor']) ? $bbconf['editor'] : true); define('BBCODE_URL_MAXLEN', isset($bbconf['url-maxlen']) ? $bbconf['url-maxlen'] : 40); if (!file_exists('getfile.php')) { define('BBCODE_USE_WRAPPER', false); } else { $funcs = explode(',', ini_get('disable_functions')); if (in_array('readfile', $funcs)) { define('BBCODE_USE_WRAPPER', false);
<?php /* Plugin Name: Akismet Version: 0.1 Plugin URI: http://flatpress.sf.net Description: Integration with Akismet powerful Antispam system! Author: NoWhereMan Author URI: http://flatpress.sf.net */ define('AKISMET_TIMEOUT', 10); require plugin_getdir('akismet') . '/inc/Akismet.class.php'; function plugin_akismet_setup() { global $fp_config; if (!plugin_getoptions('akismet', 'apikey')) { return -1; } return 1; } if (plugin_getoptions('akismet', 'apikey')) { add_filter('comment_validate', 'plugin_akismet_validate', 10, 2); } function plugin_akismet_validate($bool, $contents) { if (!$bool) { return false; } global $fp_config; $akismet = new Akismet($fp_config['general']['www'], plugin_getoptions('akismet', 'apikey')); $akismet->setAuthor($contents['name']);