Advertisement
Guest User

Untitled

a guest
Sep 30th, 2010
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.90 KB | None | 0 0
  1. <?php
  2. /*******************************************
  3. * Sphider Version 1.3.x
  4. * Moded by Soul / Ljuska.org 2010
  5. * This program is licensed under the GNU GPL.
  6. * By Ando Saabas          ando(a t)cs.ioc.ee
  7. ********************************************/
  8. //error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
  9. error_reporting(E_ALL);
  10. $include_dir = "./include";
  11. include ("$include_dir/commonfuncs.php");
  12. //extract(getHttpVars());
  13.  
  14. if (isset($_GET['query']))
  15.     $query = $_GET['query'];
  16. if (isset($_GET['search']))
  17.     $search = $_GET['search'];
  18. if (isset($_GET['domain']))
  19.     $domain = $_GET['domain'];
  20. if (isset($_GET['type']))
  21.     $type = $_GET['type'];
  22. if (isset($_GET['catid']))
  23.     $catid = $_GET['catid'];
  24. if (isset($_GET['category']))
  25.     $category = $_GET['category'];
  26. if (isset($_GET['results']))
  27.     $results = $_GET['results'];
  28. if (isset($_GET['start']))
  29.     $start = $_GET['start'];
  30. if (isset($_GET['adv']))
  31.     $adv = $_GET['adv'];
  32.    
  33.    
  34. $include_dir = "./include";
  35. $template_dir = "./templates";
  36. $settings_dir = "./settings";
  37. $language_dir = "./languages";
  38.  
  39.  
  40. require_once("$settings_dir/database.php");
  41. require_once("$language_dir/en-language.php");
  42. require_once("$include_dir/searchfuncs.php");
  43. require_once("$include_dir/categoryfuncs.php");
  44.  
  45.  
  46. include "$settings_dir/conf.php";
  47.  
  48. include "$template_dir/$template/header.html";
  49. include "$language_dir/$language-language.php";
  50.  
  51.  
  52. if ($type != "or" && $type != "and" && $type != "phrase") {
  53.     $type = "and";
  54. }
  55.  
  56. if (preg_match("/[^a-z0-9-.]+/", $domain)) {
  57.     $domain="";
  58. }
  59.  
  60.  
  61. if ($results != "") {
  62.     $results_per_page = $results;
  63. }
  64.  
  65. if (get_magic_quotes_gpc()==1) {
  66.     $query = stripslashes($query);
  67. }
  68.  
  69. if (!is_numeric($catid)) {
  70.     $catid = "";
  71. }
  72.  
  73. if (!is_numeric($category)) {
  74.     $category = "";
  75. }
  76.  
  77.  
  78.  
  79. if ($catid && is_numeric($catid)) {
  80.  
  81.     $tpl_['category'] = sql_fetch_all('SELECT category FROM '.$mysql_table_prefix.'categories WHERE category_id='.(int)$_REQUEST['catid']);
  82. }
  83.    
  84. $count_level0 = sql_fetch_all('SELECT count(*) FROM '.$mysql_table_prefix.'categories WHERE parent_num=0');
  85. $has_categories = 0;
  86.  
  87. if ($count_level0) {
  88.     $has_categories = $count_level0[0][0];
  89. }
  90.  
  91.  
  92.  
  93. require_once("$template_dir/$template/search_form.html");
  94.  
  95.  
  96. function getmicrotime(){
  97.     list($usec, $sec) = explode(" ",microtime());
  98.     return ((float)$usec + (float)$sec);
  99.     }
  100.  
  101. function getStatistics() {
  102. global $mysql_table_prefix;
  103. $stats = array();
  104. $keywordQuery = "select count(keyword_id) from ".$mysql_table_prefix."keywords";
  105. $linksQuery = "select count(url) from ".$mysql_table_prefix."links";
  106. $siteQuery = "select count(site_id) from ".$mysql_table_prefix."sites";
  107. $categoriesQuery = "select count(category_id) from ".$mysql_table_prefix."categories";
  108.  
  109. $result = mysql_query($keywordQuery);
  110. echo mysql_error();
  111. if ($row=mysql_fetch_array($result)) {
  112. $stats['keywords']=$row[0];
  113. }
  114. $result = mysql_query($linksQuery);
  115. echo mysql_error();
  116. if ($row=mysql_fetch_array($result)) {
  117. $stats['links']=$row[0];
  118. }
  119. for ($i=0;$i<=15; $i++) {
  120. $char = dechex($i);
  121. $result = mysql_query("select count(link_id) from ".$mysql_table_prefix."link_keyword$char");
  122. echo mysql_error();
  123. if ($row=mysql_fetch_array($result)) {
  124. $stats['index']+=$row[0];
  125. }
  126. }
  127. $result = mysql_query($siteQuery);
  128. echo mysql_error();
  129. if ($row=mysql_fetch_array($result)) {
  130. $stats['sites']=$row[0];
  131. }
  132. $result = mysql_query($categoriesQuery);
  133. echo mysql_error();
  134. if ($row=mysql_fetch_array($result)) {
  135. $stats['categories']=$row[0];
  136. }
  137. return $stats;
  138. }
  139.  
  140. function poweredby () {
  141.     global $sph_messages;
  142.     //If you want to remove this, please donate to the project at http://www.sphider.eu/donate.php
  143.     print $sph_messages[''];?>
  144.  
  145.     <?php
  146. }
  147.  
  148.  
  149. function saveToLog ($query, $elapsed, $results) {
  150.         global $mysql_table_prefix;
  151.     if ($results =="") {
  152.         $results = 0;
  153.     }
  154.     $query =  "insert into ".$mysql_table_prefix."query_log (query, time, elapsed, results) values ('$query', now(), '$elapsed', '$results')";
  155.     mysql_query($query);
  156.                    
  157.     echo mysql_error();
  158.                        
  159. }
  160.  
  161. switch ($search) {
  162.     case 1:
  163.  
  164.         if (!isset($results)) {
  165.             $results = "";
  166.         }
  167.         $search_results = get_search_results($query, $start, $category, $type, $results, $domain);
  168.         require("$template_dir/$template/search_results.html");
  169.     break;
  170.     default:
  171.         if ($show_categories) {
  172.             if ($_REQUEST['catid']  && is_numeric($catid)) {
  173.                 $cat_info = get_category_info($catid);
  174.             } else {
  175.                 $cat_info = get_categories_view();
  176.             }
  177.             require("$template_dir/$template/categories.html");
  178.         }
  179.     break;
  180.     }
  181.  
  182. include "$template_dir/$template/footer.html";
  183. ?>
  184. <html><center><b><?php
  185. $stats = getStatistics();
  186. print "<br/>    <center><p>Currently in database: ".$stats['sites']." providers, ".$stats['links']." songs, ".$stats['categories']." categories and ".$stats['keywords']." keywords.</p></center>\n";
  187. ?></b></center></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement