Location: PHPKode > projects > PhpDig Search Engine > phpdig-1.8.8/includes/config.php
PhpDig Version 1.8.x - See the config file for the full version number.
This program is provided WITHOUT warranty under the GNU/GPL license.
See the LICENSE file for more information about the GNU/GPL license.
Contributors are listed in the CREDITS and CHANGELOG files in this package.
Developer from inception to and including PhpDig v.1.6.2: Antoine Bajolet
Developer from PhpDig v.1.6.3 to and including current version: Charter
Copyright (C) 2001 - 2003, Antoine Bajolet, http://www.toiletoine.net/
Copyright (C) 2003 - current, Charter, http://www.phpdig.net/
Contributors hold Copyright (C) to their code submissions.
Do NOT edit or remove this copyright or licence information upon redistribution.
If you modify code and redistribute, you may ADD your copyright to this notice.


// error_reporting(E_ALL);
// @ini_set('error_reporting',E_ALL);

//-------------CONFIGURATION FILE-------
//-------------PHP DIG------------------

// NOTE: If you want a different path, you need to add that path (relative path up to the 
// admin directory: ../dir or full path up to the admin directory: /full/path/to/dir) in 
// the first if statement in this config.php file - for example:
// && ($relative_script_path != "../dir") // relative path
// && ($relative_script_path != "/full/path/to/dir") // full path
// You may also need to set $relative_script_path to this path in search.php, clickstats.php, 
// and function_phpdig_form.php depending on what files you are calling from where
// NOTE: double dot means go back one and single dot means stay in same directory
// NOTE: the path should be UP TO but NOT INCLUDING the admin directory - NO ending slash
/***** Example
* PhpDig installed at: http://www.domain.com/phpdig/
* Want search page at: http://www.domain.com/search.php
* Copy http://www.domain.com/phpdig/search.php to http://www.domain.com/search.php
* Copy http://www.domain.com/phpdig/clickstats.php to http://www.domain.com/clickstats.php
* Set $relative_script_path = './phpdig'; in search.php, clickstats.php, and function_phpdig_form.php
* Add ($relative_script_path != "./phpdig") && to if statement

define('ABSOLUTE_SCRIPT_PATH','/full/path/to/dir'); // full path up to but not including admin dir, no end slash

if ((!isset($relative_script_path)) || (($relative_script_path != ".") && 
($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH))) {
  // echo "\n\nPath $relative_script_path not recognized!\n\n";

// NOTE: If you receive an "undefined index" message that means that your server is not recognizing 
// one or some of the $_SERVER variables so check your PHP info and set the $_SERVER variables to 
// those recognized by your server: See http://www.php.net/reserved.variables for a list
// If using RSS (config vars below) there are $_SERVER variables in the custom_rss.php file too

if ((isset($_SERVER['SCRIPT_FILENAME'])) && (eregi("config.php",$_SERVER['SCRIPT_FILENAME']))) {
if ((isset($_SERVER['SCRIPT_URI'])) && (eregi("config.php",$_SERVER['SCRIPT_URI']))) {
if ((isset($_SERVER['SCRIPT_URL'])) && (eregi("config.php",$_SERVER['SCRIPT_URL']))) {
if ((isset($_SERVER['REQUEST_URI'])) && (eregi("config.php",$_SERVER['REQUEST_URI']))) {
if ((isset($_SERVER['SCRIPT_NAME'])) && (eregi("config.php",$_SERVER['SCRIPT_NAME']))) {
if ((isset($_SERVER['PATH_TRANSLATED'])) && (eregi("config.php",$_SERVER['PATH_TRANSLATED']))) {
if ((isset($_SERVER['PHP_SELF'])) && (eregi("config.php",$_SERVER['PHP_SELF']))) {


$phpdig_language = "en"; // ca, cs, da, de, en, es, fr, gr, it, nl, no, pt
if (!isset($phpdig_language)) { $phpdig_language = "en"; }

define('PHPDIG_ADM_AUTH','1');     //Activates/deactivates the authentification functions
define('PHPDIG_ADM_USER','admin'); //Username
define('PHPDIG_ADM_PASS','admin'); //Password

// template file and style - checks to see that template is set to a valid value
if (isset($_REQUEST['template_demo'])) { $template_demo = $_REQUEST['template_demo']; }
$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');
if(isset($template_demo) && in_array($template_demo, $templates_array)) {
    $template = "$relative_script_path/templates/$template_demo";
} else {
    $template = "$relative_script_path/templates/phpdig.html";

// template file and style - alternatively force the template value
// $template = "$relative_script_path/templates/phpdig.html";
// if using array, set $template = "array";
// if using classic, set $template = "classic";

// now set $template_demo to clean $template filename or empty string
if (($template != "array") && ($template != "classic")) {
    $template_demo = substr($template,strrpos($template,"/")+1); // get filename.ext from $template variable
} else {
    $template_demo = "";

define('HIGHLIGHT_BACKGROUND','#FFBB00');        //Highlighting background color
                                                 //Only for classic mode
define('HIGHLIGHT_COLOR','#000000');             //Highlighting text color
                                                 //Only for classic mode

define('LINK_TARGET','_blank');                  //Target for result links
define('WEIGHT_IMGSRC','./tpl_img/weight.gif');  //Baragraph image path
define('WEIGHT_HEIGHT','5');                     //Baragraph height
define('WEIGHT_WIDTH','50');                     //Max baragraph width

define('SEARCH_PAGE','search.php');              //The name of the search page
define('DISPLAY_DROPDOWN',true);                 //Display dropdown on search page
define('DROPDOWN_URLS',true);                    //Always URLs in dropdown: DISPLAY_DROPDOWN needs to be true

define('SUMMARY_DISPLAY_LENGTH',150);            //Max chars displayed in summary
define('SNIPPET_DISPLAY_LENGTH',200);            //Max chars displayed in each snippet

define('DISPLAY_SNIPPETS',true);                 //Display text snippets
define('DISPLAY_SNIPPETS_NUM',4);                //Max snippets to display
define('DISPLAY_SUMMARY',false);                 //Display description

define('PHPDIG_DATE_FORMAT','\1-\2-\3');         // Date format for last update
                                                 // \1 is year, \2 month and \3 day
                                                 // if using rss, use date format \1-\2-\3

define("END_OF_LINE_MARKER","\r\n");             // End of line marker - keep double quotes
define('SEARCH_BOX_SIZE',15);                    // Search box size
define('SEARCH_BOX_MAXLENGTH',50);               // Search box maxlength

define('PHPDIG_ENCODING','iso-8859-1');  // encoding for interface, search and indexing.
                                         // iso-8859-1, iso-8859-2, iso-8859-7, tis-620,
                                         // and windows-1251 supported in this version.

// replace/edit phpdig_string_subst/phpdig_words_chars for encodings as needed
// note: you may need to alter table keywords modify keyword varchar(64) binary; for certain encodings

$phpdig_string_subst['iso-8859-1'] = 'A:ÀÁÂÃÄÅ,a:àáâãäå,O:ÒÓÔÕÖØ,o:òóôõöø,E:ÈÉÊË,e:èéêë,C:Ç,c:ç,I:ÌÍÎÏ,i:ìíîï,U:ÙÚÛÜ,u:ùúûü,Y:Ý,y:ÿý,N:Ñ,n:ñ';
$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:¼¿¾';
$phpdig_string_subst['iso-8859-6'] = 'Q:Q,q:q';
$phpdig_string_subst['iso-8859-7'] = 'á:Á¶Ü,â:Â,ã:Ã,ä:Ä,å:ŸÝ,æ:Æ,ç:Þǹ,è:è,é:ßúɺ,ê:Ê,ë:Ë,ì:Ì,í:Í,î:Î,ï:ü¼Ï,ð:Ð,ñ:Ñ,ó:Óò,ô:Ô,õ:ýûÕ¾,ö:Ö,÷:×,ø:Ø,ù:þÙ¿';
$phpdig_string_subst['tis-620'] = 'Q:Q,q:q';
$phpdig_string_subst['windows-1251'] = 'à:À,á:Á,â:Â,ã:Ã,ä:Ä,å:Å,æ:Æ,ç:Ç,è:È,é:É,ê:Ê,ë:Ë,ì:Ì,í:Í,î:Î,ï:Ï,ð:Ð,ñ:Ñ,ò:Ò,ó:Ó,ô:Ô,õ:Õ,ö:Ö,÷:×,ø:Ø,ù:Ù,ú:Ú,û:Û,ü:Ü,ý:Ý,þ:Þ,ÿ:ß';

$phpdig_words_chars['iso-8859-1'] = '[:alnum:]ðþßµ';
$phpdig_words_chars['iso-8859-2'] = '[:alnum:]ðþßµ';
$phpdig_words_chars['iso-8859-6'] = '[:alnum:]¤¬»¿ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚàáâãäåæçèéêëìíîïðñò';
$phpdig_words_chars['iso-8859-7'] = '[:alnum:]ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖ×ØÙ¢¸¹º¼¾¿ÚÛáâãäåæçèéêëìíîïðñóôõö÷øùÜÝÞßüýþúûÀà';
$phpdig_words_chars['tis-620'] = '[:alnum:]¡¢£¤¥¦§¨©ª«¬_®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÜßàáâãäåæçèéêëìíîïðñòóôõö÷øùúû';
$phpdig_words_chars['windows-1251'] = '[:alnum:]ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';

// start is AND OPERATOR, exact is EXACT PHRASE, and any is OR OPERATOR
define('SEARCH_DEFAULT_MODE','start');  // default search mode (start|exact|any)
// in language pack make the appropriate changes to 'w_begin', 'w_whole', and 'w_part'
// 'w_begin' => 'and operator', 'w_whole' => 'exact phrase', 'w_part' => 'or operator'

define('SEARCH_DEFAULT_LIMIT',10);      //results per page

define('SPIDER_MAX_LIMIT',20);          //max recurse levels in spider
define('RESPIDER_LIMIT',5);             //recurse respider limit for update
define('LINKS_MAX_LIMIT',20);           //max links per each level
define('RELINKS_LIMIT',5);              //recurse links limit for an update

//for limit to directory, URL format must either have file at end or ending slash at end
//e.g., http://www.domain.com/dirs/ (WITH ending slash) or http://www.domain.com/dirs/dirs/index.php
define('LIMIT_TO_DIRECTORY',false);     //limit index to given (sub)directory, no sub dirs of dirs are indexed

define('LIMIT_DAYS',0);                 //default days before reindex a page
define('SMALL_WORDS_SIZE',2);           //words to not index - must be 2 or more
define('MAX_WORDS_SIZE',30);            //max word size

define('PHPDIG_EXCLUDE_COMMENT','<!-- phpdigExclude -->');  //comment to exclude a page part
define('PHPDIG_INCLUDE_COMMENT','<!-- phpdigInclude -->');  //comment to include a page part
                                                            // must be on own lines in HTML source
                                                            // text within comments not indexed
                                                            // links within comments still indexed

define('PHPDIG_DEFAULT_INDEX',false);    //phpDig considers /index or /default
                                         //html, htm, php, asp, phtml as the
                                         //same as '/'

define('ALLOW_RSS_FEED',false);                       // Do RSS and display link - if true, set rss dir to 777
$theenc = PHPDIG_ENCODING;                            // needs to be same encoding used in index
$theurl = "http://www.phpdig.net/";                   // site offering the RSS feed
$thetitle = "PhpDig.net";                             // title for site offering the RSS feed
$thedesc = "PhpDig :: Web Spider and Search Engine";  // description of site offering the RSS feed
$thedir = "./rss";                                    // the rss directory name, no ending slash
$thefile = "search.rss";                              // used in rss filenames

define('PHPDIG_SESSID_REMOVE',true);        // remove SIDS or vars from indexed URLS
define('PHPDIG_SESSID_VAR','PHPSESSID,s');  // name of SID or variable to remove
                                            // can be 's' or comma delimited 's,id,var,foo,etc'

define('APPEND_TITLE_META',false);       //append title and meta information to results
define('TITLE_WEIGHT',3);                //relative title weight: APPEND_TITLE_META needs to be true

define('CHUNK_SIZE',1024);               //chunk size for regex processing

define('SUMMARY_LENGTH',500);            //length of results summary

define('TEXT_CONTENT_PATH','text_content/'); //Text content files path

define('CONTENT_TEXT',1);                    //Activates/deactivates the
                                             //storage of text content.

define('PHPDIG_IN_DOMAIN',true);             //allows phpdig jump hosts in the same
                                             //domain. If the host is "www.mydomain.tld",
                                             //domain is "mydomain.tld"

define('PHPDIG_LOGS',true);               //write logs
define('LOG_CLICKS',true);                //log clicks
define('SILENCE_404S',true);              //silence 404 output

define('TEMP_FILENAME_LENGTH',8);         //filename length of temp files
// if using external tools with extension, use 4 for filename of length 8

define('NUMBER_OF_RESULTS_PER_SITE',-1);  //max number of results per site
                                          // use -1 to display all results

define('USE_RENICE_COMMAND','1');         //use renice for process priority

// if set to true is_executable used - set to '0' if is_executable is undefined
define('USE_IS_EXECUTABLE_COMMAND','1'); //use is_executable for external binaries

// if set to true, full path to external binary required
define('PHPDIG_OPTION_MSWORD','-s 8859-1');




// if external binary is not STDOUT or different extension is needed
// for example, use '.txt' if external binary writes to filename.txt

//---------FTP SETTINGS
define('FTP_ENABLE',0);//enable ftp content for distant PhpDig
define('FTP_HOST','<ftp host>'); //if distant PhpDig, ftp host;
define('FTP_PORT',21); //ftp port
define('FTP_PASV',1); //passive mode
define('FTP_PATH','<path to phpdig directory>'); //distant path from the ftp root
define('FTP_TEXT_PATH','text_content');//ftp path to text-content directory
define('FTP_USER','<ftp usename>');
define('FTP_PASS','<ftp password>');

// NOTE: make sure ABSOLUTE_SCRIPT_PATH is the full path up to but not including the admin dir, no ending slash
// NOTE: CRON_ENABLE set to true writes a file at CRON_CONFIG_FILE containing the cron job information
// The CRON_CONFIG_FILE must be 777 permissions if applicable to your OS/setup
// You still need to call the CRON_CONFIG_FILE to run the cron job!!!
// From shell: crontab CRON_CONFIG_FILE to set the cron job: replace CRON_CONFIG_FILE with actual file
// From shell: crontab -l to list and crontab -d to delete

define('LIST_ENABLE',true);             //do listing of past queries
define('LIST_PAGE','list.php');         //the name of the list page
define('LIST_NEW_WINDOW',1);            //open queries in new window
define('LIST_SHOW_ZEROS',0);            //show queries with zero results
define('LIST_DEFAULT_LIMIT',20);        //listings per page - positive integer of ten - 10,20,30,...
define('LIST_META_TAG','<meta name="robots" content="noindex,nofollow">'); //meta tag for list page

// regular expression to ban useless external links in index

// regexp forbidden extensions - return sometimes text/html mime-type !!!

// character class MUST have "[ characters go in here ]*" format
// do NOT enter [ or ] in character class - blackslash other special characters
// see http://www.php.net/manual/en/reference.pcre.pattern.syntax.php for further info
// $allowed_link_chars = "[:%/?=&;\\,._a-zA-Z0-9|+ ()~-]*"; // includes space and () - not good with javascript
$allowed_link_chars = "[:%/?=&;\\,._a-zA-Z0-9|+~-]*";

//----------HTML ENTITIES
$spec = array( "&amp" => "&",
               "&agrave" => "à",
               "&egrave" => "è",
               "&ugrave" => "ù",
               "&oacute;" => "ó",
               "&eacute" => "é",
               "&icirc" => "î",
               "&ocirc" => "ô",
               "&ucirc" => "û",
               "&ecirc" => "ê",
               "&ccedil" => "ç",
               "&#156" => "oe",
               "&gt" => " ",
               "&lt" => " ",
               "&deg" => " ",
               "&apos" => "'",
               "&quot" => " ",
               "&acirc" => "â",
               "&iuml" => "ï",
               "&euml" => "ë",
               "&auml" => "ä",
               "&Auml" => "Ä",
               "&Euml" => "Ë",
               "&Iuml" => "Ï",
               "&Uuml" => "Ü",
               "&ouml" => "ö",
               "&uuml" => "ü",
               "&nbsp" => " ",
               "&szlig" => "ß",
               "&iacute" => "í",
               "&reg" => " ",
               "&copy" => " ",
               "&aacute" => "á",
               "&Aacute" => "Á",
               "&eth" => "ð",
               "&ETH" => "Ð",
               "&Eacute" => "É",
               "&Iacute" => "Í",
               "&Oacute" => "Ó",
               "&uacute" => "ú",
               "&Uacute" => "Ú",
               "&THORN" => "Þ",
               "&thorn" => "þ",
               "&Ouml" => "Ö",
               "&aelig" => "æ",
               "&AElig" => "Æ",
               "&aring" => "å",
               "&Aring" => "Å",
               "&oslash" => "ø",
               "&Oslash" => "Ø"

//month names in iso dates
$month_names = array ('jan'=>1,

//apache multi indexes parameters
$apache_indexes = array (  "?N=A" => 1,
                           "?N=D" => 1,
                           "?M=A" => 1,
                           "?M=D" => 1,
                           "?S=A" => 1,
                           "?S=D" => 1,
                           "?D=A" => 1,
                           "?D=D" => 1,
                           "?C=N&amp;O=A" => 1,
                           "?C=M&amp;O=A" => 1,
                           "?C=S&amp;O=A" => 1,
                           "?C=D&amp;O=A" => 1,
                           "?C=N&amp;O=D" => 1,
                           "?C=M&amp;O=D" => 1,
                           "?C=S&amp;O=D" => 1,
                           "?C=D&amp;O=D" => 1);

//includes language file
define('PHPDIG_LANG_CONSTANT',$phpdig_language); // this line for classic
if (is_file("$relative_script_path/locales/$phpdig_language-language.php")) {
    include "$relative_script_path/locales/$phpdig_language-language.php";
elseif (is_file("$relative_script_path/locales/en-language.php")) {
    include "$relative_script_path/locales/en-language.php";
else {
    die("Unable to select language pack.\n");

//connection to database
if ((!isset($no_connect)) || ($no_connect != 1)) {
    if (is_file("$relative_script_path/includes/connect.php")) {
        include "$relative_script_path/includes/connect.php";
    else {
        die("Unable to find connect.php file.\n");

//includes of libraries
if (is_file("$relative_script_path/libs/phpdig_functions.php")) {
    include "$relative_script_path/libs/phpdig_functions.php";
else {
    die ("Unable to find phpdig_functions.php file.\n");
if (is_file("$relative_script_path/libs/function_phpdig_form.php")) {
    include "$relative_script_path/libs/function_phpdig_form.php";
else {
    die ("Unable to find function_phpdig_form.php file.\n");
if (is_file("$relative_script_path/libs/mysql_functions.php")) {
    include "$relative_script_path/libs/mysql_functions.php";
else {
    die ("Unable to find mysql_functions.php file.\n");
if ((!isset($template)) || ((!is_file($template)) && ($template != "array") && ($template != "classic"))) {
    die ("Unable to render template file.\n");

if (!defined('CONFIG_CHECK')) {

// parse encodings (create global $phpdigEncode);
// send encoding if needed
if (!headers_sent()) {
   header('Content-type:text/html; Charset='.PHPDIG_ENCODING);
// turn off magic_quotes_runtime for escaping purposes
// turn off magic_quotes_sybase for escaping purposes
if ((!isset($no_connect)) || ($no_connect != 1)) {
Return current item: PhpDig Search Engine