Exemplo n.º 1
0
 public static function get($name)
 {
     if (!isset(self::$storage[$name])) {
         $di = data_interface::get_instance('registry');
         self::$storage[$name] = $di->get($name);
     }
     $rec = self::$storage[$name];
     switch ($rec->type) {
         case 1:
             return (string) $rec->value;
             break;
         case 2:
             return json_decode($rec->value);
             break;
         case 3:
             $cfg = $rec->value;
             if (!empty($cfg->di)) {
                 $di = data_interface::get_instance($cfg->di);
                 return $di->call($cfg->ep, json_decode($cfg->params));
             } else {
                 if (!empty($cfg->ui)) {
                     $ui = user_interface::get_instance($cfg->ui);
                     return $ui->call($cfg->ep, json_decode($cfg->params));
                 } else {
                     throw new Exception("Unknown call configuration for registry record '{$name}'");
                 }
             }
             break;
         default:
             throw new Exception("Unknown registry record type for '{$name}'");
     }
 }
Exemplo n.º 2
0
 /**
  *	Log out user
  */
 public static function logout()
 {
     session::del(array('uid', 'ulogin', 'uhash'), AUTH_DI);
     // Get instance of authentification data interface
     $auth = data_interface::get_instance(AUTH_DI);
     $auth->is_logged = FALSE;
 }
Exemplo n.º 3
0
 public function check_access($iface, $call, $type)
 {
     if (defined('AUTH_DI')) {
         $adi = data_interface::get_instance(AUTH_DI);
         return $adi->is_available_interfaces($iface, $call, $type);
     } else {
         return true;
     }
 }
Exemplo n.º 4
0
 /**
  *	Генерация главного меню
  */
 private function generate_menu()
 {
     $menu = array(array('text' => 'Запросы', 'icon' => 'comment', 'ui' => 'logistic_request', 'ep' => 'main'), array('text' => 'Заявки', 'icon' => 'folder_page', 'ui' => 'logistic_order', 'ep' => 'main'), array('text' => 'Справочники', 'icon' => 'book', 'menu' => array(array('text' => 'Услуги', 'icon' => 'book', 'ui' => 'services', 'ep' => 'main'), array('text' => 'Контрагенты', 'icon' => 'lorry', 'ui' => 'contractor', 'ep' => 'main'))), array('text' => 'Приложения', 'icon' => 'application_double', 'menu' => array(array('text' => 'Файл-менеджер', 'icon' => 'application_view_tile', 'ui' => 'file_manager', 'ep' => 'main'))), array('text' => 'Администрирование', 'icon' => 'shield', 'menu' => array(array('text' => 'Системное меню', 'icon' => 'chart_organisation', 'ui' => 'system_menu', 'ep' => 'main'), array('text' => 'Пользователи', 'icon' => 'user', 'ui' => 'user', 'ep' => 'main'), array('text' => 'Группы', 'icon' => 'group', 'ui' => 'group', 'ep' => 'main'), array('text' => 'Безопасность', 'icon' => 'shield', 'ui' => 'security', 'ep' => 'main'))), array('text' => 'Страницы помощи', 'icon' => 'help', 'ui' => 'help', 'ep' => 'main'), array('->'), array('text' => 'Выход', 'icon' => 'logout', 'href' => '/xxx/login/?cll=logout'));
     $sm = data_interface::get_instance('system_menu');
     $menu = $sm->generate_menu();
     if (UID == 1) {
         return $menu;
     } else {
         $adi = data_interface::get_instance(AUTH_DI);
         $ifs = $adi->get_available_interfaces('ui');
         return $this->process_menu($menu, $ifs);
     }
 }
Exemplo n.º 5
0
 /**
  *	Get array of DI
  * @access	private
  * @return	array	The array of DI objects
  */
 public function get_di_array()
 {
     $dis = $this->get_di_name_array();
     // Перебираем список полученных DI и регистрируем их
     foreach ($dis as $iName => $props) {
         if ($iObj = data_interface::get_instance($iName)) {
             $dis[$iName]['obj'] = $iObj;
             $dis[$iName]['rec'] = $this->register($iName, 'di', $iObj);
         } else {
             unset($dis[$iName]);
         }
     }
     return $dis;
 }
Exemplo n.º 6
0
 /**
  *	Объеденить ИД с другим ИД
  * @param	mixed	$with_di	Имя ИД
  * @param	array	$on		Массив вида "левое_поле" => "правое_поле"
  * @param	array	$fields_alias	Массив синонимов полей при объединении (для $with_di)
  * @param	mixed	$by_di		Объединяющий ИД, по умолчанию текущий ИД
  * @param	string	$join_type	Тип объединения, по умолчанию определяется конектором
  * @return	mixed	Возвращает уникальное имя связки, формируемый конектором, либо FALSE
  */
 public function join_with_di($with_di, $on, $fields_alias = array(), $by_di = null, $join_type = null)
 {
     // Если объединяющий ИД не был указан
     if ($by_di == null) {
         $by_di =& $this;
     } else {
         if (!is_object($by_di)) {
             $by_di = data_interface::get_instance($by_di);
         }
     }
     // Если было передано имя объединяемого ИД
     if (!is_object($with_di)) {
         $with_di = clone data_interface::get_instance($with_di);
     }
     if ($with_di->cfg != $by_di->cfg) {
         throw new Exception('Can`t join DI with different configuration.' . "({$with_di->cfg} and {$by_di->cfg})");
     }
     return $this->connector->_join($by_di, $with_di, $on, $fields_alias, $join_type);
 }
Exemplo n.º 7
0
#!/usr/bin/env php5
<?php 
// NOTE: Base initialization
include_once 'base.php';
// NOTE: The prefix of UI methods
define('UI_CALL_PREFIX', ADM_PREFIX);
$int = data_interface::get_instance('util_db');
$path_di = DI_PATH;
$path_dump = DUMP_PATH . $subfold;
$int->perform_init(3, $path_di, $path_dump);
echo " =====  done =====\n";
Exemplo n.º 8
0
 public function __construct()
 {
     // Call Base Constructor
     parent::__construct(__CLASS__);
 }
Exemplo n.º 9
0
 /**
  *	Unset data to storage and return results in JSON
  * @access protected
  */
 protected function sys_unset()
 {
     $this->_flush();
     $data = $this->extjs_unset_json(false);
     // Remove all links between users and deleted groups
     $gu = data_interface::get_instance('group_user');
     $epg = data_interface::get_instance('entry_point_group');
     $ids = (array) $this->get_lastChangedId();
     foreach ($ids as $gid) {
         $gu->remove_users_from_group($gid);
         $epg->remove_entry_points_from_group($gid);
     }
     response::send($data, 'json');
 }
Exemplo n.º 10
0
 /**
  *	Формирование ветки меню
  * @param	array	$results	Массив записей с пунктами меню
  * @param	integer	$left		LEFT индекс
  * @param	integer	$right		RIGHT индекс
  * @param	integer	$level		Уровень вложенности
  */
 private function process_slice($results, $left, $right, $level)
 {
     $slice = array();
     foreach ($results as $record) {
         if ($record->left > $left && $record->right < $right && $record->level == $level) {
             if ($record->text == CURRENT_USER) {
                 $di = data_interface::get_instance('user');
                 $usr = $di->get_user();
                 $record->text = $usr['name'] . ' (' . UID . ')';
             }
             if ($record->left + 1 < $record->right) {
                 $slice[] = array('text' => $record->text, 'icon' => $record->icon, 'menu' => $this->process_slice($results, $record->left, $record->right, $record->level + 1));
             } else {
                 if ($record->type == 0 && !empty($record->ui) && !empty($record->ep)) {
                     $slice[] = array('text' => $record->text, 'icon' => $record->icon, 'ui' => $record->ui, 'ep' => $record->ep);
                 } else {
                     if ($record->type == 0 && !empty($record->href)) {
                         $slice[] = array('text' => $record->text, 'icon' => $record->icon, 'href' => $record->href);
                     } else {
                         if ($record->type == 1) {
                             $slice[] = array($record->text);
                         }
                     }
                 }
             }
         }
     }
     return $slice;
 }
Exemplo n.º 11
0
<?php

/**
*	Public site initialization
*
* @author	Litvinenko S. Anthon <*****@*****.**>
* @access	public
* @package	SBIN DIESEL	
*/
try {
    $uri = empty($_SERVER['REDIRECT_URL']) ? '/' : $_SERVER['REDIRECT_URL'];
    $diStrc = data_interface::get_instance(SITE_DI);
    $page = $diStrc->get_page_by_uri($uri);
    define(PAGE_URI, $page['uri']);
    define(SRCH_URI, str_replace($page['uri'], "", $uri));
    define(PAGE_ID, $page['id']);
    if (!empty($page['redirect'])) {
        response::redirect($page['redirect']);
    } else {
        $uiStrc = user_interface::get_instance(SITE_UI);
        $uiStrc->set_args(request::get());
        $uiStrc->process_page($page);
    }
} catch (Exception $e) {
    dbg::write('Error: ' . $e->getMessage());
    //response::header('404');
    //9* 28102010
    try {
        $out = user_interface::get_instance('action_page');
        $out->set_args(array('action_msg' => $e->getMessage()));
        return $out->render();
Exemplo n.º 12
0
#!/usr/bin/env php5
<?php 
// NOTE: Base initialization
include_once 'base.php';
// NOTE: The prefix of UI methods
define('UI_CALL_PREFIX', ADM_PREFIX);
$int = data_interface::get_instance('interface');
$dis = $int->get_di_array();
//var_dump($dis);
foreach ($dis as $name => $cfg) {
    try {
        $di = $cfg['obj'];
        $di->make_dump();
        echo "{$name} ({$di->title}): Done\n";
    } catch (Exception $e) {
        echo "{$name} ({$di->title}): ERROR\n";
        echo $e->getMEssage() . "\n";
    }
}
Exemplo n.º 13
0
 public function perform_init($type_id, $path_di, $path_dump)
 {
     $type = $this->types_map[$type_id];
     if ($type_id == 4) {
         $type = 2;
     }
     $dh = dir($path_di);
     while (($i = $dh->read()) !== FALSE) {
         if (preg_match('/^(\\w+)\\.di\\.php$/', $i, $match)) {
             if ($iObj = data_interface::get_instance($match[1])) {
                 if ($this->dump_kernel_to_instance_cfg == false) {
                     if (preg_match('/^cpy_.+/', $match[1], $match2)) {
                         continue;
                     }
                 }
                 try {
                     $iObj->init_dump2($type, $path_dump);
                 } catch (Exception $e) {
                     dbg::write($match[1] . '  ' . $e->getMessage());
                 }
             }
         }
     }
     $dh->close();
 }
Exemplo n.º 14
0
<?php

/**
*	The data interface initialization code
*
* @author	Litvinenko S. Anthon <*****@*****.**>
* @version	2.0
* @access	public
* @package	SBIN Diesel	
*/
try {
    // NOTE: If defined authentication data interface and user not logged in
    /* 9* старый вариант не рубил отдачу файлов по сслке /files/?id=6 например в случае  если юзер не залогинен
    	 и вот потому  дополнительно условие если аутх мое публик то на pub_ не будем руибить доступ ибо это публик по дефолту
    
    
    	if (defined('AUTH_DI') && !authenticate::is_logged())
    	*/
    if (defined('AUTH_DI') && !authenticate::is_logged() && AUTH_MODE != 'public') {
        // Then send error
        response::send('Session closed. Authorization needed.', 'error');
    }
    $di = data_interface::get_instance(request::get('di'));
    // If return FALSE then access denied
    if (!$di->call(request::get('cll'), request::get())) {
        response::send('Access denied.', 'error');
    }
} catch (Exception $e) {
    dbg::write("UID: " . UID . "\nREQUEST_URI: {$_SERVER['REQUEST_URI']}\n" . $e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'di_errors.log');
    response::send('Error while process request.', 'error');
}