From 638e250f2868d4ad4957756892ee3f965d7f4a9d Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Wed, 28 Mar 2018 16:12:13 -0400 Subject: [PATCH 1/2] Adding check to prevent generating 10000 Schedules Adds a simple check that before actually running through a result, PHP stops and returns an error --- api/generate.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/generate.php b/api/generate.php index a9f5245..a5eb7cd 100644 --- a/api/generate.php +++ b/api/generate.php @@ -391,6 +391,19 @@ function pruneSpecialCourses($schedules, $courseGroups) { $courseGroupsByCourseId = array(); $courseSet = array(); + + // Check to make sure schedule wont exceed 10,000 options + $totalSchedules = 1; + for($i = 1; $i <= $_POST['courseCount']; $i++) { + if(!isset($_POST["courses{$i}Opt"])) { continue; } + $totalSchedules *= count($_POST["courses{$i}Opt"]); + } + if ($totalSchedules >= 10000){ + echo json_encode(array("error" => "argument", "msg" => "Too many schedule possibilities to generate, try to prune possibilities. + Adding classes like YearOne or classes with hundreds of sections can cause this to occur.", "arg" => "action")); + break; + } + for($i = 1; $i <= $_POST['courseCount']; $i++) { // It's 1-indexed... :[ // Iterate over the courses in that course slot if(!isset($_POST["courses{$i}Opt"])) { continue; } From 1ae6d8ff305e49dcef1823743811b603de39e2dc Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Wed, 28 Mar 2018 22:02:34 -0400 Subject: [PATCH 2/2] Fixing phrasing --- api/generate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/generate.php b/api/generate.php index a5eb7cd..f08c0a9 100644 --- a/api/generate.php +++ b/api/generate.php @@ -399,7 +399,7 @@ function pruneSpecialCourses($schedules, $courseGroups) { $totalSchedules *= count($_POST["courses{$i}Opt"]); } if ($totalSchedules >= 10000){ - echo json_encode(array("error" => "argument", "msg" => "Too many schedule possibilities to generate, try to prune possibilities. + echo json_encode(array("error" => "argument", "msg" => "Too many schedule possibilities to generate, try to remove classes from your shopping cart. Adding classes like YearOne or classes with hundreds of sections can cause this to occur.", "arg" => "action")); break; }