Changeset 129

Show
Ignore:
Timestamp:
01/07/05 19:32:36 (4 years ago)
Author:
davea
Message:

A bunch of modifications to make the blog system work when it's not in a subdir - see http://blog.minus-zero.org/
Fixed a bug where a comment wouldn't appear if it was the first on for an entry.
Also made the textbox for new/edited entries a sensible size.

Files:

Legend:

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

    r127 r129  
    4040                $this->shortDateFormat = "Y-m-d"; 
    4141                $this->longDateFormat = "r"; 
    42                 $this->httpPath = dirname($_SERVER['SCRIPT_NAME'])."/"; 
     42                $this->httpPath = dirname($_SERVER['SCRIPT_NAME']); 
     43                if($this->httpPath[strlen($this->httpPath)-1]!="/") { 
     44                        $this->httpPath .= "/"; 
     45                } 
    4346                $this->adminPath = $this->httpPath."admin.php/"; 
    4447                $this->basePath = $this->httpPath."index.php/"; 
     
    439442                echo "</p>\n"; 
    440443                echo "<p>\n"; 
    441                 echo "<textarea name=\"body\" id=\"body\" cols=\"50\" rows=\"10\" tabindex=\"3\">" . (($show) ? br2nl($row['body']) : "") . "</textarea>\n"; 
     444                echo "<textarea name=\"body\" id=\"body\" cols=\"75\" rows=\"30\" tabindex=\"3\">" . (($show) ? br2nl($row['body']) : "") . "</textarea>\n"; 
    442445                echo "</p>\n"; 
    443446                echo "<p>\n"; 
  • blog.lib.php

    r127 r129  
    11<?php 
     2/* vim: set tabstop=4: */ 
    23/* 
    34 * blogs class - provides functions for blogs 
     
    6768                        $this->longDateFormat = "%c"; 
    6869                        //path for all http stuff.. ie images, css and so on 
    69                         $this->httpPath = dirname($_SERVER['SCRIPT_NAME'])."/"; 
     70                        $this->httpPath = dirname($_SERVER['SCRIPT_NAME']); 
     71                        // make the httpPath work nicely if we're not in a subdir 
     72                        if(substr($this->httpPath, -1)!="/") { 
     73                                $this->httpPath .= "/"; 
     74                        } 
    7075                        //path for the blog viewer with no user 
    7176                        $this->basePath = $this->httpPath."index.php/"; 
     
    201206                $sql = db_query("SELECT timestamp, name, email, body, host, id FROM comments WHERE post = ".$postid." and moderated = true ORDER BY timestamp ASC limit ".$limit." OFFSET ".$offset.";"); 
    202207                $sqlNum = db_num_rows($sql); 
     208                echo "<div id=\"comments\">\n"; 
    203209                if ($sqlNum > 0) { 
    204210                        $blogOwner = $this->checkSessionOwner(); 
     
    206212                                echo "<form name=\"deletecomments\" id=\"deletecomments\" method=\"post\" action=\"{$this->adminPath}deletecomments/{$this->currentEntry}\">\n"; 
    207213                        } 
    208                         echo "<div id=\"comments\">\n"; 
    209214                         
    210215                        $count=0; 
     
    213218                        } 
    214219 
    215                         echo "</div>\n"; 
    216220 
    217221                        if($blogOwner) { 
     
    222226                        } 
    223227                } 
     228                echo "</div>\n"; 
    224229        } 
    225230 
     
    432437                echo "<li><a href=\"{$this->blogPath}archive/\">"._("Archive")."</a></li>\n"; 
    433438                //put the path back together, and dont forget the tailing slash 
    434                 echo "<li><a href=\"{$this->basePath}\">"._("Other Bloggers")."</a></li>\n"; 
     439                echo "<li><a href=\"{$this->basePath}list/\">"._("Other Bloggers")."</a></li>\n"; 
    435440                if ($this->checkSessionOwner()){ 
    436441                        echo "<li><a href=\"{$this->adminPath}\">"._("Blog admin")."</a></li>\n"; 
     
    473478                $this->title = _("SUCS Blogs"); 
    474479                $this->description = _("Swansea University Computer Society member web logs"); 
    475                 $this->httpPath = dirname($_SERVER['SCRIPT_NAME'])."/"; 
     480                $this->httpPath = dirname($_SERVER['SCRIPT_NAME']); 
     481                if(substr($this->httpPath, -1)!="/") { 
     482                        $this->httpPath .= "/"; 
     483                } 
    476484                $this->basePath = $this->httpPath."index.php/"; 
    477485                $this->adminPath = $this->httpPath."admin.php/"; 
  • feed.php

    r128 r129  
    1919if(db_num_rows($result)!=1){ 
    2020        error(1, "No such user"); 
    21 }  
     21} 
    2222else { 
    2323        //fetch the users info from the db 
    2424        $row = db_getrow($result); 
    2525        $user = $row; 
    26         $user['link'] = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php/".$user['username']."/"; 
     26        if(substr(dirname($_SERVER['SCRIPT_NAME']), -1)=="/"){ 
     27                $user['link'] = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."index.php/".$user['username']."/"; 
     28        } 
     29        else { 
     30                $user['link'] = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php/".$user['username']."/"; 
     31        } 
    2732} 
    2833 
     
    4449        $row = db_getrow($result); 
    4550        $pubdate = date("r",strtotime($row['timestamp'])); 
    46  
    4751        $entries = ""; 
    4852        //output this entry 
  • index.php

    r128 r129  
    11<?php 
     2$DEBUG = FALSE; 
     3 
    24        include("blog.lib.php"); 
    35        $request=explode('/',substr($_SERVER[PATH_INFO], 1)); 
     
    2830        <h1><a href="<?php echo $blog->blogPath; ?>"><? echo $blog->title; ?></a></h1> 
    2931        <h2><? echo $blog->description; ?></h2> 
    30     <h3><? if ($blog->userName != "") echo _("A weblog by")." ".$blog->userName; ?></h3> 
     32    <h3><? if ($blog->realName != "") echo _("A weblog by")." ".$blog->realName; ?></h3> 
    3133    </div> 
    3234    <div id="content"> 
     
    7577</div> 
    7678<div id="botbot"></div> 
    77 <pre><?php print_r($_SESSION); print_r($_COOKIE); ?></pre> 
     79<?php 
     80if($DEBUG) { 
     81        echo "<pre>"; 
     82        print_r($_SESSION); 
     83        print_r($_COOKIE); 
     84        print_r($blog);  
     85        echo "</pre>"; 
     86
     87?> 
    7888</body> 
    7989</html>