/** * {@inheritdoc} */ public function run(Core $app, Http $answer) : Answer { # Create the render and set some attributes $render = new Html($app->getCore() . 'views/welcome.php'); # Returns the answer return $answer->setData($render->run($app)); }
private function savePropertiesToLog() { $logConfig = Core::getInstance()->getConfig()['log']; if ($logConfig['saveToDB'] and $logConfig['saveResponse']) { DBLog::getInstance()->save($this->getPropertiesForLog()); } }
public function createKeys($private_key_bits = 1024) { $new_key_pair = openssl_pkey_new(array("private_key_bits" => $private_key_bits, "private_key_type" => OPENSSL_KEYTYPE_RSA)); openssl_pkey_export($new_key_pair, $private_key_pem); $details = openssl_pkey_get_details($new_key_pair); $public_key_pem = $details['key']; $config = Core::getInstance()->getConfig()['keys']; $publicPemFile = $config['ours']['public']; return file_put_contents($this->privatePemFile, $private_key_pem) && file_put_contents($publicPemFile, $public_key_pem); }
private function __construct() { /** @var $core Core */ $core = Core::getInstance(); $config = $core->getConfig(); $this->dsn = $config['db']['dsn']; $this->username = $config['db']['username']; $this->password = $config['db']['password']; $this->properties = []; }
public static function factorize() { self::$loader = new \Twig_Loader_Filesystem(base_path() . '/views'); self::$twig = new \Twig_Environment(self::$loader, Core::config('twig')); //loading functions self::$twig->addFunction('sanitized_current_url', new \Twig_Function_Function('sanitized_current_url')); self::$twig->addFunction('base_path', new \Twig_Function_Function('base_path')); self::$twig->addFunction('cache_path', new \Twig_Function_Function('cache_path')); self::$twig->addFunction('base_url', new \Twig_Function_Function('base_url')); self::$twig->addFunction('plugin_url', new \Twig_Function_Function('plugin_url')); self::$twig->addFunction('assets_url', new \Twig_Function_Function('assets_url')); self::$twig->addFunction('dd', new \Twig_Function_Function('dd')); self::$twig->addFunction('posts_url', new \Twig_Function_Function('posts_url')); self::$twig->addFunction('current_url', new \Twig_Function_Function('current_url')); return self::$twig; }
<?php /** * Created by PhpStorm. * User: cherepakha * Date: 06.02.15 * Time: 12:14 */ spl_autoload_extensions(".php"); spl_autoload_register(); $config = __DIR__ . '/config/config.php'; use core\Core; use core\signature\Signature; Core::getInstance()->setConfig($config); //var_dump($_SERVER); $var = $_SERVER['HTTP_HOST'] . '/index.php?' . $_SERVER['QUERY_STRING']; $sign = Signature::getInstance()->sign($var); echo urlencode($sign);
public static function editDatabase($params) { if (!\mod\user\Main::userIsLoggedIn() || (!\mod\user\Main::userBelongsToGroup('Admin') && !\mod\arkeogis\ArkeoGIS::isDatabaseOwner((int) $params['id'], \mod\user\Main::getUserId($_SESSION['login'])) || !$params['id'])) { return false; } $acceptedParams = array('name', 'declared_modification', 'issn', 'scale_resolution', 'type', 'geographical_limit', 'geographical_limit_de', 'description', 'description_de', 'published'); $dbParans = array(); while (list($k, $v) = each($params)) { if (in_array($k, $acceptedParams)) { $dbParams[$k] = $v; } } if (isset($dbParams['declared_modification']) && empty($dbParams['declared_modification'])) { unset($dbParams['declared_modification']); } if (isset($dbParams['published'])) { $dbParams['published'] = $dbParams['published'] == 0 ? 'f' : 't'; } if (!\mod\user\Main::userBelongsToGroup('Admin')) { unset($dbParams['published']); } $owner_id = \core\Core::$db->fetchOne('SELECT uid FROM "ch_user" WHERE full_name = ?', array($params['author'])); if ($owner_id) { $dbParams['owner_id'] = $owner_id; } \mod\arkeogis\ArkeoGIS::updateDatabase((int) $params['id'], $dbParams); \core\Core::log($dbParams); return true; }
/** * Get the device component of this useragent as pretty HTML. * * @return string */ private function _getAsHTMLDevice(){ // Piwik can provide pretty icons! $icon = (\Core::IsComponentAvailable('piwik-analytics') && $this->device_maker) ? 'assets/images/brand/' . $this->device_maker . '.gif' : null; $title = ''; $text = ''; $out = ''; $class = 'useragent-pretty-device'; if($this->device_maker && $this->device_name){ $title .= $this->device_maker . ' ' . $this->device_name; $text .= $this->device_name; } elseif($this->device_maker){ $title .= $this->device_maker; $text .= $this->device_maker; } // Start compiling this attribute together. $out .= '<span class="' . $class . '" title="' . $title . '">'; if($icon){ $out .= '<img src="' . \Core\resolve_asset($icon) . '"/> '; } $out .= $text; $out .= '</span>'; return $out; }
<?php require_once './config.php'; use Core\Core; $Core = new Core(); $loader = new Twig_Loader_Filesystem('./templates'); $twig = new Twig_Environment($loader, array('cache' => './tmp', 'debug' => true)); #echo "<pre>"; #var_export($Core->unfiltered()); #echo "</pre>"; d($Core->unfiltered()); #echo $twig->render('page.html.twig', array('data' => $Core->getData(), 'titles' => $Core->getTitles(), 'dates' => $dates));
/** * {@inheritdoc} */ public function run(Core $app, Http $answer) : Answer { # Set a default error $answer->setStatus(500); $data['error'] = $data['title'] = 'Exception'; # Create the render and set some attributes $render = new Html($app->getCore() . 'views/exception.php'); if ($app->getException() !== null) { # Core custom exception only if ($app->getException() instanceof \Core\HttpException) { $answer->setStatus($app->getException()->getStatus()); } if (defined('insight')) { # Get the detailed exception $data['error'] = sprintf("%s\n\n# %s(%s)\n%s", $app->getException()->getMessage(), $app->getException()->getFile(), $app->getException()->getLine(), str_replace('Stack trace:', '', $app->getException()->getTraceAsString())); } else { # Get an user acceptable error message $data['error'] = $app->getException()->getMessage(); } } # Returns the answer return $answer->setData($render->run($app, $data)); }
public function checkRequest() { $config = Core::getInstance()->getConfig(); if ($this->_remoteAddr != $config['ps']['address']) { Error::getInstance()->сatchError('WRONG_SOURCE'); } else { $this->checkSign(); $this->checkRequestByAction(); } }
/** * Retrieve the messages and optionally clear the message stack. * * @param bool $returnSorted Set to true to sort the message by message type * @param bool $clearStack Set to false to NOT clear the message stack * * @return array */ function get_messages($returnSorted = FALSE, $clearStack = TRUE){ return \Core::GetMessages($returnSorted, $clearStack); }
/** * 获取请求类 * @return Core\Request */ function req() { return \Core\Core::getInstance()->getRequest(); }