zen version 1.3.9d but issue exists since at least 1.3.6
Widows platforms. In my case win 2003 server.
Clinking on "Version" link or "Tools>Server/Version Info" Returns:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
This is because you are passing unix commands to windows with-out error detection/redirection.
File: admin\includes\functions\general.php
PHP Code:
function zen_get_system_information() {
...
list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);
...
}
You must provide error redirection to prevent CGI Error by adding 2>&1
PHP Code:
list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a 2>&1'), 5);
While this prevents the CGI Error, no meaning full information will be displayed on a windows platform.
Commenting out the entire line will display correct server info.
//list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a 2>&1'), 5);
While you may have your own ideas on how to fix this, here is how I have done it which is still cross platform friendly.
PHP Code:
// Retreive server information
function zen_get_system_information() {
global $db;
// determine database size stats
$indsize = 0;
$datsize = 0;
$result = $db->Execute("SHOW TABLE STATUS" . (DB_PREFIX == '' ? '' : " LIKE '" . str_replace('_', '\_', DB_PREFIX) . "%'"));
while (!$result->EOF) {
$datsize += $result->fields['Data_length'];
$indsize += $result->fields['Index_length'];
$result->MoveNext();
}
$mysql_in_strict_mode = false;
$result = $db->Execute("SHOW VARIABLES LIKE 'sql\_mode'");
while (!$result->EOF) {
if (strstr($result->fields['Value'], 'strict_')) $mysql_in_strict_mode = true;
$result->MoveNext();
}
$db_query = $db->Execute("select now() as datetime");
// Problem code
//list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);
//if ($host == '') list($system, $host, $kernel) = array('', $_SERVER['SERVER_NAME'], php_uname());
// Corrected code
$error = 0;
@exec('uname -a 2>&1',$output,$error);
if(!$error) { list($system, $host, $kernel) = preg_split('/[\s,]+/', $output, 5);}
else { list($system, $host, $kernel) = array('', $_SERVER['SERVER_NAME'], php_uname());}
// Also check the uptime return value (which also fails on Windows)
if(DISPLAY_SERVER_UPTIME) {
@exec('uptime 2>&1',$uptime,$error);
if ($error) $uptime = "Not Available";
}else { $uptime = "Unchecked";}
// End of corrected code
return array('date' => zen_datetime_short(date('Y-m-d H:i:s')),
'system' => $system,
'kernel' => $kernel,
'host' => $host,
'ip' => gethostbyname($host),
// uptime will always have a value.
//'uptime' => (DISPLAY_SERVER_UPTIME == 'true' ? @exec('uptime 2>&1') : 'Unchecked'),
'uptime' => $uptime,
//
'http_server' => $_SERVER['SERVER_SOFTWARE'],
'php' => PHP_VERSION,
'zend' => (function_exists('zend_version') ? zend_version() : ''),
'db_server' => DB_SERVER,
'db_ip' => gethostbyname(DB_SERVER),
'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''),
'db_date' => zen_datetime_short($db_query->fields['datetime']),
'php_memlimit' => @ini_get('memory_limit'),
'php_safemode' => strtolower(@ini_get('safe_mode')),
'php_file_uploads' => strtolower(@ini_get('file_uploads')),
'php_uploadmaxsize' => @ini_get('upload_max_filesize'),
'php_postmaxsize' => @ini_get('post_max_size'),
'database_size' => $datsize,
'index_size' => $indsize,
'mysql_strict_mode' => $mysql_in_strict_mode,
);
}
Bookmarks