Пример #1
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     // проверим есть ли pid и если есть то относится ли к нужному root_id
     $filter = get('filter', array());
     if ($filter['all_pids']) {
         $page_root_id = sql_getValue("SELECT root_id FROM `tree` WHERE id='" . (int) $filter['all_pids'] . "'");
         if ($page_root_id != domainRootID()) {
             $_GET['filter']['all_pids'] = 0;
         }
     }
     $tree = array();
     $root_id = domainRootId();
     if ($root_id > 0 && allowDomainForUser($root_id)) {
         $tree = $tree + $this->getPages((int) $root_id);
         $temp = $tree;
         $tree = array();
         foreach ($temp as $val) {
             $tree[$val['id']] = $val['name'];
         }
     }
     $filter_pid_value = array('' => 'все') + $tree;
     // строим таблицу
     require_once core('list_table');
     $data['table'] = list_table(array('columns' => array(array('select' => 'p.id', 'display' => 'id', 'type' => 'checkbox'), array('select' => 'p.name', 'display' => 'name', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'UNIX_TIMESTAMP(p.date)', 'as' => 'date', 'display' => 'date', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'date', 'filter_value' => 'date', 'type' => 'date'), array('select' => 'p.pid', 'display' => 'pid', 'type' => 'dir'), $root_id > 0 ? array('select' => 'CAST(CONCAT(p.pid,\',\',p.pids) AS CHAR)', 'as' => 'all_pids', 'flags' => FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => $filter_pid_value, 'filter_display' => 'pid', 'filter_rule' => 'find_in_set') : array('select' => 'CAST(CONCAT(p.pid,\',\',p.pids) AS CHAR)', 'as' => 'all_pids'), array('select' => 'p.visible', 'display' => 'visible', 'type' => 'visible', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет'), 'filter_field' => 'IF(p.visible=0,2,1)'), array('select' => 'p.id', 'display' => 'showInSite', 'type' => 'show'), array('select' => 't.dir'), array('select' => 't.root_id'), array('select' => 't.name', 'as' => 't_name', 'flags' => FLAG_SEARCH), array('select' => 'p.notice', 'flags' => FLAG_SEARCH), array('select' => 'p.text', 'flags' => FLAG_SEARCH)), 'from' => $this->table . " as p\n\t\t\tLEFT JOIN `tree` as t ON t . id = p . pid\n\t\t\t", 'where' => (domainRootId() > 0 ? ' (t.root_id=' . domainRootId() . ' OR t.root_id IS NULL OR FIND_IN_SET(' . domainRootId() . ', (SELECT GROUP_CONCAT( DISTINCT CAST(root_id AS CHAR)) FROM tree WHERE FIND_IN_SET(id, CONCAT(p.pid, ",", p.pids)))) )' : '') . $this->where_extra, 'orderby' => 'p.date DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => 'editItem(p.id)', 'click' => 'ID=cb.value'), $this);
     $data['table'] .= "<script type='text/javascript'>\n        \$('ul.navPanel').find('a:first').attr('onclick','').click(function(){\n            \$('.createbox').show().find('input[type=text]').focus();\n        });\n        </script>\n        <style type='text/css'>\n        .createbox {\n            width:307px;\n            height:100px;\n            background-color:#fff;\n            border:2px solid #FAAE3E;\n            position:fixed;\n            left:550px;\n            top:400px;\n            display:none;\n            padding:10px;\n            box-shadow:5px 5px 5px rgba(0,0,0,0.5);\n        }\n            .createbox .close {\n                text-decoration:none;\n                position:relative;\n                top:-7px;\n                left:304px;\n                font-size:16px;\n                color:#f00;\n            }\n        </style>\n        <div class='createbox'>\n            <a href='javascript:void(0);' onclick='\$(\".createbox\").hide();' class='close'>X</a>\n            <form action='' method='post'>\n                <input type='hidden' name='page' value='{$this->name}' />\n                <input type='hidden' name='do' value='editCreate' />\n                <!--input type='hidden' name='ref' value='/admin/editor.php?page={$this->name}' /-->\n                <label>Введите название новой публикации:</label>\n                <input type='text' class='text' name='fld[name]' id='fld_name' value='' />\n                <a href='javascript:void(0);' onclick='if(\$(this).parent().find(\"#fld_name\").val()) \$(this).parent().submit(); else alert(\"Вы не ввели название публикации\");' class='button' style='position:relative;left:90px;top:5px;'><span>Создать</span></a>\n            </form>\n        </div>";
     $this->AddStrings($data);
     return $this->Parse($data, LIST_TEMPLATE);
 }
Пример #2
0
 function Show()
 {
     // обязательная фигня
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     global $settings;
     $types = array();
     foreach ($settings['subscribe_categories'] as $key => $val) {
         if (isset($val['sub'])) {
             foreach ($val['sub'] as $k => $v) {
                 $types[$v['type']] = $v['title'];
             }
         }
     }
     require_once core('ajax_table');
     $data['table'] = ajax_table(array('columns' => array(array('select' => 'id', 'display' => 'id', 'type' => 'checkbox', 'width' => '1px'), array('select' => 'email', 'display' => 'email', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'type', 'display' => 'type', 'type' => 'type', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_display' => 'type', 'filter_type' => 'array', 'filter_value' => array('' => '-- Все --') + $types, 'filter_field' => 'type')), 'from' => $this->table, 'where' => 'root_id=' . domainRootId(), 'params' => array('page' => $this->name, 'do' => 'show'), 'click' => 'ID=cb.value'), $this);
     $this->AddStrings($data);
     $data['thisname'] = $this->name;
     $data['thisname2'] = str_replace('/', '', $this->name);
     return Parse($data, "notify/tmpls/properties.tmpl");
 }
Пример #3
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     $positions = $this->getFilterPositions();
     if (!$positions) {
         echo "<p style='color: red;'>Не задан массив infoblocks_positions в файле settings.cfg.php</p>";
     }
     // строим таблицу
     require_once core('list_table');
     $columns = array(array('select' => 'p.id', 'display' => 'id', 'type' => 'checkbox'), array('select' => 'p.name', 'display' => 'name', 'flags' => FLAG_SORT | FLAG_SEARCH), domainRootID() > 0 ? array('select' => 'p.position', 'display' => 'position', 'type' => 'position', 'flags' => FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + $positions) : array('select' => 'p.position', 'display' => 'position', 'type' => 'position', 'flags' => FLAG_SEARCH), array('select' => 'IF(p.visible=1,1,2)', 'as' => 'visible', 'display' => 'visible', 'type' => 'visible', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет')), array('select' => 'IF(p.publ_announce=1,1,2)', 'as' => 'publ_announce', 'flags' => FLAG_FILTER, 'filter_type' => 'array', 'filter_display' => 'announce', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет')), array('select' => 'p.priority', 'display' => 'priority', 'flags' => FLAG_SORT), array('select' => 'p.id', 'display' => 'showurl', 'type' => 'showurl'), array('select' => 'p.id', 'display' => 'hiddenurl', 'type' => 'hiddenurl'), array('select' => 'p.title', 'flags' => FLAG_SEARCH), array('select' => 'p.header_text', 'flags' => FLAG_SEARCH), array('select' => '(SELECT GROUP_CONCAT(",", ir.url) FROM infoblocks_rules AS ir WHERE p.id=ir.pid GROUP BY p.id)', 'flags' => FLAG_SEARCH));
     // проверим сколько сайтов, если несколько то выводим колонку
     global $site_domains;
     $current = current($site_domains);
     if (count($site_domains) > 1 || count($current['langs']) > 1) {
         $columns[] = array('select' => 'p.root_id', 'display' => 'root_id', 'type' => 'showsites');
     }
     $data['table'] = list_table(array('columns' => $columns, 'from' => $this->table . " as p", 'orderby' => 'p.name ASC', 'where' => domainRootId() > 0 ? 'root_id=' . domainRootID() : '', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => 'editItem(p.id)', 'click' => 'ID=cb.value'), $this);
     $this->AddStrings($data);
     return $this->Parse($data, LIST_TEMPLATE);
 }
Пример #4
0
 /**
  * Оторажение списка персон
  * @return mixed
  */
 function Show()
 {
     if (!empty($_POST)) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     require_once core('list_table');
     $ret['table'] = list_table(array('columns' => array(array('select' => 'id', 'display' => 'id', 'type' => 'checkbox', 'width' => '1px'), array('select' => 'name', 'display' => 'name', 'flags' => FLAG_SEARCH | FLAG_SORT), array('select' => 'image', 'type' => 'imagepath', 'display' => 'image'), array('select' => 'visible', 'display' => 'visible', 'type' => 'visible', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет'), 'filter_field' => 'IF(visible=0,2,1)'), array('select' => 'priority', 'display' => 'priority', 'flags' => FLAG_SEARCH | FLAG_SORT)), 'from' => $this->table, 'where' => domainRootId() > 0 ? '(FIND_IN_SET(' . domainRootID() . ', root_ids) OR root_ids="")' : "", 'params' => array('page' => $this->name, 'do' => 'show'), 'orderby' => 'name', 'script' => "function pic_preview(obj) {\n                obj_href = \$(obj).attr('link');\n                obj_init = \$(obj).attr('init');\n                if (typeof(obj_init)=='undefined') {\n                \t\$(obj).fancybox({\n                \t    'href' : obj_href,\n                        'centerOnScroll': true,\n                        'autoScale'     : false,\n                        'transitionIn'\t: 'none',\n                        'transitionOut'\t: 'none',\n                        'hideOnOverlayClick' : false\n                \t});\n                \t\$(obj).attr('init', 1);\n                    \$(obj).click();\n                }\n            }"), $this);
     $ret['thisname'] = $this->name;
     return $this->Parse($ret, LIST_TEMPLATE);
 }
Пример #5
0
 function TDistribution()
 {
     global $actions, $str;
     // обязательно вызывать
     TNotify::TNotify();
     TTable::TTable();
     $str[get_class_name($this)] = array('title' => array('Отправить', 'Send'), 'plugins' => array('Вид сообщения', 'Plugin'), 'basic_caption' => array('Параметры', 'Properties'), 'sms' => array('SMS сообщение', 'SMS message'), 'email' => array('Электронная почта', 'E-mail'), 'news' => array('Рассылка новостей', 'News'), 'objects' => array('Рассылка объектов', 'Objects'), 'templates' => array('Шаблоны', 'Templates'), 'saved' => array('Данные успешно сохранены', 'Data has been saved successfully'));
     //собственныйе экшены
     $actions[$this->name] = array('send' => array('Отправить', 'Send', 'link' => 'cnt.Send();', 'img' => 'icon.countries.gif', 'display' => 'block', 'show_title' => true), 'preview' => array('Предварительный просмотр', 'Preview', 'link' => 'cnt.sendForm.Preview();', 'img' => 'icon.view.gif', 'display' => 'block', 'show_title' => true), 'save' => array('Сохранить', 'Send', 'link' => 'cnt.sendForm.Save();', 'img' => 'icon.save.gif', 'display' => 'block', 'show_title' => true));
     global $notify_subscribe;
     foreach ($notify_subscribe as $key => $val) {
         $notify_subscribe[$key] = str_replace('__ROOT_ID__', domainRootId(), $val);
     }
 }
Пример #6
0
 function ElemInit()
 {
     global $site_domains;
     $count = 0;
     foreach ($site_domains as $site) {
         foreach ($site['langs'] as $lang) {
             $count++;
         }
     }
     if ($count < 2) {
         $this->elem_fields['columns']['root_ids'] = array('type' => 'hidden', 'value' => domainRootId());
     }
     return parent::ElemInit();
 }
Пример #7
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     // строим таблицу
     require_once core('list_table');
     $data['table'] = list_table(array('columns' => array(array('select' => 'c.id', 'display' => 'id', 'type' => 'checkbox'), array('select' => 'UNIX_TIMESTAMP(c.date)', 'as' => 'date', 'display' => 'date', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'date', 'filter_value' => 'date', 'type' => 'date'), array('select' => 'IF(p.name IS NOT NULL, p.name, "-")', 'as' => 'publication', 'display' => 'publication', 'type' => 'publication_link'), array('select' => 'IF(a.name IS NOT NULL, a.name, c.name)', 'as' => 'user_name', 'display' => 'user_name', 'flags' => FLAG_SEARCH | FLAG_SORT, 'type' => 'user_link'), array('select' => 'c.text', 'type' => 'text', 'as' => 'descr', 'display' => 'text'), array('select' => 'c.visible', 'display' => 'visible', 'type' => 'visible', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет'), 'filter_field' => 'IF(c.visible=0,2,1)'), array('select' => 'c.user_id'), array('select' => 'c.publication_id'), array('select' => 'c.text', 'flags' => FLAG_SEARCH)), 'from' => $this->table . " as c\n\t\t\tLEFT JOIN `auth_users` as a ON a.id = c.user_id\n\t\t\tLEFT JOIN `publications` as p ON p.id = c.publication_id\n\t\t\tLEFT JOIN `tree` as t ON t.id = p.pid\n\t\t\t", 'where' => '(t.root_id=' . domainRootId() . ' OR t.root_id IS NULL)', 'orderby' => 'c.date DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => 'editItem(p.id)', 'click' => 'ID=cb.value'), $this);
     $this->AddStrings($data);
     return $this->Parse($data, LIST_TEMPLATE);
 }
Пример #8
0
 function TFmr()
 {
     global $str, $actions;
     TTable::TTable();
     $actions = array();
     $str[get_class_name($this)] = array_merge($str[get_class_name($this)], array('title' => array('Файловый менеджер', 'File Manager'), 'file' => array('Файл', 'File'), '_file' => array('Макс. размер: ', 'Max size'), 'resample' => array('Масштабировать', 'Scale'), '_resample' => array('только для JPEG формата', 'only for JPEG files'), 'watermark' => array('наложить водяной знак', 'add watermark'), 'edit' => array('Параметры файла', 'File params'), 'add' => array('Добавить файл', 'Add file'), 'name' => array('Название', 'Title'), '_name' => array('По-умолчанию равно названию файла', 'Default value is the name of the file'), 'name_' => array('Картинка', 'Picture'), 'date' => array('Дата', 'Date'), 'size' => array('Размер', 'Size'), 'width' => array('Ширина', 'Width'), 'height' => array('Высота', 'Height'), 'dimensions' => array('ШxВ', 'w*h'), 'description' => array('Описание<br>(255 символов)', 'Description<br>(255 symbol)'), 'wait' => array('Подождите, идет отправка...', 'Please wait, sending...'), 'link' => array('Ссылка', 'Link'), 'e_rename' => array('Произошла ошибка при переименовывании файла.', 'An error occurred while renaming the file.'), 'create' => array('Добавить', 'Create'), 'picture' => array('Просмотр', 'View'), 'thumbnail' => array('Картинка со ссылкой', 'Image with reference'), 'no_pic' => array('<span class=note>не выбрано</span>', '<span class=note>not selected</span>'), 'setpic' => array('Посмотреть', 'View'), 'set_pic' => array('В редактор &gt;&gt;', 'In a editor &gt;&gt;'), 'set_thumb' => array('В редактор &gt;&gt;', 'In a editor &gt;&gt;'), 'set_small' => array('Поставить как маленькую картинку', 'Set as a small picture'), 'set_big' => array('Поставить как картинку для pop-up окна', 'Set a pop-up picture'), 'small' => array('<span title=Поставить&nbsp;как&nbsp;маленькую&nbsp;картинку>&lt;М&gt;</span>', '<span title="Set&nbsp;as&nbsp;a&nbsp;small&nbsp;picture">&lt;М&gt;</span>'), 'big' => array('Доп.', 'Доп.'), 'pic' => array('&nbsp;', '&nbsp;'), 'upload' => array('Закачать новый файл', 'Upload new file'), 'submit' => array('Закачать', 'Upload'), 'paste' => array('Поместить в редактор', 'Поместить в редактор Put to the editor'), 'paste_head' => array('Поместить картинку в редактор', 'Put picture to the editor'), 'big_pic' => array('Картинка для pop-up', 'Picture for pop-up'), 'small_pic' => array('Основная картинка', 'Main picture'), 'folder' => array('&lt;папка&gt;', '&lt;folder&gt;'), 'del' => array('Удалить&nbsp;выделенное?', 'Delete&nbsp;selected?'), 'foldername' => array('Введите имя папки:', 'Enter the name of the folder:'), 'createfolder' => array('Создать папку', 'Create folder'), 'error' => array('Ошибка: ', 'Error:'), 'emakedir' => array('не удается создать папку: папка с таким именем уже существует', 'can not create a folder: a folder with that name already exists'), 'edeletedir' => array('не удается удалить непустую папку', 'unable to remove a nonempty folder'), 'search' => array('поиск', 'search'), 'reset' => array('cброс', 'clear'), 'back' => array('вернуться назад', 'back'), 'display' => array('Показывать по', 'Show on'), 'pages' => array('Страницы', 'Pages'), 'im_date' => array('Дата', 'Date'), 'im_size' => array('Размер', 'Size'), 'im_all' => array('Все', 'All'), 'im_pic' => array('Картинки', 'Picture'), 'im_nopic' => array('Не картинки', 'Not picture'), 'e_no_pic' => array('Вы не выбрали картинку.', 'You have not selected a picture'), 'e_no_dirname' => array('Введите имя директории', 'Enter the name of the directory'), 'no' => array('-', '-'), 'e_no_file' => array('Вы не выбрали файл.', 'You have not selected a file.'), 'e_not_writable' => array('Ошибка записи в файловую директорию (отсутствует или запрещена запись)', 'Error writable'), 'e_upload' => array('Ошибка переноса файла в директорию пользователя', 'Error upload'), 'paste' => array('Поместить в редактор', 'Paste')));
     $data['dirs'] = array();
     $data['defaults'] = array();
     $dir = FILES_DIR . domainRootId();
     if (!is_dir($dir)) {
         $dir = FILES_DIR;
     }
     $data['dirs'][] = $dir;
     $data['defaults']['dir'] = $dir;
 }
Пример #9
0
 function Show()
 {
     if (!empty($_POST)) {
         $action = get('actions', '', 'p');
         if ($action) {
             if ($this->Allow($action)) {
                 return $this->{$action}();
             } else {
                 return $this->alert_method_not_allowed();
             }
         }
     }
     require_once core('list_table');
     $data['table'] = list_table(array('columns' => array(array('select' => 'IFNULL(t2.id,t1.id)', 'as' => 'id', 'display' => 'id', 'type' => 'checkbox'), array('select' => "CONCAT(IF(t1.module='site', '', CONCAT(t1.module, '_')), t1.name)", 'as' => 'name', 'display' => 'name', 'flags' => FLAG_SEARCH | FLAG_SORT), array('select' => 't1.module', 'display' => 'module', 'type' => 'module_name', 'flags' => FLAG_SEARCH | FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('' => $this->str('all')) + $this->getSiteModules(), 'filter_str' => false), array('select' => 'IFNULL(t2.value,t1.value)', 'as' => 'value', 'display' => 'value', 'flags' => FLAG_SEARCH), array('select' => 'IF(t2.value IS NULL,1,0)', 'as' => 'is_default', 'display' => 'is_default', 'type' => 'visible', 'flags' => FLAG_SORT), array('select' => 'IFNULL(t2.def,t1.def)', 'display' => 'def', 'flags' => FLAG_SEARCH), array('select' => 'IFNULL(t2.description,t1.description)', 'display' => 'description', 'flags' => FLAG_SEARCH)), 'from' => $this->table . ' AS t1 LEFT JOIN ' . $this->table . ' AS t2 ON (t1.module=t2.module AND t1.name=t2.name AND t2.root_id=' . domainRootID() . ')', 'where' => domainRootId() > 0 ? 't1.root_id=' . getMainRootID() : '', 'orderby' => 't1.module,t1.name', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => 'editItem(id)', 'click' => 'ID=cb.value'), $this);
     $this->AddStrings($data);
     return $this->Parse($data, LIST_TEMPLATE);
 }
Пример #10
0
 function EditDownload()
 {
     $dir = get("down_dir", 'null', 'gp');
     $vdir = $this->verifyDir($dir);
     if (!is_array($vdir)) {
         $vdir = $this->getStartDir();
     }
     $dir = $vdir['dir'];
     $width = get("width", 0, 'gp');
     $height = get("height", 0, 'gp');
     $file = isset($_FILES['file']) ? $_FILES['file'] : "";
     if ($width != 0 || $height != 0) {
         $size = array($width, $height);
     }
     if (!empty($file)) {
         # находим несуществующее имя
         $file_name = GetPureName($file['name']);
         # уменьшаем рассширение файла, для номрального просмотра в fm
         $dot = strrpos($file_name, '.');
         $ext = strtolower(substr($file_name, $dot, strlen($file_name) - $dot));
         if (in_array($ext, $this->deny)) {
             echo "<script>alert('Вы не можете закачивать файлы с таким расширением.');</script>";
             return;
         }
         $file_name = substr($file_name, 0, $dot) . $ext;
         if (file_exists($this->SlashSep($dir, $file_name))) {
             $num = 1;
             while (file_exists($this->SlashSep($dir, new_file_name($file_name, '[' . $num . ']')))) {
                 $num++;
             }
             $file_name = new_file_name($file_name, '[' . $num . ']');
         }
         $file_put = $this->SlashSep($dir, $file_name);
         if (!move_uploaded_file($file['tmp_name'], $file_put)) {
             echo "<script>alert('Ошибка загрузки файла');</script>";
         }
         @chmod($file_put, FILES_MOD);
         @chown($file_put, fileowner($_SERVER['SCRIPT_FILENAME']));
         @chgrp($file_put, filegroup($_SERVER['SCRIPT_FILENAME']));
         # Ресайз
         if (!empty($size)) {
             $quality = sql_getValue('SELECT value FROM strings WHERE name="resize_quality" AND module="site" AND root_id=' . domainRootId() . ' AND lang="' . lang() . '"');
             if (!$quality) {
                 $quality = 85;
             }
             $file_name = ResampleImage($dir, $file_name, $size, false, $quality);
         }
         if (get('watermark', false, 'gp')) {
             $data = $this->config;
             $watermark = $data['module']['watermark_file'];
             if (!is_file(".." . $watermark)) {
                 echo "<script>alert('Не найден файл с водяным знаком!');</script>";
                 die;
             }
             $this->addWaterMark($file_name, ".." . $watermark);
         }
     }
     echo "\n\t\t<script>\n\t\tparent.openDir('" . $dir . "');\n\t\tparent.hideDownloadFrom();\n\t\tparent.stopMainLoad();\n\t\t</script>\n\t\t";
 }
Пример #11
0
 function SendSubscribe($data)
 {
     set_time_limit(0);
     ignore_user_abort(TRUE);
     // получаем список получателей
     switch ($data['users']) {
         case 'all':
             $data['users'] = sql_getRows("SELECT login as email, CONCAT(lname,' ',name) FROM auth_users WHERE root_id=" . domainRootId(), true);
             break;
         case 'subscribe':
         default:
             $data['users'] = sql_getRows("SELECT email, '' FROM subscribe_users WHERE root_id=" . domainRootId(), true);
             break;
     }
     //отправляем
     $sender = new TSender();
     // отправляем
     // подгружаем настройки для данного плугина
     $sender->params = $this->params;
     echo "<script>\n\n\t\t\t  window.onload = function(){\n\t\t\t  \t load();\n\t\t\t  }\n\n\t\t\t  function load(){\n\t\t\t  \ttry {";
     echo "window.top.document.getElementById('name').innerText = '" . $_SERVER['HTTP_HOST'] . "';";
     if (!empty($data['text'])) {
         $total = count($data['users']);
         # вытаскиваем все картинки из текста
         $images = array();
         $save_text = $data['text'];
         preg_match_all("~(src|background)\\s*=\\s*(\"|')(?!java)(?!mail)(?!ftp)(?!http)([^\"'#]+)(#\\w+)?(\"|')~i", $data['text'], $m);
         if (!empty($m)) {
             $images =& $m[3];
             //убираем дублирующиеся картинки
             foreach ($images as $key => $val) {
                 $img[$val] = 1;
             }
             if (!empty($img)) {
                 # меняем адреса картинок
                 foreach ($img as $key => $val) {
                     $names = explode('/', $key);
                     $name = end($names);
                     $data['text'] = str_replace($key, 'cid:' . $name, $data['text']);
                     $embedded[] = array('name' => $name, 'path' => '..' . $key, 'cid' => $name);
                 }
             }
         }
         $num = 0;
         foreach ($data['users'] as $k => $v) {
             $send = array('from' => sql_getValue("SELECT value FROM strings WHERE name='email_subscribe'"), 'fromName' => sql_getValue("SELECT value FROM strings WHERE name='name_subscribe'"), 'subj' => $data['subj'], 'to' => array($k => $v), 'mess' => array('html' => "<HTML><HEAD><META content=\"MSHTML 6.00.2800.1106\" name=GENERATOR></HEAD><BODY>" . $data['text'] . "</BODY></HTML>", 'text' => ''));
             if (isset($embedded)) {
                 $send['embedded'] = $embedded;
             }
             //pr($data);
             if ($sender->emailSend($send)) {
                 $num++;
                 foreach ($data['users'] as $email => $name) {
                     sql_query("INSERT INTO notify_sent(`plugin`, `whom`,`text`) VALUES('email','" . e($name) . "<" . e($email) . ">','" . e($save_text) . "')");
                 }
                 echo "parent.inRow('<b>" . $v . "</b>','<font color=\"Green\"><b>" . $this->str('mail_good') . "</b></font>');";
             } else {
                 echo "parent.inRow('<b>" . $v . "</b>','<font color=\"Red\"><b>" . $this->str('mail_bad') . "</b></font>');";
             }
             echo "window.top.run('" . $num / $total . "');";
         }
         echo "window.top.document.getElementById('send_footer').innerHTML = '<b>" . $this->str('sended') . " : " . $num . "</b>';";
     } else {
         echo "parent.inRow('<b>" . $this->str('error') . "</b>','<font color=\"Red\"><b>" . $this->str('err_notext') . "</b></font>');";
     }
     echo "    }\n\t\t\t\t  catch(e){}\n\t\t\t\t  finally{}\n\t\t\t  }\n\t\t\t  </script>";
     return $result;
 }
Пример #12
0
 /**
  * проверяет массив файлов и ресайзит их
  *
  * @param array() $fld
  * @param class $parent
  */
 function putFiles(&$fld, &$parent)
 {
     $main_root_id = defined('MAIN_ROOT_ID') ? MAIN_ROOT_ID : 100;
     $root_id = domainRootId();
     $module =& Registry::get('T' . $parent->name);
     $selector = $module ? (bool) $module->selector : true;
     foreach ($parent->elem_fields['columns'] as $k => $v) {
         if (($v['type'] == 'input_image' || $v['type'] == 'input_file') && !empty($fld[$k])) {
             if (substr($fld[$k], 0, 5) == '@temp') {
                 //перекладываем папку в нужную директорию
                 //определяем директорию использую id и folder для филда или общую
                 $source_file = substr($fld[$k], 5);
                 /*// пока закомментировала создание подпапок root_id, т.к. хотим от них отказаться
                   // позже введем какие-нибудь настройки
                    * if ($main_root_id == $root_id || !$selector) {
                       $folder = FILES_DIR;
                   }
                   else {
                       $folder = FILES_DIR . $root_id . '/';
                       if (!is_dir($folder)) {
                           mkdir($folder);
                           chmod($folder, DIRS_MOD);
                       }
                   }*/
                 $folder = FILES_DIR;
                 if (isset($v['display']['folder'])) {
                     $folder .= $v['folder'] . '/';
                     //Директория для закачивания собственная
                 } elseif ($parent->elem_fields['folder']) {
                     $folder .= $parent->elem_fields['folder'] . '/';
                     //Директория для закачивания глобальная
                 }
                 verifyDir($folder);
                 $id = get('id', '0', 'p');
                 $is_fancy = get('is_fancy', '', 'gp');
                 if ($is_fancy) {
                     $id = get('pid', '0', 'gp');
                 }
                 //иногда почему-то теряется id :)
                 if (is_array($id)) {
                     $id = $_POST['fld']['id'];
                 }
                 //@todo сделать проверку, что объект создан и id!=0 иначе как-нить раскладывать в другие папкив таких случаях,
                 //можно оставлять где попало и всо второго раза все будет ок..но тоже тупо:)
                 if ($id) {
                     $folder .= $id;
                 }
                 verifyDir($folder);
                 $dest_file = $folder . '/' . basename($source_file);
                 $dest_file = file_getUniName(path($dest_file));
                 //перемещаем
                 rename($source_file, $dest_file);
                 /*
                 copy($source_file, $dest_file);
                 unlink($source_file);
                 */
                 $fld[$k] = substr($dest_file, 2);
             } elseif ($fld[$k] == FILE_NO_SELECT_STR) {
                 $fld[$k] = "";
             }
         }
     }
 }
Пример #13
0
 function Save($unique)
 {
     $fld = get('fld', array(), 'p');
     $id = get('id', '', 'p');
     /*
         [recipient] => admin
         [types] => Array
             (
                 [email] => on
                 [sms] => on
             )
     
         [admins] => Array
             (
                 [email] => Array
                     (
                         [0] => 1
                         [1] => 3
                     )
     
                 [sms] => Array
                     (
                         [0] => 2
                         [1] => 1
                         [2] => 3
                     )
     
             )*/
     //Проверяем уникальные поля
     $query = '';
     foreach ($unique as $k => $field) {
         if (!empty($fld[$field])) {
             $query .= " `" . $field . "`='" . $fld[$field] . "' OR";
         }
     }
     if (!empty($query)) {
         //обрезаем последний OR
         $query = substr($query, 0, -2);
         //запрашиваем id
         $uid = sql_getValue("SELECT id FROM " . $this->table . " WHERE " . $query);
         if ($uid && $id != $uid) {
             return "<script>alert('" . $this->str('error_name') . "');</script>";
         }
     }
     // добавляем новую запись
     if (!$id) {
         $sql = sql_query("INSERT INTO " . $this->table . " (`name`,`description`,`comments`,`recipient`) VALUES('" . htmlspecialchars($fld['name']) . "', '" . htmlspecialchars($fld['description']) . "', '" . htmlspecialchars($fld['comments']) . "', '" . $fld['recipient'] . "')");
         if (!$sql) {
             trigger_error(sql_getError(), E_USER_ERROR);
         } else {
             $id = sql_getLastId();
         }
     } else {
         if (is_devel()) {
             $sql = sql_query("UPDATE " . $this->table . " SET name='" . htmlspecialchars($fld['name']) . "', description='" . htmlspecialchars($fld['description']) . "', comments='" . htmlspecialchars($fld['comments']) . "',recipient='" . $fld['recipient'] . "' WHERE id=" . $id);
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         } elseif (isset($fld['description']) & !empty($fld['description'])) {
             $sql = sql_query("UPDATE " . $this->table . " SET description='" . htmlspecialchars($fld['description']) . "' WHERE id=" . $id);
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         }
     }
     //удаляем всех админов для данного события
     $root = domainRootId();
     sql_query("DELETE FROM notify_admins WHERE event=" . $id . " AND root_id=" . $root);
     $types = $fld['types'];
     if ($fld['recipient'] == 'admin') {
         unset($fld['types']);
         if (isset($fld['admins'])) {
             foreach ($fld['admins'] as $plugin => $it) {
                 if (isset($types[$plugin])) {
                     foreach ($it as $k => $admin_id) {
                         sql_query("INSERT INTO notify_admins(`event`,`admin_id`,`type`,`root_id`) VALUES(" . $id . "," . $admin_id . ",'" . $plugin . "'," . $root . ")");
                     }
                     $fld['types'][$plugin] = 'on';
                 }
             }
         }
     }
     $sql = sql_query("DELETE FROM notify_compare WHERE event=" . $id);
     if (!$sql) {
         trigger_error(sql_getError(), E_USER_ERROR);
     }
     if (isset($fld['types']) & !empty($fld['types'])) {
         foreach ($fld['types'] as $k => $v) {
             $sql = sql_query("INSERT INTO notify_compare(`event`,`plugin`) VALUES ('" . $id . "', '" . $k . "')");
             if (!$sql) {
                 trigger_error(sql_getError(), E_USER_ERROR);
             }
         }
     }
     return $id;
 }