IndexAction.class.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class IndexAction extends AuthAction{
  10. //首页
  11. public function index(){
  12. //管理员的SESSION
  13. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  14. $adm_name = $adm_session['adm_name'];
  15. $adm_id = intval($adm_session['adm_id']);
  16. if(intval(app_conf('EXPIRED_TIME'))>0&&$adm_id!=0){
  17. $admin_logined_time = intval($adm_session['admin_logined_time']);
  18. $max_time = intval(conf('EXPIRED_TIME'))*60;
  19. if(NOW_TIME-$admin_logined_time>=$max_time)
  20. {
  21. es_session::delete((md5(conf("AUTH_KEY"))));
  22. $this->display();
  23. }
  24. }
  25. if($adm_id == 0)
  26. {
  27. //已登录
  28. $this->redirect(u("Public/login"));
  29. }else{
  30. $this->display();
  31. }
  32. }
  33. //框架头
  34. public function top()
  35. {
  36. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  37. $role_id = intval($adm_session['role_id']);
  38. $navs= get_admin_nav($role_id,$adm_session['adm_name']);
  39. $this->assign("navs",$navs);
  40. $this->assign("admin",$adm_session);
  41. $this->display();
  42. }
  43. //框架左侧
  44. public function left()
  45. {
  46. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  47. $adm_id = intval($adm_session['adm_id']);
  48. $role_id = intval($adm_session['role_id']);
  49. $navs= get_admin_nav($role_id,$adm_session['adm_name']);
  50. $nav_key = strim($_REQUEST['key']);
  51. $nav_group = $navs[$nav_key]['groups'];
  52. $this->assign("menus",$nav_group);
  53. $this->display();
  54. }
  55. //默认框架主区域
  56. public function main()
  57. {
  58. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  59. $this->assign("adm_session",$adm_session);
  60. $adm_id = intval($adm_session['adm_id']);
  61. $login_time = $GLOBALS['db']->getOne("SELECT login_time FROM ".DB_PREFIX."admin where id = $adm_id ");
  62. $h=to_date($login_time,"H");
  63. $login_time = to_date($login_time);
  64. $this->assign("login_time",$login_time);
  65. if($h<12){
  66. $greet ="上午好";
  67. }elseif($h<18){
  68. $greet ="下午好";
  69. }else{
  70. $greet ="晚上好";
  71. }
  72. $this->assign("greet",$greet);
  73. //$navs = require_once APP_ROOT_PATH."system/admnav_cfg.php";
  74. $role_id = intval($adm_session['role_id']);
  75. $navs= get_admin_nav($role_id,$adm_session['adm_name']);
  76. $this->assign("navs",$navs);
  77. if($navs['index']['groups']['index']['nodes'][0]['action'] == main){
  78. //待审核
  79. $register_count = M("User")->where("is_effect=0 and user_type=0 ")->count();
  80. $company_register_count = M("User")->where("is_effect=0 and user_type=1")->count();
  81. $this->assign("register_count",$register_count);
  82. $this->assign("company_register_count",$company_register_count);
  83. //认证
  84. $user_authentication=M("User")->where("is_authentication = 1 and is_effect=1 and is_robot = 0 ")->count();
  85. //$business_authentication=M("User")->where("is_authentication = 1 and is_effect=1 and user_type=1 ")->count();
  86. //$all_authentication=M("User")->where(" (user_type=0 or user_type=1) and is_authentication =1 and is_effect=1 and is_robot = 0")->count();
  87. //认证未通过
  88. $authentication_not_allow=M("User")->where("is_authentication = 3 and is_effect=1 and is_robot = 0 ")->count();
  89. $this->assign("user_authentica",$user_authentication);
  90. //$this->assign("business_authentica",$business_authentication);
  91. //$this->assign("all_authentica",$all_authentication);
  92. $this->assign("authentication_not_allow",$authentication_not_allow);
  93. //充值
  94. $pay_count = floatval($GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."payment_notice where payment_id <>0"));
  95. $this->assign("pay_count",$pay_count);
  96. //普通用户
  97. $user_level=M("User")->where("is_authentication<>2 and is_effect=1 and is_robot = 0")->count();
  98. $this->assign("user_level",$user_level);
  99. //认证用户
  100. $authentication=M("User")->where("is_authentication=2 and is_effect=1 and is_robot = 0")->count();
  101. $this->assign("authentication",$authentication);
  102. //机器人
  103. $robot=M("User")->where("is_effect=1 and is_robot = 1")->count();
  104. $this->assign("robot",$robot);
  105. //会员总数
  106. $user_count=M("User")->where("is_effect=1")->count();
  107. $this->assign("user_count",$user_count);
  108. $is_live=M("Video")->where("live_in=1 or live_in = 3")->count(); //直播中
  109. $this->assign("is_live",$is_live);
  110. $is_playback=M("VideoHistory")->where("is_delete=0 and is_del_vod = 0 and room_type<>1")->count(); //保存的视频
  111. $this->assign("is_playback",intval($is_playback));
  112. //直播中视频观看人数
  113. $watch_number = intval($GLOBALS['db']->getOne("SELECT sum(watch_number) FROM ".DB_PREFIX."video where live_in=1"));
  114. $this->assign("watch_number",$watch_number);
  115. //统计在线人数
  116. $m_config = load_auto_cache("m_config");
  117. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  118. $api = createTimAPI();
  119. $show_online_user = 0;
  120. if($m_config['tim_identifier']&&!is_array($api)){
  121. $ret = $api->group_get_group_member_info($m_config['on_line_group_id'],0,0);
  122. $online_user = isset($ret['MemberNum'])?intval($ret['MemberNum']):0;//减去管理员本身
  123. $show_online_user = 1;
  124. $this->assign("online_user",$online_user);
  125. }
  126. $this->assign("show_online_user",$show_online_user);
  127. }
  128. $this->display();
  129. }
  130. //底部
  131. public function footer()
  132. {
  133. $this->display();
  134. }
  135. //修改管理员密码
  136. public function change_password()
  137. {
  138. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  139. $this->assign("adm_data",$adm_session);
  140. $this->display();
  141. }
  142. public function do_change_password()
  143. {
  144. $adm_id = intval($_REQUEST['adm_id']);
  145. if(!check_empty($_REQUEST['adm_password']))
  146. {
  147. $this->error(L("ADM_PASSWORD_EMPTY_TIP"));
  148. }
  149. if(!check_empty($_REQUEST['adm_new_password']))
  150. {
  151. $this->error(L("ADM_NEW_PASSWORD_EMPTY_TIP"));
  152. }
  153. if($_REQUEST['adm_confirm_password']!=$_REQUEST['adm_new_password'])
  154. {
  155. $this->error(L("ADM_NEW_PASSWORD_NOT_MATCH_TIP"));
  156. }
  157. if(M("Admin")->where("id=".$adm_id)->getField("adm_password")!=md5($_REQUEST['adm_password']))
  158. {
  159. $this->error(L("ADM_PASSWORD_ERROR"));
  160. }
  161. M("Admin")->where("id=".$adm_id)->setField("adm_password",md5($_REQUEST['adm_new_password']));
  162. save_log(M("Admin")->where("id=".$adm_id)->getField("adm_name").L("CHANGE_SUCCESS"),1);
  163. $this->success(L("CHANGE_SUCCESS"));
  164. }
  165. public function reset_sending()
  166. {
  167. $field = trim($_REQUEST['field']);
  168. if($field=='DEAL_MSG_LOCK'||$field=='PROMOTE_MSG_LOCK'||$field=='APNS_MSG_LOCK')
  169. {
  170. M("Conf")->where("name='".$field."'")->setField("value",'0');
  171. $this->success(L("RESET_SUCCESS"),1);
  172. }
  173. else
  174. {
  175. $this->error(L("INVALID_OPERATION"),1);
  176. }
  177. }
  178. /*
  179. * 网站数据统计
  180. */
  181. public function statistics(){
  182. //$user_count=M("User")->where("is_robot=0")->count();
  183. $user_count=M("User")->count();
  184. $no_effect=M("User")->where(" is_effect=0 or is_effect=2")->count(); //无效
  185. $is_effect=M("User")->where(" is_effect=1")->count(); //有效
  186. //认证
  187. $user_authentication=M("User")->where("is_authentication = 2 and user_type=0 and is_effect=1 and is_robot = 0")->count();
  188. $business_authentication=M("User")->where("is_authentication = 2 and user_type=1 and is_effect=1 and is_robot = 0")->count();
  189. $all_authentication=M("User")->where(" (user_type=0 or user_type=1) and is_authentication =2 and is_effect=1 and is_robot = 0")->count();
  190. if(defined('QK_TREE')&& QK_TREE == 1){
  191. //树苗订单
  192. $tree_order_count= M("QkTreeOrder")->count();
  193. $total_tree_order_money = M("QkTreeOrder")->sum('pay');
  194. $m_config = load_auto_cache('m_config');
  195. $diamonds_name = $m_config['diamonds_name'];
  196. $this->assign("diamonds_name",$diamonds_name);
  197. $this->assign("tree_order_count",$tree_order_count);
  198. $this->assign("total_tree_order_money",$total_tree_order_money);
  199. $this->assign("open_qk_tree",1);
  200. }
  201. //资金进出
  202. //线上充值
  203. $online_pay = floatval($GLOBALS['db']->getOne("SELECT sum(money) FROM ".DB_PREFIX."payment_notice where is_paid = 1 and payment_id>0 "));
  204. $this->assign("online_pay",$online_pay);
  205. //总计
  206. $total_usre_money = $online_pay;
  207. $this->assign("total_usre_money",$total_usre_money);
  208. $this->assign("user_count",$user_count);
  209. $this->assign("no_effect",$no_effect);
  210. $this->assign("is_effect",$is_effect);
  211. $this->assign("user_authentication",$user_authentication);
  212. $this->assign("business_authentication",$business_authentication);
  213. $this->assign("all_authentication",$all_authentication);
  214. $this->display();
  215. }
  216. public function main_weibo()
  217. {
  218. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  219. $this->assign("adm_session",$adm_session);
  220. $adm_id = intval($adm_session['adm_id']);
  221. $login_time = $GLOBALS['db']->getOne("SELECT login_time FROM ".DB_PREFIX."admin where id = $adm_id ");
  222. $h=to_date($login_time,"H");
  223. $login_time = to_date($login_time);
  224. $this->assign("login_time",$login_time);
  225. if($h<12){
  226. $greet ="上午好";
  227. }elseif($h<18){
  228. $greet ="下午好";
  229. }else{
  230. $greet ="晚上好";
  231. }
  232. $this->assign("greet",$greet);
  233. $navs = require_once APP_ROOT_PATH."system/admnav_cfg.php";
  234. $this->assign("navs",$navs);
  235. //待审核
  236. $register_count = M("User")->where("is_effect=0 and user_type=0 ")->count();
  237. $company_register_count = M("User")->where("is_effect=0 and user_type=1")->count();
  238. $this->assign("register_count",$register_count);
  239. $this->assign("company_register_count",$company_register_count);
  240. //认证
  241. $user_authentication=M("User")->where("is_authentication = 1 and is_effect=1 and user_type=0 and is_robot = 0 ")->count();
  242. $business_authentication=M("User")->where("is_authentication = 1 and is_effect=1 and user_type=1 ")->count();
  243. $all_authentication=M("User")->where(" (user_type=0 or user_type=1) and is_authentication =1 and is_effect=1 and is_robot = 0")->count();
  244. //认证未通过
  245. $authentication_not_allow=M("User")->where("is_authentication = 3 and is_effect=1 and user_type=0 and is_robot = 0 ")->count();
  246. $this->assign("user_authentica",$user_authentication);
  247. $this->assign("business_authentica",$business_authentication);
  248. $this->assign("all_authentica",$all_authentication);
  249. $this->assign("authentication_not_allow",$authentication_not_allow);
  250. //充值
  251. $pay_count = floatval($GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."payment_notice where payment_id <>0"));
  252. $this->assign("pay_count",$pay_count);
  253. //普通用户
  254. $user_level=M("User")->where("is_authentication<>2 and is_effect=1 and is_robot = 0")->count();
  255. $this->assign("user_level",$user_level);
  256. //认证用户
  257. $authentication=M("User")->where("is_authentication=2 and is_effect=1 and is_robot = 0")->count();
  258. $this->assign("authentication",$authentication);
  259. //会员总数
  260. $user_count=M("User")->where("is_effect=1")->count();
  261. $this->assign("user_count",$user_count);
  262. $this->display();
  263. }
  264. }
  265. ?>