# Version: $Id: index.php3,v 1.16 2001/11/14 23:02:46 ldrolez Exp $ # Website: http://mythreads.sourceforge.net # # Desc: Main script for maintaining a links database # # # License: This code is released under the terms of the GNU GPL # version 2 or later. Please refer to www.gnu.org for a copy # of this license. # #-----------------------------------------------------------------> # main() : This function controls the script functions. function main() { include("./lib/lib_main.php3"); global $tpl, $allow, $HTTP_GET_VARS, $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $admin_username, $admin_password,$add_link,$sug_category; global $config; DatabaseConnect(); if (isset ($HTTP_GET_VARS["mode"])) { if ($HTTP_GET_VARS["mode"] == 'search') { include("./lib/lib_search.php3"); } else if ($HTTP_POST_VARS["sorry_go_back"] != '') { include(HEADER); showMainPage(); include(FOOTER); } else if (eregi("(add_link|update_link|add_category)",$HTTP_GET_VARS["mode"])) { include("./lib/lib_addupdate.php3"); } else if ($HTTP_GET_VARS["mode"] == 'admin') { include("./lib/lib_admin.php3"); } else { include(HEADER); showMainPage(); include(FOOTER); } } else if(isset ($HTTP_GET_VARS["count"])) { countIt($HTTP_GET_VARS["count"]); } else if (isset ($HTTP_GET_VARS["category"])) { # Get the content before showing the webpage if ($HTTP_GET_VARS["category"] == 'top_links') { $your_current_location = Message("top_links"); $category_links=Top_Hits($config["sp_max_top_links"]); } else if ($HTTP_GET_VARS["category"] == 'new_links') { $your_current_location = Message("new_links"); $category_links=Newly_Added($config["sp_max_new_links"]); } else if ($HTTP_GET_VARS["category"] == 'upd_links') { $your_current_location = Message("upd_links"); $category_links=Newly_Updated($config["sp_max_upd_links"]); } else { $categories = viewPage($HTTP_GET_VARS["category"]); $your_current_location = display_category($HTTP_GET_VARS["category"]); $category_links = display_category_links($HTTP_GET_VARS["category"], $HTTP_GET_VARS["view"]); } # Sets a few variables before we parse the HTML template $tpl->set_var( array( "ADD_LINK" => "$add_link"."&category=$HTTP_GET_VARS[category]", "SUG_CATEGORY" => "$sug_category"."&category=$HTTP_GET_VARS[category]", "SUB_CATEGORIES" => $categories, "CATEGORY_LINKS" => $category_links, "INFO" => $your_current_location )); include(HEADER); showStartTemplate(); include(FOOTER); } else { showMainPage(); } } # End Main Function function DatabaseConnect() { global $database, $host, $username, $password, $config; if ($config["use_pconnect"] == 1) { $mylink = mysql_pconnect( $host, $username, $password); } else { $mylink = mysql_connect( $host, $username, $password); } if (!$mylink) { print "

could not connect to database

\n"; exit; } mysql_select_db($database); } function showStartTemplate() { global $tpl; $tpl->parse("MyOutput", "start"); $tpl->p("MyOutput"); } # Call the main function which controls everything main(); ?>