1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- include_once dirname(__FILE__) . '/../main.php';
- $params = query_paras();
- //$params = $_POST['date'];
- $date = $params['date']['ts'];
- $uid = $params['date']['uid'];
- $zoneid = $params['date']['zoneid'];
- $sqlName = "tab_op_log".$date;
- $arr = daoInst()->select("*")->from($sqlName)
- ->where('cmd')->eq(6901)
- ->andWhere('zoneid')->eq($zoneid)
- ->andWhere('uid')->eq($uid)
- ->fetchAll();
- $lastItem = null;
- $dic = new stdClass();
- $list = array();
- $index = 1;
- foreach ($arr as $item) {
- if($lastItem != null){
- $list[] = $lastItem;
-
- if(strtotime($item->ts) - strtotime($lastItem->ts) > 20*60){
- $timeDic = new stdClass();
- $timeDic->startTs = strtotime($list[0]->ts);
- $timeDic->endTs = strtotime($list[count($list)-1]->ts);
- $timeDic->durationTs = strtotime($list[count($list)-1]->ts) - strtotime($list[0]->ts);
-
- $dic->$index = $timeDic;
- $index += 1;
-
- $list = array();
- }
- }
- $lastItem = $item;
- }
- $result = new stdClass();
- $result->data = $dic;
- echo json_encode($result);
|