#-----------------------------------------------------------------> # Version: $Id: index.php3,v 1.26 2004/08/16 08:29:49 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. # #-----------------------------------------------------------------> require("./lib/phplib/template.inc"); #include("./lib/lib_session.php3"); #page_open(array("sess" => "My_Session")); # # initialize the templates, and return a template object # function init_templates() { global $language, $start_script_t, $start_script, $HTTP_GET_VARS, $date; global $admin_link, $add_link, $update_link, $sug_category, $top_links; global $new_links, $upd_links, $linkbackurl; # dynamic template selection: $language = ""; $start_script_t = $start_script."?"; if (isset ($HTTP_GET_VARS["tmpl"])) { if (ereg("[a-zA-Z0-9]+", $HTTP_GET_VARS["tmpl"], $ma)) { if (is_dir("./templates/$ma[0]")) { $language = $ma[0]; $start_script_t = $start_script."?tmpl=".$ma[0]."&"; } } } $admin_link=$start_script_t."mode=admin"; $add_link=$start_script_t."mode=add_link"; $update_link=$start_script_t."mode=update_link"; $sug_category=$start_script_t."mode=add_category"; $top_links=$start_script_t."category=top_links"; $new_links=$start_script_t."category=new_links"; $upd_links=$start_script_t."category=upd_links"; # Declare a new FastTemplates object and pass it the # path to our templates. $tpl = new Template("./templates/$language", "remove"); # This defines the HTML templates. Currently there is only one. $tpl->set_file( array( "start" => "main.tpl", "link" => "link.tpl", "moredetails" => "details.tpl", "messages" => "messages.tpl", "prevnext" => "prevnext.tpl", "subtitle" => "subtitle.tpl", "category_main" => "category_main.tpl", "category" => "category.tpl" ) ); # extract the block named "link_row" from "link", creating a # reference to {link_rows} in "link". $tpl->set_block("link", "link_row", "link_rows"); # This is default data for use with the HTML templates $tpl->set_var( array( "RELEASE" => "v1.0.2", "HOME_LINK" => $linkbackurl, "ADMIN_LINK" => $admin_link, "ADD_LINK" => $add_link, "SUG_CATEGORY" => $sug_category, "UPDATE_LINK" => $update_link, "TOP_LINKS" => $top_links, "NEW_LINKS" => $new_links, "UPD_LINKS" => $upd_links, "START_SCRIPT" => $start_script, "START_SCRIPT_T" => $start_script_t, "DATE" => $date, "ACTION" => $start_script, "CATEGORY_TITLE" => "", "ACTION_ADMIN" => $start_script_t."mode=admin", "CALENDAR" => $calendar, "MONTH" => $changemonth ) ); return $tpl; } require("./config.php3"); # # 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, "CALENDAR" => $calendar, "MONTH" => $changemonth )); 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 "