2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
41 if(!is_admin($current_user)){
42 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
45 if(!empty($_REQUEST['filter'])){
46 $filter = $_REQUEST['filter'];
49 if(!empty($_REQUEST['ignore_self'])){
50 $ignore_self = 'checked';
53 if(!empty($_REQUEST['reg_ex'])){
58 <form action='index.php' name='logview'>
59 <input type='hidden' name='action' value='LogView'>
60 <input type='hidden' name='module' value='Configurator'>
61 <input type='hidden' name='doaction' value=''>
62 <input type='button' onclick='document.logview.doaction.value="all";document.logview.submit()' name='all' value='{$mod_strings['LBL_ALL']}'>
63 <input type='button' onclick='document.logview.doaction.value="mark";document.logview.submit()' name='mark' value='{$mod_strings['LBL_MARK_POINT']}'>
64 <input type='submit' name='display' value='{$mod_strings['LBL_REFRESH_FROM_MARK']}'>
65 <input type='button' onclick='document.logview.doaction.value="next";document.logview.submit()' name='next' value='{$mod_strings['LBL_NEXT_']}'>
67 {$mod_strings['LBL_SEARCH']} <input type='text' name='filter' value='$filter'> {$mod_strings['LBL_REG_EXP']} <input type='checkbox' name='reg_ex' $reg_ex>
69 {$mod_strings['LBL_IGNORE_SELF']} <input type='checkbox' name='ignore_self' $ignore_self>
73 define('PROCESS_ID', 1);
74 define('LOG_LEVEL', 2);
75 define('LOG_NAME', 3);
76 define('LOG_DATA', 4);
77 $logFile = $sugar_config['log_dir'].'/'.$sugar_config['log_file'];
79 if (!file_exists($logFile)) {
83 $doaction =(!empty($_REQUEST['doaction']))?$_REQUEST['doaction']:'';
87 echo "<h3>{$mod_strings['LBL_MARKING_WHERE_START_LOGGING']}</h3><br>";
88 $_SESSION['log_file_size'] = filesize($logFile);
91 if(!empty($_SESSION['last_log_file_size'])){
92 $_SESSION['log_file_size'] = $_SESSION['last_log_file_size'];
94 $_SESSION['log_file_size'] = 0;
96 $_REQUEST['display'] = true;
99 $_SESSION['log_file_size'] = 0;
100 $_REQUEST['display'] = true;
105 if (!empty ($_REQUEST['display'])) {
106 echo "<h3>{$mod_strings['LBL_DISPLAYING_LOG']}</h3>";
107 $process_id = getmypid();
109 echo $mod_strings['LBL_YOUR_PROCESS_ID'].' [' . $process_id. ']';
110 echo '<br>'.$mod_strings['LBL_YOUR_IP_ADDRESS'].' ' . $_SERVER['REMOTE_ADDR'];
112 echo $mod_strings['LBL_IT_WILL_BE_IGNORED'];
114 if (empty ($_SESSION['log_file_size'])) {
115 $_SESSION['log_file_size'] = 0;
117 $cur_size = filesize($logFile);
118 $_SESSION['last_log_file_size'] = $cur_size;
120 if ($cur_size >= $_SESSION['log_file_size']) {
121 $pos = $_SESSION['log_file_size'] - $cur_size;
123 if($_SESSION['log_file_size'] == $cur_size){
124 echo $mod_strings['LBL_LOG_NOT_CHANGED'].'<br>';
126 $fp = sugar_fopen($logFile, 'r');
127 fseek($fp, $pos , SEEK_END);
129 while($line = fgets($fp)){
131 $line = remove_xss($line);
132 //preg_match('/[^\]]*\[([0-9]*)\] ([a-zA-Z]+) ([a-zA-Z0-9\.]+) - (.*)/', $line, $result);
133 preg_match('/[^\]]*\[([0-9]*)\]/', $line, $result);
136 if(empty($result) && $lastMatch){
140 if(empty($result) || ($ignore_self &&$result[LOG_NAME] == $_SERVER['REMOTE_ADDR'] )){
143 if(empty($filter) || (!$reg_ex && substr_count($line, $filter) > 0) || ($reg_ex && preg_match($filter, $line))){