# 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.php"); global $tpl, $allow, $_GET, $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $admin_username, $admin_password,$add_link,$sug_category; global $config; DatabaseConnect(); if (isset ($_GET["mode"])) { if ($_GET["mode"] == 'search') { include("./lib/lib_search.php"); } else if ($HTTP_POST_VARS["sorry_go_back"] != '') { showMainPage(); } else if (eregi("(add_link|update_link|add_category)",$_GET["mode"])) { include("./lib/lib_addupdate.php"); } else if ($_GET["mode"] == 'admin') { include("./lib/lib_admin.php"); } else { showMainPage(); } } else if(isset ($_GET["count"])) { countIt($_GET["count"]); } else if (isset ($_GET["category"])) { # Get the content before showing the webpage if ($_GET["category"] == 'top_links') { $your_current_location = Message("top_links"); $category_links=Top_Hits($config["sp_max_top_links"]); } else if ($_GET["category"] == 'new_links') { $your_current_location = Message("new_links"); $category_links=Newly_Added($config["sp_max_new_links"]); } else if ($_GET["category"] == 'upd_links') { $your_current_location = Message("upd_links"); $category_links=Newly_Updated($config["sp_max_upd_links"]); } else { $categories = viewPage($_GET["category"]); $your_current_location = display_category($_GET["category"]); $category_links = display_category_links($_GET["category"], $_GET["view"]); } # Sets a few variables before we parse the HTML template $tpl->set_var( array( "ADD_LINK" => "$add_link"."&category=$_GET[category]", "SUG_CATEGORY" => "$sug_category"."&category=$_GET[category]", "SUB_CATEGORIES" => $categories, "CATEGORY_LINKS" => $category_links, "INFO" => $your_current_location )); showStartTemplate(); } 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(); ?>