本文整理汇总了PHP中load_plugin函数的典型用法代码示例。如果您正苦于以下问题:PHP load_plugin函数的具体用法?PHP load_plugin怎么用?PHP load_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_plugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_plugins
function validate_plugins($configuration)
{
// For each plugin listed in the config.json, we get it's name, and validate then load the shit outta him.
foreach ($configuration as $key => $value) {
$plugin_name = $key;
if ($value == 1) {
error_log("[32m[1m[ ✔️ ][0m The plugin : " . $plugin_name . " is activated !", 0);
$valid_plugin_config = 0;
if (!file_exists("plugins/" . $plugin_name . "/" . $plugin_name . ".json")) {
error_log("[31m[1m[ ❌ ][0m Unable to find the config file for : " . $plugin_name . " ! Is it there ?");
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has not been loaded because of a missing " . $plugin_name . ".json file.");
continue;
} else {
// Read it's plugin_name.json settings file
$plugin_config_file = fopen("plugins/" . $plugin_name . "/" . $plugin_name . ".json", "r");
$plugin_configuration = json_decode(fread($plugin_config_file, filesize("plugins/" . $plugin_name . "/" . $plugin_name . ".json")), true);
fclose($plugin_config_file);
}
// We make sure that every field in the plugin config is valid.
foreach ($plugin_configuration as $plugin_config_name => $plugin_config_value) {
// Check for the presence of : name, version, license, author, description, settings.
if ($plugin_config_name == "name" || $plugin_config_name == "version" || $plugin_config_name == "license" || $plugin_config_name == "author" || $plugin_config_name == "description" || $plugin_config_name == "settings") {
$valid_plugin_config = $valid_plugin_config + 1;
}
}
if ($valid_plugin_config == 6) {
// check if name is a string and the name of the plugin in the config.json file && check if the version is a number and > 0.
if (is_string($plugin_configuration["name"]) && is_numeric($plugin_configuration["version"]) && $plugin_configuration["version"] > 0) {
// Check if the license, author and description are strings.
if (is_string($plugin_configuration["license"]) && is_string($plugin_configuration["author"]) && is_string($plugin_configuration["description"])) {
// Check if the settings is an array
if (is_array($plugin_configuration["settings"])) {
// check if settings[height] is an int, settings[width] is an int, settings[auto-update] is a boolean
if (is_int($plugin_configuration["settings"]["height"]) && is_int($plugin_configuration["settings"]["width"]) && $plugin_configuration["settings"]["width"] <= 12 && is_bool($plugin_configuration["settings"]["auto-update"])) {
error_log("[32m[1m[ ✔️ ][0m The plugin : " . $plugin_name . " has been loaded and is ready for use.", 0);
// error_log("\n> [".$plugin_configuration['name']."]\n [Version] > ".$plugin_configuration['version']."\n [Author] > ".$plugin_configuration['author']."\n [Description] > ".$plugin_configuration['description']);
// When we made sure that the plugin config file is okay, we load it and render it.
load_plugin($plugin_name, $plugin_configuration["settings"]["width"], $plugin_configuration["name"]);
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has an invalid config file : the height, width should be ints, and auto-update a boolean", 0);
}
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has an invalid config file : settings should contain the height, width and auto-update value.", 0);
}
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has an invalid config file : the license, author and description should be a string.", 0);
}
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has an invalid config file : the name should be a string, the version a number.", 0);
}
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " has an invalid config file: it should be made like the core plugin.", 0);
}
} else {
error_log("[31m[1m[ ❌ ][0m The plugin : " . $plugin_name . " is not activated ! Skipping...", 0);
}
}
}
示例2: serialize
/**
* Serialize a data array as a text string of XML data
*
* @param Array $data the array of data to be serialized
* @param Array $options an array of options overrides (optional)
* @return String the data serialized as a text string of XML data
*/
public static function serialize($data, $options = array())
{
load_plugin('XML/Serializer');
$options = array_merge(self::$defaults, $options);
$serializer = new XML_Serializer($options);
$status = $serializer->serialize($data);
if (PEAR::isError($status)) {
throw new Exception($status->getMessage());
}
return $serializer->getSerializedData();
}
示例3: get_html
function get_html($array)
{
if (!array_key_exists($array["input"], $this->InputType())) {
return false;
}
$varname = "_" . strtoupper($array["input"]);
//判断是否有插件替换
$plugin = load_plugin("phpok_input_lib:" . $varname, $array, true);
if ($plugin) {
return $plugin;
}
return $this->{$varname}($array);
}
示例4: install_plugin
/**
* @brief installs an addon.
*
* @param string $plugin name of the addon
* @return bool
*/
function install_plugin($plugin)
{
if (!file_exists('addon/' . $plugin . '/' . $plugin . '.php')) {
return false;
}
logger("Addons: installing " . $plugin);
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
@(include_once 'addon/' . $plugin . '/' . $plugin . '.php');
if (function_exists($plugin . '_install')) {
$func = $plugin . '_install';
$func();
}
$plugin_admin = function_exists($plugin . '_plugin_admin') ? 1 : 0;
q("INSERT INTO `addon` (`aname`, `installed`, `tstamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", dbesc($plugin), intval($t), $plugin_admin);
load_plugin($plugin);
}
示例5: ok_f
function ok_f()
{
load_plugin("login:ok:prev");
//在执行登录前运行相关插件
if (!$this->sys_config["login_status"]) {
$message = $this->sys_config["close_login"] ? $this->sys_config["close_login"] : "Not Login!";
error($message, $this->url());
}
$username = $this->trans_lib->safe("username");
$password = $this->trans_lib->safe("password");
$login_url = site_url("login", "", false);
//账号和密码为空时警告
if (!$username || !$password) {
error($this->lang["login_false_empty"], $login_url);
}
//检查会员不存在时的警告
$rs = $this->user_m->user_from_name($username);
if (!$rs) {
error($this->lang["login_false_rs"], $login_url);
}
//密码检测
$password = sys_md5($password);
if ($rs["pass"] != $password) {
error($this->lang["login_false_password"], $login_url);
}
//检查会员状态的警告
if (!$rs["status"]) {
error($this->lang["login_false_check"], $login_url);
}
//检查会员是否被锁定
if ($rs["status"] == 2) {
error($this->lang["login_false_lock"], $login_url);
}
//将数据存到session中
$_SESSION["user_id"] = $rs["id"];
$_SESSION["user_name"] = $rs["name"];
$_SESSION["group_id"] = $rs["groupid"];
$_SESSION["user_rs"] = $rs;
$_SESSION[SYS_CHECKED_SESSION_ID] = sys_md5($rs);
//执行插件
load_plugin("login:ok:next", $rs);
//error($this->lang["login_usccess"].$ext,site_url("index"));
echo "<script language=javascript>\nwindow.alert('登录成功!');\nwindow.location.href='cs-putong.html';\n</script>";
}
示例6: load_plugins
/**
* Loads all the registered plugins.
*/
function load_plugins()
{
global $conf, $pwg_loaded_plugins;
$pwg_loaded_plugins = array();
if ($conf['enable_plugins']) {
$plugins = get_db_plugins('active');
foreach ($plugins as $plugin) {
// include main from a function to avoid using same function context
load_plugin($plugin);
}
trigger_notify('plugins_loaded');
}
}
示例7: ajax_del_f
function ajax_del_f()
{
$id = $this->trans_lib->int("id");
if (!$id) {
exit("error:没有指定ID");
}
sys_popedom("user:delete", "ajax");
load_plugin("user:del:prev");
$this->user_m->del($id);
load_plugin("user:del:next");
exit("ok");
}
示例8: p
p(event-summary). Allows a plugin to insert additional html in the rendered html form tag.
h3(event). mem_form.submit
p(event-summary). Allows a plugin to act upon a successful form submission.
h3(event). mem_form.spam
p(event-summary). Allows a plugin to test a submission as spam. The function get_mem_form_evaluator() returns the evaluator.
# --- END PLUGIN HELP ---
<?php
}
# --- BEGIN PLUGIN CODE ---
$mem_glz_custom_fields_plugin = load_plugin('glz_custom_fields');
// needed for MLP
define('MEM_FORM_PREFIX', 'mem_form');
global $mem_form_lang;
if (!is_array($mem_form_lang)) {
$mem_form_lang = array('error_file_extension' => 'File upload failed for field {label}.', 'error_file_failed' => 'Failed to upload file for field {label}.', 'error_file_size' => 'Failed to upload File for field {label}. File is to large.', 'field_missing' => 'The field {label} is required.', 'form_expired' => 'The form has expired.', 'form_misconfigured' => 'The mem_form is misconfigured. You must specify the "form" attribute.', 'form_sorry' => 'The form is currently unavailable.', 'form_used' => 'This form has already been used to submit.', 'general_inquiry' => '', 'invalid_email' => 'The email address {email} is invalid.', 'invalid_host' => 'The host {domain} is invalid.', 'invalid_utf8' => 'Invalid UTF8 string for field {label}.', 'invalid_value' => 'The value "{value}" is invalid for the input field {label}.', 'invalid_format' => 'The input field {label} must match the format "{example}".', 'max_warning' => 'The input field {label} must be smaller than {max} characters long.', 'min_warning' => 'The input field {label} must be at least {min} characters long.', 'refresh' => 'Refresh', 'spam' => 'Your submission was blocked by a spam filter.', 'submitted_thanks' => 'You have successfully submitted the form. Thank you.');
}
register_callback('mem_form_enumerate_strings', 'l10n.enumerate_strings');
function mem_form_enumerate_strings($event, $step = '', $pre = 0)
{
global $mem_form_lang;
$r = array('owner' => 'mem_form', 'prefix' => MEM_FORM_PREFIX, 'lang' => 'en-gb', 'event' => 'public', 'strings' => $mem_form_lang);
return $r;
}
function mem_form_gTxt($what, $args = array())
{
示例9: load_plugin
<?php
// Reset Module Title
$mod_title = "MySQL Test";
$data_source = 'test_mysql';
load_plugin('benchmark');
$cb = new code_benchmark();
$cb->start_timer();
include dirname(__FILE__) . '/../common/controller.php';
$cb->stop_timer();
$times = $cb->get_results();
$time_elapsed = round($times['stop'] - $times['start'], 5);
$gen_message[] = "Elapsed Time: {$time_elapsed} seconds";
示例10: ign_validate
function ign_validate($user, $password)
{
global $ign_user_db, $prefs;
$fallback = false;
$safe_user = addslashes($user);
$safe_pass = doSlash($password);
$sql = "name = '{$safe_user}' and pass = password(lower('{$safe_pass}')) ";
$r = safe_row("name, realname, privs, nonce, last_access, email", $ign_user_db, $sql);
if (!$r) {
$fallback = true;
$sql = "name = '{$safe_user}' and (pass = old_password(lower('{$safe_pass}')) or pass = old_password('{$safe_pass}')) ";
$r = safe_row("name, realname, privs, nonce, last_access, email", $ign_user_db, $sql);
if (!$r && $prefs['ign_use_custom'] == 1) {
$sql = "name = '{$safe_user}' and ( pass = password(lower('{$safe_pass}')) or pass = old_password(lower('{$safe_pass}')) or pass = old_password('{$safe_pass}') )";
$r = safe_row("name, realname, privs, nonce, last_access, email", 'txp_users', $sql);
}
}
if ($r) {
if ($fallback) {
safe_update($ign_user_db, "pass = password(lower('{$password}'))", "name='{$user}'");
}
// Create session & cookies for Vanilla forum
if (load_plugin("ddh_vanilla_integration")) {
ddh_vanilla_login($safe_user, $password);
}
ign_update_access($r);
return $r;
}
return false;
}
示例11: check_config
//.........这里部分代码省略.........
if ($build != DB_UPDATE_VERSION) {
$stored = intval($build);
if (!$stored) {
logger('Critical: check_config unable to determine database schema version');
return;
}
$current = intval(DB_UPDATE_VERSION);
if ($stored < $current && file_exists('install/update.php')) {
load_config('database');
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
require_once 'install/update.php';
// make sure that boot.php and update.php are the same release, we might be
// updating right this very second and the correct version of the update.php
// file may not be here yet. This can happen on a very busy site.
if (DB_UPDATE_VERSION == UPDATE_VERSION) {
for ($x = $stored; $x < $current; $x++) {
if (function_exists('update_r' . $x)) {
// There could be a lot of processes running or about to run.
// We want exactly one process to run the update command.
// So store the fact that we're taking responsibility
// after first checking to see if somebody else already has.
// If the update fails or times-out completely you may need to
// delete the config entry to try again.
if (get_config('database', 'update_r' . $x)) {
break;
}
set_config('database', 'update_r' . $x, '1');
// call the specific update
$func = 'update_r' . $x;
$retval = $func();
if ($retval) {
// Prevent sending hundreds of thousands of emails by creating
// a lockfile.
$lockfile = 'store/[data]/mailsent';
if (file_exists($lockfile) && filemtime($lockfile) > time() - 86400) {
return;
}
@unlink($lockfile);
//send the administrator an e-mail
file_put_contents($lockfile, $x);
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array('$sitename' => $a->config['system']['sitename'], '$siteurl' => $a->get_baseurl(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
$subject = email_header_encode(sprintf(t('Update Error at %s'), $a->get_baseurl()));
mail($a->config['system']['admin_email'], $subject, $email_msg, 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
//try the logger
logger('CRITICAL: Update Failed: ' . $x);
} else {
set_config('database', 'update_r' . $x, 'success');
}
}
}
set_config('system', 'db_version', DB_UPDATE_VERSION);
}
}
}
/**
*
* Synchronise plugins:
*
* $a->config['system']['addon'] contains a comma-separated list of names
* of plugins/addons which are used on this system.
* Go through the database list of already installed addons, and if we have
* an entry, but it isn't in the config list, call the unload procedure
* and mark it uninstalled in the database (for now we'll remove it).
* Then go through the config list and if we have a plugin that isn't installed,
* call the install procedure and add it to the database.
*
*/
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if ($r) {
$installed = $r;
} else {
$installed = array();
}
$plugins = get_config('system', 'addon');
$plugins_arr = array();
if ($plugins) {
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
}
$a->plugins = $plugins_arr;
$installed_arr = array();
if (count($installed)) {
foreach ($installed as $i) {
if (!in_array($i['name'], $plugins_arr)) {
unload_plugin($i['name']);
} else {
$installed_arr[] = $i['name'];
}
}
}
if (count($plugins_arr)) {
foreach ($plugins_arr as $p) {
if (!in_array($p, $installed_arr)) {
load_plugin($p);
}
}
}
load_hooks();
}
示例12: load
public static function load()
{
$plugins = PluginQuery::create()->filterByEnabled(true);
if (!defined('NO_SESSION')) {
$user_id = DatawrapperSession::getUser()->getId();
if (!empty($user_id)) {
$plugins->where('Plugin.Id IN (SELECT plugin_id FROM plugin_organization WHERE organization_id IN (SELECT organization_id FROM user_organization WHERE user_id = ?))', $user_id)->_or();
}
$plugins = $plugins->where('Plugin.IsPrivate = FALSE');
}
$plugins = $plugins->find();
$not_loaded_yet = array();
foreach ($plugins as $plugin) {
if (!isset(self::$loaded[$plugin->getId()])) {
$not_loaded_yet[] = $plugin;
}
}
$could_not_install = array();
if (!function_exists('load_plugin')) {
function load_plugin($plugin)
{
$plugin_path = ROOT_PATH . 'plugins/' . $plugin->getName() . '/plugin.php';
if (file_exists($plugin_path)) {
require $plugin_path;
// init plugin class
$className = $plugin->getClassName();
$pluginClass = new $className();
} else {
$pluginClass = new DatawrapperPlugin($plugin->getName());
}
// but before we load the libraries required by this lib
foreach ($pluginClass->getRequiredLibraries() as $lib) {
require_once ROOT_PATH . 'plugins/' . $plugin->getName() . '/' . $lib;
}
$pluginClass->init();
return $pluginClass;
}
}
while (count($not_loaded_yet) > 0) {
$try = $not_loaded_yet;
$not_loaded_yet = array();
while (count($try) > 0) {
$plugin = array_shift($try);
$id = $plugin->getId();
$deps = $plugin->getDependencies();
unset($deps['core']);
// ignore core dependency
$can_load = true;
if (is_array($deps)) {
foreach ($deps as $dep => $version) {
if (!isset(self::$loaded[$dep])) {
// dependency not loaded
$can_load = false;
if (!file_exists(ROOT_PATH . 'plugins/' . $dep) || isset($could_not_install[$dep])) {
// dependency does not exists, not good
$could_not_install[$id] = true;
}
break;
}
}
}
if (isset(self::$loaded[$id]) && self::$loaded[$id]) {
// plugin already loaded by now
continue;
}
if ($can_load) {
// load plugin
self::$loaded[$id] = true;
self::$instances[$id] = load_plugin($plugin);
} else {
if (!isset($could_not_install[$id])) {
$not_loaded_yet[] = $plugin;
// so try next time
}
}
}
}
}
示例13: before_filter
if ($m->omb) {
before_filter('authenticate_with_omb', $m->function);
}
if ($m->http) {
before_filter('authenticate_with_http', $m->function);
}
if ($m->oauth) {
before_filter('authenticate_with_oauth', $m->function);
}
}
/**
* load plugins
*/
if (isset($env)) {
while (list($key, $plugin) = each($env['plugins'])) {
load_plugin($plugin);
}
}
/**
* connect more Routes to the Mapper
*/
$request->connect(':resource/:id/email/:ident', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+', '[A-Za-z0-9]+')));
$request->connect(':resource/page/:page/:action', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+', '[A-Za-z0-9_.]+')));
$request->connect(':resource/page/:page', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+')));
$request->connect(':resource/:id/:action', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+', '[A-Za-z0-9_.]+')));
$request->connect(':resource/:id', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+')));
$request->connect(':resource/:action', array('requirements' => array('[A-Za-z0-9_.]+', '[A-Za-z0-9_.]+')));
$request->connect(':resource/:id/:action/partial', array('requirements' => array('[A-Za-z0-9_.]+', '[0-9]+', '[A-Za-z0-9_.]+')));
$request->connect(':resource/:action/partial', array('requirements' => array('[A-Za-z0-9_.]+', '[A-Za-z0-9_.]+')));
$request->connect(':resource', array('requirements' => array('[A-Za-z0-9_.]+')));
$request->connect('', array('resource' => $env['goes'], 'action' => 'get'));
示例14: load_plugin
<?php
load_plugin('Net/Browscap');
class UserAgent
{
const BROWSCAP_CACHE_DIR = 'app/tmp/browscap';
const MAX_USER_AGENTS_COUNT = 1000;
private static $browscap = NULL;
private static $user_agents = array();
public static function details($user_agent)
{
if (is_null(self::$browscap)) {
$cache_dir = self::BROWSCAP_CACHE_DIR;
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
self::$browscap = new Browscap($cache_dir);
}
// Reset the user agents cache if we've cached too many
if (count(self::$user_agents) > self::MAX_USER_AGENTS_COUNT) {
self::$user_agents = array();
}
// If user agent info is cached then return it
if ($details = array_key(self::$user_agents, $user_agent)) {
return $details;
}
// Look up the user agent using the browscap.ini file
$browscap = self::$browscap->getBrowser($user_agent, TRUE);
$browser = array_key($browscap, 'Browser');
// e.g. "IE"
$version = array_key($browscap, 'Parent');
示例15: load_plugin
* Include navigation
*/
include $config['template_path'] . "navigation.php";
/**
* Include admin navigation
*/
include $config['template_path'] . "admin/navigation.php";
/**
* Include posts
*/
include $config['template_path'] . "admin/posts.php";
} else {
if ($action == "plugins") {
if (isset($_GET['activate'])) {
// set to load
$result = load_plugin(urldecode($_GET['activate']));
// User data
if (is_string($result)) {
$error = lang($result);
}
if (!$error) {
// set as loaded
plugin_loaded($_GET['activate']);
// set as active
$success = lang('success_plugin_activate');
}
} else {
if (isset($_GET['deactivate'])) {
// unset the load
$result = unload_plugin(urldecode($_GET['deactivate']));
// User data