コード例 #1
1
ファイル: class-bootstrap.php プロジェクト: arter97/h5ai
 public static function run()
 {
     spl_autoload_register(['Bootstrap', 'autoload']);
     putenv('LANG=en_US.UTF-8');
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     date_default_timezone_set(@date_default_timezone_get());
     session_start();
     $session = new Session($_SESSION);
     $request = new Request($_REQUEST);
     $setup = new Setup($request->query_boolean('refresh', false));
     $context = new Context($session, $request, $setup);
     if ($context->is_api_request()) {
         (new Api($context))->apply();
     } else {
         if ($context->is_info_request()) {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             require __DIR__ . '/pages/info.php';
         } else {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             $fallback_html = (new Fallback($context))->get_html();
             require __DIR__ . '/pages/index.php';
         }
     }
 }
コード例 #2
0
ファイル: listing11.02.php プロジェクト: jabouzi/projet
 function interpret(Context $context)
 {
     if (!is_null($this->val)) {
         $context->replace($this, $this->val);
         $this->val = null;
     }
 }
コード例 #3
0
ファイル: Verify.php プロジェクト: saintho/phpdisk
 /**
  *  获取校验结果
  * @return type
  */
 public static function getVerifyResult()
 {
     $context = new Context();
     $typhoon = new Typhoon();
     if ($typhoon->isValid()) {
         $ssid = $typhoon->_ssid;
         $name = $typhoon->_name;
         $value = $context->get($name, '');
         if ($value != '') {
             if ($typhoon->_request_type == 1) {
                 $ret = Valid::sendVerifyRemoteRequest($ssid, $value, $typhoon->_diff_time);
             } else {
                 $ret = Valid::sendVerifyLocalRequest($ssid, $value);
             }
             self::$_result = Valid::getResult();
             self::$_code = Valid::getCode();
             self::$_details = Valid::getDetails();
         } else {
             self::$_result = 0;
             self::$_code = 'E_VALUEEMPTY_001';
             self::$_details = '验证码不可以为空';
         }
     } else {
         self::$_result = 0;
         self::$_code = 'E_PARAM_001';
         self::$_details = '重要参数传递错误';
     }
     return self::$_result === 1 ? TRUE : FALSE;
 }
コード例 #4
0
 /**
  * @param Context $context
  * @param Request $request
  */
 public function _execute($context, $request)
 {
     controller_ChangeController::setNoCache();
     $generator = form_CaptchaGenerator::getInstance();
     $renew = $request->hasParameter('renew');
     // Set optionnal parameters.
     if ($request->hasParameter('ml')) {
         $generator->setCodeMaxLength(intval($request->getParameter('ml')));
         if ($renew) {
             $generator->setCodeMinLength(intval($request->getParameter('ml')));
         }
     }
     if ($request->hasParameter('iw')) {
         $generator->setWidth(intval($request->getParameter('iw')));
     }
     if ($request->hasParameter('ih')) {
         $generator->setHeight(intval($request->getParameter('ih')));
     }
     if ($request->hasParameter('fs')) {
         $generator->setFontSize(intval($request->getParameter('fs')));
     }
     if ($request->hasParameter('fd')) {
         $generator->setFontDepth(intval($request->getParameter('fd')));
     }
     // Renders the image.
     if ($renew) {
         $generator->generateCode();
     }
     $generator->render($context->getUser()->getAttribute(CAPTCHA_SESSION_KEY));
     return View::NONE;
 }
コード例 #5
0
ファイル: ContextTest.php プロジェクト: superruzafa/rules
 /** @test */
 public function iterator()
 {
     $context = new Context(array('foo' => 'bar'));
     $iterator = $context->getIterator();
     $this->assertInstanceOf('IteratorAggregate', $iterator);
     $iterator->offsetExists('foo');
 }
コード例 #6
0
 /**
  * Запуск периодических задач.
  *
  * Проверяется время последнего запуска, чаще установленного администратором
  * времени запуск производиться не будет (по умолчанию 15 минут).
  */
 public static function on_rpc(Context $ctx)
 {
     $status = "DELAYED";
     $lastrun = $ctx->config->get('modules/cron/lastrun');
     $delay = $ctx->config->get('modules/cron/delay', 15) * 60;
     if (time() >= $lastrun + $delay) {
         $ctx->config->set('modules/cron/lastrun', time());
         $ctx->config->save();
         @set_time_limit(0);
         ob_start();
         try {
             $ctx->registry->broadcast('ru.molinos.cms.cron', array($ctx));
             $status = "OK";
         } catch (Exception $e) {
             Logger::trace($e);
             $status = "ERROR: " . get_class($e) . '; ' . trim($e->getMessage(), '.') . '.';
         }
         ob_end_clean();
     }
     if ($ctx->get('destination')) {
         return $ctx->getRedirect();
     }
     if (!MCMS_CONSOLE) {
         header('Content-Type: text/plain; charset=utf-8');
         die($status);
     }
     die;
 }
コード例 #7
0
 function __construct(Context $context = null)
 {
     if (!$context) {
         $context = new Context('helper', 'phaxsi');
     }
     $this->module = $context->getModule();
 }
コード例 #8
0
ファイル: ContextTest.php プロジェクト: mgldev/coffeetrack
 /** @test */
 public function getSocketShouldNotAddReadListenerForNonReadableSocketType()
 {
     $loop = $this->getMock('React\\EventLoop\\LoopInterface');
     $loop->expects($this->never())->method('addReadStream');
     $context = new Context($loop);
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH);
 }
コード例 #9
0
ファイル: Client.php プロジェクト: CcrisS/PHP-Patterns
 public function killer()
 {
     $secure = new SecureData();
     $context = new Context(new DeleteRecord());
     $secure->removeRecord();
     $context->algorithm($secure->setEntry());
 }
コード例 #10
0
 /**
  * Вывод формы авторизации.
  * @route GET//login
  */
 public static function on_get_login_form(Context $ctx)
 {
     if ($ctx->user->id and !$ctx->get('stay')) {
         return $ctx->getRedirect();
     }
     if (class_exists('APIStream')) {
         APIStream::init($ctx);
     }
     $handler = array('theme' => $ctx->config->get('modules/auth/login_theme'));
     $content = '';
     foreach ((array) $ctx->registry->poll('ru.molinos.cms.page.head', array($ctx, $handler, null), true) as $block) {
         if (!empty($block['result'])) {
             $content .= $block['result'];
         }
     }
     $content .= self::getXML($ctx);
     $xml = html::em('page', array('status' => 401, 'base' => $ctx->url()->getBase($ctx), 'host' => MCMS_HOST_NAME, 'prefix' => os::webpath(MCMS_SITE_FOLDER, 'themes'), 'back' => urlencode(MCMS_REQUEST_URI), 'next' => $ctx->get('destination'), 'api' => APIStream::getPrefix(), 'query' => $ctx->query()), $content);
     if (file_exists($xsl = os::path(MCMS_SITE_FOLDER, 'themes', $handler['theme'], 'templates', 'login.xsl'))) {
         try {
             return xslt::transform($xml, $xsl);
         } catch (Exception $e) {
         }
     }
     return xslt::transform($xml, 'lib/modules/auth/xsl/login.xsl');
 }
コード例 #11
0
 public static function rpc_post_install(Context $ctx)
 {
     $data = $ctx->post;
     if (empty($data['dbtype'])) {
         throw new RuntimeException(t('Вы не выбрали тип БД.'));
     }
     $config = $ctx->config;
     // Выносим секцию main в самое начало.
     $config['main'] = array();
     if ($config->isok()) {
         throw new ForbiddenException(t('Инсталляция невозможна: конфигурационный файл уже есть.'));
     }
     $dsn = self::getDSN($data['dbtype'], $data['db'][$data['dbtype']]);
     if (!empty($data['db']['prefix'])) {
         $dsn['prefix'] = $data['db']['prefix'];
     }
     $config->set('modules/db', $dsn);
     foreach (array('modules/mail/server', 'modules/mail/from', 'main/debug/errors') as $key) {
         if (!empty($data[$key])) {
             $config->set($key, $data[$key]);
         }
     }
     $config->set('modules/files/storage', 'files');
     $config->set('modules/files/ftp', 'ftp');
     $config->set('main/tmpdir', 'tmp');
     $config->set('main/debug/allow', array('127.0.0.1', $_SERVER['REMOTE_ADDR']));
     // Создаём маршрут для главной страницы.
     $config['routes']['localhost/'] = array('title' => 'Molinos CMS', 'theme' => 'example', 'call' => 'BaseRoute::serve');
     // Проверим соединение с БД.
     $pdo = Database::connect($config->get('modules/db'));
     // Подключились, можно сохранять конфиг.
     $config->save();
     $ctx->redirect('admin/system/reload?destination=admin/system/settings');
 }
コード例 #12
0
ファイル: loader_tags.php プロジェクト: idlesign/dja
 /**
  * @param Context $context
  *
  * @return mixed
  */
 public function render($context)
 {
     /** @var $block_context BlockContext */
     $block_context = null;
     if (isset($context->render_context[BLOCK_CONTEXT_KEY])) {
         $block_context = $context->render_context[BLOCK_CONTEXT_KEY];
     }
     $context->push();
     if ($block_context === null) {
         $context['block'] = $this;
         $result = $this->nodelist->render($context);
     } else {
         $push = $block = $block_context->pop($this->name);
         if ($block === null) {
             $block = $this;
         }
         // Create new block so we can store context without thread-safety issues.
         $block = new BlockNode($block->name, $block->nodelist);
         $block->context = $context;
         $context['block'] = $block;
         $result = $block->nodelist->render($context);
         if ($push !== null) {
             $block_context->push($this->name, $push);
         }
     }
     $context->pop();
     return $result;
 }
コード例 #13
0
 /**
  * Method called after the module has been setup, but before the action
  * is executed.
  * @param Context $context
  */
 function controllerStart($context)
 {
     if (!$this->config['enabled']) {
         return;
     }
     #Execute this only when it is a page controller and not when
     #it is a block, layout or some other type of controller
     if ($context->getType() != 'controller') {
         return;
     }
     #Put the action in lowercase to avoid it not being detected due to case
     $action = strtolower($context->getAction());
     #Checks for user credentials and executes in case they are not valid
     if (!$this->isAuthorized($action)) {
         $this->callDenyFunction($action);
         $view_type = $context->getViewType();
         switch ($view_type) {
             case 'html':
             case 'process':
             case 'mail':
                 $this->loginRedirect();
                 break;
             case 'json':
             case 'feed':
             default:
                 exit;
         }
         exit;
     }
     $this->started = true;
 }
コード例 #14
0
ファイル: MoveTest.php プロジェクト: shabbirvividads/magento2
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->scheduledStructureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock);
     $this->move = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Reader\\Move');
 }
コード例 #15
0
ファイル: file.php プロジェクト: srph/playground
 public function execute()
 {
     $context = new Context();
     $context->execute(function () {
         array_pop($this->tasks);
         echo count($this->tasks);
     });
 }
コード例 #16
0
 function __construct(Context $context)
 {
     $this->load = new Loader($context);
     $this->db = new DatabaseProxy($this->load);
     $this->context = $context;
     $this->view = new ShellView($context);
     $this->args = array_merge((array) $this->args, (array) $context->getArguments());
 }
コード例 #17
0
ファイル: client.php プロジェクト: luisOO/design-patterns
 /**
  * Main program
  */
 public static function main()
 {
     $context = new Context();
     $context->request();
     $context->request();
     $context->request();
     $context = null;
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  *
  * @param $path
  */
 public function load($path)
 {
     $tests = $this->getTests($path);
     foreach ($tests as $test) {
         $this->context->setFile($test);
         include $test;
     }
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 public function holdsFor(Context $context)
 {
     if (!$context->has($this->key)) {
         return false;
     }
     $argument = $context->get($this->key);
     return $this->operator->appliesTo($argument);
 }
コード例 #20
0
 /**
  * Initializes controller
  * @param Context $context
  * @param View $view
  */
 function __construct(Context $context, View $view)
 {
     $this->load = new Loader($context);
     $this->context = $context;
     $this->view = $view;
     $this->args = array_merge((array) $this->args, (array) $context->getArguments());
     $base_module = $context->getBaseModuleName();
     $this->config = isset(AppConfig::$modules[$base_module]) ? AppConfig::$modules[$base_module] : array();
 }
コード例 #21
0
 /**
  * Initializes the Controller instance and selects the appropiate View
  * @param Context $context
  */
 function __construct(Context $context)
 {
     $type = $context->getViewType();
     $class_name = $type . 'view';
     $view = new $class_name($context);
     parent::__construct($context, $view);
     $this->db = new DatabaseProxy($this->load);
     $this->helper = new HelperLoader($this->load);
 }
コード例 #22
0
ファイル: VariableNode.php プロジェクト: lopo/phpsass
 /**
  * Parse this node.
  * Sets the variable in the current context.
  *
  * @param Context $context the context in which this node is parsed
  * @return array the parsed node - an empty array
  */
 public function parse($context)
 {
     if (!$this->isDefault || !$context->hasVariable($this->name)) {
         $context->setVariable($this->name, $this->evaluate($this->value, $context));
     }
     $this->parseChildren($context);
     // Parse any warnings
     return [];
 }
コード例 #23
0
ファイル: ui.php プロジェクト: fruition-sciences/phpfw
 /**
  * Use the router to generate a new URL to this website.
  * This allows generating a link using a 'routeName' rather than assuming that
  * you know the actual format of the path.
  *
  * @param String $routeName the routing name to use (as defined in routes.yaml)
  * @param Array $data data to use as variables for the route
  * @param Boolean $useCurrentParams if true, uses data from current route and
  *        then overrides with params given by the $data parameter.
  * @return Href
  */
 public function generateURL($routeName, $data = array(), $useCurrentParams = false)
 {
     $router = $this->ctx->getRouter();
     if ($useCurrentParams) {
         $route = $router->getMatchedRoute();
         $data = array_merge($route->params, $data);
     }
     $url = '/' . $router->generate($routeName, $data);
     return new Href($url);
 }
コード例 #24
0
 public static function rpc_get_default(Context $ctx)
 {
     $user = Node::load(array('class' => 'user', 'deleted' => 0, 'published' => 1, 'id' => $ctx->get('id')), $ctx->db);
     $email = $user ? $user->email : '*****@*****.**';
     $gurl = 'http://www.gravatar.com/avatar/' . md5($email);
     if (null !== ($s = $ctx->get('s'))) {
         $gurl .= '?s=' . intval($s) . '&r=x';
     }
     return new Redirect($gurl);
 }
コード例 #25
0
 final function __construct(Context $context)
 {
     parent::__construct($this->driver_name);
     $this->load = new Loader($context);
     $this->db = new DatabaseProxy($this->load);
     $this->session = new Session($context->getModule());
     $this->plugin = $this->load->service('plugin');
     $this->table_name = strtolower($context->getAction());
     $this->id_column = $this->table_name . '_id';
 }
コード例 #26
0
 /**
  * Открепление файлов от ноды.
  */
 public static function on_post_detach(Context $ctx)
 {
     if (is_array($ids = $ctx->post('remove'))) {
         $ctx->db->beginTransaction();
         $params = array();
         Node::load($ctx->get('id'), $ctx->db)->touch(ACL::UPDATE)->onSave('DELETE FROM `node__rel` WHERE `tid` = %ID% AND `key` IS NULL AND `nid` ' . sql::in($ids, $params), $params)->save();
         $ctx->db->commit();
     }
     return $ctx->getRedirect();
 }
コード例 #27
0
ファイル: BundledAsset.php プロジェクト: chh/pipe
 function getBody()
 {
     if (null === $this->body) {
         $body = parent::getBody();
         $bundleProcessors = $this->environment->bundleProcessors->all($this->getContentType());
         $context = new Context($this->environment);
         $this->body = $context->evaluate($this->path, array("processors" => $bundleProcessors, "data" => $body));
     }
     return $this->body;
 }
コード例 #28
0
 public static function on_get_delete(Context $ctx)
 {
     $pages = '';
     foreach ((array) $ctx->get('check') as $id) {
         $pages .= html::em('page', urldecode($id));
     }
     if (empty($pages)) {
         throw new ForbiddenException(t('Не выбраны пути для удаления.'));
     }
     return html::wrap('content', $pages, array('name' => 'route-delete'));
 }
コード例 #29
0
ファイル: class.pollrpc.php プロジェクト: umonkey/molinos-cms
 /**
  * Возвращает результаты по опросу.
  */
 public static function on_get_results(Context $ctx)
 {
     $output = '';
     $id = $ctx->get('id');
     $data = $ctx->db->getResultsKV("option", "count", "SELECT `option`, COUNT(*) AS `count` FROM `node__poll` WHERE `nid` = ? GROUP BY `option`", array($ctx->get('id')));
     foreach ($data as $k => $v) {
         $output .= html::em('option', array('count' => $v), html::cdata($k));
     }
     $voted = $ctx->user->id ? $ctx->db->fetch("SELECT COUNT(*) FROM `node__poll` WHERE `nid` = ? AND `uid` = ?", array($id, $ctx->user->id)) : $ctx->db->fetch("SELECT COUNT(*) FROM `node__poll` WHERE `nid` = ? AND `ip` = ?", array($id, $_SERVER['REMOTE_ADDR']));
     return new Response(html::em('results', array('voted' => (bool) $voted), $output), 'text/xml');
 }
コード例 #30
0
 public static function on_download(Context $ctx)
 {
     zip::fromFolder($zipFile = os::path($ctx->config->getPath('main/tmpdir'), 'backup.zip'), MCMS_ROOT, realpath($ctx->config->getPath('main/tmpdir')));
     $filename = $ctx->host() . '-' . date('YmdHi', time() - date('Z', time())) . '.zip';
     header('Content-Type: application/zip');
     header('Content-Length: ' . filesize($zipFile));
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     readfile($zipFile);
     unlink($zipFile);
     die;
 }