source: Administrace/AddSection.php

Last change on this file was 1, checked in by george, 15 years ago
  • Import souborů projektu.
File size: 3.4 KB
Line 
1<?php
2 include '../includes/Global.php';
3
4 TestLicence('2');
5
6 if (array_key_exists('Mode', $_GET)) {
7 $Mode = $_GET['Mode'];
8 } else {
9 $Mode = '';
10 }
11
12 If ($Mode == '') { // formuláø pøidání sekce
13 $sql = "SELECT max(ID) FROM section";
14 $ID = $db->SQLCommand($sql);
15 $Line = mysql_fetch_row($ID);
16 $ID = $Line[0]+1;
17?>
18 <h4>Pøidání sekce</h4>
19 <form enctype="multipart/form-data" action="AddSection.php?Mode=AddSection" method="post">
20 <table border="0">
21 <tr><td>Název:</td><td><input type="text" name="Name"></td></tr>
22 <tr><td>Adresa:</td><td><input type="text" value="/Section.php?Section=<?php echo $ID; ?>" name="Address"></td></tr>
23 <tr><td>Popis: </td><td><input name="Description" type="Text"></td></tr>
24 <tr><td>Uživatel: </td><td><b><?php echo $_SESSION['User']; ?></b></td></tr>
25 <tr><td>Zobrazit od: </td><td><select name="ShowDay">
26<?php
27 for ($i=1; $i<32; ++$i) {
28 echo '<option value="'.$i.'">'.$i.'</option>';
29 }
30?>
31 </select></td></tr>
32 <tr><td>Zobrazit do: </td><td>TODO</td></tr>
33 <tr><td><input type="submit" value="Odeslat"></td></tr>
34 </table>
35 </form>
36
37<?php
38 }
39
40 if ($Mode == 'AddSection') { //pøidání sekce
41 $Name = mysql_escape_string($_POST['Name']);
42 $UserID = mysql_escape_string($_SESSION['ID']);
43 $Address = mysql_escape_string($_POST['Address']);
44 $Description = mysql_escape_string($_POST['Description']);
45 echo('Jméno: '.$Name.'<br>');
46 echo('Uživatel: '.$_SESSION['User'].'<br>');
47 echo('Address: '.$Address.'<br>');
48 echo('Popis: '.$Description.'<br>');
49
50 $sql = "SELECT max(ID) FROM section";
51 $ID = $db->SQLCommand($sql);
52 $Line = mysql_fetch_row($ID);
53 $ID = $Line[0]+1;
54 $sql = "INSERT section VALUE('$ID','$Name','$Description','$Address',now(),now(),now(),'$UserID')";
55 $db->SQLCommand($sql);
56 echo 'Sekce '.$Name.' byla uložena';
57 WriteLog('Sekce byla uložena: '.$Name.' ID: '.$ID.' Popis: '.$Description.' User: '.$UserID,'4');
58 }
59
60 /* if ($AdminLevel < 4) { //level 4
61 echo $NotLicence;
62 include '../includes/FormLogin.php';
63 ShowFooter();
64 die();
65 } */
66
67
68 If ($Mode == '') { // formuláø smazání sekce
69 TestLicence('4');
70
71 $sql = "SELECT max(ID) FROM section";
72 $ID = $db->SQLCommand($sql);
73 $Line = mysql_fetch_row($ID);
74 $ID = $Line[0]+1;
75?>
76 <h4>Smazání sekce</h4>
77 <form enctype="multipart/form-data" action="AddSection.php?Mode=DelSection" method="post">
78 <table border="0">
79 <tr><td>Section:</td><td>
80<?php
81 $sql = "SELECT * FROM section";
82 $ID = $db->SQLCommand($sql);
83 echo '<select name="Section" size="10">';
84 while($Line = mysql_fetch_array($ID)) {
85 echo '<option value="',$Line['ID'],'">',$Line['Name'],' (',$Line['ID'],')</option>';
86 // echo $Line['Description'];
87 } // konec while
88 echo '</select>';
89
90?>
91 </td></tr>
92 <tr><td><input type="submit" value="Smazat"></td></tr>
93 </table>
94 </form>
95
96<?php
97 }
98
99 if ($Mode == 'DelSection') { //pøidání sekce
100 TestLicence('4');
101
102 $Section = mysql_escape_string($_POST['Section']);
103 echo('Smazání Sekce: '.$Section.'<br>');
104
105 $sql = "DELETE FROM section WHERE ID = '$Section'";
106 $db->SQLCommand($sql);
107 echo 'Sekce byla Smazána';
108 WriteLog('Sekce byla smazána: ID: '.$Section,'2');
109 }
110
111 ShowFooter()
112?>
Note: See TracBrowser for help on using the repository browser.