Location: PHPKode > projects > Phoenix FS > phoenixfs1.0.1/includes/functions.inc.php
<?php
/*-----------------------------------------------------------------------
| Phoenix FS v. 1.0.1                                                   |
| Created by Gian_PHP                                                   |
| Based on PHP & MySQL                                                  |
-------------------------------------------------------------------------
| This program is free software: you can redistribute it and/or modify  |
| it under the terms of the GNU General Public License as published by  |
| the Free Software Foundation, either version 3 of the License, or     |
| any later version.                                                    |
|                                                                       |
| This program is distributed in the hope that it will be useful,       |
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
| GNU General Public License for more details.                          |
|                                                                       |
| GNU GPL License: http://www.gnu.org/licenses/gpl.txt                  |
-------------------------------------------------------------------------
| functions.inc.php                                                     |
-----------------------------------------------------------------------*/

if(!defined('ACCESS')) {
	die('Access Denied');
}

// database connection
function DB_Connect($host, $user, $pass, $name) {
	$db_connect = mysql_connect($host, $user, $pass);
	if(!$db_connect) {
		die(mysql_error());
	}
	$db_select = mysql_select_db($name);
	if(!$db_select) {
		die(mysql_error());
	}
	return $db_select;
}

// closing connection
function DB_Close() {
	return mysql_close();
}

// getting html code from module
function Get_HTML($template) {
	return str_replace("\"", "\\\"", implode("", file($template)));
}

// printing module
function Print_Module($url) {
	echo $url;
}

// installing table 1
function Insert_Module() {
	$query_module = "CREATE TABLE ".DB_PREF."module_fields(
	field_display_name VARCHAR (32),
	field_name VARCHAR (32),
	field_type VARCHAR (12),
	field_size INT (6),
	PRIMARY KEY (field_display_name)
	)";
	$query_module_return = mysql_query($query_module);
	if(!$query_module_return) {
		die(mysql_error());
	}
	return $query_module_return;
}

// installing table 2
function Insert_Options() {
	$query_opt = "CREATE TABLE ".DB_PREF."options(
	opt_name VARCHAR (32),
	opt_content VARCHAR (255),
	PRIMARY KEY (opt_name)
	)";
	$query_opt_return = mysql_query($query_opt);
	if(!$query_opt_return) {
		die(mysql_error());
	}
	return $query_opt_return;
}

// installing table 3
function Insert_Admin() {
	$query_admin = "CREATE TABLE ".DB_PREF."admin(
	admin_id INT (5) UNSIGNED not null AUTO_INCREMENT,
	admin_name VARCHAR (32),
	admin_pass VARCHAR (32),
	PRIMARY KEY (admin_id)
	)";
	$query_admin_return = mysql_query($query_admin);
	if(!$query_admin_return) {
		die(mysql_error());
	}
	return $query_admin_return;
}

// completing installation
function Install_Options_Fields() {
	$query_field[1] = "INSERT INTO ".DB_PREF."module_fields (field_display_name, field_name, field_type, field_size) VALUES ('Nickname', 'nickname', 'text', '20')";
	$query_field[2] = "INSERT INTO ".DB_PREF."module_fields (field_display_name, field_name, field_type, field_size) VALUES ('Password Field', 'password', 'password', '20')";
	foreach($query_field as $value) {
		if(mysql_query($value)) {
			define('FIELDS_INSTALL', true);
		} else {
			die(mysql_error());
		}
	}
	$query_module[1] = "INSERT INTO ".DB_PREF."options (opt_name, opt_content) VALUES ('module_style', 'green')";
	$query_module[2] = "INSERT INTO ".DB_PREF."options (opt_name, opt_content) VALUES ('script_name', 'Phoenix FS')";
	$query_module[3] = "INSERT INTO ".DB_PREF."options (opt_name, opt_content) VALUES ('script_url', 'http://phoenixfs.sf.net')";
	$query_module[4] = "INSERT INTO ".DB_PREF."options (opt_name, opt_content) VALUES ('script_version', '1.0s')";
	foreach($query_module as $value) {
		if(mysql_query($value)) {
			define('MODULE_INSTALL', true);
		} else {
			die(mysql_error());
		}
	}
}

// email spam check
function Check_Field($field) {
	if(eregi("To:", $field) OR eregi("Cc:", $field)) {
		return true;
	} else {
		return false;
	}
}
?>
Return current item: Phoenix FS