diff --git a/upload/engine/core.class.php b/upload/engine/core.class.php index f23fd5d..da7b05f 100644 --- a/upload/engine/core.class.php +++ b/upload/engine/core.class.php @@ -165,6 +165,11 @@ exit; } + public function colorize($str, $color, $format='{STRING}'){ + + return str_replace(array('{COLOR}', '{STRING}'), array($color, $str), $format); + } + /** * Адрес сайта по умолчанию * @return String - адрес сайта diff --git a/upload/engine/user.class.php b/upload/engine/user.class.php index 255fd86..c8454bf 100644 --- a/upload/engine/user.class.php +++ b/upload/engine/user.class.php @@ -5,7 +5,7 @@ private $core, $db, $config, $lng; // Set default user vars - public $email, $login, $group, $group_desc, $password, $salt, $tmp, $ip, $ip_create, $data, $permissions, $permissions_v2, $gender; + public $email, $login, $login_v2, $group, $group_v2, $group_desc, $password, $salt, $tmp, $ip, $ip_create, $data, $permissions, $permissions_v2, $gender; public $id = 0; @@ -56,8 +56,9 @@ $uid = intval($cookie[0]); $hash = $cookie[1]; - $query = $this->db->query("SELECT `u`.gid, `u`.login, `u`.email, `u`.password, `u`.`salt`, `u`.`tmp`, `u`.ip_create, `u`.`data`, `u`.`is_skin`, `u`.`is_cloak`, - `g`.title, `g`.`description`, `g`.`permissions`, `i`.`money`, `i`.realmoney, `i`.bank + $query = $this->db->query("SELECT `u`.gid, `u`.login, `u`.email, `u`.password, `u`.`salt`, `u`.`tmp`, `u`.ip_create, `u`.`data`, `u`.`is_skin`, `u`.`is_cloak`, `u`.`color`, + `g`.title, `g`.`description`, `g`.`permissions`, `g`.`color` AS `gcolor`, + `i`.`money`, `i`.realmoney, `i`.bank FROM `mcr_users` AS `u` INNER JOIN `mcr_groups` AS `g` ON `g`.id=`u`.gid @@ -79,6 +80,14 @@ // Check security auth if($_COOKIE['mcr_user'] !== $ar_hash){ $this->set_unauth(); $this->core->notify(); } + $login = $this->db->HSC($ar['login']); + + $color = (!empty($ar['color'])) ? $this->db->HSC($ar['color']) : $this->db->HSC($ar['gcolor']); + + $group = $this->db->HSC($ar['title']); + + $gcolor = $this->db->HSC($ar['gcolor']); + // Identificator $this->id = $uid; @@ -86,7 +95,10 @@ $this->gid = intval($ar['gid']); // Username - $this->login = $this->db->HSC($ar['login']); + $this->login = $login; + + // Username + $this->login_v2 = $this->core->colorize($login, $color); // E-Mail $this->email = $this->db->HSC($ar['email']); @@ -107,7 +119,10 @@ $this->data = json_decode($ar['data']); // Group title - $this->group = $this->db->HSC($ar['title']); + $this->group = $group; + + // Group title with colorize + $this->group_v2 = $this->core->colorize($group, $gcolor); // Group description $this->group_desc = $this->db->HSC($ar['description']); diff --git a/upload/install/tables.sql b/upload/install/tables.sql index 9905527..2913af6 100644 --- a/upload/install/tables.sql +++ b/upload/install/tables.sql @@ -23,6 +23,7 @@ `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(32) NOT NULL, `description` varchar(255) NOT NULL, + `color` varchar(24) NOT NULL, `permissions` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; @@ -362,6 +363,7 @@ `is_cloak` tinyint(1) NOT NULL DEFAULT '0', `ip_create` varchar(15) CHARACTER SET latin1 NOT NULL DEFAULT '127.0.0.1', `ip_last` varchar(15) CHARACTER SET latin1 NOT NULL DEFAULT '127.0.0.1', + `color` varchar(24) NOT NULL, `data` text NOT NULL, `ban_server` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), diff --git a/upload/language/ru_RU/admin.php b/upload/language/ru_RU/admin.php index e8631b1..586139f 100644 --- a/upload/language/ru_RU/admin.php +++ b/upload/language/ru_RU/admin.php @@ -24,6 +24,7 @@ 'com_not_exist' => 'Нет доступных комментариев', 'com_col_comment' => 'Комментарий', 'com_col_news' => 'Новость', + 'com_col_user' => 'Пользователь', 'com_action' => 'Действие с комментариями', 'com_accept' => 'Вы уверены, что хотите удалить выбранные комментарии', 'com_text' => 'Текст комментария', @@ -45,6 +46,7 @@ 'grp_edit_success' => 'Группа пользователей успешно изменена', 'grp_edit_page_name' => 'Редактирование группы', 'grp_edit_btn' => 'Сохранить', + 'grp_e_color_format' => 'Неверный формат цвета', 'grp_empty' => 'Нет доступных групп пользователей', 'grp_field_name' => 'Название', 'grp_field_desc' => 'Описание', @@ -433,6 +435,7 @@ 'user_edit_page_name' => 'Редактирование пользователя', 'user_edit_btn' => 'Сохранить', 'user_add_btn' => 'Добавить', + 'user_e_color_format' => 'Неверный формат цвета', 'user_success' => 'Выбранные пользователи успешно', 'user_not_found' => 'Пользователи не найдены', 'user_e_incorrect_fname' => 'Имя может состоять только из букв', diff --git a/upload/language/ru_RU/system.php b/upload/language/ru_RU/system.php index 0e66af0..636425e 100644 --- a/upload/language/ru_RU/system.php +++ b/upload/language/ru_RU/system.php @@ -90,6 +90,7 @@ "email" => "E-Mail", "pass" => "Пароль", "group" => "Группа", + "color" => "Цвет", "firstname" => "Имя", "lastname" => "Фамилия", "date_reg" => "Дата регистрации", diff --git a/upload/modules/admin.php b/upload/modules/admin.php index 8ee6f1f..ea4063c 100644 --- a/upload/modules/admin.php +++ b/upload/modules/admin.php @@ -19,7 +19,8 @@ $this->core->bc = $this->core->gen_bc($bc); - $this->core->header .= ''; + $this->core->header .= ''; + $this->core->header .= ''; } public function content(){ diff --git a/upload/modules/admin/comments.class.php b/upload/modules/admin/comments.class.php index f9688dc..0c03a7c 100644 --- a/upload/modules/admin/comments.class.php +++ b/upload/modules/admin/comments.class.php @@ -28,18 +28,37 @@ $end = $this->config->pagin['adm_comments']; // Set end pagination $where = ""; + $sort = "`c`.id"; + $sortby = "DESC"; + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'comment': $sort = "`c`.text_html"; break; + case 'news': $sort = "`n`.title"; break; + case 'user': $sort = "`u`.login"; break; + } + } if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `c`.text_html LIKE '%$search%'"; } - $query = $this->db->query("SELECT `c`.id, `c`.nid, `c`.text_html, `n`.title AS `new` + $query = $this->db->query("SELECT `c`.id, `c`.nid, `c`.text_html, `n`.title AS `new`, + `u`.login, `u`.`color`, `g`.`color` AS `gcolor` FROM `mcr_comments` AS `c` LEFT JOIN `mcr_news` AS `n` ON `n`.id=`c`.nid + LEFT JOIN `mcr_users` AS `u` + ON `u`.id=`c`.uid + LEFT JOIN `mcr_groups` AS `g` + ON `g`.id=`u`.gid $where - ORDER BY `c`.id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/comments/com-none.html"); } @@ -54,11 +73,16 @@ $new = (empty($ar['new'])) ? 'Новость удалена' : $this->db->HSC($ar['new']); + $login = (is_null($ar['login'])) ? 'Пользователь удален' : $this->db->HSC($ar['login']); + + $color = (empty($ar['color'])) ? $this->db->HSC($ar['gcolor']) : $this->db->HSC($ar['color']); + $page_data = array( "ID" => intval($ar['id']), "NID" => intval($ar['nid']), "NEW" => $new, - "TEXT" => $text + "TEXT" => $text, + "LOGIN" => $this->core->colorize($login, $color), ); echo $this->core->sp(MCR_THEME_MOD."admin/comments/com-id.html", $page_data); @@ -70,13 +94,17 @@ private function comment_list(){ $sql = "SELECT COUNT(*) FROM `mcr_comments`"; - $page = "?mode=admin&do=comments&pid="; + $page = "?mode=admin&do=comments"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_comments` WHERE text_html LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=comments&search=$search&pid="; + $page = "?mode=admin&do=comments&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -86,7 +114,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_comments'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_comments'], $page.'&pid=', $ar[0]), "COMMENTS" => $this->comment_array() ); diff --git a/upload/modules/admin/groups.class.php b/upload/modules/admin/groups.class.php index 10c2483..a2ab98d 100644 --- a/upload/modules/admin/groups.class.php +++ b/upload/modules/admin/groups.class.php @@ -28,16 +28,29 @@ $end = $this->config->pagin['adm_groups']; // Set end pagination $where = ""; + $sort = "id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE title LIKE '%$search%'"; } - $query = $this->db->query("SELECT id, title, description + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "title"; break; + case 'desc': $sort = "description"; break; + } + } + + $query = $this->db->query("SELECT id, title, `color`, description FROM `mcr_groups` $where - ORDER BY id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/groups/group-none.html"); } @@ -46,9 +59,11 @@ while($ar = $this->db->fetch_assoc($query)){ + $color = $this->db->HSC($ar['color']); + $page_data = array( "ID" => intval($ar['id']), - "TITLE" => $this->db->HSC($ar['title']), + "TITLE" => $this->core->colorize($this->db->HSC($ar['title']), $color), "TEXT" => $this->db->HSC($ar['description']), ); @@ -61,13 +76,17 @@ private function group_list(){ $sql = "SELECT COUNT(*) FROM `mcr_groups`"; - $page = "?mode=admin&do=groups&pid="; + $page = "?mode=admin&do=groups"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_groups` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=groups&search=$search&pid="; + $page = "?mode=admin&do=groups&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -77,7 +96,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_groups'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_groups'], $page.'&pid=', $ar[0]), "GROUPS" => $this->group_array() ); @@ -192,8 +211,11 @@ if($_SERVER['REQUEST_METHOD']=='POST'){ $title = $this->db->safesql(@$_POST['title']); $text = $this->db->safesql(@$_POST['text']); + $color = $this->db->safesql(@$_POST['color']); $permissions = $this->db->safesql(@$_POST['permissions']); + if(!empty($color) && !preg_match("/^\#[a-f0-9]{6}|[a-f0-9]{3}$/i", $color)){ $this->core->notify($this->core->lng["e_msg"], $this->lng["grp_e_color_format"], 2, '?mode=admin&do=groups&op=add'); } + $perm_data = $_POST; unset($perm_data['submit'], $perm_data['mcr_secure'], $perm_data['title'], $perm_data['text']); @@ -201,11 +223,11 @@ $new_permissions = $this->db->safesql($this->gen_permissions($perm_data)); $insert = $this->db->query("INSERT INTO `mcr_groups` - (title, description, `permissions`) + (title, description, `color`, `permissions`) VALUES - ('$title', '$text', '$new_permissions')"); + ('$title', '$text', '$color', '$new_permissions')"); - if(!$insert){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=groups'); } + if(!$insert){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=groups&op=add'); } $id = $this->db->insert_id(); @@ -222,6 +244,7 @@ "PAGE" => $this->lng['grp_add_page_name'], "TITLE" => '', "TEXT" => '', + "COLOR" => '', "PERMISSIONS" => $this->perm_list(), "BUTTON" => $this->lng['grp_add_btn'] ); @@ -234,7 +257,7 @@ $id = intval($_GET['id']); - $query = $this->db->query("SELECT title, `description`, `permissions` + $query = $this->db->query("SELECT title, `description`, `color`, `permissions` FROM `mcr_groups` WHERE id='$id'"); @@ -253,8 +276,11 @@ if($_SERVER['REQUEST_METHOD']=='POST'){ $title = $this->db->safesql(@$_POST['title']); $text = $this->db->safesql(@$_POST['text']); + $color = $this->db->safesql(@$_POST['color']); $permissions = $this->db->safesql(@$_POST['permissions']); + if(!empty($color) && !preg_match("/^\#[a-f0-9]{6}|[a-f0-9]{3}$/i", $color)){ $this->core->notify($this->core->lng["e_msg"], $this->lng["grp_e_color_format"], 2, '?mode=admin&do=groups&op=edit&id='.$id); } + $perm_data = $_POST; unset($perm_data['submit'], $perm_data['mcr_secure'], $perm_data['title'], $perm_data['text']); @@ -262,7 +288,7 @@ $new_permissions = $this->db->safesql($this->gen_permissions($perm_data)); $update = $this->db->query("UPDATE `mcr_groups` - SET title='$title', description='$text', `permissions`='$new_permissions' + SET title='$title', `color`='$color', description='$text', `permissions`='$new_permissions' WHERE id='$id'"); if(!$update){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=groups&op=edit&id='.$id); } @@ -279,6 +305,7 @@ $data = array( "PAGE" => $this->lng['grp_edit_page_name'], "TITLE" => $this->db->HSC($ar['title']), + "COLOR" => $this->db->HSC($ar['color']), "TEXT" => $this->db->HSC($ar['description']), "PERMISSIONS" => $this->perm_list($ar['permissions']), "BUTTON" => $this->lng['grp_edit_btn'] diff --git a/upload/modules/admin/info.class.php b/upload/modules/admin/info.class.php index fbb5843..9efe293 100644 --- a/upload/modules/admin/info.class.php +++ b/upload/modules/admin/info.class.php @@ -25,7 +25,7 @@ private function main(){ $this->core->header .= ''; - $this->core->header .= ''; + $this->core->header .= ''; return $this->core->sp(MCR_THEME_MOD."admin/info/main.html"); } @@ -98,7 +98,7 @@ private function extensions(){ $this->core->header .= ''; - $this->core->header .= ''; + $this->core->header .= ''; return $this->core->sp(MCR_THEME_MOD."admin/info/extensions.html"); } diff --git a/upload/modules/admin/logs.class.php b/upload/modules/admin/logs.class.php index 10999ab..d24d505 100644 --- a/upload/modules/admin/logs.class.php +++ b/upload/modules/admin/logs.class.php @@ -28,18 +28,34 @@ $end = $this->config->pagin['adm_logs']; // Set end pagination $where = ""; + $sort = "`l`.id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `l`.`message` LIKE '%$search%'"; } - $query = $this->db->query("SELECT `l`.id, `l`.uid, `l`.`message`, `l`.`date`, `u`.login + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'user': $sort = "`u`.login"; break; + case 'msg': $sort = "`l`.`message`"; break; + case 'date': $sort = "`l`.`date`"; break; + } + } + + $query = $this->db->query("SELECT `l`.id, `l`.uid, `l`.`message`, `l`.`date`, `u`.login, `u`.`color`, `g`.`color` AS `gcolor` FROM `mcr_logs` AS `l` LEFT JOIN `mcr_users` AS `u` ON `u`.id=`l`.uid + LEFT JOIN `mcr_groups` AS `g` + ON `g`.id=`u`.gid $where - ORDER BY `l`.id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/logs/log-none.html"); } @@ -47,12 +63,17 @@ ob_start(); while($ar = $this->db->fetch_assoc($query)){ + + $color = (empty($ar['color'])) ? $this->db->HSC($ar['gcolor']) : $this->db->HSC($ar['color']); + + $login = (!is_null($ar['login'])) ? $this->db->HSC($ar['login']) : 'Пользователь удален'; + $page_data = array( "ID" => intval($ar['id']), "UID" => intval($ar['uid']), "MESSAGE" => $this->db->HSC($ar['message']), "DATE" => date("d.m.Y в H:i:s", $ar['date']), - "LOGIN" => (!is_null($ar['login'])) ? $this->db->HSC($ar['login']) : 'Пользователь удален', + "LOGIN" => $this->core->colorize($login, $color), ); echo $this->core->sp(MCR_THEME_MOD."admin/logs/log-id.html", $page_data); @@ -64,13 +85,17 @@ private function logs_list(){ $sql = "SELECT COUNT(*) FROM `mcr_logs`"; - $page = "?mode=admin&do=logs&pid="; + $page = "?mode=admin&do=logs"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_logs` WHERE `message` LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=logs&search=$search&pid="; + $page = "?mode=admin&do=logs&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -78,7 +103,7 @@ $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_logs'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_logs'], $page.'&pid=', $ar[0]), "LOGS" => $this->logs_array() ); diff --git a/upload/modules/admin/menu.class.php b/upload/modules/admin/menu.class.php index 64c3123..5df80b4 100644 --- a/upload/modules/admin/menu.class.php +++ b/upload/modules/admin/menu.class.php @@ -28,18 +28,31 @@ $end = $this->config->pagin['adm_menu']; // Set end pagination $where = ""; + $sort = "`m`.id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `m`.title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "`m`.title"; break; + case 'parent': $sort = "`p`.title"; break; + } + } + $query = $this->db->query("SELECT `m`.id, `m`.title, `m`.`parent`, `m`.`url`, `m`.`target`, `p`.title AS `ptitle` FROM `mcr_menu` AS `m` LEFT JOIN `mcr_menu` AS `p` ON `p`.id=`m`.`parent` $where - ORDER BY `m`.id ASC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/menu/menu-none.html"); } @@ -68,13 +81,17 @@ private function menu_list(){ $sql = "SELECT COUNT(*) FROM `mcr_menu`"; - $page = "?mode=admin&do=menu&pid="; + $page = "?mode=admin&do=menu"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_menu` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=menu&search=$search&pid="; + $page = "?mode=admin&do=menu&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -84,7 +101,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu'], $page.'&pid=', $ar[0]), "MENU" => $this->menu_array() ); @@ -106,7 +123,7 @@ $list = $this->db->safesql(implode(", ", $list)); - if(!$this->db->remove_fast("mcr_menu", "id IN ($list) AND `parent` IN ($list)")){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=menu'); } + if(!$this->db->remove_fast("mcr_menu", "id IN ($list) OR `parent` IN ($list)")){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=menu'); } $count = $this->db->affected_rows(); diff --git a/upload/modules/admin/menu_adm.class.php b/upload/modules/admin/menu_adm.class.php index ea4eaf7..2c883d5 100644 --- a/upload/modules/admin/menu_adm.class.php +++ b/upload/modules/admin/menu_adm.class.php @@ -28,18 +28,31 @@ $end = $this->config->pagin['adm_menu_adm']; // Set end pagination $where = ""; + $sort = "`m`.`id`"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `m`.title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "`m`.title"; break; + case 'group': $sort = "`g`.title"; break; + } + } + $query = $this->db->query("SELECT `m`.id, `m`.gid, `m`.title, `m`.`url`, `m`.`target`, `g`.title AS `group` FROM `mcr_menu_adm` AS `m` LEFT JOIN `mcr_menu_adm_groups` AS `g` ON `g`.id=`m`.gid $where - ORDER BY `m`.`priority` ASC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/menu_adm/menu-none.html"); } @@ -66,13 +79,17 @@ private function menu_list(){ $sql = "SELECT COUNT(*) FROM `mcr_menu_adm`"; - $page = "?mode=admin&do=menu_adm&pid="; + $page = "?mode=admin&do=menu_adm"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_menu_adm` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=menu_adm&search=$search&pid="; + $page = "?mode=admin&do=menu_adm&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -80,7 +97,7 @@ $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_adm'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_adm'], $page.'&pid=', $ar[0]), "MENU" => $this->menu_array() ); diff --git a/upload/modules/admin/menu_groups.class.php b/upload/modules/admin/menu_groups.class.php index 374f7dd..3c880ae 100644 --- a/upload/modules/admin/menu_groups.class.php +++ b/upload/modules/admin/menu_groups.class.php @@ -28,18 +28,31 @@ $end = $this->config->pagin['adm_menu_groups']; // Set end pagination $where = ""; + $sort = "`g`.`id`"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `g`.title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "`g`.title"; break; + case 'perm': $sort = "`p`.title"; break; + } + } + $query = $this->db->query("SELECT `g`.id, `g`.title, `g`.`text`, `p`.id AS `pid`, `p`.`title` AS `perm` FROM `mcr_menu_adm_groups` AS `g` LEFT JOIN `mcr_permissions` AS `p` ON `p`.`value`=`g`.`access` $where - ORDER BY `g`.`priority` ASC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/menu_groups/group-none.html"); } @@ -65,13 +78,17 @@ private function group_list(){ $sql = "SELECT COUNT(*) FROM `mcr_menu_adm_groups`"; - $page = "?mode=admin&do=menu_groups&pid="; + $page = "?mode=admin&do=menu_groups"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_menu_adm_groups` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=menu_groups&search=$search&pid="; + $page = "?mode=admin&do=menu_groups&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -81,7 +98,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_groups'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_groups'], $page.'&pid=', $ar[0]), "GROUPS" => $this->group_array() ); diff --git a/upload/modules/admin/menu_icons.class.php b/upload/modules/admin/menu_icons.class.php index 9e9d6aa..70f141e 100644 --- a/upload/modules/admin/menu_icons.class.php +++ b/upload/modules/admin/menu_icons.class.php @@ -28,16 +28,28 @@ $end = $this->config->pagin['adm_menu_icons']; // Set end pagination $where = ""; + $sort = "id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "title"; break; + } + } + $query = $this->db->query("SELECT id, title, img FROM `mcr_menu_adm_icons` $where - ORDER BY id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/menu_icons/icon-none.html"); } @@ -61,13 +73,17 @@ private function icon_list(){ $sql = "SELECT COUNT(*) FROM `mcr_menu_adm_icons`"; - $page = "?mode=admin&do=menu_icons&pid="; + $page = "?mode=admin&do=menu_icons"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_menu_adm_icons` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=menu_icons&search=$search&pid="; + $page = "?mode=admin&do=menu_icons&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -77,7 +93,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_icons'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_menu_icons'], $page.'&pid=', $ar[0]), "ICONS" => $this->icon_array() ); diff --git a/upload/modules/admin/monitoring.class.php b/upload/modules/admin/monitoring.class.php index 13e97d4..d34f1db 100644 --- a/upload/modules/admin/monitoring.class.php +++ b/upload/modules/admin/monitoring.class.php @@ -28,16 +28,29 @@ $end = $this->config->pagin['adm_monitoring']; // Set end pagination $where = ""; + $sort = "id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "title"; break; + case 'address': $sort = "CONCAT(`ip`, `port`)"; break; + } + } + $query = $this->db->query("SELECT id, title, ip, `port` FROM `mcr_monitoring` $where - ORDER BY id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/monitoring/monitor-none.html"); } @@ -62,13 +75,17 @@ private function monitor_list(){ $sql = "SELECT COUNT(*) FROM `mcr_monitoring`"; - $page = "?mode=admin&do=monitoring&pid="; + $page = "?mode=admin&do=monitoring"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_monitoring` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=monitoring&search=$search&pid="; + $page = "?mode=admin&do=monitoring&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -78,7 +95,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_monitoring'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_monitoring'], $page.'&pid=', $ar[0]), "SERVERS" => $this->monitor_array() ); diff --git a/upload/modules/admin/news.class.php b/upload/modules/admin/news.class.php index db6e81a..3c12ac3 100644 --- a/upload/modules/admin/news.class.php +++ b/upload/modules/admin/news.class.php @@ -28,18 +28,31 @@ $end = $this->config->pagin['adm_news']; // Set end pagination $where = ""; + $sort = "`n`.id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `n`.title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "`n`.title"; break; + case 'category': $sort = "`c`.title"; break; + } + } + $query = $this->db->query("SELECT `n`.id, `n`.cid, `n`.title, `c`.title AS `category` FROM `mcr_news` AS `n` LEFT JOIN `mcr_news_cats` AS `c` ON `c`.id=`n`.cid $where - ORDER BY `n`.id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); @@ -66,13 +79,17 @@ private function news_list(){ $sql = "SELECT COUNT(*) FROM `mcr_news`"; - $page = "?mode=admin&do=news&pid="; + $page = "?mode=admin&do=news"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_news` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=news&search=$search&pid="; + $page .= "&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -80,7 +97,7 @@ $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news'], $page.'&pid=', $ar[0]), "NEWS" => $this->news_array() ); diff --git a/upload/modules/admin/news_cats.class.php b/upload/modules/admin/news_cats.class.php index 1c105dd..ca31461 100644 --- a/upload/modules/admin/news_cats.class.php +++ b/upload/modules/admin/news_cats.class.php @@ -28,16 +28,28 @@ $end = $this->config->pagin['adm_news_cats']; // Set end pagination $where = ""; + $sort = "id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "title"; break; + } + } + $query = $this->db->query("SELECT id, title, `data` FROM `mcr_news_cats` $where - ORDER BY id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/news_cats/cat-none.html"); } @@ -61,13 +73,17 @@ private function cats_list(){ $sql = "SELECT COUNT(*) FROM `mcr_news_cats`"; - $page = "?mode=admin&do=news_cats&pid="; + $page = "?mode=admin&do=news_cats"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_news_cats` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=news_cats&search=$search&pid="; + $page .= "&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -77,7 +93,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_cats'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_cats'], $page.'&pid=', $ar[0]), "CATEGORIES" => $this->cats_array() ); diff --git a/upload/modules/admin/news_views.class.php b/upload/modules/admin/news_views.class.php index c1100c7..950203b 100644 --- a/upload/modules/admin/news_views.class.php +++ b/upload/modules/admin/news_views.class.php @@ -27,13 +27,31 @@ $start = $this->core->pagination($this->config->pagin['adm_news_views'], 0, 0); // Set start pagination $end = $this->config->pagin['adm_news_views']; // Set end pagination - $query = $this->db->query("SELECT `v`.id, `v`.nid, `v`.uid, `v`.`time`, `n`.title, `u`.login + $sort = "`v`.id"; + $sortby = "DESC"; + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'news': $sort = "`n`.title"; break; + case 'user': $sort = "`u`.login"; break; + case 'date': $sort = "`v`.`time`"; break; + } + } + + $query = $this->db->query("SELECT `v`.id, `v`.nid, `v`.uid, `v`.`time`, `n`.title, + `u`.login, `u`.`color`, `g`.`color` AS `gcolor` FROM `mcr_news_views` AS `v` LEFT JOIN `mcr_news` AS `n` ON `n`.id=`v`.nid LEFT JOIN `mcr_users` AS `u` ON `u`.id=`v`.uid - ORDER BY `v`.id DESC + LEFT JOIN `mcr_groups` AS `g` + ON `g`.id=`u`.gid + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/news_views/view-none.html"); } @@ -50,11 +68,15 @@ $new = $this->db->HSC($ar['title']); } + $login = (is_null($ar['login'])) ? 'Пользователь удален' : $this->db->HSC($ar['login']); + + $color = (empty($ar['color'])) ? $this->db->HSC($ar['gcolor']) : $this->db->HSC($ar['color']); + $page_data = array( "ID" => intval($ar['id']), "NID" => intval($ar['nid']), "NEW" => $new, - "LOGIN" => $this->db->HSC($ar['login']), + "LOGIN" => $this->core->colorize($login, $color), "UID" => intval($ar['uid']), "TIME_CREATE" => date("d.m.Y в H:i", $ar['time']), "STATUS_CLASS" => $status_class @@ -68,12 +90,18 @@ private function views_list(){ + $page = "?mode=admin&do=news_views"; + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); + } + $query = $this->db->query("SELECT COUNT(*) FROM `mcr_news_views`"); $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_views'], "?mode=admin&do=news_views&pid=", $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_views'], $page."&pid=", $ar[0]), "VIEWS" => $this->views_array() ); diff --git a/upload/modules/admin/news_votes.class.php b/upload/modules/admin/news_votes.class.php index 05fbd04..52f21dc 100644 --- a/upload/modules/admin/news_votes.class.php +++ b/upload/modules/admin/news_votes.class.php @@ -27,17 +27,34 @@ $start = $this->core->pagination($this->config->pagin['adm_news_votes'], 0, 0); // Set start pagination $end = $this->config->pagin['adm_news_votes']; // Set end pagination - $query = $this->db->query("SELECT `v`.id, `v`.nid, `v`.uid, `v`.`value`, `v`.`time`, `n`.title, `u`.login + $sort = "`v`.id"; + $sortby = "DESC"; + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'news': $sort = "`n`.title"; break; + case 'value': $sort = "`v`.`value`"; break; + case 'user': $sort = "`u`.login"; break; + case 'date': $sort = "`v`.`time`"; break; + } + } + + $query = $this->db->query("SELECT `v`.id, `v`.nid, `v`.uid, `v`.`value`, `v`.`time`, `n`.title, + `u`.login, `u`.`color`, `g`.`color` AS `gcolor` FROM `mcr_news_votes` AS `v` LEFT JOIN `mcr_news` AS `n` ON `n`.id=`v`.nid LEFT JOIN `mcr_users` AS `u` ON `u`.id=`v`.uid - ORDER BY `v`.id DESC + LEFT JOIN `mcr_groups` AS `g` + ON `g`.id=`u`.gid + ORDER BY $sort $sortby LIMIT $start, $end"); - - if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/news_votes/vote-none.html"); } ob_start(); @@ -54,11 +71,15 @@ $value = (intval($ar['value'])===1) ? 'icon-thumbs-up' : 'icon-thumbs-down'; + $login = (is_null($ar['login'])) ? 'Пользователь удален' : $this->db->HSC($ar['login']); + + $color = (empty($ar['color'])) ? $this->db->HSC($ar['gcolor']) : $this->db->HSC($ar['color']); + $page_data = array( "ID" => intval($ar['id']), "NID" => intval($ar['nid']), "NEW" => $new, - "LOGIN" => $this->db->HSC($ar['login']), + "LOGIN" => $this->core->colorize($login, $color), "UID" => intval($ar['uid']), "TIME_CREATE" => date("d.m.Y в H:i", $ar['time']), "STATUS_CLASS" => $status_class, @@ -73,12 +94,18 @@ private function votes_list(){ + $page = "?mode=admin&do=news_votes"; + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); + } + $query = $this->db->query("SELECT COUNT(*) FROM `mcr_news_votes`"); $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_votes'], "?mode=admin&do=news_votes&pid=", $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_news_votes'], $page."&pid=", $ar[0]), "VOTES" => $this->votes_array() ); diff --git a/upload/modules/admin/permissions.class.php b/upload/modules/admin/permissions.class.php index 9c39b54..5032860 100644 --- a/upload/modules/admin/permissions.class.php +++ b/upload/modules/admin/permissions.class.php @@ -28,16 +28,29 @@ $end = $this->config->pagin['adm_groups']; // Set end pagination $where = ""; + $sort = "id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "title"; break; + case 'value': $sort = "`value`"; break; + } + } + $query = $this->db->query("SELECT id, title, description, `value`, `system`, `data` FROM `mcr_permissions` $where - ORDER BY `value` ASC + ORDER BY $sort $sortby LIMIT $start, $end"); @@ -68,13 +81,17 @@ private function permissions_list(){ $sql = "SELECT COUNT(*) FROM `mcr_permissions`"; - $page = "?mode=admin&do=permissions&pid="; + $page = "?mode=admin&do=permissions"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_permissions` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=permissions&search=$search&pid="; + $page = "?mode=admin&do=permissions&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -84,7 +101,7 @@ $ar = $this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_groups'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_groups'], $page.'&pid=', $ar[0]), "PERMISSIONS" => $this->permissions_array() ); @@ -421,7 +438,7 @@ $op = (isset($_GET['op'])) ? $_GET['op'] : 'list'; $this->core->header .= ''; - $this->core->header .= ''; + $this->core->header .= ''; switch($op){ case 'add': $content = $this->add(); break; diff --git a/upload/modules/admin/statics.class.php b/upload/modules/admin/statics.class.php index 4f09e28..9234d7b 100644 --- a/upload/modules/admin/statics.class.php +++ b/upload/modules/admin/statics.class.php @@ -28,19 +28,32 @@ $end = $this->config->pagin['adm_statics']; // Set end pagination $where = ""; + $sort = "`s`.`id`"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $where = "WHERE `s`.title LIKE '%$search%'"; } + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'title': $sort = "`s`.title"; break; + case 'perm': $sort = "`p`.title"; break; + } + } + $query = $this->db->query("SELECT `s`.id, `s`.`uniq`, `s`.title, `s`.uid, `p`.title AS `perm` FROM `mcr_statics` AS `s` LEFT JOIN `mcr_permissions` AS `p` ON `p`.`value`=`s`.`permissions` $where - ORDER BY `s`.id DESC + ORDER BY $sort $sortby LIMIT $start, $end"); @@ -70,13 +83,17 @@ private function static_list(){ $sql = "SELECT COUNT(*) FROM `mcr_statics`"; - $page = "?mode=admin&do=statics&pid="; + $page = "?mode=admin&do=statics"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); $sql = "SELECT COUNT(*) FROM `mcr_statics` WHERE title LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=statics&search=$search&pid="; + $page = "?mode=admin&do=statics&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -84,7 +101,7 @@ $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_statics'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_statics'], $page.'&pid=', $ar[0]), "STATICS" => $this->static_array() ); diff --git a/upload/modules/admin/users.class.php b/upload/modules/admin/users.class.php index dde0406..8e5c459 100644 --- a/upload/modules/admin/users.class.php +++ b/upload/modules/admin/users.class.php @@ -28,6 +28,8 @@ $end = $this->config->pagin['adm_users']; // Set end pagination $where = ""; + $sort = "`u`.id"; + $sortby = "DESC"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); @@ -36,12 +38,26 @@ $where = "WHERE `u`.`$table` LIKE '%$search%'"; } - $query = $this->db->query("SELECT `u`.id, `u`.gid, `u`.login, `u`.email, `g`.title AS `group`, `u`.ip_create, `u`.ip_last + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $expl = explode(' ', $_GET['sort']); + + $sortby = ($expl[0]=='asc') ? "ASC" : "DESC"; + + switch(@$expl[1]){ + case 'user': $sort = "`u`.login"; break; + case 'group': $sort = "`g`.title"; break; + case 'email': $sort = "`u`.email"; break; + case 'ip': $sort = "`u`.ip_last"; break; + } + } + + $query = $this->db->query("SELECT `u`.id, `u`.gid, `u`.login, `u`.email, `u`.`color`, `u`.ip_create, `u`.ip_last, + `g`.title AS `group`, `g`.`color` AS `gcolor` FROM `mcr_users` AS `u` LEFT JOIN `mcr_groups` AS `g` ON `g`.id=`u`.gid $where - ORDER BY `u`.login ASC + ORDER BY $sort $sortby LIMIT $start, $end"); if(!$query || $this->db->num_rows($query)<=0){ return $this->core->sp(MCR_THEME_MOD."admin/users/user-none.html"); } @@ -50,12 +66,15 @@ while($ar = $this->db->fetch_assoc($query)){ + $ucolor = (!empty($ar['color'])) ? $this->db->HSC($ar['color']) : $this->db->HSC($ar['gcolor']); + $gcolor = $this->db->HSC($ar['gcolor']); + $page_data = array( "ID" => intval($ar['id']), "GID" => intval($ar['gid']), - "LOGIN" => $this->db->HSC($ar['login']), + "LOGIN" => $this->core->colorize($this->db->HSC($ar['login']), $ucolor), "EMAIL" => $this->db->HSC($ar['email']), - "GROUP" => $this->db->HSC($ar['group']), + "GROUP" => $this->core->colorize($this->db->HSC($ar['group']), $gcolor), "IP_LAST" => $this->db->HSC($ar['ip_last']), "IP_CREATE" => $this->db->HSC($ar['ip_create']), ); @@ -69,7 +88,7 @@ private function user_list(){ $sql = "SELECT COUNT(*) FROM `mcr_users`"; - $page = "?mode=admin&do=users&pid="; + $page = "?mode=admin&do=users"; if(isset($_GET['search']) && !empty($_GET['search'])){ $search = $this->db->safesql(urldecode($_GET['search'])); @@ -77,7 +96,11 @@ $table = (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i", $search)) ? "ip_last" : "login"; $sql = "SELECT COUNT(*) FROM `mcr_users` WHERE `$table` LIKE '%$search%'"; $search = $this->db->HSC(urldecode($_GET['search'])); - $page = "?mode=admin&do=users&search=$search&pid="; + $page = "?mode=admin&do=users&search=$search"; + } + + if(isset($_GET['sort']) && !empty($_GET['sort'])){ + $page .= '&sort='.$this->db->HSC(urlencode($_GET['sort'])); } $query = $this->db->query($sql); @@ -85,7 +108,7 @@ $ar = @$this->db->fetch_array($query); $data = array( - "PAGINATION" => $this->core->pagination($this->config->pagin['adm_users'], $page, $ar[0]), + "PAGINATION" => $this->core->pagination($this->config->pagin['adm_users'], $page.'&pid=', $ar[0]), "USERS" => $this->user_array() ); @@ -206,12 +229,15 @@ if($_SERVER['REQUEST_METHOD']=='POST'){ $login = $this->db->safesql(@$_POST['login']); + $color = $this->db->safesql(@$_POST['color']); $uuid = $this->db->safesql($this->user->logintouuid(@$_POST['login'])); $salt = $this->db->safesql($this->core->random()); $password = $this->core->gen_password($_POST['password'], $salt); $password = $this->db->safesql($password); + if(!empty($color) && !preg_match("/^\#[a-f0-9]{6}|[a-f0-9]{3}$/i", $color)){ $this->core->notify($this->core->lng["e_msg"], $this->lng["user_e_color_format"], 2, '?mode=admin&do=users&op=add'); } + if(mb_strlen($_POST['password'], "UTF-8")<6){ $this->core->notify($this->core->lng['e_msg'], $this->lng['user_e_reg_pass_length'], 2, '?mode=admin&do=users&op=add'); } $email = $this->db->safesql(@$_POST['email']); @@ -248,9 +274,9 @@ $new_data = $this->db->safesql(json_encode($new_data)); $insert = $this->db->query("INSERT INTO `mcr_users` - (gid, login, email, password, `uuid`, `salt`, ip_create, ip_last, `data`) + (gid, login, email, password, `color`, `uuid`, `salt`, ip_create, ip_last, `data`) VALUES - ('$gid', '$login', '$email', '$password', '$uuid', '$salt', '{$this->user->ip}', '{$this->user->ip}', '$new_data')"); + ('$gid', '$login', '$email', '$password', '$color', '$uuid', '$salt', '{$this->user->ip}', '{$this->user->ip}', '$new_data')"); if(!$insert){ $this->core->notify($this->core->lng["e_msg"], $this->core->lng["e_sql_critical"], 2, '?mode=admin&do=users'); } @@ -273,17 +299,18 @@ } $data = array( - "PAGE" => $this->lng['user_add_page_name'], - "LOGIN" => '', - "EMAIL" => '', - "FIRSTNAME" => '', - "LASTNAME" => '', - "BIRTHDAY" => date("d-m-Y"), - "GENDER" => '', - "GROUPS" => $this->groups(), - "MONEY" => 0, - "REALMONEY" => 0, - "BUTTON" => $this->lng['user_add_btn'] + 'PAGE' => $this->lng['user_add_page_name'], + 'LOGIN' => '', + 'EMAIL' => '', + 'FIRSTNAME' => '', + 'LASTNAME' => '', + 'COLOR' => '', + 'BIRTHDAY' => date("d-m-Y"), + 'GENDER' => '', + 'GROUPS' => $this->groups(), + 'MONEY' => 0, + 'REALMONEY' => 0, + 'BUTTON' => $this->lng['user_add_btn'] ); return $this->core->sp(MCR_THEME_MOD."admin/users/user-add.html", $data); @@ -294,7 +321,7 @@ $id = intval($_GET['id']); - $query = $this->db->query("SELECT `u`.login, `u`.gid, `u`.email, `u`.`data`, + $query = $this->db->query("SELECT `u`.login, `u`.gid, `u`.email, `u`.`data`, `u`.`color`, `i`.`money`, `i`.realmoney FROM `mcr_users` AS `u` LEFT JOIN `mcr_iconomy` AS `i` @@ -317,11 +344,14 @@ if($_SERVER['REQUEST_METHOD']=='POST'){ $login = $this->db->safesql(@$_POST['login']); + $color = $this->db->safesql(@$_POST['color']); $uuid = $this->db->safesql($this->user->logintouuid(@$_POST['login'])); $password = "`password`"; $salt = "`salt`"; + if(!empty($color) && !preg_match("/^\#[a-f0-9]{6}|[a-f0-9]{3}$/i", $color)){ $this->core->notify($this->core->lng["e_msg"], $this->lng["user_e_color_format"], 2, '?mode=admin&do=users&op=edit&id='.$id); } + if(isset($_POST['password']) && !empty($_POST['password'])){ $salt = $this->db->safesql($this->core->random()); $salt = "'$salt'"; @@ -366,7 +396,7 @@ $new_data = $this->db->safesql(json_encode($new_data)); $update = $this->db->query("UPDATE `mcr_users` - SET gid='$gid', login='$login', gid='$gid', email='$email', + SET gid='$gid', login='$login', `color`='$color', gid='$gid', email='$email', password=$password, `uuid`='$uuid', `salt`=$salt, `data`='$new_data' WHERE id='$id'"); @@ -408,6 +438,7 @@ "PAGE" => $this->lng['user_edit_page_name'], "LOGIN" => $this->db->HSC($ar['login']), "EMAIL" => $this->db->HSC($ar['email']), + 'COLOR' => $this->db->HSC($ar['color']), "FIRSTNAME" => $this->db->HSC($data->firstname), "LASTNAME" => $this->db->HSC($data->lastname), "BIRTHDAY" => $birthday, diff --git a/upload/modules/news.php b/upload/modules/news.php index 97bd662..23d8c70 100644 --- a/upload/modules/news.php +++ b/upload/modules/news.php @@ -157,10 +157,14 @@ $start = $this->core->pagination($this->config->pagin['comments'], 0, 0); // Set start pagination $end = $this->config->pagin['comments']; // Set end pagination - $query = $this->db->query("SELECT `c`.id, `c`.text_html, `c`.uid, `c`.`data`, `u`.login + $query = $this->db->query("SELECT `c`.id, `c`.text_html, `c`.uid, `c`.`data`, + `u`.login, `u`.`color`, + `g`.`color` AS `gcolor` FROM `mcr_comments` AS `c` LEFT JOIN `mcr_users` AS `u` ON `u`.id=`c`.uid + LEFT JOIN `mcr_groups` AS `g` + ON `g`.id=`u`.gid WHERE `c`.nid='$nid' ORDER BY `c`.id DESC LIMIT $start, $end"); @@ -194,13 +198,17 @@ $act_get = $this->core->sp(MCR_THEME_MOD."news/comments/comment-act-get.html", $data); } + $login = (is_null($ar['login'])) ? 'Пользователь удален' : $this->db->HSC($ar['login']); + + $color = (!empty($ar['color'])) ? $this->db->HSC($ar['color']) : $this->db->HSC($ar['gcolor']); + $com_data = array( "ID" => $id, "NID" => $nid, "TEXT" => $ar['text_html'], "UID" => intval($ar['uid']), "DATA" => json_decode($ar['data'], true), - "LOGIN" => $this->db->HSC($ar['login']), + "LOGIN" => $this->core->colorize($login, $color), "ACTION_DELETE" => $act_del, "ACTION_EDIT" => $act_edt, "ACTION_QUOTE" => $act_get diff --git a/upload/themes/default/blocks/profile/auth.html b/upload/themes/default/blocks/profile/auth.html index 58b0110..52b3b06 100644 --- a/upload/themes/default/blocks/profile/auth.html +++ b/upload/themes/default/blocks/profile/auth.html @@ -8,8 +8,8 @@