Location: PHPKode > projects > Phoenix FS > phoenixfs1.0.1/manage/admin_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($_SESSION['ADMIN_LOGIN'] != true) {
	header('location: index.php');
	exit();
}
if(!defined('ADMIN_ACCESS')) {
	die('Access Denied');
}

// getting a white line
function Get_Sep() {
	echo '<hr noshade color="#FFFFFF" size="1">';
}

// change module name
function Module_Name() {
	$query = "SELECT opt_content FROM ".DB_PREF."options WHERE opt_name = 'module_name'";
	$result = mysql_query($query);
	echo "Actual module name: <b>".mysql_result($result, 0)."</b>";
	echo '<form method="post" action="panel.php?id=module_name2">
	<p>New module name<br>
	<input type="text" name="modulename" size="20"></p>
	<p><input type="submit" value="Change"> <input type="reset" value="Reset"></p>
	</form>';
}

// module name part 2
function Module_Name2() {
	$newmodulename = $_POST['modulename'];
	if(empty($newmodulename)) {
		die('Module name is required');
	} elseif(strlen($newmodulename) > 32) {
		die('Module name is too long');
	}
	$query = "UPDATE ".DB_PREF."options SET opt_content = '$newmodulename' WHERE opt_name = 'module_name'";
	if(mysql_query($query)) {
		echo 'Module name changed.';
	} else {
		die(mysql_error());
	}
}

// change module style
function Module_Style() {
	echo '<form method="post" action="panel.php?id=module_style2">
	<p>New style name <b>(IMPORTANT: must be a folder called like this in the /styles/ directory)</b><br>
	<input type="text" name="style" size="20"></p>
	<p><input type="submit" value="Change"> <input type="reset" value="Reset"></p>
	</form>';
}

// module style part 2
function Module_Style2() {
	$newstylename = $_POST['style'];
	if(empty($newstylename)) {
		die('Please compile the field');
	} elseif(!file_exists('../styles/'.$newstylename)) {
		die('Folder doesn\'t exist');
	}
	$query = "UPDATE ".DB_PREF."options SET opt_content = '$newstylename' WHERE opt_name = 'module_style'";
	if(mysql_query($query)) {
		echo 'Module style changed.';
	} else {
		die(mysql_error());
	}
}

// view module fields
function View_Fields() {
	$query = "SELECT * FROM ".DB_PREF."module_fields";
	$result = mysql_query($query);
	echo '<table cellpadding="10" cellspacing="1" bgcolor="#33CC33" class="font_small">
	<tr>
		<td><b><font color="#FFFFFF">Field display name</font></b></td>
		<td><b><font color="#FFFFFF">Field name</font></b></td>
		<td><b><font color="#FFFFFF">Field type</font></b></td>
		<td><b><font color="#FFFFFF">Field size</font></b></td>
	</tr>';
	while($fields = mysql_fetch_array($result)) {
		echo "<tr>
		<td bgcolor=\"#FFFFFF\">".@$fields[field_display_name]."</td>
		<td bgcolor=\"#FFFFFF\">".@$fields[field_name]."</td>
		<td bgcolor=\"#FFFFFF\">".@$fields[field_type]."</td>
		<td bgcolor=\"#FFFFFF\">".@$fields[field_size]."</td>
	</tr>";
	}
	echo '</table>';
}

// delete a module field
function Delete_Fields() {
	$query = "SELECT field_display_name, field_name FROM ".DB_PREF."module_fields";
	$result = mysql_query($query);
	echo '
	<form method="post" action="panel.php?id=delete_fields2">
	<select size="1" name="moduledelete">
	';
	while($row = mysql_fetch_array($result)) {
		echo "<option value=\"".$row[field_name]."\">".$row[field_display_name]."</option>";
	}
	echo '
	</select>
	<input type="submit" value="Delete">
	</form>';
}

// delete function part 2
function Delete_Fields2() {
	$field_deleted = $_POST['moduledelete'];
	$query = "DELETE FROM ".DB_PREF."module_fields WHERE field_name = '$field_deleted'";
	if(mysql_query($query)) {
		echo 'Field deleted.';
	} else {
		die(mysql_error());
	}
}

// add a module field
function Add_Fields() {
	echo '
	<form method="post" action="panel.php?id=add_fields2">
	<p>Field display name<br>
	<input type="text" name="field_display_name" size="20"></p>
	<p>Field name<br>
	<input type="text" name="field_name" size="20"></p>
	<p>Field type<br>
	<input type="text" name="field_type" size="20"></p>
	<p>Field size<br>
	<input type="text" name="field_size" size="20"></p>
	<p><input type="submit" value="Insert">
	<input type="reset" value="Reset"></p>
</form>
	';
}

// add function part 2
function Add_Fields2() {
	$field_display = $_POST['field_display_name'];
	$field_name = $_POST['field_name'];
	$field_type = $_POST['field_type'];
	$field_size = $_POST['field_size'];
	if(empty($field_display)) {
		die('Display name is required');
	} elseif(empty($field_name)) {
		die('Field name is required');
	} elseif(empty($field_type)) {
		die('Field type is required');
	} elseif(empty($field_size)) {
		die('Field size is required');
	} elseif(!is_numeric($field_size)) {
		die('The field size must be composed only of numbers');
	}
	$query = "INSERT INTO ".DB_PREF."module_fields (field_display_name, field_name, field_type, field_size) VALUES ('$field_display', '$field_name', '$field_type', '$field_size')";
	if(mysql_query($query)) {
		echo 'Field inserted.';
	} else {
		die(mysql_error());
	}
}
?>
Return current item: Phoenix FS