source: tmp/version-2_5-test/data/class/pages/admin/system/LC_Page_Admin_System_Log.php @ 18609

Revision 18609, 4.1 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2008 LOCKON CO.,LTD. All Rights Reserved.
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
25require_once(CLASS_PATH . "pages/LC_Page.php");
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 */
34class LC_Page_Admin_System_Log extends LC_Page {
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';
50        $this->tpl_subtitle = 'ログ表示';
51        $this->line_max     = 50;
52    }
53
54    /**
55     * Page のプロセス.
56     *
57     * @return void
58     */
59    function process() {
60        SC_Utils_Ex::sfIsSuccess(new SC_Session);
61        $objView = new SC_AdminView();
62       
63        $this->lfInitParam();
64       
65        if (SC_Utils::sfIsInt($tmp = $this->objForm->getValue('line'))) {
66            $this->line_max = $tmp;
67        }
68       
69        $this->tpl_ec_log = $this->getEccubeLog();
70       
71        $objView->assignobj($this);
72        $objView->display(MAIN_FRAME);
73    }
74
75    /**
76     * デストラクタ.
77     *
78     * @return void
79     */
80    function destroy() {
81        parent::destroy();
82    }
83   
84    /**
85     * パラメータの初期化
86     *
87     * @return array
88     */
89    function lfInitParam() {
90        $this->objForm = new SC_FormParam;
91        $this->objForm->addParam('line_max', 'line_max', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK'));
92        $this->objForm->setParam($_POST);
93    }
94
95    /**
96     * EC-CUBE ログを取得する
97     *
98     * @return array
99     */
100    function getEccubeLog() {
101       
102        $index = 0;
103        $arrLogs = array();
104        for ($gen = 0 ; $gen <= MAX_LOG_QUANTITY; $gen++) {
105            $path = LOG_PATH;
106            if ($gen != 0) {
107                $path .= ".$gen";
108            }
109           
110            // ファイルが存在しない場合、前世代のログへ
111            if (!file_exists($path)) continue;
112           
113            $arrLogTmp = array_reverse(file($path));
114           
115            $arrBodyReverse = array();
116            foreach ($arrLogTmp as $line) {
117                $line = chop($line);
118                if (preg_match('/^(\d+\/\d+\/\d+ \d+:\d+:\d+) \[([^\]]+)\] (.*)$/', $line, $arrMatch)) {
119                    $arrLogLine = array();
120                    // 日時
121                    $arrLogLine['date'] = $arrMatch[1];
122                    // パス
123                    $arrLogLine['path'] = $arrMatch[2];
124                    // 内容
125                    $arrBodyReverse[] = $arrMatch[3];
126                    $arrLogLine['body'] = implode("\n", array_reverse($arrBodyReverse));
127                    $arrBodyReverse = array();
128                   
129                    $arrLogs[] = $arrLogLine;
130                   
131                    // 上限に達した場合、処理を抜ける
132                    if (count($arrLogs) >= $this->line_max) break 2;
133                } else {
134                    // 内容
135                    $arrBodyReverse[] = $line;
136                }
137            }
138        }
139        return $arrLogs;
140    }
141}
Note: See TracBrowser for help on using the repository browser.