Revision: 1124
http://mrbs.svn.sourceforge.net/mrbs/?rev=1124&view=rev
Author: cimorrison
Date: 2009-06-22 22:56:38 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
Added checks for zero values of Resolution in order to avoid divide by zero
errors and endless loops.
Modified Paths:
--------------
mrbs/trunk/web/edit_area_room.php
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2009-06-22 22:06:36 UTC (rev 1123)
+++ mrbs/trunk/web/edit_area_room.php 2009-06-22 22:56:38 UTC (rev 1124)
@@ -261,22 +261,30 @@
$valid_email = validate_email_list($area_admin_email);
if (!$enable_periods)
- {
- // Check morningstarts, eveningends, and resolution for consistency
- $start_first_slot = ($area_morningstarts*60) +
$area_morningstarts_minutes; // minutes
- $start_last_slot = ($area_eveningends*60) + $area_eveningends_minutes;
// minutes
- $start_difference = ($start_last_slot - $start_first_slot); //
minutes
- if (($start_difference < 0) or ($start_difference%$area_res_mins != 0))
+ {
+ // Avoid divide by zero errors
+ if ($area_res_mins == 0)
{
$valid_resolution = FALSE;
}
+ else
+ {
+ // Check morningstarts, eveningends, and resolution for consistency
+ $start_first_slot = ($area_morningstarts*60) +
$area_morningstarts_minutes; // minutes
+ $start_last_slot = ($area_eveningends*60) +
$area_eveningends_minutes; // minutes
+ $start_difference = ($start_last_slot - $start_first_slot); //
minutes
+ if (($start_difference < 0) or ($start_difference%$area_res_mins != 0))
+ {
+ $valid_resolution = FALSE;
+ }
- // Check that the number of slots we now have is no greater than
$max_slots
- // defined in the config file - otherwise we won't generate enough CSS
classes
- $n_slots = ($start_difference/$area_res_mins) + 1;
- if ($n_slots > $max_slots)
- {
- $enough_slots = FALSE;
+ // Check that the number of slots we now have is no greater than
$max_slots
+ // defined in the config file - otherwise we won't generate enough CSS
classes
+ $n_slots = ($start_difference/$area_res_mins) + 1;
+ if ($n_slots > $max_slots)
+ {
+ $enough_slots = FALSE;
+ }
}
}
@@ -391,6 +399,8 @@
{
// generates the HTML for the drop-down for the last slot time and
// puts it in the element with id 'last_slot'
+ if (res_mins == 0) return; // avoid endless loops
+
var first_slot = (morningstarts * 60) + morningstarts_minutes;
var last_slot = (eveningends * 60) + eveningends_minutes;
var last_possible = (24 * 60) - res_mins;
@@ -414,6 +424,7 @@
{
// re-generates the dropdown given changed form values
var res_mins = parseInt(formObj.area_res_mins.value);
+ if (res_mins == 0) return; // avoid endless loops and divide by
zero errors
var morningstarts = parseInt(formObj.area_morningstarts.value);
var morningstarts_minutes =
parseInt(formObj.area_morningstarts_minutes.value);
var eveningends_t = parseInt(formObj.area_eveningends_t.value);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits