4 |
andreas |
1 |
<?
|
|
|
2 |
require_once('version.inc');
|
|
|
3 |
require_once('dbaccess.inc');
|
|
|
4 |
require_once('language.inc');
|
|
|
5 |
require_once('header.inc');
|
|
|
6 |
require_once('crypt.inc');
|
|
|
7 |
require_once('settings.inc');
|
|
|
8 |
require_once('menu.inc');
|
|
|
9 |
|
|
|
10 |
function SaveNewSGF() {
|
|
|
11 |
$ks_num = $_REQUEST['ks_num'];
|
|
|
12 |
$ks_sgf = $_REQUEST['ks_sgf'];
|
|
|
13 |
|
|
|
14 |
$db = OpenDB();
|
|
|
15 |
$query = "select ks_sgf from key_sgf where ks_num = $ks_num";
|
|
|
16 |
$result = QueryDB($db, $query);
|
|
|
17 |
$numrows = numrowsDB($result);
|
|
|
18 |
|
|
|
19 |
if ($numrows == 1) {
|
|
|
20 |
Error("Schlüssel $ks_num ist bereits vorhanden!\n");
|
|
|
21 |
closeDB($db);
|
|
|
22 |
return false;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
$query = "insert into key_sgf (ks_num, ks_sgf) values ($ks_num, '$ks_sgf')";
|
|
|
26 |
|
|
|
27 |
if (!TQueryDB($db, $query)) {
|
|
|
28 |
Error("SQL-Error: $query");
|
|
|
29 |
closeDB($db);
|
|
|
30 |
return false;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
closeDB($db);
|
|
|
34 |
return true;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
function SaveEditSGF() {
|
|
|
38 |
$ks_num = $_REQUEST['ks_num'];
|
|
|
39 |
$ks_sgf = $_REQUEST['ks_sgf'];
|
|
|
40 |
|
|
|
41 |
$db = OpenDB();
|
|
|
42 |
$query = "select ks_sgf from key_sgf where ks_num = $ks_num";
|
|
|
43 |
$result = QueryDB($db, $query);
|
|
|
44 |
$numrows = numrowsDB($result);
|
|
|
45 |
|
|
|
46 |
if ($numrows != 1) {
|
|
|
47 |
Error("Schlüssel $ks_num ist nicht vorhanden!\n");
|
|
|
48 |
closeDB($db);
|
|
|
49 |
return false;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
$query = "update key_sgf set ks_sgf = '$ks_sgf' where ks_num = $ks_num";
|
|
|
53 |
|
|
|
54 |
if (!TQueryDB($db, $query)) {
|
|
|
55 |
Error("SQL-Error: $query");
|
|
|
56 |
closeDB($db);
|
|
|
57 |
return false;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
closeDB($db);
|
|
|
61 |
return true;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
$newsgf = $_REQUEST['newsgf'];
|
|
|
65 |
$editsgf = $_REQUEST['editsgf'];
|
|
|
66 |
|
|
|
67 |
if (!isset($editsgf)) {
|
|
|
68 |
$editsgf = 0;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$savenewsgf = $_REQUEST['savenewsgf'];
|
|
|
72 |
$saveeditsgf = $_REQUEST['saveeditsgf'];
|
|
|
73 |
|
|
|
74 |
if (isset($savenewsgf)) {
|
|
|
75 |
SaveNewSGF();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
if (isset($saveeditsgf)) {
|
|
|
79 |
SaveEditSGF();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
?>
|
|
|
83 |
<form action="sgf.php" method="post">
|
|
|
84 |
<input type="hidden" name="headline" value="15">
|
|
|
85 |
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>">
|
|
|
86 |
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
|
|
|
87 |
<input type="hidden" name="unum" value="<? echo "$unum"; ?>">
|
|
|
88 |
<button type="submit" name="newsgf" value="newsgf"><img src="image/button_newsgf.png" border=0 alt="Neuer SGF"></button>
|
|
|
89 |
<?php
|
|
|
90 |
$db = OpenDB();
|
|
|
91 |
$query = "select ks_num, ks_sgf from key_sgf order by ks_num";
|
|
|
92 |
$result = QueryDB($db, $query);
|
|
|
93 |
|
|
|
94 |
if (!$result) {
|
|
|
95 |
echo "</table></form><br>\n";
|
|
|
96 |
Error("SQL-Error: $query");
|
|
|
97 |
require('footer.inc');
|
|
|
98 |
exit;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
$numrows = numrowsDB($result);
|
|
|
102 |
|
|
|
103 |
if ($numrows > 0 || isset($newsgf)) {
|
|
|
104 |
?>
|
|
|
105 |
<table border=1>
|
|
|
106 |
<tr>
|
|
|
107 |
<td class="tbhead"> </td>
|
|
|
108 |
<td class="tbhead">Key</td>
|
|
|
109 |
<td class="tbhead">Text</td>
|
|
|
110 |
</tr>
|
|
|
111 |
<?php
|
|
|
112 |
$row = 0;
|
|
|
113 |
|
|
|
114 |
while ($row < $numrows) {
|
|
|
115 |
$data = fetchDB($result, $row);
|
|
|
116 |
$ks_num = $data[0];
|
|
|
117 |
$ks_sgf = $data[1];
|
|
|
118 |
|
|
|
119 |
if ($ks_num == $editsgf) {
|
|
|
120 |
echo "<input type=\"hidden\" name=\"ks_num\" value=\"$ks_num\">\n";
|
|
|
121 |
echo "<tr><td><button type=\"submit\" name=\"saveeditsgf\" value=\"$ks_num\"><img src=\"image/new.png\" border=0 alt=\"Edit\"></button></td>";
|
|
|
122 |
echo "<td>$ks_num</td>";
|
|
|
123 |
echo "<td><input type=\"text\" name=\"ks_sgf\" value=\"$ks_sgf\" size=20 maxlength=20></td></tr>\n";
|
|
|
124 |
} else {
|
|
|
125 |
echo "<tr><td><button type=\"submit\" name=\"editsgf\" value=\"$ks_num\"><img src=\"image/edit.png\" border=0 alt=\"Edit\"></button></td>";
|
|
|
126 |
echo "<td>$ks_num</td><td>$ks_sgf</td></tr>";
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
$row++;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
if (isset($newsgf)) {
|
|
|
133 |
echo "<tr><td><button type=\"submit\" name=\"savenewsgf\" value=\"savenewsgf\"><img src=\"image/new.png\" border=0 alt=\"Neu\"></button></td>";
|
|
|
134 |
echo "<td><input type=\"text\" name=\"ks_num\" size=7 maxlength=7></td>";
|
|
|
135 |
echo "<td><input type=\"text\" name=\"ks_sgf\" size=20 maxlength=20></td></tr>\n";
|
|
|
136 |
}
|
|
|
137 |
?>
|
|
|
138 |
</table>
|
|
|
139 |
<button type="submit" name="newsgf" value="new"><img src="image/button_newsgf.png" border=0 alt="Neuer SGF"></button>
|
|
|
140 |
</form>
|
|
|
141 |
<?php
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
require('footer.inc');
|
|
|
145 |
?>
|