Changeset 96

Show
Ignore:
Timestamp:
30/05/05 15:19:33 (4 years ago)
Author:
davea
Message:

Added list of 5 most recent entries to the admin main page, a link to view all past entries on the menu, and fixed some numpty's over zealous use of striptags()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • admin.lib.php

    r95 r96  
    127127        function menu() { 
    128128                echo "<ul class=\"side-menu\">\n"; 
    129                 echo "<li><a href=\"".$this->adminPath."newentry"."\">Add a new entry</a></li>\n"; 
    130                 echo "<li><a href=\"",$this->adminPath."settings"."\">Edit blog settings</a></li>\n"; 
     129                echo "<li><a href=\"".$this->adminPath."newentry"."\">Write new entry</a></li>\n"; 
     130        echo "<li><a href=\"".$this->adminPath."showentries\">Edit entries</a></li>\n"; 
     131                echo "<li><a href=\"",$this->adminPath."settings"."\">Settings</a></li>\n"; 
    131132                echo "</ul>\n"; 
    132133        } 
     
    243244                //sanitise body 
    244245                if (isset($_POST['body']) && trim($_POST['body']) != "") { 
    245                         $body = addslashes(nl2br(trim(strip_tags($_POST['body'])))); 
     246                        $body = addslashes(nl2br(trim($_POST['body']))); 
    246247                } else { 
    247248                        $this->inputError = _("No entry body!"); 
     
    318319                echo "</p>\n"; 
    319320                echo "<p>\n"; 
    320                 echo "<textarea name=\"body\" id=\"body\" cols=\"50\" rows=\"10\" tabindex=\"3\">" . (($show) ? strip_tags($row['body'],$entryTags) : "") . "</textarea>\n"; 
     321                echo "<textarea name=\"body\" id=\"body\" cols=\"50\" rows=\"10\" tabindex=\"3\">" . (($show) ? $row['body'] : "") . "</textarea>\n"; 
    321322                echo "</p>\n"; 
    322323                echo "<p>\n"; 
     
    367368                echo "</div>\n";         
    368369        } 
     370 
     371    function printEntries($amount=0, $title=TRUE) 
     372    { 
     373        $limit = ($amount > 0) ? " LIMIT $amount" : ""; 
     374        $result = db_query("SELECT shortsubject,timestamp,subject FROM entries WHERE user_id = '".$this->id."' ORDER BY timestamp DESC $limit;"); 
     375        if(db_num_rows($result)==0){ 
     376            error(5, _("No entries found.")); 
     377        } else { 
     378            if($title){ 
     379                echo "<h2>"._("Edit Entries")."</h2>\n"; 
     380            } 
     381            echo "<ul>\n"; 
     382            while($row = db_getrow($result)){ 
     383                echo "<li>".date("r", strtotime($row['timestamp']))." <a href=\"".$this->adminPath."update/".$row['shortsubject']."\">".$row['subject']."</a></li>\n"; 
     384            } 
     385            echo "</ul>\n"; 
     386        } 
     387    } 
    369388 
    370389/* Some functions to manage posts, users etc. */ 
  • admin.php

    r92 r96  
    3939                        if ($_SESSION['userName']) echo "<div class=\"login\"><h3>"._("Hello")." {$admin->realName} (<a href=\"{$admin->adminPath}logout\">"._("Log out")."</a>)</h3></div>"; 
    4040                        switch (array_shift($request)) { 
    41                         case "newentry": 
    42                                 $admin->printEntryForm() ; 
    43                                 break; 
    44                         case "settings": 
    45                                 $admin->printSettingsForm() ; 
    46                                 break; 
    47                         case "postentry": 
    48                                 $admin->postEntry() ; 
    49                                 break; 
    50                         case "postupdate": 
    51                                 $admin->updateEntry(array_shift($request)) ; 
    52                                 break; 
    53                         case "update": 
    54                                 $admin->updateForm(array_shift($request)) ; 
    55                                 break; 
    56                         case "postsettings": 
    57                                 $admin->updateSettings() ; 
    58                                 break; 
    59                         default: 
    60                                 //Should display blog entries here 
    61                 echo "<div class=\"entry\">\n"; 
    62                 echo "<h2>"._("Blog Management")."</h2>\n"; 
    63                 echo "<div class=\"td\">\n"; 
    64                 echo "<p>"._("Use the links on the left to manage your blog")."</p>\n"; 
    65                 echo "</div>\n"; 
    66                 echo "<p>&nbsp;</p><p>&nbsp;</p>\n"; // To allow the menu to display properly 
    67                 echo "</div>\n"; 
    68  
    69                                 break; 
     41                        case "newentry": 
     42                                $admin->printEntryForm() ; 
     43                                break; 
     44                case "settings": 
     45                        $admin->printSettingsForm() ; 
     46                        break; 
     47                        case "postentry": 
     48                                $admin->postEntry() ; 
     49                                break; 
     50                        case "postupdate": 
     51                                $admin->updateEntry(array_shift($request)) ; 
     52                                break; 
     53                        case "update": 
     54                                $admin->updateForm(array_shift($request)) ; 
     55                                break; 
     56                case "postsettings": 
     57                    $admin->updateSettings() ; 
     58                    break; 
     59                case "showentries": 
     60                    $admin->printEntries(); 
     61                    break; 
     62                        default: 
     63                                //Should display blog entries here 
     64                        echo "<div class=\"entry\">\n"; 
     65                    echo "<h2>"._("Blog Management")."</h2>\n"; 
     66                    echo "<div class=\"td\">\n"; 
     67                    echo "<p>"._("Use the links on the left to manage your blog, or choose a recent entry to edit:")."</p>\n"; 
     68                    $admin->printEntries(5, FALSE); 
     69                    echo "<a href=\"".$admin->adminPath."showentries\">show all entries...</a></div>\n"; 
     70                    echo "<p>&nbsp;</p><p>&nbsp;</p>\n"; // To allow the menu to display properly 
     71                    echo "</div>\n"; 
    7072                        } 
    7173                }