/* ----------------------------------------------------------------------------- Jade: Directory and Search Engine. Copyright (C) 2003 Ernesto Otero This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ------------------------------------------------------------------------------ Ernesto Otero - 2003/2004 email : jadephp@hotmail.com ------------------------------------------------------------------------------ */ global $jadeversion; $jadeversion["jade"] = "2.10beta"; include_once("jadevars2.inc.php"); if (isset($_GET['lang'])) { if (!file_exists($jadevars["homepath"]."/languages/".$_GET['lang'].".inc.php")) { setcookie ("lang", "", time() - 3600); } else { if (file_exists($jadevars["homepath"]."/languages/".$_GET['lang'].".inc.php")) { setcookie("lang", $_GET['lang'], time()+3600); $jadevars['language']=$_GET['lang']; } } } if (isset($_COOKIE['lang'])) { $jadevars['language']=$_COOKIE['lang']; } $langfile=$jadevars['homepath']."/languages/".$jadevars['language'].".inc.php"; include_once($langfile); // Setting a cookkie to remember templates (usefult for test) if (isset($_GET['template'])) { if (!file_exists($jadevars["homepath"]."/templates/".$_GET['template']."/top.tpl")) { setcookie ("template", "", time() - 3600); } else { if (file_exists($jadevars["homepath"]."/".$jadevars["templatedir"].$_GET['template']."/top.tpl")) { // check if selected template is correct setcookie("template", $_GET['template'], time()+3600); $jadevars['template']=$_GET['template']; } } } if (isset($_COOKIE['template'])) { $jadevars['template']=$_COOKIE['template']; } include_once($jadevars["homepath"]."/".$jadevars["templatedir"].$jadevars['template']."/tpl.info.php"); // end of cookie action if (isset($_GET['action'])) { $action=$_GET['action']; } elseif (isset($_POST['action'])) { $action=$_POST['action']; } else { $action='showmain'; } //if (empty($action) or !isset($action)) { $action=$_POST['action']; } //if (empty($action) or !isset($action)) { $action='showmain'; } switch ($action) { case 'showcat': { if (isset($_GET['idcat'])) { $idcat=$_GET['idcat']; } else { $idcat=0; } include_once($jadevars["homepath"]."/jf2_category.inc.php"); if (empty($idcat) or !isset($idcat) or !is_numeric($idcat)) { include_once($jadevars["homepath"]."/jf2_home.inc.php"); $idcat=0; print build_home(); } else { $page=$_GET['page']; if (empty($page) or !isset($page) or !is_numeric($page)) { $page=1;} print build_category($idcat,$page); } break; } case 'showdetail': { if (isset($_GET['id'])) { $id=$_GET['id']; } else { $id=0; } if (empty($id) or !isset($id) or !is_numeric($id)) { $idcat=0; print build_home(); } else { print build_detail($id); } break; } case 'jump': { if (isset($_GET['jumpto'])) { $jumpto=$_GET['jumpto']; } else { $jumpto=""; } if (isset($_GET['window'])) { $window=$_GET['window']; } else { $window=""; } //if ($window=='new') { $window = 'new'; } else { $window = 'same'; } if (is_numeric($jumpto)) { jump($jumpto, $window); } else { if (!($jadevars['dinamic'])) { //header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.shtml"); $url="http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."index.shtml"; print "click here to go to the site "; break; } print build_home(); } break; } case 'showframe': { if (isset($_GET['url'])) { $url=$_GET['url']; } if (isset($_GET['back'])) { $back=$_GET['back']; } if (isset($_GET['id'])) { $id=$_GET['id']; } //$back=$_SERVER['HTTP_REFERER']; showframe($url,$back,$id); break; } case 'brokenlink': { reportbrokenlink($_GET['id']); break; } case 'new': { include_once($jadevars["homepath"]."/jf2_new.inc.php"); print shownew(); break; } case 'favorite': { include_once($jadevars["homepath"]."/jf2_favorite.inc.php"); print showfavorite(); break; } case 'popular': { include_once($jadevars["homepath"]."/jf2_popular.inc.php"); print showPopular(); break; } case 'backlinks': { include_once($jadevars["homepath"]."/jf2_backlinks.inc.php"); print showBackLinks(); break; } case 'sow': { include_once($jadevars["homepath"]."/jf2_sow.inc.php"); print showSOW(); break; } case 'toprat': { include_once($jadevars["homepath"]."/jf2_rat.inc.php"); if ( isset($_GET['kind']) && $_GET['kind']=='usr' ) { $kind='usr'; } else { $kind='adm'; } if ( isset($_GET['stars']) && ($_GET['stars']<0 || $_GET['stars']>5 || !is_numeric($_GET['stars'])) ) { $stars=5; } else { if (isset($_GET['stars'])) { $stars = $_GET['stars']; } } print showRat($kind,$stars); break; } case 'addnew': { include_once($jadevars["homepath"]."/jf2_addnew.inc.php"); if (empty($_POST['url'])) { $url=$_GET['url']; } else { $url=$_POST['url']; } if (empty($_POST['idcat'])) { $idcat=$_GET['idcat']; } else { $idcat=$_POST['idcat']; } if (empty($idcat) or !isset($idcat)) { $idcat=$_POST['idcat'];} if (!is_numeric($idcat)) {$idcat=0;} $step=$_GET['step']; if (empty($step) or !isset($step)) { $step=$_POST['step'];} if (empty($step) or !isset($step)) { $step=0; } if (!is_numeric($step)) { $step=0; } addnewsite($idcat,$step,$url); break; } case 'suggestcat': { if (isset($_GET['idcat'])) { $idcat=$_GET['idcat']; } if (empty($idcat) or !isset($idcat)) { if (isset($_POST['idcat'])) { $idcat=$_POST['idcat']; } } if (!is_numeric($idcat)) { $idcat=0;} if (isset($_GET['step'])) { $step=$_GET['step']; } if (empty($step) or !isset($step)) { if (isset($_POST['step'])) { $step=$_POST['step']; } } if (empty($step) or !isset($step)) { $step=0;} if (!is_numeric($step)) { $step=0; } include_once($jadevars["homepath"]."/jf2_suggestcat.inc.php"); suggestcat($idcat,$step); break; } case 'tree': { include_once($jadevars["homepath"]."/jf2_tree.inc.php"); print showtree(); break; } case 'search': { if ($_POST['query']=="" AND $_SERVER['QUERY_STRING']=="") { include_once($jadevars["homepath"]."/jf2_home.inc.php"); print build_home(); break; } if (isset($_POST['query'])) { $query=$_POST['query']; } if (empty($query) or !isset($query)) { $query=rawurldecode($_GET['query']); } $query=trim($query); //$query=addslashes($query); $page=$_GET['page']; if (empty($page) or !isset($page)) { $page=1; } include_once($jadevars["homepath"]."/jf2_search.inc.php"); print showsearchresults($query,$page); break; } case 'rateit': { include_once($jadevars["homepath"]."/jf2_rateit.inc.php"); $id=$_GET['id']; if (is_numeric($id) AND $id!=0) { print rateit($id); } break; } default: { if (!($jadevars['dinamic'])) { //header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.shtml"); $url="http://".$_SERVER['HTTP_HOST']."/index.shtml"; print "click here to go to the site "; break; } include_once($jadevars["homepath"]."/jf2_home.inc.php"); print build_home(); break; } } function jump($jumpto, $window) { /*********************************************************************/ /* This function makes posible to jump to the selected link, and if */ /* the jump2frame option is on it open the new link in a page with */ /* a frame givig the user a easy way to return to your site */ /*********************************************************************/ global $jadevars; include_once($jadevars["homepath"]."/jf2_network.inc.php"); include_once($jadevars["homepath"]."/jf2_other.inc.php"); $link = mysql_connect ($jadevars['host'], $jadevars['user'], $jadevars['password']) or mydie ('I cannot connect to the database.'); mysql_select_db ($jadevars['db']) or mydie(mysql_error(),"Error opening DB on jump"); $jumpto=$jumpto+1-1; $sqlquery="SELECT * FROM jade_sites WHERE id = $jumpto"; $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); $link = mysql_fetch_array($result, MYSQL_ASSOC); $url=$link['url']; $hits=$link['numhits']+1; $title=$link['title']; mysql_free_result($result); /* Here is the anticheat option */ if ($jadevars['anticheats']==1) { /* First, delete all records. All records with date different that today */ $sqlquery="DELETE FROM jade_anticheat WHERE datelog <> NOW()"; $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); /* Verify if user (IPAddress) clicked today */ $sqlquery="SELECT * FROM jade_anticheat WHERE idsite = $jumpto AND datelog = NOW() AND ipnum = ".getIPNum(); $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); $numlinks = mysql_num_rows($result); if ($numlinks==0) { $sqlquery="INSERT INTO jade_anticheat(idsite, datelog, ipnum) VALUES(".$jumpto.", NOW(), ".getIPNum().")"; $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); $sqlquery = "UPDATE jade_sites SET numhits = ".$hits." WHERE id = $jumpto"; $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); } /* if anticheat is disabled or never enabled */ } else { $sqlquery = "UPDATE jade_sites SET numhits = ".$hits." WHERE id = $jumpto"; $result = mysql_query($sqlquery) or mydie(mysql_error(),$sqlquery); } /* end of anticheat */ if ($jadevars['jump2frame'] AND $window!='new') { ?>