fields.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:4k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: fields.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.9 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Administrator-defined custom fields maintenance
- // | (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- // start file
- require("./global.php");
- // globalise variables
- $global = array (
- array('id')
- );
- rg($global);
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- ############################### UPDATE/ADD FIELD ###############################
- if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') {
- if ($_REQUEST['do'] == 'add') {
- admin_header('Admin Fields', 'Add New Field');
- } else {
- if (!$id) {
- mistake("No ID specified. Nothing to edit.");
- }
- $field = $db->query_return("SELECT * FROM ticket_fielddisplay WHERE id = $id");
- if (!$db->num_rows()) {
- mistake("Invalid ID specified. Nothing to edit.");
- }
- admin_header('Admin Fields', 'Edit Field');
- }
- $table[] = array('<b>Name</b>', form_input('name', $field['name']));
- $table[] = array('<b>Code</b>', form_input('code', $field['code']));
- $table[] = array('<b>Example</b>', form_input('example', $field['example']));
- table_header(iff($_REQUEST['do'] == 'add', "Add New Field", "Edit Field"), 'fields.php', array('do' => iff($_REQUEST['do'] == 'add', 'new2', 'edit2'), 'id' => $id));
- table_content(NULL, $table);
- table_footer(iff($_REQUEST['do'] == 'add', 'Add Field', 'Edit Field'));
- exit;
- }
- ############################### CREATE FIELD (2) ###############################
- if ($_REQUEST['do'] == "new2") {
- $db->query("INSERT INTO ticket_fielddisplay SET
- name = '" . mysql_escape_string($_REQUEST[name]) . "',
- code = '" . mysql_escape_string($_REQUEST[code]) . "',
- example = '" . mysql_escape_string($_REQUEST[example]) . "'
- ");
- jump('fields.php', 'Field Created');
- }
- if ($_REQUEST['do'] == "edit2") {
- if (!$id) {
- mistake("No ID specified. Nothing to update.");
- }
- $db->query("UPDATE ticket_fielddisplay SET
- name = '" . mysql_escape_string($_REQUEST[name]) . "',
- code = '" . mysql_escape_string($_REQUEST[code]) . "',
- example = '" . mysql_escape_string($_REQUEST[example]) . "'
- WHERE id = $id
- ");
- jump('fields.php', 'Field Updated');
- }
- ############################### DELETE FIELD ###############################
- if ($_REQUEST['do'] == "delete") {
- if ($id) {
- $db->query("DELETE FROM ticket_fielddisplay WHERE id = $id");
- } else {
- mistake("No ID provided. Nothing to delete.");
- }
- jump('fields.php', 'Field deleted.');
- }
- ############################### VIEW FIELD ###############################
- if ($_REQUEST['do'] == "view") {
- admin_header('Admin Fields', 'View Fields');
- $fields = $db->query_return_array("SELECT * FROM ticket_fielddisplay ORDER BY name");
- if (is_array($fields)) {
- foreach ($fields AS $field) {
- $table[] = array(
- $field['name'],
- highlight_string($field['code'], 1),
- htmlspecialchars_uni($field['example']),
- jprompt('This will delete the field!',
- "fields.php?do=delete&id=$field[id]",
- 'Delete'),
- "<A HREF="fields.php?do=edit&id=$field[id]">Edit</A>"
- );
- }
- } else {
- $table[] = "<CENTER>No fields defined.</CENTER>";
- }
- $cols = array('Name', 'Code', 'Example', 'Delete', 'Edit');
- table_header("Custom Admin Fields");
- table_content($cols, $table);
- table_footer();
- print "<A HREF="fields.php?do=add">Add New Field</A>";
- }
- ##############################################################
- admin_footer();
- ?>