Beispiel #1
0
 function init()
 {
     parent::init();
     $this->esoTalk->addToHead("<style type='text/css'>.emoticon {width:16px; height:16px; background:url({$this->emoticonDir}emoticons.png); background-repeat:no-repeat}</style>");
     // Add the formatter
     $this->esoTalk->formatter->addFormatter("emoticons", "Formatter_Emoticons");
 }
Beispiel #2
0
 function init()
 {
     parent::init();
     // Add the hooks
     if ($this->esoTalk->action == "conversation") {
         $this->esoTalk->controller->addHook("formatForDisplay", array($this, "formatWordfilterForDisplay"));
     }
 }
Beispiel #3
0
 function init()
 {
     parent::init();
     // Add the hooks
     if ($this->esoTalk->action == "join") {
         $this->esoTalk->controller->addHook("beforeAddMember", array($this, "addAccountField"));
         $this->esoTalk->controller->addHook("afterAddMember", array($this, "logInUser"));
     }
 }
 /**
  * Tests current_snapshot_uuid().
  *
  * @see current_snapshot_uuid()
  */
 public function test_current_snapshot_uuid()
 {
     global $customize_snapshots_plugin;
     $this->assertNull(current_snapshot_uuid());
     $uuid = '65aee1ff-af47-47df-9e14-9c69b3017cd3';
     $_REQUEST['customize_snapshot_uuid'] = $uuid;
     $customize_snapshots_plugin = new Plugin();
     $customize_snapshots_plugin->init();
     $this->assertEquals($uuid, current_snapshot_uuid());
 }
Beispiel #5
0
 public function __construct()
 {
     global $config;
     session_start();
     $config['PLUGIN_PATH'] = __ROOTDIR__ . '/plugins/';
     $this->config = $config;
     $this->model = self::initModel($this->config);
     $this->cache = self::initCache($this->config);
     $this->init();
     Plugin::init('Admin', $config);
     $langCon = Lang::langCon();
     $this->config = array_merge((array) $config, (array) $langCon);
 }
Beispiel #6
0
 function init()
 {
     parent::init();
     $this->esoTalk->addHook("beforeDatabaseQuery", array($this, "addQuery"));
     if ($this->esoTalk->ajax) {
         $this->esoTalk->addHook("ajaxFinish", array($this, "addInformationToAjaxResult"));
         return;
     }
     // Language definitions
     $this->esoTalk->addLanguage("Debug information", "Debug information");
     $this->esoTalk->addLanguage("Page loaded in", "Page loaded in just over");
     $this->esoTalk->addLanguage("MySQL queries", "MySQL queries");
     $this->esoTalk->addLanguage("POST + GET + FILES information", "POST + GET + FILES information");
     $this->esoTalk->addLanguage("SESSION + COOKIE information", "SESSION + COOKIE information");
     $this->esoTalk->addLanguage("seconds", "seconds");
     $this->esoTalk->addScript("plugins/Debug/debug.js", 1000);
     $this->esoTalk->addHook("footer", array($this, "renderDebug"));
 }
 /**
  * Test updating a snapshot when the user does not have the customize_publish capability.
  *
  * @covers \CustomizeSnapshots\Customize_Snapshot_Manager::handle_update_snapshot_request()
  */
 function test_ajax_update_snapshot_ok_for_draft_and_pending_but_not_future()
 {
     unset($GLOBALS['wp_customize']);
     remove_all_actions('wp_ajax_' . Customize_Snapshot_Manager::AJAX_ACTION);
     $post_type_obj = get_post_type_object(Post_Type::SLUG);
     $setting_key = 'anyonecanedit';
     add_filter('user_has_cap', function ($allcaps, $caps, $args) {
         $allcaps['customize'] = true;
         if (!empty($allcaps['edit_posts']) && !empty($args) && 'customize' === $args[0]) {
             $allcaps = array_merge($allcaps, array_fill_keys($caps, true));
         }
         return $allcaps;
     }, 10, 3);
     $tomorrow = date('Y-m-d H:i:s', time() + 86400);
     $this->set_current_user('contributor');
     $this->assertFalse(current_user_can($post_type_obj->cap->publish_posts));
     $post_vars = array('action' => Customize_Snapshot_Manager::AJAX_ACTION, 'nonce' => wp_create_nonce(Customize_Snapshot_Manager::AJAX_ACTION), 'customize_snapshot_uuid' => self::UUID, 'customized' => wp_json_encode(array($setting_key => 'Hello')), 'publish_date' => $tomorrow);
     $this->plugin = new Plugin();
     $this->plugin->init();
     $this->add_setting();
     // Draft pass.
     $post_vars['status'] = 'draft';
     $this->set_input_vars($post_vars);
     $this->make_ajax_call(Customize_Snapshot_Manager::AJAX_ACTION);
     $response = json_decode($this->_last_response, true);
     $this->_last_response = '';
     $this->assertTrue($response['success']);
     // Pending pass.
     $post_vars['status'] = 'pending';
     $this->set_input_vars($post_vars);
     $this->make_ajax_call(Customize_Snapshot_Manager::AJAX_ACTION);
     $response = json_decode($this->_last_response, true);
     $this->_last_response = '';
     $this->assertTrue($response['success']);
     // Future fail.
     $post_vars['status'] = 'future';
     $this->set_input_vars($post_vars);
     $this->make_ajax_call(Customize_Snapshot_Manager::AJAX_ACTION);
     $response = json_decode($this->_last_response, true);
     $expected_results = array('success' => false, 'data' => 'customize_not_allowed');
     $this->assertSame($expected_results, $response);
 }
Beispiel #8
0
 public function __construct()
 {
     global $config;
     @session_start();
     if (!file_exists('data/install.lock')) {
         $this->redirect(__ROOT__ . '/install/');
     }
     $config['PLUGIN_PATH'] = __ROOTDIR__ . '/plugins/';
     $this->config = $config;
     $this->model = self::initModel($this->config);
     $this->init();
     Plugin::init();
     $langCon = Lang::langCon();
     $this->config = array_merge((array) $config, (array) $langCon);
     if ($config['LANG_OPEN']) {
         define('__INDEX__', __APP__ . '/' . __LANG__);
     } else {
         define('__INDEX__', __APP__);
     }
 }
Beispiel #9
0
 function init()
 {
     parent::init();
     // Language definitions.
     $this->esoTalk->addLanguage("Shouts", "Shouts");
     $this->esoTalk->addLanguage("Shout it", "Shout it!");
     $this->esoTalk->addLanguage("Type a shout here", "Type a shout here...");
     $this->esoTalk->addLanguage("View more shouts", "View more shouts");
     $this->esoTalk->addLanguage("emailOnNewShout", "Email me when someone adds a shout to my profile");
     $this->esoTalk->addLanguage(array("emails", "newShout", "subject"), "%s, someone shouted on your profile");
     $this->esoTalk->addLanguage(array("emails", "newShout", "body"), "%s, %s has added a shout to your profile!\n\nTo view the new activity, check out the following link:\n%s");
     // If we're on the profile view, initiate all the shout stuff.
     if ($this->esoTalk->action == "profile") {
         $this->esoTalk->controller->addHook("init", array($this, "addShoutsSection"));
         $this->esoTalk->controller->addHook("ajax", array($this, "ajax"));
         $this->esoTalk->addScript("plugins/Shouts/shouts.js");
         $this->esoTalk->addCSS("plugins/Shouts/shouts.css");
     }
     if ($this->esoTalk->action == "settings") {
         $this->esoTalk->controller->addHook("init", array($this, "addShoutsSettings"));
     }
 }
Beispiel #10
0
 public function __construct()
 {
     global $config;
     $session_name = session_name();
     if (!isset($_COOKIE[$session_name])) {
         foreach ($_COOKIE as $key => $val) {
             $key = strtoupper($key);
             if (strpos($key, $session_name)) {
                 session_id($_COOKIE[$key]);
             }
         }
     }
     @session_start();
     $config['PLUGIN_PATH'] = __ROOTDIR__ . '/plugins/';
     $this->config = $config;
     $this->model = self::initModel($this->config);
     $this->init();
     $this->check_login();
     Plugin::init('Admin', $config);
     $langCon = Lang::langCon();
     $this->config = array_merge((array) $config, (array) $langCon);
 }
Beispiel #11
0
 /**
  * Protected Construct
  */
 protected function __construct()
 {
     /**
      * Load core defines
      */
     Monstra::loadDefines();
     /**
      * Compress HTML with gzip
      */
     if (MONSTRA_GZIP) {
         if (!ob_start("ob_gzhandler")) {
             ob_start();
         }
     } else {
         ob_start();
     }
     /**
      * Send default header and set internal encoding
      */
     header('Content-Type: text/html; charset=UTF-8');
     function_exists('mb_language') and mb_language('uni');
     function_exists('mb_regex_encoding') and mb_regex_encoding('UTF-8');
     function_exists('mb_internal_encoding') and mb_internal_encoding('UTF-8');
     /**
      * Gets the current configuration setting of magic_quotes_gpc
      * and kill magic quotes
      */
     if (get_magic_quotes_gpc()) {
         function stripslashesGPC(&$value)
         {
             $value = stripslashes($value);
         }
         array_walk_recursive($_GET, 'stripslashesGPC');
         array_walk_recursive($_POST, 'stripslashesGPC');
         array_walk_recursive($_COOKIE, 'stripslashesGPC');
         array_walk_recursive($_REQUEST, 'stripslashesGPC');
     }
     /**
      * Set Gelato Display Errors to False for Production environment.
      */
     if (Monstra::$environment == Monstra::PRODUCTION) {
         define('GELATO_DEVELOPMENT', false);
     }
     /**
      * Define Monstra Folder for Gelato Logs
      */
     define('GELATO_LOGS_PATH', LOGS);
     /**
      * Include Gelato Library
      */
     include ROOT . DS . 'libraries' . DS . 'Gelato' . DS . 'Gelato.php';
     /**
      * Map Monstra Engine Directory
      */
     ClassLoader::directory(ROOT . DS . 'engine' . DS);
     /**
      * Map all Monstra Classes
      */
     ClassLoader::mapClasses(array('Security' => ROOT . DS . 'engine' . DS . 'Security.php', 'Uri' => ROOT . DS . 'engine' . DS . 'Uri.php', 'Site' => ROOT . DS . 'engine' . DS . 'Site.php', 'Alert' => ROOT . DS . 'engine' . DS . 'Alert.php', 'XML' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'XML.php', 'DB' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'DB.php', 'Table' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'Table.php', 'Plugin' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Plugin.php', 'Frontend' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Frontend.php', 'Backend' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Backend.php', 'Action' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Action.php', 'Filter' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Filter.php', 'View' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'View.php', 'I18n' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'I18n.php', 'Stylesheet' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Stylesheet.php', 'Javascript' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Javascript.php', 'Navigation' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Navigation.php', 'Option' => ROOT . DS . 'engine' . DS . 'Option.php', 'Shortcode' => ROOT . DS . 'engine' . DS . 'Shortcode.php', 'ORM' => ROOT . DS . 'libraries' . DS . 'Idiorm' . DS . 'ORM.php', 'PHPMailer' => ROOT . DS . 'libraries' . DS . 'PHPMailer' . DS . 'PHPMailer.php'));
     /**
      *  Start session
      */
     Session::start();
     /**
      * Init Idiorm
      */
     if (defined('MONSTRA_DB_DSN')) {
         ORM::configure(MONSTRA_DB_DSN);
         ORM::configure('username', MONSTRA_DB_USER);
         ORM::configure('password', MONSTRA_DB_PASSWORD);
         ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
     }
     /**
      * Auto cleanup if DEVELOPMENT environment
      */
     if (Monstra::$environment == Monstra::DEVELOPMENT) {
         Monstra::cleanTmp();
     }
     /**
      * Set Cache dir
      */
     Cache::configure('cache_dir', CACHE);
     /**
      * Init Options API module
      */
     Option::init();
     /**
      * Set default timezone
      */
     @ini_set('date.timezone', Option::get('timezone'));
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(Option::get('timezone'));
     } else {
         putenv('TZ=' . Option::get('timezone'));
     }
     /**
      * Sanitize URL to prevent XSS - Cross-site scripting
      */
     Security::runSanitizeURL();
     /**
      * Load default
      */
     Monstra::loadPluggable();
     /**
      * Init I18n
      */
     I18n::init(Option::get('language'));
     /**
      * Init Plugins API
      */
     Plugin::init();
     /**
      * Init Notification service
      */
     Notification::init();
     /**
      * Init site module
      */
     if (!BACKEND) {
         Site::init();
     }
 }
Beispiel #12
0
 function plugin()
 {
     if ($this->method !== 'post') {
         $this->error('403', 'Forbidden');
         return;
     }
     $local = $this->input->post('local_path');
     $guid = $this->input->post('guid');
     $install_id = $this->input->post('uuid');
     $purchase = $this->input->post('purchase');
     $is_new = $this->input->post('new');
     $plugin_id = $this->input->post('id');
     $base = FCPATH . 'storage' . DIRECTORY_SEPARATOR;
     $tmp_path = $base . 'tmp';
     $remote = KOKEN_STORE_URL . '/plugins/download/' . $guid . '/for/' . $install_id . ($purchase ? '/' . $purchase : '');
     $local_zip = $tmp_path . DIRECTORY_SEPARATOR . 'update.zip';
     $updated_theme = $tmp_path . DIRECTORY_SEPARATOR . $guid;
     $current_path = $base . $local;
     if (is_dir("{$current_path}.off")) {
         delete_files("{$current_path}.off", true, 1);
     }
     if (is_dir("{$current_path}/.git")) {
         delete_files("{$current_path}/.git", true, 1);
     }
     make_child_dir($tmp_path);
     $success = false;
     $old_mask = umask(0);
     if (ENVIRONMENT === 'development' && !$is_new) {
         $success = true;
         sleep(3);
     } else {
         if ($this->_download($remote, $local_zip)) {
             $this->load->library('unzip');
             $this->unzip->extract($local_zip);
             if (file_exists($updated_theme . DIRECTORY_SEPARATOR . 'info.json') || file_exists($updated_theme . DIRECTORY_SEPARATOR . 'pulse.json') || file_exists($updated_theme . DIRECTORY_SEPARATOR . 'plugin.json')) {
                 if ($is_new || rename($current_path, "{$current_path}.off")) {
                     if (rename($updated_theme, $current_path)) {
                         // Hack for watermark update issue. Can removed this eventually (0.15.1 was when this was implemented)
                         if (file_exists("{$current_path}.off/image.png")) {
                             copy("{$current_path}.off/image.png", "{$current_path}/storage/image.png");
                         }
                         // /Hack
                         // Copy storage folder to ensure userland files survive update
                         if (is_dir("{$current_path}.off/storage")) {
                             delete_files("{$current_path}/storage", true, 1);
                             rename("{$current_path}.off/storage", "{$current_path}/storage");
                         }
                         delete_files("{$current_path}.off", true, 1);
                         $success = true;
                         if (file_exists($current_path . DIRECTORY_SEPARATOR . 'info.json')) {
                             $json = $current_path . DIRECTORY_SEPARATOR . 'info.json';
                         } else {
                             if (file_exists($current_path . DIRECTORY_SEPARATOR . 'pulse.json')) {
                                 $json = $current_path . DIRECTORY_SEPARATOR . 'pulse.json';
                             } else {
                                 $json = $current_path . DIRECTORY_SEPARATOR . 'plugin.json';
                             }
                         }
                         $json = json_decode(file_get_contents($json, true));
                     } else {
                         $json = 'Could not rename folder.';
                     }
                 } else {
                     $json = 'Could not rename old version before upgrading';
                 }
             } else {
                 $json = 'Could not download plugin ZIP.';
             }
             unlink($local_zip);
             delete_files($updated_theme, true, 1);
         }
     }
     umask($old_mask);
     if ($plugin_id) {
         $p = new Plugin();
         $p->where('id', $plugin_id)->get();
         if ($p->exists()) {
             $plugins = $this->parse_plugins();
             $plugin = $p->init($plugins);
             if ($plugin->database_fields) {
                 $db_config = Shutter::get_db_configuration();
                 $this->load->dbforge();
                 foreach ($plugin->database_fields as $table => $fields) {
                     $table = $db_config['prefix'] . $table;
                     foreach ($fields as $column => $info) {
                         if (in_array(strtolower($info['type']), array('text', 'varchar', 'longtext'))) {
                             $info['null'] = true;
                         }
                         $this->dbforge->add_column($table, array($column => $info));
                     }
                 }
                 $this->_clear_datamapper_cache();
             }
             $p->run_plugin_method('after_upgrade', $plugins);
         }
     }
     $this->_compile_plugins();
     die(json_encode(array('done' => $success, 'info' => isset($json) ? $json : array())));
 }
 public function testInit()
 {
     $this->object->init();
     $this->assertSame(['aliases' => ['@dns' => '/dns/', '@more' => '/more'], 'modules' => ['dns' => 'dns config here'], 'components' => ['i18n' => 'i18n config here']], $this->object->getItems());
 }
 /**
  * Test that all required actions and filters are added as expected
  */
 function test_init()
 {
     Plugin::init();
     $this->do_action_validation('widgets_init', [__NAMESPACE__ . '\\Plugin', 'register_widgets']);
 }
Beispiel #15
0
 function index()
 {
     if (!$this->auth) {
         $this->error('401', 'Not authorized to perform this action.');
         return;
     }
     list($params, $id) = $this->parse_params(func_get_args());
     $plugins = $this->parse_plugins();
     $db_config = Shutter::get_db_configuration();
     switch ($this->method) {
         case 'delete':
             $p = new Plugin();
             $p->where('id', $id)->get();
             if ($p->exists()) {
                 $p->run_plugin_method('after_uninstall', $plugins);
                 $plugin = $p->init($plugins);
                 if ($plugin->database_fields) {
                     $this->load->dbforge();
                     foreach ($plugin->database_fields as $table => $fields) {
                         $table = $db_config['prefix'] . $table;
                         foreach ($fields as $column => $info) {
                             $this->dbforge->drop_column($table, $column);
                         }
                     }
                     $this->_clear_datamapper_cache();
                 }
                 $p->delete();
             }
             $this->_compile_plugins();
             exit;
             break;
         case 'post':
             $p = new Plugin();
             $p->path = $_POST['path'];
             $p->setup = $p->run_plugin_method('require_setup', $plugins) === false;
             if ($p->save()) {
                 $plugin = $p->init($plugins);
                 if ($plugin->database_fields) {
                     $this->load->dbforge();
                     foreach ($plugin->database_fields as $table => $fields) {
                         $table = $db_config['prefix'] . $table;
                         foreach ($fields as $column => $info) {
                             $this->dbforge->add_column($table, array($column => $info));
                         }
                     }
                     $this->_clear_datamapper_cache();
                 }
                 $p->run_plugin_method('after_install', $plugins);
             }
             $this->_compile_plugins();
             $this->redirect('/plugins');
             break;
         case 'put':
             unset($_POST['_method']);
             $data = serialize($_POST);
             $p = new Plugin();
             $p->where('id', $id)->get();
             $p->save_data($plugins, $_POST);
             $validate = $p->run_plugin_method('confirm_setup', $plugins, $data);
             if ($validate === true) {
                 $p->setup = 1;
                 $p->save();
                 $this->_compile_plugins();
                 exit;
             } else {
                 $this->error(400, $validate);
                 return;
             }
             break;
         default:
             $data = array('plugins' => $plugins);
             function sortByName($a, $b)
             {
                 return $a['name'] > $b['name'];
             }
             usort($data['plugins'], 'sortByName');
             $data['plugins'] = Shutter::filter('api.plugins', array($data['plugins']));
             $data['custom_sources'] = Shutter::$custom_sources;
             $this->set_response_data($data);
             break;
     }
 }
Beispiel #16
0
    $_FILES = array_map(array('Toolbox', 'clean_cross_side_scripting_deep'), $_FILES);
}
// Mark if Header is loaded or not :
$HEADER_LOADED = false;
$FOOTER_LOADED = false;
if (isset($AJAX_INCLUDE)) {
    $HEADER_LOADED = true;
}
/* On startup, register all plugins configured for use. */
if (!isset($AJAX_INCLUDE) && !isset($PLUGINS_INCLUDED)) {
    // PLugin already included
    $PLUGINS_INCLUDED = 1;
    $LOADED_PLUGINS = array();
    $plugin = new Plugin();
    if (!isset($_SESSION["glpi_plugins"])) {
        $plugin->init();
    }
    if (isset($_SESSION["glpi_plugins"]) && is_array($_SESSION["glpi_plugins"])) {
        //Plugin::doHook("config");
        if (count($_SESSION["glpi_plugins"])) {
            foreach ($_SESSION["glpi_plugins"] as $name) {
                Plugin::load($name);
            }
        }
        // For plugins which require action after all plugin init
        Plugin::doHook("post_init");
    }
}
if (!isset($_SESSION["MESSAGE_AFTER_REDIRECT"])) {
    $_SESSION["MESSAGE_AFTER_REDIRECT"] = "";
}
 /**
  * @see Plugin::init()
  */
 function test_init()
 {
     $this->plugin->init();
     $this->assertInstanceOf('WP_Widget_Factory', $this->plugin->widget_factory);
     $this->assertNotFalse(has_action('wp_default_scripts', array($this->plugin, 'register_scripts')));
 }
Beispiel #18
0
// DEFINED ONLY FOR BACKWARDS SUPPORT - to be taken out before 0.9.0
$__FROG_CONN__ = $__CMS_CONN__;
Record::connection($__CMS_CONN__);
Record::getConnection()->exec("set names 'utf8'");
Setting::init();
use_helper('I18n');
AuthUser::load();
if (AuthUser::isLoggedIn()) {
    I18n::setLocale(AuthUser::getRecord()->language);
} else {
    I18n::setLocale(Setting::get('language'));
}
// Only add the cron web bug when necessary
if (defined('USE_POORMANSCRON') && USE_POORMANSCRON && defined('POORMANSCRON_INTERVAL')) {
    Observer::observe('page_before_execute_layout', 'run_cron');
    function run_cron()
    {
        $cron = Cron::findByIdFrom('Cron', '1');
        $now = time();
        $last = $cron->getLastRunTime();
        if ($now - $last > POORMANSCRON_INTERVAL) {
            echo $cron->generateWebBug();
        }
    }
}
Plugin::init();
// Setup admin routes
$admin_routes = array('/' . ADMIN_DIR => Setting::get('default_tab'), '/' . ADMIN_DIR . '/' => Setting::get('default_tab'), '/' . ADMIN_DIR . '/:any' => '$1');
Dispatcher::addRoute($admin_routes);
// run everything!
require APP_PATH . '/main.php';
        if ($response === false) {
            handle(ERROR_SYSTEM . '00');
        }
        handle('0000{"pid":' . $response . '}');
        break;
    case 'renew':
        if (!checkAuthority(9)) {
            handle(ERROR_PERMISSION . '00');
        }
        $currentPlugin = new Plugin();
        $currentPlugin->pid = getRequest('pid');
        $response = json_decode($currentPlugin->getData(), true);
        $gitStatus = (int) getRequest('gitStatus');
        if (!($gitStatus >= 0 && $gitStatus <= 2)) {
            $gitStatus = $response['gitStatus'];
        }
        $currentPlugin->init($response['uid'], $response['folder'], getRequest('cover'), getRequest('name'), getRequest('author'), getRequest('git'), $gitStatus, (int) getRequest('available'));
        if (!$currentPlugin->checkVariables()) {
            handle(ERROR_INPUT . '01');
        }
        $response = $currentPlugin->modify();
        if ($response === false) {
            handle(ERROR_SYSTEM . '00' . '目录名冲突!');
        } else {
            handle('0000');
        }
        break;
    default:
        ERROR(ERROR_INPUT . '02', 'Request Error.');
        break;
}