📄 templates.php
字号:
<?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: templates.php,v $
// | $Date: 2004/02/10 01:34:25 $
// | $Revision: 1.75 $
// +-------------------------------------------------------------+
// | File Details:
// | - User interface template maintenance, import, and export
// | (administration interface)
// +-------------------------------------------------------------+
error_reporting(E_ALL & ~E_NOTICE);
include("./global.php");
include "./../includes/functions/conditional_functions.php";
include "./../includes/functions/devmode_functions.php";
// default do
$_REQUEST['do'] = trim($_REQUEST['do']);
if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
$_REQUEST['do'] = "view";
}
// globalise variables
$global = array (
array('category'),
array('id')
);
rg($global);
########################################################################################
############################### VIEW TEMPLATES ###############################
########################################################################################
if ($_REQUEST['do'] == "view") {
admin_header('Styles', 'View User Templates');
// get template categories
$db->query("SELECT * FROM template_cat");
while ($result = $db->row_array()) {
$cats[$result['id']] = $result['name'];
}
/***************************************************
DEFAULT TEMPLATES
***************************************************/
// get default, non backup templates
$db->query("
SELECT * FROM template
WHERE custom = 0
AND backup = 0
ORDER BY category, displayorder
");
while ($template = $db->row_array()) {
if ($lastcategory != $template[category]) {
$table[] = table_midheader($cats[$template[category]]);
}
if ($template[upgraded] == "1") {
$word = "<font color=\"red\">CHANGED</font>";
} elseif ($template[changed] == 1) {
$word = "<font color=\"orange\">EDITED</font>";
} else {
$word = '';
}
$bit = jprompt('Are you sure you want to restore this template to its original?\\nAll your modifications will be lost', "templates.php?do=restore&id=$template[id]", 'Restore Default');
// set if we have a restore to default link
$table[] = array(
"<b>$template[name]</b> $word",
$template[description],
iff($template[changed], $bit, ''),
"<a href=\"templates.php?do=edit&id=$template[id]\">Edit</a>"
);
$lastcategory = $template[category];
}
$width = array('20%', '40%', '15%', '15%');
table_header("User Templates");
table_content($columns, $table, '', '', '', '', $width, $bottomline);
table_footer();
unset($templates_temp, $table, $bottomline, $columns, $uncreated, $notemplate);
/***************************************************
CUSTOM TEMPLATES
***************************************************/
// get custom templates
$db->query("
SELECT * FROM template
WHERE custom = 1
AND backup = 0
");
while ($template = $db->row_array()) {
$templates_temp[] = $template[name];
$bit = jprompt('Are you sure you want to delete this template?', "templates.php?do=restore&id=$template", 'Delete');
$table[] = array(
"<b>$template[name]</b>",
$template[description],
$bit,
"<a href=\"templates.php?do=editcustom&id=$template[id]\">Edit</a>"
);
}
table_header("Custom Templates");
table_content($cols, $table, '', '', '', '', $width, $bottomline);
table_footer();
echo "<b>KEY:</b><ul>
<li><font color=\"red\">CHANGED</font> : The template has been upgraded since you last changed it. You should find the changes made or revert the template.</li>
<li><font color=\"orange\">EDITED</font> : You have made changes to this template.</li>
</ul>
";
}
########################################################################################
############################### EDIT CUSTOM TEMPLATE ###############################
########################################################################################
/***************************************************
QUERY TO UPDATE CUSTOM TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "editcustom2") {
$temp = $db->query_return("SELECT name FROM template WHERE id = $id");
$template = parse_conditionals($_REQUEST[template_unparsed]);
// update descriptions and names
$db->query("
UPDATE template SET
description = '" . mysql_escape_string($_REQUEST[description]) . "',
category = $_REQUEST[category]
WHERE name = '" . mysql_escape_string($temp[name]) . "'
");
$db->query("
UPDATE template SET
template = '" . mysql_escape_string($template) . "',
template_unparsed = '" . mysql_escape_string($_REQUEST[template_unparsed]) . "'
WHERE id = $id
");
jump("templates.php?do=view&category=$_REQUEST[category]", "Template Updated");
}
/***************************************************
SHOW TO EDIT CUSTOM TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "editcustom") {
admin_header('Styles', 'Edit User Templates');
// get the category details
$db->query("SELECT * FROM template_cat");
while ($categories = $db->row_array()) {
$cat[$categories[id]] = $categories[name];
}
$template = $db->query_return("SELECT *
FROM template
WHERE id = $id
");
$table[] = array('<b>Name</b>', $template[name]);
$bit = form_select('category', $cat, '', $template[category]);
$table[] = array('<b>Category</b>', $bit);
$bit = form_textarea('description', '120', '4', $template[description]);
$table[] = array('<b>Description</b>', $bit);
$bit = form_textarea('template_unparsed', '120', '40', $template[template_unparsed]);
$table[] = array('<b>Template</b>', $bit);
table_header("Edit Custom Template " . $template[name], 'templates.php', array('do' => 'editcustom2', 'id' => $id));
table_content($columns, $table);
table_footer('Edit Template');
unset($table);
}
########################################################################################
############################### EDIT DEFAULT TEMPLATE ###############################
########################################################################################
/***************************************************
QUERY TO UPDATE DEFAULT TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "edit2") {
$temp = $db->query_return("SELECT category FROM template WHERE id = $id");
$template = parse_conditionals($_REQUEST['template_unparsed']);
$db->query("UPDATE template SET
template = '" . mysql_escape_string($template) . "',
template_unparsed = '" . mysql_escape_string($_REQUEST['template_unparsed']) . "',
" . iff(developer_check(1), "
description = '" . mysql_escape_string($_REQUEST[description]) . "',
category = '" . mysql_escape_string($_REQUEST[category]) . "',
") . "
changed = 1
WHERE id = '$id'
");
jump("templates.php?do=view&category=$temp[category]", "Template Updated");
}
/***************************************************
SHOW TO EDIT DEFAULT TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "edit") {
admin_header('Styles', 'Edit User Templates');
// get the category details
$db->query("SELECT * FROM template_cat");
while ($categories = $db->row_array()) {
$cat[$categories[id]] = $categories[name];
}
$template = $db->query_return("SELECT *
FROM template
WHERE id = $id
");
$table[] = array('<b>Name</b>', $template[name]);
if (developer_check(1)) {
$table[] = array('<b>Category</b>', form_select('category', $cat, '', $template[category]));
} else {
$table[] = array('<b>Category</b>', $cat[$template[category]]);
}
if (developer_check(1)) {
$table[] = array('<b>Description</b>', form_textarea('description', '70', '4', $template[description]));
} else {
$table[] = array('<b>Description</b>', $template[description]);
}
$backup = $db->query_return("SELECT * FROM template WHERE name = '$template[name]' AND backup = 1");
$table[] = array('<b>Edit Template</b>', form_textarea('template_unparsed', '120', '15', $template[template_unparsed]));
$table[] = array('<b>Backup Template</b>' , '<br /><b>Template shown for reference. Editing it will have no affect</b><br /><br />' .form_textarea('backup', '120', '10', $backup[template_unparsed]));
table_header("Edit Template " . $template[name], 'templates.php', array('do' => 'edit2', 'id' => $id));
table_content($columns, $table);
table_footer('Edit Template');
unset($table);
}
########################################################################################
############################### CREATE TEMPLATES ###############################
########################################################################################
/***************************************************
QUERY TO CREATE TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "add2") {
$template = parse_conditionals($_REQUEST[template_unparsed]);
// check template does not exist
$db->query("SELECT id FROM template
WHERE name = '" . mysql_escape_string($_REQUEST[name]) . "'
");
if ($db->num_rows() > 0) {
alert('There is already a template with this name');
$_REQUEST['do'] = 'add';
} else {
$db->query("
INSERT into template SET
name = '" . mysql_escape_string($_REQUEST['name']) . "',
description = '" . mysql_escape_string($_REQUEST['description']) . "',
template = '" . mysql_escape_string($template) . "',
template_unparsed = '" . mysql_escape_string($_REQUEST['template_unparsed']) . "',
custom = 1
");
jump("templates.php?do=view&category=$_REQUEST[category]", "Template Created");
}
}
/***************************************************
SHOW TO CREATE NEW TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "add") {
admin_header('Styles', 'Create Template');
$bit = form_input('name', iff($_REQUEST[name], $_REQUEST[name], $template[name]));
$table[] = array('<b>Name</b>', $bit);
$bit = form_textarea('description', '60', '4', iff($_REQUEST[description], $_REQUEST[description], $template[description]));
$table[] = array('<b>Description</b>', $bit);
$bit = form_textarea('template_unparsed', '120', '40', iff($_REQUEST[template_unparsed], $_REQUEST[template_unparsed], $template[template_unparsed]));
$table[] = array('<b>Template</b>', $bit);
$extra = form_hidden('do', 'edit2');
table_header("Create New Template", 'templates.php', array('do' => 'add2'));
table_content($columns, $table);
table_footer('Create Template');
unset($table);
}
########################################################################################
############################### RESTORE / DELETE TEMPLATES #############################
########################################################################################
/***************************************************
DELETE CUSTOM TEMPLATE
***************************************************/
if ($_REQUEST['do'] == "delete") {
$db->query("DELETE FROM template WHERE id = $id");
jump("templates.php?do=view&category=$_REQUEST[category]", 'Custom template deleted');
}
/***************************************************
RESTORE DEFAULT TEMPLATE FROM BACKUP
***************************************************/
if ($_REQUEST['do'] == "restore") {
$template = $db->query_return("SELECT * FROM template WHERE id = $id");
if (!$db->num_rows()) {
mistake('Template to restore not found.');
}
$template_backup = $db->query_return("
SELECT * FROM template
WHERE name = '$template[name]'
AND backup = 1
");
if ($db->num_rows()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -