public function __construct($driver, \Liten\Liten $liten = null) { $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance(); if ($driver == 'file') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_Filesystem(); } elseif ($driver == 'apc') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_APC(); } elseif ($driver == 'memcache') { /** * Filter whether to use `\Memcache`|`\Memcached`. * * @since 6.2.0 * @param * bool false Use `\Memcache`|`\Memcached`. Default is false. */ $useMemcached = $this->app->hook->apply_filter('use_memcached', false); $this->_cache = new \app\src\Core\Cache\etsis_Cache_Memcache($useMemcached); $pool = [['host' => '127.0.0.1', 'port' => 11211, 'weight' => 20]]; /** * Filter the `\Memcache`|`\Memcached` server pool. * * @since 6.2.0 * @param array $pool * Array of servers to add to the connection pool. */ $servers = $this->app->hook->apply_filter('memcache_server_pool', $pool); $this->_cache->addServer($servers); } elseif ($driver == 'external') { /** * Fires when being used to call another caching system not * native to eduTrac SIS. * * @since 6.2.0 */ $this->_cache = $this->app->hook->do_action('external_cache_driver'); } elseif ($driver == 'xcache') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_XCache(); } elseif ($driver == 'cookie') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_Cookie(); } elseif ($driver == 'json') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_JSON(); } elseif ($driver == 'memory') { $this->_cache = new \app\src\Core\Cache\etsis_Cache_Memory(); } if (is_etsis_exception($this->_cache)) { return $this->_cache->getMessage(); } return $this->_cache; }
/** * Loads all activated plugin for inclusion. * * @access public * @since 1.0.1 * @param * string (optional) $plugins_dir Loads plugins from specified folder * @return mixed */ public function load_activated_plugins($plugins_dir = '') { $plugin = $this->_app->db->plugin(); $q = $plugin->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q as $k => $v) { $pluginFile = _h($v['location']); $plugin = str_replace('.plugin.php', '', $pluginFile); if (!file_exists($plugins_dir . $plugin . '/' . $pluginFile)) { $file = $plugins_dir . $pluginFile; } else { $file = $plugins_dir . $plugin . '/' . $pluginFile; } $error = etsis_php_check_syntax($file); if (is_etsis_exception($error)) { $this->deactivate_plugin(_h($v['location'])); $this->_app->flash('error_message', sprintf(_t('The plugin <strong>%s</strong> has been deactivated because your changes resulted in a <strong>fatal error</strong>. <br /><br />') . $error->getMessage(), _h($v['location']))); return false; } if (file_exists($file)) { require_once $file; } else { $this->deactivate_plugin(_h($v['location'])); } } }
/** * Checks if a new release is available. * If so, installation along with * database will be updated. * * @since 6.2.2 */ public function updateCheck() { $error = $this->getServerStatus(); if (is_etsis_exception($error)) { echo $error->getMessage(); } else { $this->update->setCurrentVersion(RELEASE_TAG); $this->update->setUpdateUrl($this->url . 'core/1.1/update-check'); // Optional: $this->update->addLogHandler(new \Monolog\Handler\StreamHandler(APP_PATH . 'tmp' . DS . 'logs' . DS . 'core-update.' . date('m-d-Y') . '.txt')); $this->update->setCache(new \Desarrolla2\Cache\Adapter\File(APP_PATH . 'tmp/cache'), 3600); $cacheFile = APP_PATH . 'tmp/cache/__update-versions.php.cache'; echo '<p>' . sprintf(_t('Last checked on %s @ %s'), date('M d, Y', file_mod_time($cacheFile)), date('h:i A', file_mod_time($cacheFile))); if ($this->update->checkUpdate() !== false) { if ($this->update->newVersionAvailable()) { // Install new update echo sprintf(_t('<p>New Release: <font color="red">r%s</font></p>'), $this->update->getLatestVersion()); echo '<p>' . _t('Installing Updates: ') . '</p>'; echo '<pre>'; var_dump(array_map(function ($version) { return (string) $version; }, $this->update->getVersionsToUpdate())); echo '</pre>'; $result = $this->update->update(); echo '<p>' . _t('Database Check . . .') . '</p>'; $this->updateDatabaseCheck(); echo '<p>' . _t('Directory Check . . .') . '</p>'; $this->removeDirCheck(); echo '<p>' . _t('File Check . . .') . '</p>'; $this->removeFileCheck(); if ($result === true) { echo '<p>' . _t('Update successful!') . '</p>'; } else { echo '<p>' . sprintf(_t('Update failed: %s!'), $result) . '</p>'; if ($result = \VisualAppeal\AutoUpdate::ERROR_SIMULATE) { echo '<pre>'; var_dump($this->update->getSimulationResults()); echo '</pre>'; } } } else { echo sprintf(_t('<p>You currently have the latest release of eduTrac SIS installed: <font color="green">r%s</font></p>'), RELEASE_TAG); } } else { echo '<p>' . _t('Could not check for updates! See log file for details.') . '</p>'; } } }
<div class="widget widget-heading-simple widget-body-white <?php echo $app->hook->has_filter('sidebar_menu') ? 'col-md-12' : 'col-md-10'; ?> "> <div class="widget-body"> <!-- Row --> <div class="row"> <!-- Alert --> <div class="alert alert-info" style="color: #666666;"> <?php $update = \app\src\CoreUpdate::inst(); $zip = $update->zip_extention_loaded(); if (is_etsis_exception($zip)) { echo $zip->getMessage(); exit; } $update->update(); ?> </div> <!-- // Alert END --> </div> </div> </div> </div>
<!-- Widget --> <div class="widget widget-heading-simple widget-body-white"> <div class="widget-body"> <!-- Row --> <div class="row"> <!-- Alert --> <div class="alerts alerts-error"> <strong><?php echo _t('Error!'); ?> </strong> <?php echo is_etsis_exception($error) ? $error->getMessage() : ''; ?> </div> <!-- // Alert END --> </div> </div> </div> </div> </div> <!-- // Content END -->
/** * Validates a plugin and checks to make sure there are no syntax and/or * parsing errors. * * @since 6.2.0 * @param string $plugin_name * Name of the plugin file (i.e. moodle.plugin.php). */ function etsis_validate_plugin($plugin_name) { $app = \Liten\Liten::getInstance(); $plugin = str_replace('.plugin.php', '', $plugin_name); if (!file_exists(ETSIS_PLUGIN_DIR . $plugin . '/' . $plugin_name)) { $file = ETSIS_PLUGIN_DIR . $plugin_name; } else { $file = ETSIS_PLUGIN_DIR . $plugin . '/' . $plugin_name; } $error = etsis_php_check_syntax($file); if (is_etsis_exception($error)) { $app->flash('error_message', _t('Plugin could not be activated because it triggered a <strong>fatal error</strong>. <br /><br />') . $error->getMessage()); return false; } if (file_exists($file)) { include_once $file; } /** * Fires before a specific plugin is activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.00 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activate_plugin', $plugin_name); /** * Fires as a specifig plugin is being activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.00 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activate_' . $plugin_name); /** * Activate the plugin if there are no errors. * * @since 5.0.0 * @param string $plugin_name * The plugin's base name. */ activate_plugin($plugin_name); /** * Fires after a plugin has been activated. * * $pluginName refers to the plugin's * name (i.e. moodle.plugin.php). * * @since 6.1.06 * @param string $plugin_name * The plugin's base name. */ $app->hook->do_action('activated_plugin', $plugin_name); }