//ajax请求 if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest") { if ($ajaxMethod == 'showChart') { $detail = MailStatistics::getRefuseForHoursData($start_date, $end_date); $list = array(); foreach ($detail as $item) { $list['DAYS'][] = $item['MAIL_TIME'] . str_pad($item['HOURS'], 2, '0', STR_PAD_LEFT); $list['NUMS'][] = $item['NUM']; } $res = array(); $res['list'] = $list; $res = json_encode($res); exit($res); } if ($ajaxMethod == 'showImg') { $data = MailStatistics::getRefuseForHours($start_date, $end_date, $width, $height); $jpg = $data[0]['IMAGE']; if (!empty($jpg)) { $filename = 'refuseForHours.png'; $file = file_put_contents(ADMIN_BASE_RIMAGE . $filename, $jpg); //打开文件准备写入 $imgurl = ADMIN_URL_RIMAGE . $filename . '?' . microtime(true); $img = "<center><img src=\"{$imgurl}\"></center>"; } else { $img = "图片加载失败"; } $res = array(); $res['img'] = $img; $res = json_encode($res); exit($res); }