Mercurial > owls
comparison Owls.php @ 10:144bc36a6c27
moved login form from nav to top of content
added last modified date
author | meillo@marmaro.de |
---|---|
date | Sun, 27 May 2007 02:13:46 +0200 |
parents | 3cacc24e1774 |
children | 46617062bef5 |
comparison
equal
deleted
inserted
replaced
9:eb5bff360deb | 10:144bc36a6c27 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 define('DB_PREFIX', 'rem__1_'); | 3 define('DB_PREFIX', 'rem__1_'); |
4 define('TITLE', 'Owls'); | 4 define('TITLE', 'Owls'); |
5 | 5 |
6 require_once '../Db.inc.php'; | 6 require_once '../../Db.inc.php'; |
7 require_once 'Includes/Loginsys.class.php'; | 7 require_once 'Includes/Loginsys.class.php'; |
8 include_once 'Includes/Bbcodeparser.inc.php'; | 8 include_once 'Includes/Bbcodeparser.inc.php'; |
9 | 9 |
10 $lsys = &new Loginsys(); | 10 $lsys = &new Loginsys(); |
11 | 11 |
70 <img src="Owls.png" id="banner" alt="<?php echo htmlentities(TITLE); ?>" /> | 70 <img src="Owls.png" id="banner" alt="<?php echo htmlentities(TITLE); ?>" /> |
71 | 71 |
72 <?php | 72 <?php |
73 | 73 |
74 | 74 |
75 | |
76 | |
77 | |
78 if ($_GET['action'] == 'show') { // show | 75 if ($_GET['action'] == 'show') { // show |
79 show($lsys); | 76 show($lsys); |
80 | 77 |
81 } else if ($_GET['action'] == 'new' && $lsys->loggedIn()) { // new | 78 } else if ($_GET['action'] == 'new' && $lsys->loggedIn()) { // new |
82 create($lsys); | 79 create($lsys); |
113 </div> | 110 </div> |
114 | 111 |
115 </body> | 112 </body> |
116 </html> | 113 </html> |
117 <?php | 114 <?php |
118 | |
119 | |
120 | |
121 | 115 |
122 | 116 |
123 | 117 |
124 | 118 |
125 | 119 |
130 displays content of the node | 124 displays content of the node |
131 performs action 'edit' | 125 performs action 'edit' |
132 shows admincontrols if logged in | 126 shows admincontrols if logged in |
133 */ | 127 */ |
134 function show($lsys) { | 128 function show($lsys) { |
129 | |
135 | 130 |
136 // perform action: write edited node to db | 131 // perform action: write edited node to db |
137 if (isset($_POST['editDoc']) && $lsys->loggedIn()) { | 132 if (isset($_POST['editDoc']) && $lsys->loggedIn()) { |
138 $_POST['editDoc_title'] = addslashes($_POST['editDoc_title']); | 133 $_POST['editDoc_title'] = addslashes($_POST['editDoc_title']); |
139 $_POST['editDoc_text'] = addslashes($_POST['editDoc_text']); | 134 $_POST['editDoc_text'] = addslashes($_POST['editDoc_text']); |
147 | 142 |
148 // print nav | 143 // print nav |
149 include 'Includes/Nav.inc.php'; | 144 include 'Includes/Nav.inc.php'; |
150 | 145 |
151 | 146 |
147 | |
148 | |
152 // query data of the node | 149 // query data of the node |
153 $result = mysql_query("select * from ". DB_PREFIX ."Owls where id=$_GET[id]"); | 150 $result = mysql_query("select * from ". DB_PREFIX ."Owls where id=$_GET[id]"); |
154 | 151 |
155 // catch nodes that not exist | 152 // catch nodes that not exist |
156 if (!mysql_num_rows($result)) { | 153 if (!mysql_num_rows($result)) { |
177 } else { | 174 } else { |
178 | 175 |
179 $row = mysql_fetch_array($result); | 176 $row = mysql_fetch_array($result); |
180 echo ' <div id="content">'."\n"; | 177 echo ' <div id="content">'."\n"; |
181 | 178 |
182 // display admin controls if logged in | 179 // display admin controls or login form |
180 ?> | |
181 <div class="ctrl"> | |
182 | |
183 <?php | |
184 // display last update | |
185 if ($_GET['id'] == 1) { | |
186 // root node displays date of last modification of any node | |
187 $sql = sprintf(" | |
188 select | |
189 max(date) | |
190 from %sOwls | |
191 ", | |
192 DB_PREFIX | |
193 ); | |
194 } else { | |
195 $sql = sprintf(" | |
196 select | |
197 date | |
198 from %sOwls | |
199 where | |
200 id = ". $_GET['id'] ." | |
201 ", | |
202 DB_PREFIX | |
203 ); | |
204 } | |
205 $result = mysql_query($sql) or die(mysql_error()); | |
206 unset($sql); | |
207 | |
208 $rowUpdate = mysql_fetch_row($result); | |
209 $lastUpdate = $rowUpdate[0]; | |
210 ?> | |
211 <span style="font-size: 0.8em;"> | |
212 last update: <?php echo date('d.m.Y H:i', $lastUpdate); ?> | |
213 </span> | |
214 | |
215 <?php | |
183 if ($lsys->loggedIn()) { | 216 if ($lsys->loggedIn()) { |
184 ?> | 217 ?> |
185 <div class="ctrl"> | |
186 <a href="<?php echo $row['id'] .'n'; ?>">new</a> | 218 <a href="<?php echo $row['id'] .'n'; ?>">new</a> |
187 <a href="<?php echo $row['id'] .'e'; ?>">edit</a> | 219 <a href="<?php echo $row['id'] .'e'; ?>">edit</a> |
188 <?php | 220 <?php |
189 if ($row['id'] != 1) { | 221 if ($row['id'] != 1) { |
190 echo '<a href="javascript:sureToDelete('. $row['id'] .')">delete</a>'; | 222 echo '<a href="javascript:sureToDelete('. $row['id'] .')">delete</a>'; |
191 } | 223 } |
224 echo ' <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>'; | |
225 } else { | |
226 ?> | |
227 <form name="loginform" id="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data" style="display: inline;"> | |
228 <input name="login_loginname" type="text" /> | |
229 <input name="login_password" type="password" /> | |
230 <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer; width: 5em;" /> | |
231 </form> | |
232 <?php | |
233 } | |
192 ?> | 234 ?> |
193 </div> | 235 </div> |
194 <?php | 236 <?php |
195 } | |
196 | 237 |
197 // print content of the node | 238 // print content of the node |
198 echo ' <h2>'.stripslashes($row['name']).'</h2>'."\n"; | 239 echo ' <h2>'.stripslashes($row['name']).'</h2>'."\n"; |
199 if (!empty($row['text'])) { | 240 if (!empty($row['text'])) { |
200 echo ' <p>'.bbcode(stripslashes($row['text']), 1, 1).'</p>'; | 241 echo ' <p>'.bbcode(stripslashes($row['text']), 1, 1).'</p>'; |