[18179] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[18179] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[19661] | 25 | require_once(CLASS_PATH . "pages/admin/LC_Page_Admin.php"); |
---|
[18179] | 26 | |
---|
| 27 | /** |
---|
| 28 | * ログ のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author Seasoft 塚田将久 |
---|
| 32 | * @version $Id: LC_Page_Admin_System_System.php 17576 2008-08-28 06:08:09Z Seasoft $ |
---|
| 33 | */ |
---|
[19661] | 34 | class LC_Page_Admin_System_Log extends LC_Page_Admin { |
---|
[18179] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_mainpage = 'system/log.tpl'; |
---|
| 47 | $this->tpl_subnavi = 'system/subnavi.tpl'; |
---|
| 48 | $this->tpl_subno = 'log'; |
---|
| 49 | $this->tpl_mainno = 'system'; |
---|
[19715] | 50 | $this->tpl_subtitle = 'EC-CUBE ログ表示'; |
---|
[18179] | 51 | $this->line_max = 50; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | * Page のプロセス. |
---|
| 56 | * |
---|
| 57 | * @return void |
---|
| 58 | */ |
---|
| 59 | function process() { |
---|
[19661] | 60 | $this->action(); |
---|
| 61 | $this->sendResponse(); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * Page のアクション. |
---|
| 66 | * |
---|
| 67 | * @return void |
---|
| 68 | */ |
---|
| 69 | function action() { |
---|
[18179] | 70 | SC_Utils_Ex::sfIsSuccess(new SC_Session); |
---|
| 71 | |
---|
| 72 | $this->lfInitParam(); |
---|
| 73 | |
---|
| 74 | if (SC_Utils::sfIsInt($tmp = $this->objForm->getValue('line'))) { |
---|
| 75 | $this->line_max = $tmp; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | $this->tpl_ec_log = $this->getEccubeLog(); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * デストラクタ. |
---|
| 83 | * |
---|
| 84 | * @return void |
---|
| 85 | */ |
---|
| 86 | function destroy() { |
---|
| 87 | parent::destroy(); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * パラメータの初期化 |
---|
| 92 | * |
---|
| 93 | * @return array |
---|
| 94 | */ |
---|
| 95 | function lfInitParam() { |
---|
| 96 | $this->objForm = new SC_FormParam; |
---|
| 97 | $this->objForm->addParam('line_max', 'line_max', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK')); |
---|
| 98 | $this->objForm->setParam($_POST); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * EC-CUBE ログを取得する |
---|
| 103 | * |
---|
| 104 | * @return array |
---|
| 105 | */ |
---|
| 106 | function getEccubeLog() { |
---|
| 107 | |
---|
| 108 | $index = 0; |
---|
| 109 | $arrLogs = array(); |
---|
| 110 | for ($gen = 0 ; $gen <= MAX_LOG_QUANTITY; $gen++) { |
---|
| 111 | $path = LOG_PATH; |
---|
| 112 | if ($gen != 0) { |
---|
| 113 | $path .= ".$gen"; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | // ファイルが存在しない場合、前世代のログへ |
---|
| 117 | if (!file_exists($path)) continue; |
---|
| 118 | |
---|
| 119 | $arrLogTmp = array_reverse(file($path)); |
---|
| 120 | |
---|
[18281] | 121 | $arrBodyReverse = array(); |
---|
[18179] | 122 | foreach ($arrLogTmp as $line) { |
---|
[18281] | 123 | $line = chop($line); |
---|
[18179] | 124 | if (preg_match('/^(\d+\/\d+\/\d+ \d+:\d+:\d+) \[([^\]]+)\] (.*)$/', $line, $arrMatch)) { |
---|
| 125 | $arrLogLine = array(); |
---|
| 126 | // 日時 |
---|
| 127 | $arrLogLine['date'] = $arrMatch[1]; |
---|
| 128 | // パス |
---|
| 129 | $arrLogLine['path'] = $arrMatch[2]; |
---|
| 130 | // 内容 |
---|
[18281] | 131 | $arrBodyReverse[] = $arrMatch[3]; |
---|
| 132 | $arrLogLine['body'] = implode("\n", array_reverse($arrBodyReverse)); |
---|
| 133 | $arrBodyReverse = array(); |
---|
[18179] | 134 | |
---|
| 135 | $arrLogs[] = $arrLogLine; |
---|
| 136 | |
---|
| 137 | // 上限に達した場合、処理を抜ける |
---|
| 138 | if (count($arrLogs) >= $this->line_max) break 2; |
---|
| 139 | } else { |
---|
| 140 | // 内容 |
---|
[18281] | 141 | $arrBodyReverse[] = $line; |
---|
[18179] | 142 | } |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | return $arrLogs; |
---|
| 146 | } |
---|
| 147 | } |
---|