owls

diff 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
line diff
     1.1 --- a/Owls.php	Thu Dec 14 21:51:44 2006 +0100
     1.2 +++ b/Owls.php	Sun May 27 02:13:46 2007 +0200
     1.3 @@ -3,7 +3,7 @@
     1.4    define('DB_PREFIX', 'rem__1_');
     1.5    define('TITLE', 'Owls');
     1.6  
     1.7 -  require_once '../Db.inc.php';
     1.8 +  require_once '../../Db.inc.php';
     1.9    require_once 'Includes/Loginsys.class.php';
    1.10    include_once 'Includes/Bbcodeparser.inc.php';
    1.11  
    1.12 @@ -72,9 +72,6 @@
    1.13  <?php
    1.14  
    1.15  
    1.16 -
    1.17 -
    1.18 -
    1.19    if ($_GET['action'] == 'show') {    // show
    1.20      show($lsys);
    1.21  
    1.22 @@ -123,9 +120,6 @@
    1.23  
    1.24  
    1.25  
    1.26 -
    1.27 -
    1.28 -
    1.29  /*
    1.30      displays content of the node
    1.31      performs action 'edit'
    1.32 @@ -133,6 +127,7 @@
    1.33  */
    1.34  function show($lsys) {
    1.35  
    1.36 +
    1.37    // perform action: write edited node to db
    1.38    if (isset($_POST['editDoc']) && $lsys->loggedIn()) {
    1.39      $_POST['editDoc_title'] = addslashes($_POST['editDoc_title']);
    1.40 @@ -149,6 +144,8 @@
    1.41    include 'Includes/Nav.inc.php';
    1.42  
    1.43  
    1.44 +
    1.45 +
    1.46    // query data of the node
    1.47    $result = mysql_query("select * from ". DB_PREFIX ."Owls where id=$_GET[id]");
    1.48    
    1.49 @@ -179,20 +176,64 @@
    1.50      $row = mysql_fetch_array($result);
    1.51      echo '  <div id="content">'."\n";
    1.52  
    1.53 -      // display admin controls if logged in
    1.54 +      // display admin controls or login form
    1.55 +?>
    1.56 +        <div class="ctrl">
    1.57 +
    1.58 +<?php
    1.59 +          // display last update
    1.60 +          if ($_GET['id'] == 1) {
    1.61 +            // root node displays date of last modification of any node
    1.62 +            $sql = sprintf("
    1.63 +              select
    1.64 +                max(date)
    1.65 +              from %sOwls
    1.66 +              ",
    1.67 +              DB_PREFIX
    1.68 +            );
    1.69 +          } else {
    1.70 +            $sql = sprintf("
    1.71 +              select
    1.72 +                date
    1.73 +              from %sOwls
    1.74 +              where
    1.75 +                id = ". $_GET['id'] ."
    1.76 +              ",
    1.77 +              DB_PREFIX
    1.78 +            );
    1.79 +          }
    1.80 +          $result = mysql_query($sql) or die(mysql_error());
    1.81 +          unset($sql);
    1.82 +
    1.83 +          $rowUpdate = mysql_fetch_row($result);
    1.84 +          $lastUpdate = $rowUpdate[0];
    1.85 +?>
    1.86 +          <span style="font-size: 0.8em;">
    1.87 +            last update: <?php echo date('d.m.Y H:i', $lastUpdate); ?>
    1.88 +          </span>
    1.89 +
    1.90 +<?php
    1.91        if ($lsys->loggedIn()) {
    1.92  ?>
    1.93 -        <div class="ctrl">
    1.94            <a href="<?php echo $row['id'] .'n'; ?>">new</a>
    1.95            <a href="<?php echo $row['id'] .'e'; ?>">edit</a>
    1.96  <?php
    1.97            if ($row['id'] != 1) {
    1.98              echo '<a href="javascript:sureToDelete('. $row['id'] .')">delete</a>';
    1.99            }
   1.100 +          echo '    <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>';
   1.101 +      } else {
   1.102 +?>
   1.103 +        <form name="loginform" id="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data" style="display: inline;">
   1.104 +          <input name="login_loginname" type="text" />
   1.105 +          <input name="login_password" type="password" />
   1.106 +          <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer; width: 5em;" />
   1.107 +        </form>
   1.108 +<?php
   1.109 +      }
   1.110  ?>
   1.111          </div>
   1.112  <?php
   1.113 -      }
   1.114  
   1.115      // print content of the node
   1.116      echo '    <h2>'.stripslashes($row['name']).'</h2>'."\n";