Source

phpHgAdmin / admin / checkinstall.php

The default branch has multiple heads

Full commit
<?php 
header('Cache-Control: no-cache');
header('Pragma: no-cache');
define('BASEPATH', 'system/');
include 'application/config/config.php';
include 'application/config/phphgadmin.php';

$checks = array(

		/* base url, htaccess redirects, e-mailer set up, */
		'General' => array(
				'sitename' => array(
						'description' => 'Makes sure it\'s not empty or pointing to localhost.',
						'msg_warning' => '',
						'msg_fail' => 'Set the config base_url to an accessible address.',
					),
				'htaccess' => array(
						'description' => 'Allows clean URLs and redirects while protecting direct access to framework scripts. Ensure Apache Rewrite module is enabled.',
						'msg_warning' => '',
						'msg_fail' => 'Restore the .htaccess file from initial install to this web directory.',
					),
				'default_profile' => array(
						'description' => 'A valid default profile has been set, used when the user has not explicitly picked a profile to work under.',
						'msg_warning' => '',
						'msg_fail' => 'Set the config default_profile to the name of an existing profile.',
					),
			),
		/* write temp directory, allow uploads */
		'Server Permissions' => array(
				'writetemp' => array(
						'description' => 'Ensures local scratch space is writable.',
						'msg_warning' => '',
						'msg_fail' => 'Enable server write permissions to the temp directory. Config: lock_dir',
					),
				'global_permissions' => array(
						'description' => 'Global lock-down privileges on view, create, delete and update are not in effect.',
						'msg_warning' => '',
						'msg_fail' => 'Lift permissions by setting the following config to TRUE: global_allow_repo_create, global_allow_repo_view, global_allow_repo_delete, global_allow_repo_update',
					),
			),
	);
	
$repo_checks = array(
		'writehgwebdir' => array(
				'description' => 'Ensures Mercurial web directory registry is writable.',
				'msg_warning' => '',
				'msg_fail' => 'Allow hgwebdir.config to be writable by PHP. Config: $config[\'profile\'][PROFILE_NAME][\'ini\']',
			),
		'writehgrc' => array(
				'description' => 'Ensures Mercurial default repository folder writable.',
				'msg_warning' => '',
				'msg_fail' => 'Allow Mercurial repositories folder to be writable by PHP. Config: $config[\'profile\'][PROFILE_NAME][\'default_repo_dir\']',
			),
	);
	
function table_result($t_name, $t_config, $t_result)
{
	$status_cell = '';
	if($t_result)
	{
		$status_cell = '<td width=50 style="color:green" align=center>OK</td><td width="500"></td>';
	}
	else
	{
		$status_cell = '<td width=50 align=center valign=top><span style="color:white;background:red;padding:3"><b>FAIL</b></span></td><td width="500" valign=top><font size=-1>'.$t_config['msg_fail'].'</font></td>';
	}
	
	echo "<tr><td width=150 valign=top><b>$t_name</b></td><td width=200 valign=top><font size=-1>".$t_config['description'] ."</font></td>$status_cell</tr>";
}

///////////////////////////////////////////////////////////////////

function test_sitename()
{
	global $config;
	return (!empty($config['base_url']) && stripos($config['base_url'], '127.0.0.1')===FALSE && stripos($config['base_url'], '://localhost')===FALSE);
}

function test_htaccess()
{
	return @file_exists('.htaccess');
}

function test_default_profile()
{
	global $config;
	$default_profile = $config['default_profile'];
	return (!empty($default_profile) && isset($config['profile'][$default_profile]));
}

///////////////////////////////////////////////////////////////////

function test_writetemp()
{
	global $config;
	return is_writable($config['lock_dir']);
}

function test_global_permissions()
{
	global $config;
	return $config['global_allow_repo_view'] && $config['global_allow_repo_create'] && $config['global_allow_repo_update'] && $config['global_allow_repo_delete'];
}

////////////////////////////////////////////////////////////////////

function test_writehgwebdir($r_name)
{
	global $config;
	return is_writable($config['profile'][$config['default_profile']]['ini']);
}

function test_writehgrc($r_name)
{
	global $config;
	return is_writable($config['profile'][$config['default_profile']]['default_repo_dir']);
}

///////////////////////////////////////////////////////////////////

?>
<html>
<head>
<title>phpHgAdmin Check Installation</title>
</head>
<body>
<h2>phpHgAdmin Check Installation</h2>

<fieldset>
<legend>Server Information</legend>
<table width="100%">
<tr>
	<td width="170"><b>PHP version</b></td>
	<td><?php echo phpversion(); ?></td>
</tr>
<tr>
	<td width="170"><b>Apache version</b></td>
	<td>
	<?php 
		if(function_exists('apache_get_version'))
		{
			echo apache_get_version();
		}
		else if(isset($_SERVER) && isset($_SERVER['SERVER_SOFTWARE']))
		{
			echo $_SERVER['SERVER_SOFTWARE'];
		}
	?>
	</td>
</tr>
<tr>
	<td width="170"><b>Native Python version</b></td>
	<td><?php echo exec('python --version'); ?></td>
</tr>
</table>
</fieldset>

<?php foreach($checks as $category => $tests): ?>
<fieldset>
<legend><?php echo $category; ?></legend>
<table width="100%">
	<?php 
		foreach($tests as $t_name => $test)
		{
			$t_result = call_user_func('test_'.$t_name);
			echo table_result($t_name, $test, $t_result);
		}
	?>
</table>
</fieldset>
<?php endforeach;?>
<fieldset>
<legend>Repository Profiles</legend>

	<?php 
		$repos = array_keys($config['profile']);
		foreach($repos as $r_name)
		{
			echo "<fieldset><legend>$r_name</legend><table width='100%'>";
			foreach($repo_checks as $t_name => $test)
			{
				$t_result = call_user_func('test_'.$t_name, $r_name);
				echo table_result($t_name, $test, $t_result);
			}
			echo "</table></fieldset>";
		}
	?>

</fieldset>


<br/><font size="-1">
<?php echo 'Report generated ' . date("g:i:s A D, F jS Y",time()); ?></font>
</body>
</html>
<?php
// clean up 
	$config = null; 
	$db = null;
?>