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);
78 // bug 53041 - now that we are respecting file name suffixes for log files, we need to get the log file name properly
79 $config = SugarConfig::getInstance();
80 $ext = $config->get('logger.file.ext');
81 $logfile = $config->get('logger.file.name');
82 $log_dir = $config->get('log_dir');
83 $log_dir = $log_dir . (empty($log_dir)?'':'/');
84 $file_suffix = $config->get('logger.file.suffix');
86 if( !empty($file_suffix) )
88 $date_suffix = "_" . date(str_replace("%", "", $file_suffix));
91 $logFile = $log_dir . $logfile . $date_suffix . $ext;
93 if (!file_exists($logFile)) {
97 $doaction =(!empty($_REQUEST['doaction']))?$_REQUEST['doaction']:'';
101 echo "<h3>{$mod_strings['LBL_MARKING_WHERE_START_LOGGING']}</h3><br>";
102 $_SESSION['log_file_size'] = filesize($logFile);
105 if(!empty($_SESSION['last_log_file_size'])){
106 $_SESSION['log_file_size'] = $_SESSION['last_log_file_size'];
108 $_SESSION['log_file_size'] = 0;
110 $_REQUEST['display'] = true;
113 $_SESSION['log_file_size'] = 0;
114 $_REQUEST['display'] = true;
119 if (!empty ($_REQUEST['display'])) {
120 echo "<h3>{$mod_strings['LBL_DISPLAYING_LOG']}</h3>";
121 $process_id = getmypid();
123 echo $mod_strings['LBL_YOUR_PROCESS_ID'].' [' . $process_id. ']';
124 echo '<br>'.$mod_strings['LBL_YOUR_IP_ADDRESS'].' ' . $_SERVER['REMOTE_ADDR'];
126 echo $mod_strings['LBL_IT_WILL_BE_IGNORED'];
128 if (empty ($_SESSION['log_file_size'])) {
129 $_SESSION['log_file_size'] = 0;
131 $cur_size = filesize($logFile);
132 $_SESSION['last_log_file_size'] = $cur_size;
134 if ($cur_size >= $_SESSION['log_file_size']) {
135 $pos = $_SESSION['log_file_size'] - $cur_size;
137 if($_SESSION['log_file_size'] == $cur_size){
138 echo $mod_strings['LBL_LOG_NOT_CHANGED'].'<br>';
140 $fp = sugar_fopen($logFile, 'r');
141 fseek($fp, $pos , SEEK_END);
143 while($line = fgets($fp)){
145 $line = filter_var($line, FILTER_SANITIZE_SPECIAL_CHARS);
146 //preg_match('/[^\]]*\[([0-9]*)\] ([a-zA-Z]+) ([a-zA-Z0-9\.]+) - (.*)/', $line, $result);
147 preg_match('/[^\]]*\[([0-9]*)\]/', $line, $result);
150 if(empty($result) && $lastMatch){
154 if(empty($result) || ($ignore_self &&$result[LOG_NAME] == $_SERVER['REMOTE_ADDR'] )){
157 if(empty($filter) || (!$reg_ex && substr_count($line, $filter) > 0) || ($reg_ex && preg_match($filter, $line))){