public function waterfall() { $sid = intval($_GET['sub_mid']); $pageId = max(intval($_GET['page']), 1); $limit = 10; $start = ($pageId - 1) * $limit; $stop = $start + $limit; $submoduleDB = new SubmoduleModelDB(); $submodule = $submoduleDB->getRow('SELECT mid, code FROM `' . $submoduleDB->getTableName() . '` WHERE id=?', array(intval($sid))); $details = MyRedis::getSubmoduleDetail($submodule, $start, $stop); Common::debug($details); foreach ($details['messages'] as $key => $value) { if ($tmp = unserialize($value)) { $value = array_map('urldecode', array_map('htmlspecialchars', $tmp)); // $detail = date('[Y-m-d H:i:s] ', $time)."{$submodule['name']} 错误号:{$submodule['code']} 详细:{$message}, 邮件:第{$mailMsgCount}次,短信:第{$smsMsgCount}次,来自{$client_ip}/{$onlineip},xhprofId[{$xhprofId}]"; $details['messages'][$key] = date('[Y-m-d H:i:s] ', $value['time']) . "{$value['name']} 错误号:{$value['code']},脚本:{$value['script']},详细:{$value['message']},来自{$value['clientIp']}/{$value['serverIp']}"; } else { $details['messages'][$key] = htmlspecialchars($value); } } Message::showSucc('详细信息', $details['messages']); }
/** * 获取外键数据来源 * @param string $key 指定key获取 * @return array|string 获取到的数据或指定key的值 */ public function getSubmodule($key = '') { $submoduleDB = new SubmoduleModelDB(); $data = array(); if (is_array($key)) { if (!empty($key)) { $sql = "SELECT `id`,`name` FROM `" . $submoduleDB->getTableName() . "` WHERE `id` IN ?"; $submoduleModelDBArr = $submoduleDB->getData($sql, array($key)); $data = Common::createArr($submoduleModelDBArr, 'id', 'name'); } } else { if ($key === '') { $sql = "SELECT `id`,`name` FROM `" . $submoduleDB->getTableName() . "`"; $submoduleModelDBArr = $submoduleDB->getData($sql); $data = Common::createArr($submoduleModelDBArr, 'id', 'name'); } else { $sql = "SELECT `name` FROM `" . $submoduleDB->getTableName() . "` WHERE `id` = ?"; $data = $submoduleDB->getFirst($sql, array($key)); } } return $data; }
public function getDetail() { $pageId = max(intval($_GET['page']), 1); $limit = 50; $start = ($pageId - 1) * $limit; $stop = $start + $limit; $submoduleDB = new SubmoduleModelDB(); $submodule = $submoduleDB->getRow('SELECT mid, code FROM `' . $submoduleDB->getTableName() . '` WHERE id=?', array(intval($_GET['sub_mid']))); $detail = MyRedis::getSubmoduleDetail($submodule, $start, $stop); $data = array(); foreach ($detail['messages'] as $i => $v) { if (($msg = @unserialize($v)) && is_array($msg)) { $data[$i] = $msg; } else { $msg = explode(" ", $v); $data[$i]['time'] = str_replace(array('[', ']'), '', array_shift($msg) . ' ' . array_shift($msg)); $data[$i]['name'] = array_shift($msg); $data[$i]['code'] = str_replace(array("错误号:", '{', '}'), '', array_shift($msg)); $otherMsg = array_pop($msg); $otherMsgArr = explode(",", $otherMsg); if (count($otherMsgArr) == 4) { $data[$i]['xhprofId'] = str_replace(array('xhprofId[', ']'), '', array_pop($otherMsgArr)); } list($data[$i]['clientIp'], $data[$i]['serverIp']) = explode("/", str_replace(array("来自"), '', array_pop($otherMsgArr))); $data[$i]['email'] = str_replace(array("短信:", '第', '次'), '', array_pop($otherMsgArr)); $data[$i]['sms'] = str_replace(array("邮件:", '第', '次'), '', array_pop($otherMsgArr)); $data[$i]['message'] = str_replace(array("详细:"), '', implode(" ", $msg)); } } Common::debug($detail, 'Result'); $pageModel = new Page($detail['count'], $limit); $this->setView('pageStr', $pageModel->getPageStr()); $this->setView('data', $data); $this->setView('sub_mid', intval($_GET['sub_mid'])); $this->display('Detail.html'); }