Location: PHPKode > scripts > QuickLinks Module > quicklinks-module/quicklinks_install.inc.php
<?PHP
/**
 * Quicklinks 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$
 * @module quicklinks
 * @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) { //  dmin read the README & clicked the install button 

	// Create quicklinks table
	$result = mysql_query ("CREATE TABLE " . $table_prefix."mod_".$modname." 
		(id int(10) NOT NULL default '0' auto_increment, link text, 
		text varchar(50) NOT NULL, xsize smallint(4) DEFAULT '400' NOT NULL,
		ysize smallint(4) DEFAULT '500' NOT NULL, PRIMARY KEY (id)) 
		TYPE=MyISAM PACK_KEYS=1");
	// Display error message if quicklinks table isn't created
	if (!$result) {
		$box_content .= "quicklinks table creation error:<br />" . mysql_error();
	}
	
	// Insert module into modules table
	$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: QuickLinks Module