Changeset 12 for trunk/www/mangos_debug.php
- Timestamp:
- Jun 11, 2009, 9:37:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/mangos_debug.php
r6 r12 1 1 <?php 2 3 include('global.php');4 2 5 3 class MangosDebug extends Module 6 4 { 7 var $MangosConfFile = '/opt/mangos/etc/mangosd.conf';8 var $StdOutLogFile = '/opt/mangos/log/mangos-worldd.log';9 var $ErrOutLogFile = '/opt/mangos/log/mangos-worldd.err';10 var $MangosLogFile = '/opt/mangos/log/Server.log';11 var $MangosDbErrorsLogFile = '/opt/mangos/log/DBErrors.log';12 5 var $ItemPerPage = 35; 13 6 … … 95 88 function ProcessLog() 96 89 { 90 $Output = ''; 91 // Read server Id from first parameter 92 if((count($_SERVER['argv']) > 1) and is_numeric($_SERVER['argv'][1])) 93 { 94 $ServerId = $_SERVER['argv'][1]; 95 $LogDir = '../server/'.$ServerId.'/log/'; 96 $MangosConfFile = $LogDir.'mangosd.conf'; 97 $StdOutLogFile = $LogDir.'mangos-worldd.log'; 98 $ErrOutLogFile = $LogDir.'mangos-worldd.err'; 99 $MangosLogFile = $LogDir.'Server.log'; 100 $MangosDbErrorsLogFile = $LogDir.'DBErrors.log'; 101 102 if(!file_exists($StdOutLogFile)) exit; 103 97 104 $Content = file_get_contents($StdOutLogFile); 98 105 $Lines = explode("\n", $Content); … … 126 133 127 134 // Insert data to database 128 $Database->query('INSERT INTO `Debug` (`Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES (NOW(), "'. 129 $MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 135 $Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 130 136 $InsertId = $Database->insert_id; 131 137 … … 133 139 $Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId); 134 140 $Backtrace = ''; 135 //echo($Database->error); 136 $Log = addslashes(file_get_contents($MangosLogFile)); 137 $Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 138 //echo($Database->error); 139 $Log = addslashes(file_get_contents($MangosDbErrorsLogFile)); 140 $Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId); 141 //echo($Database->error); 141 142 if(file_exists($MangosLogFile)) 143 { 144 $Log = addslashes(file_get_contents($MangosLogFile)); 145 $Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 146 unlink($MangosLogFile); 147 148 } 149 if(file_exists($MangosDbErrorLogFile)) 150 { 151 $Log = addslashes(file_get_contents($MangosDbErrorsLogFile)); 152 $Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId); 153 unlink($MangosDbErrorsLogFile); 154 } 142 155 143 $Configuration = array(); 144 $Log = addslashes(file_get_contents($MangosConfFile)); 145 $LogLines = explode("\n", $Log); 146 foreach($LogLines as $LogLine) 156 if(file_exists($MangosConfFile)) 147 157 { 148 if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine; 158 $Configuration = array(); 159 $Log = addslashes(file_get_contents($MangosConfFile)); 160 $LogLines = explode("\n", $Log); 161 foreach($LogLines as $LogLine) 162 { 163 if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine; 164 } 165 $Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId); 149 166 } 150 $Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId);151 167 152 //echo($Database->error);153 $Log = addslashes(file_get_contents($ErrOutLogFile));154 $Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId);155 156 // Clear log files157 unlink($MangosLogFile);168 if(file_exists($ErrOutLogFile)) 169 { 170 $Log = addslashes(file_get_contents($ErrOutLogFile)); 171 $Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId); 172 unlink($ErrOutLogFile); 173 } 158 174 unlink($StdOutLogFile); 159 unlink($ErrOutLogFile);160 unlink($MangosDbErrorsLogFile);175 } else $Output = 'Je nutno zadat číslo serveru jako parameter'; 176 return($Output); 161 177 } 162 178 }
Note:
See TracChangeset
for help on using the changeset viewer.