From cec434f1b668c3c0898c63b633a3c6ef1adf426d Mon Sep 17 00:00:00 2001 From: McDanci Date: Tue, 22 Mar 2016 11:52:47 +0800 Subject: [PATCH 1/5] Format groups.php --- uploads/panel/group_role.php | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/uploads/panel/group_role.php b/uploads/panel/group_role.php index ab268fc..e1f4c43 100644 --- a/uploads/panel/group_role.php +++ b/uploads/panel/group_role.php @@ -1,30 +1,30 @@ 100){ - $temp[]=$group_role; + // 绯荤粺棰勭暀鑿滃崟 id 涓 100 浠ュ唴 + if ($group_role > 100){ + $temp[] = $group_role; } } @@ -34,20 +34,20 @@ $menu_ids = array_unique($menu_ids); asort($menu_ids); } - $group_role = join ( ',', $menu_ids ); - $group_data = array ('group_role' => $group_role ); - $result = UserGroup::updateGroupInfo ( $group_id, $group_data ); - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'UserGroup' ,$group_id, json_encode($group_data) ); + $group_role = join(',', $menu_ids); + $group_data = array('group_role' => $group_role); + $result = UserGroup::updateGroupInfo($group_id, $group_data); + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'UserGroup' ,$group_id, json_encode($group_data)); UserSession::reload(); - Common::exitWithSuccess (ErrorMessage::SUCCESS_NEED_LOGIN,'panel/group_role.php'); - }else{ + Common::exitWithSuccess(ErrorMessage::SUCCESS_NEED_LOGIN, 'panel/group_role.php'); + } else { OSAdmin::alert("error"); } } -Template::assign ( 'role_list', $role_list ); -Template::assign ( 'group_id', $group_id ); -Template::assign ( 'group_option_list', $group_option_list ); -Template::assign ( 'group_role', $group_role_array ); -Template::display ( 'panel/group_role.tpl' ); \ No newline at end of file +Template::assign('role_list', $role_list); +Template::assign('group_id', $group_id); +Template::assign('group_option_list', $group_option_list); +Template::assign('group_role', $group_role_array); +Template::display('panel/group_role.tpl'); From 6577ddcd752eeb8deafb363d57875a3ed02d4fad Mon Sep 17 00:00:00 2001 From: McDanci Date: Wed, 23 Mar 2016 09:36:57 +0800 Subject: [PATCH 2/5] Format Sample.class.php --- uploads/include/class/sample/Sample.class.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/uploads/include/class/sample/Sample.class.php b/uploads/include/class/sample/Sample.class.php index 30372a2..f95e15f 100644 --- a/uploads/include/class/sample/Sample.class.php +++ b/uploads/include/class/sample/Sample.class.php @@ -1,9 +1,9 @@ query($sql)->fetchAll(); - if ($list) { - return $list; - } - return array(); + if ($list) return $list; + return array(); } } From 8ad3ea3ff201766f3461c46d522c5b4723d28c0d Mon Sep 17 00:00:00 2001 From: McDanci Date: Tue, 12 Apr 2016 16:52:40 +0800 Subject: [PATCH 3/5] Small changes --- sql/osadmin_v2.1.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/osadmin_v2.1.0.sql b/sql/osadmin_v2.1.0.sql index a8952ec..63fad46 100644 --- a/sql/osadmin_v2.1.0.sql +++ b/sql/osadmin_v2.1.0.sql @@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `osa_menu_url` ( `menu_name` varchar(50) NOT NULL, `menu_url` varchar(255) NOT NULL, `module_id` int(11) NOT NULL, - `is_show` tinyint(4) NOT NULL COMMENT '鏄惁鍦╯idebar閲屽嚭鐜', + `is_show` tinyint(4) NOT NULL COMMENT '鏄惁鍦 sidebar 閲屽嚭鐜', `online` int(11) NOT NULL DEFAULT '1' COMMENT '鍦ㄧ嚎鐘舵侊紝杩樻槸涓嬬嚎鐘舵侊紝鍗冲彲鐢紝涓嶅彲鐢ㄣ', `shortcut_allowed` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '鏄惁鍏佽蹇嵎璁块棶', `menu_desc` varchar(255) DEFAULT NULL, From 815ff8d28b7b8bb2436f0cc1ab5d6eaecff37f11 Mon Sep 17 00:00:00 2001 From: McDanci Date: Tue, 24 Jan 2017 20:33:16 +0800 Subject: [PATCH 4/5] PSR --- uploads/ajax/shortcut.php | 77 +-- uploads/include/class/Base.class.php | 28 +- uploads/include/class/GroupRole.class.php | 62 +- uploads/include/class/MenuUrl.class.php | 505 +++++++------- uploads/include/class/Module.class.php | 234 ++++--- uploads/include/class/QuickNote.class.php | 193 +++--- uploads/include/class/SideBar.class.php | 130 ++-- uploads/include/class/SysLog.class.php | 191 +++--- uploads/include/class/System.class.php | 64 +- uploads/include/class/User.class.php | 632 ++++++++++-------- uploads/include/class/UserGroup.class.php | 209 +++--- uploads/include/class/UserSession.class.php | 150 +++-- uploads/include/class/sample/Sample.class.php | 37 +- .../include/class/sample/SampleBase.class.php | 28 +- uploads/include/config/config.inc.php | 88 +-- uploads/include/init.inc.php | 118 ++-- uploads/include/lib/Common.class.php | 377 ++++++----- uploads/include/lib/ErrorMessage.class.php | 58 +- uploads/include/lib/ExcelReader.class.php | 42 +- uploads/include/lib/OSAEncrypt.class.php | 51 +- uploads/include/lib/OSAdmin.class.php | 130 ++-- uploads/include/lib/Pagination.class.php | 135 ++-- uploads/include/lib/Template.class.php | 137 ++-- uploads/panel/_restore_db_.php | 36 +- uploads/panel/group.php | 56 +- uploads/panel/group_add.php | 49 +- uploads/panel/group_modify.php | 54 +- uploads/panel/group_role.php | 56 +- uploads/panel/groups.php | 44 +- uploads/panel/index.php | 2 +- uploads/panel/login.php | 62 +- uploads/panel/logout.php | 6 +- uploads/panel/menu_add.php | 64 +- uploads/panel/menu_modify.php | 110 +-- uploads/panel/menus.php | 93 +-- uploads/panel/module.php | 68 +- uploads/panel/module_add.php | 48 +- uploads/panel/module_modify.php | 61 +- uploads/panel/modules.php | 42 +- uploads/panel/pdo.php | 19 +- uploads/panel/profile.php | 80 +-- uploads/panel/quicknote_add.php | 38 +- uploads/panel/quicknote_modify.php | 62 +- uploads/panel/quicknotes.php | 72 +- uploads/panel/set.php | 18 +- uploads/panel/setting.php | 41 +- uploads/panel/syslog.php | 104 +-- uploads/panel/system.php | 8 +- uploads/panel/user_add.php | 62 +- uploads/panel/user_modify.php | 82 +-- uploads/panel/users.php | 141 ++-- uploads/panel/verify_code_cn.php | 118 +++- uploads/sample/read_excel.php | 26 +- uploads/sample/sample.php | 6 +- 54 files changed, 2889 insertions(+), 2515 deletions(-) diff --git a/uploads/ajax/shortcut.php b/uploads/ajax/shortcut.php index 3fcf48f..3bfb0bf 100644 --- a/uploads/ajax/shortcut.php +++ b/uploads/ajax/shortcut.php @@ -1,47 +1,48 @@ $shortcuts ); - - $result = User::updateUser ( $user_id,$update_data ); - if($result !==false ){ - $ret = json_encode(array("result"=>"1","msg"=>"娣诲姞鎴愬姛")); - UserSession::reload(); - }else{ - $ret = json_encode(array("result"=>"0","msg"=>"oOops!")); - } - - echo $ret; -}else if($method=="del"){ + $shortcut_arr = explode(',', $shortcuts); + if (!in_array($menu_id, $shortcut_arr)) { + $shortcut_arr[] = $menu_id; + asort($shortcut_arr); + } + $shortcuts = implode(',', $shortcut_arr); + $update_data = array('shortcuts' => $shortcuts); - $shortcut_arr = explode(',',$shortcuts); - $idx = array_search($menu_id,$shortcut_arr); - if($idx !==false ){ - unset($shortcut_arr[$idx]); - } - $shortcuts = implode(',',$shortcut_arr); - $update_data = array ('shortcuts' => $shortcuts ); - - $result = User::updateUser ( $user_id,$update_data ); - if($result !==false ){ - $ret = json_encode(array("result"=>"1","msg"=>"鍒犻櫎鎴愬姛")); - UserSession::reload(); - }else{ - $ret = json_encode(array("result"=>"0","msg"=>"oOops!")); - } - echo $ret; + $result = User::updateUser($user_id, $update_data); + if ($result !== false) { + $ret = json_encode(array("result" => "1", "msg" => "娣诲姞鎴愬姛")); + UserSession::reload(); + } else { + $ret = json_encode(array("result" => "0", "msg" => "oOops!")); + } + + echo $ret; +} else { + if ($method == "del") { + + $shortcut_arr = explode(',', $shortcuts); + $idx = array_search($menu_id, $shortcut_arr); + if ($idx !== false) { + unset($shortcut_arr[$idx]); + } + $shortcuts = implode(',', $shortcut_arr); + $update_data = array('shortcuts' => $shortcuts); + + $result = User::updateUser($user_id, $update_data); + if ($result !== false) { + $ret = json_encode(array("result" => "1", "msg" => "鍒犻櫎鎴愬姛")); + UserSession::reload(); + } else { + $ret = json_encode(array("result" => "0", "msg" => "oOops!")); + } + echo $ret; + } } -?> \ No newline at end of file diff --git a/uploads/include/class/Base.class.php b/uploads/include/class/Base.class.php index 516e912..40fe3fb 100644 --- a/uploads/include/class/Base.class.php +++ b/uploads/include/class/Base.class.php @@ -1,13 +1,19 @@ $module ) { - $list = MenuUrl::getListByModuleId ($module ['module_id'] ,"role"); - foreach ( $list as $menu ) { - $data [$k] ['menu_info'][$menu ['menu_id']] = $menu ['menu_name']; - } - } - - - return $data; - } - - public static function getGroupForOptions() { - $group_list = UserGroup::getAllGroup (); - - foreach ( $group_list as $group ) { - $group_options_array [$group ['group_id']] = $group ['group_name']; - } - - return $group_options_array; - } - -} \ No newline at end of file + +class GroupRole +{ + public static function getGroupRoles($group_id) + { + if (!$group_id || !is_numeric($group_id)) { + return false; + } + $data = Module::getAllModules(1); + //鐢ㄦ埛缁勭殑鏉冮檺 + foreach ($data as $k => $module) { + $list = MenuUrl::getListByModuleId($module ['module_id'], "role"); + foreach ($list as $menu) { + $data [$k] ['menu_info'][$menu ['menu_id']] = $menu ['menu_name']; + } + } + + + return $data; + } + + public static function getGroupForOptions() + { + $group_list = UserGroup::getAllGroup(); + + foreach ($group_list as $group) { + $group_options_array [$group ['group_id']] = $group ['group_name']; + } + + return $group_options_array; + } + +} diff --git a/uploads/include/class/MenuUrl.class.php b/uploads/include/class/MenuUrl.class.php index 80b8616..fd90adf 100644 --- a/uploads/include/class/MenuUrl.class.php +++ b/uploads/include/class/MenuUrl.class.php @@ -1,260 +1,305 @@ query($sql)->fetchAll(); - $list = $db->query($sql)->fetchAll(); + if ($list) { + foreach ($list as $menu_info) { + $url_array[] = $menu_info['menu_url']; + } + return $url_array; + } + return array(); + } - if ($list) { - foreach ($list as $menu_info) { - $url_array[] = $menu_info['menu_url']; - } - return $url_array; - } - return array(); - } + public static function getMenuByUrl($url) + { + $url_array = array(); + $condition = array("menu_url" => $url); + $db = self::__instance(); + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + $menu = $list[0]; + $module = Module::getModuleById($menu['module_id']); + $menu['module_id'] = $module['module_id']; + $menu['module_name'] = $module['module_name']; + $menu['module_url'] = $module['module_url']; + if ($menu['father_menu'] > 0) { + $father_menu = self::getMenuById($menu['father_menu']); + $menu['father_menu_url'] = $father_menu['menu_url']; + $menu['father_menu_name'] = $father_menu['menu_name']; + } + return $menu; + } + return array(); + } - public static function getMenuByUrl($url) - { - $url_array = array(); - $condition = array("menu_url" => $url); - $db = self::__instance(); - $list = $db->select(self::getTableName(), self::$columns, $condition); - if ($list) { - $menu = $list[0]; - $module = Module::getModuleById($menu['module_id']); - $menu['module_id'] = $module['module_id']; - $menu['module_name'] = $module['module_name']; - $menu['module_url'] = $module['module_url']; - if ($menu['father_menu'] > 0) { - $father_menu = self::getMenuById($menu['father_menu']); - $menu['father_menu_url'] = $father_menu['menu_url']; - $menu['father_menu_name'] = $father_menu['menu_name']; - } - return $menu; - } - return array(); - } + public static function getListByModuleId($module_id, $type = "all") + { + if (!$module_id || !is_numeric($module_id)) { + return array(); + } + switch ($type) { + case "sidebar": + $sub_condition["is_show"] = 1; + $sub_condition["online"] = 1; + break; + case "role": + $sub_condition["online"] = 1; + break; + case "navibar": + $sub_condition["is_show"] = 1; + $sub_condition["online"] = 1; + break; + // default: + } + $sub_condition["module_id"] = $module_id; + $condition = array("AND" => $sub_condition); + $db = self::__instance(); + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list; + } + return array(); + } - public static function getListByModuleId($module_id, $type = "all") - { - if (!$module_id || !is_numeric($module_id)) { - return array(); - } - switch ($type) { - case "sidebar": - $sub_condition["is_show"] = 1; - $sub_condition["online"] = 1; - break; - case "role": - $sub_condition["online"] = 1; - break; - case "navibar": - $sub_condition["is_show"] = 1; - $sub_condition["online"] = 1; - break; - // default: - } - $sub_condition["module_id"] = $module_id; - $condition = array("AND" => $sub_condition); - $db = self::__instance(); - $list = $db->select(self::getTableName(), self::$columns, $condition); - if ($list) return $list; - return array(); - } + public static function getFatherMenuForOptions() + { + $menu_options_array = array("0" => "鏃"); + $modules = Module::getAllModules(); + foreach ($modules as $module) { + $list = self::getListByModuleId($module['module_id'], 'navibar'); + foreach ($list as $menu) { + $menu_options_array[$module['module_name']][$menu['menu_id']] = $menu['menu_name']; + } + } + return $menu_options_array; + } - public static function getFatherMenuForOptions() - { - $menu_options_array = array("0" => "鏃"); - $modules = Module::getAllModules(); - foreach ($modules as $module) { - $list = self::getListByModuleId($module['module_id'], 'navibar'); - foreach ($list as $menu) { - $menu_options_array[$module['module_name']][$menu['menu_id']] = $menu['menu_name']; - } - } - return $menu_options_array; - } + public static function addMenu($function_data) + { + if (!$function_data || !is_array($function_data)) { + return false; + } + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $function_data); + self::clearSession(); + return $id; + } - public static function addMenu($function_data) - { - if (!$function_data || !is_array($function_data)) { - return false; - } - $db = self::__instance(); - $id = $db->insert(self::getTableName(), $function_data); - self::clearSession(); - return $id; - } + public static function getAllMenus($start = '', $page_size = '') + { + $db = self::__instance(); + $condition = array(); + if ($page_size) { + $condition['LIMIT'] = array($start, $page_size); + } + $list = $db->select(self::getTableName(), self::$columns, $condition); + $session_list = self::getSessionMenus(); + foreach ($list as &$menu) { + if ($menu['father_menu'] > 0) { + $menu['father_menu_name'] = $session_list[$menu['father_menu']]['menu_name']; + } + } + if ($list) { + return $list; + } + return array(); + } - public static function getAllMenus($start = '', $page_size = '') - { - $db = self::__instance(); - $condition = array(); - if ($page_size) { - $condition['LIMIT'] = array($start, $page_size); - } - $list = $db->select(self::getTableName(), self::$columns, $condition); - $session_list = self::getSessionMenus(); - foreach ($list as &$menu) { - if ($menu['father_menu'] > 0) { - $menu['father_menu_name'] = $session_list[$menu['father_menu']]['menu_name']; - } - } - if ($list) return $list; - return array(); - } + public static function clearSession() + { + unset($_SESSION[self::SESSION_NAME]); + } - public static function clearSession() - { - unset($_SESSION[self::SESSION_NAME]); - } + public static function getSessionMenus() + { + if (array_key_exists(self::SESSION_NAME, $_SESSION)) { + return $_SESSION[self::SESSION_NAME]; + } else { + $db = self::__instance(); + $list = $db->select(self::getTableName(), self::$columns); + $new_list = array(); + foreach ($list as $menu) { + $new_list[$menu['menu_id']] = $menu; + } + foreach ($new_list as $menu_id => &$menu) { + if ($menu['father_menu'] > 0) { + $menu['father_menu_name'] = $new_list[$menu['father_menu']]['menu_name']; + } + } + if ($new_list) { + $_SESSION[self::SESSION_NAME] = $new_list; + } + return $new_list; + } + } - public static function getSessionMenus() - { - if (array_key_exists(self::SESSION_NAME, $_SESSION)) { - return $_SESSION[self::SESSION_NAME]; - } else { - $db = self::__instance(); - $list = $db->select(self::getTableName(), self::$columns); - $new_list = array(); - foreach ($list as $menu) { - $new_list[$menu['menu_id']] = $menu; - } - foreach ($new_list as $menu_id => &$menu) { - if ($menu['father_menu'] > 0) { - $menu['father_menu_name'] = $new_list[$menu['father_menu']]['menu_name']; - } - } - if ($new_list) { - $_SESSION[self::SESSION_NAME] = $new_list; - } - return $new_list; - } - } + public static function search($module_id, $menu_name, $start, $page_size) + { + $db = self::__instance(); + $limit = ""; + $where = ""; + if ($page_size) { + $limit = " limit $start,$page_size "; + } + if ($module_id > 0 && $menu_name != "") { + $where = " where me.module_id=$module_id and me.menu_name like '%$menu_name%'"; + } else { + if ($module_id > 0) { + $where = " where me.module_id=$module_id "; + } + if ($menu_name != "") { + $where = " where me.menu_name like '%$menu_name%' "; + } + } - public static function search($module_id, $menu_name, $start, $page_size) - { - $db = self::__instance(); - $limit = ""; - $where = ""; - if ($page_size) $limit = " limit $start,$page_size "; - if ($module_id > 0 && $menu_name != "") { - $where = " where me.module_id=$module_id and me.menu_name like '%$menu_name%'"; - } else { - if ($module_id > 0) $where = " where me.module_id=$module_id "; - if ($menu_name != "") $where = " where me.menu_name like '%$menu_name%' "; - } + $sql = "select * ,coalesce(mo.module_name, '宸插垹闄') from " . self::getTableName() . " me left join " . Module::getTableName() . " mo on me.module_id = mo.module_id $where order by me.module_id,me.menu_id $limit"; + $list = $db->query($sql)->fetchAll(); + $session_list = self::getSessionMenus(); - $sql = "select * ,coalesce(mo.module_name, '宸插垹闄') from " . self::getTableName() . " me left join " . Module::getTableName() . " mo on me.module_id = mo.module_id $where order by me.module_id,me.menu_id $limit"; - $list = $db->query($sql)->fetchAll(); - $session_list = self::getSessionMenus(); + foreach ($list as &$menu) { + if ($menu['father_menu'] > 0) { + $menu['father_menu_name'] = $session_list[$menu['father_menu']]['menu_name']; + } + } + if ($list) { + return $list; + } + return array(); + } - foreach ($list as &$menu) { - if ($menu['father_menu'] > 0) { - $menu['father_menu_name'] = $session_list[$menu['father_menu']]['menu_name']; - } - } - if ($list) { - return $list; - } - return array(); - } + public static function count($condition = '') + { + $db = self::__instance(); + $num = $db->count(self::getTableName(), $condition); + return $num; + } - public static function count($condition = '') - { - $db = self::__instance(); - $num = $db->count(self::getTableName(), $condition); - return $num; - } + public static function countSearch($module_id, $menu_name) + { + $db = self::__instance(); + $condition = array(); + if ($module_id > 0 && $menu_name != "") { + $condition['module_id'] = $module_id; + $condition['LIKE'] = array("menu_name" => $menu_name); + } else { + if ($module_id > 0) { + $condition['module_id'] = $module_id; + } + if ($menu_name != "") { + $condition['LIKE'] = array("menu_name" => $menu_name); + } + } + $num = $db->count(self::getTableName(), $condition); + return $num; + } - public static function countSearch($module_id, $menu_name) - { - $db = self::__instance(); - $condition = array(); - if ($module_id > 0 && $menu_name != "") { - $condition['module_id'] = $module_id; - $condition['LIKE'] = array("menu_name" => $menu_name); - } else { - if ($module_id > 0) $condition['module_id'] = $module_id; - if ($menu_name != "") $condition['LIKE'] = array("menu_name" => $menu_name); - } - $num = $db->count(self::getTableName(), $condition); - return $num; - } - - public static function delMenu($menu_id) - { - if (!$menu_id || !is_numeric($menu_id)) return false; - $db = self::__instance(); - $condition = array("menu_id" => $menu_id); - $result = $db->delete(self::getTableName(), $condition); - return $result; - } + public static function delMenu($menu_id) + { + if (!$menu_id || !is_numeric($menu_id)) { + return false; + } + $db = self::__instance(); + $condition = array("menu_id" => $menu_id); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } - public static function getMenuById($menu_id) - { - if (!$menu_id || !is_numeric($menu_id)) return false; - $db = self::__instance(); - $condition = array("menu_id" => $menu_id); - $list = $db->select(self::getTableName(), self::$columns, $condition); - if ($list) return $list[0]; + public static function getMenuById($menu_id) + { + if (!$menu_id || !is_numeric($menu_id)) { + return false; + } + $db = self::__instance(); + $condition = array("menu_id" => $menu_id); + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list[0]; + } - return array(); - } + return array(); + } - public static function getMenuByIds($menu_ids, $online = null, $shortcut_allowed = null) - { - $url_array = array(); - $privi = explode(',', $menu_ids); - $sub_condition['menu_id'] = $privi; - if (isset($online)) $sub_condition['online'] = $online; - if (isset($shortcut_allowed)) $sub_condition['shortcut_allowed'] = $shortcut_allowed; + public static function getMenuByIds($menu_ids, $online = null, $shortcut_allowed = null) + { + $url_array = array(); + $privi = explode(',', $menu_ids); + $sub_condition['menu_id'] = $privi; + if (isset($online)) { + $sub_condition['online'] = $online; + } + if (isset($shortcut_allowed)) { + $sub_condition['shortcut_allowed'] = $shortcut_allowed; + } - $db = self::__instance(); - $list = $db->select(self::getTableName(), self::$columns, array("AND" => $sub_condition)); - if ($list) return $list; - return array(); - } + $db = self::__instance(); + $list = $db->select(self::getTableName(), self::$columns, array("AND" => $sub_condition)); + if ($list) { + return $list; + } + return array(); + } - public static function updateMenuInfo($menu_id, $function_data) - { - if (!$function_data || !is_array($function_data)) return false; - $db = self::__instance(); - $condition = array("menu_id" => $menu_id); - $id = $db->update(self::getTableName(), $function_data, $condition); - return $id; - } + public static function updateMenuInfo($menu_id, $function_data) + { + if (!$function_data || !is_array($function_data)) { + return false; + } + $db = self::__instance(); + $condition = array("menu_id" => $menu_id); + $id = $db->update(self::getTableName(), $function_data, $condition); + return $id; + } - /** - * 鎵归噺淇敼鑿滃崟锛屽鎵归噺淇敼鎵灞炴ā鍧 - * menu_ids 鍙互涓烘棤 key 鏁扮粍锛屼篃鍙互涓 1, 2, 3 褰㈠紡鐨勫瓧绗︿覆 - */ - public static function batchUpdateMenus($menu_ids, $function_data) { + /** + * 鎵归噺淇敼鑿滃崟锛屽鎵归噺淇敼鎵灞炴ā鍧 + * menu_ids 鍙互涓烘棤 key 鏁扮粍锛屼篃鍙互涓 1, 2, 3 褰㈠紡鐨勫瓧绗︿覆 + */ + public static function batchUpdateMenus($menu_ids, $function_data) + { - if (!$function_data || !is_array($function_data)) return false; - if (!is_array($menu_ids)) $menu_ids = explode(',', $menu_ids); - $db = self::__instance(); - $condition = array("menu_id" => $menu_ids); + if (!$function_data || !is_array($function_data)) { + return false; + } + if (!is_array($menu_ids)) { + $menu_ids = explode(',', $menu_ids); + } + $db = self::__instance(); + $condition = array("menu_id" => $menu_ids); - $id = $db->update(self::getTableName(), $function_data, $condition); - return $id; - } + $id = $db->update(self::getTableName(), $function_data, $condition); + return $id; + } } diff --git a/uploads/include/class/Module.class.php b/uploads/include/class/Module.class.php index 824093d..1cd006c 100644 --- a/uploads/include/class/Module.class.php +++ b/uploads/include/class/Module.class.php @@ -1,108 +1,130 @@ $is_online); - }else{ - } - $order = ' module_sort asc,module_id asc'; - $condition['ORDER']=$order; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list; - } - return array (); - } - - public static function addModule($module_data) { - if (! $module_data || ! is_array ( $module_data )) { - return false; - } - $db=self::__instance(); - $id = $db->insert ( self::getTableName(), $module_data ); - return $id; - } - - public static function getModuleById($module_id) { - if (! $module_id || ! is_numeric ( $module_id )) { - return false; - } - $db=self::__instance(); - $condition['module_id'] = $module_id; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - return array (); - } - - public static function getModuleByName($module_name) { - if (! $module_name || ! is_numeric ( $module_name )) { - return false; - } - $db=self::__instance(); - $condition['module_name'] = $module_name; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - return array (); - } - - public static function getModuleMenu($module_id) { - if (! $module_id || ! is_numeric ( $module_id )) { - return false; - } - $db=self::__instance(); - $sql="select * from ".self::getTableName() ." m,".MenuUrl::getTableName()." u where m.module_id = $module_id and m.module_id = u.module_id order by m.module_id,u.menu_id"; - $list = $db->query($sql)->fetchAll(); - if ($list) { - return $list[0]; - } - return array (); - } - - public static function updateModuleInfo($module_id,$module_data) { - if (! $module_data || ! is_array ( $module_data )) { - return false; - } - $db=self::__instance(); - $condition=array("module_id"=>$module_id); - $id = $db->update ( self::getTableName(), $module_data, $condition ); - return $id; - } - - public static function delModule($module_id) { - if (! $module_id || ! is_numeric ( $module_id )) { - return false; - } - $db=self::__instance(); - $condition = array("module_id"=>$module_id); - $result = $db->delete ( self::getTableName(), $condition ); - return $result; - } - - public static function getModuleForOptions() { - $module_options_array = array (); - $module_list = self::getAllModules (1); - - foreach ( $module_list as $module ) { - $module_options_array [$module ['module_id']] = $module ['module_name']; - } - - return $module_options_array; - } +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class Module extends Base +{ + // 琛ㄥ悕 + private static $table_name = 'module'; + // 鏌ヨ瀛楁 + private static $columns = array( + 'module_id', + 'module_name', + 'module_url', + 'module_sort', + 'module_desc', + 'module_icon', + 'online' + ); + + public static function getTableName() + { + return parent::$table_prefix . self::$table_name; + } + + //鍒楄〃 + public static function getAllModules($is_online = null) + { + $db = self::__instance(); + $conditon = array(); + + if (isset($is_online)) { + $condition['AND'] = array("online" => $is_online); + } else { + } + $order = ' module_sort asc,module_id asc'; + $condition['ORDER'] = $order; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list; + } + return array(); + } + + public static function addModule($module_data) + { + if (!$module_data || !is_array($module_data)) { + return false; + } + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $module_data); + return $id; + } + + public static function getModuleById($module_id) + { + if (!$module_id || !is_numeric($module_id)) { + return false; + } + $db = self::__instance(); + $condition['module_id'] = $module_id; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + return array(); + } + + public static function getModuleByName($module_name) + { + if (!$module_name || !is_numeric($module_name)) { + return false; + } + $db = self::__instance(); + $condition['module_name'] = $module_name; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + return array(); + } + + public static function getModuleMenu($module_id) + { + if (!$module_id || !is_numeric($module_id)) { + return false; + } + $db = self::__instance(); + $sql = "select * from " . self::getTableName() . " m," . MenuUrl::getTableName() . " u where m.module_id = $module_id and m.module_id = u.module_id order by m.module_id,u.menu_id"; + $list = $db->query($sql)->fetchAll(); + if ($list) { + return $list[0]; + } + return array(); + } + + public static function updateModuleInfo($module_id, $module_data) + { + if (!$module_data || !is_array($module_data)) { + return false; + } + $db = self::__instance(); + $condition = array("module_id" => $module_id); + $id = $db->update(self::getTableName(), $module_data, $condition); + return $id; + } + + public static function delModule($module_id) + { + if (!$module_id || !is_numeric($module_id)) { + return false; + } + $db = self::__instance(); + $condition = array("module_id" => $module_id); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } + + public static function getModuleForOptions() + { + $module_options_array = array(); + $module_list = self::getAllModules(1); + + foreach ($module_list as $module) { + $module_options_array [$module ['module_id']] = $module ['module_name']; + } + + return $module_options_array; + } } diff --git a/uploads/include/class/QuickNote.class.php b/uploads/include/class/QuickNote.class.php index 8312004..83a32d7 100644 --- a/uploads/include/class/QuickNote.class.php +++ b/uploads/include/class/QuickNote.class.php @@ -1,93 +1,106 @@ query($sql)->fetchAll(); - if ($list) { - return $list; - } - return array (); - } - - public static function addNote($note_data) { - if (! $note_data || ! is_array ( $note_data )) { - return false; - } - $db=self::__instance(); - $id = $db->insert ( self::getTableName(), $note_data ); - return $id; - } +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class QuickNote extends Base +{ + // 琛ㄥ悕 + private static $table_name = 'quick_note'; + // 鏌ヨ瀛楁 + private static $columns = array('note_id', 'note_content', 'owner_id'); + + //鐘舵佸畾涔 + + public static function getTableName() + { + return parent::$table_prefix . self::$table_name; + } + + //鍒楄〃 + public static function getNotes($start = '', $page_size = '') + { + $db = self::__instance(); + $limit = ""; + if ($page_size) { + $limit = " limit $start,$page_size "; + } + $columns = implode(self::$columns, ','); + $sql = "select " . $columns . " ,coalesce(u.user_name,'宸插垹闄') as owner_name from " . self::getTableName() . " q left join " . User::getTableName() . " u on q.owner_id = u.user_id order by q.note_id desc $limit"; + $list = $db->query($sql)->fetchAll(); + if ($list) { + return $list; + } + return array(); + } + + public static function addNote($note_data) + { + if (!$note_data || !is_array($note_data)) { + return false; + } + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $note_data); + return $id; + } + + public static function getNoteById($note_id) + { + if (!$note_id || !is_numeric($note_id)) { + return false; + } + $db = self::__instance(); + $condition['note_id'] = $note_id; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + return array(); + } + + public static function getRandomNote() + { + $db = self::__instance(); + $sql = "select min(note_id), max(note_id) from " . self::getTableName(); + $list = $db->query($sql)->fetch(); + if ($list) { + $note_id = rand($list[0], $list[1]); + $condition['note_id[>=]'] = $note_id; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + } + return array(); + } + + public static function count($condition = '') + { + $db = self::__instance(); + $num = $db->count(self::getTableName(), $condition); + return $num; + } + + public static function updateNote($note_id, $note_data) + { + if (!$note_data || !is_array($note_data)) { + return false; + } + $db = self::__instance(); + $condition = array("note_id" => $note_id); + $id = $db->update(self::getTableName(), $note_data, $condition); + + return $id; + } - public static function getNoteById($note_id) { - if (! $note_id || ! is_numeric ( $note_id )) { - return false; - } - $db=self::__instance(); - $condition['note_id'] = $note_id; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - return array (); - } - - public static function getRandomNote() { - $db=self::__instance(); - $sql="select min(note_id), max(note_id) from ".self::getTableName(); - $list = $db->query($sql)->fetch(); - if ($list) { - $note_id=rand($list[0],$list[1]); - $condition['note_id[>=]'] = $note_id; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - } - return array (); - } - - public static function count($condition = '') { - $db=self::__instance(); - $num = $db->count ( self::getTableName(), $condition ); - return $num; - } - - public static function updateNote($note_id,$note_data) { - if (! $note_data || ! is_array ( $note_data )) { - return false; - } - $db=self::__instance(); - $condition=array("note_id"=>$note_id); - $id = $db->update ( self::getTableName(), $note_data,$condition ); - - return $id; - } - - public static function delNote($note_id) { - if (! $note_id || ! is_numeric ( $note_id )) { - return false; - } - $db=self::__instance(); - $condition = array("note_id" => $note_id); - $result = $db->delete ( self::getTableName(), $condition ); - return $result; - } + public static function delNote($note_id) + { + if (!$note_id || !is_numeric($note_id)) { + return false; + } + $db = self::__instance(); + $condition = array("note_id" => $note_id); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } } diff --git a/uploads/include/class/SideBar.class.php b/uploads/include/class/SideBar.class.php index b63fc0c..803cc4e 100644 --- a/uploads/include/class/SideBar.class.php +++ b/uploads/include/class/SideBar.class.php @@ -1,63 +1,69 @@ $module ) { - $list = MenuUrl::getlistByModuleId ($module ['module_id'],'sidebar' ); - - if (! $list) { - unset ( $data [$k] ); - continue; - } - //鍘婚櫎鏃犳潈闄愯闂殑 - foreach ( $list as $key => $value ) { - if (! in_array ( $value ['menu_url'], $access )) { - unset ( $list [$key] ); - } - } - $data [$k] ['menu_list'] = $list; - } - return $data; - } - - public static function getMenuShortCuts() { - - $user_info = UserSession::getSessionInfo (); - //鍔熻兘鑿滃崟 - $data = array (); - $data = Module::getAllModule (); - $user_info = UserSession::getSessionInfo(); - //鐢ㄦ埛鐨勬潈闄 - $access = MenuUrl::getMenuByRole ( $user_info ['user_role'] ); - - foreach ( $data as $k => $module ) { - $list = MenuUrl::getlistByModuleId ('shortcut' , $module ['module_id']); - - if (! $list) { - unset ( $data [$k] ); - continue; - } - //鍘婚櫎鏃犳潈闄愯闂殑 - foreach ( $list as $key => $value ) { - if (! in_array ( $value ['menu_url'], $access )) { - unset ( $list [$key] ); - } - } - $data [$k] ['menu_list'] = $list; - } - return $data; - } -} \ No newline at end of file +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class SideBar +{ + //鏄剧ず鍙鑿滃崟 + const SHOW_MENU = 1; + + public static function getTree() + { + + $user_info = UserSession::getSessionInfo(); + //鍔熻兘鑿滃崟 + $data = array(); + $data = Module::getAllModules(1); + + $user_info = UserSession::getSessionInfo(); + //鐢ㄦ埛鐨勬潈闄 + $access = MenuUrl::getMenuByRole($user_info ['user_role']); + + foreach ($data as $k => $module) { + $list = MenuUrl::getlistByModuleId($module ['module_id'], 'sidebar'); + + if (!$list) { + unset ($data [$k]); + continue; + } + //鍘婚櫎鏃犳潈闄愯闂殑 + foreach ($list as $key => $value) { + if (!in_array($value ['menu_url'], $access)) { + unset ($list [$key]); + } + } + $data [$k] ['menu_list'] = $list; + } + return $data; + } + + public static function getMenuShortCuts() + { + + $user_info = UserSession::getSessionInfo(); + //鍔熻兘鑿滃崟 + $data = array(); + $data = Module::getAllModule(); + $user_info = UserSession::getSessionInfo(); + //鐢ㄦ埛鐨勬潈闄 + $access = MenuUrl::getMenuByRole($user_info ['user_role']); + + foreach ($data as $k => $module) { + $list = MenuUrl::getlistByModuleId('shortcut', $module ['module_id']); + + if (!$list) { + unset ($data [$k]); + continue; + } + //鍘婚櫎鏃犳潈闄愯闂殑 + foreach ($list as $key => $value) { + if (!in_array($value ['menu_url'], $access)) { + unset ($list [$key]); + } + } + $data [$k] ['menu_list'] = $list; + } + return $data; + } +} diff --git a/uploads/include/class/SysLog.class.php b/uploads/include/class/SysLog.class.php index 1b748f1..d4c7a19 100644 --- a/uploads/include/class/SysLog.class.php +++ b/uploads/include/class/SysLog.class.php @@ -1,92 +1,107 @@ $user_name, 'action' => $action, 'class_name' => $class_name ,'class_obj' => $class_obj , 'result' => $result ,'op_time' => $now_time); - $db=self::__instance(); - $id = $db->insert ( self::getTableName(), $insert_data ); - return $id; - } - - public static function getLogs($class_name,$user_name,$start ,$page_size,$start_date='',$end_date='') { - $db=self::__instance(); - - $condition=array(); - $sub_condition = array(); - if($class_name != ''){ - $sub_condition['class_name']=$class_name; - } - if($user_name != ''){ - $sub_condition['user_name']=$user_name; - } - if($start_date !='' && $end_date !=''){ - $sub_condition["op_time[<>]"] =array($start_date,$end_date); - } - if(empty($sub_condition)){ - $condition = array(); - }else{ - $condition["AND"] = $sub_condition; - } - - $condition["ORDER"]=" op_id desc"; - $condition['LIMIT']=array($start,$page_size); +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class SysLog extends Base +{ + private static $table_name = 'sys_log'; + private static $columns = array('op_id', 'user_name', 'action', 'class_name', 'class_obj', 'result', 'op_time'); + + public static function getTableName() + { + return parent::$table_prefix . self::$table_name; + } + + public static function addLog($user_name, $action, $class_name, $class_obj, $result = "") + { + $now_time = time(); + $insert_data = array( + 'user_name' => $user_name, + 'action' => $action, + 'class_name' => $class_name, + 'class_obj' => $class_obj, + 'result' => $result, + 'op_time' => $now_time + ); + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $insert_data); + return $id; + } + + public static function getLogs($class_name, $user_name, $start, $page_size, $start_date = '', $end_date = '') + { + $db = self::__instance(); + + $condition = array(); + $sub_condition = array(); + if ($class_name != '') { + $sub_condition['class_name'] = $class_name; + } + if ($user_name != '') { + $sub_condition['user_name'] = $user_name; + } + if ($start_date != '' && $end_date != '') { + $sub_condition["op_time[<>]"] = array($start_date, $end_date); + } + if (empty($sub_condition)) { + $condition = array(); + } else { + $condition["AND"] = $sub_condition; + } + + $condition["ORDER"] = " op_id desc"; + $condition['LIMIT'] = array($start, $page_size); + + $list = $db->select(self::getTableName(), self::$columns, $condition); + if (!empty($list)) { + foreach ($list as &$item) { + $item['op_time'] = Common::getDateTime($item['op_time']); + } + } + + if ($list) { + return $list; + } + return array(); + } + + public static function count($class_name = '', $user_name = 0) + { + $db = self::__instance(); + + $sub_condition = array(); + if ($class_name != '') { + $sub_condition['class_name[=]'] = $class_name; + } + if ($user_name != '') { + $sub_condition['user_name'] = $user_name; + } + + if (empty($sub_condition)) { + $condition = array(); + } else { + $condition["AND"] = $sub_condition; + } + + $num = $db->count(self::getTableName(), $condition); + return $num; + } - $list = $db->select ( self::getTableName(), self::$columns, $condition); - if(!empty($list)){ - foreach ($list as &$item){ - $item['op_time']=Common::getDateTime($item['op_time']); - } - } + public static function getCountByDate($class_name, $user_name, $start_date, $end_date) + { + $db = self::__instance(); + $condition = array(); + if ($class_name != '') { + $sub_condition['class_name'] = $class_name; + } + if ($user_name != '') { + $sub_condition['user_name'] = $user_name; + } + $sub_condition["op_time[<>]"] = array($start_date, $end_date); + $condition["AND"] = $sub_condition; - if ($list) { - return $list; - } - return array (); - } - - public static function count($class_name='',$user_name=0) { - $db=self::__instance(); - - $sub_condition = array(); - if($class_name != ''){ - $sub_condition['class_name[=]']=$class_name; - } - if($user_name != ''){ - $sub_condition['user_name']=$user_name; - } - - if(empty($sub_condition)){ - $condition = array(); - }else{ - $condition["AND"] = $sub_condition; - } - - $num = $db->count ( self::getTableName(),$condition); - return $num; - } - - public static function getCountByDate($class_name,$user_name,$start_date,$end_date) { - $db=self::__instance(); - $condition=array(); - if($class_name != ''){ - $sub_condition['class_name']=$class_name; - } - if($user_name != ''){ - $sub_condition['user_name']=$user_name; - } - $sub_condition["op_time[<>]"] =array($start_date,$end_date); - $condition["AND"] = $sub_condition; - - $num = $db->count ( self::getTableName(),$condition ); - return $num; - } + $num = $db->count(self::getTableName(), $condition); + return $num; + } } -?> \ No newline at end of file diff --git a/uploads/include/class/System.class.php b/uploads/include/class/System.class.php index 9aaa83a..7f9603c 100644 --- a/uploads/include/class/System.class.php +++ b/uploads/include/class/System.class.php @@ -1,31 +1,37 @@ query ($sql); - - return $id; - } - - public static function get($key_name) { - $db=self::__instance(); - $condition['key_name'] = $key_name; - $list = $db->select ( self::getTableName(),self::$columns,$condition ); - if($list){ - return json_decode($list[0]['key_value']); - } - return null; - } +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class System extends Base +{ + private static $table_name = 'system'; + private static $columns = array('key_name', 'key_value'); + + public static function getTableName() + { + return parent::$table_prefix . self::$table_name; + } + + public static function set($key_name, $key_value) + { + + $key_value = json_encode($key_value); + $sql = "insert into " . self::getTableName() . " values ('$key_name' ,'$key_value') on duplicate key update key_value='$key_value'"; + $db = self::__instance(); + $id = $db->query($sql); + + return $id; + } + + public static function get($key_name) + { + $db = self::__instance(); + $condition['key_name'] = $key_name; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return json_decode($list[0]['key_value']); + } + return null; + } } -?> \ No newline at end of file diff --git a/uploads/include/class/User.class.php b/uploads/include/class/User.class.php index 0576aa9..9e0a28f 100644 --- a/uploads/include/class/User.class.php +++ b/uploads/include/class/User.class.php @@ -1,294 +1,340 @@ query($sql)->fetch();// self::getTableName(), self::$columns, $condition ); - if ($list) { - $list['login_time']=Common::getDateTime($list['login_time']); - return $list; - } - return array (); - } - - public static function getUserById($user_id) { - if (! $user_id || ! is_numeric ( $user_id )) { - return false; - } - $db=self::__instance(); - $condition = array("AND" => - array("user_id[=]" => $user_id, - ) - ); - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - - if ($list) { - $list[0]['login_time']=Common::getDateTime($list[0]['login_time']); - return $list [0]; - } - return array (); - } - - public static function setCookieRemember($encrypted,$day=7){ - setcookie("osa_remember",$encrypted,time()+3600*24*$day); - } - - public static function getCookieRemember(){ - $encrypted = $_COOKIE["osa_remember"]; - $base64=urldecode($encrypted); - return OSAEncrypt::decrypt($base64); - } - - public static function logout(){ - setcookie("osa_remember","",time()-3600); - unset($_SESSION[UserSession::SESSION_NAME]); - unset($_SESSION['osa_timezone']); - } - - public static function getAllUsers( $start ='' ,$page_size='' ) { - $db=self::__instance(); - $limit =""; - if($page_size){ - $limit =" limit $start,$page_size "; - } - $sql = "select * ,coalesce(g.group_name,'宸插垹闄') from ".self::getTableName()." u left join ".UserGroup::getTableName()." g on u.user_group = g.group_id order by u.user_id desc $limit"; - - $list=$db->query($sql)->fetchAll(); - if(!empty($list)){ - foreach($list as &$item){ - - $item['login_time']=Common::getDateTime($item['login_time']); - } - } - - if ($list) { - return $list; - } - return array (); - } - - public static function search($user_group ,$user_name, $start ='' ,$page_size='' ) { - $db=self::__instance(); - $limit =""; - $where = ""; - if($page_size){ - $limit =" limit $start,$page_size "; - } - if($user_group >0 && $user_name!=""){ - $where = " where u.user_group=$user_group and u.user_name like '%$user_name%'"; - }else{ - if($user_group>0){ - $where = " where u.user_group=$user_group "; - } - if($user_name!=""){ - $where = " where u.user_name like '%$user_name%' "; - } - } - $sql = "select * ,coalesce(g.group_name,'宸插垹闄') from ".self::getTableName()." u left join ".UserGroup::getTableName()." g on u.user_group = g.group_id $where order by u.user_id desc $limit"; - - $list=$db->query($sql)->fetchAll(); - if(!empty($list)){ - foreach($list as &$item){ - - $item['login_time']=Common::getDateTime($item['login_time']); - } - } - if ($list) { - return $list; - } - return array (); - } - - public static function getUsersByGroup( $group_id ) { - $db=self::__instance(); - $condition = array("AND" => - array("user_group[=]" => $group_id, - ) - ); - $list = $db->select( self::getTableName(), self::$columns, $condition ); - if ($list) { - foreach($list as &$item){ - if($item['login_time']==null){ - ; - }else{ - $item['login_time']=Common::getDateTime($item['login_time']); - } - } - return $list; - } - return array (); - } - - public static function checkLogin() { - $user_info = UserSession::getSessionInfo (); - if (empty ( $user_info )) { - Common::jumpUrl("panel/login.php"); - return true; - } - } - - public static function checkActionAccess() { - $action_url = Common::getActionUrl(); - - - $user_info = UserSession::getSessionInfo(); - - $role_menu_url = MenuUrl::getMenuByRole ( $user_info['user_role']); - - $search_result = in_array ( $action_url, $role_menu_url ); - if (! $search_result) { - Common::exitWithMessage ('鎮ㄥ綋鍓嶆病鏈夋潈闄愯闂鍔熻兘锛屽闇璁块棶璇疯仈绯荤鐞嗗憳寮閫氭潈闄','index.php' ); - return true; - } - } - - public static function checkPassword($user_name, $password) { - $md5_pwd = md5 ( $password ); - $db=self::__instance(); - $condition = array("AND"=> - array("user_name" => $user_name, - "password" => $md5_pwd, - ) - ); - - $list = $db->select( self::getTableName(), self::$columns, $condition ); - - if ($list) { - - return $list [0]; - } else { - return false; - } - } - - public static function updateUser($user_id,$user_data) { - - if (! $user_data || ! is_array ( $user_data )) { - return false; - } - $db=self::__instance(); - $condition=array("user_id"=>$user_id); - - $id = $db->update ( self::getTableName(), $user_data, $condition ); - return $id; - } - - /** - * 鎵归噺淇敼鐢ㄦ埛锛屽鎵归噺淇敼鐢ㄦ埛鍒嗙粍 - * user_ids 鍙互涓烘棤key鏁扮粍锛屼篃鍙互涓1,2,3褰㈠娍鐨勫瓧绗︿覆 - */ - public static function batchUpdateUsers($user_ids,$user_data) { - - if (! $user_data || ! is_array ( $user_data )) { - return false; - } - if(!is_array($user_ids)){ - $user_ids=explode(',',$user_ids); - } - $db=self::__instance(); - $condition=array("user_id"=>$user_ids); - - $id = $db->update ( self::getTableName(), $user_data, $condition ); - return $id; - } - - public static function addUser($user_data) { - if (! $user_data || ! is_array ( $user_data )) { - return false; - } - $db=self::__instance(); - $id = $db->insert ( self::getTableName(), $user_data ); - return $id; - } - - public static function delUser($user_id) { - if (! $user_id || ! is_numeric ( $user_id )) { - return false; - } - $db=self::__instance(); - $condition = array("user_id"=>$user_id); - $result = $db->delete ( self::getTableName(), $condition ); - return $result; - } - - public static function delUserByUserName($user_name) { - if (! $user_name ) { - return false; - } - $db=self::__instance(); - $condition = array("user_name"=>$user_name); - $result = $db->delete ( self::getTableName(), $condition ); - return $result; - } - - public static function count($condition = '') { - $db=self::__instance(); - $num = $db->count ( self::getTableName(), $condition ); - return $num; - } - - public static function countSearch($user_group,$user_name) { - $db=self::__instance(); - $condition = array(); - if($user_group >0 && $user_name!=""){ - $condition['user_group']=$user_group; - $condition['LIKE']=array("user_name"=>$user_name); - }else{ - if($user_group>0){ - $condition['user_group']=$user_group; - } - if($user_name!=""){ - $condition['LIKE']=array("user_name"=>$user_name); - } - } - $num = $db->count( self::getTableName(), $condition); - return $num; - } - - public static function setTemplate($user_id,$template){ - $user_data=array("template"=>$template); - $ret=self::updateUser($user_id,$user_data); - return $ret; - } - - public static function loginDoSomething($user_id){ - - $user_info = User::getUserById($user_id); - if($user_info['status']!=1){ - Common::jumpUrl("login.php"); - return; - } - - //璇诲彇璇ョ敤鎴锋墍灞炵敤鎴风粍灏嗚缁勭殑鏉冮檺淇濆瓨鍦$_SESSION涓 - $user_group = UserGroup::getGroupById($user_info['user_group']); - - $user_info['group_id']=$user_group['group_id']; - $user_info['user_role']=$user_group['group_role']; - $user_info['shortcuts_arr']=explode(',',$user_info['shortcuts']); - $menu = MenuUrl::getMenuByUrl('/admin/setting.php'); - if(strpos($user_group['group_role'],$menu['menu_id'])){ - $user_info['setting']=1; - } - - $login_time = time(); - $login_ip = Common::getIp (); - $update_data = array ('login_ip' => $login_ip, 'login_time' => $login_time ); - User::updateUser ( $user_info['user_id'], $update_data ); - $user_info['login_ip']=$login_ip; - $user_info['login_time']=Common::getDateTime($login_time); - UserSession::setSessionInfo( $user_info); - } -} \ No newline at end of file +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class User extends Base +{ + // 琛ㄥ悕 + private static $table_name = 'user'; + // 鏌ヨ瀛楁 + private static $columns = array( + 'user_id', + 'user_name', + 'password', + 'real_name', + 'mobile', + 'email', + 'user_desc', + 'login_time', + 'status', + 'login_ip', + 'user_group', + 'template', + 'shortcuts', + 'show_quicknote' + ); + //鐘舵佸畾涔 + const ACTIVE = 1; + const DEACTIVE = 0; + + public static function getTableName() + { + return parent::$table_prefix . self::$table_name; + } + + public static function getUserByName($user_name) + { + $db = self::__instance(); + $sql = "select * ,g.group_name from " . self::getTableName() . " u," . UserGroup::getTableName() . " g where u.user_name='$user_name' and u.user_group=g.group_id"; + $list = $db->query($sql)->fetch();// self::getTableName(), self::$columns, $condition ); + if ($list) { + $list['login_time'] = Common::getDateTime($list['login_time']); + return $list; + } + return array(); + } + + public static function getUserById($user_id) + { + if (!$user_id || !is_numeric($user_id)) { + return false; + } + $db = self::__instance(); + $condition = array( + "AND" => + array( + "user_id[=]" => $user_id, + ) + ); + $list = $db->select(self::getTableName(), self::$columns, $condition); + + if ($list) { + $list[0]['login_time'] = Common::getDateTime($list[0]['login_time']); + return $list [0]; + } + return array(); + } + + public static function setCookieRemember($encrypted, $day = 7) + { + setcookie("osa_remember", $encrypted, time() + 3600 * 24 * $day); + } + + public static function getCookieRemember() + { + $encrypted = $_COOKIE["osa_remember"]; + $base64 = urldecode($encrypted); + return OSAEncrypt::decrypt($base64); + } + + public static function logout() + { + setcookie("osa_remember", "", time() - 3600); + unset($_SESSION[UserSession::SESSION_NAME]); + unset($_SESSION['osa_timezone']); + } + + public static function getAllUsers($start = '', $page_size = '') + { + $db = self::__instance(); + $limit = ""; + if ($page_size) { + $limit = " limit $start,$page_size "; + } + $sql = "select * ,coalesce(g.group_name,'宸插垹闄') from " . self::getTableName() . " u left join " . UserGroup::getTableName() . " g on u.user_group = g.group_id order by u.user_id desc $limit"; + + $list = $db->query($sql)->fetchAll(); + if (!empty($list)) { + foreach ($list as &$item) { + + $item['login_time'] = Common::getDateTime($item['login_time']); + } + } + + if ($list) { + return $list; + } + return array(); + } + + public static function search($user_group, $user_name, $start = '', $page_size = '') + { + $db = self::__instance(); + $limit = ""; + $where = ""; + if ($page_size) { + $limit = " limit $start,$page_size "; + } + if ($user_group > 0 && $user_name != "") { + $where = " where u.user_group=$user_group and u.user_name like '%$user_name%'"; + } else { + if ($user_group > 0) { + $where = " where u.user_group=$user_group "; + } + if ($user_name != "") { + $where = " where u.user_name like '%$user_name%' "; + } + } + $sql = "select * ,coalesce(g.group_name,'宸插垹闄') from " . self::getTableName() . " u left join " . UserGroup::getTableName() . " g on u.user_group = g.group_id $where order by u.user_id desc $limit"; + + $list = $db->query($sql)->fetchAll(); + if (!empty($list)) { + foreach ($list as &$item) { + + $item['login_time'] = Common::getDateTime($item['login_time']); + } + } + if ($list) { + return $list; + } + return array(); + } + + public static function getUsersByGroup($group_id) + { + $db = self::__instance(); + $condition = array( + "AND" => + array( + "user_group[=]" => $group_id, + ) + ); + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + foreach ($list as &$item) { + if ($item['login_time'] == null) { + ; + } else { + $item['login_time'] = Common::getDateTime($item['login_time']); + } + } + return $list; + } + return array(); + } + + public static function checkLogin() + { + $user_info = UserSession::getSessionInfo(); + if (empty ($user_info)) { + Common::jumpUrl("panel/login.php"); + return true; + } + } + + public static function checkActionAccess() + { + $action_url = Common::getActionUrl(); + + + $user_info = UserSession::getSessionInfo(); + + $role_menu_url = MenuUrl::getMenuByRole($user_info['user_role']); + + $search_result = in_array($action_url, $role_menu_url); + if (!$search_result) { + Common::exitWithMessage('鎮ㄥ綋鍓嶆病鏈夋潈闄愯闂鍔熻兘锛屽闇璁块棶璇疯仈绯荤鐞嗗憳寮閫氭潈闄', 'index.php'); + return true; + } + } + + public static function checkPassword($user_name, $password) + { + $md5_pwd = md5($password); + $db = self::__instance(); + $condition = array( + "AND" => + array( + "user_name" => $user_name, + "password" => $md5_pwd, + ) + ); + + $list = $db->select(self::getTableName(), self::$columns, $condition); + + if ($list) { + + return $list [0]; + } else { + return false; + } + } + + public static function updateUser($user_id, $user_data) + { + + if (!$user_data || !is_array($user_data)) { + return false; + } + $db = self::__instance(); + $condition = array("user_id" => $user_id); + + $id = $db->update(self::getTableName(), $user_data, $condition); + return $id; + } + + /** + * 鎵归噺淇敼鐢ㄦ埛锛屽鎵归噺淇敼鐢ㄦ埛鍒嗙粍 + * user_ids 鍙互涓烘棤key鏁扮粍锛屼篃鍙互涓1,2,3褰㈠娍鐨勫瓧绗︿覆 + */ + public static function batchUpdateUsers($user_ids, $user_data) + { + + if (!$user_data || !is_array($user_data)) { + return false; + } + if (!is_array($user_ids)) { + $user_ids = explode(',', $user_ids); + } + $db = self::__instance(); + $condition = array("user_id" => $user_ids); + + $id = $db->update(self::getTableName(), $user_data, $condition); + return $id; + } + + public static function addUser($user_data) + { + if (!$user_data || !is_array($user_data)) { + return false; + } + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $user_data); + return $id; + } + + public static function delUser($user_id) + { + if (!$user_id || !is_numeric($user_id)) { + return false; + } + $db = self::__instance(); + $condition = array("user_id" => $user_id); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } + + public static function delUserByUserName($user_name) + { + if (!$user_name) { + return false; + } + $db = self::__instance(); + $condition = array("user_name" => $user_name); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } + + public static function count($condition = '') + { + $db = self::__instance(); + $num = $db->count(self::getTableName(), $condition); + return $num; + } + + public static function countSearch($user_group, $user_name) + { + $db = self::__instance(); + $condition = array(); + if ($user_group > 0 && $user_name != "") { + $condition['user_group'] = $user_group; + $condition['LIKE'] = array("user_name" => $user_name); + } else { + if ($user_group > 0) { + $condition['user_group'] = $user_group; + } + if ($user_name != "") { + $condition['LIKE'] = array("user_name" => $user_name); + } + } + $num = $db->count(self::getTableName(), $condition); + return $num; + } + + public static function setTemplate($user_id, $template) + { + $user_data = array("template" => $template); + $ret = self::updateUser($user_id, $user_data); + return $ret; + } + + public static function loginDoSomething($user_id) + { + + $user_info = User::getUserById($user_id); + if ($user_info['status'] != 1) { + Common::jumpUrl("login.php"); + return; + } + + //璇诲彇璇ョ敤鎴锋墍灞炵敤鎴风粍灏嗚缁勭殑鏉冮檺淇濆瓨鍦$_SESSION涓 + $user_group = UserGroup::getGroupById($user_info['user_group']); + + $user_info['group_id'] = $user_group['group_id']; + $user_info['user_role'] = $user_group['group_role']; + $user_info['shortcuts_arr'] = explode(',', $user_info['shortcuts']); + $menu = MenuUrl::getMenuByUrl('/admin/setting.php'); + if (strpos($user_group['group_role'], $menu['menu_id'])) { + $user_info['setting'] = 1; + } + + $login_time = time(); + $login_ip = Common::getIp(); + $update_data = array('login_ip' => $login_ip, 'login_time' => $login_time); + User::updateUser($user_info['user_id'], $update_data); + $user_info['login_ip'] = $login_ip; + $user_info['login_time'] = Common::getDateTime($login_time); + UserSession::setSessionInfo($user_info); + } +} diff --git a/uploads/include/class/UserGroup.class.php b/uploads/include/class/UserGroup.class.php index 4b99d7a..4717a1c 100644 --- a/uploads/include/class/UserGroup.class.php +++ b/uploads/include/class/UserGroup.class.php @@ -1,102 +1,115 @@ query($sql)->fetchAll(); + if ($list) { + + return $list; + } + return array(); + } + + public static function addGroup($group_data) + { + if (!$group_data || !is_array($group_data)) { + return false; + } + $db = self::__instance(); + $id = $db->insert(self::getTableName(), $group_data); + return $id; + } + + public static function getGroupById($group_id) + { + if (!$group_id || !is_numeric($group_id)) { + return false; + } + $db = self::__instance(); + $condition['group_id'] = $group_id; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + return array(); + } + + public static function getGroupByName($group_name) + { + if ($group_name == "") { + return false; + } + $db = self::__instance(); + $condition['group_name'] = $group_name; + $list = $db->select(self::getTableName(), self::$columns, $condition); + if ($list) { + return $list [0]; + } + return array(); + } + + public static function updateGroupInfo($group_id, $group_data) + { + if (!$group_data || !is_array($group_data)) { + return false; + } + $db = self::__instance(); + $condition = array("group_id" => $group_id); + $id = $db->update(self::getTableName(), $group_data, $condition); + + return $id; + } + + public static function delGroup($group_id) + { + if (!$group_id || !is_numeric($group_id)) { + return false; + } + $db = self::__instance(); + $condition = array("group_id" => $group_id); + $result = $db->delete(self::getTableName(), $condition); + return $result; + } + + public static function getGroupForOptions() + { + $group_list = self::getAllGroup(); + + foreach ($group_list as $group) { + $group_options_array [$group ['group_id']] = $group ['group_name']; + } - public static function getTableName(){ - return parent::$table_prefix.self::$table_name; - } - - //鍒楄〃 - public static function getAllGroup() { - $db=self::__instance(); - $columns = implode(self::$columns, ','); - $sql = "select " . $columns . ", u.user_name as owner_name from ".self::getTableName()." g left join ".User::getTableName()." u on g.owner_id = u.user_id order by g.group_id"; - $list = $db->query($sql)->fetchAll(); - if ($list) { - - return $list; - } - return array (); - } - - public static function addGroup($group_data) { - if (! $group_data || ! is_array ( $group_data )) { - return false; - } - $db=self::__instance(); - $id = $db->insert ( self::getTableName(), $group_data ); - return $id; - } + return $group_options_array; + } - public static function getGroupById($group_id) { - if (! $group_id || ! is_numeric ( $group_id )) { - return false; - } - $db=self::__instance(); - $condition['group_id'] = $group_id; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - return array (); - } - - public static function getGroupByName($group_name) { - if ( $group_name == "" ) { - return false; - } - $db=self::__instance(); - $condition['group_name'] = $group_name; - $list = $db->select ( self::getTableName(), self::$columns, $condition ); - if ($list) { - return $list [0]; - } - return array (); - } - - public static function updateGroupInfo($group_id,$group_data) { - if (! $group_data || ! is_array ( $group_data )) { - return false; - } - $db=self::__instance(); - $condition=array("group_id"=>$group_id); - $id = $db->update ( self::getTableName(), $group_data,$condition ); - - return $id; - } - - public static function delGroup($group_id) { - if (! $group_id || ! is_numeric ( $group_id )) { - return false; - } - $db=self::__instance(); - $condition = array("group_id" => $group_id); - $result = $db->delete ( self::getTableName(), $condition ); - return $result; - } - - public static function getGroupForOptions() { - $group_list = self::getAllGroup (); - - foreach ( $group_list as $group ) { - $group_options_array [$group ['group_id']] = $group ['group_name']; - } - - return $group_options_array; - } - - public static function getGroupUsers($group_id) { - $db=self::__instance(); - $columns = implode(self::$columns,','); - $sql = "select " . $columns . ", u.user_id as user_id, u.user_name as user_name, u.real_name as real_name from " . self::getTableName() . " g,".User::getTableName()." u where g.group_id = $group_id and g.group_id = u.user_group ORDER BY g.group_id, u.user_id"; - $list = $db->query ($sql)->fetchAll(); - if ($list) { - return $list; - } - return array (); - } + public static function getGroupUsers($group_id) + { + $db = self::__instance(); + $columns = implode(self::$columns, ','); + $sql = "select " . $columns . ", u.user_id as user_id, u.user_name as user_name, u.real_name as real_name from " . self::getTableName() . " g," . User::getTableName() . " u where g.group_id = $group_id and g.group_id = u.user_group ORDER BY g.group_id, u.user_id"; + $list = $db->query($sql)->fetchAll(); + if ($list) { + return $list; + } + return array(); + } } diff --git a/uploads/include/class/UserSession.class.php b/uploads/include/class/UserSession.class.php index f905431..464dbd7 100644 --- a/uploads/include/class/UserSession.class.php +++ b/uploads/include/class/UserSession.class.php @@ -1,72 +1,86 @@ query($sql)->fetchAll(); - if ($list) return $list; - return array(); - } + $sql = "select " . self::$columns . " from " . self::getTableName(); + $list = $db->query($sql)->fetchAll(); + if ($list) { + return $list; + } + return array(); + } } diff --git a/uploads/include/class/sample/SampleBase.class.php b/uploads/include/class/sample/SampleBase.class.php index 3542fc5..7e20eea 100644 --- a/uploads/include/class/sample/SampleBase.class.php +++ b/uploads/include/class/sample/SampleBase.class.php @@ -1,13 +1,19 @@ '127.0.0.1', - 'port' => '3306', - 'username' => 'root', - 'password' => '', - 'db_name' => 'osadmin'); +define('OSA_DB_ID', 'osadmin'); +$DATABASE_LIST[OSA_DB_ID] = array( + 'server' => '127.0.0.1', + 'port' => '3306', + 'username' => 'root', + 'password' => '', + 'db_name' => 'osadmin' +); // 鏍蜂緥鏁版嵁搴撹缃 -define('SAMPLE_DB_ID' ,'sample'); -$DATABASE_LIST[SAMPLE_DB_ID] = array ( - 'server' => '127.0.0.1', - 'port' => '3306', - 'username' => 'root', - 'password' => '', - 'db_name' => 'osadmin'); +define('SAMPLE_DB_ID', 'sample'); +$DATABASE_LIST[SAMPLE_DB_ID] = array( + 'server' => '127.0.0.1', + 'port' => '3306', + 'username' => 'root', + 'password' => '', + 'db_name' => 'osadmin' +); // COOKIE 鍔犲瘑瀵嗛挜锛屽缓璁慨鏀 -define('OSA_ENCRYPT_KEY','whatafuckingday!'); +define('OSA_ENCRYPT_KEY', 'whatafuckingday!'); // prefix 涓嶈鏇存敼锛岄櫎闈炰慨鏀 osadmin.sql 鏂囦欢涓殑鎵鏈夎〃鍚 -define('OSA_TABLE_PREFIX' ,'osa_'); +define('OSA_TABLE_PREFIX', 'osa_'); // 椤甸潰璁剧疆 -define('DEBUG' ,false); +define('DEBUG', false); define('PAGE_SIZE', 25); $OSA_TEMPLATES = array( - 'default' => '榛樿妯℃澘', - 'schoolpainting' => '闈掕懕鏍″洯', - 'blacktie' => '榛戣壊棰嗙粨', - 'wintertide' => '鍐伴洩鍐', + 'default' => '榛樿妯℃澘', + 'schoolpainting' => '闈掕懕鏍″洯', + 'blacktie' => '榛戣壊棰嗙粨', + 'wintertide' => '鍐伴洩鍐', ); -$OSADMIN_COMMAND_FOR_LOG = array( - 'SUCCESS' => '鎴愬姛', - 'ERROR' => '澶辫触', - 'ADD' => '澧炲姞', - 'DELETE' => '鍒犻櫎', - 'MODIFY' => '淇敼', - 'LOGIN' => '鐧诲綍', - 'LOGOUT' => '閫鍑', - 'PAUSE' => '灏佸仠', - 'PLAY' => '瑙e皝', +$OSADMIN_COMMAND_FOR_LOG = array( + 'SUCCESS' => '鎴愬姛', + 'ERROR' => '澶辫触', + 'ADD' => '澧炲姞', + 'DELETE' => '鍒犻櫎', + 'MODIFY' => '淇敼', + 'LOGIN' => '鐧诲綍', + 'LOGOUT' => '閫鍑', + 'PAUSE' => '灏佸仠', + 'PLAY' => '瑙e皝', ); $OSADMIN_CLASS_FOR_LOG = array( - 'ALL' => '鍏ㄩ儴', - 'User' => '鐢ㄦ埛', - 'UserGroup' => '璐﹀彿缁', - 'Module' => '鑿滃崟妯″潡', - 'MenuUrl' => '鍔熻兘', - 'GroupRole' => '鏉冮檺', - 'QuickNote' => 'QuickNote', + 'ALL' => '鍏ㄩ儴', + 'User' => '鐢ㄦ埛', + 'UserGroup' => '璐﹀彿缁', + 'Module' => '鑿滃崟妯″潡', + 'MenuUrl' => '鍔熻兘', + 'GroupRole' => '鏉冮檺', + 'QuickNote' => 'QuickNote', ); diff --git a/uploads/include/init.inc.php b/uploads/include/init.inc.php index 9a3b32f..3ab77ab 100644 --- a/uploads/include/init.inc.php +++ b/uploads/include/init.inc.php @@ -2,41 +2,43 @@ error_reporting(E_ALL); require 'config/config.inc.php'; session_start(); -function OSAdminAutoLoad($classname){ +function OSAdminAutoLoad($classname) +{ - $filename = str_replace('_', '/', $classname) . '.class.php'; + $filename = str_replace('_', '/', $classname) . '.class.php'; // class绫 $filepath = ADMIN_BASE_CLASS . $filename; if (file_exists($filepath)) { return include $filepath; - }else{ - // Class 浠呮敮鎸佷竴绾у瓙鐩綍 - // 濡傛灉瀛愮洰褰曚腑 class 鏂囦欢涓 CLASS 鏍逛笅鏂囦欢鍚屽悕锛屽垯瀛愮洰褰曢噷鐨 class 鏂囦欢灏嗚蹇界暐 - - $handle=opendir(ADMIN_BASE_CLASS); - - while (false !== ($file = readdir($handle))) { - if (is_dir(ADMIN_BASE_CLASS. "/" . $file)) { - $filepath=ADMIN_BASE_CLASS."/".$file."/".$filename; - if (file_exists($filepath)) { - return include $filepath; - } - } - } - } + } else { + // Class 浠呮敮鎸佷竴绾у瓙鐩綍 + // 濡傛灉瀛愮洰褰曚腑 class 鏂囦欢涓 CLASS 鏍逛笅鏂囦欢鍚屽悕锛屽垯瀛愮洰褰曢噷鐨 class 鏂囦欢灏嗚蹇界暐 + + $handle = opendir(ADMIN_BASE_CLASS); + + while (false !== ($file = readdir($handle))) { + if (is_dir(ADMIN_BASE_CLASS . "/" . $file)) { + $filepath = ADMIN_BASE_CLASS . "/" . $file . "/" . $filename; + if (file_exists($filepath)) { + return include $filepath; + } + } + } + } // lib 搴撴枃浠 $filepath = ADMIN_BASE_LIB . $filename; if (file_exists($filepath)) { return include $filepath; } - throw new Exception( $filepath . ' NOT FOUND!'); + throw new Exception($filepath . ' NOT FOUND!'); } + spl_autoload_register('OSAdminAutoLoad'); -if(!isset($_SESSION['osa_timezone'])){ - $timezone = System::get('timezone'); - $_SESSION['osa_timezone'] = $timezone; +if (!isset($_SESSION['osa_timezone'])) { + $timezone = System::get('timezone'); + $_SESSION['osa_timezone'] = $timezone; } date_default_timezone_set($_SESSION['osa_timezone']); @@ -44,48 +46,48 @@ function OSAdminAutoLoad($classname){ /** * 涓嶉渶瑕佺櫥褰曞氨鍙互璁块棶鐨勯摼鎺ワ紝涔熷彲浠ユ槸鏌愪釜鐩綍锛屼笉鍚瓙鐩綍 * 濡 "/nologin/", "/nologin/aaa/" -**/ + **/ -$no_need_login_page=array("/block.php","/panel/login.php","/panel/logout.php",); +$no_need_login_page = array("/block.php", "/panel/login.php", "/panel/logout.php",); // 濡傛灉涓嶉渶瑕佺櫥褰曞氨鍙互璁块棶鐨勮瘽 $action_url = Common::getActionUrl(); -if( OSAdmin::checkNoNeedLogin($action_url,$no_need_login_page) ){ - // for login.php, logout.php, etc . . . - // ; +if (OSAdmin::checkNoNeedLogin($action_url, $no_need_login_page)) { + // for login.php, logout.php, etc . . . + // ; } else { - // 鍚﹀垯闇瑕侀獙璇佺櫥褰曚俊鎭 - if (empty($_SESSION[UserSession::SESSION_NAME])) { - $user_id = User::getCookieRemember(); - if ($user_id > 0) { - User::loginDoSomething($user_id); - } - } - - User::checkLogin(); - - User::checkActionAccess(); - $current_user_info = UserSession::getSessionInfo(); - // 濡傛灉闈 AJAX 璇锋眰 - if (stripos($_SERVER['SCRIPT_NAME'],"/ajax") === false) { - // 鏄剧ず鑿滃崟銆佸鑸潯銆佹ā鏉 - $sidebar = SideBar::getTree (); - - // 鏄惁鏄剧ず quick note - if($current_user_info['show_quicknote']){ - OSAdmin::showQuickNote(); - } - - $menu = MenuUrl::getMenuByUrl(Common::getActionUrl()); - Template::assign ( 'page_title', $menu['menu_name']); - Template::assign ( 'content_header', $menu ); - Template::assign ( 'sidebar', $sidebar ); - Template::assign ( 'current_module_id', $menu['module_id'] ); - Template::assign ( 'user_info', UserSession::getSessionInfo()); - } + // 鍚﹀垯闇瑕侀獙璇佺櫥褰曚俊鎭 + if (empty($_SESSION[UserSession::SESSION_NAME])) { + $user_id = User::getCookieRemember(); + if ($user_id > 0) { + User::loginDoSomething($user_id); + } + } + + User::checkLogin(); + + User::checkActionAccess(); + $current_user_info = UserSession::getSessionInfo(); + // 濡傛灉闈 AJAX 璇锋眰 + if (stripos($_SERVER['SCRIPT_NAME'], "/ajax") === false) { + // 鏄剧ず鑿滃崟銆佸鑸潯銆佹ā鏉 + $sidebar = SideBar::getTree(); + + // 鏄惁鏄剧ず quick note + if ($current_user_info['show_quicknote']) { + OSAdmin::showQuickNote(); + } + + $menu = MenuUrl::getMenuByUrl(Common::getActionUrl()); + Template::assign('page_title', $menu['menu_name']); + Template::assign('content_header', $menu); + Template::assign('sidebar', $sidebar); + Template::assign('current_module_id', $menu['module_id']); + Template::assign('user_info', UserSession::getSessionInfo()); + } } -Template::assign ( 'osa_templates', $OSA_TEMPLATES); +Template::assign('osa_templates', $OSA_TEMPLATES); -$sidebarStatus=$_COOKIE['sidebarStatus']==null?"yes":$_COOKIE['sidebarStatus']; -Template::assign ( 'sidebarStatus', $sidebarStatus); +$sidebarStatus = $_COOKIE['sidebarStatus'] == null ? "yes" : $_COOKIE['sidebarStatus']; +Template::assign('sidebarStatus', $sidebarStatus); diff --git a/uploads/include/lib/Common.class.php b/uploads/include/lib/Common.class.php index 9b64e3c..b2cddac 100644 --- a/uploads/include/lib/Common.class.php +++ b/uploads/include/lib/Common.class.php @@ -1,178 +1,201 @@ 0){ - $forward_title = $menu['menu_name']; - } - if ($forward_url) { - $message_detail = "$message_detail "; - } - Template::assign ( 'type', $type ); - Template::assign ( 'page_title', $page_title ); - Template::assign ( 'message_detail', $message_detail ); - Template::assign ( 'forward_url', $forward_url ); - Template::assign ( 'forward_title', $forward_title); - Template::Display ( 'message.tpl' ); - exit(); - } - - public static function exitWithError($message_detail, $forward_url, $second = 3,$type="error") { - self::exitWithMessage($message_detail, $forward_url, $second ,$type); - } - - public static function exitWithSuccess($message_detail, $forward_url, $second = 3 ,$type="success") { - self::exitWithMessage($message_detail, $forward_url, $second, $type); - } - - public static function checkParam($param,$to_url=null){ - - if($to_url == null ){ - if(array_key_exists('HTTP_REFERER',$_SERVER)){ - $referer = $_SERVER['HTTP_REFERER']; - } - if(!empty($referer)){ - $start = strpos($referer,ADMIN_URL); - $to_url = substr($referer,$start+strlen(ADMIN_URL)); - }else{ - $to_url = 'index.php'; - } - } - - if (empty ( $param )) { - Common::exitWithError ( '缂哄皯蹇呰鐨勫弬鏁', $to_url ,3,"error" ); - } - } - - public static function jumpUrl($url) { - - Header ( "Location: ".ADMIN_URL."/$url" ); - return true; - } - - public static function isPost() { - return $_SERVER ['REQUEST_METHOD'] === 'POST' ? TRUE : FALSE; - } - - public static function isGet() { - return $_SERVER ['REQUEST_METHOD'] === 'GET' ? TRUE : FALSE; - } - - public static function getIp() { - if (getenv ( "HTTP_CLIENT_IP" ) && strcasecmp ( getenv ( "HTTP_CLIENT_IP" ), "unknown" )) { - $ip = getenv ( "HTTP_CLIENT_IP" ); - } elseif (getenv ( "HTTP_X_FORWARDED_FOR" ) && strcasecmp ( getenv ( "HTTP_X_FORWARDED_FOR" ), "unknown" )) { - $ip = getenv ( "HTTP_X_FORWARDED_FOR" ); - } elseif (getenv ( "REMOTE_ADDR" ) && strcasecmp ( getenv ( "REMOTE_ADDR" ), "unknown" )) { - $ip = getenv ( "REMOTE_ADDR" ); - } elseif (isset ( $_SERVER ['REMOTE_ADDR'] ) && $_SERVER ['REMOTE_ADDR'] && strcasecmp ( $_SERVER ['REMOTE_ADDR'], "unknown" )) { - $ip = $_SERVER ['REMOTE_ADDR']; - } else { - $ip = "unknown"; - } - return ($ip); - } - - public static function getDateTime($time = null) { - - return (!is_numeric($time)) ? date ( 'Y-m-d H:i:s' ) : date( 'Y-m-d H:i:s', $time); - } - - public static function getTime() { - return strtotime(date( 'Y-m-d H:i:s' )); - } - - public static function getSysInfo() { - $sys_info_array = array (); - $sys_info_array ['gmt_time'] = gmdate ( "Y骞磎鏈坉鏃 H:i:s", time () ); - $sys_info_array ['bj_time'] = gmdate ( "Y骞磎鏈坉鏃 H:i:s", time () + 8 * 3600 ); - $sys_info_array ['server_ip'] = gethostbyname ( $_SERVER ["SERVER_NAME"] ); - $sys_info_array ['software'] = $_SERVER ["SERVER_SOFTWARE"]; - $sys_info_array ['port'] = $_SERVER ["SERVER_PORT"]; - $sys_info_array ['admin'] = $_SERVER ["SERVER_ADMIN"]; - $sys_info_array ['diskfree'] = intval ( diskfreespace ( "." ) / (1024 * 1024) ) . 'Mb'; - $sys_info_array ['current_user'] = @get_current_user (); - $sys_info_array ['timezone'] = date_default_timezone_get(); - $db=new Medoo(OSA_DB_ID); - $mysql_version = $db->query("select version()")->fetchAll(); - $sys_info_array ['mysql_version'] = $mysql_version[0]['version()']; - return $sys_info_array; - } - - public static function transact($options) { - $temp_array = array (); - foreach ( $options as $k => $v ) { - if (is_null ( $v ) || (is_string ( $v ) && trim ( $v ) == '')) - $v = ''; - else - is_array ( $v ) ? $v = self::transact ( $v ) : $v = ( string ) $v; - $temp_array [$k] = $v; - } - return $temp_array; - } - - public static function getRandomIp() { - $ip = ''; - for($i = 0; $i < 4; $i ++) { - $ip_str = rand ( 1, 255 ); - $ip .= ".$ip_str"; - } - $ip = substr($ip, 1); - - return $ip; - } - - public static function filterText($text){ - if(ini_get('magic_quotes_gpc')){ - $text=stripslashes($text); - } - return $text; - } -} \ No newline at end of file +if (!defined('ACCESS')) { + exit('Access denied.'); +} + +class Common +{ + + //鑾峰彇OSAdmin鐨刟ction_url锛岀敤浜庢潈闄愰獙璇 + public static function getActionUrl() + { + $action_script = $_SERVER['SCRIPT_NAME']; + $admin_url = strtolower(ADMIN_URL); + if ($admin_url{strlen($admin_url) - 1} == "/") { + $admin_url = substr($admin_url, 0, strlen($admin_url) - 1); + } + + $http_pos = strpos($admin_url, 'http://'); + + if ($http_pos !== false) { + $admin_url_no_http = substr($admin_url, 7); + } else { + $admin_url_no_http = $admin_url; + } + $slash = 0; + $slash = strpos($admin_url_no_http, '/'); + + if ($slash) { + $sub_dir = substr($admin_url_no_http, $slash); + $action_url = substr($action_script, strlen($sub_dir)); + } else { + $action_url = $action_script; + } + return str_replace('//', '/', $action_url); + } + + public static function exitWithMessage($message_detail, $forward_url, $second = 3, $type = "message") + { + + switch ($type) { + case "success" : + $page_title = "鎿嶄綔鎴愬姛锛"; + break; + case "error": + $page_title = "閿欒!"; + break; + default: + $page_title = "鍡!"; + break; + } + $temp = explode('?', $forward_url); + $file_url = $temp[0]; + if ($file_url{0} !== "/") { + $file_url = '/' . $file_url; + $forward_url = '/' . $forward_url; + } + $menu = MenuUrl::getMenuByUrl($file_url); + $forward_title = "棣栭〉"; + if (sizeof($menu) > 0) { + $forward_title = $menu['menu_name']; + } + if ($forward_url) { + $message_detail = "$message_detail "; + } + Template::assign('type', $type); + Template::assign('page_title', $page_title); + Template::assign('message_detail', $message_detail); + Template::assign('forward_url', $forward_url); + Template::assign('forward_title', $forward_title); + Template::Display('message.tpl'); + exit(); + } + + public static function exitWithError($message_detail, $forward_url, $second = 3, $type = "error") + { + self::exitWithMessage($message_detail, $forward_url, $second, $type); + } + + public static function exitWithSuccess($message_detail, $forward_url, $second = 3, $type = "success") + { + self::exitWithMessage($message_detail, $forward_url, $second, $type); + } + + public static function checkParam($param, $to_url = null) + { + + if ($to_url == null) { + if (array_key_exists('HTTP_REFERER', $_SERVER)) { + $referer = $_SERVER['HTTP_REFERER']; + } + if (!empty($referer)) { + $start = strpos($referer, ADMIN_URL); + $to_url = substr($referer, $start + strlen(ADMIN_URL)); + } else { + $to_url = 'index.php'; + } + } + + if (empty ($param)) { + Common::exitWithError('缂哄皯蹇呰鐨勫弬鏁', $to_url, 3, "error"); + } + } + + public static function jumpUrl($url) + { + + Header("Location: " . ADMIN_URL . "/$url"); + return true; + } + + public static function isPost() + { + return $_SERVER ['REQUEST_METHOD'] === 'POST' ? true : false; + } + + public static function isGet() + { + return $_SERVER ['REQUEST_METHOD'] === 'GET' ? true : false; + } + + public static function getIp() + { + if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) { + $ip = getenv("HTTP_CLIENT_IP"); + } elseif (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) { + $ip = getenv("HTTP_X_FORWARDED_FOR"); + } elseif (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) { + $ip = getenv("REMOTE_ADDR"); + } elseif (isset ($_SERVER ['REMOTE_ADDR']) && $_SERVER ['REMOTE_ADDR'] && strcasecmp($_SERVER ['REMOTE_ADDR'], + "unknown") + ) { + $ip = $_SERVER ['REMOTE_ADDR']; + } else { + $ip = "unknown"; + } + return ($ip); + } + + public static function getDateTime($time = null) + { + + return (!is_numeric($time)) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $time); + } + + public static function getTime() + { + return strtotime(date('Y-m-d H:i:s')); + } + + public static function getSysInfo() + { + $sys_info_array = array(); + $sys_info_array ['gmt_time'] = gmdate("Y骞磎鏈坉鏃 H:i:s", time()); + $sys_info_array ['bj_time'] = gmdate("Y骞磎鏈坉鏃 H:i:s", time() + 8 * 3600); + $sys_info_array ['server_ip'] = gethostbyname($_SERVER ["SERVER_NAME"]); + $sys_info_array ['software'] = $_SERVER ["SERVER_SOFTWARE"]; + $sys_info_array ['port'] = $_SERVER ["SERVER_PORT"]; + $sys_info_array ['admin'] = $_SERVER ["SERVER_ADMIN"]; + $sys_info_array ['diskfree'] = intval(diskfreespace(".") / (1024 * 1024)) . 'Mb'; + $sys_info_array ['current_user'] = @get_current_user(); + $sys_info_array ['timezone'] = date_default_timezone_get(); + $db = new Medoo(OSA_DB_ID); + $mysql_version = $db->query("select version()")->fetchAll(); + $sys_info_array ['mysql_version'] = $mysql_version[0]['version()']; + return $sys_info_array; + } + + public static function transact($options) + { + $temp_array = array(); + foreach ($options as $k => $v) { + if (is_null($v) || (is_string($v) && trim($v) == '')) { + $v = ''; + } else { + is_array($v) ? $v = self::transact($v) : $v = ( string )$v; + } + $temp_array [$k] = $v; + } + return $temp_array; + } + + public static function getRandomIp() + { + $ip = ''; + for ($i = 0; $i < 4; $i++) { + $ip_str = rand(1, 255); + $ip .= ".$ip_str"; + } + $ip = substr($ip, 1); + + return $ip; + } + + public static function filterText($text) + { + if (ini_get('magic_quotes_gpc')) { + $text = stripslashes($text); + } + return $text; + } +} diff --git a/uploads/include/lib/ErrorMessage.class.php b/uploads/include/lib/ErrorMessage.class.php index 70de36c..bcdcaca 100644 --- a/uploads/include/lib/ErrorMessage.class.php +++ b/uploads/include/lib/ErrorMessage.class.php @@ -1,29 +1,33 @@ setOutputEncoding('UTF-8'); //璁剧疆杈撳嚭鐨勭紪鐮佷负utf8 - $ret = $data->read($file); //瑕佽鍙栫殑excel鏂囦欢鍦板潃 - if($ret == -1){ - $array = false; - }else{ - for ($i =1 ; $i <= $data->sheets[0]['numRows']; $i++) { - for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { - $array[$i-1][$j-1] = $data->sheets[0]['cells'][$i][$j]; - } - } - } - return $array; - } +if (!defined('ACCESS')) { + exit('Access denied.'); +} +require(__DIR__ . '/Spreadsheet_Excel_Reader.class.php'); + +class ExcelReader +{ + public static function readXLS($file) + { + $data = new Spreadsheet_Excel_Reader(); + $data->setOutputEncoding('UTF-8'); //璁剧疆杈撳嚭鐨勭紪鐮佷负utf8 + $ret = $data->read($file); //瑕佽鍙栫殑excel鏂囦欢鍦板潃 + if ($ret == -1) { + $array = false; + } else { + for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { + for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { + $array[$i - 1][$j - 1] = $data->sheets[0]['cells'][$i][$j]; + } + } + } + return $array; + } } -?> \ No newline at end of file diff --git a/uploads/include/lib/OSAEncrypt.class.php b/uploads/include/lib/OSAEncrypt.class.php index a7f6a25..9b69841 100644 --- a/uploads/include/lib/OSAEncrypt.class.php +++ b/uploads/include/lib/OSAEncrypt.class.php @@ -1,25 +1,32 @@ \ No newline at end of file diff --git a/uploads/include/lib/OSAdmin.class.php b/uploads/include/lib/OSAdmin.class.php index d46cbee..7f8f545 100644 --- a/uploads/include/lib/OSAdmin.class.php +++ b/uploads/include/lib/OSAdmin.class.php @@ -1,75 +1,83 @@ +class OSAdmin extends Base +{ + public static function showQuickNote() + { + $note = QuickNote::getRandomNote(); + $note_content = $note['note_content']; + $note_html = "
$note_content
"; - Template::assign("osadmin_quick_note",$note_html); - } - - public static function alert($type,$message=""){ - if($message == "") { - switch(strtolower($type)){ - case "success": - $message=ErrorMessage::SUCCESS; - break; - case "error" : - $message=ErrorMessage::ERROR; - break; - } - } - $alert_html="
$message
"; - Template::assign("osadmin_action_alert",$alert_html); - } - - public static function renderJsConfirm($class,$confirm_title="纭畾瑕佽繖鏍峰仛鍚楋紵"){ - $confirm_html=" + } + + $confirm_html .= " + +"; + return $confirm_html; + } + + public static function checkNoNeedLogin($action_url, $no_need_login_array) + { + $last_slash_pos = strrpos($action_url, '/'); + $action_dir = substr($action_url, 0, $last_slash_pos + 1); + + if (in_array($action_url, $no_need_login_array) || in_array($action_dir, $no_need_login_array)) { + return true; + } else { + return false; + } + } -"; - return $confirm_html; - } - - public static function checkNoNeedLogin($action_url,$no_need_login_array){ - $last_slash_pos = strrpos($action_url,'/'); - $action_dir = substr($action_url,0,$last_slash_pos+1); - - if(in_array($action_url,$no_need_login_array) || in_array($action_dir,$no_need_login_array)){ - return true; - }else{ - return false; - } - } - - public static function _restore_db_($sql_file){ - $file = file($sql_file); - $sql = implode('',$file); - $db=self::__instance(); - $ret = $db->query($sql); - //print_r($db->error()); - return $ret; - } + public static function _restore_db_($sql_file) + { + $file = file($sql_file); + $sql = implode('', $file); + $db = self::__instance(); + $ret = $db->query($sql); + //print_r($db->error()); + return $ret; + } } diff --git a/uploads/include/lib/Pagination.class.php b/uploads/include/lib/Pagination.class.php index b00ef9e..2224033 100644 --- a/uploads/include/lib/Pagination.class.php +++ b/uploads/include/lib/Pagination.class.php @@ -1,69 +1,72 @@
    "; - $offset=self::OFFSET; - //$page_size=10; - $total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size); - - $page_no=$page_no<1?1:$page_no; - $page_no=$page_no>($total_page)?($total_page):$page_no; - if ($page_no > 1){ - $navibar .= "
  • 棣栭〉
  • \n
  • 涓婁竴椤
  • \n"; - } - /**** 鏄剧ず椤垫暟 鍒嗛〉鏍忔樉绀11椤碉紝鍓5鏉...褰撳墠椤...鍚5鏉 *****/ - $start_page = $page_no -$offset; - $end_page =$page_no+$offset; - if($start_page<1){ - $start_page=1; - } - if($end_page>$total_page){ - $end_page=$total_page; - } - for($i=$start_page;$i<=$end_page;$i++){ - if($i==$page_no){ - $navibar.= "
  • $i
  • "; - }else{ - $navibar.= "
  • $i
  • "; - } - } - - if ($page_no < $total_page){ - $navibar .= "
  • 涓嬩竴椤
  • \n
  • 鏈〉
  • \n "; - } - if($total_page>0){ - $navibar.="
  • ".$page_no ."/". $total_page."
  • "; - } - $navibar.="
  • 鍏".$row_count."鏉
  • "; - $jump =""; - //$jump ="
  • "; - - $navibar.=$jump; - $navibar.="
"; - - return $navibar; - } + * @author yuwenqi@gmail.com + * @time 2013-05-15 + */ +class Pagination +{ + //鏄剧ず褰撳墠椤电殑鍓嶅悗椤垫暟 4,5,6,涓,8,9,10 + const OFFSET = 3; + + public static function showPager($link, &$page_no, $page_size, $row_count) + { + $url = ""; + $params = ""; + if ($link != "") { + $pos = strpos($link, "?"); + + if ($pos === false) { + $url = $link; + } else { + $url = substr($link, 0, $pos); + $params = substr($link, $pos + 1); + } + } + + $navibar = "
    "; + $offset = self::OFFSET; + //$page_size=10; + $total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); + + $page_no = $page_no < 1 ? 1 : $page_no; + $page_no = $page_no > ($total_page) ? ($total_page) : $page_no; + if ($page_no > 1) { + $navibar .= "
  • 棣栭〉
  • \n
  • 涓婁竴椤
  • \n"; + } + /**** 鏄剧ず椤垫暟 鍒嗛〉鏍忔樉绀11椤碉紝鍓5鏉...褰撳墠椤...鍚5鏉 *****/ + $start_page = $page_no - $offset; + $end_page = $page_no + $offset; + if ($start_page < 1) { + $start_page = 1; + } + if ($end_page > $total_page) { + $end_page = $total_page; + } + for ($i = $start_page; $i <= $end_page; $i++) { + if ($i == $page_no) { + $navibar .= "
  • $i
  • "; + } else { + $navibar .= "
  • $i
  • "; + } + } + + if ($page_no < $total_page) { + $navibar .= "
  • 涓嬩竴椤
  • \n
  • 鏈〉
  • \n "; + } + if ($total_page > 0) { + $navibar .= "
  • " . $page_no . "/" . $total_page . "
  • "; + } + $navibar .= "
  • 鍏" . $row_count . "鏉
  • "; + $jump = ""; + //$jump ="
  • "; + + $navibar .= $jump; + $navibar .= "
"; + + return $navibar; + } } -?> - \ No newline at end of file diff --git a/uploads/include/lib/Template.class.php b/uploads/include/lib/Template.class.php index 8ca9e61..512c1a7 100644 --- a/uploads/include/lib/Template.class.php +++ b/uploads/include/lib/Template.class.php @@ -1,95 +1,108 @@ setTemplateDir(TEMPLATE_DIR); + static private function getTemplate() + { + if (null == self::$mTemplate) { + $smarty = new Smarty(); + $smarty->setTemplateDir(TEMPLATE_DIR); //$smarty->template_dir = TEMPLATE_DIR; - $smarty->setCompileDir(TEMPLATE_COMPILED); + $smarty->setCompileDir(TEMPLATE_COMPILED); //$smarty->compile_dir = TEMPLATE_COMPILED; - $smarty->setConfigDir(TEMPLATE_CONFIGS); + $smarty->setConfigDir(TEMPLATE_CONFIGS); //$smarty->config_dir = TEMPLATE_CONFIGS; $smarty->setCacheDir(TEMPLATE_CACHE); - //$smarty->cache_dir = TEMPLATE_CACHE; - $smarty->setPluginsDir(TEMPLATE_PLUGINS); - //$smarty->plugins_dir = TEMPLATE_PLUGINS; + //$smarty->cache_dir = TEMPLATE_CACHE; + $smarty->setPluginsDir(TEMPLATE_PLUGINS); + //$smarty->plugins_dir = TEMPLATE_PLUGINS; - $smarty->left_delimiter = '<{'; - $smarty->right_delimiter = '}>'; - self::$mTemplate = $smarty; - } - return self::$mTemplate; - } + $smarty->left_delimiter = '<{'; + $smarty->right_delimiter = '}>'; + self::$mTemplate = $smarty; + } + return self::$mTemplate; + } /** - *鍏抽棴瀵硅薄 + *鍏抽棴瀵硅薄 * @return void */ - static private function closeTemplate(){ - self::$mTemplate = null; - } + static private function closeTemplate() + { + self::$mTemplate = null; + } /** - * 鏄剧ず妯$増 - * @param mixed $tpl_file - * @param array $v - * @param mixed $cache_id + * 鏄剧ず妯$増 + * @param mixed $tpl_file + * @param array $v + * @param mixed $cache_id * @return void */ - static public function display( $tpl_file,$v=array(), $cache_id=null ){ - if ( is_array($v) ) self::Assign($v); - else $cache_id = $v; - $smarty = self::getTemplate(); - //var_dump($smarty); - $smarty->display( $tpl_file, $cache_id ); - self::closeTemplate(); - } - + static public function display($tpl_file, $v = array(), $cache_id = null) + { + if (is_array($v)) { + self::Assign($v); + } else { + $cache_id = $v; + } + $smarty = self::getTemplate(); + //var_dump($smarty); + $smarty->display($tpl_file, $cache_id); + self::closeTemplate(); + } + /** - * 鍚戞ā鐗堜腑璧嬪煎彉閲 - * @param mixed $k - * @param mixed $v + * 鍚戞ā鐗堜腑璧嬪煎彉閲 + * @param mixed $k + * @param mixed $v * @return void */ - static public function assign($k=null, $v=null){ - $smarty = self::getTemplate(); - if ( $k && is_array($k) ) { - foreach( $k AS $key=>$value ) - $smarty->assign($key, $value); - return $smarty; - } - $smarty->assign($k, $v); - return $smarty; - } + static public function assign($k = null, $v = null) + { + $smarty = self::getTemplate(); + if ($k && is_array($k)) { + foreach ($k AS $key => $value) { + $smarty->assign($key, $value); + } + return $smarty; + } + $smarty->assign($k, $v); + return $smarty; + } /** - * 娓呯┖smarty瀵硅薄 + * 娓呯┖smarty瀵硅薄 * @return void */ - static public function clear(){ - self::closeTemplate(); - } + static public function clear() + { + self::closeTemplate(); + } } diff --git a/uploads/panel/_restore_db_.php b/uploads/panel/_restore_db_.php index 241bb7e..a7bbbc5 100644 --- a/uploads/panel/_restore_db_.php +++ b/uploads/panel/_restore_db_.php @@ -1,24 +1,24 @@ $user_group); - $result = User::batchUpdateUsers ($user_ids,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'User' ,$user_ids, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/groups.php'); - } else { - - OSAdmin::alert("error"); - } - } + if (empty($user_ids) || empty($user_group)) { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + if (in_array(1, $user_ids)) { + Common::exitWithError('涓嶅彲鏇存敼鍒濆绠$悊鍛樼殑璐﹀彿缁', 'panel/groups.php'); + } + $user_ids = implode(',', $user_ids); + $update_data = array('user_group' => $user_group); + $result = User::batchUpdateUsers($user_ids, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'User', $user_ids, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/groups.php'); + } else { + + OSAdmin::alert("error"); + } + } } $user_infos = User::getUsersByGroup($group_id); -$groupOptions=UserGroup::getGroupForOptions(); +$groupOptions = UserGroup::getGroupForOptions(); -Template::assign ( 'group', $group ); -Template::assign ( 'user_infos', $user_infos ); -Template::assign ( 'groupOptions', $groupOptions ); -Template::display ( 'panel/group.tpl' ); \ No newline at end of file +Template::assign('group', $group); +Template::assign('user_infos', $user_infos); +Template::assign('groupOptions', $groupOptions); +Template::display('panel/group.tpl'); diff --git a/uploads/panel/group_add.php b/uploads/panel/group_add.php index 8c2ca54..6d3f536 100644 --- a/uploads/panel/group_add.php +++ b/uploads/panel/group_add.php @@ -1,26 +1,33 @@ $group_name, 'group_desc' => $group_desc, 'group_role' => "1,5,17,18,22,23,24,25" ,'owner_id' => UserSession::getUserId() ); - $group_id = UserGroup::addGroup ( $input_data ); - - if ($group_id) { - SysLog::addLog ( UserSession::getUserName(), 'ADD', 'UserGroup' ,$group_id, json_encode($input_data) ); - Common::exitWithSuccess ('璐﹀彿缁勬坊鍔犲畬鎴','panel/groups.php'); - } - } +if (Common::isPost()) { + $exist = UserGroup::getGroupByName($group_name); + if ($exist) { + + OSAdmin::alert("error", ErrorMessage::NAME_CONFLICT); + } else { + if ($group_name == "") { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $input_data = array( + 'group_name' => $group_name, + 'group_desc' => $group_desc, + 'group_role' => "1,5,17,18,22,23,24,25", + 'owner_id' => UserSession::getUserId() + ); + $group_id = UserGroup::addGroup($input_data); + + if ($group_id) { + SysLog::addLog(UserSession::getUserName(), 'ADD', 'UserGroup', $group_id, json_encode($input_data)); + Common::exitWithSuccess('璐﹀彿缁勬坊鍔犲畬鎴', 'panel/groups.php'); + } + } + } } -Template::assign("_POST" ,$_POST); -Template::display('panel/group_add.tpl' ); +Template::assign("_POST", $_POST); +Template::display('panel/group_add.tpl'); diff --git a/uploads/panel/group_modify.php b/uploads/panel/group_modify.php index d88d85b..c6db95d 100644 --- a/uploads/panel/group_modify.php +++ b/uploads/panel/group_modify.php @@ -1,36 +1,36 @@ $group_name, 'group_desc' => $group_desc); - $result = UserGroup::updateGroupInfo ( $group_id,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'UserGroup' ,$group_id, json_encode($update_data) ); - Common::exitWithSuccess ( '璐﹀彿缁勪慨鏀瑰畬鎴','panel/groups.php' ); - } else { - - OSAdmin::alert("error"); - } - } +if (Common::isPost()) { + + if ($group_name == "") { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $update_data = array('group_name' => $group_name, 'group_desc' => $group_desc); + $result = UserGroup::updateGroupInfo($group_id, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'UserGroup', $group_id, json_encode($update_data)); + Common::exitWithSuccess('璐﹀彿缁勪慨鏀瑰畬鎴', 'panel/groups.php'); + } else { + + OSAdmin::alert("error"); + } + } } -$groupOptions=UserGroup::getGroupForOptions(); +$groupOptions = UserGroup::getGroupForOptions(); -Template::assign ( 'group', $group ); -Template::assign ( 'groupOptions', $groupOptions ); -Template::display ( 'panel/group_modify.tpl' ); \ No newline at end of file +Template::assign('group', $group); +Template::assign('groupOptions', $groupOptions); +Template::display('panel/group_modify.tpl'); diff --git a/uploads/panel/group_role.php b/uploads/panel/group_role.php index e1f4c43..76e4fe9 100644 --- a/uploads/panel/group_role.php +++ b/uploads/panel/group_role.php @@ -9,8 +9,8 @@ $group_option_list = GroupRole::getGroupForOptions(); $group_info = UserGroup::getGroupById($group_id); if (!$group_info) { - $group_id = 1; - $group_info = UserGroup::getGroupById($group_id); + $group_id = 1; + $group_info = UserGroup::getGroupById($group_id); } $role_list = GroupRole::getGroupRoles($group_id); @@ -18,32 +18,32 @@ $group_role_array = explode(',', $group_role); if (Common::isPost()) { - if($group_id == 1){ - $temp = array(); - foreach ($group_role_array as $group_role) { - - // 绯荤粺棰勭暀鑿滃崟 id 涓 100 浠ュ唴 - if ($group_role > 100){ - $temp[] = $group_role; - } - } - - $admin_role = array_diff($group_role_array,$temp); - - $menu_ids = array_merge($admin_role,$menu_ids); - $menu_ids = array_unique($menu_ids); - asort($menu_ids); - } - $group_role = join(',', $menu_ids); - $group_data = array('group_role' => $group_role); - $result = UserGroup::updateGroupInfo($group_id, $group_data); - if ($result >= 0) { - SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'UserGroup' ,$group_id, json_encode($group_data)); - UserSession::reload(); - Common::exitWithSuccess(ErrorMessage::SUCCESS_NEED_LOGIN, 'panel/group_role.php'); - } else { - OSAdmin::alert("error"); - } + if ($group_id == 1) { + $temp = array(); + foreach ($group_role_array as $group_role) { + + // 绯荤粺棰勭暀鑿滃崟 id 涓 100 浠ュ唴 + if ($group_role > 100) { + $temp[] = $group_role; + } + } + + $admin_role = array_diff($group_role_array, $temp); + + $menu_ids = array_merge($admin_role, $menu_ids); + $menu_ids = array_unique($menu_ids); + asort($menu_ids); + } + $group_role = join(',', $menu_ids); + $group_data = array('group_role' => $group_role); + $result = UserGroup::updateGroupInfo($group_id, $group_data); + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'UserGroup', $group_id, json_encode($group_data)); + UserSession::reload(); + Common::exitWithSuccess(ErrorMessage::SUCCESS_NEED_LOGIN, 'panel/group_role.php'); + } else { + OSAdmin::alert("error"); + } } Template::assign('role_list', $role_list); diff --git a/uploads/panel/groups.php b/uploads/panel/groups.php index 3e08307..9673ab8 100644 --- a/uploads/panel/groups.php +++ b/uploads/panel/groups.php @@ -1,28 +1,30 @@ 0){ - OSAdmin::alert("error",ErrorMessage::HAVE_USER); - }else if(intval($group_id) === 1){ - OSAdmin::alert("error",ErrorMessage::CAN_NOT_DO_FOR_SUPER_GROUP); - }else{ - $group = UserGroup::getGroupById($group_id); - $result = UserGroup::delGroup ( $group_id ); - if ($result>0) { - SysLog::addLog ( UserSession::getUserName(), 'DELETE', 'UserGroup',$group_id, json_encode($group) ); - Common::exitWithSuccess ('宸插皢璐﹀彿缁勫垹闄','panel/groups.php'); - }else{ - OSAdmin::alert("error"); - } - } +if ($method == 'del' && !empty ($group_id)) { + $users = UserGroup::getGroupUsers($group_id); + if (sizeof($users) > 0) { + OSAdmin::alert("error", ErrorMessage::HAVE_USER); + } else { + if (intval($group_id) === 1) { + OSAdmin::alert("error", ErrorMessage::CAN_NOT_DO_FOR_SUPER_GROUP); + } else { + $group = UserGroup::getGroupById($group_id); + $result = UserGroup::delGroup($group_id); + if ($result > 0) { + SysLog::addLog(UserSession::getUserName(), 'DELETE', 'UserGroup', $group_id, json_encode($group)); + Common::exitWithSuccess('宸插皢璐﹀彿缁勫垹闄', 'panel/groups.php'); + } else { + OSAdmin::alert("error"); + } + } + } } $groups = UserGroup::getAllGroup(); $confirm_html = OSAdmin::renderJsConfirm("icon-remove"); -Template::assign ( 'osadmin_action_confirm' , $confirm_html); -Template::assign ( 'groups', $groups ); -Template::display ( 'panel/groups.tpl' ); +Template::assign('osadmin_action_confirm', $confirm_html); +Template::assign('groups', $groups); +Template::display('panel/groups.tpl'); diff --git a/uploads/panel/index.php b/uploads/panel/index.php index 0ebc40e..985334b 100644 --- a/uploads/panel/index.php +++ b/uploads/panel/index.php @@ -1,4 +1,4 @@ - $ip))); - Common::jumpUrl ( 'panel/index.php' ); - }else{ - OSAdmin::alert("error",ErrorMessage::BE_PAUSED); - } - } else { - OSAdmin::alert("error",ErrorMessage::USER_OR_PWD_WRONG); - SysLog::addLog ( $user_name, 'LOGIN','User' ,'' , json_encode(ErrorMessage::USER_OR_PWD_WRONG) ); - } - } +if (Common::isPost()) { + if (strtolower($verify_code) != strtolower($_SESSION['osa_verify_code'])) { + OSAdmin::alert("error", ErrorMessage::VERIFY_CODE_WRONG); + } else { + $user_info = User::checkPassword($user_name, $password); + + if ($user_info) { + if ($user_info['status'] == 1) { + + User::loginDoSomething($user_info['user_id']); + + if ($remember) { + $encrypted = OSAEncrypt::encrypt($user_info['user_id']); + User::setCookieRemember(urlencode($encrypted), 30); + } + $ip = Common::getIp(); + SysLog::addLog($user_name, 'LOGIN', 'User', UserSession::getUserId(), json_encode(array("IP" => $ip))); + Common::jumpUrl('panel/index.php'); + } else { + OSAdmin::alert("error", ErrorMessage::BE_PAUSED); + } + } else { + OSAdmin::alert("error", ErrorMessage::USER_OR_PWD_WRONG); + SysLog::addLog($user_name, 'LOGIN', 'User', '', json_encode(ErrorMessage::USER_OR_PWD_WRONG)); + } + } } -Template::assign ( '_POST',$_POST ); -Template::assign ( 'page_title','鐧诲叆' ); -Template::Display ( 'login.tpl' ); \ No newline at end of file +Template::assign('_POST', $_POST); +Template::assign('page_title', '鐧诲叆'); +Template::Display('login.tpl'); diff --git a/uploads/panel/logout.php b/uploads/panel/logout.php index 2fcccc1..ec1e890 100644 --- a/uploads/panel/logout.php +++ b/uploads/panel/logout.php @@ -1,7 +1,7 @@ $menu_name, 'menu_url' => $menu_url, 'module_id' => $module_id, - 'is_show' => $is_show, 'online' =>1 , 'menu_desc' => $menu_desc ,'shortcut_allowed'=>$shortcut_allowed,'father_menu'=>$father_menu ); - $menu_id = MenuUrl::addMenu ( $input_data ); - - if ($menu_id) { - SysLog::addLog ( UserSession::getUserName(), 'ADD', 'MenuUrl' ,$menu_id ,json_encode($input_data)); - Common::exitWithSuccess ('宸插皢閾炬帴娣诲姞','panel/menus.php'); - }else{ - OSAdmin::alert("error"); - } - } - } +if (Common::isPost()) { + if ($menu_name == "" || $menu_url == "" || $module_id == "") { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $menu = MenuUrl::getMenuByUrl($menu_url); + if (!empty($menu)) { + OSAdmin::alert("error", ErrorMessage::MENU_URL_CONFLICT); + } else { + $input_data = array( + 'menu_name' => $menu_name, + 'menu_url' => $menu_url, + 'module_id' => $module_id, + 'is_show' => $is_show, + 'online' => 1, + 'menu_desc' => $menu_desc, + 'shortcut_allowed' => $shortcut_allowed, + 'father_menu' => $father_menu + ); + $menu_id = MenuUrl::addMenu($input_data); + + if ($menu_id) { + SysLog::addLog(UserSession::getUserName(), 'ADD', 'MenuUrl', $menu_id, json_encode($input_data)); + Common::exitWithSuccess('宸插皢閾炬帴娣诲姞', 'panel/menus.php'); + } else { + OSAdmin::alert("error"); + } + } + } } -$module_options_list = Module::getModuleForOptions (); -$father_menu_options_list = MenuUrl::getFatherMenuForOptions (); -Template::assign ( '_POST', $_POST ); -Template::assign ( 'module_options_list', $module_options_list ); -Template::assign ( 'father_menu_options_list', $father_menu_options_list ); -Template::display ( 'panel/menu_add.tpl' ); \ No newline at end of file +$module_options_list = Module::getModuleForOptions(); +$father_menu_options_list = MenuUrl::getFatherMenuForOptions(); +Template::assign('_POST', $_POST); +Template::assign('module_options_list', $module_options_list); +Template::assign('father_menu_options_list', $father_menu_options_list); +Template::display('panel/menu_add.tpl'); diff --git a/uploads/panel/menu_modify.php b/uploads/panel/menu_modify.php index dc9d252..f401fb3 100644 --- a/uploads/panel/menu_modify.php +++ b/uploads/panel/menu_modify.php @@ -1,60 +1,66 @@ 100 && empty($module_id)) ){ - - OSAdmin::alert("error",ErrorMessage::NEED_PARAM); - - }else{ - $exist = false; - $menu_exist = MenuUrl::getMenuByUrl($menu_url); - if(!empty($menu_exist)){ - if($menu_id!=$menu_exist['menu_id']){ - $exist=true; - OSAdmin::alert("error",ErrorMessage::MENU_URL_CONFLICT); - } - } - if(!$exist){ - $update_data = array ('menu_name' => $menu_name, 'menu_url' => $menu_url, - 'is_show' => $is_show, "online" => $online,'menu_desc' => $menu_desc, 'shortcut_allowed' => $shortcut_allowed, - 'father_menu' => $father_menu); - if($menu_id > 100){ - $update_data['module_id'] = $module_id; - } - - $result = MenuUrl::updateMenuInfo ( $menu_id,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'MenuUrl' ,$menu_id, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/menus.php'); - } else { - OSAdmin::alert("error"); - } - } - } +if (Common::isPost()) { + + if ($menu_name == "" || $menu_url == "" || ($menu_id > 100 && empty($module_id))) { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + + } else { + $exist = false; + $menu_exist = MenuUrl::getMenuByUrl($menu_url); + if (!empty($menu_exist)) { + if ($menu_id != $menu_exist['menu_id']) { + $exist = true; + OSAdmin::alert("error", ErrorMessage::MENU_URL_CONFLICT); + } + } + if (!$exist) { + $update_data = array( + 'menu_name' => $menu_name, + 'menu_url' => $menu_url, + 'is_show' => $is_show, + "online" => $online, + 'menu_desc' => $menu_desc, + 'shortcut_allowed' => $shortcut_allowed, + 'father_menu' => $father_menu + ); + if ($menu_id > 100) { + $update_data['module_id'] = $module_id; + } + + $result = MenuUrl::updateMenuInfo($menu_id, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'MenuUrl', $menu_id, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/menus.php'); + } else { + OSAdmin::alert("error"); + } + } + } } -$module_options_list = Module::getModuleForOptions (); -$father_menu_options_list = MenuUrl::getFatherMenuForOptions (); - -$show_options_list=array("1"=>"鏄剧ず","0"=>"涓嶆樉绀"); -$online_options_list=array("1"=>"鍦ㄧ嚎","0"=>"涓嬬嚎"); -$shortcut_allowed_options_list = array("1"=>"鍏佽","0"=>"涓嶅厑璁"); -Template::assign ( 'menu', $menu ); -Template::assign ( 'module_options_list', $module_options_list ); -Template::assign ( 'father_menu_options_list', $father_menu_options_list ); -Template::assign ( 'show_options_list', $show_options_list ); -Template::assign ( 'online_options_list', $online_options_list ); -Template::assign ( 'shortcut_allowed_options_list', $shortcut_allowed_options_list ); -Template::display ( 'panel/menu_modify.tpl' ); \ No newline at end of file +$module_options_list = Module::getModuleForOptions(); +$father_menu_options_list = MenuUrl::getFatherMenuForOptions(); + +$show_options_list = array("1" => "鏄剧ず", "0" => "涓嶆樉绀"); +$online_options_list = array("1" => "鍦ㄧ嚎", "0" => "涓嬬嚎"); +$shortcut_allowed_options_list = array("1" => "鍏佽", "0" => "涓嶅厑璁"); +Template::assign('menu', $menu); +Template::assign('module_options_list', $module_options_list); +Template::assign('father_menu_options_list', $father_menu_options_list); +Template::assign('show_options_list', $show_options_list); +Template::assign('online_options_list', $online_options_list); +Template::assign('shortcut_allowed_options_list', $shortcut_allowed_options_list); +Template::display('panel/menu_modify.tpl'); diff --git a/uploads/panel/menus.php b/uploads/panel/menus.php index 3192546..c527d12 100644 --- a/uploads/panel/menus.php +++ b/uploads/panel/menus.php @@ -1,59 +1,60 @@ ($total_page)?($total_page):$page_no; - $start = ($page_no - 1) * $page_size; - $menus = MenuUrl::search($module_id,$menu_name,$start , $page_size); - -}else{ - $row_count = MenuUrl::count (); - $total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size); - $total_page=$total_page<1?1:$total_page; - $page_no=$page_no>($total_page)?($total_page):$page_no; - $start = ($page_no - 1) * $page_size; - $menus = MenuUrl::getAllMenus ( $start , $page_size ); +$page_no = $page_no < 1 ? 1 : $page_no; + +if ($search) { + + $row_count = MenuUrl::countSearch($module_id, $menu_name); + $total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); + $total_page = $total_page < 1 ? 1 : $total_page; + $page_no = $page_no > ($total_page) ? ($total_page) : $page_no; + $start = ($page_no - 1) * $page_size; + $menus = MenuUrl::search($module_id, $menu_name, $start, $page_size); + +} else { + $row_count = MenuUrl::count(); + $total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); + $total_page = $total_page < 1 ? 1 : $total_page; + $page_no = $page_no > ($total_page) ? ($total_page) : $page_no; + $start = ($page_no - 1) * $page_size; + $menus = MenuUrl::getAllMenus($start, $page_size); } -$page_html=Pagination::showPager("menus.php?module_id=$module_id&menu_name=$menu_name&search=$search",$page_no,$page_size,$row_count); +$page_html = Pagination::showPager("menus.php?module_id=$module_id&menu_name=$menu_name&search=$search", $page_no, + $page_size, $row_count); -$module_options_list = Module::getModuleForOptions (); -$module_options_list[0]="鍏ㄩ儴"; +$module_options_list = Module::getModuleForOptions(); +$module_options_list[0] = "鍏ㄩ儴"; ksort($module_options_list); $confirm_html = OSAdmin::renderJsConfirm("icon-remove"); -Template::assign ( 'page_no', $page_no ); -Template::assign ( 'menus', $menus ); -Template::assign ( '_GET', $_GET); -Template::assign ( 'page_html', $page_html ); -Template::assign ( 'module_options_list', $module_options_list ); -Template::assign ( 'osadmin_action_confirm' , $confirm_html); -Template::display ( 'panel/menus.tpl' ); \ No newline at end of file +Template::assign('page_no', $page_no); +Template::assign('menus', $menus); +Template::assign('_GET', $_GET); +Template::assign('page_html', $page_html); +Template::assign('module_options_list', $module_options_list); +Template::assign('osadmin_action_confirm', $confirm_html); +Template::display('panel/menus.tpl'); diff --git a/uploads/panel/module.php b/uploads/panel/module.php index 3f115f8..64bfa41 100644 --- a/uploads/panel/module.php +++ b/uploads/panel/module.php @@ -1,44 +1,44 @@ $module); - $result = MenuUrl::batchUpdateMenus ( $menu_ids,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'MenuUrl' ,$menu_ids, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/modules.php'); - } else { - OSAdmin::alert("error"); - } - } +if (Common::isPost()) { + + if (empty($module) || empty($menu_ids)) { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + if ($module != 1) { + foreach ($menu_ids as $menu_id) { + if ($menu_id <= 100) { + Common::exitWithError('绯荤粺鑿滃崟涓嶈兘杞Щ鍒板叾瀹冩ā鍧', 'panel/modules.php'); + } + } + } + $menu_ids = implode(',', $menu_ids); + $update_data = array('module_id' => $module); + $result = MenuUrl::batchUpdateMenus($menu_ids, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'MenuUrl', $menu_ids, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/modules.php'); + } else { + OSAdmin::alert("error"); + } + } } -$menus = MenuUrl::getListByModuleId($module_id ); -$module_options_list = Module::getModuleForOptions (); +$menus = MenuUrl::getListByModuleId($module_id); +$module_options_list = Module::getModuleForOptions(); -Template::assign ( 'module_options_list', $module_options_list ); -Template::assign ( 'menus', $menus ); -Template::assign ( 'module_id', $module_id ); -Template::display ( 'panel/module.tpl' ); \ No newline at end of file +Template::assign('module_options_list', $module_options_list); +Template::assign('menus', $menus); +Template::assign('module_id', $module_id); +Template::display('panel/module.tpl'); diff --git a/uploads/panel/module_add.php b/uploads/panel/module_add.php index 7e57aa0..9ff4718 100644 --- a/uploads/panel/module_add.php +++ b/uploads/panel/module_add.php @@ -1,24 +1,32 @@ $module_name, 'module_desc' => $module_desc, 'module_url' => $module_url ,'module_sort' =>$module_sort,'module_icon' =>$module_icon); - $module_id = Module::addModule ( $input_data ); - - if ($module_id) { - SysLog::addLog ( UserSession::getUserName(), 'ADD', 'Module' , $module_id, json_encode($input_data) ); - Common::exitWithSuccess ('妯″潡娣诲姞鎴愬姛','panel/modules.php'); - } - } +if (Common::isPost()) { + $exist = Module::getModuleByName($module_name); + if ($exist) { + OSAdmin::alert("error", ErrorMessage::NAME_CONFLICT); + } else { + if ($module_name == "" || $module_url == "") { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $input_data = array( + 'module_name' => $module_name, + 'module_desc' => $module_desc, + 'module_url' => $module_url, + 'module_sort' => $module_sort, + 'module_icon' => $module_icon + ); + $module_id = Module::addModule($input_data); + + if ($module_id) { + SysLog::addLog(UserSession::getUserName(), 'ADD', 'Module', $module_id, json_encode($input_data)); + Common::exitWithSuccess('妯″潡娣诲姞鎴愬姛', 'panel/modules.php'); + } + } + } } -Template::assign("_POST" ,$_POST); -Template::display('panel/module_add.tpl' ); +Template::assign("_POST", $_POST); +Template::display('panel/module_add.tpl'); diff --git a/uploads/panel/module_modify.php b/uploads/panel/module_modify.php index 0ad921e..81b3fd0 100644 --- a/uploads/panel/module_modify.php +++ b/uploads/panel/module_modify.php @@ -1,38 +1,43 @@ $module_name, 'module_desc' => $module_desc, 'module_icon' => $module_icon ,'module_url' => $module_url , - 'module_sort' =>$module_sort); - if($module_id >1){ - $update_data['online'] =$online; - } - $result = Module::updateModuleInfo ( $module_id,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'Module' ,$module_id, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/modules.php'); - } else { - OSAdmin::alert("error"); - } - } +if (Common::isPost()) { + + if ($module_name == "" || $module_url == "") { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $update_data = array( + 'module_name' => $module_name, + 'module_desc' => $module_desc, + 'module_icon' => $module_icon, + 'module_url' => $module_url, + 'module_sort' => $module_sort + ); + if ($module_id > 1) { + $update_data['online'] = $online; + } + $result = Module::updateModuleInfo($module_id, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'Module', $module_id, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/modules.php'); + } else { + OSAdmin::alert("error"); + } + } } -$module_online_optioins = array("1"=>"鍦ㄧ嚎","0"=>"涓嬬嚎"); -Template::assign ( 'module', $module ); -Template::assign ( 'module_online_optioins', $module_online_optioins ); -Template::display ( 'panel/module_modify.tpl' ); \ No newline at end of file +$module_online_optioins = array("1" => "鍦ㄧ嚎", "0" => "涓嬬嚎"); +Template::assign('module', $module); +Template::assign('module_online_optioins', $module_online_optioins); +Template::display('panel/module_modify.tpl'); diff --git a/uploads/panel/modules.php b/uploads/panel/modules.php index 5cff27f..70aa4f6 100644 --- a/uploads/panel/modules.php +++ b/uploads/panel/modules.php @@ -1,28 +1,30 @@ 0){ - OSAdmin::alert("error",ErrorMessage::HAVE_FUNC); - }else if(intval($module_id) === 1){ - OSAdmin::alert("error",ErrorMessage::CAN_NOT_DELETE_SYSTEM_MODULE); - }else{ - $module=Module::getModuleById($module_id); - $result = Module::delModule ( $module_id ); - - if ($result) { - SysLog::addLog ( UserSession::getUserName(), 'DELETE', 'Module' ,$module_id, json_encode($module) ); - Common::exitWithSuccess ('妯″潡鍒犻櫎鎴愬姛','panel/modules.php'); - } - } +if ($method == 'del' && !empty ($module_id)) { + $menus = Module::getModuleMenu($module_id); + if (sizeof($menus) > 0) { + OSAdmin::alert("error", ErrorMessage::HAVE_FUNC); + } else { + if (intval($module_id) === 1) { + OSAdmin::alert("error", ErrorMessage::CAN_NOT_DELETE_SYSTEM_MODULE); + } else { + $module = Module::getModuleById($module_id); + $result = Module::delModule($module_id); + + if ($result) { + SysLog::addLog(UserSession::getUserName(), 'DELETE', 'Module', $module_id, json_encode($module)); + Common::exitWithSuccess('妯″潡鍒犻櫎鎴愬姛', 'panel/modules.php'); + } + } + } } $modules = Module::getAllModules(); $confirm_html = OSAdmin::renderJsConfirm("icon-remove"); -Template::assign ( 'modules', $modules ); -Template::assign ( 'osadmin_action_confirm' , $confirm_html); -Template::display ( 'panel/modules.tpl' ); \ No newline at end of file +Template::assign('modules', $modules); +Template::assign('osadmin_action_confirm', $confirm_html); +Template::display('panel/modules.tpl'); diff --git a/uploads/panel/pdo.php b/uploads/panel/pdo.php index c1d8850..cda4538 100644 --- a/uploads/panel/pdo.php +++ b/uploads/panel/pdo.php @@ -1,14 +1,11 @@ exec('SET NAMES \'UTF8\''); - $result = $pdo->query("select now()"); - $row = $result->fetch(); - var_dump($row); + $pdo = new PDO('mysql:host=' . OSA_DB_URL . ';dbname=' . OSA_DB_NAME, OSA_USER_NAME, OSA_PASSWORD); + $pdo->exec('SET NAMES \'UTF8\''); + $result = $pdo->query("select now()"); + $row = $result->fetch(); + var_dump($row); +} catch (PDOException $e) { + echo $e->getMessage(); } -catch (PDOException $e) { - echo $e->getMessage(); -} - -?> diff --git a/uploads/panel/profile.php b/uploads/panel/profile.php index 435b134..8cb8f95 100644 --- a/uploads/panel/profile.php +++ b/uploads/panel/profile.php @@ -1,46 +1,46 @@ -"鏄剧ず","0"=>"涓嶆樉绀"); +$quicknoteOptions = array("1" => "鏄剧ず", "0" => "涓嶆樉绀"); //鏇存柊Session閲岀殑鐢ㄦ埛淇℃伅 -Template::assign("change_password",$change_password); -Template::assign("user_info",UserSession::getSessionInfo()); -Template::assign("quicknoteOptions",$quicknoteOptions); -Template::display ( 'panel/profile.tpl' ); +Template::assign("change_password", $change_password); +Template::assign("user_info", UserSession::getSessionInfo()); +Template::assign("quicknoteOptions", $quicknoteOptions); +Template::display('panel/profile.tpl'); diff --git a/uploads/panel/quicknote_add.php b/uploads/panel/quicknote_add.php index 0f8e88a..eba5992 100644 --- a/uploads/panel/quicknote_add.php +++ b/uploads/panel/quicknote_add.php @@ -1,24 +1,24 @@ $note_content, 'owner_id' => UserSession::getUserId() ); - $note_id = QuickNote::addNote ( $input_data ); - - if ($note_id) { - SysLog::addLog ( UserSession::getUserName(), 'ADD', 'QuickNote' ,$note_id, json_encode($input_data) ); - Common::exitWithSuccess ('渚跨娣诲姞鎴愬姛','panel/quicknote_add.php'); - } - } +if (Common::isPost()) { + + if ($note_content == "") { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $note_content = htmlspecialchars($note_content); + $input_data = array('note_content' => $note_content, 'owner_id' => UserSession::getUserId()); + $note_id = QuickNote::addNote($input_data); + + if ($note_id) { + SysLog::addLog(UserSession::getUserName(), 'ADD', 'QuickNote', $note_id, json_encode($input_data)); + Common::exitWithSuccess('渚跨娣诲姞鎴愬姛', 'panel/quicknote_add.php'); + } + } } -Template::assign("_POST" ,$_POST); -Template::display('panel/quicknote_add.tpl' ); +Template::assign("_POST", $_POST); +Template::display('panel/quicknote_add.tpl'); diff --git a/uploads/panel/quicknote_modify.php b/uploads/panel/quicknote_modify.php index ba2576f..1e2a5a5 100644 --- a/uploads/panel/quicknote_modify.php +++ b/uploads/panel/quicknote_modify.php @@ -1,38 +1,38 @@ $note_content); - $result = QuickNote::updateNote( $note_id,$update_data ); - - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'QuickNote' ,$note_id, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/quicknotes.php'); - } else { - OSAdmin::alert("error"); - } - }else{ - OSAdmin::alert("error",ErrorMessage::QUICKNOTE_NOT_OWNER); - } - } +if (Common::isPost()) { + $note_content = Common::filterText($note_content); + if ($note_content == "") { + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $current_user_info = UserSession::getSessionInfo(); + $user_group = $current_user_info['user_group']; + $current_user_id = $current_user_info['user_id']; + if ($user_group == 1 || $quicknote['owner_id'] == $current_user_id) { + $note_content = htmlspecialchars($note_content); + $update_data = array('note_content' => $note_content); + $result = QuickNote::updateNote($note_id, $update_data); + + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'QuickNote', $note_id, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/quicknotes.php'); + } else { + OSAdmin::alert("error"); + } + } else { + OSAdmin::alert("error", ErrorMessage::QUICKNOTE_NOT_OWNER); + } + } } -Template::assign ( 'quicknote', $quicknote ); -Template::display ( 'panel/quicknote_modify.tpl' ); \ No newline at end of file +Template::assign('quicknote', $quicknote); +Template::display('panel/quicknote_modify.tpl'); diff --git a/uploads/panel/quicknotes.php b/uploads/panel/quicknotes.php index 2d55a04..37a224f 100644 --- a/uploads/panel/quicknotes.php +++ b/uploads/panel/quicknotes.php @@ -1,51 +1,51 @@ ($total_page)?($total_page):$page_no; +$page_no = $page_no < 1 ? 1 : $page_no; +$total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); +$total_page = $total_page < 1 ? 1 : $total_page; +$page_no = $page_no > ($total_page) ? ($total_page) : $page_no; $start = ($page_no - 1) * $page_size; -$current_user_info=UserSession::getSessionInfo(); +$current_user_info = UserSession::getSessionInfo(); $user_group = $current_user_info['user_group']; $current_user_id = $current_user_info['user_id']; -if ($method == 'del' && ! empty ( $note_id )) { - - $note = QuickNote::getNoteById($note_id); - - //鏄秴绾х鐞嗗憳缁勭殑鎴愬憳鎴栬呮槸quicknote鐨勪富浜 - if($user_group ==1 || $note['owner_id'] == $current_user_id){ - $result = QuickNote::delNote ( $note_id ); - if ($result>0) { - SysLog::addLog ( UserSession::getUserName(), 'DELETE', 'QuickNote',$note_id, json_encode($note) ); - Common::exitWithSuccess ('渚跨鍒犻櫎鎴愬姛','panel/quicknotes.php'); - }else{ - OSAdmin::alert("error"); - } - }else{ - OSAdmin::alert("error",ErrorMessage::QUICKNOTE_NOT_OWNER); - } +if ($method == 'del' && !empty ($note_id)) { + + $note = QuickNote::getNoteById($note_id); + + //鏄秴绾х鐞嗗憳缁勭殑鎴愬憳鎴栬呮槸quicknote鐨勪富浜 + if ($user_group == 1 || $note['owner_id'] == $current_user_id) { + $result = QuickNote::delNote($note_id); + if ($result > 0) { + SysLog::addLog(UserSession::getUserName(), 'DELETE', 'QuickNote', $note_id, json_encode($note)); + Common::exitWithSuccess('渚跨鍒犻櫎鎴愬姛', 'panel/quicknotes.php'); + } else { + OSAdmin::alert("error"); + } + } else { + OSAdmin::alert("error", ErrorMessage::QUICKNOTE_NOT_OWNER); + } } -$quicknotes = QuickNote::getNotes($start,$page_size); +$quicknotes = QuickNote::getNotes($start, $page_size); $confirm_html = OSAdmin::renderJsConfirm("icon-remove"); -$page_html=Pagination::showPager("",$page_no,PAGE_SIZE,$row_count); - -Template::assign ( 'page_no', $page_no ); -Template::assign ( 'page_size', PAGE_SIZE ); -Template::assign ( 'row_count', $row_count ); -Template::assign ( 'page_html', $page_html ); -Template::assign ( 'quicknotes', $quicknotes ); -Template::assign ( 'osadmin_action_confirm' , $confirm_html); -Template::assign ( 'user_group', $user_group ); -Template::assign ( 'current_user_id', $current_user_id ); -Template::display ( 'panel/quicknotes.tpl' ); +$page_html = Pagination::showPager("", $page_no, PAGE_SIZE, $row_count); + +Template::assign('page_no', $page_no); +Template::assign('page_size', PAGE_SIZE); +Template::assign('row_count', $row_count); +Template::assign('page_html', $page_html); +Template::assign('quicknotes', $quicknotes); +Template::assign('osadmin_action_confirm', $confirm_html); +Template::assign('user_group', $user_group); +Template::assign('current_user_id', $current_user_id); +Template::display('panel/quicknotes.tpl'); diff --git a/uploads/panel/set.php b/uploads/panel/set.php index de31db3..c8c99e8 100644 --- a/uploads/panel/set.php +++ b/uploads/panel/set.php @@ -1,15 +1,15 @@ "绾界害", - "Europe/London"=>"浼︽暒,鍗¤惃甯冩媺鍗", - "Asia/Shanghai"=>"鍖椾含,鏂板姞鍧,棣欐腐", - "Asia/Tokyo"=>"涓滀含,棣栧皵", - ); - -//鏇存柊Session閲岀殑鐢ㄦ埛淇℃伅 +} -Template::assign("user_info",UserSession::getSessionInfo()); -Template::assign("timezone",$timezone); -Template::assign("timezone_options",$timezone_options); -Template::display ( 'panel/setting.tpl' ); -?> +$timezone_options = array( + "America/New_York" => "绾界害", + "Europe/London" => "浼︽暒,鍗¤惃甯冩媺鍗", + "Asia/Shanghai" => "鍖椾含,鏂板姞鍧,棣欐腐", + "Asia/Tokyo" => "涓滀含,棣栧皵", +); +//鏇存柊Session閲岀殑鐢ㄦ埛淇℃伅 +Template::assign("user_info", UserSession::getSessionInfo()); +Template::assign("timezone", $timezone); +Template::assign("timezone_options", $timezone_options); +Template::display('panel/setting.tpl'); diff --git a/uploads/panel/syslog.php b/uploads/panel/syslog.php index 79c7778..e8860ad 100644 --- a/uploads/panel/syslog.php +++ b/uploads/panel/syslog.php @@ -1,77 +1,77 @@ ($total_page)?($total_page):$page_no; +$total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); +$total_page = $total_page < 1 ? 1 : $total_page; +$page_no = $page_no > ($total_page) ? ($total_page) : $page_no; $start = ($page_no - 1) * $page_size; //END -$sys_logs = SysLog::getLogs($class_name,$user_name, $start,$page_size,$start_time,$end_time ); +$sys_logs = SysLog::getLogs($class_name, $user_name, $start, $page_size, $start_time, $end_time); $loadedClz = array(); $namePool = array(); -foreach ($sys_logs as &$log){ - - if(array_key_exists($log['action'],$OSADMIN_COMMAND_FOR_LOG)){ - $log['action']=$OSADMIN_COMMAND_FOR_LOG[$log['action']]; - } - - $class_obj = $log['class_obj']; - if(array_key_exists($log['class_name'],$OSADMIN_CLASS_FOR_LOG)){ - $log['class_name'] = $OSADMIN_CLASS_FOR_LOG[$log['class_name']]; - } +foreach ($sys_logs as &$log) { - - if($log['class_obj']==""){ - $log['class_obj']='null'; - } + if (array_key_exists($log['action'], $OSADMIN_COMMAND_FOR_LOG)) { + $log['action'] = $OSADMIN_COMMAND_FOR_LOG[$log['action']]; + } - if(empty($log['result'])){ - $log['result'] = '鎴愬姛'; - }else{ - $result =json_decode($log['result'],true); - if(is_array($result)){ - $temp = null; - foreach($result as $key => $value){ - $temp[] = "$key=>$value"; - } - $log['result']=implode(';',$temp); - }else{ - $log['result']=$result; - } - } + $class_obj = $log['class_obj']; + if (array_key_exists($log['class_name'], $OSADMIN_CLASS_FOR_LOG)) { + $log['class_name'] = $OSADMIN_CLASS_FOR_LOG[$log['class_name']]; + } + + + if ($log['class_obj'] == "") { + $log['class_obj'] = 'null'; + } + + if (empty($log['result'])) { + $log['result'] = '鎴愬姛'; + } else { + $result = json_decode($log['result'], true); + if (is_array($result)) { + $temp = null; + foreach ($result as $key => $value) { + $temp[] = "$key=>$value"; + } + $log['result'] = implode(';', $temp); + } else { + $log['result'] = $result; + } + } } // 鏄剧ず鍒嗛〉鏍 -$page_html=Pagination::showPager("syslog.php?class_name=$class_name&user_name=$user_name&start_date=$start_date&end_date=$end_date",$page_no,PAGE_SIZE,$row_count); +$page_html = Pagination::showPager("syslog.php?class_name=$class_name&user_name=$user_name&start_date=$start_date&end_date=$end_date", + $page_no, PAGE_SIZE, $row_count); -Template::assign ( 'page_no', $page_no ); -Template::assign ( 'page_size', PAGE_SIZE ); -Template::assign ( 'row_count', $row_count ); -Template::assign ( 'page_html', $page_html ); -Template::assign ( '_GET', $_GET ); -Template::assign ( 'class_options', $OSADMIN_CLASS_FOR_LOG ); -Template::assign ( 'sys_logs', $sys_logs ); -Template::display ( 'panel/syslog.tpl' ); - \ No newline at end of file +Template::assign('page_no', $page_no); +Template::assign('page_size', PAGE_SIZE); +Template::assign('row_count', $row_count); +Template::assign('page_html', $page_html); +Template::assign('_GET', $_GET); +Template::assign('class_options', $OSADMIN_CLASS_FOR_LOG); +Template::assign('sys_logs', $sys_logs); +Template::display('panel/syslog.tpl'); diff --git a/uploads/panel/system.php b/uploads/panel/system.php index efde2b4..ec03b3b 100644 --- a/uploads/panel/system.php +++ b/uploads/panel/system.php @@ -1,6 +1,6 @@ $user_name, 'password' => md5 ( $password ), 'real_name' => $real_name, 'mobile' => $mobile, 'email' => $email, 'user_desc' => $user_desc, 'user_group' => $user_group ); - $user_id = User::addUser ( $input_data ); - - if ($user_id) { - $input_data['password']=""; - SysLog::addLog ( UserSession::getUserName(), 'ADD', 'User' ,$user_id, json_encode($input_data) ); - Common::exitWithSuccess ('璐﹀彿娣诲姞鎴愬姛','panel/users.php'); - }else{ - OSAdmin::alert("error"); - } - } +if (Common::isPost()) { + $exist = User::getUserByName($user_name); + if ($exist) { + + OSAdmin::alert("error", ErrorMessage::NAME_CONFLICT); + } else { + if ($password == "" || $real_name == "" || $mobile == "" || $email == "" || $user_group <= 0) { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + $input_data = array( + 'user_name' => $user_name, + 'password' => md5($password), + 'real_name' => $real_name, + 'mobile' => $mobile, + 'email' => $email, + 'user_desc' => $user_desc, + 'user_group' => $user_group + ); + $user_id = User::addUser($input_data); + + if ($user_id) { + $input_data['password'] = ""; + SysLog::addLog(UserSession::getUserName(), 'ADD', 'User', $user_id, json_encode($input_data)); + Common::exitWithSuccess('璐﹀彿娣诲姞鎴愬姛', 'panel/users.php'); + } else { + OSAdmin::alert("error"); + } + } + } } $group_options = UserGroup::getGroupForOptions(); -Template::assign("_POST" ,$_POST); -Template::assign ( 'group_options', $group_options ); -Template::display ( 'panel/user_add.tpl' ); +Template::assign("_POST", $_POST); +Template::assign('group_options', $group_options); +Template::display('panel/user_add.tpl'); diff --git a/uploads/panel/user_modify.php b/uploads/panel/user_modify.php index 268b9b5..a2e0922 100644 --- a/uploads/panel/user_modify.php +++ b/uploads/panel/user_modify.php @@ -1,47 +1,51 @@ $real_name, 'mobile' => $mobile, - 'email' => $email, 'user_desc' => $user_desc ); - if($user_id > 1 ){ - $update_data["user_group"]=$user_group; - } - - if (! empty ( $password )) { - $update_data = array_merge ( $update_data, array ('password' => md5 ( $password ) ) ); - } - - $result = User::updateUser ( $user_id,$update_data ); - - if ($result>=0) { - $current_user=UserSession::getSessionInfo(); - $ip = Common::getIp(); - $update_data['ip']=$ip; - SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'User' , $user_id, json_encode($update_data) ); - Common::exitWithSuccess ('鏇存柊瀹屾垚','panel/users.php'); - } else { - - OSAdmin::alert("error"); - } - } +if (Common::isPost()) { + + if ($real_name == "" || $mobile == "" || $email == "" || ($user_id != 1 && $user_group <= 0)) { + + OSAdmin::alert("error", ErrorMessage::NEED_PARAM); + } else { + + $update_data = array( + 'real_name' => $real_name, + 'mobile' => $mobile, + 'email' => $email, + 'user_desc' => $user_desc + ); + if ($user_id > 1) { + $update_data["user_group"] = $user_group; + } + + if (!empty ($password)) { + $update_data = array_merge($update_data, array('password' => md5($password))); + } + + $result = User::updateUser($user_id, $update_data); + + if ($result >= 0) { + $current_user = UserSession::getSessionInfo(); + $ip = Common::getIp(); + $update_data['ip'] = $ip; + SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'User', $user_id, json_encode($update_data)); + Common::exitWithSuccess('鏇存柊瀹屾垚', 'panel/users.php'); + } else { + + OSAdmin::alert("error"); + } + } } -$group_options=UserGroup::getGroupForOptions(); +$group_options = UserGroup::getGroupForOptions(); -Template::assign ( 'user', $user ); -Template::assign ( 'group_options', $group_options ); -Template::display ( 'panel/user_modify.tpl' ); \ No newline at end of file +Template::assign('user', $user); +Template::assign('group_options', $group_options); +Template::display('panel/user_modify.tpl'); diff --git a/uploads/panel/users.php b/uploads/panel/users.php index 4849304..4245de2 100644 --- a/uploads/panel/users.php +++ b/uploads/panel/users.php @@ -1,91 +1,92 @@ 0); - - if($user_id == UserSession::getUserId()){ - OSAdmin::alert("error",ErrorMessage::CAN_NOT_DO_SELF); - }else{ - if($user_id==1){ - Common::exitWithSuccess ( '涓嶈兘灏佸仠鍒濆绠$悊鍛','panel/users.php' ); - } - $result = User::updateUser ( $user_id,$user_data ); - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'PAUSE', 'User' ,$user_id ,json_encode($user_data) ); - Common::exitWithSuccess ( '宸插皝鍋','panel/users.php' ); - }else{ - OSAdmin::alert("error"); - } - } +extract($_REQUEST, EXTR_IF_EXISTS); +if ($method == 'pause' && !empty ($user_id)) { + $user_data = array("status" => 0); + + if ($user_id == UserSession::getUserId()) { + OSAdmin::alert("error", ErrorMessage::CAN_NOT_DO_SELF); + } else { + if ($user_id == 1) { + Common::exitWithSuccess('涓嶈兘灏佸仠鍒濆绠$悊鍛', 'panel/users.php'); + } + $result = User::updateUser($user_id, $user_data); + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'PAUSE', 'User', $user_id, json_encode($user_data)); + Common::exitWithSuccess('宸插皝鍋', 'panel/users.php'); + } else { + OSAdmin::alert("error"); + } + } } -if ($method == 'play' && ! empty ( $user_id )) { - $user_data=array("status"=>1); - $result = User::updateUser ( $user_id,$user_data ); - if ($result>=0) { - SysLog::addLog ( UserSession::getUserName(), 'PLAY' , 'User' ,$user_id ,json_encode($user_data) ); - Common::exitWithSuccess ( '宸茶В灏','panel/users.php' ); - }else{ - OSAdmin::alert("error"); - } +if ($method == 'play' && !empty ($user_id)) { + $user_data = array("status" => 1); + $result = User::updateUser($user_id, $user_data); + if ($result >= 0) { + SysLog::addLog(UserSession::getUserName(), 'PLAY', 'User', $user_id, json_encode($user_data)); + Common::exitWithSuccess('宸茶В灏', 'panel/users.php'); + } else { + OSAdmin::alert("error"); + } } -if ($method == 'del' && ! empty ( $user_id )) { - if($user_id == UserSession::getUserId()){ - OSAdmin::alert("error",ErrorMessage::CAN_NOT_DO_SELF); - }else{ - if($user_id==1){ - Common::exitWithSuccess ( '涓嶈兘鍒犻櫎鍒濆绠$悊鍛','panel/users.php' ); - } - $user = User::getUserById($user_id); - $result = User::delUser ( $user_id ); - if ($result>=0) { - $user['password']=null; - SysLog::addLog ( UserSession::getUserName(), 'DELETE', 'User' ,$user_id ,json_encode($user) ); - Common::exitWithSuccess ( '宸插垹闄','panel/users.php' ); - }else{ - OSAdmin::alert("error"); - } - } +if ($method == 'del' && !empty ($user_id)) { + if ($user_id == UserSession::getUserId()) { + OSAdmin::alert("error", ErrorMessage::CAN_NOT_DO_SELF); + } else { + if ($user_id == 1) { + Common::exitWithSuccess('涓嶈兘鍒犻櫎鍒濆绠$悊鍛', 'panel/users.php'); + } + $user = User::getUserById($user_id); + $result = User::delUser($user_id); + if ($result >= 0) { + $user['password'] = null; + SysLog::addLog(UserSession::getUserName(), 'DELETE', 'User', $user_id, json_encode($user)); + Common::exitWithSuccess('宸插垹闄', 'panel/users.php'); + } else { + OSAdmin::alert("error"); + } + } } //START 鏁版嵁搴撴煡璇㈠強鍒嗛〉鏁版嵁 $page_size = PAGE_SIZE; -$page_no=$page_no<1?1:$page_no; +$page_no = $page_no < 1 ? 1 : $page_no; + +if ($search) { + $row_count = User::countSearch($user_group, $user_name); + $total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); + $total_page = $total_page < 1 ? 1 : $total_page; + $page_no = $page_no > ($total_page) ? ($total_page) : $page_no; + $start = ($page_no - 1) * $page_size; + $user_infos = User::search($user_group, $user_name, $start, $page_size); -if($search){ - $row_count = User::countSearch($user_group,$user_name); - $total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size); - $total_page=$total_page<1?1:$total_page; - $page_no=$page_no>($total_page)?($total_page):$page_no; - $start = ($page_no - 1) * $page_size; - $user_infos = User::search($user_group,$user_name,$start , $page_size); - -}else{ - $row_count = User::count (); - $total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size); - $total_page=$total_page<1?1:$total_page; - $page_no=$page_no>($total_page)?($total_page):$page_no; - $start = ($page_no - 1) * $page_size; - $user_infos = User::getAllUsers ( $start , $page_size ); +} else { + $row_count = User::count(); + $total_page = $row_count % $page_size == 0 ? $row_count / $page_size : ceil($row_count / $page_size); + $total_page = $total_page < 1 ? 1 : $total_page; + $page_no = $page_no > ($total_page) ? ($total_page) : $page_no; + $start = ($page_no - 1) * $page_size; + $user_infos = User::getAllUsers($start, $page_size); } -$page_html=Pagination::showPager("users.php?user_group=$user_group&user_name=$user_name&search=$search",$page_no,$page_size,$row_count); +$page_html = Pagination::showPager("users.php?user_group=$user_group&user_name=$user_name&search=$search", $page_no, + $page_size, $row_count); //杩藉姞鎿嶄綔鐨勭‘璁ゅ眰 $confirm_html = OSAdmin::renderJsConfirm("icon-pause,icon-play,icon-remove"); // 璁剧疆妯℃澘鍙橀噺 -$group_options=UserGroup::getGroupForOptions(); +$group_options = UserGroup::getGroupForOptions(); $group_options[0] = "鍏ㄩ儴"; ksort($group_options); -Template::assign ( 'group_options', $group_options ); -Template::assign ( 'user_infos', $user_infos ); -Template::assign ( '_GET', $_GET ); -Template::assign ( 'page_no', $page_no ); -Template::assign ( 'page_html', $page_html ); -Template::assign ( 'osadmin_action_confirm' , $confirm_html); -Template::display ( 'panel/users.tpl' ); +Template::assign('group_options', $group_options); +Template::assign('user_infos', $user_infos); +Template::assign('_GET', $_GET); +Template::assign('page_no', $page_no); +Template::assign('page_html', $page_html); +Template::assign('osadmin_action_confirm', $confirm_html); +Template::display('panel/users.tpl'); diff --git a/uploads/panel/verify_code_cn.php b/uploads/panel/verify_code_cn.php index 234969d..ddf7170 100644 --- a/uploads/panel/verify_code_cn.php +++ b/uploads/panel/verify_code_cn.php @@ -1,44 +1,102 @@ - \ No newline at end of file diff --git a/uploads/sample/read_excel.php b/uploads/sample/read_excel.php index a3bda19..3966cd1 100644 --- a/uploads/sample/read_excel.php +++ b/uploads/sample/read_excel.php @@ -1,18 +1,18 @@ "Male",1=>"Female"); +$radio_types = array(0 => "Male", 1 => "Female"); Template::assign('samples', $samples); Template::assign('radio_types', $radio_types); From bcf3c7c8b4e3b023185971daf78ff0a3a2454654 Mon Sep 17 00:00:00 2001 From: McDanci Date: Tue, 24 Jan 2017 20:34:16 +0800 Subject: [PATCH 5/5] Add ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e56a363..b53171d 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,5 @@ pip-log.txt # Mr Developer .mr.developer.cfg + +.idea