Exemple #1
0
 protected static function restoreImageColumnConfig()
 {
     try {
         $data = array('columns' => array('image' => array('max_size' => 10 * 1024 * 1024)), 'tag' => array('cacheLifeTime' => '3600', 'cacheKey' => 'system_columns_tag', 'tag_table' => 'tags', 'cross_table' => 'document2tag'));
         $register = new \SystemRegister('/System/');
         \SystemRegisterHelper::import($register, $data);
     } catch (\Exception $e) {
     }
 }
Exemple #2
0
 /**
  * Осуществляет делегированный вызов
  */
 public static function delegate($aCurrentPath, $aNewPath, $method, $aData)
 {
     // то доверяем задачу сыну
     $szKey = array_pop($aNewPath);
     $szNewPath = SystemRegisterHelper::createPath($aCurrentPath, $aNewPath);
     // Получаем новый узел
     $branch = new SystemRegister($szNewPath);
     //
     array_unshift($aData, $szKey);
     return call_user_func_array(array($branch, $method), $aData);
 }
Exemple #3
0
 public function getDocuments()
 {
     $register = new SystemRegister(self::ConfigPath);
     $data = SystemRegisterHelper::exportData($register->Documents->getId());
     ksort($data);
     $result = array();
     foreach ($data as $key => $row) {
         $result[] = array('title' => $key, 'name' => $row);
     }
     return $result;
 }
Exemple #4
0
 public function delete($id)
 {
     $node = SystemRegisterHelper::createById($id);
     if (is_subclass_of($node, 'SystemRegister') || get_class($node) == 'SystemRegister') {
         $aPath = explode('/', $node->getFullPath());
         $szKey = $aPath = $aPath[sizeof($aPath) - 1];
         $node->getParent()->delete($szKey);
     } else {
         $szKey = $node->name;
         $node->parent->delete($szKey);
     }
     SystemRegisterSample::createCache();
     die;
 }
Exemple #5
0
 protected static function insertIntoBD($szName, $szUrlKey, $szDocument, $nDocumentId, $aParent)
 {
     $szName = strip_tags($szName);
     $szName = \Faid\DB::escape($szName);
     $szUrlKey = \Faid\DB::escape($szUrlKey);
     $szDocument = \Faid\DB::escape($szDocument);
     $nDocumentId = intval($nDocumentId);
     $condition = array('parent' => $aParent['id']);
     DBSimple::update('sitemap', '`order` = `order` + 1', $condition);
     $visible = SystemRegisterHelper::getValue('/System/Sitemap/visible');
     $sql = 'INSERT INTO `%s` SET `name`="%s",`url_key`="%s",`document_name`="%s",`document_id`="%d",`parent`="%d",`order`="%d",date_created=NOW(),date_updated=NOW(),revision_count=0, `sitemap_xml_priority` = "0.1", `sitemap_xml_change`="weekly",`visible`="%d"';
     $sql = sprintf($sql, SITEMAP_TABLE, $szName, $szUrlKey, $szDocument, $nDocumentId, $aParent['id'], 0, $visible);
     DB::post($sql);
     return DB::$connection->insert_id;
 }
Exemple #6
0
 protected function displayRights($rightsString)
 {
     // Получаем все права существующие в системе
     $register = new SystemRegister('System/CMS/userRights');
     $fullRightsList = SystemRegisterHelper::exportData($register->getId());
     $usersRights = explode("\r\n", $rightsString);
     // Перебор прав
     $result = array();
     foreach ($fullRightsList as $key => $row) {
         $checkbox = new CCheckbox();
         $checkbox->name = 'rights[]';
         $checkbox->value = $key;
         $checkbox->title = $row['comment'];
         if (in_array($key, $usersRights)) {
             $checkbox->checked = true;
         }
         $result[] = $checkbox;
     }
     return implode('<br/>', $result);
 }
Exemple #7
0
 protected static function loadConfig()
 {
     $register = new \SystemRegister(self::SystemRegisterPath);
     self::$config = \SystemRegisterHelper::exportData($register->getId());
 }
Exemple #8
0
 public function testImportUpdatingFileCacheWithDeletion()
 {
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($system->array));
     SystemRegisterHelper::import($system, array('XX' => '1', 'yy' => '2', 'Gisma' => 'rulit!', 'array' => array('0' => 'value1', '1' => array('1' => '2', '3' => '4'))));
     $this->assertEquals(true, isset($system->array));
     //
     SystemRegisterSample::loadAll();
     $base = new SystemRegister('System');
     $this->assertEquals(true, isset($system->array));
     $base->delete('array');
     $this->assertEquals(false, isset($base->array));
     //
     SystemRegisterSample::clearCache();
     SystemRegisterSample::loadAll();
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($base->array));
 }
Exemple #9
0
 public static function getRootDocuments()
 {
     $register = new SystemRegister(self::RootDocumentsKey);
     return SystemRegisterHelper::export($register->getId());
 }
Exemple #10
0
 protected function testIfDashboardMenuShouldBeShown()
 {
     $user = UsersLogin::getCurrentSession();
     if (empty($user)) {
         return false;
     }
     if (!CMSAuth::isAdmin($user)) {
         return false;
     }
     $isMenuActivated = SystemRegisterHelper::getValue(self::DashboardMenuKey);
     if (!$isMenuActivated) {
         return false;
     }
     return true;
 }
Exemple #11
0
 /**
  * По ключу элемента ($key) отыскивает его детей и возвращает их
  * @param $key string Путь от текущего элемента, к которому нужно получить доступ
  */
 public function get($key)
 {
     //
     $aNewPath = SystemRegisterHelper::responsePath($key);
     // Если путь больше чем 1
     if (sizeof($aNewPath) > 1) {
         return SystemRegisterHelper::delegate($this->aCurrentPath, $aNewPath, 'get', array());
     } else {
         $aChilds = SystemRegisterSample::selectChild($this->nId);
         // Ищем среди детей
         foreach ($aChilds as $row) {
             if ($row['name'] == $aNewPath[0]) {
                 // Имя совпало
                 // Это ветвь?
                 if (SystemRegisterHelper::isBranch($row['value'], $row['type'])) {
                     $szNewPath = SystemRegisterHelper::createPath($this->aCurrentPath, $aNewPath);
                     return new SystemRegister($szNewPath);
                 } else {
                     $primitive = new SystemRegisterPrimitive($this, $row['name'], $row['value'], $row['comment'], $row['type'], $row['id']);
                     return $primitive;
                 }
             }
         }
     }
     throw new SystemRegisterException('Element `' . $key . '` not found. Current element:' . $this->getFullPath());
 }
Exemple #12
0
<?php

use Faid\DB;
$sql = <<<SQL
\tcreate table ddos_detector (
\t\t`id` int not null auto_increment,
\t\t`ip` binary(16) not null default "",
\t\t`date` datetime not null,
\t\tindex `search_by_ip` (`ip`),
\t\tprimary key (`id` )
\t)
SQL;
DB::post($sql);
SystemRegisterHelper::import(new SystemRegister('/System/Security/'), array('DDosDetector' => array('MaxConnections' => 100, 'Period' => '1 minute', 'Message' => 'Ваш аккаунт был временно заблокирован по причине превышения допустимого количества запросов')));
SystemRegisterSample::createCache();
Exemple #13
0
<?php

use Faid\DB;
$register = new SystemRegister('/System/');
$import = array('Audit' => array('notification_emails' => '*****@*****.**'));
SystemRegisterHelper::import($register, $import);
SystemRegisterSample::createCache();
$sql = <<<SQL
\tcreate table `audit_logs` (
\t\t`id` int not null auto_increment,
\t\t`name` varchar(40) not null,
\t\t`description` text null,
\t\t`critical` bool not null default true,
\t\t`enable_logging` bool not null default false,
\t\tPRIMARY key (`id`)
\t) DEFAULT CHARSET utf8
SQL;
DB::post($sql);
$sql = <<<SQL
\tcreate table `audit_records` (
\t\t`id` int not null auto_increment,
\t\t`log_id` int not null,
\t\t`date` datetime default '0000-00-00 00:00:00',
\t\t`user_id` int not null default 0,
\t\t`user_login`  varchar( 40 ) null,
\t\t`short` text null,
\t\t`full` text null,
\t\t`ip` binary(16),
\t\t`viewed` BOOL not null default false
\t\tprimary key ( `id` ),
\t\tindex search_by_log (`log_id` ),