public function __construct() { $b = Bootstrap::getInstance(); $b->init(); $b->includeWordPress(); $this->uploadDir = wp_upload_dir(); }
public function getGeoInfo($ip) { $cache = Cache::getInstance(); $return = $cache->get('geo:' . $ip); if ($cache->wasResultFound()) { if (DEBUG_BAR) { Bootstrap::getInstance()->debugbar['messages']->addMessage("Cached GeoInfo: {$ip}"); } return $return; } $client = new \GuzzleHttp\Client(); //'https://geoip.maxmind.com/geoip/v2.1/city/me $res = $client->get($this->url . $ip, array('auth' => array($this->user, $this->password))); $body = $res->getBody(true); $json = json_decode($body); $return = array('countryCode' => $json->country->iso_code, 'countryName' => $json->country->names->en, 'state' => $json->subdivisions[0]->names->en, 'city' => $json->city->names->en); if (empty($return['city'])) { $return['city'] = 'Unknown'; } if (empty($return['state'])) { $return['state'] = 'Unknown'; } $cache->set('geo:' . $ip, $return, 3600); return $return; }
public function __construct() { $this->bootstrap = Bootstrap::getInstance(); $this->import = Import::getInstance(); $this->resolver = Resolver::getInstance(); $dir = BASEPATH . '/bootstrap/sidebars'; foreach ($this->bootstrap->getFiles($dir) as $sidebar) { $subdir = BASEPATH . "/bootstrap/sidebars/{$sidebar}"; $newSidebar = new \stdClass(); $newSidebar->slug = $sidebar; $newSidebar->items = array(); $newSidebar->meta = unserialize(file_get_contents($subdir . '/meta')); foreach ($newSidebar->meta as $key => $widgetRef) { $widget = new \stdClass(); $parts = explode('-', $widgetRef); $ord = end($parts); $type = substr($widgetRef, 0, -1 * strlen('-' . $ord)); $widget->type = $type; $widget->ord = $ord; $widget->meta = unserialize(file_get_contents($subdir . '/' . $widgetRef)); $newSidebar->items[] = $widget; } $this->sidebars[] = $newSidebar; } $baseUrl = get_option('siteurl'); $neutralUrl = Bootstrap::NETURALURL; $this->resolver->fieldSearchReplace($this->sidebars, Bootstrap::NETURALURL, $this->import->baseUrl); $this->process(); }
public function __construct() { $this->bootstrap = Bootstrap::getInstance(); $this->import = Import::getInstance(); $this->resolver = Resolver::getInstance(); foreach ($this->bootstrap->appSettings->wpbootstrap->menus as $menu => $locations) { $dir = BASEPATH . "/bootstrap/menus/{$menu}"; $newMenu = new \stdClass(); $newMenu->slug = $menu; $newMenu->locations = $locations; $newMenu->items = array(); foreach ($this->getFiles($dir) as $file) { $menuItem = new \stdClass(); $menuItem->done = false; $menuItem->id = 0; $menuItem->parentId = 0; $menuItem->slug = $file; $menuItem->menu = unserialize(file_get_contents($dir . '/' . $file)); $newMenu->items[] = $menuItem; } usort($newMenu->items, function ($a, $b) { return (int) $a->menu->menu_order - (int) $b->menu->menu_order; }); $this->menus[] = $newMenu; } $baseUrl = get_option('siteurl'); $neutralUrl = Bootstrap::NETURALURL; $this->resolver->fieldSearchReplace($this->menus, Bootstrap::NETURALURL, $this->import->baseUrl); $this->process(); }
public function export() { $this->bootstrap = Bootstrap::getInstance(); $this->resolver = Resolver::getInstance(); $this->extractMedia = new Extractmedia(); $this->bootstrap->init(); $this->bootstrap->includeWordPress(); $this->mediaIds = array(); $this->baseUrl = get_option('siteurl'); $this->exportSettings(); $this->exportContent(); }
public function provideStorage() { $mysql = Bootstrap::getInstance()->getMysqlPdo(); $postgres = Bootstrap::getInstance()->getPostgresPdo(); $sqlite = Bootstrap::getInstance()->getSqlitePdo(); $mongo = Bootstrap::getInstance()->getMongo(); $redis = Bootstrap::getInstance()->getRedisStorage(); $cassandra = Bootstrap::getInstance()->getCassandraStorage(); $memory = Bootstrap::getInstance()->getMemoryStorage(); /* hack until we can fix "default_scope" dependencies in other tests */ $memory->defaultScope = 'defaultscope1 defaultscope2'; return array(array($memory), array($sqlite), array($mysql), array($postgres), array($mongo), array($redis), array($cassandra)); }
static function isHomepage() { $Dispatcher = Dispatcher::getInstance(); $Bootstrap = Bootstrap::getInstance(); if ($Dispatcher->getControllerName() . '/' . $Dispatcher->getActionName() == $Bootstrap->getDefaultPath()) { return true; } else { if ($Dispatcher->getControllerName() . '/' . $Dispatcher->getActionName() == 'default/index') { return true; } } return false; }
/** @dataProvider provideStorage */ public function testGetClientKey(JwtBearerInterface $storage) { if ($storage instanceof NullStorage) { $this->markTestSkipped('Skipped Storage: ' . $storage->getMessage()); return; } // nonexistant client_id $key = $storage->getClientKey('this-is-not-real', 'nor-is-this'); $this->assertFalse($key); // valid client_id and subject $key = $storage->getClientKey('oauth_test_client', 'test_subject'); $this->assertNotNull($key); $this->assertEquals($key, Bootstrap::getInstance()->getTestPublicKey()); }
public function __construct($calling_file_php) { $this->view = new Zend_View(array("basePath" => dirname($calling_file_php))); // Modifier for the links in the headers. $bibledit_root_folder = Bootstrap::getInstance()->bibledit_root_folder; $file_path = dirname($calling_file_php); $header_path_modifier = ""; $iterations_count = 0; while ($file_path != $bibledit_root_folder && $iterations_count < 10) { $file_path = dirname($file_path); $iterations_count++; $header_path_modifier .= "../"; } $this->view->header_path_modifier = $header_path_modifier; }
/** @dataProvider provideStorage */ public function testSetAccessToken($storage) { if ($storage instanceof NullStorage) { $this->markTestSkipped('Skipped Storage: ' . $storage->getMessage()); return; } if (!$storage instanceof PublicKeyInterface) { // incompatible storage return; } $configDir = Bootstrap::getInstance()->getConfigDir(); $globalPublicKey = file_get_contents($configDir . '/keys/id_rsa.pub'); $globalPrivateKey = file_get_contents($configDir . '/keys/id_rsa'); /* assert values from storage */ $this->assertEquals($storage->getPublicKey(), $globalPublicKey); $this->assertEquals($storage->getPrivateKey(), $globalPrivateKey); }
public function import() { error_reporting(-1); $this->bootstrap = Bootstrap::getInstance(); $this->resolver = Resolver::getInstance(); $this->bootstrap->init(); $this->bootstrap->includeWordPress(); require_once $this->bootstrap->localSettings->wppath . '/wp-admin/includes/image.php'; $this->baseUrl = get_option('siteurl'); $this->uploadDir = wp_upload_dir(); $this->importSettings(); $this->importContent(); // references $this->resolveMetaReferences(); $this->resolvePostReferences(); $this->resolveOptionReferences(); }
public function __construct() { $this->bootstrap = Bootstrap::getInstance(); $dir = BASEPATH . '/bootstrap/taxonomies'; foreach ($this->bootstrap->getFiles($dir) as $subdir) { $taxonomy = new \stdClass(); $taxonomy->slug = $subdir; $taxonomy->terms = array(); foreach ($this->bootstrap->getFiles($dir . '/' . $subdir) as $file) { $term = new \stdClass(); $term->done = false; $term->id = 0; $term->slug = $file; $term->term = unserialize(file_get_contents($dir . '/' . $subdir . '/' . $file)); $taxonomy->terms[] = $term; } $this->taxonomies[] = $taxonomy; } $this->process(); }
public function __construct() { $this->bootstrap = Bootstrap::getInstance(); $this->import = Import::getInstance(); $this->resolver = Resolver::getInstance(); $dir = BASEPATH . '/bootstrap/posts'; foreach ($this->bootstrap->getFiles($dir) as $postType) { foreach ($this->bootstrap->getFiles($dir . '/' . $postType) as $slug) { $newPost = new \stdClass(); $newPost->done = false; $newPost->id = 0; $newPost->parentId = 0; $newPost->slug = $slug; $file = BASEPATH . "/bootstrap/posts/{$postType}/{$slug}"; $newPost->post = unserialize(file_get_contents($file)); $this->posts[] = $newPost; } } $this->resolver->fieldSearchReplace($this->posts, Bootstrap::NETURALURL, $this->import->baseUrl); $this->process(); }
public function testCreatePdoStorageUsingConfig() { $config = array('dsn' => sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir())); $storage = new Pdo($config); $this->assertNotNull($storage->getClientDetails('oauth_test_client')); }
* @version 5.0,0 */ // ------------------------------------------------------------------------ // define the current environment define('ENVIRONMENT', 'development'); //define the url for textstem (assumes the installation is in the root directory) define('TEXTSTEM_URL', '/' . basename(dirname(__FILE__))); //define the installation path (ie path to the folder this file is in). define('INSTALL_PATH', rtrim(dirname(__FILE__), '/\\') . DIRECTORY_SEPARATOR); //define the root path (assumes the INSTALL PATH is in the root). define('ROOT_PATH', rtrim(dirname(INSTALL_PATH), '/\\') . DIRECTORY_SEPARATOR); // define the system. Usually, this is a folder called 'System' in the install folder define('SYSTEM_PATH', INSTALL_PATH . 'System' . DIRECTORY_SEPARATOR); // define the app path. Usually, this is a folder called 'Application' in the install folder define('APP_PATH', INSTALL_PATH . 'Application' . DIRECTORY_SEPARATOR); // define the vendor path. Usually, this is a folder called 'Vendor' in the System folder define('VENDOR_PATH', SYSTEM_PATH . 'Vendor' . DIRECTORY_SEPARATOR); // define the app path. Usually, this is a folder called 'Textstem' in the System folder define('TEXTSTEM_PATH', SYSTEM_PATH . 'Textstem' . DIRECTORY_SEPARATOR); // define the cache path. Usually, this is a folder called 'Cache' in the Application folder define('CACHE_PATH', APP_PATH . 'Cache' . DIRECTORY_SEPARATOR); /** * Load bootstrap */ require_once SYSTEM_PATH . 'Bootstrap.php'; Bootstrap::getInstance()->Initialise(); /** * Start the APP */ Debug::clockIn(); Textstem::getInstance()->handleRequest();
<?php define('ROOT', realpath(dirname(__FILE__) . '/../../')); define('LIB', ROOT . '/_lib'); define('APP', ROOT . '/apps' . dirname($_SERVER['SCRIPT_NAME'])); define('MODELS', ROOT . '/models'); define('CONTROLLERS', APP . '/controllers'); define('VIEWS', APP . '/views'); require_once LIB . '/core/_includes.php'; require_once LIB . '/vendors/doctrine/Doctrine.php'; require_once ROOT . '/configs/env.php'; require_once ROOT . '/configs/lang.php'; require_once ROOT . '/configs/set.php'; $Bootstrap = Bootstrap::getInstance(); $Bootstrap->setDefaultPath('default/index'); $Bootstrap->setEnv(ENV); $Bootstrap->addAutoloadPath(CONTROLLERS); $Bootstrap->addAutoloadPath(CONTROLLERS . '/_components'); $Bootstrap->addAutoloadPath(VIEWS); $Bootstrap->addAutoloadPath(VIEWS . '/_helpers'); $Bootstrap->loadConfigs(ROOT . '/configs'); $Bootstrap->loadConfigs(APP . '/configs'); $Bootstrap->addModelPath(MODELS . '/bases'); $Bootstrap->addModelPath(MODELS); $Bootstrap->setDoctrine(); $Bootstrap->dispatch();
public function __construct() { $this->bootstrap = Bootstrap::getInstance(); }
<?php /* * [ Тестовое задание ] * * Filename : index.php * Date : 10.04.2012 */ define('PATH_APPLICATION', dirname(__FILE__) . '/../application'); define('PATH_ENGINE', dirname(__FILE__) . '/../engine'); require_once PATH_ENGINE . '/Bootstrap.php'; set_error_handler(function ($code, $text, $file, $line) { die("[{$line}] [{$file}] {$text}"); }); Bootstrap::getInstance()->autoload()->run();