openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a7f485b89e144eff6e66bccf9ff431e85e3f84d0
parent c8d86a158d499e13a9ac4c57149910aa08d18866
Author: dankert <devnull@localhost>
Date:   Mon, 29 Sep 2003 20:20:09 +0200

erste Version

Diffstat:
doc/examples/config/config.ini.php | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index.php | 275+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
title.php | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
tree.php | 439+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
treemenu.php | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
user.php | 361+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 1375 insertions(+), 0 deletions(-)

diff --git a/doc/examples/config/config.ini.php b/doc/examples/config/config.ini.php @@ -0,0 +1,156 @@ +; <!-- $Id$ --> +; <?php exit('direct access denied') ?> + +[database] + +count = 2 + + +[database_1] + +name = FSTEST +comment = "Testdatenbank MySQL" +type = mysql +user = cms +password = horst +host = :/var/run/mysqld/mysqld.sock +database = cms +prefix = +persistent = yes + + +[database_2] + +name = FSTESTXXX +comment = "Testdatenbank MySQL persistent" +type = mysql +user = cms +password = horst +host = 127.0.0.1 +database = cms +prefix = +persistent = yes + + + +[debug] + +; This is a switch to switch on or off the debugging mode. +; The debugging mode ist only useful for developers :-) +; Default: 'false' + +debug = true + + + + + + + +[ldap] + +; LDAP server hostname for password checking with this server +; If you want to use this method, you MUST set a LDAP-rdn for each user +; Default: '' (blank) +; UNDER DEVELOPMENT! + +host = "192.168.10.19" + + + +; External database for password checking +; You only need this if you have your own password server! +; Default: '' (blank) +; UNDER DEVELOPMENT! + +[auth_database] + +dsn = "mysql://cms:horst@127.0.0.1/cms" +db_sql = "select * from tablexy where user={user} and password={pw}" + + + +[global] + +; --------------------------------------------------------------------- +; The title displayed in the title bar of your browser. +; Maybe you like to change it to something more friendly :-) + +title = "Content Management System DaCMS'03" +version = "0.1 cvs" +; --------------------------------------------------------------------- + + +; --------------------------------------------------------------------- +; The php file extension which is used on your server. +; Default: php +; --------------------------------------------------------------------- +ext = php +; --------------------------------------------------------------------- + +; --------------------------------------------------------------------- +; Authorization method +; Can be one of "url", "cookie" or "http" +; at the moment, only "url" is supported +; --------------------------------------------------------------------- +auth = url +; --------------------------------------------------------------------- + + +; --------------------------------------------------------------------- +; Width of the left Tree +; --------------------------------------------------------------------- +;tree_width = "250" +tree_width = "25%" +; --------------------------------------------------------------------- + + + +; --------------------------------------------------------------------- +; Directories +; --------------------------------------------------------------------- + +[directories] + +datadir = "./data" +incldir = "./functions" +themedir = "./themes/default" +languagedir = "./language" +plugindir = "./plugins" +tmpdir = "./tmp" + +[log] + +level = "debug" +file = "./data/cms.log" + + +; --------------------------------------------------------------------- +; Session config +; --------------------------------------------------------------------- + +[session] + +cookies = no +transient = no + + +; --------------------------------------------------------------------- +; GD Image Library +; --------------------------------------------------------------------- +[gd] + +; is GD installed (with GD you can use dynamic resizing of images) +gd = yes + +; Version of GD ( set to 1 or 2 ) +; GD version 2 allows you to use TrueColor Images +version = 2 + +; if using GD, which Image-Types are supported (seperated by commas) +extension = jpeg,jpg,png + + + +; Thats it :-) +; Have a lovely day+ \ No newline at end of file diff --git a/index.php b/index.php @@ -0,0 +1,274 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// DaCMS Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.1 2003-09-29 18:17:46 dankert +// erste Version +// +// --------------------------------------------------------------------------- + +session_start(); + +if ( !isset($SESS['conf']) ) +{ + $conf = parse_ini_file( 'config.ini.php',true ); + + $conf_php = $conf['global']['ext']; + + $conf_db = $conf['database_1']; + $conf_incldir = $conf['directories']['incldir']; + $conf_datadir = $conf['directories']['datadir']; + $conf_themedir = $conf['directories']['themedir']; + $conf_languagedir = $conf['directories']['languagedir']; + $conf_plugindir = $conf['directories']['languagedir']; + $conf_tmpdir = $conf['directories']['tmpdir']; + + $conf_logfile = $conf['log']['file']; + $conf_loglevel = $conf['log']['level']; + + $SESS['conf'] = $conf; +} + +require_once './DB.php'; + +include( "$conf_incldir/folder.inc.$conf_php" ); +include( "$conf_incldir/login.inc.$conf_php" ); +include( "$conf_incldir/theme.inc.$conf_php" ); +include( "$conf_incldir/language.inc.$conf_php" ); +include( "$conf_incldir/project.inc.$conf_php" ); +include( "$conf_incldir/request.inc.$conf_php" ); +include( "$conf_incldir/db.inc.$conf_php" ); + +request_into_session('folderid'); +request_into_session('fileid'); +request_into_session('pageid'); +request_into_session('dbid'); +request_into_session('projectid'); +request_into_session('projectmodelid'); +request_into_session('languageid'); +request_into_session('folderaction'); +request_into_session('fileaction'); +request_into_session('pageaction'); + + + +if ($_REQUEST['action']=='logout') +{ + unset( $SESS['user'] ); +} + + +if ( !isset($SESS['user']) ) +{ + $SESS['action'] = 'login'; +} + + +if ( !isset($SESS['lang']) ) +{ + language_read(); +} + + +# Authorization über HTTP +# +if ( $conf['global']['auth'] == 'http' ) +{ + if ( isset($PHP_AUTH_USER) ) + { + login( $PHP_AUTH_USER,$PHP_AUTH_PW,$db ); + } + + # Falls Benutzer nicht angemeldet, dann Login-Maske präsentieren + # + if ( !isset($sess_user) ) + { + header( 'WWW-Authenticate: Basic realm="Login"' ); + header( 'HTTP/1.0 401 Unauthorized' ); + echo 'Authorization Required!'; + exit; + } +} + + + + +if (!isset($sess_plugin_hooks)) +{ +// $sess_plugin_hooks = read_plugin_hooks(); +// session_register( 'sess_plugin_hooks' ); + +// $sess_global_plugins = array(); +// session_register( 'sess_global_plugins' ); +// +// $sess_project_plugins = array(); +// session_register( 'sess_project_plugins' ); +} + + +# Ein Benutzer versucht sich anzumelden +# + +if ( isset($REQ['login_name']) && isset($REQ['login_password']) ) +{ + unset( $sess_user ); + session_unregister( 'sess_user' ); + + //plugin_global('login'); + + if (!isset($sess_user)) + { + login( $REQ['login_name'],$REQ['login_password'],$REQ['dbid'] ); + } + + $SESS['dbid'] = $REQ['dbid']; +} + + +/* +# Wenn Startseite gewünscht, dann wird diese hier erzwungen. +# Nur nach dem Login ist $startpage gefüllt, sonst steht die +# Startpage nur in der Session. +# +if ( isset($startpage) && !session_is_registered('sess_startpage') ) +{ + session_register('sess_startpage'); + $sess_startpage = $startpage; +} + +if ( session_is_registered('sess_startpage') && $menu != "login" && isset($sess_user['name']) && isset($login_name) ) +{ + $menu = "edit"; + $menuaction = "preview"; + session_register('sess_page'); + $sess_page = $sess_startpage; +} + +if ( isset($startproject) ) +{ + session_register('sess_startproject'); + $sess_startproject = $startproject; +} + +if ( ! isset($menu ) ) $menu = 'login'; +if ( ! isset($menuaction) ) $menuaction = 'login'; + +if ( $menu != "edit" ) +{ + session_unregister('sess_page'); + unset($sess_page); +} + +if ( isset($page) ) +{ + session_register('sess_page'); + $sess_page = $page; +} +if ( isset($generate) ) +{ + session_register('sess_generate'); + $sess_generate = $generate; +} + +if (asdf) +{ +} + +$session = session_id(); + +$skript = $menuaction; + +if ( $menuaction == 'preview' ) +{ + $skript = 'generate'; + $generate = 'preview'; +} + +if ( $menuaction == 'view' ) +{ + $skript = 'generate'; + $generate = 'view'; +} + +if ( $menuaction == 'generate' ) +{ + $skript = 'generate'; + $generate = 'file'; +} + +session_register( 'sess_generate' ); +session_register( 'sess_menu' ); +session_register( 'sess_menuaction' ); +$sess_menu = $menu; +$sess_generate = $generate; +$sess_menuaction = $menuaction; +*/ + +session_write_close(); + +/* +$u = $sess_user['name']; +$p = $prj_project[ $sess_project ]; +$m = lang( strtoupper('menu_'.$menuaction) ); +if ( isset($sess_page) ) + $s = $pagecache[$sess_page]['title']; +else $s = ""; +if ( $p == "" ) $p = "-"; +if ( $u == "" ) $u = "-"; +*/ + + +$title = 'Content Management System (Benutzer: **user**)'; +$title = eregi_replace( '\*\*user\*\*',$u,$title ); +$title = eregi_replace( '\*\*project\*\*',$p,$title ); +$title = eregi_replace( '\*\*menu\*\*',$m,$title ); +$title = eregi_replace( '\*\*page\*\*',$s,$title ); + + +$var = array(); + +$title = $conf['global']['title'].' '.$conf['global']['version']; + +if (!isset($SESS['user'])) +{ + $var['title'] = lang('NOT_LOGGED_IN').' - '.$title; +} +else +{ + $var['title'] = $SESS['user']['name'].' @'.$conf['database_'.$SESS['dbid']]['name'].' - '.$title; +} + +$var['frame_src_title' ] = 'title.'.$conf_php; +$var['frame_src_treemenu'] = 'treemenu.'.$conf_php; +$var['frame_src_tree' ] = 'tree.'.$conf_php; +$var['frame_src_main' ] = 'main.'.$conf_php; + +if (isset($SESS['user'])) + $var['tree_width' ] = $conf['global']['tree_width']; +else $var['tree_width' ] = '0'; + +if ( $conf['global']['tree_resizable'] ) + $var['border_width' ] = '2'; +else $var['border_width' ] = '0'; + +output( 'frameset',$var ); + +?>+ \ No newline at end of file diff --git a/title.php b/title.php @@ -0,0 +1,50 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// DaCMS Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.1 2003-09-29 18:20:09 dankert +// erste Version +// +// --------------------------------------------------------------------------- + +$conf = parse_ini_file( 'config.ini.php',true ); + +require_once( $conf['directories']['incldir']. + '/config.inc.'. + $conf['global']['ext'] ); + +session_start(); + + +include( "./$conf_incldir/theme.inc.$conf_php" ); +include( "./$conf_incldir/language.inc.$conf_php" ); +include( "./$conf_incldir/request.inc.$conf_php" ); + +$var = array(); +$var['css_body_class'] = 'title'; +if ( isset($SESS['dbid']) ) $var['db'] = $conf['database_'.$SESS['dbid']]['name']; +if ( isset($SESS['user']) ) $var['user' ] = $SESS['user']['name']; + +$var['project' ] = $SESS['db']; +$var['logout_url' ] = 'index.'.$conf_php.'?action=logout'; +output( 'title',$var ); + +?>+ \ No newline at end of file diff --git a/tree.php b/tree.php @@ -0,0 +1,438 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// DaCMS Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.1 2003-09-29 18:19:48 dankert +// erste Version +// +// --------------------------------------------------------------------------- + + +$conf = parse_ini_file( 'config.ini.php',true ); + +require_once( $conf['directories']['incldir']. + '/config.inc.'. + $conf['global']['ext'] ); + +session_start(); + +require_once "./DB.$conf_php"; +require_once( "$conf_incldir/language.inc.$conf_php" ); +require_once( "$conf_incldir/theme.inc.$conf_php" ); +require_once( "$conf_incldir/tree.inc.$conf_php" ); +require_once( "$conf_incldir/request.inc.$conf_php" ); +require_once( "$conf_incldir/db.inc.$conf_php" ); + + +request_into_session('treeaction'); + +if ( !isset($SESS['treeaction']) ) +{ + $SESS['treeaction'] = $SESS['projectid']; +} + +$treeaction = $SESS['treeaction']; + +if (!isset($SESS['tree_open'])) + $SESS['tree_open'] = array(); + +if ( !is_array($SESS['tree_open'][$treeaction]) ) + $SESS['tree_open'][$treeaction] = array(); + + +if (isset($REQ['open'])) +{ + array_push($SESS['tree_open'][$treeaction],$REQ['open']); +} + + +if (isset($REQ['close'])) +{ + $key = array_search( $REQ['close'],$SESS['tree_open'][$treeaction] ); + if ( !is_null($key) && $key!==false ) + unset( $SESS['tree_open'][$treeaction][$key] ); +} + + +// Erzeugen des Menue-Baums +// +if ( (isset($SESS['user']) && isset($REQ['treeaction'])) || !isset($SESS['tree']) || $REQ['refresh']=='1' ) +{ + $db = db_connection(); + + $SESS['tree'] = array(); + if ( $SESS['treeaction'] == 'admin' ) + { + + // Einstellungen + // + # "root"-element + $SESS['tree']['projects'] = array('text' => lang('PROJECTS'), + 'url' => "main.$conf_php?action=project&projectaction=list", + 'icon' => 'project', + 'target'=> 'cms_main' ); + + $sql = "SELECT * FROM $t_project ORDER BY name"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['prj'.$row['id']] = array('text' => $row['name'], + 'parent'=> 'projects', + 'url' => "main.$conf_php?action=project&projectaction=edit&projectid=".$row['id'], + 'icon' => 'project', + 'target'=> 'cms_main' ); + } + $res->free(); + + $SESS['tree']['global'] = array('text' => lang('common'), + 'icon' => 'user' ); + + $SESS['tree']['user'] = array('text' => lang('USER'), + 'parent'=> 'global', + 'url' => "main.$conf_php?action=user&useraction=list", + 'icon' => 'user', + 'target'=> 'cms_main' ); + + $sql = "SELECT * FROM $t_user ORDER BY name"; + $res = $db->query($sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['user'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=user&userid=".$row['id'], + 'icon' => 'user', + 'parent' => "user", + 'target' => 'cms_main' ); + } + $res->free(); + + $SESS['tree']['group'] = array('text' => lang('GROUPS'), + 'parent'=> 'global', + 'url' => "main.$conf_php?action=group&groupaction=list", + 'icon' => 'group', + 'target'=> 'cms_main' ); + + $sql = 'SELECT * FROM '.$t_group.' ORDER BY name'; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['group'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=group&groupid=".$row['id'], + 'icon' => 'user', + 'parent' => "group", + 'target' => 'cms_main' ); + } + $res->free(); + + $SESS['tree']['logout'] = array('text' => lang('LOGOUT'), + 'url' => "index.$conf_php?action=logout", + 'icon' => 'logout', + 'target'=> '_top' ); + } + else + { + // Projektstruktur + // --------------- + + // Projekt-ID in Session speichern + $SESS['projectid'] = $SESS['treeaction']; + $projectid = $SESS['projectid']; + + // Ermitteln Sprache + $sql = "SELECT id FROM $t_language WHERE projectid=$projectid AND is_default=1"; + $SESS['languageid'] = $db->getOne($sql); + + // Ermitteln Projectmodell + $sql = "SELECT id FROM $t_projectmodel WHERE projectid=$projectid AND is_default=1"; + $SESS['projectmodelid'] = $db->getOne($sql); + + + // Projekt-Baum + // + $SESS['tree']['folder'] = array('text' => lang('FOLDER'), + 'url' => "main.$conf_php?action=folder&folderid=", + 'icon' => 'folder', + 'target' => 'cms_main' ); + + $sql = "SELECT * FROM $t_folder WHERE projectid=$projectid AND parentid IS NULL"; + $res = $db->query($sql); + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['f'.$row['id']] = array('text' => $row['name'], + 'desc' => $row['desc'], + 'parent' => 'folder', + 'icon' => 'folder', + 'url' => "main.$conf_php?action=folder&folderid=".$row['id'], + 'target' => 'cms_main' ); + add_folder( $row['id'] ); + } + $res->free(); + + $sql = "SELECT * FROM $t_page ". + "WHERE projectid=$projectid AND folderid IS NULL"; + $res = $db->query($sql); + while ($row = $res->fetchrow() ) + { + $SESS['tree']['page'.$row['id']] = array('text' => $row['name'], + 'desc' => $row['desc'], + 'url' => "main.$conf_php?action=page&pageid=".$row['id'], + 'icon' => 'page', + 'parent' => 'folder', + 'target' => 'cms_main' ); + add_page_elements( $row['id'],$row['templateid'] ); + } + $res->free(); + + + $sql = "SELECT * FROM $t_file ". + " WHERE projectid=$projectid AND folderid IS NULL ORDER BY filename"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['file'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=file&fileid=".$row['id'], + 'icon' => 'file', + 'desc' => $row['desc'], + 'name' => 'file'.$row['id'], + 'parent' => 'folder', + 'target' => 'cms_main' ); + } + $res->free(); + + + + // Templates anzeigen + // + if ( $SESS['user']['is_admin'] == '1' ) + { + $SESS['tree']['tpl'] = array('text' => lang('TEMPLATES'), + 'url' => "main.$conf_php?action=template&tplaction=list", + 'icon' => 'tpl_list', + 'target' => 'cms_main' ); + $sql = "SELECT * FROM $t_template WHERE projectid=".$SESS['treeaction']; + $res = $db->query($sql); + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['tpl'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=template&templateid=".$row['id'], + 'parent' => "tpl", + 'icon' => 'tpl', + 'target' => 'cms_main' ); + // Anzeigen der Template-Elemente + // + $sql = "SELECT * FROM $t_element WHERE templateid=".$row['id']." ORDER BY name ASC"; + $resel = $db->query($sql); + + while ($rowel = $resel->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['tpl'.$row['id'].'el'.$rowel['id']] = array('text' => $rowel['name'], + 'url' => "main.$conf_php?action=element&templateid=".$row['id'].'&elementaction=edit&elementid='.$rowel['id'], + 'icon' => 'el_'.$rowel['type'], + 'parent' => 'tpl'.$row['id'], + 'target' => 'cms_main' ); + } + } + $res->free(); + } + + + // Sprachvarianten + // + if ( $SESS['user']['is_admin'] == '1' ) + { + $SESS['tree']['lang'] = array('text' => lang('LANGUAGES'), + 'url' => "main.$conf_php?action=language", + 'icon' => 'lang_list', + 'target' => 'cms_main' ); + $sql = "SELECT * FROM $t_language". + " WHERE projectid=".$SESS['treeaction']. + " ORDER BY name"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['lang'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=language&languageid=".$row['id'], + 'parent' => 'lang', + 'icon' => 'lang', + 'target' => 'cms_main' ); + } + $res->free(); + } + + + // Projektvarianten + // + if ( $SESS['user']['is_admin'] == '1' ) + { + $SESS['tree']['pvar'] = array('text' => lang('VARIATIONS'), + 'url' => "main.$conf_php?action=projectmodel", + 'icon' => 'model_list', + 'target' => 'cms_main' ); + $sql = "SELECT * FROM $t_projectmodel WHERE projectid=".$SESS['treeaction']; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['pvar'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=projectmodel&projectmodelid=".$row['id'], + 'parent' => "pvar", + 'icon' => 'model', + 'target' => 'cms_main' ); + } + $res->free(); + } + + $SESS['tree']['search'] = array('text' => lang('SEARCH'), + 'url' => "main.$conf_php?action=search", + 'icon' => 'search', + 'target' => 'cms_main' ); + + } + + + // Zu jedem Baumelement werden die Kinder ermittelt + // Ziel: Performancesteigerung, schnellere Baumanzeige. + + // Wir benötigen eine Kopie von $SESS['tree'], weil innerhalb einer foreach()-Schleife + // nicht das gleiche Array nochmal mit foreach() durchlaufen werden kann. + $SESS['tree_kopie'] = $SESS['tree']; + + foreach( $SESS['tree'] as $idx=>$inh ) + { + $SESS['tree'][$idx]['children'] = array(); + + foreach( $SESS['tree_kopie'] as $name=>$val ) + { + if ( $val['parent'] == $idx ) + { + $SESS['tree'][$idx]['children'][] = $name; + } + } + } + unset( $SESS['tree_kopie'] ); + +} + + + + +function add_folder( $parentid ) +{ + global $db, + + $SESS, + + $conf_php, + $t_templatemodel, + $t_template, + $t_folder, + $t_file, + $t_page; + $sql = "SELECT * FROM $t_folder ". + "WHERE projectid=".$SESS['treeaction']. + " AND parentid=$parentid"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['f'.$row['id']] = array('text' => $row['name'], + 'desc' => $row['desc'], + 'url' => "main.$conf_php?action=folder&folderid=".$row['id'], + 'icon' => 'folder', + 'parent' => "f$parentid", + 'target' => 'cms_main' ); + add_folder( $row['id'] ); + } + $res->free(); + + $sql = "SELECT * FROM $t_page ". + //"LEFT JOIN $t_templatemodel ON $t_page.templateid=$t_templatemodel.id ". + "WHERE folderid=$parentid"; + $res = $db->query($sql); + while ($row = $res->fetchrow() ) + { + $SESS['tree']['page'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=page&pageid=".$row['id'], + 'icon' => 'page', + 'desc' => $row['desc'], + 'parent' => "f$parentid", + 'target' => 'cms_main' ); + + add_page_elements( $row['id'],$row['templateid'] ); + } + $res->free(); + + $sql = "SELECT * FROM $t_file WHERE folderid=$parentid ORDER BY filename"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['file'.$row['id']] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=file&fileid=".$row['id'], + 'icon' => 'file', + 'desc' => $row['desc'], + 'name' => 'file'.$row['id'], + 'parent' => "f$parentid", + 'target' => 'cms_main' ); + } + $res->free(); +} + +function add_page_elements( $pageid,$templateid ) +{ + global $db,$SESS,$conf_php,$t_element; + + $sql = "SELECT * FROM $t_element ". + " WHERE templateid=$templateid ". + " AND $t_element.type!='infodate' AND $t_element.type!='info'". + " ORDER BY name ASC"; + $res = $db->query($sql); + if (DB::isError($res)) die ($res->getMessage().'<br>'.$sql); + while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC) ) + { + $SESS['tree']['page'.$pageid.'el'.$row['id'] ] = array('text' => $row['name'], + 'url' => "main.$conf_php?action=pageelement&pageid=".$pageid.'&elementid='.$row['id'], + 'icon' => 'el_'.$row['type'], + 'parent' => "page$pageid", + 'target' => 'cms_main' ); + } + $res->free(); +} + + +// Füllen der Ausgabevariablen +// +$var = array(); + +// Erzeugen des Baumes. Die Ausgabe erfolgt in die Variable $var +tree_show( &$var ); + +// Link zum Aktualisieren +$var['refresh_url'] = $PHP_SELF.'?treeaction='.$SESS['treeaction']; + +// Ausgabe des Templates +// +output('tree',$var); + +?>+ \ No newline at end of file diff --git a/treemenu.php b/treemenu.php @@ -0,0 +1,91 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// DaCMS Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.1 2003-09-29 18:18:48 dankert +// erste Version +// +// --------------------------------------------------------------------------- + +$conf = parse_ini_file( 'config.ini.php',true ); + +require_once( $conf['directories']['incldir']. + '/config.inc.'. + $conf['global']['ext'] ); + +session_start(); + +include( "DB.php" ); +include( "$conf_incldir/language.inc.$conf_php" ); +include( "$conf_incldir/theme.inc.$conf_php" ); +include( "$conf_incldir/db.inc.$conf_php" ); +include( "$conf_incldir/request.inc.$conf_php" ); + +$var = array(); + +$var['css_body_class'] = 'menu'; + +if (isset($SESS['user'])) +{ + $var['form_method'] = 'get'; + $var['form_target'] = 'cms_tree'; + $var['form_action'] = 'tree.'.$conf_php; + + $var['form_select_name'] = 'treeaction'; + $var['form_select_onchange'] = 'submit();'; + $var['form_select_value'] = array(); + + + // Lesen der verfügbaren Projekte + $db = db_connection(); + $sql = new Sql( 'SELECT id,name from {t_project} ORDER BY name ASC' ); + $projekte = $db->getAssoc( $sql->query ); + + // Unterscheidung Administrator/Benutzer + if ( $SESS['user']['is_admin'] == '1' ) + { + // Administrator sieht Administrationsbereich + $var['form_select_value']['admin'] = lang('ADMINISTRATION'); + + // Administrator sieht alle Projekte + foreach( $projekte as $projectid=>$name ) + { + $var['form_select_value'][$projectid] = $name; + } + } + else + { + // Bereitstellen der Projekte, für die der Benutzer berechtigt ist + //print_r($SESS['rights']); + foreach( $projekte as $projectid=>$name ) + { + if ( isset( $SESS['rights'][$projectid]) ) + $var['form_select_value'][$projectid] = $name; + } + } + + $var['form_select_default'] = $SESS['projectid']; +} + +// Ausgabe des Templates +output('tree_menu',$var); + +?>+ \ No newline at end of file diff --git a/user.php b/user.php @@ -0,0 +1,360 @@ +<?php +// --------------------------------------------------------------------------- +// $Id$ +// --------------------------------------------------------------------------- +// DaCMS Content Management System +// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// --------------------------------------------------------------------------- +// $Log$ +// Revision 1.1 2003-09-29 18:18:21 dankert +// erste Version +// +// --------------------------------------------------------------------------- + + +$conf = parse_ini_file( 'config.ini.php',true ); + +require_once( $conf['directories']['incldir']. + '/config.inc.'. + $conf['global']['ext'] ); + +session_start(); + + +include( "DB.php" ); + +include( "$conf_incldir/language.inc.$conf_php" ); +include( "$conf_incldir/theme.inc.$conf_php" ); +include( "$conf_incldir/request.inc.$conf_php" ); + +request_into_session('useraction'); +request_into_session('userid'); + +// Zugriff nur für Administratoren gestattet +if ( $SESS['user']['is_admin'] != '1' ) + die('access denied'); + + +$db = new DB( $conf['database_'.$SESS['dbid']] ); + +$var = array(); + +if ( !isset($SESS['useraction'])) + $SESS['useraction'] = 'show'; + + +if ( $SESS['useraction'] == 'save' ) +{ + if ( $REQ['is_admin']!=1 ) + $REQ['is_admin'] = 0; + + $t_user = $conf_db_prefix.'user'; + $sql = "UPDATE $t_user ". + "SET ". + "name ='".$REQ['name']."', ". + "fullname ='".$REQ['fullname']."', ". + "is_admin = ".$REQ['is_admin'].", ". + "ldap ='".$REQ['ldap']."', ". + "mail ='".$REQ['mail']."', ". + "lang ='".$REQ['lang']."', ". + "style ='".$REQ['style']."' ". + "WHERE id=".$SESS['userid']; + $res = $db->query($sql); + + $SESS['useraction'] = 'show'; +} + +if ( $SESS['useraction'] == 'add' ) +{ + $t_user = $conf_db_prefix.'user'; + $sql = "INSERT INTO $t_user ". + "(name) VALUES(". + "'".$REQ['name']."'". + ")"; + echo "$sql"; + $res = $db->query($sql); + + $SESS['useraction'] = 'list'; +} + +if ( $SESS['useraction'] == 'addgroup' ) +{ + $t_usergroup = $conf_db_prefix.'usergroup'; + $sql = "INSERT INTO $t_usergroup ". + "(userid,groupid) VALUES(". + "'".$SESS['userid']."',". + "'".$REQ['groupid']."'". + ")"; + echo "$sql"; + $res = $db->query($sql); + + $SESS['useraction'] = 'groups'; +} + +if ( $SESS['useraction'] == 'delgroup' ) +{ + $t_usergroup = $conf_db_prefix.'usergroup'; + $sql = "DELETE FROM $t_usergroup ". + "WHERE id=".$REQ['usergroupid']; + $res = $db->query($sql); + + $SESS['useraction'] = 'groups'; +} + + +if ( $SESS['useraction'] == 'pwchange' ) +{ + if ($REQ['password1'] != '' && $REQ['password1'] == $REQ['password2']) + { + $t_user = $conf_db_prefix.'user'; + $sql = "UPDATE $t_user ". + "SET password='".md5($REQ['password1'])."' ". + "WHERE id=".$SESS['userid']; + echo "$sql"; + $res = $db->query($sql); + } + else + { + die("both passwords not equal or blank"); + } + $SESS['useraction'] = 'show'; +} + + + + + + + +if ( $SESS['useraction'] == 'list' ) +{ + $t_user = $conf_db_prefix.'user'; + $sql = "SELECT * FROM $t_user ORDER BY name"; + $res = $db->query($sql); + + $var['action'] = 'user.'.$conf_php; + $var['el'] = array(); + + while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $id = $row['id' ]; + $var['el'][$id] = array(); + $var['el'][$id]['url' ] = 'user.'.$conf_php.'?useraction=edit&userid='.$id; + $var['el'][$id]['name'] = $row['name']; + } + $res->free(); + + output('user_list',$var); +} + + +if ( $SESS['useraction'] == 'edit' ) +{ + // Benutzerdaten lesen + // + $t_user = $conf_db_prefix.'user'; + $sql = "SELECT * FROM $t_user WHERE id=".$SESS['userid']; + $res = $db->query($sql); + $row = $res->fetchRow(DB_FETCHMODE_ASSOC); + + $id = $row['id' ]; + $var = $row; + + $res->free(); + + // Styles lesen + // + $var['allstyles'] = array(); + $handle=opendir( $conf_themedir.'/css' ); + while ($file = readdir ($handle)) + { + if ( eregi('\.css$',$file) ) + { + $var['allstyles'][$file] = $file; + } + } + closedir($handle); + + // Sprachen lesen + // + $var['alllanguages'][''] = array(); + $var['alllanguages'][''] = lang('AUTOMATIC'); + + $ini_isolang = parse_ini_file( $conf_languagedir.'/lang.ini.'.$conf_php ); + + foreach($ini_isolang as $l2=>$text) + { + if (is_file($conf_languagedir.'/'.strtolower($l2).'.ini.'.$conf_php)) + $var['alllanguages'][ $l2 ] = $text; + } + + output('user_edit',$var); +} + + +if ( $SESS['useraction'] == 'groups' ) +{ + // Alle Gruppen ermitteln + // + $var['groups'] = array(); + $t_group = $conf_db_prefix.'group'; + $sql = "SELECT * FROM `$t_group`"; + $res = $db->query($sql); + while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $var['groups'][$row['id']] = $row['name']; + } + + // Mitgliedschaften ermitteln + // + $var['memberships'] = array(); + $t_usergroup = $conf_db_prefix.'usergroup'; + $sql = "SELECT * FROM $t_usergroup ". + "WHERE userid=".$SESS['userid']; + $res = $db->query($sql); + while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $var['memberships'][$row['id']] = $var['groups'][$row['groupid']]; + } + + output('user_groups',$var); +} + + +if ( $SESS['useraction'] == 'pw' ) +{ + output('user_pw',$var); +} + + +if ( $SESS['useraction'] == 'show' ) +{ + // Benutzerdaten lesen + // + $t_user = $conf_db_prefix.'user'; + $sql = "SELECT * FROM $t_user WHERE id=".$SESS['userid']; + $res = $db->query($sql); + $row = $res->fetchRow(DB_FETCHMODE_ASSOC); + + $id = $row['id' ]; + $var = $row; + + $res->free(); + + // Alle Gruppen ermitteln + // + $var['groups'] = array(); + $t_group = $conf_db_prefix.'group'; + $sql = "SELECT * FROM `$t_group`"; + $res = $db->query($sql); + while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $var['groups'][$row['id']] = $row['name']; + } + + // Mitgliedschaften ermitteln + // + $var['memberships'] = array(); + $t_usergroup = $conf_db_prefix.'usergroup'; + $sql = "SELECT * FROM $t_usergroup ". + "WHERE userid=".$SESS['userid']; + $res = $db->query($sql); + while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) ) + { + $var['memberships'][$row['id']] = $var['groups'][$row['groupid']]; + } + + output('user_show',$var); +} + + + + + + + + + + + + + + + + + + + +exit; + + +include( "./config.inc" ); +include( "./functions$phpext" ); + +head(); +?> +<body style="margin:0pt;"> +<br> +<?php + +$dateiname = $datadir.'/'.$userfile; + +$file = file( $dateiname ); + +# Sortieren, damit die Benutzer alphabetisch +# angezeigt werden +# +natcasesort( $file ); + +$nr = 0; + +# Einlesen der Benutzer +# +echo "<center><table cellpadding=\"5\" cellspacing=\"0\" width=\"200\">\n"; + +# Der aktuelle Buchstabe +$buchstabe = ""; + +echo '<tr><td class="ben" colspan="2"><a href="useredit'.$phpext.'?session='.$session.'&useraction=new" title=" '.lang('user_new_description').' ">'.lang('user_new_description').'</a></td></tr>'."\n"; + +foreach( $file as $zeile ) +{ + if ( ! is_integer(strpos( $zeile,'<user ' )) ) + continue; + + $nr ++; + $flag = xmlzeile( $zeile ); + $buchstabe_neu = substr(strtoupper($flag['name']),0,1); + if ( $buchstabe != $buchstabe_neu ) + { + $buchstabe = $buchstabe_neu; + echo '<tr><td colspan="2" class="buchstabe"><br>'.$buchstabe.'</td></tr>'."\n"; + } + echo '<tr><td class="ben"><a href="useredit'.$phpext.'?session='.$session.'&useraction=edit&user_name='.$flag['name'].'" title=" '.lang('user_edit').' ">'.$flag['name'].'</a></td>'."\n"; + echo '<td class="ben">'.$flag['description'].'</td>'."\n"; + echo "</tr>\n"; + +} + +echo "</table><center><br><br>\n"; + + +?> + +<?php fusszeile(); ?> +</body> +</html>+ \ No newline at end of file