<?php

// The Script lists what features are available at your hosting.
// Apache version, PHP version, perl version etc.
// Svetoslav Marinov <svetoslavm@gmail.com>
// License: LGPL
// (c) January 2007
$hosting_info_data_array = array();
$hosting_info_ver '1.0.0';

$hosting_info_data_array['Domain']                = $_SERVER['SERVER_NAME'];
$hosting_info_data_array['Server IP']                = $_SERVER['SERVER_ADDR'];
$hosting_info_data_array['Your IP']                = $_SERVER['REMOTE_ADDR'];
$hosting_info_data_array['Web Server']                         = $_SERVER['SERVER_SOFTWARE'];
$hosting_info_data_array['Operating System']                = PHP_OS;
$hosting_info_data_array['Operating System Extended'] = php_uname();
$hosting_info_data_array['PHP Version']                       = PHP_VERSION;

$show_php_ext = isset($_REQUEST['php_ext']) ? 0;
if (
$show_php_ext) {
    
// showing what php extensions we have
    
$php_exts get_loaded_extensions();

    
$hosting_info_data_array['PHP Extensions']  = '';
    
$hosting_info_data_array array_merge($hosting_info_data_array$php_exts);
}

// reading php info
ob_start();
phpinfo();
$buffer ob_get_contents();
while (@
ob_end_clean());

$hosting_info_data_array['Zend Optimizer'] = false;
$hosting_info_data_array['ionCube'] = false;
$hosting_info_data_array['Perl Version']     = false;
$hosting_info_data_array['Python Version'] = false;

// check for Zend Optimizer
$search_regex  '#Zend(?:\s|&nbsp;)+Optimizer(?:\s|&nbsp;)+v(\d+\.\d+\.\d+)#si'// with Zend Optimizer v3.0.2
if (preg_match($search_regex$buffer$matches)) {
    
$hosting_info_data_array['Zend Optimizer'] = $matches[1];
}

// check for ionCube
$ioncube_search_regex  '#ionCube(?:\s|&nbsp;)+PHP(?:\s|&nbsp;)+Loader(?:\s|&nbsp;)+v(\d+\.\d+\.\d+)#si'// with the ionCube PHP Loader v3.1.13
if (preg_match($ioncube_search_regex$buffer$matches)) {
    
$hosting_info_data_array['ionCube'] = $matches[1];
}

// searchig for perl 
$perl_cmd1 'perl -v';
$perl_cmd2 '/usr/bin/perl -v';
$perl_cmd3 '/usr/local/bin/perl -v';
$perl_ver_search_regex  '#v(\d+\.\d+\.\d+(?:\.\d+)?)#si'// This is perl, v5.8.8

exec($perl_cmd1$output$ret_var);
if (
$ret_var == 0) {
    if (
preg_match($perl_ver_search_regexjoin(""$output), $matches)) {
        
$hosting_info_data_array['Perl Version'] = $matches[1];
    }
}

if (
$hosting_info_data_array['Perl Version']  === false) {
    
exec($perl_cmd2$output$ret_var);
    if (
$ret_var == 0) {
        if (
preg_match($perl_ver_search_regexjoin(""$output), $matches)) {
            
$hosting_info_data_array['Perl Version'] = $matches[1];
        }
    }
}

if (
$hosting_info_data_array['Perl Version']  === false) {
    
exec($perl_cmd3$output$ret_var);
    if (
$ret_var == 0) {
        if (
preg_match($perl_ver_search_regexjoin(""$output), $matches)) {
            
$hosting_info_data_array['Perl Version'] = $matches[1];
        }
    }
}

// searchig for python 
$python_cmd1 'python -V 2>&1';
$python_cmd2 '/usr/bin/python -V 2>&1';
$python_cmd3 '/usr/local/bin/python -V 2>&1';
$python_ver_search_regex  '#(\d+\.\d+\.\d+(?:\.\d+)?)#si'// Python 2.2.2

$output '';
exec($python_cmd1$output$ret_var);
if (
$ret_var == 0) {
    if (
preg_match($python_ver_search_regexjoin(""$output), $matches)) {
        
$hosting_info_data_array['Python Version'] = $matches[1];
    }
}

$output '';
if (
$hosting_info_data_array['Python Version']  === false) {
    
exec($python_cmd2$output$ret_var);
    if (
$ret_var == 0) {
        if (
preg_match($python_ver_search_regexjoin(""$output), $matches)) {
            
$hosting_info_data_array['Python Version'] = $matches[1];
        }
    }
}

$output '';
if (
$hosting_info_data_array['Python Version']  === false) {
    
exec($python_cmd3$output$ret_var);
    if (
$ret_var == 0) {
        if (
preg_match($python_ver_search_regexjoin(""$output), $matches)) {
            
$hosting_info_data_array['Python Version'] = $matches[1];
        }
    }
}


$i       0;
$rows '';
foreach (
$hosting_info_data_array as $feature => $status) {
    if (
is_int($feature)) {
        
$feature "";
    }
    
$altern_color = ($i == 0) ? 'bgcolor="#eeeeee"' "";
    
$rows .= sprintf("<tr $altern_color><td><b>$feature</b></td><td>" . (($status !== false) ? $status '<font color="red">Not Available</font>') . "</td></tr>\n");
    
$i++;
}

?>

<table width="800" align="center">
<tr bgcolor="#543C1C">
    <td>
        <b><font color="white">Hosting Info Script v<?php print $hosting_info_ver?></font></b>
    </td>
    <td align="right">
    <?php $file basename(__FILE__); ?>
    <?php if ($show_php_ext) {
        print 
'<b><font color="white"><a href="index.php"><font color="white">Hide PHP Extensions</font></a></b>';
    } else {
        print 
'<b><font color="white"><a href="index.php?php_ext=1"><font color="white">Show PHP Extensions</font></a></b>';
    }
?>    |
        <b><font color="white"><a href="index_source.php" target="_blank" ><font color="white">Get Source</font></a></b>
    </td>
</tr>
<?php print $rows?>
</table>
<div align="center" style="font-size:10pt">Hosting Info Script by Svetoslav Marinov [svetoslavmATgmail.com] <a href="http://seofilter.com" target="_blank" >http://seofilter.com</a></div>