Location: PHPKode > scripts > Multi Search Module > multi-search-module/search_install.inc.php
<?PHP
/**
 * Search Module Installer
 *
 * This installer makes sure an admin is authenticated
 * and checks whether the module is installed or not
 * before installing. This file is included by index.php
 *
 * @author Edward Ritter <hide@address.com>
 * @version $Id: search_install.inc.php,v 1.1 2002/09/06 06:09:26 esritter Exp $
 * @module search
 * @package phpWebSite
 */


// DON'T CHANGE THIS CODE!
/* security check */
global $PHP_SELF;
if (substr_count ($PHP_SELF,"/mod/")) {
    $inc_prefix = "../../";
} else if (substr_count ($PHP_SELF,"mod.php") ||
    substr_count ($PHP_SELF,"admin.php")) {
    $inc_prefix = "./";
} else {
    $inc_prefix = "../";
}
include_once ($inc_prefix . 'modsecurity.php');
include ($inc_prefix . 'config.php');
if (!check_internal_call()) {
    html_header_location("$phpws_url");
}
/* end security check */

if ($ready == 1) { //  admin read the README & clicked the install button 

	// Create search data table
	$result = mysql_query ("CREATE TABLE " . $table_prefix."mod_".$modname."_data 
		(id int(5) NOT NULL auto_increment, name varchar(30) NOT NULL DEFAULT '',
		query varchar(250) NOT NULL default '', flag tinyint(1) NOT NULL DEFAULT '1',
		fav tinyint(1) NOT NULL DEFAULT '', PRIMARY KEY (id),
		UNIQUE KEY name (name)) TYPE=MyISAM PACK_KEYS=1");
	// Display error message if first table isn't created
	if (!$result) {
		$box_content .= "error creating search data table:<br />" . mysql_error();
	}
	// Populate search data table
	$search_data = "INSERT INTO ".$table_prefix."mod_".$modname."_data VALUES
		('','Alta Vista','http://www.altavista.com/sites/search/web/?pg=q&kl=XX&q=',1,''),
		('','Excite','http://search.excite.com/search.gw?c=web&search=',1,''),
		('','Google','http://www.google.com/search?q=',1,1),
		('','DMOZ','http://search.dmoz.org/cgi-bin/search?search=',1,''),
		('','Yahoo!','http://search.yahoo.com/bin/search?p=',1,''),
		('','This Site','/search.php?query=',1,''),
		('','Google BSD','http://www.google.com/bsd?q=','',''),
		('','AllTheWeb','http://www.alltheweb.com/cgi-bin/search?type=all&query=',1,''),
		('','Dictionary.com','http://www.dictionary.com/search?q=',1,''),
		('','Everything2','http://www.everything2.com/index.pl?node=',1,''),
 		('','Freshmeat','http://freshmeat.net/search/?q=',1,''),
		('','Overture','http://www.overture.com/d/search/?type=home&tm=1&Keywords=',1,''),
		('','HotBot','http://hotbot.lycos.com/?query=',1,''),
		('','IMDB','http://www.imdb.com/Find/?',1,''),
		('','Lycos','http://search.lycos.com/default.asp?lpv=1&loc=searchhp&query=',1,''),
		('','PHP.net','http://www.php.net/manual-lookup.php?pattern=',1,''),
		('','Slashdot','http://slashdot.org/search.pl?query=',1,''),
		('','SourceForge','http://sourceforge.net/search/?type_of_search=soft&words=',1,''),
		('','WebCrawler','http://www.webcrawler.com/cgi-bin/WebQuery?searchText=',1,''),
		('','Dogpile','http://search.dogpile.com/texis/search?q=',1,''),
		('','MetaCrawler','http://search.metacrawler.com/crawler?general=',1,'');";
	$result = mysql_query ($search_data);
	// Display error message if table isn't populated
	if (!$result) {
		$box_content .= "search data wasn't populated:<br />" . mysql_error();
	}

	$result = mysql_query ("INSERT INTO " . $table_prefix."modules VALUES 
		('', '$module_long_name', 'mod.php?mod=$modname', '$module_icon', 
		'$modname', '$block_display_position', '".$modname."_block.php',
		'$admin_only', '$user_only', '".$modname."_admin', '$misc_info')");
	// Display error message if module isn't inserted into the modules table
	if (!$result) {
		$box_content .= "Error writing to modules table:<br>" . mysql_error();
	}
	
} else { // Display the README file and present an install button
	$box_content = "<div class=\"type4\">Please read the module's
        release notes before continuing.</div>\n
        <div align=\"center\"><form action=\"mod.php\" method=\"post\">\n
        <input type=\"hidden\" name=\"mod\" value=\"$modname\" />\n
        <input type=\"hidden\" name=\"op\" value=\"install\" />\n
        <input type=\"hidden\" name=\"ready\" value=\"1\" />\n
        <textarea name=\"readme\" cols=\"60\" rows=\"15\">\n";
    $readme = file ("./mod/$modname/README");
    $readme = implode ("",$readme);
    $box_content .= "$readme</textarea>
		<input type=\"submit\" value=\"Install $module_long_name\" /></form></div>";
}

?>
Return current item: Multi Search Module