/** * @expectedException Exception * @throws Exception */ public function testDoubleSet() { $r = new \Core\Registry(); $key1 = 'key1'; $data1 = 'data1'; $data2 = 'data2'; $r->set($key1, $data1); $r->set($key1, $data2); }
<?php ini_set('display_errors', 'Off'); ini_set('log_errors', 'On'); ini_set("error_log", "my_errors.txt"); error_reporting(E_ALL); date_default_timezone_set('Europe/Kiev'); // change if needed require_once "include/constants.php"; require_once "include/autoload.php"; // state templates: [state] => [template file name] $templateMap = array(\Core\Application::STATE_LOGIN => "LoginTemplate.html", \Core\Application::STATE_BROWSE => "BrowseTemplate.php", \Core\Application::STATE_EMPLOYEE => "EmployeeTemplate.php", \Core\Application::STATE_EMPLOYEE_LIST => "EmployeeListTemplate.php", \Core\Application::STATE_BOOK => "BookTemplate.php", \Core\Application::STATE_DETAILS => "DetailsTemplate.php", \Core\Application::STATE_DETAILS_RETURN => "DetailsReturnTemplate.html", \Core\Application::STATE_REDIRECT => null); // vidget templates: [vidget class name (like in data-vidgets attribute)] => [template file name] $vidgetViews = array('LoginForm' => 'LoginForm.php', 'Navigation' => 'Navigation.php', 'Informer' => 'Informer.php', 'Messages' => 'Messages.php', 'Calendar' => 'Calendar.php', 'SideMenu' => 'SideMenu.php', 'Error' => 'Error.php', 'EmpListMessage' => 'EmpListMessage.php', 'Employee' => 'Employee.php', 'EmployeeList' => 'EmployeeList.php', 'PeriodNavigator' => 'PeriodNavigator.php', 'Book' => 'Book.php', 'DetailsCaption' => 'DetailsCaption.php', 'Details' => 'Details.php'); $registry = new \Core\Registry(); $registry->set(REG_SITE_ROOT, 'http://' . $_SERVER['HTTP_HOST'] . pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME)); \Utility\DependencyInjectionStorage::getInstance()->setPrefix(DI_PREFIX); \Utility\DependencyInjectionStorage::getInstance()->addInstance($registry); $http = new \Core\Http(); \Utility\DependencyInjectionStorage::getInstance()->addInstance($http); $session = new \Core\Session(); \Utility\DependencyInjectionStorage::getInstance()->addInstance($session); $app = new Core\Application($registry->get(REG_SITE_ROOT), $session); \Utility\DependencyInjectionStorage::getInstance()->addInstance($app); $db = new \Core\Database('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8', DB_USER, DB_PASSWORD, 'appointments', '\\Utility\\DatabaseCreateScript'); \Utility\DependencyInjectionStorage::getInstance()->addInstance($db); \Utility\DependencyInjectionStorage::getInstance()->addInstance(new \DBMappers\RoomItem('rooms')); \Utility\DependencyInjectionStorage::getInstance()->addInstance(new \DBMappers\AppointmentItem('appointments')); $empMapper = new \DBMappers\EmpItem('employees'); \Utility\DependencyInjectionStorage::getInstance()->addInstance($empMapper); (new \Core\Router())->start($http, $app, $db, $empMapper);
/** * Get the current users ipaddress * @return string ipaddress */ function get_client_ip() { $r = Core\Registry::getInstance()->request; $ipaddress = ''; if (isset($r->server['HTTP_CLIENT_IP'])) { $ipaddress = $r->server['HTTP_CLIENT_IP']; } else { if (isset($r->server['HTTP_X_FORWARDED_FOR'])) { $ipaddress = $r->server['HTTP_X_FORWARDED_FOR']; } else { if (isset($r->server['HTTP_X_FORWARDED'])) { $ipaddress = $r->server['HTTP_X_FORWARDED']; } else { if (isset($r->server['HTTP_FORWARDED_FOR'])) { $ipaddress = $r->server['HTTP_FORWARDED_FOR']; } else { if (isset($r->server['HTTP_FORWARDED'])) { $ipaddress = $r->server['HTTP_FORWARDED']; } else { if (isset($r->server['REMOTE_ADDR'])) { $ipaddress = $r->server['REMOTE_ADDR']; } else { $ipaddress = 'UNKNOWN'; } } } } } } return $ipaddress; }
Plugin Name: open-search Description: Sync the Wordpress Posts,Pages, Categories and Tags to OpenSearch Version: 1.0 Author: zzqer Author URI: http://www.zzqer.com */ namespace OpenSearch; // Exit if accessed directly if (!defined('ABSPATH')) { exit; } //These are the only require_once needed. Then you should use the Loader class require_once plugin_dir_path(__FILE__) . '/core/Loader.php'; Core\Loader::load(plugin_dir_path(__FILE__), array('core/Registry')); $registry = Core\Registry::instance(); $registry->setPluginDir(plugin_dir_path(__FILE__)); $registry->setPluginUrl(defined('DEV_ENV') && DEV_ENV ? WP_PLUGIN_URL . "/{basename(plugin_dir_path( __FILE__ ))}/" : plugin_dir_url(__FILE__)); $registry->setPluginVersion("0.1"); $registry->setPluginName('Open Search'); $registry->setPluginShortName('opSou'); $registry->setServerTemplate(WP_PLUGIN_DIR . '/' . basename(plugin_dir_path(__FILE__)) . '/config/config.json'); $registry->init(); if (is_admin()) { $settings = Admin\Controllers\Settings::instance(); $adminIndexer = Admin\Controllers\Indexer::instance(); } else { if ($registry->isEnabled()) { try { $searcher = new Core\Search(); } catch (Exception $exc) {
<?php require __DIR__ . '/core/registry.php'; require __DIR__ . '/core/helper.php'; require __DIR__ . '/core/translator.php'; $registry = new Core\Registry(); $registry->db_version = 14; $registry->db = function () use($registry) { require __DIR__ . '/vendor/PicoDb/Database.php'; if (DB_DRIVER === 'sqlite') { require __DIR__ . '/schemas/sqlite.php'; $db = new \PicoDb\Database(array('driver' => 'sqlite', 'filename' => DB_FILENAME)); } elseif (DB_DRIVER === 'mysql') { require __DIR__ . '/schemas/mysql.php'; $db = new \PicoDb\Database(array('driver' => 'mysql', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_NAME, 'charset' => 'utf8')); } else { die('Database driver not supported'); } if ($db->schema()->check($registry->db_version)) { return $db; } else { die('Unable to migrate database schema!'); } }; $registry->event = function () use($registry) { require __DIR__ . '/core/event.php'; return new \Core\Event(); }; $registry->action = function () use($registry) { require_once __DIR__ . '/models/action.php'; return new \Model\Action($registry->shared('db'), $registry->shared('event'));