Changeset 775 for trunk

Show
Ignore:
Timestamp:
01/06/08 13:47:35 (11 months ago)
Author:
michiel
Message:

added frontend logging.
For this we had to add a global variable with all the users.

Re #161

Location:
trunk/common
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/common/mvblog.php

    r761 r775  
    7878        public function __construct ($basedir="") { 
    7979                parent::__construct($basedir."plugins/"); 
     80                $this->log = new MvBlog_log($basedir, 0); 
    8081        } 
    8182        /* }}} */ 
     
    11091110                                $_SESSION["blog_user"]["email"]    = $row["email"]; 
    11101111                                $_SESSION["blog_user"]["website"]  = $row["website"]; 
     1112                                $this->log->add_log(mktime(), $row["id"], 2, sprintf("User %s logged in", $row["username"])); 
    11111113                                return true; 
    11121114                        } else { 
     
    12231225                                $email, $website, $regcode, $email_public 
    12241226                        ); 
     1227                        $logmsg = sprintf("User %s registered", $username); 
    12251228                } else { 
    12261229                        if ($password) 
     
    12341237                        $sql = sprintf("UPDATE blog_users SET realname = '%s'%s, email = '%s', website = '%s', email_public = %d WHERE id = %d", 
    12351238                                $realname, $passwdq, $email, $website, $email_public, $_SESSION["blog_user"]["user_id"]); 
     1239                        $logmsg = sprintf("User %d:%s updated", $_SESSION["blog_user"]["id"], $_SESSION["blog_user"]["username"]); 
    12361240                } 
    12371241                $this->db->exec($sql); 
     1242                $this->log->add_log(mktime(), 0, 2, $logmsg); 
    12381243                if ($register) { 
    12391244                        if (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") 
  • trunk/common/mvblog_common.php

    r770 r775  
    6161        public $authors    = array(); 
    6262        /** 
     63         * @var array $users Array with all active users. 
     64         * The array looks like this: 
     65         * <pre> 
     66         * array ( 
     67         *   [id] => "fullname", 
     68         *   [id] => "fullname" 
     69         * ) 
     70         * </pre> 
     71         */ 
     72        public $users      = array(); 
     73        /** 
    6374         * @var array $categories Array with all active categories. 
    6475         * The array looks like this: 
     
    187198                        /* populate the authors array */ 
    188199                        $this->_get_authors(); 
     200 
     201                        /* populate the users array */ 
     202                        $this->_get_users(); 
    189203 
    190204                        /* populate the categories array */ 
     
    607621                } 
    608622                $this->authors = $authors; 
     623        } 
     624        /* }}} */ 
     625        /* _get_users() {{{ */ 
     626        /** 
     627         * Get all the users into an array. 
     628         */ 
     629        public function _get_users() { 
     630                /* user with id 0 is for a new user. */ 
     631                $authors = array( 
     632                        0 => array( 
     633                                "login"    => "login", 
     634                                "password" => "", 
     635                                "email"    => "", 
     636                                "fullname" => "", 
     637                                "active"   => 1, 
     638                                "website"  => "" 
     639                        ) 
     640                ); 
     641 
     642                $res =& $this->db->query("SELECT * FROM blog_users"); 
     643                if (PEAR::isError($res)) { 
     644                        die($res->getMessage()); 
     645                } 
     646                while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { 
     647                        $users[$row["id"]] = array( 
     648                                "username" => $row["username"], 
     649                                "password" => $row["password"], 
     650                                "email"    => $row["email"], 
     651                                "realname" => $row["realname"], 
     652                                "active"   => $row["active"], 
     653                                "website"  => $row["website"] 
     654                        ); 
     655                } 
     656                $this->users = $users; 
    609657        } 
    610658        /* }}} */ 
  • trunk/common/mvblog_log.php

    r773 r775  
    8080                while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { 
    8181                        $row["human_time"] = date("Y-m-d H:i:s", $row["time"]); 
    82                         $row["username"] = $this->authors[$row["user_id"]]["login"]; 
    83                         $row["fullname"] = $this->authors[$row["user_id"]]["fullname"]; 
     82                        if ($row["user_type"] == 1) { 
     83                                $row["username"] = $this->authors[$row["user_id"]]["login"]; 
     84                                $row["fullname"] = $this->authors[$row["user_id"]]["fullname"]; 
     85                        } elseif ($row["user_type"] == 2) { 
     86                                $row["username"] = $this->users[$row["user_id"]]["username"]; 
     87                                $row["fullname"] = $this->users[$row["user_id"]]["realname"]; 
     88                        } 
    8489                        $logrecords[] = $row; 
    8590                }