A Support Tool
Posted: Fri Jun 13, 2008 12:24 am
Here is a small start to something I hope can be incorporated into the CMSMS Admin Panel. The idea is to provide a simple means to gather the basic info required for support questions in the Forum.
Create a UDT called "support_info" and add the following code:
Updated to include CMSMS Version and active modules
Updated 13/6/2008 to add more php config info, browser info and directory permission info
Updated 14/6/2008 mostly cosmetic changes and changed from get_cfg_var to ini_get
Updated 16/6/2008 to add mysqli and postgre db info
Now you can place the {support_info} tag on a test page and it will print out some of the basic configuration info that is required to provide effective support, which you can copy and paste into your Forum posting.
Perhaps others could add to the code, to make it more comprehensive. I'm thinking that we should be able to read the Apache and MySQL log files, to include a number of lines from them as well.
Nullig
Create a UDT called "support_info" and add the following code:
Updated to include CMSMS Version and active modules
Updated 13/6/2008 to add more php config info, browser info and directory permission info
Updated 14/6/2008 mostly cosmetic changes and changed from get_cfg_var to ini_get
Updated 16/6/2008 to add mysqli and postgre db info
Code: Select all
global $gCms;
$db = &$gCms->db;
$config = &$gCms->config;
echo "<b>CMS Made Simple Version:</b> " . $GLOBALS['CMS_VERSION'] . "<br /> <br />";
echo "<b>Installed Modules:</b> ";
echo "<ul>";
$query = "SELECT * FROM ".cms_db_prefix()."modules WHERE active=1";
$dbresult = $db->Execute($query);
while($row = $dbresult->FetchRow()) {
echo "<li>" . $row['module_name'] . ": " . $row['version'] . "</li>";
}
echo "</ul>";
echo "<b>Current PHP Version:</b> " . phpversion() . "<br /> <br />";
echo "<b>PHP Configuration:</b>";
echo "<ul>";
echo "<li>Maximum Post Size: " . ini_get('post_max_size') . "</li>";
echo "<li>Maximum Upload Size: " . ini_get('upload_max_filesize') . "</li>";
echo "<li>PHP Memory Limit: " . ini_get( 'memory_limit' ) . "</li>";
if (ini_get('safe_mode') == 1) {
echo "<li>PHP Safe Mode: On</li>";
} else {
echo "<li>PHP Safe Mode: Off</li>";
}
echo "<li>Maximum Execution Time: " . ini_get('max_execution_time') . " seconds</li>";
echo "<li>Session Save Path: " . session_save_path() . "</li>";
echo "</ul>";
switch($config['dbms'])
{
case 'postgres7': $v = pg_version();
$_server_db = "<b>PostgreSQL Server Version:</b> " . $v['server_version'];
break;
case 'mysql': $v = mysql_get_server_info();
$_server_db = "<b>MySQL Server Version:</b> " . $v;
break;
case 'mysqli': $v = mysqli_get_server_info();
$_server_db = "<b>MySQLi Server Version:</b> " . $v;
break;
}
echo $_server_db . "<br /> <br />";
echo "<b>Server Software:</b> " . $_SERVER['SERVER_SOFTWARE'] . "<br />";
echo "<b>Server API:</b> " . strtoupper(PHP_SAPI) . "<br />";
echo "<b>Server OS:</b> " . PHP_OS . " v " . php_uname('r') . " on " . php_uname('m') . " architecture<br /> <br />";
clearstatcache();
echo "<b>Directory Permissions:</b>";
echo "<ul>";
echo "<li>tmp/cache - " . substr(sprintf('%o', fileperms($config['root_path'].DIRECTORY_SEPARATOR.'tmp/cache')), -4) . "</li>";
echo "<li>tmp/templates_c - " . substr(sprintf('%o', fileperms($config['root_path'].DIRECTORY_SEPARATOR.'tmp/templates_c')), -4) . "</li>";
echo "<li>uploads - " . substr(sprintf('%o', fileperms($config['root_path'].DIRECTORY_SEPARATOR.'uploads')), -4) . "</li>";
echo "<li>modules - " . substr(sprintf('%o', fileperms($config['root_path'].DIRECTORY_SEPARATOR.'modules')), -4) . "</li>";
echo "</ul>";
echo "<b>Browser:</b> " . $_SERVER['HTTP_USER_AGENT'] . "<br />";
Perhaps others could add to the code, to make it more comprehensive. I'm thinking that we should be able to read the Apache and MySQL log files, to include a number of lines from them as well.
Nullig