// -- local config --
session_start();
header("Cache-control: private"); // IE 6 Fix.
//if(!$_SESSION['username'])
if (false)
{
@include('login_form.php');
exit(0);
}
@include('db.php');
@include('equipment_db.php');
$db = mysql_select_db($database_name, $connection);
if (!$db)
{
die("Could not select database:\n" . mysql_error() . "\n");
}
// -- setup --
@include('fns.php');
// ----
echo "\n";
echo "
\n";
echo " gbff equipment admin \n";
echo " \n";
echo " \n";
echo "\n";
echo "\n";
// -- process --
$action = $_POST['submit_btn'];
if (isset($action))
{
echo "\n";
echo "Processing your selections :-\n";
echo "
\n";
$query = "LOCK TABLES {$dbt_equipment} WRITE, {$dbt_bookings} WRITE, {$dbt_booking_list} WRITE";
$result = mysql_query($query);
if (!$result)
{
echo 'Could not lock tables: ' . mysql_error() . " \n";
}
else
{
$equipment_new = $_POST['equipment_new'];
if ($equipment_new != '')
{
$query = "SELECT * FROM {$dbt_equipment}";
$result = mysql_query($query);
if (!is_resource($result))
{
echo "Could not insert into table {$dbt_equipment}: " . mysql_error() . " \n";
}
else
{
$col_0_id = mysql_field_name($result, 0);
mysql_free_result($result);
// ----
// insert new equipment
$query = "SELECT {$col_0_id} FROM {$dbt_equipment}";
$result = mysql_query($query);
$new_uid = get_new_uid($result, $max_equipment);
if (is_resource($result))
{
mysql_free_result($result);
}
if ($new_uid == $max_equipment)
{
echo "Could not insert into table {$dbt_equipment} - it is full ! \n";
}
else
{
$query = "INSERT INTO {$dbt_equipment} VALUES ({$new_uid}, '{$equipment_new}')";
$result = mysql_query($query);
if (!$result)
{
echo "Could not insert {$col_0_id}.{$new_uid} into table {$dbt_equipment}: " . mysql_error() . " \n";
}
}
}
}
admin_action_del($dbt_equipment);
admin_action_del($dbt_bookings);
// can't do this table this way...
//admin_action_del($dbt_booking_list);
//echo " \n";
//print_r($_POST);
$query = "UNLOCK TABLES";
$result = mysql_query($query);
if (!$result)
{
echo 'Could not unlock tables: ' . mysql_error() . " \n";
}
}
echo "\n";
echo "Done !\n";
echo "
\n";
echo " \n";
}
// -- edit equipment table -- action='./admin_do.php'
echo "\n";
echo " \n";
echo "\n";
echo "Note :- if you remove any items from the tables above, then they\n";
echo "will be automatically removed from the booking lists below. \n";
//echo "You only need to make selections in this table if it is a\n";
//echo "seperate/special item that you want to remove.\n";
echo "
\n";
echo " \n";
echo "\n";
html_show_bookinglists();
echo "
\n";
// --
echo "\n";
echo " \n";
echo " ";
echo " \n";
echo " ";
echo "
\n";
echo " \n";
// ----
echo "\n";
echo "\n";
// ----
return(0);
?>