0) { /* Error($closest_id); */ $page = GrabPage($closest_id); $extra_line = "

The closest related page found was {$page["name"]}

"; } else { $extra_line = ""; } $oldversion = "https://kooka.info/oldversion/$path"; $searchstr = str_replace("_", " ", $final_html); echo(<<

Insects of Townsville

The address you requested no longer exists after the upgrade of this website.

We tried to guess the corresponding page in the new version of this website, however we were unable to find a reasonable match for the URL "$path".

$extra_line

Look for this missing page on the search page.

Alternatively you might like to try from the top of this website.


The old page will be preserved at $oldversion temporarily.

For reference, the error message was: "$msg".

EOF ); die(); } function Lookup($path, $name, $table, $backup_id=-1) { $name = str_replace("_", " ", $name); $sql = "SELECT * FROM class_$table WHERE name LIKE :name"; $result = SQLCall($sql, ["name" => $name]); if($result->rowCount() == 0) { Unable("Unable to identify the $table from the URL.", $backup_id); } else if($result->rowCount() > 1) { Unable("Too many matches for the $table from the URL", $backup_id); } $out = $result->fetch(); return($out); } $path_parts = explode("/", $path); $final_html = pathinfo($path_parts[count($path_parts)-1], PATHINFO_FILENAME); $order = Lookup($path, $path_parts[0], "orders"); $page_id = "not found"; if(count($path_parts) == 2 && strcasecmp($final_html, $order["name"]) == 0) { $page_id = $order["page_id"]; } else if(count($path_parts) == 2) { $page = Lookup($path, $final_html, "species", $order["page_id"]); $page_id = $page["page_id"]; } else { // Look up one more $family = Lookup($path, $path_parts[1], "families", $order["page_id"]); if(count($path_parts) == 3 && strcasecmp($final_html, $family["name"]) == 0) { $page_id = $family["page_id"]; } else if(count($path_parts) == 3) { $page = Lookup($path, $final_html, "species", $family["page_id"]); $page_id = $page["page_id"]; } else { Unable("Can't handle so many parts to the path.", $family["page_id"]); } } if($page_id == "not found") Unable("Got to end without finding an ID"); header("Location: /tree.html?page_id=$page_id¬ifyredirect=$path", true, 301); die(); ?>