config.php 22 KB

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