PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/public/module/copyscene/copy_scene_check.php

https://github.com/karlom/gameadmin
PHP | 289 lines | 254 code | 20 blank | 15 comment | 39 complexity | c0b2640eb140014a7daae1a1d8100b48 MD5 | raw file
  1. <?php
  2. include_once '../../../protected/config/config.php';
  3. include_once SYSDIR_ADMIN_INCLUDE . '/global.php';
  4. include_once SYSDIR_ADMIN_DICT.'/dict.php';
  5. include_once SYSDIR_ADMIN_DICT.'/arrItemsAll.php';
  6. global $lang;
  7. $nowTime = time();
  8. $action = isset($_POST['action']) ? SS($_POST['action']) : '';
  9. $role = $_REQUEST['role'];
  10. $role['roleName'] = $roleName = $role['roleName'] ? autoAddPrefix( SS($role['roleName']) ): '';
  11. $role['accountName'] = $accountName = $role['accountName'] ? autoAddPrefix( SS($role['accountName'])) : '';
  12. $page = getUrlParam('page'); //设置初始页
  13. $pageLine = $_POST['pageLine'] ? SS($_POST['pageLine']) : LIST_PER_PAGE_RECORDS;
  14. $type = $_POST['type'] ? SS($_POST['type']) : '200';
  15. //$type2= isset($_POST['type2']) ? SS(trim($_POST['type2'])) : "B.`level` desc";
  16. $type2= isset($_POST['type2']) ? SS(trim($_POST['type2'])) : '';
  17. $strictMatch = SS($_POST['strict']);
  18. $excelParam = $_POST['excel'];
  19. $excelParam = SS($excelParam);
  20. if($excelParam == 's'){
  21. $excelParam ='';
  22. }
  23. //获取时间段
  24. if (!isset ($_POST['starttime'])) {
  25. $startDate = Datatime :: getPreDay(date("Y-m-d"), 1);
  26. } else {
  27. $startDate = trim($_POST['starttime']);
  28. }
  29. if (!isset ($_POST['endtime'])) {
  30. $endDate = Datatime :: getTodayString();
  31. } else {
  32. $endDate = trim($_POST['endtime']);
  33. }
  34. $startDateStamp = strtotime($startDate . ' 0:0:0');
  35. $endDateStamp = strtotime($endDate . ' 23:59:59');
  36. $openTimestamp = strtotime( ONLINEDATE );
  37. if($startDateStamp < $openTimestamp)
  38. {
  39. $startDateStamp = $openTimestamp;
  40. $startDate = ONLINEDATE;
  41. }
  42. if($action == 'start'){
  43. if(isPost()) {
  44. $accountName2 = SS($_POST['an']);
  45. $sTime2 = strtotime(SS($_POST['st']));
  46. $eTime2 = strtotime(SS($_POST['et']));
  47. $mapId2 = SS($_POST['mi']);
  48. if(isset($accountName2)) {
  49. $sql = " select `id`,`mdate`,`mtime`,`item_id`,`isbind`,`num`,`color`,`type`,`detail` from ".T_LOG_ITEM." where `account_name`='$accountName2' and `map_id`=$mapId2 and `mtime`>=$sTime2 and `mtime`<=$eTime2 ";
  50. $rs = GFetchRowSet($sql,'id');
  51. if(empty($rs)){
  52. $stat = 0;
  53. $msg = $lang->copyscene->itemNotExists;
  54. $result = json_encode(array('stat'=>$stat,'msg'=>$msg,));
  55. echo $result;
  56. exit();
  57. } else {
  58. foreach($rs as $r=>&$s){
  59. $s['id'] = $s['id'];
  60. $s['item_id'] = $s['item_id'];
  61. $s['mdate'] = $s['mdate'];
  62. $s['item_name'] = $arrItemsAll[$s['item_id']]['name'];
  63. if($s['isbind'] = 0){
  64. $s['isbind'] = $lang->copyscene->unfinish;
  65. } else {
  66. $s['isbind'] = $lang->copyscene->finish;
  67. }
  68. $s['num'] = $s['num'];
  69. $s['color'] = $dictColor[$s['color']];
  70. $s['type'] = $dictItemUsageType[$s['type']];
  71. $s['detail'] = $s['detail'];
  72. }
  73. $stat = $rs;
  74. $msg = 0;
  75. $result = json_encode(array('stat'=>$stat,'msg'=>$msg,));
  76. echo $result;
  77. exit();
  78. }
  79. }
  80. }
  81. }
  82. $where = 1;
  83. $where .= " and `mtime`>=$startDateStamp and `mtime`<=$endDateStamp ";
  84. if($type != '200') {
  85. $where .= " and `map_id`=$type ";
  86. }
  87. $where .= $accountName ? " and `account_name` = '{$accountName}' ":'';
  88. $where .= $roleName ? " and `role_name` = '{$roleName}' ":'';
  89. $arrType2 = array(
  90. "B.`map_id`" => " {$lang->copyscene->into}"."(".$lang->copyscene->level.")↑ ",
  91. "B.`map_id` desc" => " {$lang->copyscene->into}"."(".$lang->copyscene->level.")↓ ",
  92. "B.`level`" => " {$lang->sys->playerLevel}↑ ",
  93. "B.`level` desc" => " {$lang->sys->playerLevel}↓ ",
  94. "B.`is_captain`" => " {$lang->copyscene->isCaptain}↑ ",
  95. "B.`is_captain` desc" => " {$lang->copyscene->isCaptain}↓ ",
  96. "B.`is_team`" => " {$lang->copyscene->isTeam}↑ ",
  97. "B.`is_team` desc" => " {$lang->copyscene->isTeam}↓ ",
  98. "B.`men_count`" => " {$lang->copyscene->menCount}↑ ",
  99. "B.`men_count` desc" => " {$lang->copyscene->menCount}↓ ",
  100. "B.`time_used`" => " {$lang->copyscene->usedTime}↑ ",
  101. 'B.`time_used` desc' => " {$lang->copyscene->usedTime}↓ ",
  102. "B.`enter_times`" => " {$lang->copyscene->enterTims}↑ ",
  103. 'B.`enter_times` desc' => " {$lang->copyscene->enterTims}↓ ",
  104. "B.`status`" => " {$lang->copyscene->isFinished}↑ ",
  105. 'B.`status` desc' => " {$lang->copyscene->isFinished}↓ ",
  106. );
  107. if($type2) {
  108. // $order .= " ORDER BY B.`map_id`, B.`enter_times`, {$type2} ";
  109. $order .= " ORDER BY {$type2} ";
  110. } else {
  111. // $order .= " ORDER BY `map_id`,`enter_times` ";
  112. $order .= " ORDER BY B.`map_id`, B.`enter_times` ";
  113. }
  114. //页数
  115. $recordCount = 0; //总记录
  116. $startNum = ($page - 1) * $pageLine; //每页开始位置
  117. $viewData = getCopySceneRecord(1,$where,$order,$startNum,$pageLine,&$recordCount);
  118. $pageCount = ceil($recordCount/$pageLine ); //总页数
  119. $pageList = getPages($page, $recordCount, $pageLine);
  120. foreach ($viewData as $key => &$value) {
  121. $value['time_used'] = ConvertSecondToChinese($value['time_used']);
  122. }
  123. $dateStrPrev = strftime("%Y-%m-%d", strtotime($startDate) - 86400);
  124. $dateStrToday = strftime("%Y-%m-%d");
  125. $dateStrNext = strftime("%Y-%m-%d", strtotime($startDate) + 86400);
  126. $dateOnline = ONLINEDATE;
  127. $arrType = $goldType;
  128. $arrType[-1] = $lang->page->showType1;
  129. ksort($arrType);
  130. if($recordCount>=5000) {
  131. $startNum2=array();
  132. $pageLine2 = 5000;
  133. $page2 = ceil($recordCount/$pageLine2);
  134. for($i=1;$i<=$page2;$i++){
  135. $startNum2['s']= $lang->msg->mustSelectOut;
  136. $startNum2[($i-1)*$pageLine2] = ($i-1)*$pageLine2. $lang->page->to .($i)*$pageLine2. $lang->page->row . $lang->page->excel ;
  137. }
  138. }
  139. //输出Excel文件
  140. if($recordCount>0 && $excelParam == true || is_numeric($excelParam)){
  141. if($recordCount<5000) {
  142. $viewData2 = getCopySceneRecord(0,$where,$order);
  143. } else {
  144. $viewData2 = getCopySceneRecord(1,$where,$order,$excelParam,$pageLine2);
  145. }
  146. $excel = getExcel();
  147. $smarty->assign('title', $excel['title']); // 标题
  148. $smarty->assign('hd', $excel['hd']); // 表头
  149. $smarty->assign('num',$excel['hdnum']); // 列数
  150. $smarty->assign('ct', $excel['content']); // 内容
  151. // 输出文件头,表明是要输出 excel 文件
  152. header('Content-type: application/vnd.ms-excel');
  153. header('Content-Disposition: attachment; filename='.$excel['title'].date('_Ymd_Gi_Gs').'.xls');
  154. $smarty->display('module/pay/pay_excel.tpl');
  155. exit;
  156. }
  157. $minDate = ONLINEDATE;
  158. $maxDate = Datatime :: getTodayString();
  159. $smarty->assign("minDate", $minDate);
  160. $smarty->assign("maxDate", $maxDate);
  161. $smarty->assign("dateStrPrev", $dateStrPrev);
  162. $smarty->assign("dateStrToday", $dateStrToday);
  163. $smarty->assign("dateStrNext", $dateStrNext);
  164. $smarty->assign("dateOnline", $dateOnline);
  165. $smarty->assign("startDate", $startDate);
  166. $smarty->assign("endDate", $endDate);
  167. $smarty->assign('lang', $lang);
  168. $smarty->assign('viewData', $viewData);
  169. $smarty->assign('page', $page);
  170. $smarty->assign('type', $type);
  171. $smarty->assign('type2', $type2);
  172. $smarty->assign('type3', $type3);
  173. $smarty->assign('excelParam', $excelParam);
  174. $smarty->assign('arrType', $arrType);
  175. $smarty->assign('arrType2', $arrType2);
  176. $smarty->assign('dictMapType', $dictMapType);
  177. $smarty->assign('pageList', $pageList);
  178. $smarty->assign('pageLine', $pageLine);
  179. $smarty->assign('startNum2', $startNum2);
  180. $smarty->assign('pageCount', $pageCount);
  181. $smarty->assign('role', $role);
  182. $smarty->assign('strictMatch', $strictMatch);
  183. $smarty->assign('recordCount', $recordCount);
  184. $smarty->display("module/copyscene/copy_scene_check.tpl");
  185. exit;
  186. /**
  187. * @param $tmp 是否使用LIMIT
  188. */
  189. function getCopySceneRecord($tmp,$where='',$order='',$startNum='',$record='',&$counts=''){
  190. // $sql = " select `mdate`,`mtime` as `etime`,`role_name`,`account_name`,`level`,`map_id`,`is_captain`,`is_team`,`men_count`,`time_used`,`enter_times`,`status` from `".T_LOG_COPY_SCENE."` where {$where} ";
  191. $sql = " select B.`mdate`, A.`stime`, B.`etime`, B.`role_name`, B.`account_name`, B.`level`, B.`map_id`, B.`is_captain`, B.`is_team`, B.`men_count`, B.`time_used`, B.`enter_times`, B.`status` from (select `mtime` as `stime`,`role_name`,`account_name`,`level`,`map_id`,`time_used`,`enter_times`,`status`,`day` from `".T_LOG_COPY_SCENE."` where {$where} and `status`=0) A, (select `mdate`,`mtime` as `etime`,`role_name`,`account_name`,`level`,`map_id`,`is_captain`,`is_team`,`men_count`,`time_used`,`enter_times`,`status`,`day` from `".T_LOG_COPY_SCENE."` where {$where} and `status`>0) B where A.`day`= B.`day` and A.`map_id`=B.`map_id` and A.`account_name`= B.`account_name` and A.`enter_times`= B.`enter_times` and A.`stime`< B.`etime` ";
  192. if(!empty($order)) {
  193. $sql .= " {$order} ";
  194. }
  195. if($tmp==1) {
  196. $sql.= " LIMIT {$startNum}, {$record} ";
  197. }
  198. $result = GFetchRowSet($sql);
  199. $countSql = " select count(B.`role_name`) count from (select `mtime` as `stime`,`role_name`,`account_name`,`level`,`map_id`,`time_used`,`enter_times`,`status`, `day` from `".T_LOG_COPY_SCENE."` where {$where} and `status`=0) A, (select `mdate`,`mtime` as `etime`,`role_name`,`account_name`,`level`,`map_id`,`is_captain`,`is_team`,`men_count`,`time_used`,`enter_times`,`status`,`day` from `".T_LOG_COPY_SCENE."` where {$where} and `status`>0) B where A.`day`= B.`day` and A.`map_id`=B.`map_id` and A.`account_name`= B.`account_name` and A.`enter_times`= B.`enter_times` and A.`stime`< B.`etime` ";
  200. $countsRs = GFetchRowOne($countSql);
  201. $counts = $countsRs['count'];
  202. return $result;
  203. }
  204. function getExcel(){
  205. //记录数据
  206. global $viewData2,$lang,$arrType,$dictMapType;
  207. $excel = array();
  208. // 标题
  209. $excel['title'] = $lang->menu->copySceneData;
  210. // 表头
  211. $excel['hd'] = array(
  212. $lang->sys->account,
  213. $lang->page->roleName,
  214. $lang->sys->playerLevel,
  215. $lang->copyscene->inTime,
  216. $lang->copyscene->outTime,
  217. $lang->copyscene->mapId,
  218. $lang->copyscene->into,
  219. $lang->copyscene->level,
  220. $lang->copyscene->enterTimes,
  221. $lang->copyscene->isFinished,
  222. $lang->copyscene->usedTime,
  223. $lang->copyscene->isCaptain,
  224. $lang->copyscene->isTeam,
  225. $lang->copyscene->menCount,
  226. );
  227. // 列数
  228. $excel['hdnum'] = count($excel['hd']);
  229. $excel['content'] = array();
  230. foreach($viewData2 as $k=>$v){
  231. $excel['content'][$k] = array();
  232. $excel['content'][$k][] = array('StyleID'=>'s28', 'Type'=>'String', 'content'=>$v['role_name']);
  233. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['account_name']);
  234. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['level']);
  235. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['stime']);
  236. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['etime']);
  237. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['map_id']);
  238. if($dictMapType[$v['map_id']]['isCopyScene'] == true) {
  239. $copyName = $dictMapType[$v['map_id']]['name'];
  240. $copyLevel = $dictMapType[$v['map_id']]['level'];
  241. }
  242. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$copyName);
  243. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$copyLevel);
  244. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['enter_times']);
  245. if($v['status']==0) {
  246. $v['status'] = $lang->copyscene->goInto;
  247. } elseif ($v['status']==1) {
  248. $v['status'] = $lang->copyscene->finish;
  249. } else {
  250. $v['status'] = $lang->copyscene->unfinish;
  251. }
  252. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['status']);
  253. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['time_used'].$lang->copyscene->seconds);
  254. if($v['is_captain'] == 1) {
  255. $v['is_captain'] = $lang->player->yes;
  256. } else {
  257. $v['is_captain'] = $lang->player->no;
  258. }
  259. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['is_captain']);
  260. if($v['is_captain'] == 1) {
  261. $v['is_team'] = $lang->player->yes;
  262. } else {
  263. $v['is_team'] = $lang->player->no;
  264. }
  265. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['is_team']);
  266. $excel['content'][$k][] = array('StyleID'=>'s29', 'Type'=>'String', 'content'=>$v['men_count']);
  267. }
  268. return $excel;
  269. }