Commits

Anonymous committed 7b9bb49

Update checkinstall to examine each profile config.
Fix issue #17 if apache_get_version unavailable

Comments (0)

Files changed (1)

admin/checkinstall.php

 				'sitename' => array(
 						'description' => 'Makes sure it\'s not empty or pointing to localhost.',
 						'msg_warning' => '',
-						'msg_fail' => 'Set the site base url to an accessible address.',
+						'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(
 						'msg_warning' => '',
 						'msg_fail' => 'Enable server write permissions to the temp directory. Config: lock_dir',
 					),
-				'writehgwebdir' => array(
-						'description' => 'Ensures Mercurial web directory registry is writable.',
+				'global_permissions' => array(
+						'description' => 'Global lock-down privileges on view, create, delete and update are not in effect.',
 						'msg_warning' => '',
-						'msg_fail' => 'Allow hgwebdir.config to be writable by PHP. Config: hgwebconf_abs_filepath',
+						'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',
 					),
-				'writehgrc' => array(
-						'description' => 'Ensures Mercurial repository folder writable.',
-						'msg_warning' => '',
-						'msg_fail' => 'Allow Mercurial repositories folder to be writable by PHP. Config: repositories_abs_dir',
-					),
+			),
+	);
+	
+$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\']',
 			),
 	);
 	
 		$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=100 valign=top><b>$t_name</b></td><td width=200 valign=top><font size=-1>".$t_config['description'] ."</font></td>$status_cell</tr>";
+	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>";
 }
 
 ///////////////////////////////////////////////////////////////////
 	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()
 	return is_writable($config['lock_dir']);
 }
 
-function test_writehgwebdir()
+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()
+function test_writehgrc($r_name)
 {
 	global $config;
 	return is_writable($config['profile'][$config['default_profile']]['default_repo_dir']);
 
 <fieldset>
 <legend>Server Information</legend>
-<table>
+<table width="100%">
 <tr>
-	<td width="150"><b>PHP version</b></td>
+	<td width="170"><b>PHP version</b></td>
 	<td><?php echo phpversion(); ?></td>
 </tr>
 <tr>
-	<td width="150"><b>Apache version</b></td>
-	<td><?php echo apache_get_version(); ?></td>
+	<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="150"><b>Native Python version</b></td>
+	<td width="170"><b>Native Python version</b></td>
 	<td><?php echo exec('python --version'); ?></td>
 </tr>
 </table>
 			$t_result = call_user_func('test_'.$t_name);
 			echo table_result($t_name, $test, $t_result);
 		}
-		
 	?>
 </table>
 </fieldset>
-<?php endforeach;?><br/><font size="-1">
+<?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>