Esempio n. 1
0
 public static function send($event)
 {
     $live = \Control\Live::getInstance();
     $conf = \Control\Core::conf();
     // Поиск шаблона письма по имени события
     $mail = $this->find(array('event' => $event, 'active' => 1));
     if (!empty($mail)) {
         // Замена тегов в письме на значения переменных
         $tags = explode(',', $mail->tags);
         foreach ($tags as $tag) {
             $tag = explode('.', $tag);
             if (is_array($GLOBALS[$tag[0]])) {
                 $value = $GLOBALS[$tag[0]][$tag[1]];
             } elseif (is_object($GLOBALS[$tag[0]])) {
                 $value = $GLOBALS[$tag[0]]->{$tag}[1];
             } else {
                 $value = $GLOBALS[$tag[0]];
             }
             $subject = str_replace('{' . $tag[0] . '.' . $tag[1] . '}', $value, $mail->subject);
             $message = str_replace('{' . $tag[0] . '.' . $tag[1] . '}', $value, $mail->message);
         }
         $mail_to = $user->email;
         $mail_from = $conf->site_mail;
         // Отправка письма
         if (!empty($subject) && !empty($message)) {
             $headers = 'MIME-Version: 1.0' . "\r\n";
             $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
             $headers .= 'To: ' . $live->user->name . ' <' . $mail_to . '>' . "\r\n";
             $headers .= 'From: ' . $conf->site_name . ' <' . $mail_from . '>' . "\r\n";
             mail($mail_to, $subject, $message, $headers);
         }
     }
 }
Esempio n. 2
0
 public function settingsAction()
 {
     $conf = \Control\Core::conf();
     $form = new \Control\Forms();
     $form->setTitle('Wysiwygs');
     $form->setTemplate('form');
     $obj = new \stdClass();
     $obj->type = 'select';
     $obj->id = 'wysiwygs_name';
     $obj->status = 'db';
     $obj->value = !empty($conf->settings['wysiwyg']) ? $conf->settings['wysiwyg'] : '';
     $obj->options = 'a:4:{s:6:"module";s:8:"Wysiwygs";s:6:"entity";s:7:"Wysiwyg";s:5:"index";s:4:"name";s:5:"title";s:5:"title";}';
     $obj->caption = 'Визивиг';
     $form->addObject($obj);
     $form->addHTML('<div id="wysiwygs_info"><br/><br/><br/></div>');
     $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => 'wysiwygs_save_settings()'));
     $output = $form->render();
     return $output;
 }
Esempio n. 3
0
 public function optionsAction($page = null)
 {
     $conf = \Control\Core::conf();
     $live = \Control\live::getInstance();
     $json = array();
     /*
             $qb = $this->em->createQueryBuilder();
             $qb->add('select', 'm')
                 ->add('from', '\Menu\Entities\Menu m')
                 ->add('where', $qb->expr()->andX(
                     'm.module = ?1',
                     $qb->expr()->orX(
                         'm.page = ?2',
                         $qb->expr()->like('m.childs', '?2')
                     )
                 ))
                 ->setParameter(1, 'data')
                 ->setParameter(2, $page)
             ;
             $info = $qb->getQuery()->getResult();
             
             if (!empty($info))
             {
                 $options = $info[0]->options;
                 echo $options .', ';
                 
                 $this->$options();
             }*/
     $json[] = array('title' => 'Добавить тип данных', 'href' => '#Data/add');
     $childs = array();
     $data_types = $this->repDataType->findBy(array());
     if (!empty($data_types)) {
         foreach ($data_types as $data_type) {
             $childs_right = array();
             $childs_right[] = array('type' => 'link_img_list', 'href' => '#Data/listFields/' . $data_type->name);
             $childs_right[] = array('type' => 'link_img_edit', 'href' => '#Data/edit/' . $data_type->id);
             $childs_bottom = array();
             $data_fields = $this->repDataField->findBy(array('data_name' => $data_type->name));
             if (!empty($data_fields)) {
                 foreach ($data_fields as $data_field) {
                     $childs_bottom[] = array('title' => $data_field->title, 'href' => '#Data/editField/' . $data_field->id);
                 }
             }
             $childs_spoiler = array('id' => 'data_options_type_' . $data_type->id, 'items' => $childs_bottom);
             $childs[] = array('name' => $data_type->name, 'title' => $data_type->title, 'action' => "acSlideToggle('data_options_type_" . $data_type->id . "')", 'childs_right' => $childs_right, 'childs_spoiler' => $childs_spoiler);
         }
     }
     $json[] = array('title' => 'Список данных', 'href' => '#Data/list', 'childs' => $childs);
     $json[] = array('title' => '');
     $json[] = array('title' => 'Добавить шаблон', 'href' => '#Data/addTemplate');
     $childs = array();
     $data_templates = $this->repDataTemplate->findAll();
     if (!empty($data_templates)) {
         foreach ($data_templates as $data_template) {
             $childs[] = array('name' => $data_template->name, 'title' => !empty($data_template->title) ? $data_template->title : $data_template->name, 'href' => '#Data/editTemplate/' . $data_template->id);
         }
     }
     $json[] = array('title' => 'Список Шаблонов', 'href' => '#Data/listTemplates', 'childs' => $childs);
     // $json[] = array('title'=>'Настройки', 'href'    => '#Data/settings' );
     $output = json_encode($json);
     return $output;
 }
Esempio n. 4
0
            $error = 'No error code avaiable';
    }
    echo $error;
} elseif (empty($_FILES[$fileElementName]['tmp_name']) || $_FILES[$fileElementName]['tmp_name'] == 'none') {
    $error = 'No file was uploaded..';
    echo $error;
} else {
    // Подключение классов
    require_once 'system/modules/Control/Config.php';
    require_once 'system/modules/Control/Core.php';
    require_once 'system/modules/Control/Engine.php';
    require_once 'system/modules/Control/Live.php';
    \Control\Core::init();
    $conf = \Control\Core::conf();
    $live = \Control\Live::getInstance();
    $em = \Control\Core::em();
    $con = $em->getConnection();
    $code = $live->user->id;
    $id = $fileElementName;
    $name = $_FILES[$fileElementName]['name'];
    $ext = explode('.', $name);
    $ext = $ext[count($ext) - 1];
    $path = '/temp/files/' . $code . '_' . $id . '.' . $ext;
    $size = $_FILES[$fileElementName]['size'];
    $time = time();
    if (rename($_FILES[$fileElementName]['tmp_name'], $root_dir . '' . $path)) {
        $file_id = $con->executeQuery("SELECT `id` FROM {$db_prefix}files_temp WHERE `user`='{$code}' AND `path`='{$path}'")->fields['id'];
        // пользователь перезагрузил файл - обновляем запись в базе
        if ($file_id > 0) {
            $con->executeQuery("UPDATE {$db_prefix}files_temp SET `created`='{$time}', `name`='{$name}' WHERE `user`='{$code}' AND `path`='{$path}';");
        } else {
Esempio n. 5
0
 public function set_additional_field($field, $value)
 {
     $db_prefix = \Control\Core::conf()->db_prefix;
     $this->db = \Control\Core::db();
     if ($this->db->Execute("SELECT `{$field}` FROM {$this->conf->db_prefix}users_additional_data WHERE `id`='{$this->id}'")->RecordCount() == 1) {
         $this->db->Execute("UPDATE {$this->conf->db_prefix}users_additional_data SET `{$field}`='{$value}' WHERE `id`='{$this->id}'");
     } else {
         $this->db->Execute("INSERT INTO {$this->conf->db_prefix}users_additional_data SET `{$field}`='{$value}', `id`='{$this->id}'");
     }
 }
Esempio n. 6
0
 public function createTables()
 {
     $con = $this->em->getConnection();
     $mysql_types = array('varchar', 'tinyint', 'text', 'date', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'datetime', 'timestamp', 'time', 'year', 'char', 'tinyblob', 'tinytext', 'blob', 'mediumblob', 'mediumtext', 'longblob', 'longtext', 'enum', 'set', 'bit', 'bool', 'binary', 'varbinary');
     if (!empty($this->info->tables) && is_array($this->info->tables)) {
         foreach ($this->info->tables as $table_name => $table_fields) {
             $sql = "CREATE TABLE IF NOT EXISTS `{$this->conf->db_prefix}" . \Control\Core::quote_smart($table_name) . "` (";
             $fields = array();
             foreach ($table_fields as $field_name => $field_info) {
                 // Название поля и тип
                 $field_type = in_array($field_info['type'], $mysql_types) ? $field_info['type'] : 'text';
                 $field = "`" . \Control\Core::quote_smart($field_name) . "` {$field_type}";
                 // Длина/значения
                 if (isset($field_info['length'])) {
                     $field_length = intval($field_info['length']);
                     $field .= "(" . $field_length . ")";
                 }
                 // not_null
                 if (isset($field_info['not_null']) && $field_info['not_null'] == 1) {
                     $field .= " not null";
                 }
                 // default
                 if (isset($field_info['default']) && $field_info['default'] != '') {
                     $field .= " default '" . \Control\Core::quote_smart($field_info['default']) . "'";
                 }
                 // auto_increment
                 if (isset($field_info['auto_increment']) && $field_info['auto_increment'] == 1) {
                     $field .= " auto_increment";
                 }
                 $fields[] = $field;
             }
             $sql .= implode(',', $fields);
             $sql .= ", PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
             try {
                 $con->executeQuery($sql);
             } catch (Exception $e) {
                 echo $this->name . '. Ошибка:<br/>' . $e . '<br/>' . $sql . '<br/><br/>';
             }
         }
     }
 }
Esempio n. 7
0
 public function editProfileAction()
 {
     $conf = \Control\Core::conf();
     $db = \Control\Core::db();
     $live = \Control\Live::getInstance();
     $user = $live->user;
     $time = time();
     $fields = explode($conf->ac_sep, $_POST['fields']);
     $new_values = str_replace($conf->ac_con, '&', $_POST['new_values']);
     $new_values = explode($conf->ac_sep, $new_values);
     $values_sql = array();
     for ($i = 0; $i < count($fields); $i++) {
         $field = data::quote_smart($fields[$i]);
         switch ($field) {
             case 'pass':
                 $pass = $new_values[$i];
                 break;
             case 'pass2':
                 $pass2 = $new_values[$i];
                 break;
             default:
                 $value = data::quote_smart($new_values[$i]);
                 $values_sql[] = sprintf("`%s`='%s'", $field, $value);
         }
     }
     if (!empty($pass) && !empty($pass2)) {
         // если изменился пароль, генерируем хэш
         if ($pass == $pass2) {
             $hash = $_SESSION['user_hash'] = md5($user->id . ':' . $user->login . ':' . md5($pass) . ':' . $user->salt);
             $values_sql[] = sprintf("`hash`='%s'", $hash);
         } else {
             echo 'Пароли не совпадают.';
             exit;
         }
     }
     $values_sql = implode(',', $values_sql);
     $db->Execute("UPDATE {$conf->db_prefix}users SET {$values_sql} WHERE `id`='{$user->id}'");
 }
Esempio n. 8
0
 public function displayAction()
 {
     $live = \Control\Live::getInstance();
     $core = \Control\Core::getInstance();
     $user = $live->user;
     $active_module = !empty($_POST['module']) ? $core->quote_smart($_POST['module']) : '';
     $active_page = !empty($_POST['page']) ? $core->quote_smart($_POST['page']) : '';
     $result = $this->repMenu->findOneBy(array('active' => 1, 'level' => 1, 'module' => $active_module, 'page' => $active_page));
     if (empty($result) && !empty($active_page)) {
         // sql: "SELECT `page` FROM {$this->conf->db_prefix}menu WHERE `active`='1' AND `level`='1' AND `module`='{$active_module}' AND `childs` LIKE '%{$active_page}%'"
         $qb = $this->em->createQueryBuilder();
         $qb->add('select', 'm')->add('from', '\\Menu\\Entities\\Menu m')->add('where', $qb->expr()->andX('m.active = 1', 'm.level = 1', 'm.module = ?1', $qb->expr()->like('m.childs', '?2')))->setParameter(1, $active_module)->setParameter(2, "%" . $active_page . "%");
         $result = $qb->getQuery()->getResult();
         if (!empty($result)) {
             $active_page = $result[0]->page;
         }
     }
     $menu = array();
     $tab_first = true;
     $items = $this->repMenu->findBy(array('active' => 1, 'level' => 0), array('weight' => 'ASC'));
     foreach ($items as $item) {
         $parent_id = $item->id;
         $parent_title = $item->title;
         $active_tab = false;
         $inner_tab = array();
         // sql: "SELECT `page`, `title`, `module`, `data`, `options` FROM {$this->conf->db_prefix}menu WHERE `active`='1' AND `parent`='{$parent_id}' ORDER BY `weight`"
         $childs = $this->repMenu->findBy(array('active' => 1, 'parent' => $parent_id), array('weight' => 'ASC'));
         foreach ($childs as $child) {
             $module = $child->module;
             $title = $child->title;
             $page = $child->page;
             $data = $child->data != '' ? $child->data : 1;
             // если есть доступ к странице, формируем ссылку
             if ($user->access(array('module' => $module, 'page' => $page))) {
                 $inner_tab_link = array('id' => $module . '_' . $page, 'href' => $data != 1 ? $module . '/' . $page . '/' . $data : $module . '/' . $page, 'title' => $title);
                 if ($page == $active_page && $module == $active_module) {
                     $active_tab = true;
                     $inner_tab_link['active'] = 1;
                 }
                 $inner_tab[] = $inner_tab_link;
             }
         }
         // если во вкладке есть элементы меню, записываем ее в массив
         if (count($inner_tab) > 0) {
             $inner_tab = array('id' => $parent_id, 'title' => $parent_title, 'items' => $inner_tab);
             if ($active_tab) {
                 $inner_tab['active'] = 1;
             }
             $menu[] = $inner_tab;
         }
     }
     $output = json_encode($menu);
     return $output;
 }
Esempio n. 9
0
<?php

// Подключение классов
require_once 'system/modules/Control/Config.php';
require_once 'system/modules/Control/Core.php';
require_once 'system/modules/Control/Engine.php';
require_once 'system/modules/Control/ErrorSupervisor.php';
$errorController = new \Control\ErrorSupervisor();
\Control\Core::init();
// Инициализация
$engine = new \Control\Engine();
// Start the System
$engine->init();
// Init modules entities
$engine->parsing();
// Parsing input data
$engine->routing();
// Find any routes
$engine->controlling();
// Do something usefull
$engine->theming();
// Put data into template engine and wraping the data in the theme
$engine->display();
// Display output data