Example #1
0
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("[ ✔️ ] The plugin : " . $plugin_name . " is activated !", 0);
            $valid_plugin_config = 0;
            if (!file_exists("plugins/" . $plugin_name . "/" . $plugin_name . ".json")) {
                error_log("[ ❌ ] Unable to find the config file for : " . $plugin_name . " ! Is it there ?");
                error_log("[ ❌ ] 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("[ ✔️ ] 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("[ ❌ ] The plugin : " . $plugin_name . " has an invalid config file : the height, width should be ints, and auto-update a boolean", 0);
                            }
                        } else {
                            error_log("[ ❌ ] The plugin : " . $plugin_name . " has an invalid config file : settings should contain the height, width and auto-update value.", 0);
                        }
                    } else {
                        error_log("[ ❌ ] The plugin : " . $plugin_name . " has an invalid config file : the license, author and description should be a string.", 0);
                    }
                } else {
                    error_log("[ ❌ ] The plugin : " . $plugin_name . " has an invalid config file : the name should be a string, the version a number.", 0);
                }
            } else {
                error_log("[ ❌ ] The plugin : " . $plugin_name . " has an invalid config file: it should be made like the core plugin.", 0);
            }
        } else {
            error_log("[ ❌ ] The plugin : " . $plugin_name . " is not activated ! Skipping...", 0);
        }
    }
}
Example #2
0
 /**
  * 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();
 }
Example #3
0
 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);
 }
Example #4
0
/**
 * @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);
}
Example #5
0
 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"] : "******";
         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>";
 }
/**
 * 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');
    }
}
Example #7
0
 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");
 }
Example #8
0
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())
{
Example #9
0
<?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";
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;
}
Example #11
0
function check_config(&$a)
{
    $build = get_config('system', 'db_version');
    if (!intval($build)) {
        $build = set_config('system', 'db_version', DB_UPDATE_VERSION);
    }
    $saved = get_config('system', 'urlverify');
    if (!$saved) {
        set_config('system', 'urlverify', bin2hex(z_root()));
    }
    if ($saved && $saved != bin2hex(z_root())) {
        // our URL changed. Do something.
        $oldurl = hex2bin($saved);
        logger('Baseurl changed!');
        $oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
        $host = substr(z_root(), strpos(z_root(), '//') + 2);
        $is_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) ? true : false;
        $was_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $oldhost) ? true : false;
        // only change the url to an ip address if it was already an ip and not a dns name
        if (!$is_ip_addr || $is_ip_addr && $was_ip_addr) {
            fix_system_urls($oldurl, z_root());
            set_config('system', 'urlverify', bin2hex(z_root()));
        } else {
            logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
        }
    }
    // This will actually set the url to the one stored in .htconfig, and ignore what
    // we're passing - unless we are installing and it has never been set.
    $a->set_baseurl($a->get_baseurl());
    // Make sure each site has a system channel.  This is now created on install
    // so we just need to keep this around a couple of weeks until the hubs that
    // already exist have one
    $syschan_exists = get_sys_channel();
    if (!$syschan_exists) {
        create_sys_channel();
    }
    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();
}
Example #12
0
 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
                 }
             }
         }
     }
 }
Example #13
0
    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'));
Example #14
0
<?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');
Example #15
0
      * 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
    ?>
><a href="?page=links">Офферы</a></li>
            <li <?php 
    if ($_REQUEST['page'] == 'rules') {
        echo 'class="active"';
    }
    ?>
><a href="?page=rules">Ссылки</a></li>
            <li <?php 
    if (in_array($_REQUEST['page'], array('import', 'costs', 'postback'))) {
        echo 'class="active"';
    }
    ?>
><a href="?page=import">Инструменты</a></li>
            <?php 
    echo load_plugin('demo', 'demo_warn');
    ?>
          </ul>

          <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class='fa fa-clock-o color-white'></i>&nbsp;<?php 
    echo _e($arr_timezone_selected_name);
    ?>
 <b class="caret"></b></a>
              <ul class="dropdown-menu">
               <?php 
    foreach ($arr_timezone_settings as $cur) {
        if ($cur['is_active'] != 1) {
            echo "<li role='presentation'><a role='menuitem' tabindex='-1' href='#' onclick='return change_current_timezone({$cur['id']})'>" . _e($cur['timezone_name']) . "</a></li>";
        }
function get_plugin_instance($name)
{
    load_plugin($name);
    $service_class_name = str_replace(' ', '', ucwords(str_replace('-', ' ', $name))) . "Plugin";
    return new $service_class_name();
}
Example #18
0
function load_plugins($type = NULL)
{
    global $prefs, $plugins;
    if (!is_array($plugins)) {
        $plugins = array();
    }
    if (!empty($prefs['plugin_cache_dir'])) {
        $dir = rtrim($prefs['plugin_cache_dir'], '/') . '/';
        $dh = @opendir($dir);
        while ($dh and false !== ($f = @readdir($dh))) {
            if ($f[0] != '.') {
                load_plugin(basename($f, '.php'));
            }
        }
    }
    $where = "status='1'";
    if ($type !== NULL) {
        $where .= " and type='" . doSlash($type) . "'";
    }
    $rs = safe_rows("name, code", "txp_plugin", $where);
    if ($rs) {
        $old_error_handler = set_error_handler("pluginErrorHandler");
        foreach ($rs as $a) {
            if (!in_array($a['name'], $plugins)) {
                $plugins[] = $a['name'];
                $GLOBALS['txp_current_plugin'] = $a['name'];
                $eval_ok = eval($a['code']);
                if ($eval_ok === FALSE) {
                    echo gTxt('plugin_load_error_above') . strong($a['name']) . n . br;
                }
                unset($GLOBALS['txp_current_plugin']);
            }
        }
        restore_error_handler();
    }
}
Example #19
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
/**
 * Just include the Facebook PHP library as it is with no wrapper.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
load_plugin('Facebook/src/facebook');
// End of Facebook.php
Example #20
0
 public function render()
 {
     //============================================================
     // Core Components
     //============================================================
     $this->pofw->load_db_engine();
     $this->pofw->load_form_engine();
     load_plugin('rs_list');
     load_plugin('table');
     //============================================================
     // Application Logic
     //============================================================
     require_once "{$this->app_logic_path}/security/module_list.class.php";
     //============================================================
     // Menu
     //============================================================
     $this->menu_xml = $_SESSION['menu_xml'];
     //============================================================
     // Content
     //============================================================
     $this->content_constructor();
 }
Example #21
0
 /**
  * 解析处理一个模板文件
  *
  * @param  string $filePath  模板文件路径
  * @param  array  $vars 需要给模板变量赋值的变量
  * @return void
  */
 public function renderFile($filePath, $vars)
 {
     try {
         //加载DiscuzTemplate
         load_plugin("DiscuzTemplate");
         $template = DiscuzTemplate::getInstance();
         //使用单件模式实例化模板类
         //判断是否传递配置参数
         if (empty($this->params) || !isset($this->params['cache_dir'])) {
             throw new TM_Exception("Discuz template engine configure [cache_dir] not set, please  TM_View->factory() entry params");
         }
         //设置模板参数
         $this->params['cache_dir'] = $this->params['cache_dir'];
         $this->params['template_dir'] = isset($this->params['template_dir']) ? $this->params['template_dir'] : APP_VIEW_DIR;
         $this->params['auto_update'] = isset($this->params['auto_update']) ? $this->params['auto_update'] : true;
         $this->params['cache_lifetime'] = isset($this->params['cache_lifetime']) ? $this->params['cache_lifetime'] : 1;
         $template->setOptions($this->params);
         //设置模板参数
         //检查模板文件
         if (!is_file($filePath) || !is_readable($filePath)) {
             throw new TM_Exception("View file " . $filePath . " not exist or not readable");
         }
         //设置模板变量
         if (!empty($vars)) {
             foreach ($vars as $key => $value) {
                 ${$key} = $value;
             }
         }
         //输出到模板文件
         include $template->getfile($filePath);
     } catch (Exception $e) {
         throw new TM_Exception($e->getMessage());
     } catch (TM_Exception $e) {
         throw $e;
     }
 }
Example #22
0
 * @package   XML_Serializer
 * @author    Stephan Schmidt <*****@*****.**>
 * @copyright 2003-2008 Stephan Schmidt <*****@*****.**>
 * @license   http://opensource.org/licenses/bsd-license New BSD License
 * @version   CVS: $Id: Serializer.php 294967 2010-02-12 03:10:19Z clockwerx $
 * @link      http://pear.php.net/package/XML_Serializer
 * @see       XML_Unserializer
 */
/**
 * uses PEAR error management
 */
load_plugin('PEAR/PEAR');
/**
 * uses XML_Util to create XML tags
 */
load_plugin('XML/Util');
/**
 * option: string used for indentation
 *
 * Possible values:
 * - any string (default is any string)
 */
define('XML_SERIALIZER_OPTION_INDENT', 'indent');
/**
 * option: string used for linebreaks
 *
 * Possible values:
 * - any string (default is \n)
 */
define('XML_SERIALIZER_OPTION_LINEBREAKS', 'linebreak');
/**
<?php 
    if (is_array($arr_left_menu) && count($arr_left_menu) > 0) {
        ?>
	<div class="bs-sidebar hidden-print affix-top">
		<ul class="nav bs-sidenav">
			<?php 
        foreach ($arr_left_menu as $cur) {
            $class = $cur['is_active'] == 1 ? 'active' : '';
            ?>
				<li class="<?php 
            echo $class;
            ?>
"><a href="<?php 
            echo _e($cur['link']);
            ?>
"><?php 
            echo _e($cur['caption']);
            ?>
</a></li>
			<?php 
        }
        ?>
		</ul>
	</div>
<?php 
    }
    echo load_plugin('demo', 'demo_well');
}
?>
</div>
Example #24
0
/**
 * Loads plugins.
 *
 * @param bool $type If TRUE loads admin-side plugins, otherwise public
 */
function load_plugins($type = false)
{
    global $prefs, $plugins, $plugins_ver, $app_mode;
    if (!is_array($plugins)) {
        $plugins = array();
    }
    trace_add("[Loading plugins]", 1);
    if (!empty($prefs['plugin_cache_dir'])) {
        $dir = rtrim($prefs['plugin_cache_dir'], '/') . '/';
        // In case it's a relative path.
        if (!is_dir($dir)) {
            $dir = rtrim(realpath(txpath . '/' . $dir), '/') . '/';
        }
        $files = glob($dir . '*.php');
        if ($files) {
            natsort($files);
            foreach ($files as $f) {
                trace_add("[Loading plugin from cache dir '{$f}']");
                load_plugin(basename($f, '.php'));
            }
        }
    }
    $admin = $app_mode == 'async' ? '4,5' : '1,3,4,5';
    $where = 'status = 1 AND type IN (' . ($type ? $admin : '0,1,5') . ')';
    $rs = safe_rows("name, code, version", "txp_plugin", $where . ' order by load_order asc, name asc');
    if ($rs) {
        $old_error_handler = set_error_handler("pluginErrorHandler");
        foreach ($rs as $a) {
            if (!in_array($a['name'], $plugins)) {
                $plugins[] = $a['name'];
                $plugins_ver[$a['name']] = $a['version'];
                $GLOBALS['txp_current_plugin'] = $a['name'];
                trace_add("[Loading plugin '{$a['name']}' version '{$a['version']}']");
                $eval_ok = eval($a['code']);
                if ($eval_ok === false) {
                    echo gTxt('plugin_load_error_above') . strong($a['name']) . n . br;
                }
                unset($GLOBALS['txp_current_plugin']);
            }
        }
        restore_error_handler();
    }
    trace_add('', -1);
}
Example #25
0
    $main_content = ob_get_contents();
    ob_end_clean();
} else {
    $main_content = '';
}
if ($is_authorized) {
    // Меню сверху
    include _TRACK_SHOW_COMMON_PATH . "/templates/menu-top.inc.php";
    // Меню слева
    $sidebar = _TRACK_SHOW_COMMON_PATH . '/templates/' . (in_array($page_sidebar, $page_sidebar_allowed) ? $page_sidebar : 'sidebar-left.inc.php');
    include $sidebar;
    echo '<div class="page-content' . $menu_toggle_class . '">';
}
?>
        
        <?php 
if ($is_authorized) {
    echo load_plugin('payreminder');
    echo load_plugin('expiry');
}
echo $main_content;
if ($is_authorized) {
    echo '</div>';
}
?>
        <?php 
echo tpx('footer');
?>
    </body>
</html>
Example #26
0
function plugin_multi_edit()
{
    $selected = ps('selected');
    $method = ps('edit_method');
    if (!$selected or !is_array($selected)) {
        return plugin_list();
    }
    $where = "name IN ('" . join("','", doSlash($selected)) . "')";
    switch ($method) {
        case 'delete':
            foreach ($selected as $name) {
                if (safe_field('flags', 'txp_plugin', "name ='" . doSlash($name) . "'") & PLUGIN_LIFECYCLE_NOTIFY) {
                    load_plugin($name, true);
                    callback_event("plugin_lifecycle.{$name}", 'disabled');
                    callback_event("plugin_lifecycle.{$name}", 'deleted');
                }
            }
            safe_delete('txp_plugin', $where);
            break;
        case 'changestatus':
            foreach ($selected as $name) {
                if (safe_field('flags', 'txp_plugin', "name ='" . doSlash($name) . "'") & PLUGIN_LIFECYCLE_NOTIFY) {
                    $status = safe_field('status', 'txp_plugin', "name ='" . doSlash($name) . "'");
                    load_plugin($name, true);
                    // NB: won't show returned messages anywhere due to potentially overwhelming verbiage.
                    callback_event("plugin_lifecycle.{$name}", $status ? 'disabled' : 'enabled');
                }
            }
            safe_update('txp_plugin', 'status = (1-status)', $where);
            break;
        case 'changeorder':
            $order = min(max(intval(ps('order')), 1), 9);
            safe_update('txp_plugin', 'load_order = ' . $order, $where);
            break;
    }
    $message = gTxt('plugin_' . ($method == 'delete' ? 'deleted' : 'updated'), array('{name}' => join(', ', $selected)));
    plugin_list($message);
}
Example #27
0
 public function before()
 {
     load_helper('Twitter');
     load_plugin('Twitter/OAuth');
     parent::before();
 }
Example #28
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
load_plugin('YAML/spyc');
/**
 * Provide YAML methods to "parse" and "dump" YAML data.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
class YAML extends YAWF
{
    /**
     * Parse a text string of YAML data into a data array
     *
     * @param String $yaml the string of YAML data to parse
     * @return Array a data array containing the YAML data
     */
    public static function parse($yaml)
    {
        return Spyc::YAMLLoadString($yaml);
    }
Example #29
0
function load_plugins($type = 0)
{
    global $prefs, $plugins, $plugins_ver;
    if (!is_array($plugins)) {
        $plugins = array();
    }
    if (!empty($prefs['plugin_cache_dir'])) {
        $dir = rtrim($prefs['plugin_cache_dir'], '/') . '/';
        // in case it's a relative path
        if (!is_dir($dir)) {
            $dir = rtrim(realpath(txpath . '/' . $dir), '/') . '/';
        }
        $files = glob($dir . '*.php');
        if ($files) {
            natsort($files);
            foreach ($files as $f) {
                load_plugin(basename($f, '.php'));
            }
        }
    }
    $where = 'status = 1 AND type IN (' . ($type ? '1,3' : '0,1') . ')';
    $rs = safe_rows("name, code, version", "txp_plugin", $where . ' order by load_order');
    if ($rs) {
        $old_error_handler = set_error_handler("pluginErrorHandler");
        foreach ($rs as $a) {
            if (!in_array($a['name'], $plugins)) {
                $plugins[] = $a['name'];
                $plugins_ver[$a['name']] = $a['version'];
                $GLOBALS['txp_current_plugin'] = $a['name'];
                $eval_ok = eval($a['code']);
                if ($eval_ok === FALSE) {
                    echo gTxt('plugin_load_error_above') . strong($a['name']) . n . br;
                }
                unset($GLOBALS['txp_current_plugin']);
            }
        }
        restore_error_handler();
    }
}
Example #30
0
// +----------------------------------------------------------------------+
// | You should have received the following files along with this library |
// | - COPYRIGHT (Additional copyright notice)                            |
// | - DISCLAIMER (Disclaimer of warranty)                                |
// | - README (Important information regarding this library)              |
// +----------------------------------------------------------------------+
/**
* AkInflexor for pluralize and singularize Spanish nouns.
* 
* @author Bermi Ferrer Martinez <bermi akelos com>
* @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
* @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
* @since 0.1
* @version $Revision 0.1 $
*/
load_plugin('Text/AkInflector');
class AkInflexor extends AkInflector
{
    function pluralize($word)
    {
        $plural = array('/([aeiou])x$/i' => '\\1x', '/([áéíóú])([ns])$/i' => '|1\\2es', '/(^[bcdfghjklmnñpqrstvwxyz]*)an$/i' => '\\1anes', '/([áéíóú])s$/i' => '|1ses', '/(^[bcdfghjklmnñpqrstvwxyz]*)([aeiou])([ns])$/i' => '\\1\\2\\3es', '/([aeiouáéó])$/i' => '\\1s', '/([aeiou])s$/i' => '\\1s', '/([éí])(s)$/i' => '|1\\2es', '/z$/i' => 'ces', '/([íú])$/i' => '\\1es', '/(ng|[wckgtp])$/' => '\\1s', '/$/i' => 'es');
        // We should manage _orden_ -> _órdenes_, _joven_->_jóvenes_ and so.
        $uncountable = array('tijeras', 'gafas', 'vacaciones', 'víveres', 'déficit');
        /* In fact these words have no singular form: you cannot say neither
           "una gafa" nor "un vívere". So we should change the variable name to
           $onlyplural or something alike.*/
        $irregular = array('país' => 'países', 'champú' => 'champús', 'jersey' => 'jerséis', 'carácter' => 'caracteres', 'espécimen' => 'especímenes', 'menú' => 'menús', 'régimen' => 'regímenes', 'curriculum' => 'currículos', 'ultimátum' => 'ultimatos', 'memorándum' => 'memorandos', 'referéndum' => 'referendos');
        $lowercased_word = strtolower($word);
        foreach ($uncountable as $_uncountable) {
            if (substr($lowercased_word, -1 * strlen($_uncountable)) == $_uncountable) {
                return $word;