Location: PHPKode > projects > Work project > workproject/optimize.php
<?
include ("include_config.inc");
include ("include_profile_name.inc");
include ("include_project_name.inc");
include ("include_log_file.inc");
include ("include_delete_task.inc");
include ("include_delete_project.inc");
include ("include_delete_profile.inc");
include ("include_update_user.inc"); 
include ("include_delete_user.inc");
include ("include_list_user.inc");
include ("include_state_name.inc");
include ("include_user_name.inc");
include ("include_workload_project.inc");
include ("include_dates_project.inc");
include ("include_display_comment.inc");
include ("include_button.inc");

if ( isset( $HTTP_COOKIE_VARS[$g_string_cookie] ) ) {
	$g_string_cookie_val         = $HTTP_COOKIE_VARS[$g_string_cookie];
	write_log_user ($filename_log, "Cookie created 1.1: ".$g_string_cookie." -- ".$g_string_cookie_val);
}
if ( isset( $HTTP_COOKIE_VARS[$g_project_cookie] ) ) {
	$g_project_cookie_val        = $HTTP_COOKIE_VARS[$g_project_cookie];
	write_log_user ($filename_log, "Cookie created 2.1: ".$g_project_cookie." -- ".$g_project_cookie_val);
}

/* check the login for user */
login_cookie_check();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Your tasks - Optimize database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<? include ("include_css.inc"); ?>
<script src="main.js" type="text/javascript"></script>
<script src="tasks.js" type="text/javascript"></script>
<script src="nav.js" type="text/javascript"></script>

</head>
<BODY onload="init()">


<?
include ("include_main.inc");
?>

<?php
write_log_user ($filename_log, "Beginning of list task of the selected user.");

/* database connection */
$link= mysql_connect($g_hostname, $g_db_username, $g_db_password) or die("could not connect");
$result_link = mysql_select_db($g_database_name);

/* read of the user connected */
$connected_user = user_connected();
$profile_connected_user = user_profile($connected_user);
$name_connected_user = user_name($connected_user,$g_database_name);
$name_profile_connected_user = profile_name($profile_connected_user);
display_connected_user($name_connected_user,$name_profile_connected_user);

write_log_user ($filename_log, "Optimize the database.");

if($optimize == 1 ) {
	
	$tables = mysql_list_tables($g_database_name); 

	$is_comment ="";
	$flag =0;
	while (list($table_name) = mysql_fetch_array($tables)) { 
   		$sql = "OPTIMIZE TABLE $table_name"; 
		write_log_user ($filename_log, "Optimize the table: ".$sql);
   		mysql_query($sql) or $error = mysql_error(); 
		$is_comment = $is_comment."<br>".$error;
		if ( $error )$flag =1;
	}
	if ($flag == 0)$is_comment = "OK";
	write_log_user ($filename_log, "Optimize : ".$is_comment);
	display_comment( "Optimize database:  ". $is_comment);
	$optimize = 0;
} 


?>

<form method="post" enctype="multipart/form-data">
<input type="hidden" name="optimize" value="1">

<table class="around" border=1 align="center" cellspacing="4" cellpadding="4">
<tr><td class="title" colspan="3">Optimise the current database</td></tr>
<tr>
	<? if ( $profile_connected_user == 1) { ?>
		<td align="center">
		<? button("Optimize","Optimize all the tables of the database","submit();"); ?>
		</td>
	<? } ?>	
	<td>
	<img src="<? echo $g_icon_path;?>question.gif" ALT="Help" onClick="show_comment_screen('Help','Optimize database',60,'');">
	</td>
	<? if ( right_user($connected_user,13) ){ ?>
	<td>
	<a href=<? echo $g_file_log_directory; ?>  title="Log data" > <img src="<? echo $g_icon_path;?>see.gif" border="0"> </a>
	</td>
	<? } ?>
</tr>
</table>
</form>

<?
include ("include_bottom.inc");
?>


</BODY>
</HTML>
Return current item: Work project