# Edit me to point to the config.php3 on your PC. include "config.php3"; #-----------------------------------------------------------------> # Version: $Id: index.php3,v 1.21 2003/08/06 06:33:45 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; # Do not report uninitialized variables error_reporting (E_ERROR | E_WARNING | E_PARSE); #error_reporting(E_ALL); # Disable magic_quotes_runtime set_magic_quotes_runtime(0); $categories = ""; if( !get_magic_quotes_gpc() ) { if( is_array($HTTP_GET_VARS) ) { while( list($k, $v) = each($HTTP_GET_VARS) ) { if( is_array($HTTP_GET_VARS[$k]) ) { while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) ) { $HTTP_GET_VARS[$k][$k2] = addslashes($v2); } @reset($HTTP_GET_VARS[$k]); } else { $HTTP_GET_VARS[$k] = addslashes($v); } } @reset($HTTP_GET_VARS); } if( is_array($HTTP_POST_VARS) ) { while( list($k, $v) = each($HTTP_POST_VARS) ) { if( is_array($HTTP_POST_VARS[$k]) ) { while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) ) { $HTTP_POST_VARS[$k][$k2] = addslashes($v2); } @reset($HTTP_POST_VARS[$k]); } else { $HTTP_POST_VARS[$k] = addslashes($v); } } @reset($HTTP_POST_VARS); } if( is_array($HTTP_COOKIE_VARS) ) { while( list($k, $v) = each($HTTP_COOKIE_VARS) ) { if( is_array($HTTP_COOKIE_VARS[$k]) ) { while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) ) { $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2); } @reset($HTTP_COOKIE_VARS[$k]); } else { $HTTP_COOKIE_VARS[$k] = addslashes($v); } } @reset($HTTP_COOKIE_VARS); } } DatabaseConnect(); if (isset ($HTTP_GET_VARS["mode"])) { if ($HTTP_GET_VARS["mode"] == 'search') { include("./lib/lib_search.php3"); } else if (isset($HTTP_POST_VARS["sorry_go_back"]) && $HTTP_POST_VARS["sorry_go_back"] != '') { showMainPage(); } 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_rdf.php3"); include("./lib/lib_admin.php3"); } else { showMainPage(); } } else if(isset ($HTTP_GET_VARS["count"])) { countIt($HTTP_GET_VARS["count"]); } else if (isset ($HTTP_GET_VARS["category"]) || isset ($HTTP_GET_VARS["more"]) ) { # Get the content before showing the webpage if (isset($HTTP_GET_VARS["category"]) && $HTTP_GET_VARS["category"] == 'top_links') { $your_current_location = Message("top_links"); $category_links=Top_Hits($config["sp_max_top_links"]); } else if (isset($HTTP_GET_VARS["category"]) && $HTTP_GET_VARS["category"] == 'new_links') { $your_current_location = Message("new_links"); $category_links=Newly_Added($config["sp_max_new_links"]); } else if (isset($HTTP_GET_VARS["category"]) && $HTTP_GET_VARS["category"] == 'upd_links') { $your_current_location = Message("upd_links"); $category_links=Newly_Updated($config["sp_max_upd_links"]); } else if (isset ($HTTP_GET_VARS["more"])) { $your_current_location = Message("details"); $category_links = showMore($HTTP_GET_VARS["more"], $your_current_location); } 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"]); } # remove html tags (useful for headings, title) $your_current_location2 = ereg_replace("<[^>]+>", "", $your_current_location); # 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, "HEAD_INFO" => $your_current_location2, "INFO" => $your_current_location )); showStartTemplate(); } else { showMainPage(); } } # End Main Function function DatabaseConnect() { global $database, $host, $username, $password, $config, $mylink; if ($config["use_pconnect"] == 1) { $mylink = mysql_pconnect( $host, $username, $password); } else { $mylink = mysql_connect( $host, $username, $password); } if (!$mylink) { print "