Exemplo n.º 1
0
 private function requestData($latitude, $longitude, $timestamp = false, $exclusions = false)
 {
     $validUnits = array('auto', 'us', 'si', 'ca', 'uk');
     if (in_array($this->units, $validUnits)) {
         $request_url = self::API_ENDPOINT . $this->api_key . '/' . $latitude . ',' . $longitude . ($timestamp ? ',' . $timestamp : '') . '?units=' . $this->units . '&lang=' . $this->language . ($exclusions ? '&exclude=' . $exclusions : '');
         /**
          * Use Buffer to cache API-requests if initialized
          * (if not, just get the latest data)
          *
          * More info: http://git.io/FoO2Qw
          */
         if (class_exists('Buffer')) {
             $cache = new Buffer();
             $content = $cache->data($request_url);
         } else {
             $content = file_get_contents($request_url);
         }
     } else {
         return false;
     }
     if (!empty($content)) {
         return json_decode($content);
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $Buffer = new Func('Buffer', function () {
         $self = new Buffer();
         $self->init(func_get_args());
         return $self;
     });
     $Buffer->set('prototype', Buffer::$protoObject);
     $Buffer->setMethods(Buffer::$classMethods, true, false, true);
     return $Buffer;
 }
Exemplo n.º 3
0
 /** @test */
 public function loopShouldSendQueuedMessages()
 {
     $writeListener = function () {
     };
     $loop = $this->getMock('React\\EventLoop\\LoopInterface');
     $loop->expects($this->once())->method('addWriteStream')->with($this->isType('integer'), $writeListener);
     $socket = $this->getMockBuilder('ZMQSocket')->disableOriginalConstructor()->getMock();
     $socket->expects($this->at(0))->method('sendmulti')->with(array('foo'), \ZMQ::MODE_DONTWAIT)->will($this->returnSelf());
     $socket->expects($this->at(1))->method('sendmulti')->with(array('bar'), \ZMQ::MODE_DONTWAIT)->will($this->returnSelf());
     $buffer = new Buffer($socket, 42, $loop, $writeListener);
     $buffer->send('foo');
     $buffer->send('bar');
     $buffer->handleWriteEvent();
 }
Exemplo n.º 4
0
 protected function _is_display()
 {
     $user = Loader::get_user();
     $access_zone = config(URL_AP, 'access', 'zone');
     $access_users = (array) config(URL_AP, 'access', 'user');
     $access_groups = (array) config(URL_AP, 'access', 'group');
     $controller_name = Buffer::get(URL_CONTROLLER);
     $controller_zone = config(URL_CONTROLLER, $controller_name, 'zone');
     $permissions = config(URL_AP, 'access', $controller_name, 'permissions') | config(URL_AP, 'access', 'permissions');
     $path_url = get_path_url();
     //Попытка доступа в области закрытые для посещения?
     if ($controller_zone == Z_CLOSED or $access_zone == Z_CLOSED) {
         return FALSE;
     }
     if ($access_zone != Z_PUBLIC and $user->is_visitor()) {
         return FALSE;
     }
     //Проверяем не заблокирован ли IP
     if (config(URL_AP, 'access', 'check_blocked_ip')) {
         Security::check_access_ip();
     }
     //разрешён ли вход этому типу пользователей?
     if (!in_array(User::T_ALL, $access_users) and !empty($access_users) and !in_array($user->get_type(), $access_users)) {
         return FALSE;
     }
     //Состоит ли пользователь в нужных для доступа группах?
     if (!$user->is_groups($access_groups)) {
         return FALSE;
     }
     //Проверка прав доступа при входе в закрытую зону сайта
     if ((bool) $permissions === TRUE and ($controller_zone == Z_PRIVATE or $access_zone == Z_PRIVATE) and !($user->check_permission($path_url) & $permissions)) {
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 5
0
 public function browse($opt = NULL)
 {
     $interval = 1;
     $type = 'created';
     Builder::add_meta('robots', 'noindex', TRUE);
     Builder::add_css('pages/frontend-browse');
     Builder::set_title(get_string('pages', 'articles-browse') . ' — ' . get_string('url_naming', $type));
     if (!empty($opt)) {
         $type = reset($opt);
         $url_interval = next($opt);
         $interval = $url_interval === FALSE ? 1 : intval($url_interval);
     }
     $articles_model = $this->model('articles_model');
     $header = array();
     $header['type_list'] = $articles_model->get_type_list();
     $header['current'] = $type;
     $header = $this->view('article_types', $header, TRUE);
     $content = array();
     $content['data_list'] = $articles_model->get_articles_list($interval, $type);
     $content['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD) . '/' . $type), 'interval' => $articles_model->get_interval($type), 'selected' => $interval);
     if (empty($content['data_list'])) {
         throw new Exception_wx(4040004, $type, 'none');
     }
     $content = $this->view('article_list', $content, TRUE);
     $nav = array();
     $nav[get_string('url_naming', 'articles')] = 'articles/browse';
     $nav[get_string('url_naming', $type)] = 'articles/browse/' . $type;
     $page = array();
     $page['nav'] =& $nav;
     $page['submenu'] =& $header;
     $page['content'] =& $content;
     $this->view('frontend/frontend', $page);
 }
Exemplo n.º 6
0
 /**
  * Outputs a child template. Pass the template name (with extension) and
  * an associative array context of variables to be passed to the child.
  * 
  * @param string The filename of the template, with extension, relative to AssertiveTemplate paths.
  * @param array The associative array of context the child template expects.
  * @return boolean Returns true on success.
  */
 public static function draw($template, $context)
 {
     Buffer::to($body);
     $context = self::includeTemplate($template, $context);
     Buffer::end();
     if (empty(self::$parentStack)) {
         echo $body;
         return true;
     } else {
         if (!isset($context['body'])) {
             $context['body'] = $body;
         }
         while ($parent = array_pop(self::$parentStack)) {
             try {
                 $parentInputs = self::getInputs($parent, 'Layout');
             } catch (RecessFrameworkException $e) {
                 //				if(RecessConf::$mode == RecessConf::DEVELOPMENT) {
                 $trace = array_pop(self::$debugTraces);
                 throw new RecessErrorException('Extended layout does not exist.', 0, 0, $trace[0]['file'], $trace[0]['line'], $trace[0]['args']);
                 //				} else {
                 //					throw $e;
                 //				}
             }
             $context = array_intersect_key($context, $parentInputs);
             $context = self::includeTemplate($parent, $context);
         }
         //		if(RecessConf::$mode == RecessConf::DEVELOPMENT) {
         array_pop(self::$debugTraces);
         //		}
         return true;
     }
 }
Exemplo n.º 7
0
 /**
  * Bootstrap the application and
  * call the other bootstrap classes
  * from the projects (if they exist)
  *
  * @return self
  */
 public function bootstrap($environment = Application::ENVIRONMENT_WEB)
 {
     static::$environment = $environment;
     // Setup application
     $this->setup();
     try {
         Buffer::start();
         // Call own bootstrap
         (new Bootstrap($this))->autoCall();
         // Call bootstrap of active project
         $project = ProjectManager::getActiveProject();
         if ($project) {
             // Save it in case for further use
             $bootstrap = $project->bootstrap($this);
         }
     } catch (\Exception $err) {
         switch (static::$environment) {
             case Application::ENVIRONMENT_WEB:
                 self::renderException(array($err));
                 break;
             case Application::ENVIRONMENT_CMD:
                 throw $err;
                 break;
         }
     }
     return $this;
 }
Exemplo n.º 8
0
 public function newAction()
 {
     $this->haveAccess();
     $O_categoryMapper = new CategoryMapper();
     $O_category = $O_categoryMapper->findAll();
     Buffer::flushBuffer('label/new', array('category' => $O_category));
 }
Exemplo n.º 9
0
 public function execute()
 {
     if (Session::get_state() != Session::ST_LIFE) {
         self::set_client_command('refresh', array('url' => 'self'));
         self::set_result(FALSE);
         return;
     }
     $additionally = Buffer::get(Identification_strategy::USER_TYPE) == User::T_ALL ? '' : 'AND `type` = "' . Buffer::get(Identification_strategy::USER_TYPE) . '"';
     $pass_hash_lib = Loader::get_library('pass_hash');
     $captcha_lib = Loader::get_library('captcha');
     $login = db::escape_string($this->login);
     $row = db::row(self::Q_GET_USER_BY_NAME, array('%login' => $login, '%additionally' => $additionally));
     $this->remember = (bool) $this->remember;
     if (empty($row)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введённый логин - не существует!');
     }
     if (!$captcha_lib->check($this->captcha)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный проверочный код!');
     }
     if (!$pass_hash_lib->check_password($row['password'], $this->password)) {
         Security::set_ip_violation();
         throw new Command_exception(NULL, 'Введён неправильный пароль!');
     }
     //SELECT DATA_FREE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='db_test' AND TABLE_NAME = 'log_error'
     Session::set_user($row['id'], $this->remember);
     $user = Loader::get_user();
     $secret_key = $user->get_module('secret_key')->regenerate_secret_key();
     self::set_client_command('set_secret_key', array('secretKey' => $secret_key));
     self::set_client_command('refresh', array('url' => 'self'));
 }
Exemplo n.º 10
0
 public static function set_output($data, $to_start = FALSE)
 {
     if ($to_start) {
         self::$__final_output = $data . self::$__final_output;
         return;
     }
     self::$__final_output .= $data;
 }
Exemplo n.º 11
0
 public function editAction($I_id)
 {
     // On vérifie si l'utilisateur connecté est bien un admin
     $this->haveAccess();
     $O_profileMapper = new ProfileMapper();
     $O_profile = $O_profileMapper->findById($I_id);
     Buffer::flushBuffer('profile/edit', array('profile' => $O_profile));
 }
Exemplo n.º 12
0
 protected function _command()
 {
     Buffer::set('command', self::COMMAND, 'post');
     Buffer::set('action', self::ACTION, 'post');
     require_once BASEPATH . 'strategies/commands.php';
     $class_name = 'Commands_strategy';
     $command = new $class_name();
     $command->execute();
 }
Exemplo n.º 13
0
 public function userchecklistAction($I_pageNumber)
 {
     $O_checkMapper = new CheckMapper();
     $O_pagination = new Pagination($O_checkMapper);
     $A_limit = $O_pagination->paginate($I_pageNumber);
     $I_nbPage = $A_limit['nbPage'];
     $A_checks = $O_checkMapper->findByUserPerPage($A_limit);
     Buffer::flushBuffer('check/userchecklist', array('checks' => $A_checks, 'nbPage' => $I_nbPage, 'pageNumber' => $I_pageNumber));
 }
Exemplo n.º 14
0
 public static function check_signature($client_sig)
 {
     $user = Loader::get_user();
     if (!$client_sig) {
         return FALSE;
     }
     if (!$user->get_module(User::M_SECRET_KEY)->check_secret_key()) {
         $user->get_module(User::M_SECRET_KEY)->unset_secret_key();
         Session::destroy(Session::get_sid(), Session::ST_INCORRECT);
         return FALSE;
     }
     //Создаём серверную сигнатуру
     //1. получаем все параметры и удаляем параметр с сигнатурой
     $all_params = Buffer::get_post();
     unset($all_params['sig']);
     $elements_sig = array();
     //2. извлекаем значения из пришедших параметров в обязательный список параметров на серврере
     $params = config('web', 'sig_params');
     foreach ($params as $param) {
         //некоторые параметрый дублируем в ручную, по тем правилам, по которомы они дложны были создаваться на клиенте
         switch ($param) {
             case Session::COOKIE_ID:
                 $elements_sig[$param] = Session::get_sid();
                 break;
             case 'location':
                 $elements_sig[$param] = get_full_url();
                 $elements_sig[$param] = str_replace('/www.', '/', $elements_sig[$param]);
                 break;
             default:
                 $elements_sig[$param] = isset($all_params[$param]) ? $all_params[$param] : '';
         }
         if (isset($all_params[$param])) {
             unset($all_params[$param]);
         }
     }
     //Если в запросе остались какие-то параметры то добавляем их в конец массива
     if (!empty($all_params)) {
         $elements_sig = array_merge($elements_sig, $all_params);
     }
     //3. получаем секретный ключ текущего пользователя
     $elements_sig[self::NAME_SECRET_KEY] = $user->get_secret_key();
     //4. Сортируем и собираем в строку элементы запроса
     $server_sig = array();
     ksort($elements_sig);
     foreach ($elements_sig as $key => $value) {
         $server_sig[] = $key . '=' . $value;
     }
     //5. Формируем сигнатуру сервера
     $server_sig = md5(implode('&', $server_sig));
     //6. Сравниваем результаты
     if ($server_sig == $client_sig) {
         return TRUE;
     }
     return FALSE;
 }
Exemplo n.º 15
0
/**
 * Created by JetBrains PhpStorm.
 * User: Администратор
 * Date: 01.07.14
 * Time: 1:56
 * To change this template use File | Settings | File Templates.
 */
function menu__left(array $options)
{
    $header = '';
    $body = '';
    $selected = FALSE;
    if (!empty($options['logo'])) {
        $logo =& $options['logo'];
        $logo_img = base_url($logo['image']);
        $header = <<<EOT
        <header class="ml-logo-header">
        <img class="ml-logo" src="{$logo_img}" alt="logo" width="100%" /><h2 class="color-1">{$logo['title']}</h2><h5>{$logo['subtitle']}</h5>
        </header>
EOT;
    }
    $segment_url = Buffer::get(URL_CONTROLLER);
    $full_segment_url = Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD);
    if (!isset($options['items'])) {
        return '';
    }
    foreach ($options['items'] as $section => $items) {
        $body .= "<section><header class=\"ml-section-header\">{$section}</header>";
        foreach ($items as $name => $link) {
            $class = 'ml-item';
            if (empty($link)) {
                $link = $segment_url;
            }
            if (!$selected and strpos($link, $segment_url) !== FALSE) {
                $selected = TRUE;
                $class = 'ml-selected';
            }
            if (strpos($link, $full_segment_url) !== FALSE) {
                $selected = TRUE;
                $body = str_replace('ml-selected', 'ml-item', $body);
                $class = 'ml-selected';
            }
            if (isset($options['noindex']) and in_array($name, $options['noindex'])) {
                $body .= '<noindex><a class="' . $class . '" href="' . base_url($link) . '">' . $name . '</a></noindex>';
            } else {
                $body .= '<a class="' . $class . '" href="' . base_url($link) . '">' . $name . '</a>';
            }
        }
        $body .= '</section>';
    }
    $html = <<<EOT
    <menu class="menu-left">
        <header>
            {$header}
        </header>
        <br />
    {$body}
    </menu>
EOT;
    return $html;
}
Exemplo n.º 16
0
 public function paginateAction($I_pageNumber)
 {
     // On vérifie si l'utilisateur connecté est bien un admin
     $this->haveAccess();
     $O_inspectorMapper = new InspectorMapper();
     $O_pagination = new Pagination($O_inspectorMapper);
     $A_limit = $O_pagination->paginate($I_pageNumber);
     $I_nbPage = $A_limit['nbPage'];
     $A_inspectors = $O_inspectorMapper->findPerPage($A_limit);
     Buffer::flushBuffer('inspector/list', array('inspector' => $A_inspectors, 'nbPage' => $I_nbPage, 'pageNumber' => $I_pageNumber));
 }
Exemplo n.º 17
0
 function testPrepend()
 {
     $original = 'Original';
     $prepend = 'Prepend';
     $block = new HtmlBlock($original);
     Buffer::prependTo($block);
     echo $prepend;
     Buffer::end();
     $this->assertType('Block', $block);
     $this->assertEquals($prepend . $original, (string) $block);
 }
Exemplo n.º 18
0
 /**
  * Get the string representation of the ListBlock.
  * @see recess/recess/recess/framework/helpers/blocks/Block#__toString()
  */
 function __toString()
 {
     try {
         Buffer::to($block);
         $this->draw();
         Buffer::end();
         return (string) $block;
     } catch (Exception $e) {
         die($e);
     }
 }
Exemplo n.º 19
0
 public function execute()
 {
     $ap_name = Buffer::get(URL_AP);
     $controller_name = Buffer::get(URL_CONTROLLER);
     $query_param = Buffer::get(self::QUERY_PARAM, 'post');
     $command = Buffer::get('command', 'post');
     $client_format = Buffer::get('format', 'post');
     $action = Buffer::get('action', 'post');
     $access_zone = config(URL_AP, 'access', 'zone');
     $server_format = config('settings', 'web_format');
     if ($client_format != $server_format) {
         throw new Exception_wx(4060002, $client_format);
     }
     $command = Security::sanitize_string($command);
     $action = Security::sanitize_string($action);
     $command_path = APPPATH . 'commands/' . "{$ap_name}/{$command}" . EXT;
     if (!file_exists($command_path)) {
         $command_path = APPPATH . "modules/{$ap_name}/{$controller_name}/commands/{$command}" . EXT;
     }
     if (!file_exists($command_path)) {
         throw new Exception_wx(4040000, $command_path);
     }
     if ($access_zone != Z_PUBLIC and !Security::check_signature(Buffer::get_post('sig'))) {
         throw new Exception_wx(4030001);
     }
     include_once $command_path;
     if (!class_exists($action)) {
         throw new Exception_wx(4040002, $command_path, $action);
     }
     $query_param = Format::converter($query_param, $server_format, TRUE);
     $command_object = new $action($query_param);
     if (!is_a($command_object, self::COMMAND_CLASS)) {
         throw new Exception_wx(5000002, $command_path, $command_object);
     }
     $command_object->set_module(Buffer::get(URL_CONTROLLER));
     try {
         $command_object->execute();
     } catch (Command_exception $exc) {
         Command::set_result(FALSE);
         $message =& $exc->client_message;
         if (!empty($message)) {
             $options = array('message' => $message, 'type' => 'error');
             Command::set_client_command('show_message', $options);
         }
         Log::log_error($exc, 'command_exception');
         $this->_to_client();
     }
     if (!Command::isset_result()) {
         Command::set_result(TRUE);
     }
     $this->_to_client();
 }
Exemplo n.º 20
0
        }
        return "<img {$alt} src=\"{$link}\" {$class} />";
    }
}
//Deprecated
if (!function_exists('article_img')) {
    function article_img($img_name, $class = '', $alt = '')
    {
        $base = '/modules/images/';
        $base .= Buffer::get(URL_CONTROLLER) . '/articles_data/' . Buffer::get(ARTICLE_ID) . '/';
        $link = base_url($base . $img_name);
        if ($class) {
            $class = 'class="' . $class . '"';
Exemplo n.º 21
0
 /**
  * @inheritdoc
  */
 public function flush()
 {
     $flushed = false;
     if ($this->handler) {
         try {
             $flushed = $this->handler->handleBatch($this->metrics);
         } catch (\Exception $e) {
             // @codeCoverageIgnoreStart
             if ($this->logger) {
                 $this->logger->error('An error occurred while flush batch of metrics', ['exception' => $e, 'batch_size' => count($this->metrics)]);
             }
             // @codeCoverageIgnoreEnd
         }
     }
     return $flushed && parent::flush();
 }
Exemplo n.º 22
0
 public function log($opt = array())
 {
     if (empty($opt)) {
         $model = $this->model('error_model');
     } else {
         $model = $this->model('cron_model');
     }
     Builder::add_css('pages/backend-error_list');
     $current_interval = 1;
     if (!empty($opt)) {
         $current_interval = intval(reset($opt));
     }
     $contents['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD), TRUE), 'interval' => $model->get_interval(), 'selected' => $current_interval);
     $contents['info_list'] = $model->get_list($current_interval);
     $page = array();
     $page['content'] = $this->view('system_browser', $contents, TRUE);
     $this->view('backend/backend', $page);
 }
Exemplo n.º 23
0
 public static function &get_controller($name)
 {
     $class_name = ucfirst($name);
     if (array_key_exists($class_name, self::$_controller_list)) {
         return self::$_controller_list[$class_name];
     }
     $ap_name = Buffer::get(URL_AP);
     $path = PATH_MODULES . "{$ap_name}/{$name}/controllers/{$name}" . EXT;
     if (!file_exists($path)) {
         throw new Exception_wx(4040000, $path);
     }
     include_once $path;
     if (!class_exists($class_name)) {
         throw new Exception_wx(5000001, $path, $class_name);
     }
     self::$_controller_list[$class_name] = new $class_name();
     self::$_controller_list[$class_name]->set_module($name);
     return self::$_controller_list[$class_name];
 }
Exemplo n.º 24
0
            unset($words);
        }
        return $structures[$name];
    }
}
if (!function_exists('config')) {
    function config()
    {
        static $conf;
        $key_buffer = 'reloading_config_status';
        if (empty($conf) or !is_array($conf)) {
            include_once BASEPATH . 'config/config.php';
            if (!isset($config) or !is_array($config)) {
                exit('Config error');
            }
            $conf = $config;
            unset($config);
        }
        $status = Buffer::get($key_buffer);
        $ap_name = Buffer::get(URL_AP);
        if (!empty($ap_name) and $status != $ap_name) {
            if (!is_array($conf)) {
                $conf = array();
            }
            include_once APPPATH . "modules/{$ap_name}/config.php";
            if (array_key_exists(URL_AP, $conf)) {
                unset($conf[URL_AP]);
            }
            if (!isset($config)) {
                exit('Config error');
            }
            $conf[URL_AP] = $config;
            Buffer::set($key_buffer, $ap_name);
            unset($config);
        }
        $argv_list = func_get_args();
        $cursor =& $conf;
        foreach ($argv_list as $key) {
            if (!is_array($cursor) or !array_key_exists($key, $cursor)) {
Exemplo n.º 25
0
    public function Calendar($sFieldName, $sFromName = "", $sToName = "", $bTime = false)
    {
        /*
        		/** @global CMain $APPLICATION *
        		global $APPLICATION;
        ob_start();
        		$APPLICATION->IncludeComponent('bitrix:main.calendar', '', array(
        			'RETURN' => 'Y',
        			'SHOW_INPUT' => 'N',
        			'INPUT_NAME' => $sFieldName,
        			'SHOW_TIME' => $bTime ? 'Y' : 'N'
        		), null, array('HIDE_ICONS' => 'Y'));
        		$res = ob_get_contents();
        		ob_end_clean();
        return $res;
        */
        //Buffer::addJS(Config::getConfig("CORE_ROOT")."js/core.js");
        //Buffer::addCSS(Config::getConfig("CORE_ROOT")."css/core.css");
        Buffer::addJS(Config::getConfig("CORE_ROOT") . "js/core_date.js");
        Buffer::addCSS(Config::getConfig("CORE_ROOT") . "css/core_date.css");
        Buffer::addJS(Config::getConfig("CORE_ROOT") . "js/core_popup.js");
        Buffer::addCSS(Config::getConfig("CORE_ROOT") . "css/core_popup.css");
        $arParams = array('RETURN' => 'Y', 'SHOW_INPUT' => 'N', 'INPUT_NAME' => $sFieldName, 'SHOW_TIME' => $bTime ? 'Y' : 'N');
        ?>
<img src="/bitrix/js/main/core/images/calendar-icon.gif" alt="Выбрать дату в календаре" class="calendar-icon" onclick="BX.calendar({node:this, field:'<?php 
        echo $arParams['INPUT_NAME'];
        ?>
', form: '', bTime: <?php 
        echo $arParams['SHOW_TIME'] == 'Y' ? 'true' : 'false';
        ?>
, currentTime: '<?php 
        echo time();
        ?>
', bHideTime: <?php 
        echo $arParams['HIDE_TIMEBAR'] == 'Y' ? 'true' : 'false';
        ?>
});" onmouseover="BX.addClass(this, 'calendar-icon-hover');" onmouseout="BX.removeClass(this, 'calendar-icon-hover');" border="0"/><?php 
    }
Exemplo n.º 26
0
 public function article($opt = array())
 {
     $articles_model = $this->model('articles_model');
     $contents['type_list'] = $articles_model->get_all_types();
     $type = reset($contents['type_list']);
     $current_interval = 1;
     if (!empty($opt)) {
         $type = reset($opt);
         $current_interval = intval(next($opt));
     }
     if ($type == '_none-type') {
         $contents['info_list'] = $this->model('none_type_articles_model');
     } else {
         $contents['info_list'] = $articles_model->get_list($type, NULL, $current_interval);
     }
     $contents['interval'] = array('link' => base_url(Buffer::get(URL_CONTROLLER) . '/' . Buffer::get(URL_METHOD), TRUE), 'interval' => $articles_model->get_interval($type), 'selected' => $current_interval);
     $page = array();
     if ($type == '_none-type') {
         $page['content'] = $this->view('none_type_article_list', $contents, TRUE);
     } else {
         $page['content'] = $this->view('article_list', $contents, TRUE);
     }
     $this->view('backend/backend', $page);
 }
Exemplo n.º 27
0
<?php

require_once "config.inc.php";
require_once "Class.Parser.php";
require_once "Class.Buffer.php";
$buffer = new Buffer($config);
if (empty($_GET['do'])) {
    $buffer->throwError();
}
switch ($_GET['do']) {
    case 'closestupdate':
        if (empty($_GET['time'])) {
            $buffer->throwError();
        } else {
            echo $buffer->getClosestData($_GET['time']);
        }
        break;
    case 'lastbatch':
        if (empty($_GET['time'])) {
            $buffer->throwError();
        } else {
            echo $buffer->getLastBatch($_GET['time']);
        }
        break;
    case 'time':
        $date = date_create();
        echo json_encode(array("time" => date_timestamp_get($date)));
        break;
    case 'lastupdate':
        echo $buffer->getOldestData();
        break;
 /**
  * frees up resources
  */
 public function free()
 {
     $this->buffer->free();
 }
Exemplo n.º 29
0
// le fichier .htaccess à récupéré l'intégralité de ce qui se trouve après le nom de machine et la transmis au fichier index.php
// sous la forme l'un paramètre GET nommé url.
// On vérifie si la variable est définie et est différente de NULL, récupère cette url et la stock dans une variable :
if (isset($_GET['url'])) {
    $S_url = $_GET['url'];
} else {
    $S_url = null;
}
// On ouvre un tampon de sortie d'affichage pour que les controlleurs qui seront utilisés puissent déverser leurs vues
ob_start();
// On place un bloc de gestion des exceptions, pour attraper les exceptions qui seront levées dans les controlleurs appelés
try {
    // On crée un objet Router et l'on lui passe la variable url. il va se charger de décomposer cette url pour en determiner
    // le controlleur et l'action à appeler, ensuite l'objet Router va instancier à son tour un objet Controlleur d'action qui
    // lui se chargera de faire appel à un model pour récupérer des données sur la base de données
    $O_controller = new Router($S_url);
} catch (Exception $e) {
    //On récupère le message de l'exception
    echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
}
// On récupère le contenu du tampon de sortie d'affichage qui à été rempli par les Controlleurs d'actions qui ont utilisés
// un appel static de la class Buffer::flush, ce qui a déversé le contenu de la vue <section> à afficher dans le tampon principal .
$W_section = ob_get_clean();
//il nous reste plus qu'à afficher la <section> dans le template default en déversant le contenu de $W_section dans
//le tampon principal.
try {
    Buffer::flushBuffer('template/default', array('section' => $W_section));
} catch (Exception $e) {
    //On récupère le message de l'exception
    echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
}
Exemplo n.º 30
0
 }
 $controller = (string) str_replace('-', '_', $controller);
 Buffer::set(URL_CONTROLLER, $controller);
 if (!empty($path[$i])) {
     $method = $path[$i];
     ++$i;
 }
 $method = (string) str_replace('-', '_', $method);
 Buffer::set(URL_METHOD, $method);
 if (!empty($path[$i])) {
     for ($j = 0; $j < $i; $j++) {
         unset($path[$j]);
     }
     $options = array_values($path);
 }
 Buffer::set(URL_OPT, $options);
 //Проверяем корректность сессии
 if (!Session::analysis()) {
     Session::create();
 }
 //Разрешён ли вообще доступ пользователю?
 $access_zone = config(URL_AP, 'access', 'zone');
 $access_users = (array) config(URL_AP, 'access', 'user');
 if ($access_zone != Z_PUBLIC) {
     $user = Loader::get_user();
     if (!empty($access_users) and !in_array(User::T_ALL, $access_users) and $user->is_visitor() or !in_array($user->get_type(), $access_users)) {
         require_once PATH_STRATEGIES . 'identification.php';
         $class_name = 'Identification' . $postfix;
         $strategy = new $class_name();
     }
 }