Пример #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);
         }
     }
 }
Пример #2
0
 public function saveAction()
 {
     $live = \Control\Live::getInstance();
     $fields = explode($this->conf->ac_sep, $live->_post['fields']);
     $values = explode($this->conf->ac_sep, $live->_post['values']);
     $setting = new \Settings\Setting();
     for ($i = 0; $i < count($fields); $i++) {
         $setting->save(array('value' => $values[$i]), array('name' => $fields[$i]));
     }
 }
Пример #3
0
        default:
            $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}';");
Пример #4
0
 public function access($handler)
 {
     $live = \Control\Live::getInstance();
     $access = false;
     $this->repositoryPermission = $this->em->getRepository('Users\\Entities\\UserPermission');
     if (!empty($handler['module']) && (!empty($handler['page']) || !empty($handler['action']))) {
         $handler['active'] = 1;
         if (!empty($handler['action'])) {
             $handler['action'] = str_replace('Action', '', $handler['action']);
         }
         $permission = $this->repositoryPermission->findOneBy($handler);
         // permission not found
         if (empty($permission)) {
             // access control method
             if ($live->_theme_control) {
                 $handler_control = array('module' => 'Control', 'page' => 'index');
                 $permission_control = $this->repositoryPermission->findOneBy($handler_control);
                 if (empty($permission_control) || $permission_control->access_mask & $this->group) {
                     $access = true;
                 }
             } else {
                 $access = true;
             }
         } elseif ($permission->access_mask & $this->group) {
             $access = true;
         }
     }
     return $access;
 }
Пример #5
0
 public function addAction()
 {
     $live = \Control\Live::getInstance();
     $i = 1;
     $name = 'new';
     $title = 'Новая страница';
     $page = $this->repPage->findOneBy(array('name' => $name));
     while (!empty($page)) {
         $i++;
         $name = 'new-' . $i;
         $title = 'Новая страница (' . $i . ')';
         $page = $this->repPage->findOneBy(array('name' => $name));
     }
     $data = array('name' => $name, 'title' => $title, 'meta_title' => '', 'template' => 'main', 'text' => '');
     $pages = new \Pages\Page();
     $pages->save($data);
 }
Пример #6
0
 private function getInfo()
 {
     $live = \Control\Live::getInstance();
     $info = array();
     $file_path = $this->conf->root_dir . '/' . $this->group . '/modules/' . $this->name . '/info.php';
     if (file_exists($file_path)) {
         $info = (require $file_path);
     }
     return $info;
 }
Пример #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}'");
 }
Пример #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;
 }
Пример #9
0
 public function __construct()
 {
     parent::__construct();
     $live = \Control\Live::getInstance();
     $live->_theme_control = true;
 }