Пример #1
1
 function CreateEmail($mailto = '', $subject = '', $text = '')
 {
     $this->AddStrings($row);
     if ($mailto == 'use_client_selection' && $_SESSION['use_client_selection']) {
         $client_selection = join(' AND ', $_SESSION['use_client_selection']);
         $row['use_client_selection'] = '1';
         $emails = $this->GetValue("SELECT COUNT(*) FROM clients AS c WHERE subscribe=1 AND " . $client_selection);
         $row['mailto'] = sprintf($this->str('client_selection'), $emails);
         $row['mailto_readonly'] = 'READONLY';
     } else {
         $row['mailto'] = htmlspecialchars($mailto);
         $row['use_client_selection'] = '0';
         $row['client_selector']['value'] = ' ';
     }
     $row['subject'] = htmlspecialchars($subject);
     $managers = sql_getRows("SELECT id, CONCAT(fullname,' &lt;',email,'&gt;') FROM admins WHERE email<>'' " . (is_root() ? '' : "AND id IN (" . join(',', $this->user['subst']) . ") AND fullname!=''") . " ORDER BY fullname", true);
     $row['managers'] = $this->GetArrayOptions($managers, $this->user['id'], true);
     ###
     include "editor/fckeditor.php";
     $oFCKeditor = new FCKeditor();
     $oFCKeditor->ToolbarSet = 'Common';
     $oFCKeditor->Value = $text;
     $row['editor'] = $oFCKeditor->ReturnFCKeditor('editor[html]', '100%', '100%');
     ###
     return Parse($row, $this->name . '.tmpl');
 }
Пример #2
0
 function Show()
 {
     global $limit;
     $this->Init();
     $this->AddStrings($ret);
     $offset = (int) get('offset');
     $limit = (int) get('limit', $this->Param('limit', $limit));
     $count = sql_getValue("SELECT COUNT(*) FROM " . STAT_SESSIONS_TABLE . " WHERE robot=0 AND time_last>" . (time() - STAT_SESS_TIME * 60));
     $data = sql_getRows("SELECT ip, 'count_pages', path, time, time_last FROM " . STAT_SESSIONS_TABLE . " WHERE robot=0 AND time_last>" . (time() - STAT_SESS_TIME * 60) . " ORDER BY time_last DESC LIMIT " . $offset . ", " . $limit);
     // Построить массив для всех страниц ($this->path)
     if ($data) {
         $pages_id = array();
         foreach ($data as $row) {
             $pages_id = array_merge($pages_id, explode(' ', trim($row['path'])));
         }
         $pages_id = array_unique($pages_id);
         $this->path_pages = sql_getRows("SELECT id, CONCAT(host, uri) AS page FROM " . STAT_PAGES_TABLE . " WHERE id IN (" . join(', ', $pages_id) . ")", true);
         $this->path_keys = array_flip(array_keys($this->path_pages));
         foreach ($this->path_pages as $page_id => $href) {
             $ret['pathes']['row'][] = array('key' => $this->path_keys[$page_id] + 1, 'href' => $href);
         }
     }
     // Main Table
     $columns = array(array('header' => 'ip', 'nowrap' => '1', 'type' => 'ip'), array('header' => 'pages', 'align' => 'right', 'type' => 'pages'), array('header' => 'pathes', 'type' => 'path'), array('header' => 'time', 'align' => 'right', 'type' => 'time'), array('header' => 'last', 'align' => 'right', 'type' => 'last'));
     if (isset($GLOBALS['_stat']['stat/stat_banlist'])) {
         $columns[] = array('header' => 'ban', 'type' => 'ban', 'align' => 'center');
     }
     $ret['table'] = $this->stat_table(array('columns' => $columns, 'data' => $data, 'count' => $count, 'offset' => $offset, 'limit' => $limit));
     $ret['navig'] = $this->NavigForm(array('hidden' => array('show' => $this->show)));
     return Parse($ret, 'stat/stat.no_navig.tmpl');
 }
Пример #3
0
    function Show()
    {
        if (!empty($GLOBALS['_POST'])) {
            $actions = get('actions', '', 'p');
            if ($actions) {
                return $this->{$actions}();
            }
        }
        require_once core('ajax_table');
        $ret['id'] = 0;
        $ret['auth_group'] = (int) get('auth_group');
        $ret['auth_groups'] = sql_getRows('select id, name from auth_groups order by priority, name', true);
        if (!$ret['auth_group']) {
            $ret['auth_group'] = key($ret['auth_groups']);
        }
        $ret['auth_group_type'] = sql_getValue('
			SELECT dt.type
			FROM auth_groups AS ag
			LEFT JOIN discount_types AS dt ON dt.id = ag.discount_type
			WHERE ag.id = ' . $ret['auth_group']);
        if ($ret['auth_group_type'] == 'fix') {
            $ret['table'] = ajax_table(array('columns' => array(array('select' => 'dg.id', 'type' => 'checkbox'), array('select' => 'dg.name', 'display' => 'product_group'), array('select' => 'discounts.discount', 'display' => 'discount', 'type' => 'edit', 'align' => 'right', 'text-align' => 'right', 'maxlength' => 2, 'size' => 2), array('select' => '""', 'display' => '', 'width' => '50%')), 'from' => 'discount_groups AS dg 
				LEFT OUTER JOIN discounts ON discounts.discount_group_id = dg.id AND discounts.user_discount_group_id=' . $ret['auth_group'], 'orderby' => 'priority, name', 'params' => array('page' => $this->name, 'do' => 'show', 'id' => '', 'auth_group' => $ret['auth_group']), 'click' => 'ID=cb.value;'), $this);
        } else {
            $ret['table'] = ajax_table(array('columns' => array(array('select' => 'id', 'type' => 'checkbox', 'display' => 'id'), array('select' => 'volume', 'display' => 'upvolume', 'type' => 'edit', 'align' => 'right', 'text-align' => 'right', 'maxlength' => 10, 'size' => 10), array('select' => 'discount', 'display' => 'discount', 'type' => 'edit', 'align' => 'right', 'text-align' => 'right', 'maxlength' => 2, 'size' => 2), array('select' => '""', 'display' => '', 'width' => '50%')), 'from' => 'discounts_volume', 'where' => 'auth_group_id=' . $ret['auth_group'], 'orderby' => 'volume', 'params' => array('page' => $this->name, 'do' => 'show', 'id' => '', 'auth_group' => $ret['auth_group']), 'click' => 'ID=cb.value;'), $this);
        }
        $this->AddStrings($ret);
        return $this->Parse($ret, $this->name . '.tmpl');
    }
Пример #4
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     $this->SetValues();
     require_once core('ajax_table');
     $data['thisname'] = $this->name;
     $data['root'] = is_root();
     $this->AddStrings($data);
     $_tables = sql_getRows('SHOW tables');
     foreach ($_tables as $key => $val) {
         $tables[$val] = $val;
     }
     $_transactions = sql_getColumn('SELECT distinct action FROM ' . $this->table . ' ORDER BY action');
     foreach ($_transactions as $key => $val) {
         $transactions[$val] = $val;
     }
     $where = '';
     if ($this->from_date && $this->to_date) {
         $where = ' UNIX_TIMESTAMP(date)>=' . $this->from_date . ' AND UNIX_TIMESTAMP(date)<=' . $this->to_date;
     }
     $data['table'] = ajax_table(array('columns' => array(array('select' => 'user', 'display' => 'user', 'width' => '1px', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'object', 'display' => 'object', 'width' => '1px', 'flags' => FLAG_SORT | FLAG_FILTER | FLAG_SEARCH, 'filter_type' => 'array', 'filter_value' => array('' => '-- все --') + $tables, 'filter_rule' => 'find_in_set'), array('select' => 'action', 'display' => 'action', 'width' => '1px', 'flags' => FLAG_SORT | FLAG_FILTER | FLAG_SEARCH, 'filter_type' => 'array', 'filter_value' => array('' => '-- все --') + $transactions), array('select' => 'description', 'display' => 'description', 'type' => 'description', 'flags' => FLAG_SEARCH), array('select' => 'date', 'display' => 'date', 'type' => 'datetime', 'width' => '100px', 'flags' => FLAG_SORT)), 'from' => $this->table, 'where' => $where, 'orderby' => 'date DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => '', 'click' => ''), $this);
     $data['navig'] = $this->NavigForm();
     return $this->parse($data, $this->name . '.tmpl');
 }
Пример #5
0
 function ElemInit()
 {
     $id_user = (int) get('id', 0, 'pg');
     global $site_domains;
     $user_roles = array();
     $user_roles_tmp = sql_getRows("SELECT * FROM auth_users_roles WHERE user_id = " . (int) $id_user);
     $roles = sql_getRows("SELECT * FROM acl_roles");
     foreach ($user_roles_tmp as $v) {
         $user_roles[$v['root_id']][$v['role_id']] = true;
     }
     unset($user_roles_tmp);
     // рисуем таблицу
     $data = '<table class="ajax_table_main" cellspacing="1">';
     $data .= '<tr class="ajax_table_header_row">';
     $data .= '<th class="ajax_table_header_cell">&nbsp;</th>';
     foreach ($roles as $role) {
         $data .= '<th class="ajax_table_header_cell" style="text-align: center;">' . $role['description'] . '</th>';
     }
     $data .= '</tr>';
     foreach ($site_domains as $site) {
         foreach ($site['langs'] as $l) {
             $data .= '<tr class="ajax_table_row">';
             $data .= '<td class="ajax_table_cell" style="text-align: left; vertical-align: middle">' . $site['descr'] . (count($site['langs']) > 1 ? ' (' . $l['descr'] . ')' : '') . '<br /><a target="_blank" href="http://' . $site['name'] . '/' . (count($site['langs']) > 1 ? $l['name'] : '') . '">' . $site['name'] . '</a></td>';
             reset($roles);
             foreach ($roles as $role) {
                 $role_checked = isset($user_roles[$l['root_id']][$role['id']]) ? "checked" : null;
                 $data .= '<td class="ajax_table_cell" style="text-align: center;"><input type="checkbox" name="fld[sites][' . $l['root_id'] . '][roles][' . $role['id'] . ']" value="1" ' . $role_checked . ' /></td>';
             }
             $data .= '</tr>';
         }
     }
     $data .= '</table>';
     $this->elem_fields['columns']['data']['value'] = $data;
     return parent::ElemInit();
 }
Пример #6
0
 function ElemInit()
 {
     $columns = sql_getRows("SHOW COLUMNS FROM " . $this->elem_table . "", true);
     if (!isset($columns['footer_text_radio'])) {
         sql_query("ALTER TABLE " . $this->elem_table . " ADD footer_text_radio TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0 -  редактор текста; 1 - html-код баннера'");
     }
     if (!isset($columns['footer_title'])) {
         sql_query("ALTER TABLE {$this->elem_table} ADD footer_title VARCHAR( 255 ) NOT NULL COMMENT 'Название кнопки Подробнее';");
     }
     if (!isset($columns['footer_title_link'])) {
         sql_query("ALTER TABLE {$this->elem_table} ADD footer_title_link VARCHAR( 255 ) NOT NULL COMMENT 'Ссылка на кнопке Подробнее';");
     }
     $id = (int) get('id');
     if ($id) {
         $infoblock_end = sql_getRow("SELECT * FROM " . $this->elem_table . " WHERE id = " . $id);
         if ($infoblock_end['footer_text_radio']) {
             $this->elem_fields['columns']['footer_text']['value'] = htmlspecialchars($infoblock_end['footer_text']);
             $this->elem_fields['columns']['footer_text_area']['value'] = $infoblock_end['footer_text'];
         } else {
             $this->elem_fields['columns']['footer_text_fck']['value'] = $infoblock_end['footer_text'];
         }
     }
     $this->script .= "\n\n        function elem1(name) {\n            return \$('#tr_fld\\\\[" . $this->tabname . "\\\\]\\\\[' + name + '\\\\]');\n        }\n\n        function elemName1(name) {\n            return 'fld[" . $this->tabname . "][' + name + ']';\n        };\n\n        function getFck1(name) {\n            name = elemName1(name);\n            for(nameFck in CKEDITOR.instances) {\n                if(name == nameFck) {\n                    return CKEDITOR.instances[name];\n                }\n            }\n        }\n\n        function open_fck_footer(name_fck, name_area) {\n            var fck = getFck1(name_fck);\n            var footer_text_fck = \$(elem1(name_fck));\n            var footer_text_area = \$(elem1(name_area));\n\n            footer_text_fck.children('span').show();\n            footer_text_area.hide();\n\n            var data = footer_text_area.children('textarea').val();\n            if (data.length) fck.setData(data);\n\n            fck.container.show();\n            fck.updateElement();\n        }\n\n        function close_fck_footer(name_fck, name_area) {\n            var fck = getFck1(name_fck);\n            var footer_text_fck = \$(elem1(name_fck));\n            var footer_text_area = \$(elem1(name_area));\n            fck.container.hide();\n            fck.updateElement();\n\n            footer_text_fck.children('span').hide();\n            footer_text_area.show();\n            footer_text_area.children('textarea').css({\n                'width'         :   '98%',\n                'height'        :   fck.config.height\n            });\n\n            var data = fck.getData();\n            if (data.length) footer_text_area.children('textarea').val(data);\n        }\n\n        \$(function () {\n            var footer_text_radio   = \$(elem1('footer_text_radio')).children('input');\n            \$(footer_text_radio).click(function() {\n                if(\$(this).val() == 1) {\n                    close_fck_footer('footer_text_fck', 'footer_text_area');\n                } else {\n                    open_fck_footer('footer_text_fck', 'footer_text_area');\n                }\n            });\n\n            CKEDITOR.on( 'instanceReady', function( ev )\n            {\n                " . (isset($infoblock_end) && $infoblock_end['footer_text_radio'] ? "close_fck_footer" : "open_fck_footer") . "('footer_text_fck', 'footer_text_area');\n            });\n        });\n    ";
     TElems::ElemInit();
 }
Пример #7
0
 function GetTable()
 {
     global $limit;
     $offset = (int) get('offset');
     $limit = (int) get('limit', $this->Param('limit', $limit));
     $search = get('find', '');
     $search_state = '';
     if (!empty($search)) {
         $search_state = ' AND (city.name LIKE "' . $search . '" OR region.name LIKE "' . $search . '")';
     }
     $q = "SELECT city.name AS city, COUNT(*) AS kol, COUNT(*) as proc, region.name as region\n\t\tFROM " . $this->sess_table . " AS sess\n\t\tLEFT JOIN " . STAT_CITIES_TABLE . " AS city ON sess.city = city.id\n\t\tLEFT JOIN " . STAT_REGIONS_TABLE . " AS region ON city.reg = region.id\n\t\tWHERE sess.robot=0 {$search_state}\n\t\tGROUP BY sess.city\n\t\tORDER BY kol DESC\n\t\t";
     $data = sql_getRows($q);
     $all_total = sql_getValue("SELECT COUNT(*) FROM " . $this->sess_table . " AS sess\n        LEFT JOIN " . STAT_CITIES_TABLE . " AS city ON sess.city = city.id\n        LEFT JOIN " . STAT_REGIONS_TABLE . " AS region ON city.reg = region.id\n        WHERE sess.robot=0");
     # исправляем пустое имя
     foreach ($data as $k => $v) {
         if ($v['city'] == '') {
             $data[$k]['city'] = $this->str('unknown_city');
         } else {
             $data[$k]['city'] = $v['city'] . ' (' . $v['region'] . ')';
         }
     }
     # считаем проценты и записываем для каждого значения
     foreach ($data as $k => $v) {
         $data[$k]['proc'] = 100 * $v['kol'] / $all_total;
         unset($data[$k]['region']);
     }
     $total_head = array('', $this->str('visitors'));
     $total[] = array($this->str('total_period'), $all_total);
     // Main Table
     $ret['table'] = $this->stat_table(array('columns' => array(array('header' => 'city', 'nowrap' => 1, 'type' => 'city'), array('header' => 'visitors', 'align' => 'right', 'width' => '20%'), array('header' => 'percent', 'align' => 'right', 'width' => '50%', 'type' => 'graph')), 'data' => $data, 'total' => $total, 'total_head' => $total_head, 'count' => count($data), 'offset' => $offset, 'limit' => $limit));
     return $ret;
 }
Пример #8
0
 function ElemInit()
 {
     $columns = sql_getRows("SHOW COLUMNS FROM `publications`", true);
     if (!isset($columns['allow_comments'])) {
         unset($this->elem_fields['columns']['allow_comments']);
     }
     return parent::ElemInit();
 }
Пример #9
0
 function GetCSVData()
 {
     $filename = $_SERVER['DOCUMENT_ROOT'] . BASE . '.backup/' . $this->name . '_' . date('Y-m-d') . '.csv';
     // заголовки
     echo $this->_str('ips') . ';' . $this->_str('viewed') . "\n";
     $rows = sql_getRows("\n\t\t\tSELECT IF(ip<0, INET_NTOA(ip+4294967296), INET_NTOA(ip)) as name, COUNT(*) as kol\n\t\t\tFROM " . $this->sess_table . "\n\t\t\tWHERE robot=0 GROUP BY ip ORDER BY kol DESC");
     foreach ($rows as $k => $v) {
         echo (isset($v['name']) ? $v['name'] : 0) . ';' . (isset($v['kol']) ? $v['kol'] : 0) . "\n";
     }
 }
Пример #10
0
 function dynamic_img()
 {
     $images = sql_getRows("SELECT * FROM `" . $this->table . "`\n        WHERE\n            image != '' AND\n            visible = '1' AND\n            FIND_IN_SET('" . ROOT_ID . "', root_ids)\n        ORDER BY priority, name", true);
     foreach ($images as $key => $value) {
         if (!is_file(substr($value['image'], 1))) {
             unset($images[$key]);
         }
     }
     return array('slider' => $images);
 }
Пример #11
0
 function GetCSVData()
 {
     // заголовки
     $data = $this->_str('date') . ';' . $this->_str('time') . ';' . $this->_str('ip') . ';' . $this->_str('host1') . ';' . $this->_str('address1') . ';' . $this->_str('host2') . ';' . $this->_str('address2') . ';' . $this->_str('agent') . ';' . $this->_str('country') . ';' . $this->_str('search') . ';' . $this->_str('client') . "\n";
     $sql = "SELECT temp.time, IF(s.ip<0, INET_NTOA(s.ip+4294967296), INET_NTOA(s.ip)) as ip, p1.uri as address1, p2.uri as address2, p2.search_ph as search, p1.host as host1, p2.host as host2, a.name as agent, c.name_" . lang() . " as country, CONCAT(auth.login,' <',auth.lname,' ',auth.name,' ',auth.tname,'> ') as client FROM " . $this->log_table . " AS temp\n        LEFT JOIN stat_sessions AS s ON s.sess_id=temp.sess_id\n        LEFT JOIN stat_pages AS p1 ON p1.id=temp.page_id\n        LEFT JOIN stat_pages AS p2 ON p2.id=temp.ref_id\n        LEFT JOIN stat_agents AS a ON a.id=s.agent_id\n        LEFT JOIN auth_users AS auth ON auth.id=s.client_id\n        LEFT JOIN " . STAT_COUNTRIES_TABLE . " AS c ON c.country_id=s.country";
     $rows = sql_getRows($sql);
     foreach ($rows as $k => $v) {
         $data .= (isset($v['time']) ? date("d-m-Y", $v['time']) : 0) . ';' . (isset($v['time']) ? date("H:i:s", $v['time']) : 0) . ';' . (isset($v['ip']) ? $v['ip'] : 0) . ';' . (isset($v['host1']) ? $v['host1'] : '') . ';' . (isset($v['address1']) ? $v['address1'] : '') . ';' . (isset($v['host2']) ? $v['host2'] : '') . ';' . (isset($v['address2']) ? $v['address2'] : '') . ';' . (isset($v['agent']) ? $v['agent'] : '') . ';' . (isset($v['country']) ? $v['country'] : '') . ';' . (isset($v['search']) ? $v['search'] : '') . ';' . (isset($v['client']) ? $v['client'] : '') . "\n";
     }
     return $data;
 }
Пример #12
0
 function ShowRecycle()
 {
     global $limit;
     $limit = -1;
     require_once core('ajax_table');
     $columns = sql_getRows('SHOW columns FROM ' . $this->table, 'Field');
     $name = isset($columns['name']) ? 'name' : 'address';
     $this->AddStrings($row);
     $row['table'] = ajax_table(array('columns' => array(array('select' => 'id', 'display' => 'id', 'type' => 'checkbox'), array('select' => $name, 'display' => 'name')), 'where' => 'visible<0 and obj_type_id="room"', 'orderby' => 'address', 'params' => array('page' => $this->name, 'do' => 'Show')), $this);
     return Parse($row, 'recycle.tmpl');
 }
Пример #13
0
 function ElemInit()
 {
     $columns = sql_getRows("SHOW COLUMNS FROM `tree`", true);
     if (!isset($columns['redirect'])) {
         sql_query("ALTER TABLE tree ADD redirect VARCHAR( 255 ) NOT NULL;");
     }
     if (!isset($columns['is_link'])) {
         sql_query("ALTER TABLE tree ADD is_link TINYINT( 1 ) NOT NULL DEFAULT '0';");
     }
     parent::ElemInit();
 }
Пример #14
0
 function table_get_product(&$value, &$column, &$row)
 {
     $sql = "SELECT id, name FROM products WHERE product_type_id=" . $row['id'];
     $products = array('0' => 'не указан') + sql_getRows($sql, true);
     $html = "\n\t\t\t <input type='hidden' name='fld[" . $row['id'] . "][composition_id]' value='" . $row['composition_id'] . "'>\n\t\t\t <input type='hidden' name='fld[" . $row['id'] . "][id]' value='" . $row['id'] . "'>\n\t\t";
     $html .= "<select name='fld[" . $row['id'] . "][elem_id]'>";
     foreach ($products as $k => $v) {
         $html .= "<option value='" . $k . "' " . ($k == $value ? "selected" : "") . ">" . $v . "</option>\t";
     }
     $html .= "</select>";
     return $html;
 }
Пример #15
0
 function GetCSVData()
 {
     $filename = $_SERVER['DOCUMENT_ROOT'] . BASE . '.backup/' . $this->name . '_' . date('Y-m-d') . '.csv';
     // заголовки
     echo $this->_str('client_name') . ';' . $this->_str('sessions') . "\n";
     $this->sess_table = 'stat_sessions';
     sql_query("\n\t\t\tCREATE TEMPORARY TABLE tmp_stat_clients\n\t\t\tSELECT sess.client_id AS client_id, cl.name AS name , cl.lname AS surname\n\t\t\tFROM " . $this->sess_table . " AS sess LEFT JOIN " . $this->clients_table . " AS cl ON cl.id=sess.client_id\n\t\t\tWHERE sess.client_id!=0 AND sess.robot=0");
     $rows = sql_getRows("SELECT IF(name<>'',name,'n/a') AS name, COUNT(*) AS kol FROM tmp_stat_clients GROUP BY client_id ORDER BY kol DESC");
     foreach ($rows as $k => $v) {
         echo (isset($v['name']) ? $v['name'] : 0) . ';' . (isset($v['kol']) ? $v['kol'] : 0) . "\n";
     }
 }
Пример #16
0
 /**
  * Создание списка из БД
  * @param $type
  * @param int $pid
  * @param array $ret
  * @return array
  */
 function createList($type, $pid = 0, $ret = array())
 {
     $table = "_table_" . $type;
     $list = sql_getRows("\n        SELECT t.*, t2.name AS parent\n        FROM {$this->{$table}} AS t\n        LEFT JOIN {$this->{$table}} AS t2 ON t2.id=t.pid\n        WHERE " . ($pid ? "t.pid=" . $pid : "t.pid IS NULL"));
     $ret = array_merge($ret, $list);
     foreach ($list as $item) {
         $l = $this->createList($type, $item['id']);
         if (is_array($l)) {
             $ret = array_merge($ret, $l);
         }
     }
     return $ret;
 }
Пример #17
0
 function Edit()
 {
     $fld = $_POST['fld'];
     if (empty($fld['priority'])) {
         $pr = sql_getRows('SELECT priority FROM ' . $this->table . ' ORDER BY priority DESC');
         $fld['priority'] = current($pr) + 1;
     }
     $_POST['fld'] = $fld;
     $res = $this->Commit(array('name'), true);
     if (is_int($res)) {
         return "<script>alert('" . $this->str('saved') . "'); window.parent.location.reload();</script>";
     }
     return $this->Error($res);
 }
Пример #18
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     require_once core('list_table');
     $ret['thisname'] = $this->name . '.editform';
     $ret['table'] = list_table(array('columns' => array(array('select' => 'id'), array('select' => 'date', 'display' => 'date'), array('select' => 'event', 'display' => 'event', 'flags' => FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array(0 => $str[get_class_name($this)]['all_events']) + sql_getRows("SELECT DISTINCT `event`,`event` FROM `notify_events` ORDER BY `event`", true)), array('select' => 'email', 'display' => 'email')), 'from' => $this->table, 'orderby' => '`date` DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'click' => 'ID=cb.value', 'dblclick' => 'editItem(id)'), $this);
     $this->AddStrings($ret);
     return $this->Parse($ret, LIST_TEMPLATE);
 }
Пример #19
0
 function getWCfromDb($id)
 {
     $row = $this->GetRow('SELECT *, ' . $this->getFieldName('name', true) . ', ' . $this->getFieldName('email', true) . ' FROM elem_form WHERE pid=' . $id);
     if ($row['form_id']) {
         $row['elems'] = sql_getRows('SELECT *, ' . $this->getFieldName('text', true) . ' FROM elem_form_elems WHERE pid=' . $row['form_id']);
         foreach ($row['elems'] as $k => $v) {
             $row['elems'][$k]['value'] = "'" . implode("','", sql_getRows('SELECT ' . $this->getFieldName('text', true) . ' FROM elem_form_values WHERE pid=' . $v['id'])) . "'";
         }
     }
     if (empty($row['elems'])) {
         unset($row['form_id']);
         unset($row['elems']);
     }
     return $row;
 }
Пример #20
0
 function GetText()
 {
     # выдача скрипта, который возвращает значение из модального окна
     $instance = get('instance', '', 'p');
     $ptable = get('ptable', '', 'p');
     $pfields = get('pfields', '', 'p');
     $pid = (int) get('pid', 0, 'p');
     $uptime = get('uptime', 0, 'p');
     $hash = get('hash', 0, 'p');
     # поля, которые нужны..
     $pfields = explode(", ", $pfields);
     foreach ($pfields as $field) {
         $name = explode("fld[", $field);
         $name = explode("]", $name[1]);
         $fields[] = $name[0];
     }
     # выбираем текущее значение
     $row = sql_getRow('SELECT * FROM ' . $ptable . ' WHERE id=' . $pid);
     # выбираем все изменения
     $changes = sql_getRows('SELECT gzip FROM ' . $this->table . ' WHERE ptable="' . $ptable . '" AND pid=' . $pid . ' AND uptime >= ' . $uptime . ' ORDER BY uptime DESC');
     # начинаем изменять текущие значения проходя по массивам...
     foreach ($changes as $value) {
         $a = unserialize(gzuncompress($value));
         $row = array_merge($row, $a);
     }
     $keys = array();
     $values = array();
     foreach ($row as $key => $value) {
         if (!in_array($key, $fields)) {
             unset($row[$key]);
         } else {
             $keys[] = "'" . $key . "'";
             $values[] = "'" . $value . "'";
         }
     }
     # $row - массив значений, которые были на заданную дату
     $script = '<script type="text/javascript">' . "\n";
     $script .= "function data() {\n";
     $script .= "  this.key = new Array(" . implode(",", $keys) . ");\n";
     $script .= "  this.value = new Array(" . implode(",", $values) . ");\n";
     $script .= "}\n";
     $script .= "data = new data();";
     $script .= 'window.returnValue = data;' . "\n";
     $script .= 'window.close();';
     $script .= '</script>';
     return $script;
 }
Пример #21
0
 function TSite_usersBase()
 {
     global $str, $actions;
     TTable::TTable();
     $actions[$this->name] = array('edit' => &$actions['table']['edit'], 'create' => &$actions['table']['create'], 'delete' => &$actions['table']['delete']);
     $actions[$this->name . '.editform'] = array('save' => array('title' => array('ru' => 'Сохранить', 'en' => 'Save'), 'onclick' => 'document.forms[\'editform\'].submit(); return false;', 'img' => 'icon.save.gif', 'display' => 'block', 'show_title' => true), 'cancel' => array('title' => array('ru' => 'Назад', 'en' => 'Back'), 'onclick' => 'window.location=\'/admin/?page=' . $this->name . '\'', 'img' => 'icon.close.gif', 'display' => 'block', 'show_title' => true));
     if ((int) $_GET['id']) {
         $temp = sql_getValue("SELECT name FROM " . $this->table . " WHERE id=" . (int) $_GET['id']);
     } else {
         $temp = "Новый пользователь";
     }
     $str[get_class_name($this)] = array_merge($str[get_class_name($this)], array('title' => array('Пользователи', 'Ste ue'), 'title_editform' => array("Пользователь: " . $temp, 'Law: ' . $temp), 'login' => array('Логин', 'Login'), 'name' => array('Имя', 'Name'), 'email' => array('Email', 'Email'), 'saved' => array('Даные были успешно сохранены', 'Data has been saved successfully')));
     $tables = sql_getRows("SHOW tables LIKE 'acl_%'");
     if (!$tables) {
         $this->elements = array();
     }
 }
Пример #22
0
 function Show()
 {
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     require_once core('list_table');
     $data['thisname'] = $this->name;
     $logins = array('' => '-') + sql_getRows('SELECT DISTINCT login FROM ' . $this->table . ' ORDER BY login', true);
     $data['root'] = is_root();
     $this->AddStrings($data);
     $data['table'] = list_table(array('columns' => array(array('select' => 'login', 'display' => 'login', 'flags' => FLAG_SORT | FLAG_SEARCH | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => $logins), array('select' => 'ip', 'display' => 'ip', 'width' => '1px', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'date', 'display' => 'date', 'type' => 'datetime', 'width' => '100px', 'flags' => FLAG_SORT)), 'from' => ' log_access ', 'orderby' => 'date DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => '', 'click' => ''), $this);
     $this->AddStrings($data);
     return $this->Parse($data, LIST_TEMPLATE);
 }
Пример #23
0
    function Show()
    {
        if (!empty($_POST)) {
            $actions = get('actions', '', 'p');
            if ($actions) {
                return $this->{$actions}();
            }
        }
        $pids = $this->getChilds();
        $this->getList($pids, $rows, 1);
        $districts = sql_getRows('SELECT id, name FROM ' . $this->table . ' WHERE pid IS NULL ORDER BY name', true);
        require_once core('ajax_table');
        $ret['table'] = ajax_table(array('columns' => array(array('select' => 'd4.id', 'display' => 'id', 'type' => 'checkbox'), array('select' => 'd4.name', 'display' => 'district', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'd1.pid', 'flags' => FLAG_FILTER, 'filter_display' => 'pid1', 'filter_type' => 'array', 'filter_value' => array('' => '-- все --') + $districts), array('select' => 'd2.pid'), array('select' => 'd3.pid'), array('select' => 'd4.pid')), 'from' => $this->table . ' AS d4 
							LEFT JOIN ' . $this->table . ' AS d3 ON d4.pid=d3.id
							LEFT JOIN ' . $this->table . ' AS d2 ON d3.pid=d2.id
							LEFT JOIN ' . $this->table . ' AS d1 ON d2.pid=d1.id', 'dataset' => $rows, 'params' => array('page' => $this->name, 'do' => 'show'), 'click' => 'ID=cb.value', 'dblclick' => 'editItem(id)', 'function' => 'setFilterData'), $this);
        $ret['thisname'] = $this->name;
        return $this->Parse($ret, $this->name . '.tmpl');
    }
Пример #24
0
 function EditForm()
 {
     $id = (int) get('id');
     if ($id) {
         $row = $this->GetRow($id);
     }
     $row['date'] = sql_getValue("SELECT UNIX_TIMESTAMP(date) FROM " . $this->table . " WHERE id=" . $row['id']);
     $row['date'] = date(FORMAT_DATETIME, $row['date']);
     if ($row['content_type'] == 'text') {
         $row['body'] = nl2br($row['body']);
     }
     $row['text_tag'] = $row['content_type'] == 'html' ? 'div' : 'code';
     $row['from'] = $row['user_id'] == 1 ? h(sql_getValue("SELECT value FROM strings WHERE pid=1 AND name='from_email'")) : sql_getValue("SELECT CONCAT(fullname,CHAR(32),'&lt;',login,'&gt;') FROM users WHERE id=" . $row['user_id']);
     $to = sql_getRows("SELECT cl.id, CONCAT('<nobr>',cl.name,CHAR(32),cl.lname,CHAR(32),'&lt;',cl.login,'&gt;</nobr>') FROM email_log AS e, auth_users AS cl WHERE e.client_id=cl.id AND e.email_id=" . $row['id'], true);
     $row['to'] = join('; ', $to);
     $this->AddStrings($row);
     $row['close'] = $this->str('close');
     return $this->Parse($row, $this->name . '.editform.tmpl');
 }
Пример #25
0
 function GetDiagData()
 {
     $res_values = $res_legends = array();
     // строим темповые данные
     sql_query("\n\t\t\tCREATE TEMPORARY TABLE tmp_" . str_replace('/', '__', $this->name) . "\n\t\t\tSELECT CONCAT('http://', pag.host, pag.uri) AS name\n\t\t\tFROM " . $this->sess_table . " AS sess LEFT JOIN " . STAT_PAGES_TABLE . " AS pag ON pag.id=sess.last_page\n\t\t\tWHERE sess.robot=0 AND sess.last_page!=0");
     $total = $others = sql_getValue("SELECT COUNT(*) FROM tmp_" . str_replace('/', '__', $this->name));
     $data = sql_getRows("SELECT name, COUNT(*) AS kol FROM tmp_" . str_replace('/', '__', $this->name) . " GROUP BY name HAVING kol/" . $total . ">0.01 ORDER BY kol DESC", true);
     if ($data) {
         $others = sql_getValue("SELECT COUNT(*) FROM tmp_" . str_replace('/', '__', $this->name) . " WHERE name NOT IN ('" . join("', '", array_keys($data)) . "')");
         foreach ($data as $name => $kol) {
             $res_values[] = $kol;
             $res_legends[] = '"' . $name . '" (' . round($kol / $total * 100) . '%%)';
         }
         if ($others) {
             $res_values[] = $others;
             $res_legends[] = $this->str('others') . ' (' . round($others / $total * 100) . '%%)';
         }
     }
     return array($res_values, $res_legends);
 }
Пример #26
0
 function Delete()
 {
     $id = get('id', array(), 'gp');
     if (empty($id)) {
         return;
     }
     # Выясняем, нужно ли перегрузить одну ветвь или лучше все
     $pids = sql_getRows('SELECT pid FROM ' . $this->table . ' WHERE id in (' . join(', ', array_keys($id)) . ') GROUP BY pid');
     $pid = count($pids) > 1 ? 0 : $pids[0];
     $r1 = sql_query("DELETE FROM " . $this->table . " WHERE id IN (" . join(', ', array_keys($id)) . ")");
     if (!$r1) {
         return '<script>alert(\'' . $this->str('error') . ': ' . sql_getError() . '\')</script>';
     } else {
         return '<script>
                 alert(\'' . $this->str('deleted') . '\');
                 window.parent.top.opener.location.href="/admin/?page=tree&id=' . $pid . '";
                 window.close();
                 </script>';
     }
 }
Пример #27
0
    function table_get_page($val, $row)
    {
        // С какиех страниц переходят
        $referer = sql_getRows("SELECT ref_id, ref_page, ref_host FROM tmp_stat_errors WHERE page_id=" . $row['page_id'] . " AND ref_id!=0 GROUP BY ref_id");
        $referers = $this->str('referer') . ':<br>';
        if ($referer) {
            foreach ($referer as $ref) {
                $str = substr($ref['ref_page'], 0, 20) . (strlen($ref['ref_page']) > 20 ? '...' : '');
                $referers .= '<a href="http://' . $ref['ref_host'] . $ref['ref_page'] . '" target="_blank">http://' . $ref['ref_host'] . $str . '</a><br>';
            }
        } else {
            $referers = $this->str('no_referer');
        }
        $str = substr($row['page'], 0, 20) . (strlen($row['page']) > 20 ? '...' : '');
        return '
			<a href="#" onclick="roll(\'referer_' . $row['page_id'] . '\'); return false;"><img src="images/icons/icon.plus.gif" width=16 heidht=16 border=0 alt="' . $this->str('referer') . '" align="absmiddle"></a>
			<a href="http://' . $row['host'] . $row['page'] . '" target="_blank">http://' . $row['host'] . $str . '</a>
			<span class="tSmall">(' . $row['status'] . ')</span>
			<div class="tSmall" style="display: none;" id="referer_' . $row['page_id'] . '">' . $referers . '</div>';
    }
Пример #28
0
 function show_usage()
 {
     global $settings;
     $ret = array('hash' => $_POST['hash'], 'table_results' => array());
     $code = '"%get_form=' . mysql_real_escape_string($_POST['hash']) . '%"';
     $code2 = '"%[[FORM ' . mysql_real_escape_string($_POST['hash']) . ']]%"';
     $code3 = '"%get_form=' . mysql_real_escape_string($_POST['hash']) . '&is_popup%"';
     $code4 = '"%[[FORMPOPUP ' . mysql_real_escape_string($_POST['hash']) . ']]%"';
     foreach ($settings['forms_searching_tables'] as $s_table) {
         if (!$s_table['key']) {
             $s_table['key'] = 'id';
         }
         if (!$s_table['name']) {
             $s_table['name'] = "''";
         }
         if (!$s_table['dir']) {
             $s_table['dir'] = "''";
         }
         if (!$s_table['where']) {
             $s_table['where'] = '1';
         }
         if (!empty($s_table['search_fields'])) {
             $s_table['where'] .= " AND (\n                    (" . implode(" LIKE {$code} ) OR (", $s_table['search_fields']) . " LIKE {$code} ) OR\n                    (" . implode(" LIKE {$code2} ) OR (", $s_table['search_fields']) . " LIKE {$code2} ) OR\n                    (" . implode(" LIKE {$code3} ) OR (", $s_table['search_fields']) . " LIKE {$code3} ) OR\n                    (" . implode(" LIKE {$code4} ) OR (", $s_table['search_fields']) . " LIKE {$code4} )\n                )";
         }
         $sql = "\n                SELECT {$s_table['key']} as 'key', {$s_table['name']} as 'name', {$s_table['dir']} as 'dir'\n                FROM {$s_table['from']} WHERE {$s_table['where']}\n            ";
         $rows = sql_getRows($sql, 'key');
         $has_admn_hrefs = false;
         $has_site_hrefs = false;
         if ($s_table['admin_href'] || $s_table['site_href']) {
             foreach ($rows as $key => &$row) {
                 $row['admin_href'] = str_replace(array('{$key}', '{$dir}'), array($key, $row['dir']), $s_table['admin_href']);
                 $row['site_href'] = str_replace(array('{$key}', '{$dir}'), array($key, $row['dir']), $s_table['site_href']);
                 $has_admn_hrefs |= $row['admin_href'] != '';
                 $has_site_hrefs |= $row['site_href'] != '';
             }
         }
         $ret['table_results'][] = array('has_admin_hrefs' => $has_admn_hrefs, 'has_site_hrefs' => $has_site_hrefs, 'title' => $s_table['title'], 'items' => $rows);
     }
     echo $this->Parse(array('object' => $ret), 'forms_usages_table.tmpl');
     die;
 }
Пример #29
0
 function EditForm()
 {
     $id = get('id', 0, 'g');
     if (!empty($GLOBALS['_POST'])) {
         $actions = get('actions', '', 'p');
         if ($actions) {
             return $this->{$actions}();
         }
     }
     if ($id) {
         $data = $this->getRow($id);
         // Список ответов
         $data['answers'] = sql_getRows("SELECT * FROM surveys_variants WHERE id_group=" . $id . " ORDER BY priority", true);
     } else {
         $data['lang'] = lang();
     }
     $data['types'] = array('multi' => $this->str('multi'), 'single' => $this->str('single'));
     $data['max_answer_id'] = sql_getValue("SELECT MAX(id) FROM surveys_variants");
     $this->AddStrings($data);
     return $this->Parse($data, "surveys.editform.tmpl");
 }
Пример #30
0
 function get_config()
 {
     $id = mysql_escape_string(get('id', 0, 'gp'));
     if (!$id) {
         return;
     }
     //генерим массив необходимых полей и названия таблицы
     $config = mysql_query('SELECT * FROM csv_tools WHERE id=' . $id);
     $config = mysql_fetch_assoc($config);
     if (!$config) {
         return;
     }
     if (empty($config['fields_request'])) {
         $config['fields_request'] = "*";
     }
     $config['fields_request'] = explode(",", $config['fields_request']);
     if (empty($config['fields_ignored'])) {
         $config['fields_ignored'] = null;
     } else {
         $config['fields_ignored'] = explode(",", $config['fields_ignored']);
     }
     if ($config['fields_request'][0] == '*') {
         // если поля не перечислены , и задан SKIP делаем полный список
         foreach (sql_getRows('DESCRIBE ' . $config['table_base']) as $field) {
             if (!$config['fields_ignored'] || !in_array($field['Field'], $config['fields_ignored'])) {
                 $fields_request[] = $field['Field'];
             }
         }
         $config['fields_request'] = $fields_request;
     }
     if (empty($config['keys'])) {
         if (in_array('id', $config['fields_request'])) {
             $config['keys'] = 'id';
         } else {
             $config['keys'] = current($config['fields_request']);
         }
     }
     $config['keys'] = explode(",", $config['keys']);
     return $config;
 }