config.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?php
  2. /*
  3. ----------------------------------------------------------------------------------
  4. PhpDig Version 1.8.x - See the config file for the full version number.
  5. This program is provided WITHOUT warranty under the GNU/GPL license.
  6. See the LICENSE file for more information about the GNU/GPL license.
  7. Contributors are listed in the CREDITS and CHANGELOG files in this package.
  8. Developer from inception to and including PhpDig v.1.6.2: Antoine Bajolet
  9. Developer from PhpDig v.1.6.3 to and including current version: Charter
  10. Copyright (C) 2001 - 2003, Antoine Bajolet, http://www.toiletoine.net/
  11. Copyright (C) 2003 - current, Charter, http://www.phpdig.net/
  12. Contributors hold Copyright (C) to their code submissions.
  13. Do NOT edit or remove this copyright or licence information upon redistribution.
  14. If you modify code and redistribute, you may ADD your copyright to this notice.
  15. ----------------------------------------------------------------------------------
  16. */
  17. //---------DEFAULT VALUES
  18. // error_reporting(E_ALL);
  19. // @ini_set('error_reporting',E_ALL);
  20. //-------------CONFIGURATION FILE-------
  21. //-------------PHP DIG------------------
  22. // NOTE: If you want a different path, you need to add that path (relative path up to the
  23. // admin directory: ../dir or full path up to the admin directory: /full/path/to/dir) in
  24. // the first if statement in this config.php file - for example:
  25. // && ($relative_script_path != "../dir") // relative path
  26. // && ($relative_script_path != "/full/path/to/dir") // full path
  27. // You may also need to set $relative_script_path to this path in search.php, clickstats.php,
  28. // and function_phpdig_form.php depending on what files you are calling from where
  29. // NOTE: double dot means go back one and single dot means stay in same directory
  30. // NOTE: the path should be UP TO but NOT INCLUDING the admin directory - NO ending slash
  31. /***** Example
  32. * PhpDig installed at: http://www.domain.com/phpdig/
  33. * Want search page at: http://www.domain.com/search.php
  34. * Copy http://www.domain.com/phpdig/search.php to http://www.domain.com/search.php
  35. * Copy http://www.domain.com/phpdig/clickstats.php to http://www.domain.com/clickstats.php
  36. * Set $relative_script_path = './phpdig'; in search.php, clickstats.php, and function_phpdig_form.php
  37. * Add ($relative_script_path != "./phpdig") && to if statement
  38. *****/
  39. define('ABSOLUTE_SCRIPT_PATH','/full/path/to/dir'); // full path up to but not including admin dir, no end slash
  40. if ((!isset($relative_script_path)) || (($relative_script_path != ".") &&
  41. ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH))) {
  42. // echo "\n\nPath $relative_script_path not recognized!\n\n";
  43. exit();
  44. }
  45. // NOTE: If you receive an "undefined index" message that means that your server is not recognizing
  46. // one or some of the $_SERVER variables so check your PHP info and set the $_SERVER variables to
  47. // those recognized by your server: See http://www.php.net/reserved.variables for a list
  48. // If using RSS (config vars below) there are $_SERVER variables in the custom_search_page.php file too
  49. if ((isset($_SERVER['SCRIPT_FILENAME'])) && (eregi("config.php",$_SERVER['SCRIPT_FILENAME']))) {
  50. exit();
  51. }
  52. if ((isset($_SERVER['SCRIPT_URI'])) && (eregi("config.php",$_SERVER['SCRIPT_URI']))) {
  53. exit();
  54. }
  55. if ((isset($_SERVER['SCRIPT_URL'])) && (eregi("config.php",$_SERVER['SCRIPT_URL']))) {
  56. exit();
  57. }
  58. if ((isset($_SERVER['REQUEST_URI'])) && (eregi("config.php",$_SERVER['REQUEST_URI']))) {
  59. exit();
  60. }
  61. if ((isset($_SERVER['SCRIPT_NAME'])) && (eregi("config.php",$_SERVER['SCRIPT_NAME']))) {
  62. exit();
  63. }
  64. if ((isset($_SERVER['PATH_TRANSLATED'])) && (eregi("config.php",$_SERVER['PATH_TRANSLATED']))) {
  65. exit();
  66. }
  67. $self = api_get_self();
  68. if ((isset($self)) && (eregi('config.php',$self))) {
  69. exit();
  70. }
  71. define('PHPDIG_VERSION','1.8.6');
  72. $phpdig_language = "en"; // ca, cs, da, de, en, es, fr, gr, it, nl, no, pt
  73. if (!isset($phpdig_language)) { $phpdig_language = "en"; }
  74. define('PHPDIG_ADM_AUTH','1'); //Activates/deactivates the authentification functions
  75. define('PHPDIG_ADM_USER','admin'); //Username
  76. define('PHPDIG_ADM_PASS','secret');
  77. // template file and style - checks to see that template is set to a valid value
  78. if (isset($_REQUEST['template_demo'])) { $template_demo = $_REQUEST['template_demo']; }
  79. $templates_array = array('black.html','bluegrey.html','corporate.html','green.html','grey.html','lightgreen.html','linear.html','newspaper.html','phpdig.html','simple.html','terminal.html','yellow.html','gaagle.html');
  80. if(isset($template_demo) && in_array($template_demo, $templates_array)) {
  81. $template = "$relative_script_path/templates/$template_demo";
  82. } else {
  83. $template = "$relative_script_path/templates/phpdig.html";
  84. }
  85. $template = "array"; // RH: overrides the above
  86. // template file and style - alternatively force the template value
  87. // $template = "$relative_script_path/templates/phpdig.html";
  88. // if using array, set $template = "array";
  89. // if using classic, set $template = "classic";
  90. // now set $template_demo to clean $template filename or empty string
  91. if (($template != "array") && ($template != "classic")) {
  92. $template_demo = substr($template,strrpos($template,"/")+1); // get filename.ext from $template variable
  93. } else {
  94. $template_demo = "";
  95. }
  96. define('HIGHLIGHT_BACKGROUND','#FFBB00'); //Highlighting background color
  97. //Only for classic mode
  98. define('HIGHLIGHT_COLOR','#000000'); //Highlighting text color
  99. //Only for classic mode
  100. define('LINK_TARGET','_blank'); //Target for result links
  101. define('WEIGHT_IMGSRC','./tpl_img/weight.gif'); //Baragraph image path
  102. define('WEIGHT_HEIGHT','5'); //Baragraph height
  103. define('WEIGHT_WIDTH','50'); //Max baragraph width
  104. define('SEARCH_PAGE','search.php'); //The name of the search page
  105. define('DISPLAY_DROPDOWN',true); //Display dropdown on search page
  106. define('DROPDOWN_URLS',true); //Always URLs in dropdown: DISPLAY_DROPDOWN needs to be true
  107. define('SUMMARY_DISPLAY_LENGTH',700); // RH: was 150 //Max chars displayed in summary
  108. define('SNIPPET_DISPLAY_LENGTH',150); //Max chars displayed in each snippet
  109. define('DISPLAY_SNIPPETS',true); //Display text snippets
  110. define('DISPLAY_SNIPPETS_NUM',4); //Max snippets to display
  111. define('DISPLAY_SUMMARY',false); //Display description
  112. define('PHPDIG_DATE_FORMAT','\1-\2-\3'); // Date format for last update
  113. // \1 is year, \2 month and \3 day
  114. // if using rss, use date format \1-\2-\3
  115. define("END_OF_LINE_MARKER","\r\n"); // End of line marker - keep double quotes
  116. define('SEARCH_BOX_SIZE',15); // Search box size
  117. define('SEARCH_BOX_MAXLENGTH',50); // Search box maxlength
  118. //define('PHPDIG_ENCODING','iso-8859-1'); // encoding for interface, search and indexing.
  119. define('PHPDIG_ENCODING', strtolower($charset));
  120. // iso-8859-1, iso-8859-2, iso-8859-7, tis-620,
  121. // and windows-1251 supported in this version.
  122. // replace/edit phpdig_string_subst/phpdig_words_chars for encodings as needed
  123. // note: you may need to alter table keywords modify keyword varchar(64) binary; for certain encodings
  124. $phpdig_string_subst['iso-8859-1'] = 'A:������,a:������,O:������,o:������,E:����,e:����,C:�,c:�,I:����,i:����,U:����,u:����,Y:�,y:��,N:�,n:�';
  125. $phpdig_string_subst['iso-8859-2'] = 'A:���á,C:���,D:��,E:����,I:��,L:ť�,N:��,O:����,R:��,S:���,T:ޫ,U:����,Y:�,Z:���,a:����,c:���,d:��,e:����,i:��,l:嵳,n:��,o:����,r:��,s:���,t:��,u:����,y:�,z:���';
  126. $phpdig_string_subst['iso-8859-6'] = 'Q:Q,q:q';
  127. //$phpdig_string_subst['iso-8859-7'] = '�:��,�:�,�:�,�:�,�:�,�:��,�:�';
  128. $phpdig_string_subst['iso-8859-7'] = '�:���,�:�,�:�,�:�,�:Ÿ�,�:�,�:�ǹ,�:�,�:��ɺ,�:�,�:�,�:�,�:�,�:�,�:��,�:�,�:�,�:��,�:�,�:��վ,�:�,�:�,�:�,�:�ٿ';
  129. $phpdig_string_subst['tis-620'] = 'Q:Q,q:q';
  130. $phpdig_string_subst['windows-1251'] = '�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�,�:�';
  131. $phpdig_words_chars['iso-8859-1'] = '[:alnum:]��ߵ';
  132. $phpdig_words_chars['iso-8859-2'] = '[:alnum:]��ߵ';
  133. $phpdig_words_chars['iso-8859-6'] = '[:alnum:]�������������������������������������������������';
  134. $phpdig_words_chars['iso-8859-7'] = '[:alnum:]�����������������������٢�������������������������������������������';
  135. $phpdig_words_chars['tis-620'] = '[:alnum:]������������_���������������������������������������������������������������������������';
  136. $phpdig_words_chars['windows-1251'] = '[:alnum:]����������������������������������������������������������������';
  137. // start is AND OPERATOR, exact is EXACT PHRASE, and any is OR OPERATOR
  138. define('SEARCH_DEFAULT_MODE','start'); // default search mode (start|exact|any)
  139. // in language pack make the appropriate changes to 'w_begin', 'w_whole', and 'w_part'
  140. // 'w_begin' => 'and operator', 'w_whole' => 'exact phrase', 'w_part' => 'or operator'
  141. define('SEARCH_DEFAULT_LIMIT',10); //results per page
  142. define('SPIDER_MAX_LIMIT',20); //max recurse levels in spider
  143. define('RESPIDER_LIMIT',5); //recurse respider limit for update
  144. define('LINKS_MAX_LIMIT',20); //max links per each level
  145. define('RELINKS_LIMIT',5); //recurse links limit for an update
  146. //for limit to directory, URL format must either have file at end or ending slash at end
  147. //e.g., http://www.domain.com/dirs/ (WITH ending slash) or http://www.domain.com/dirs/dirs/index.php
  148. define('LIMIT_TO_DIRECTORY',true); //limit index to given (sub)directory, no sub dirs of dirs are indexed
  149. define('LIMIT_DAYS',0); //default days before reindex a page
  150. define('SMALL_WORDS_SIZE',2); //words to not index - must be 2 or more
  151. define('MAX_WORDS_SIZE',50); // RH: was 30 //max word size
  152. define('PHPDIG_EXCLUDE_COMMENT','<!-- phpdigExclude -->'); //comment to exclude a page part
  153. define('PHPDIG_INCLUDE_COMMENT','<!-- phpdigInclude -->'); //comment to include a page part
  154. // must be on own lines in HTML source
  155. // text within comments not indexed
  156. // links within comments still indexed
  157. define('PHPDIG_DEFAULT_INDEX',false); //phpDig considers /index or /default
  158. //html, htm, php, asp, phtml as the
  159. //same as '/'
  160. define('ALLOW_RSS_FEED',false); // Do RSS and display link - if true, set rss dir to 777
  161. $theenc = PHPDIG_ENCODING; // needs to be same encoding used in index
  162. $theurl = "http://www.phpdig.net/"; // site offering the RSS feed
  163. $thetitle = "PhpDig.net"; // title for site offering the RSS feed
  164. $thedesc = "PhpDig :: Web Spider and Search Engine"; // description of site offering the RSS feed
  165. $thedir = "./rss"; // the rss directory name, no ending slash
  166. $thefile = "search.rss"; // used in rss filenames
  167. define('PHPDIG_SESSID_REMOVE',true); // remove SIDS or vars from indexed URLS
  168. define('PHPDIG_SESSID_VAR','PHPSESSID,s'); // name of SID or variable to remove
  169. // can be 's' or comma delimited 's,id,var,foo,etc'
  170. define('APPEND_TITLE_META',false); //append title and meta information to results
  171. define('TITLE_WEIGHT',3); //relative title weight: APPEND_TITLE_META needs to be true
  172. define('CHUNK_SIZE',1024); //chunk size for regex processing
  173. define('SUMMARY_LENGTH',500); //length of results summary
  174. define('TEXT_CONTENT_PATH','text_content/'); //Text content files path
  175. define('CONTENT_TEXT',0); // RH: was 1 //Activates/deactivates the
  176. //storage of text content.
  177. define('PHPDIG_IN_DOMAIN',false); //allows phpdig jump hosts in the same
  178. //domain. If the host is "www.mydomain.tld",
  179. //domain is "mydomain.tld"
  180. define('PHPDIG_LOGS',true); //write logs
  181. define('SILENCE_404S',true); //silence 404 output
  182. define('TEMP_FILENAME_LENGTH',8); //filename length of temp files
  183. // if using external tools with extension, use 4 for filename of length 8
  184. define('NUMBER_OF_RESULTS_PER_SITE',-1); //max number of results per site
  185. // use -1 to display all results
  186. define('USE_RENICE_COMMAND','1'); //use renice for process priority
  187. //---------EXTERNAL TOOLS SETUP
  188. // if set to true is_executable used - set to '0' if is_executable is undefined
  189. define('USE_IS_EXECUTABLE_COMMAND','0'); // RH: was 1 //use is_executable for external binaries
  190. // if set to true, full path to external binary required
  191. define('PHPDIG_INDEX_MSWORD',false);
  192. define('PHPDIG_PARSE_MSWORD','/usr/local/bin/catdoc');
  193. define('PHPDIG_OPTION_MSWORD','-s 8859-1');
  194. define('PHPDIG_INDEX_PDF',false);
  195. define('PHPDIG_PARSE_PDF','/usr/local/bin/pstotext');
  196. define('PHPDIG_OPTION_PDF','-cork');
  197. define('PHPDIG_INDEX_MSEXCEL',false);
  198. define('PHPDIG_PARSE_MSEXCEL','/usr/local/bin/xls2csv');
  199. define('PHPDIG_OPTION_MSEXCEL','');
  200. define('PHPDIG_INDEX_MSPOWERPOINT',false);
  201. define('PHPDIG_PARSE_MSPOWERPOINT','/usr/local/bin/ppt2text');
  202. define('PHPDIG_OPTION_MSPOWERPOINT','');
  203. //---------EXTERNAL TOOLS EXTENSIONS
  204. // if external binary is not STDOUT or different extension is needed
  205. // for example, use '.txt' if external binary writes to filename.txt
  206. define('PHPDIG_MSWORD_EXTENSION','');
  207. define('PHPDIG_PDF_EXTENSION','');
  208. define('PHPDIG_MSEXCEL_EXTENSION','');
  209. define('PHPDIG_MSPOWERPOINT_EXTENSION','');
  210. //---------FTP SETTINGS
  211. define('FTP_ENABLE',0);//enable ftp content for distant PhpDig
  212. define('FTP_HOST','<ftp host>'); //if distant PhpDig, ftp host;
  213. define('FTP_PORT',21); //ftp port
  214. define('FTP_PASV',1); //passive mode
  215. define('FTP_PATH','<path to phpdig directory>'); //distant path from the ftp root
  216. define('FTP_TEXT_PATH','text_content');//ftp path to text-content directory
  217. define('FTP_USER','<ftp usename>');
  218. define('FTP_PASS','<ftp password>');
  219. //--------CRON SETTINGS
  220. define('CRON_ENABLE',false);
  221. define('CRON_EXEC_FILE','/usr/bin/crontab');
  222. define('CRON_CONFIG_FILE',ABSOLUTE_SCRIPT_PATH.'/admin/temp/cronfile.txt');
  223. define('PHPEXEC','/usr/local/bin/php');
  224. // NOTE: make sure ABSOLUTE_SCRIPT_PATH is the full path up to but not including the admin dir, no ending slash
  225. // NOTE: CRON_ENABLE set to true writes a file at CRON_CONFIG_FILE containing the cron job information
  226. // The CRON_CONFIG_FILE must be 777 permissions if applicable to your OS/setup
  227. // You still need to call the CRON_CONFIG_FILE to run the cron job!!!
  228. // From shell: crontab CRON_CONFIG_FILE to set the cron job: replace CRON_CONFIG_FILE with actual file
  229. // From shell: crontab -l to list and crontab -d to delete
  230. // regular expression to ban useless external links in index
  231. define('BANNED','^ad\.|banner|doubleclick');
  232. // regexp forbidden extensions - return sometimes text/html mime-type !!!
  233. define('FORBIDDEN_EXTENSIONS','\.(rm|ico|cab|swf|css|gz|z|tar|zip|tgz|msi|arj|zoo|rar|r[0-9]+|exe|bin|pkg|rpm|deb|bz2)$');
  234. //----------HTML ENTITIES
  235. $spec = array( "&amp" => "&",
  236. "&agrave" => "�",
  237. "&egrave" => "�",
  238. "&ugrave" => "�",
  239. "&oacute;" => "�",
  240. "&eacute" => "�",
  241. "&icirc" => "�",
  242. "&ocirc" => "�",
  243. "&ucirc" => "�",
  244. "&ecirc" => "�",
  245. "&ccedil" => "�",
  246. "&#156" => "oe",
  247. "&gt" => " ",
  248. "&lt" => " ",
  249. "&deg" => " ",
  250. "&apos" => "'",
  251. "&quot" => " ",
  252. "&acirc" => "�",
  253. "&iuml" => "�",
  254. "&euml" => "�",
  255. "&auml" => "�",
  256. "&Auml" => "�",
  257. "&Euml" => "�",
  258. "&Iuml" => "�",
  259. "&Uuml" => "�",
  260. "&ouml" => "�",
  261. "&uuml" => "�",
  262. "&nbsp" => " ",
  263. "&szlig" => "�",
  264. "&iacute" => "�",
  265. "&reg" => " ",
  266. "&copy" => " ",
  267. "&aacute" => "�",
  268. "&Aacute" => "�",
  269. "&eth" => "�",
  270. "&ETH" => "�",
  271. "&Eacute" => "�",
  272. "&Iacute" => "�",
  273. "&Oacute" => "�",
  274. "&uacute" => "�",
  275. "&Uacute" => "�",
  276. "&THORN" => "�",
  277. "&thorn" => "�",
  278. "&Ouml" => "�",
  279. "&aelig" => "�",
  280. "&AELIG" => "�",
  281. "&aring" => "�",
  282. "&Aring" => "�",
  283. "&oslash" => "�",
  284. "&Oslash" => "�"
  285. );
  286. //month names in iso dates
  287. $month_names = array ('jan'=>1,
  288. 'feb'=>2,
  289. 'mar'=>3,
  290. 'apr'=>4,
  291. 'may'=>5,
  292. 'jun'=>6,
  293. 'jul'=>7,
  294. 'aug'=>8,
  295. 'sep'=>9,
  296. 'oct'=>10,
  297. 'nov'=>11,
  298. 'dec'=>12
  299. );
  300. //apache multi indexes parameters
  301. $apache_indexes = array ( "?N=A" => 1,
  302. "?N=D" => 1,
  303. "?M=A" => 1,
  304. "?M=D" => 1,
  305. "?S=A" => 1,
  306. "?S=D" => 1,
  307. "?D=A" => 1,
  308. "?D=D" => 1,
  309. "?C=N&amp;O=A" => 1,
  310. "?C=M&amp;O=A" => 1,
  311. "?C=S&amp;O=A" => 1,
  312. "?C=D&amp;O=A" => 1,
  313. "?C=N&amp;O=D" => 1,
  314. "?C=M&amp;O=D" => 1,
  315. "?C=S&amp;O=D" => 1,
  316. "?C=D&amp;O=D" => 1);
  317. //includes language file
  318. define('PHPDIG_LANG_CONSTANT',$phpdig_language); // this line for classic
  319. if (is_file("$relative_script_path/locales/$phpdig_language-language.php")) {
  320. include "$relative_script_path/locales/$phpdig_language-language.php";
  321. }
  322. elseif (is_file("$relative_script_path/locales/en-language.php")) {
  323. include "$relative_script_path/locales/en-language.php";
  324. }
  325. else {
  326. die("Unable to select language pack.\n");
  327. }
  328. //connection to database
  329. if ((!isset($no_connect)) || ($no_connect != 1)) {
  330. if (is_file("$relative_script_path/includes/connect.php")) {
  331. include "$relative_script_path/includes/connect.php";
  332. }
  333. else {
  334. die("Unable to find connect.php file.\n");
  335. }
  336. }
  337. //includes of libraries
  338. if (is_file("$relative_script_path/libs/phpdig_functions.php")) {
  339. include "$relative_script_path/libs/phpdig_functions.php";
  340. }
  341. else {
  342. die ("Unable to find phpdig_functions.php file.\n");
  343. }
  344. if (is_file("$relative_script_path/libs/function_phpdig_form.php")) {
  345. include "$relative_script_path/libs/function_phpdig_form.php";
  346. }
  347. else {
  348. die ("Unable to find function_phpdig_form.php file.\n");
  349. }
  350. if (is_file("$relative_script_path/libs/mysql_functions.php")) {
  351. include "$relative_script_path/libs/mysql_functions.php";
  352. }
  353. else {
  354. die ("Unable to find mysql_functions.php file.\n");
  355. }
  356. if ((!isset($template)) || ((!is_file($template)) && ($template != "array") && ($template != "classic"))) {
  357. die ("Unable to render template file.\n");
  358. }
  359. if (!defined('CONFIG_CHECK')) {
  360. exit();
  361. }
  362. // parse encodings (create global $phpdigEncode);
  363. phpdigCreateSubstArrays($phpdig_string_subst);
  364. // send encoding if needed
  365. if (!headers_sent()) {
  366. header('Content-type:text/html; Charset='.PHPDIG_ENCODING);
  367. }
  368. // turn off magic_quotes_runtime for escaping purposes
  369. @ini_set('magic_quotes_runtime',false);
  370. // turn off magic_quotes_sybase for escaping purposes
  371. @ini_set('magic_quotes_sybase',false);
  372. if ((!isset($no_connect)) || ($no_connect != 1)) {
  373. phpdigCheckTables($id_connect,array('engine',
  374. 'excludes',
  375. 'keywords',
  376. 'sites',
  377. 'spider',
  378. 'tempspider',
  379. 'logs',
  380. 'clicks',
  381. 'site_page',
  382. 'includes'));
  383. }
  384. ?>