Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

init.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: init.php,v 1.5 2003/10/03 15:27:32 mikko Exp $ */
00003 /*
00004  * ImaComm - a web based photo album software
00005  * Copyright (C) 2003, Mikko Kokkonen
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or (at
00010  * your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00029 $_init_prefix = dirname(__FILE__);
00030 
00031 session_start();
00032 
00033 // If we asked sign out, sign user out before anything else (which could read userdata etc...)
00034 if (isset($_REQUEST['signout']))
00035 {
00036         // Easy...
00037         session_destroy();
00038 }
00039 
00040 // Load our helper functions...
00041 require_once "$_init_prefix/helper/functions.php";
00042 require_once "$_init_prefix/classes/Settings.php";
00043 require_once "$_init_prefix/classes/Configuration.php";
00044 require_once "$_init_prefix/classes/ThemeEngine.php";
00045 require_once "$_init_prefix/classes/Document.php";
00046 require_once "$_init_prefix/classes/Userdata.php";
00047 require_once "$_init_prefix/classes/Comments.php";
00048 
00049 // Load settings...
00050 loadSettingsFile();
00051 
00052 // Load configuration...
00053 $config = new Configuration();
00054 $config->loadData();
00055 
00056 // Load Theme Engine..
00057 $themeEngine = new ThemeEngine();
00058 
00059 // Load document data...
00060 $document = new Document();
00061 
00062 if ($_SESSION['logged'])
00063 {
00064         // Load user data...
00065         $user = new UserData();
00066         $user->loadData($_SESSION['logged'], $_SESSION['password']);
00067 }
00068 
00069 // Load comments class
00070 
00071 // Are we asked to sign in?
00072 if (isset($_REQUEST['dosignin']))
00073 {
00074         $user = new UserData();
00075         $user->loadData($_REQUEST['username'], $_REQUEST['password']);
00076 
00077         if ($user->allOK())
00078         {
00079                 session_register("logged");
00080                 $_SESSION['logged'] = $_REQUEST['username'];
00081                 $_SESSION['password'] = $user->password;
00082         }
00083 }
00084 
00085 // Wanted to add comment?
00086 if (isset($_REQUEST['addcomment']) && $config->option('addcomments'))
00087 {
00088         global $albumdata, $comments;
00089         $album = getAlbum();
00090         $albumdata = get_albumdata($album);
00091         $comments_source = $albumdata->attribute('comments');
00092         $comments = new Comments($comments_source);
00093 
00094         // Generate new comment data...
00095         // Cleaver for detect...
00096         if (basename($_SERVER['PHP_SELF'], ".php") == "index")
00097         {
00098                 $for = "-album-";
00099         }
00100         else
00101         {
00102                 $for = ($_REQUEST['image'] == "") ? "-album-" : $albumdata->photos[$_REQUEST['image']];
00103         }
00104         $data = array(
00105                         "for"     => $for,
00106                         "sender"  => ($_SESSION['username'] == null) ? "anonymous" : $_SESSION['username'],
00107                         "from"    => $_SERVER['REMOTE_ADDR'],
00108                         "time"    => time(),
00109                         "message" => stripslashes($_REQUEST['newcomment']));
00110         $comments->addComment($data);
00111 }
00112 
00113 theme($config->option('theme'));
00114 ?>

Generated on Sun Oct 19 11:08:00 2003 for ImaComm by doxygen1.3