Changeset 138

Show
Ignore:
Timestamp:
04/07/05 14:56:13 (4 years ago)
Author:
rollercow
Message:

A bunch of small changes from the last day or two..

* More comments
* Tidies up a index and admin .php
* Gives the RSS feed the "title" of the blog
* Makes the debug bits use a _session var so they are sticky.. to turn on vist *path*/admin/debug/1 setting debug/0 or loging out turns it off again
* Adds a link back to the blog listings from admin when not logged in

Files:

Legend:

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

    r135 r138  
    156156        } 
    157157         
    158         //destroys the session and presents you with a login screen 
     158        //destroys the session 
    159159        function logout ()  
    160160        { 
     
    166166        function printLoginForm()  
    167167        { 
    168                 echo "<div class=\"login\"><h3>"._("Not logged in")."</h3>\n"; 
    169168                echo "<h2>"._("Login")."</h2>\n"; 
    170169                echo "<div class=\"td\">\n"; 
  • admin.php

    r137 r138  
    11<?php 
    2 $DEBUG = FALSE; 
    3  
     2        //include our admin functions 
    43        include("admin.lib.php"); 
    5         $request=explode('/',substr($_SERVER[PATH_INFO], 1)); 
    64        $admin = new admin(); 
    75 
    8 // Check if we're logging in or out - must be done before any HTML is displayed 
     6        //make our command list from the path 
     7        $request=explode('/',substr($_SERVER[PATH_INFO], 1)); 
     8 
     9        // Check if we're logging in or out - must be done before any HTML is displayed 
    910        switch ($request[0]) { 
    10         case "login": 
    11                 $admin->login(); 
    12                 $admin = new admin(); 
    13                 break; 
    14         case "logout": 
    15                 $admin->logout(); 
    16                 break; 
     11                case "login": 
     12                        $admin->login(); 
     13                        //why? 
     14                        $admin = new admin(); 
     15                        break; 
     16                case "logout": 
     17                        $admin->logout(); 
     18                        break; 
    1719        } 
    1820?> 
     
    3537    <div id="content"> 
    3638        <div id="sidepanel"> 
     39        <? if($_SESSION['userName']) $admin->menu(); else echo "<ul class=\"side-menu\">\n<li><a href=\"{$admin->basePath}\">".("View blogs")."</a></li>\n</ul>" ?><br /> 
    3740            <p class="sideblurb"> 
    38                 <? if($_SESSION['userName']) $admin->menu(); ?><br /> 
    3941                <a href="http://sucs.org"><img src="<? echo $admin->httpPath."img/sucspow.png"; ?>" alt="Powered by SUCS" height="13" width="80" /></a> 
    4042            </p> 
    4143        </div> 
    4244        <div id="maincontent"><? 
     45                //alter the debuging state on request 
     46                if ($request[0] == "debug") { 
     47                        $_SESSION[debug] = $request[1]; 
     48                } 
     49                //if loged in 
    4350                if($_SESSION['userName']) { 
    44                                 if ($_SESSION['userName']) echo "<div class=\"login\"><h3>"._("Hello")." {$admin->realName} (<a href=\"{$admin->adminPath}logout\">"._("Log out")."</a>)</h3></div>"; 
     51                                echo "<div class=\"login\"><h3>"._("Hello")." {$admin->realName} (<a href=\"{$admin->adminPath}logout\">"._("Log out")."</a>)</h3></div>"; 
     52                                //call appropriate functions.. 
    4553                                switch (array_shift($request)) { 
    4654                                        case "newentry": 
     
    9199                                } 
    92100                } 
     101                //else offer login box 
    93102                else { 
     103                        echo "<div class=\"login\"><h3>"._("Not logged in")."</h3>\n"; 
    94104                        $admin->printLoginForm();  
    95105                } 
     
    98108    </div> 
    99109    <div id="bottompanel"> 
    100         <p>Validate : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a></p> 
     110        <p><? echo _("Validate"); ?> : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a></p> 
    101111    </div> 
    102112</div> 
    103113<div id="botbot"></div> 
    104114<?php 
    105 if($DEBUG){ 
    106         echo "<pre>\n"; 
    107         print_r($_SESSION); 
    108         print_r($_POST); 
    109         echo "</pre>"; 
    110 
     115        //if we are in debug mode display a bunch of stuff 
     116        if($_SESSION[debug]){ 
     117                echo "<div class=\"debug\"><h2>"._("Debug Info")."</h2><pre>\n"; 
     118                echo "**"._("Session")."**\n"; 
     119                print_r($_SESSION); 
     120                echo "**"._("Request")."**\n"; 
     121                print_r($_REQUEST); 
     122                echo "**"._("Class")."**\n"; 
     123                print_r($admin); 
     124                echo "</pre></div>"; 
     125        } 
    111126?> 
    112127</body> 
  • blog.css

    r134 r138  
    296296        text-align: left; 
    297297} 
     298 
     299.debug { 
     300        border: solid 1px black; 
     301        background-color: white; 
     302        padding: 3px; 
     303        font-size: 12px; 
     304        text-align: left; 
     305} 
  • blog.lib.php

    r129 r138  
    485485                $this->adminPath = $this->httpPath."admin.php/"; 
    486486                $this->cssFile = "blog.css"; 
     487 
     488                // setup the session purely so we get the debug bits.. 
     489                session_name("BlogSession"); 
     490                session_start(); 
    487491        } 
    488492 
  • index.php

    r134 r138  
    11<?php 
    2 $DEBUG = FALSE; 
    3  
     2        //include our blog functions 
    43        include("blog.lib.php"); 
     4        //make our command list 
    55        $request=explode('/',substr($_SERVER[PATH_INFO], 1)); 
     6        //if we have something which might be a username start a blogs instance 
    67        if($request[0] != "" and $request[0] != "list"){ 
    78                $blog = new blogs(array_shift($request)); 
    8         } else { 
     9        }  
     10        //otherwise start a bloglist instance 
     11        else { 
    912                $blog = new bloglist(); 
    1013                $request = array("list"); 
     
    1720    <title><? echo $blog->title; ?></title> 
    1821    <link rel="stylesheet" href="<? echo $blog->httpPath.$blog->cssFile; ?>" type="text/css" /> 
    19 <?  
    20 //check we have a valid username before offering a RSS feed 
    21 if($blog->userName) { ?> 
    22     <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<? echo "http://".$_SERVER['HTTP_HOST'].$blog->httpPath."feed.php/".$blog->userName.(($request[0]=="category")?"/category/".(int)$request[1]:""); ?>" /> 
    23 <? } ?> 
     22<?php  
     23        //check we have a valid username before offering a RSS feed 
     24        if($blog->userName) {  
     25                echo "    <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$blog->title}\" href=\"http://{$_SERVER['HTTP_HOST']}{$blog->httpPath}feed.php/{$blog->userName}".(($request[0]=="category")?"/category/".(int)$request[1]:"")."\"/>\n"; 
     26        }  
     27?> 
    2428    <script type="text/javascript" src="<?php echo $blog->httpPath; ?>xmlhttp.js"></script> 
    2529</head> 
     
    3438    <div id="content"> 
    3539        <div id="sidepanel"> 
    36  
    3740                <?php $blog->menu(); ?> 
    3841                <p class="sideblurb"> 
     
    4346        <div id="maincontent"> 
    4447            <? 
    45                 if ($_SESSION['userName']) echo "<div class=\"login\"><h3>"._("Hello")." {$_SESSION[realName]} (<a href=\"{$blog->adminPath}logout\">"._("Log out")."</a>)</h3></div>"; 
    46                 else echo "<div class=\"login\"><h3>"._("Not logged in")." {$_SESSION[realName]} (<a href=\"{$blog->adminPath}\">"._("Log in")."</a>)</h3></div>"; 
     48                //display login/logout messages 
     49                if ($_SESSION['userName']) { 
     50                        echo "<div class=\"login\"><h3>"._("Hello")." {$_SESSION[realName]} (<a href=\"{$blog->adminPath}logout\">"._("Log out")."</a>)</h3></div>"; 
     51                } 
     52                else { 
     53                        echo "<div class=\"login\"><h3>"._("Not logged in")." {$_SESSION[realName]} (<a href=\"{$blog->adminPath}\">"._("Log in")."</a>)</h3></div>"; 
     54                } 
     55                //run the appropriate command 
    4756                switch (array_shift($request)) { 
    4857                        case "entry": 
     
    6978    <div id="bottompanel"> 
    7079        <p><? echo _("Validate"); ?> : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a> /  
    71         <?if($blog->userName) {?> 
    72         <a href="http://feedvalidator.org/check.cgi?url=<? echo "http://".$_SERVER['HTTP_HOST'].$blog->httpPath."feed.php/".$blog->userName.(($request[0]=="category")?"/category/".(int)$request[1]:""); ?>">RSS</a> 
    73         <?} 
     80<? 
     81        if($blog->userName) { 
     82                echo "<a href=http://feedvalidator.org/check.cgi?url=http://{$_SERVER['HTTP_HOST']}{$blog->httpPath}feed.php/{$blog->userName}".(($request[0]=="category")?"/category/".(int)$request[1]:"").">RSS</a>"; 
     83        } 
    7484        else { 
    7585                echo "RSS"; 
    76         }?> 
     86        } 
     87?> 
    7788        </p> 
    7889    </div> 
     
    8091<div id="botbot"></div> 
    8192<?php 
    82 if($DEBUG) { 
    83         echo "<pre>"; 
    84         print_r($_SESSION); 
    85         print_r($_COOKIE); 
    86         print_r($blog);  
    87         echo "</pre>"; 
    88 
     93        //display debuing info as required 
     94        if($_SESSION[debug]){ 
     95                echo "<div class=\"debug\"><h2>"._("Debug Info")."</h2><pre>\n"; 
     96                echo "**"._("Session")."**\n"; 
     97                print_r($_SESSION); 
     98                echo "**"._("Request")."**\n"; 
     99                print_r($_REQUEST); 
     100                echo "**"._("Class")."**\n"; 
     101                print_r($blog); 
     102                echo "</pre></div>"; 
     103        } 
    89104?> 
    90105</body>