/
edit_global_signature.php
167 lines (139 loc) · 6.03 KB
/
edit_global_signature.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
// edit_global_signature.php
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// This Page Is Valid XHTML 1.0 Transitional! 4Nov05
// Authors: Ivan Lucas <ivanlucas[at]users.sourceforge.net>
// Paul Heaney <paulheaney[at]users.sourceforge.net>
function get_globalsignature($sig_id)
{
global $dbEmailSig;
$sql = "SELECT signature FROM `{$dbEmailSig}` WHERE id = $sig_id";
$result=mysql_query($sql);
if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_WARNING);
list($signature)=mysql_fetch_row($result);
mysql_free_result($result);
return $signature;
}
function delete_signature($sig_id)
{
global $dbEmailSig;
$sql = "DELETE FROM `{$dbEmailSig}` WHERE id = $sig_id";
mysql_query($sql);
if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_ERROR);
journal(CFG_LOGGING_NORMAL, 'Global Signature deleted', "A global signature was deleted", CFG_JOURNAL_ADMIN, 0);
html_redirect("edit_global_signature.php");
exit;
}
$permission = 43; // Edit global signature
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
$title = $strGlobalSignature;
// External variables
$action = cleanvar($_REQUEST['action']);
$sig_id = cleanvar($_REQUEST['sig_id']);
$signature = cleanvar($_REQUEST['signature']);
$formaction = cleanvar($_REQUEST['formaction']);
if (!empty($signature))
{
//we've been passed a signature - ie we must either be deleting or editing on actual signature
switch ($formaction)
{
case 'add':
//then we're adding a new signature
$sql = "INSERT INTO `{$dbEmailSig}` (signature) VALUES ('$signature') ";
mysql_query($sql);
if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_ERROR);
journal(CFG_LOGGING_NORMAL, 'Global Signature added', "A new global signature was added", CFG_JOURNAL_ADMIN, 0);
html_redirect("edit_global_signature.php");
break;
case 'edit':
$sql = "UPDATE `{$dbEmailSig}` SET signature = '$signature' WHERE id = ".$sig_id;
mysql_query($sql);
if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_ERROR);
journal(CFG_LOGGING_NORMAL, 'Global Signature updated', "A global signature was updated", CFG_JOURNAL_ADMIN, 0);
html_redirect("edit_global_signature.php");
break;
}
}
elseif (empty($action))
{
//The just view the global signatures
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
echo "<h2>{$title}</h2>";
$sql = "SELECT id, signature FROM `{$dbEmailSig}` ORDER BY id ASC";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
echo "<p align='center'>{$strOneOfTheSignaturesWillBeInserted}<br /><br />";
echo "{$strGlobalSignatureRemember}</p>";
echo "<p align='center'><a href='edit_global_signature.php?action=add'>{$strAdd}</a></p>";
echo "<table align='center' width='60%'>";
echo "<tr><th>{$strGlobalSignature}</th><th>{$strOperation}</th></tr>";
while ($signature = mysql_fetch_array($result))
{
$id = $signature['id'];
echo "<tr>";
echo "<td class='shade1' width='70%'>".ereg_replace("\n", "<br />", $signature['signature'])."</td>";
echo "<td class='shade2' align='center'><a href='edit_global_signature.php?action=edit&sig_id=$id'>{$strEdit}</a> | ";
echo "<a href='edit_global_signature.php?action=delete&sig_id=$id'>{$strDelete}</a></td>";
echo "</tr>";
}
echo "</table>";
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
elseif (!empty($action))
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
switch ($action)
{
case 'add':
echo "<h2>{$strGlobalSignature}: {$strAdd}</h2>";
echo "<form action='{$_SERVER['PHP_SELF']}' method='post'>";
echo "<input type='hidden' name='formaction' value='add' />";
echo "<table class='vertical' width='50%'>";
echo "<tr>";
echo "<td align='right' valign='top' class='shade1'><strong>{$strGlobalSignature}</strong>:<br />\n";
echo "{$strGlobalSignatureDescription}<br /><br />";
echo "$strGlobalSignatureRemember";
echo "</td>";
echo "<td class='shade1'><textarea name='signature' rows='15' cols='65'></textarea></td>";
echo "</tr>";
echo "</table>";
echo "<p align='center'><input name='submit' type='submit' value=\"{$strAdd}\" /></p>";
echo "</form>\n";
break;
case 'delete':
delete_signature($sig_id);
break;
case 'edit':
echo "<h2>{$strGlobalSignature}: {$strEdit}</h2>";
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="formaction" value="edit" />
<input type="hidden" name="sig_id" value="<?php echo $sig_id ?>" />
<table class='vertical' width='50%'>
<tr>
<?php
echo "<td align='right' valign='top' class='shade1'><strong>{$strGlobalSignature}</strong>:<br />\n";
echo "{$strGlobalSignatureDescription}<br /><br />";
echo "$strGlobalSignatureRemember";
?>
</td>
<td class="shade1"><textarea name="signature" rows="15" cols="65"><?php echo get_globalsignature($sig_id); ?></textarea></td>
</tr>
</table>
<?php
echo "<p align='center'><input name='submit' type='submit' value=\"{$strSave}\" /></p>";
echo "</form>\n";
break;
}
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
?>