4 && strlen($params[4]) > 0 && $params[4] != '?page=2') { $p1 = $params[1]; $p2 = $params[2]; $p3 = $params[3]; header("Location: /$p1/$p2/$p3/"); exit; } // // Manage parameters to script // if (isset($_GET['cat'])) $cat = $_GET['cat']; if (isset($_POST['cat'])) $cat = $_POST['cat']; if (isset($_POST['search'])) $search = $_POST['search']; if (!isset($cat) && !isset($search)) header("Location: /"); $param1 = ""; $param2 = ""; if (isset($_GET['param1'])) $param1 = $_GET['param1']; if (isset($_GET['param2'])) $param2 = $_GET['param2']; $CurrentURL = $REQUEST_URI; // // Get website info // include "include/get-website.php"; // if searching don't need to do below checks if (!isset($search)) { // // Get Category Number // include "include/get-category.php"; // // Validate the paramaters // $region = ""; $region_num = 0; $subcategory_num = 0; // Check if the first parameter is a region if (isset($param1) && strlen($param1) > 0) { $rval = $param1; // Check if the first parameter is a region $query = "select description,record_num from portal_regions " . "where website_num = $website_num " . "and region = '$rval'"; $results = db_query($query); // If a record was found then set region variables if ($results !== false && mysql_num_rows($results) > 0) { $row = mysql_fetch_array($results); $region_num = $row['record_num']; $region_descr = $row['description']; $region = $rval; } } $sval = ""; if (isset($param1) && strlen($param1) > 0 && $region_num == 0) { $sval = $param1; } if (isset($param2) && strlen($param2) > 0) { $sval = $param2; } if (isset($sval) && strlen($sval) > 0) { // Check if first parameter is a subcategory $query = "select description,record_num from portal_subcategories " . "where category_num = $category_num " . "and subcategory = '$sval'"; $results = db_query($query); if ($results !== false && mysql_num_rows($results) > 0) { $row = mysql_fetch_array($results); $subcategory_num = $row['record_num']; $subcategory_descr = $row['description']; $subcategory = $sval; } } // // Get regions for this site // include "include/get-regions.php"; // // Get subcategories for this category // include "include/get-subcategories.php"; } // Handle invalid parameters if (isset($param1) && strlen($param1) > 0 && isset($param2) && strlen($param2) > 0) { if ($region_num == 0 && $subcategory_num == 0) { header("Location: /$cat/"); exit; } if ($region_num == 0 && $subcategory_num != 0) { header("Location: /$cat/$param2/"); exit; } if ($region_num != 0 && $subcategory_num == 0) { header("Location: /$cat/$param1/"); exit; } } // Handle single parameter errors if (isset($param1) && strlen($param1) > 0 && (!isset($param2) || strlen($param2) == 0)) { if ($region_num == 0 && $subcategory_num == 0) { header("Location: /$cat/"); exit; } } // // Display the page // include "template.php"; ?>