tbrehm
2009-03-23 0cef61a3fd0c988cf46f5e45f7e06ab4e1a720d6
Added several input checks.
9 files modified
1 files deleted
4028 ■■■■ changed files
install/tpl/config.inc.php.master 306 ●●●● patch | view | raw | blame | history
interface/lib/app.inc.php 405 ●●●● patch | view | raw | blame | history
interface/web/admin/form/users.tform.php 908 ●●●● patch | view | raw | blame | history
interface/web/capp.php 107 ●●●● patch | view | raw | blame | history
interface/web/clang.php 70 ●●●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php 1390 ●●●● patch | view | raw | blame | history
interface/web/content.php 155 ●●●● patch | view | raw | blame | history
interface/web/index.php 140 ●●●● patch | view | raw | blame | history
interface/web/login/index.php 344 ●●●● patch | view | raw | blame | history
interface/web/nav.php 203 ●●●● patch | view | raw | blame | history
install/tpl/config.inc.php.master
@@ -1,153 +1,153 @@
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//** Web-only
if( !empty($_SERVER['DOCUMENT_ROOT']) ) {
    Header("Pragma: no-cache");
    Header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
    Header("Content-Type: text/html; charset=utf-8");
    //** Set a few php.ini values
    ini_set('register_globals',0);
    ini_set('magic_quotes_gpc', 0);
    if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
        die('Internal Error: GLOBALS override attempt detected');
        exit;
    }
}
//** Set a few php.ini values
set_magic_quotes_runtime(0);
if(isset($app)) unset($app);
if(isset($conf)) unset($conf);
//** SVN Revision
$svn_revision = '$Revision$';
$revision = str_replace(array('Revision:','$',' '), '', $svn_revision);
//** Application
define('ISPC_APP_TITLE', 'ISPConfig');
define('ISPC_APP_VERSION', '3.0.0.9');
//** Database
$conf["db_type"] = 'mysql';
$conf["db_host"] = '{mysql_server_host}';
$conf["db_database"] = '{mysql_server_database}';
$conf["db_user"] = '{mysql_server_ispconfig_user}';
$conf["db_password"] = '{mysql_server_ispconfig_password}';
$conf["db_charset"] = 'utf8'; // same charset as html-charset - (HTML --> MYSQL: "utf-8" --> "utf8", "iso-8859-1" --> "latin1")
define("DB_TYPE",$conf["db_type"]);
define("DB_HOST",$conf["db_host"]);
define("DB_DATABASE",$conf["db_database"]);
define("DB_USER",$conf["db_user"]);
define("DB_PASSWORD",$conf["db_password"]);
define("DB_CHARSET",$conf["db_charset"]);
//** Database settings for the master DB. This setting is only used in multiserver setups
$conf["dbmaster_type"]            = 'mysql';
$conf["dbmaster_host"]            = '{mysql_master_server_host}';
$conf["dbmaster_database"]        = '{mysql_master_server_database}';
$conf["dbmaster_user"]            = '{mysql_master_server_ispconfig_user}';
$conf["dbmaster_password"]        = '{mysql_master_server_ispconfig_password}';
//** Paths
define('ISPC_ROOT_PATH', realpath(dirname(__FILE__).'/../')); // The main ROOT is the parent directory to this file, ie Interface/. NO trailing slashes.
define('ISPC_LIB_PATH', ISPC_ROOT_PATH.'/lib');
define('ISPC_CLASS_PATH', ISPC_ROOT_PATH.'/lib/classes');
define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web');
define('ISPC_THEMES_PATH', ISPC_ROOT_PATH.'/web/themes');
define('ISPC_WEB_TEMP_PATH', ISPC_WEB_PATH.'/temp'); // Path for downloads, accessible via browser
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
//** Paths (Do not change!)
$conf["rootpath"] = substr(dirname(__FILE__),0,-4);
$conf["fs_div"] = "/"; // File system divider, "\\" on windows and "/"" on linux and unix
$conf["classpath"] = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes";
$conf["temppath"] = $conf["rootpath"].$conf["fs_div"]."temp";
define("FS_DIV",$conf["fs_div"]);
define("SERVER_ROOT",$conf["rootpath"]);
define("INCLUDE_ROOT",SERVER_ROOT.FS_DIV."lib");
define("CLASSES_ROOT",INCLUDE_ROOT.FS_DIV."classes");
//** Server
$conf['app_title'] = ISPC_APP_TITLE;
$conf['app_version'] = ISPC_APP_VERSION;
$conf['app_link'] = 'http://www.ispconfig.org/';
$conf['modules_available'] = 'admin,mail,sites,monitor,client,dns,help';
$conf["server_id"] = "{server_id}";
//** Interface
define('ISPC_INTERFACE_MODULES_ENABLED', 'mail,sites,dns,tools');
//** Logging
$conf["log_file"] = '/var/log/ispconfig/ispconfig.log';
$conf["log_priority"] = {ispconfig_log_priority}; // 0 = Debug, 1 = Warning, 2 = Error
//** Allow software package installations
$conf['software_updates_enabled'] = false;
//** Themes
$conf["theme"] = 'default';
$conf["html_content_encoding"] = 'utf-8'; // example: utf-8, iso-8859-1, ...
$conf["logo"] = 'themes/default/images/ispc_logo.png';
//** Default Language
$conf["language"] = 'en';
//** Misc.
$conf["interface_logout_url"] = ""; // example: http://www.domain.tld/
//** Auto Load Modules
$conf["start_db"] = true;
$conf["start_session"] = true;
//** Constants
define("LOGLEVEL_DEBUG",0);
define("LOGLEVEL_WARN",1);
define("LOGLEVEL_ERROR",2);
?>
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//** Web-only
if( !empty($_SERVER['DOCUMENT_ROOT']) ) {
    Header("Pragma: no-cache");
    Header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
    Header("Content-Type: text/html; charset=utf-8");
    //** Set a few php.ini values
    ini_set('register_globals',0);
    ini_set('magic_quotes_gpc', 0);
    if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_REQUEST['s']) || isset($_REQUEST['s_old']) || isset($_REQUEST['conf'])) {
        die('Internal Error: var override attempt detected');
        exit;
    }
}
//** Set a few php.ini values
set_magic_quotes_runtime(0);
if(isset($app)) unset($app);
if(isset($conf)) unset($conf);
//** SVN Revision
$svn_revision = '$Revision$';
$revision = str_replace(array('Revision:','$',' '), '', $svn_revision);
//** Application
define('ISPC_APP_TITLE', 'ISPConfig');
define('ISPC_APP_VERSION', '3.0.0.9');
//** Database
$conf["db_type"] = 'mysql';
$conf["db_host"] = '{mysql_server_host}';
$conf["db_database"] = '{mysql_server_database}';
$conf["db_user"] = '{mysql_server_ispconfig_user}';
$conf["db_password"] = '{mysql_server_ispconfig_password}';
$conf["db_charset"] = 'utf8'; // same charset as html-charset - (HTML --> MYSQL: "utf-8" --> "utf8", "iso-8859-1" --> "latin1")
define("DB_TYPE",$conf["db_type"]);
define("DB_HOST",$conf["db_host"]);
define("DB_DATABASE",$conf["db_database"]);
define("DB_USER",$conf["db_user"]);
define("DB_PASSWORD",$conf["db_password"]);
define("DB_CHARSET",$conf["db_charset"]);
//** Database settings for the master DB. This setting is only used in multiserver setups
$conf["dbmaster_type"]            = 'mysql';
$conf["dbmaster_host"]            = '{mysql_master_server_host}';
$conf["dbmaster_database"]        = '{mysql_master_server_database}';
$conf["dbmaster_user"]            = '{mysql_master_server_ispconfig_user}';
$conf["dbmaster_password"]        = '{mysql_master_server_ispconfig_password}';
//** Paths
define('ISPC_ROOT_PATH', realpath(dirname(__FILE__).'/../')); // The main ROOT is the parent directory to this file, ie Interface/. NO trailing slashes.
define('ISPC_LIB_PATH', ISPC_ROOT_PATH.'/lib');
define('ISPC_CLASS_PATH', ISPC_ROOT_PATH.'/lib/classes');
define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web');
define('ISPC_THEMES_PATH', ISPC_ROOT_PATH.'/web/themes');
define('ISPC_WEB_TEMP_PATH', ISPC_WEB_PATH.'/temp'); // Path for downloads, accessible via browser
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
//** Paths (Do not change!)
$conf["rootpath"] = substr(dirname(__FILE__),0,-4);
$conf["fs_div"] = "/"; // File system divider, "\\" on windows and "/"" on linux and unix
$conf["classpath"] = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes";
$conf["temppath"] = $conf["rootpath"].$conf["fs_div"]."temp";
define("FS_DIV",$conf["fs_div"]);
define("SERVER_ROOT",$conf["rootpath"]);
define("INCLUDE_ROOT",SERVER_ROOT.FS_DIV."lib");
define("CLASSES_ROOT",INCLUDE_ROOT.FS_DIV."classes");
//** Server
$conf['app_title'] = ISPC_APP_TITLE;
$conf['app_version'] = ISPC_APP_VERSION;
$conf['app_link'] = 'http://www.ispconfig.org/';
$conf['modules_available'] = 'admin,mail,sites,monitor,client,dns,help';
$conf["server_id"] = "{server_id}";
//** Interface
define('ISPC_INTERFACE_MODULES_ENABLED', 'mail,sites,dns,tools');
//** Logging
$conf["log_file"] = '/var/log/ispconfig/ispconfig.log';
$conf["log_priority"] = {ispconfig_log_priority}; // 0 = Debug, 1 = Warning, 2 = Error
//** Allow software package installations
$conf['software_updates_enabled'] = false;
//** Themes
$conf["theme"] = 'default';
$conf["html_content_encoding"] = 'utf-8'; // example: utf-8, iso-8859-1, ...
$conf["logo"] = 'themes/default/images/ispc_logo.png';
//** Default Language
$conf["language"] = 'en';
//** Misc.
$conf["interface_logout_url"] = ""; // example: http://www.domain.tld/
//** Auto Load Modules
$conf["start_db"] = true;
$conf["start_session"] = true;
//** Constants
define("LOGLEVEL_DEBUG",0);
define("LOGLEVEL_WARN",1);
define("LOGLEVEL_ERROR",2);
?>
interface/lib/app.inc.php
@@ -1,201 +1,206 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    Application Class
*/
ob_start('ob_gzhandler');
class app {
    private $_language_inc = 0;
    private $_wb;
    private $_loaded_classes = array();
    private $_conf;
    public function __construct()
    {
        global $conf;
        $this->_conf = $conf;
        if($this->_conf['start_db'] == true) {
            $this->load('db_'.$this->_conf['db_type']);
            $this->db = new db;
        }
        //* Start the session
        if($this->_conf['start_session'] == true) {
            session_start();
            //* Initialize session variables
            if(!isset($_SESSION['s']['id']) ) $_SESSION['s']['id'] = session_id();
            if(empty($_SESSION['s']['theme'])) $_SESSION['s']['theme'] = $conf['theme'];
            if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language'];
        }
        $this->uses('auth');
    }
    public function uses($classes)
    {
        $cl = explode(',', $classes);
        if(is_array($cl)) {
            foreach($cl as $classname){
                $classname = trim($classname);
                //* Class is not loaded so load it
                if(!array_key_exists($classname, $this->_loaded_classes)){
                    include_once(ISPC_CLASS_PATH."/$classname.inc.php");
                    $this->$classname = new $classname();
                    $this->_loaded_classes[$classname] = true;
                }
            }
        }
    }
    public function load($files)
    {
        $fl = explode(',', $files);
        if(is_array($fl)) {
            foreach($fl as $file){
                $file = trim($file);
                include_once(ISPC_CLASS_PATH."/$file.inc.php");
            }
        }
    }
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function log($msg, $priority = 0)
    {
        if($priority >= $this->_conf['log_priority']) {
            if (is_writable($this->_conf['log_file'])) {
                if (!$fp = fopen ($this->_conf['log_file'], 'a')) {
                    $this->error('Unable to open logfile.');
                }
                if (!fwrite($fp, date('d.m.Y-H:i').' - '. $msg."\r\n")) {
                    $this->error('Unable to write to logfile.');
                }
                fclose($fp);
            } else {
                $this->error('Unable to write to logfile.');
            }
        }
    }
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function error($msg, $next_link = '', $stop = true, $priority = 1)
    {
        //$this->uses("error");
        //$this->error->message($msg, $priority);
        if($stop == true){
            $msg = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../themes/default/css/central.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="uniForm">
  <div id="errorMsg">
    <h3>Error</h3>
      <ol>
        <li>'.$msg;
            if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a>';
            $msg .= '</li>
      </ol>
  </div>
</div>
</body>
</html>';
            die($msg);
        } else {
            echo $msg;
            if($next_link != '') echo "<a href='$next_link'>Next</a>";
        }
    }
    /** Loads language */
    public function lng($text)
    {
        if($this->_language_inc != 1) {
            //* loading global and module Wordbook
            // TODO: this need to be made clearer somehow - pedro
            @include_once(ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng');
            if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['language'])) {
                $lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng';
                if(!file_exists($lng_file)) $lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
                @include_once($lng_file);
            }
            $this->_wb = $wb;
            $this->_language_inc = 1;
        }
        if(!empty($this->_wb[$text])) {
            $text = $this->_wb[$text];
        }
        return $text;
    }
    public function tpl_defaults()
    {
        $this->tpl->setVar('app_title', $this->_conf['app_title']);
        $this->tpl->setVar('app_version', $this->_conf['app_version']);
        $this->tpl->setVar('app_link', $this->_conf['app_link']);
        if(isset($this->_conf['app_logo']) && $this->_conf['app_logo'] != '' && @is_file($this->_conf['app_logo'])){
            $this->tpl->setVar('app_logo', '<img src="'.$this->_conf['app_logo'].'">');
        } else {
            $this->tpl->setVar('app_logo', '&nbsp;');
        }
        $this->tpl->setVar('phpsessid', session_id());
        $this->tpl->setVar('theme', $_SESSION['s']['theme']);
        $this->tpl->setVar('html_content_encoding', $this->_conf['html_content_encoding']);
        $this->tpl->setVar('delete_confirmation', $this->lng('delete_confirmation'));
        //print_r($_SESSION);
        if(isset($_SESSION['s']['module']['name'])) {
            $this->tpl->setVar('app_module', $_SESSION['s']['module']['name']);
        }
        if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') {
            $this->tpl->setVar('is_admin', 1);
        }
        if(isset($_SESSION['s']['user']) && $this->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $this->tpl->setVar('is_reseller', 1);
        }
    }
} // end class
//** Initialize application (app) object
//* possible future =  new app($conf);
$app = new app();
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    Application Class
*/
ob_start('ob_gzhandler');
class app {
    private $_language_inc = 0;
    private $_wb;
    private $_loaded_classes = array();
    private $_conf;
    public function __construct()
    {
        global $conf;
        if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_REQUEST['s']) || isset($_REQUEST['s_old']) || isset($_REQUEST['conf'])) {
            die('Internal Error: var override attempt detected');
        }
        $this->_conf = $conf;
        if($this->_conf['start_db'] == true) {
            $this->load('db_'.$this->_conf['db_type']);
            $this->db = new db;
        }
        //* Start the session
        if($this->_conf['start_session'] == true) {
            session_start();
            //* Initialize session variables
            if(!isset($_SESSION['s']['id']) ) $_SESSION['s']['id'] = session_id();
            if(empty($_SESSION['s']['theme'])) $_SESSION['s']['theme'] = $conf['theme'];
            if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language'];
        }
        $this->uses('auth');
    }
    public function uses($classes)
    {
        $cl = explode(',', $classes);
        if(is_array($cl)) {
            foreach($cl as $classname){
                $classname = trim($classname);
                //* Class is not loaded so load it
                if(!array_key_exists($classname, $this->_loaded_classes)){
                    include_once(ISPC_CLASS_PATH."/$classname.inc.php");
                    $this->$classname = new $classname();
                    $this->_loaded_classes[$classname] = true;
                }
            }
        }
    }
    public function load($files)
    {
        $fl = explode(',', $files);
        if(is_array($fl)) {
            foreach($fl as $file){
                $file = trim($file);
                include_once(ISPC_CLASS_PATH."/$file.inc.php");
            }
        }
    }
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function log($msg, $priority = 0)
    {
        if($priority >= $this->_conf['log_priority']) {
            if (is_writable($this->_conf['log_file'])) {
                if (!$fp = fopen ($this->_conf['log_file'], 'a')) {
                    $this->error('Unable to open logfile.');
                }
                if (!fwrite($fp, date('d.m.Y-H:i').' - '. $msg."\r\n")) {
                    $this->error('Unable to write to logfile.');
                }
                fclose($fp);
            } else {
                $this->error('Unable to write to logfile.');
            }
        }
    }
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function error($msg, $next_link = '', $stop = true, $priority = 1)
    {
        //$this->uses("error");
        //$this->error->message($msg, $priority);
        if($stop == true){
            $msg = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../themes/default/css/central.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="uniForm">
  <div id="errorMsg">
    <h3>Error</h3>
      <ol>
        <li>'.$msg;
            if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a>';
            $msg .= '</li>
      </ol>
  </div>
</div>
</body>
</html>';
            die($msg);
        } else {
            echo $msg;
            if($next_link != '') echo "<a href='$next_link'>Next</a>";
        }
    }
    /** Loads language */
    public function lng($text)
    {
        if($this->_language_inc != 1) {
            //* loading global and module Wordbook
            // TODO: this need to be made clearer somehow - pedro
            @include_once(ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng');
            if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['language'])) {
                $lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng';
                if(!file_exists($lng_file)) $lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
                @include_once($lng_file);
            }
            $this->_wb = $wb;
            $this->_language_inc = 1;
        }
        if(!empty($this->_wb[$text])) {
            $text = $this->_wb[$text];
        }
        return $text;
    }
    public function tpl_defaults()
    {
        $this->tpl->setVar('app_title', $this->_conf['app_title']);
        $this->tpl->setVar('app_version', $this->_conf['app_version']);
        $this->tpl->setVar('app_link', $this->_conf['app_link']);
        if(isset($this->_conf['app_logo']) && $this->_conf['app_logo'] != '' && @is_file($this->_conf['app_logo'])){
            $this->tpl->setVar('app_logo', '<img src="'.$this->_conf['app_logo'].'">');
        } else {
            $this->tpl->setVar('app_logo', '&nbsp;');
        }
        $this->tpl->setVar('phpsessid', session_id());
        $this->tpl->setVar('theme', $_SESSION['s']['theme']);
        $this->tpl->setVar('html_content_encoding', $this->_conf['html_content_encoding']);
        $this->tpl->setVar('delete_confirmation', $this->lng('delete_confirmation'));
        //print_r($_SESSION);
        if(isset($_SESSION['s']['module']['name'])) {
            $this->tpl->setVar('app_module', $_SESSION['s']['module']['name']);
        }
        if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') {
            $this->tpl->setVar('is_admin', 1);
        }
        if(isset($_SESSION['s']['user']) && $this->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $this->tpl->setVar('is_reseller', 1);
        }
    }
} // end class
//** Initialize application (app) object
//* possible future =  new app($conf);
$app = new app();
?>
interface/web/admin/form/users.tform.php
@@ -1,455 +1,455 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    Form Definition
    Tabellendefinition
    Datentypen:
    - INTEGER (Wandelt Ausdr�cke in Int um)
    - DOUBLE
    - CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
    - VARCHAR (kein weiterer Format Check)
    - TEXT (kein weiterer Format Check)
    - DATE (Datumsformat, Timestamp Umwandlung)
    Formtype:
    - TEXT (normales Textfeld)
    - TEXTAREA (normales Textfeld)
    - PASSWORD (Feldinhalt wird nicht angezeigt)
    - SELECT (Gibt Werte als option Feld aus)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hinweis:
    Das ID-Feld ist nicht bei den Table Values einzuf�gen.
*/
$form['title']             = 'Users';
$form['description']     = 'Form to edit systemusers.';
$form['name']             = 'users';
$form['action']            = 'users_edit.php';
$form['db_table']        = 'sys_user';
$form['db_table_idx']    = 'userid';
$form["db_history"]        = "no";
$form['tab_default']    = 'users';
$form['list_default']    = 'users_list.php';
$form['auth']            = 'yes';
//* 0 = id of the user, > 0 id must match with id of current user
$form['auth_preset']['userid']  = 0;
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
$form['auth_preset']['groupid'] = 0;
//** Permissions are: r = read, i = insert, u = update, d = delete
$form['auth_preset']['perm_user']  = 'riud';
$form['auth_preset']['perm_group'] = 'riud';
$form['auth_preset']['perm_other'] = '';
//* Pick out modules
$modules_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_dir(ISPC_WEB_PATH."/$file")) {
            if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer') {
                $modules_list[$file] = $file;
            }
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Pick out groups
$groups_list = array();
$tmp_records = $app->db->queryAllRecords('SELECT groupid, name FROM sys_group ORDER BY name');
if(is_array($tmp_records)) {
    foreach($tmp_records as $tmp_rec) {
        $groups_list[$tmp_rec['groupid']] = $tmp_rec['name'];
    }
}
$form['tabs']['users'] = array (
    'title'     => 'Users',
    'width'     => 80,
    'template'     => 'templates/users_user_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,50}$/',
                                                        'errmsg'=> 'username_err'),
                                    ),
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '30',
            'rows'        => '',
            'cols'        => ''
        ),
        'passwort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '100',
            'rows'        => '',
            'cols'        => ''
        ),
        'modules' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'admin,forms',
            'value'        => $modules_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'startmodule' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $modules_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'app_theme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'typ' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'user',
            'value'        => array ('user' => 'user', 'admin' => 'admin'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'active' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'CHECKBOX',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => array(0 => 0,1 => 1),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '2',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
/*
$form['tabs']['address'] = array (
    'title'     => 'Address',
    'width'     => 80,
    'template'     => 'templates/users_address_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vorname' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'unternehmen' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'strasse' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'ort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'plz' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'land' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'telefon' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
*/
$form['tabs']['groups'] = array (
    'title'     => 'Groups',
    'width'     => 80,
    'template'     => 'templates/users_groups_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'default_group' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'groups' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    Form Definition
    Tabellendefinition
    Datentypen:
    - INTEGER (Wandelt Ausdr�cke in Int um)
    - DOUBLE
    - CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
    - VARCHAR (kein weiterer Format Check)
    - TEXT (kein weiterer Format Check)
    - DATE (Datumsformat, Timestamp Umwandlung)
    Formtype:
    - TEXT (normales Textfeld)
    - TEXTAREA (normales Textfeld)
    - PASSWORD (Feldinhalt wird nicht angezeigt)
    - SELECT (Gibt Werte als option Feld aus)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hinweis:
    Das ID-Feld ist nicht bei den Table Values einzuf�gen.
*/
$form['title']             = 'Users';
$form['description']     = 'Form to edit systemusers.';
$form['name']             = 'users';
$form['action']            = 'users_edit.php';
$form['db_table']        = 'sys_user';
$form['db_table_idx']    = 'userid';
$form["db_history"]        = "no";
$form['tab_default']    = 'users';
$form['list_default']    = 'users_list.php';
$form['auth']            = 'yes';
//* 0 = id of the user, > 0 id must match with id of current user
$form['auth_preset']['userid']  = 0;
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
$form['auth_preset']['groupid'] = 0;
//** Permissions are: r = read, i = insert, u = update, d = delete
$form['auth_preset']['perm_user']  = 'riud';
$form['auth_preset']['perm_group'] = 'riud';
$form['auth_preset']['perm_other'] = '';
//* Pick out modules
$modules_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_dir(ISPC_WEB_PATH."/$file")) {
            if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer') {
                $modules_list[$file] = $file;
            }
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Pick out groups
$groups_list = array();
$tmp_records = $app->db->queryAllRecords('SELECT groupid, name FROM sys_group ORDER BY name');
if(is_array($tmp_records)) {
    foreach($tmp_records as $tmp_rec) {
        $groups_list[$tmp_rec['groupid']] = $tmp_rec['name'];
    }
}
$form['tabs']['users'] = array (
    'title'     => 'Users',
    'width'     => 80,
    'template'     => 'templates/users_user_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_err'),
                                    ),
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '30',
            'rows'        => '',
            'cols'        => ''
        ),
        'passwort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '100',
            'rows'        => '',
            'cols'        => ''
        ),
        'modules' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'admin,forms',
            'value'        => $modules_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'startmodule' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $modules_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'app_theme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'typ' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'user',
            'value'        => array ('user' => 'user', 'admin' => 'admin'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'active' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'CHECKBOX',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => array(0 => 0,1 => 1),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '2',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
/*
$form['tabs']['address'] = array (
    'title'     => 'Address',
    'width'     => 80,
    'template'     => 'templates/users_address_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vorname' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'unternehmen' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'strasse' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'ort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'plz' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'land' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'telefon' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
*/
$form['tabs']['groups'] = array (
    'title'     => 'Groups',
    'width'     => 80,
    'template'     => 'templates/users_groups_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'default_group' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'groups' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
?>
interface/web/capp.php
@@ -1,53 +1,56 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
// importiere Modul
$mod = $_REQUEST["mod"];
// Checke ob User eingeloggt
if(!is_array($_SESSION["s"]["user"])) header("Location: index.php?phpsessid=".$_SESSION["s"]["id"]);
// checke ob User Modul verwenden darf
$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]);
if(!in_array($mod,$user_modules)) $app->error($app->lng(301));
// lade Moduldaten in Session
if(is_file($mod."/lib/module.conf.php")) {
    include_once($mod."/lib/module.conf.php");
    $_SESSION["s"]["module"] = $module;
    echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
} else {
    $app->error($app->lng(302));
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
// importiere Modul
$mod = $_REQUEST["mod"];
// Checke ob User eingeloggt
if($_SESSION["s"]["user"]['active'] != 1) {
    header("Location: index.php?phpsessid=".$_SESSION["s"]["id"]);
    die();
}
// checke ob User Modul verwenden darf
$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]);
if(!in_array($mod,$user_modules)) $app->error($app->lng(301));
// lade Moduldaten in Session
if(is_file($mod."/lib/module.conf.php")) {
    include_once($mod."/lib/module.conf.php");
    $_SESSION["s"]["module"] = $module;
    echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
} else {
    $app->error($app->lng(302));
}
?>
interface/web/clang.php
File was deleted
interface/web/client/form/client.tform.php
@@ -1,696 +1,696 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,50}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'MD5',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'MD5',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
interface/web/content.php
@@ -1,79 +1,78 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$module = $_REQUEST["s_mod"];
$page = $_REQUEST["s_pg"];
if(!preg_match("/^[a-z]{0,20}$/i", $module)) die('module name contains unallowed chars.');
if(!preg_match("/^[a-z]{0,20}$/i", $page)) die('page name contains unallowed chars.');
if(is_file("$module/$page.php")) {
    include_once("$module/$page.php");
    $classname = $module.'_'.$page;
    $page = new $classname();
    $content = $page->render();
    if($page->status == 'OK') {
        echo $content;
    } elseif($page->status == 'REDIRECT') {
        $target_parts = explode(':',$page->target);
        $module = $target_parts[0];
        $page = $target_parts[1];
        if(!preg_match("/^[a-z]{2,20}$/i", $module)) die('target module name contains unallowed chars.');
        if(!preg_match("/^[a-z]{2,20}$/i", $page)) die('target page name contains unallowed chars.');
        if(is_file("$module/$page.php")) {
            include_once("$module/$page.php");
            $classname = $module.'_'.$page;
            $page = new $classname();
            $content = $page->render();
            if($page->status == 'OK') {
                echo $content;
            }
        }
    }
} elseif (is_array($_SESSION["s"]['user']) or is_array($_SESSION["s"]["module"])) {
    // If the user is logged in, we try to load the default page of the module
    die('hhhhh');
} else {
    die('Page does not exist.');
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$module = $_REQUEST["s_mod"];
$page = $_REQUEST["s_pg"];
if(!preg_match("/^[a-z]{0,20}$/i", $module)) die('module name contains unallowed chars.');
if(!preg_match("/^[a-z]{0,20}$/i", $page)) die('page name contains unallowed chars.');
if(is_file("$module/$page.php")) {
    include_once("$module/$page.php");
    $classname = $module.'_'.$page;
    $page = new $classname();
    $content = $page->render();
    if($page->status == 'OK') {
        echo $content;
    } elseif($page->status == 'REDIRECT') {
        $target_parts = explode(':',$page->target);
        $module = $target_parts[0];
        $page = $target_parts[1];
        if(!preg_match("/^[a-z]{2,20}$/i", $module)) die('target module name contains unallowed chars.');
        if(!preg_match("/^[a-z]{2,20}$/i", $page)) die('target page name contains unallowed chars.');
        if(is_file("$module/$page.php")) {
            include_once("$module/$page.php");
            $classname = $module.'_'.$page;
            $page = new $classname();
            $content = $page->render();
            if($page->status == 'OK') {
                echo $content;
            }
        }
    }
} elseif (is_array($_SESSION["s"]['user']) or is_array($_SESSION["s"]["module"])) {
    // If the user is logged in, we try to load the default page of the module
    die('- error -');
} else {
    die('Page does not exist.');
}
?>
interface/web/index.php
@@ -1,101 +1,41 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
error_reporting(E_ALL|E_STRICT);
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$app->uses('tpl');
$app->tpl->newTemplate('main.tpl.htm');
/*
// Checke User Login and current module
if(!is_array($_SESSION["s"]['user']) or !is_array($_SESSION["s"]["module"])) {
    // Loading Login Module
    include_once('login/lib/module.conf.php');
    $_SESSION["s"]['module'] = $module;
    $topnav[] = array(    'title'     => "Login",
                          'active'     => 1);
    $module = null;
    unset($module);
} else {
    // Loading modules of the user and building top navigation
    $modules = explode(',',$_SESSION["s"]["user"]["modules"]);
    if(is_array($modules)) {
        foreach($modules as $mt) {
            if(is_file($mt."/lib/module.conf.php")) {
                include_once($mt."/lib/module.conf.php");
                $active = ($module["name"] == $_SESSION["s"]["module"]["name"])?1:0;
                $topnav[] = array(    'title'     => $app->lng($module["title"]),
                                      'active'     => $active,
                                    'module'    => $module["name"]);
            }
        }
    }
}
// Topnavigation
$app->tpl->setLoop('nav_top',$topnav);
// Loading Module part
$app->tpl->setInclude('module_tpl',$_SESSION["s"]["module"]["template"]);
// translating module navigation
$nav_translated = array();
if(is_array($_SESSION["s"]["module"]["nav"])) {
    foreach($_SESSION["s"]["module"]["nav"] as $nav) {
        $tmp_items = array();
        foreach($nav["items"] as $item) {
            $item["title"] = $app->lng($item["title"]);
            $tmp_items[] = $item;
        }
        $nav["title"] = $app->lng($nav["title"]);
        $nav["items"] = $tmp_items;
        $nav_translated[] = $nav;
    }
} else {
    $nav_translated = null;
}
// Loading left navigation
//$app->tpl->setLoop('nav_left',$_SESSION["s"]["module"]["nav"]);
$app->tpl->setLoop('nav_left',$nav_translated);
// Setting startpage
$app->tpl->setVar('startpage',$_SESSION["s"]["module"]["startpage"]);
$app->tpl->setVar('navframe_page',$_SESSION["s"]["module"]["navframe_page"]);
*/
$app->tpl_defaults();
$app->tpl->pparse();
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
error_reporting(E_ALL|E_STRICT);
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$app->uses('tpl');
$app->tpl->newTemplate('main.tpl.htm');
$app->tpl_defaults();
$app->tpl->pparse();
?>
interface/web/login/index.php
@@ -1,171 +1,175 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
class login_index {
    public $status = '';
    private $target = '';
    private $app;
    private $conf;
    public function render() {
        global $app, $conf;
        /* Redirect to page, if login form was NOT send */
        if(count($_POST) == 0) {
            if(isset($_SESSION['s']['user']) && is_array($_SESSION['s']['user']) && is_array($_SESSION['s']['module'])) {
                die('HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage']);
            }
        }
        $app->uses('tpl');
        $app->tpl->newTemplate('form.tpl.htm');
        $error = '';
        //* Login Form was send
        if(count($_POST) > 0) {
            // iporting variables
            $ip       = $app->db->quote(ip2long($_SERVER['REMOTE_ADDR']));
            $username = $app->db->quote($_POST['username']);
            $passwort = $app->db->quote($_POST['passwort']);
            if($username != '' and $passwort != '') {
                /*
                 *  Check, if there is a "login as" instead of a "normal" login
                 */
                if (isset($_SESSION['s']['user'])){
                    /*
                     * only the admin can "login as" so if the user is NOT a admin, we
                     * open the startpage (after killing the old session), so the user
                     * is logout and has to start again!
                     */
                    if ($_SESSION['s']['user']['typ'] != 'admin') {
                        /*
                         * The actual user is NOT a admin, but maybe the admin
                         * has logged in as "normal" user bevore...
                         */
                        if (isset($_SESSION['s_old'])&& ($_SESSION['s_old']['user']['typ'] == 'admin')){
                            /* The "old" user is admin, so everything is ok */
                        }
                        else {
                            die("You don't have the right to 'login as'!");
                        }
                    }
                    $loginAs = true;
                }
                else {
                    /* normal login */
                    $loginAs = false;
                }
                //* Check if there already wrong logins
                $sql = "SELECT * FROM `attempts_login` WHERE `ip`= '{$ip}' AND  `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1";
                $alreadyfailed = $app->db->queryOneRecord($sql);
                //* login to much wrong
                if($alreadyfailed['times'] > 5) {
                    $error = $app->lng(1004);
                } else {
                    if ($loginAs){
                        $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and PASSWORT = '". $passwort. "'";
                    }
                    else {
                        $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and ( PASSWORT = '".md5($passwort)."' or PASSWORT = password('$passwort') )";
                    }
                    $user = $app->db->queryOneRecord($sql);
                    if($user) {
                        if($user['active'] == 1) {
                            // User login right, so attempts can be deleted
                            $sql = "DELETE FROM `attempts_login` WHERE `ip`='{$ip}'";
                            $app->db->query($sql);
                            $user = $app->db->toLower($user);
                            if ($loginAs) $oldSession = $_SESSION['s'];
                            $_SESSION = array();
                            if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
                            $_SESSION['s']['user'] = $user;
                            $_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
                            $_SESSION['s']['language'] = $user['language'];
                            $_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
                            if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
                                include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
                                $_SESSION['s']['module'] = $module;
                            }
                            echo 'HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage'];
                               exit;
                         } else {
                            $error = $app->lng(1003);
                        }
                    } else {
                        if(!$alreadyfailed['times'] )
                        {
                            //* user login the first time wrong
                            $sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES ('{$ip}', 1, NOW())";
                            $app->db->query($sql);
                        } elseif($alreadyfailed['times'] >= 1) {
                            //* update times wrong
                            $sql = "UPDATE `attempts_login` SET `times`=`times`+1, `login_time`=NOW() WHERE `login_time` >= '{$time}' LIMIT 1";
                            $app->db->query($sql);
                        }
                        //* Incorrect login - Username and password incorrect
                        $error = $app->lng(1002);
                        if($app->db->errorMessage != '') $error .= '<br />'.$app->db->errorMessage != '';
                       }
                }
              } else {
                   //* Username or password empty
                $error = $app->lng(1001);
            }
        }
        if($error != ''){
              $error = '<div class="box box_error"><h1>Error</h1>'.$error.'</div>';
        }
        $app->tpl->setVar('error', $error);
        $app->tpl->setInclude('content_tpl','login/templates/index.htm');
        $app->tpl_defaults();
        $this->status = 'OK';
        return $app->tpl->grab();
    } // << end function
} // << end class
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
class login_index {
    public $status = '';
    private $target = '';
    private $app;
    private $conf;
    public function render() {
        global $app, $conf;
        /* Redirect to page, if login form was NOT send */
        if(count($_POST) == 0) {
            if(isset($_SESSION['s']['user']) && is_array($_SESSION['s']['user']) && is_array($_SESSION['s']['module'])) {
                die('HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage']);
            }
        }
        $app->uses('tpl');
        $app->tpl->newTemplate('form.tpl.htm');
        $error = '';
        //* Login Form was send
        if(count($_POST) > 0) {
            //** Check variables
            if(!preg_match("/^[\w\.\-\_]{1,64}$/", $_POST['username'])) $error = 'Username contains unallowed characters or is longer then 64 characters.';
            if(!preg_match("/^.{1,64}$/i", $_POST['passwort'])) $error = 'The password length is > 64 characters.';
            //** iporting variables
            $ip       = $app->db->quote(ip2long($_SERVER['REMOTE_ADDR']));
            $username = $app->db->quote($_POST['username']);
            $passwort = $app->db->quote($_POST['passwort']);
            $loginAs  = false;
            if($username != '' && $passwort != '' && $error == '') {
                /*
                 *  Check, if there is a "login as" instead of a "normal" login
                 */
                if (isset($_SESSION['s']['user']) && $_SESSION['s']['user']['active'] == 1){
                    /*
                     * only the admin can "login as" so if the user is NOT a admin, we
                     * open the startpage (after killing the old session), so the user
                     * is logout and has to start again!
                     */
                    if ($_SESSION['s']['user']['typ'] != 'admin') {
                        /*
                         * The actual user is NOT a admin, but maybe the admin
                         * has logged in as "normal" user bevore...
                         */
                        if (isset($_SESSION['s_old'])&& ($_SESSION['s_old']['user']['typ'] == 'admin')){
                            /* The "old" user is admin, so everything is ok */
                        }
                        else {
                            die("You don't have the right to 'login as'!");
                        }
                    }
                    $loginAs = true;
                }
                else {
                    /* normal login */
                    $loginAs = false;
                }
                //* Check if there are already wrong logins
                $sql = "SELECT * FROM `attempts_login` WHERE `ip`= '{$ip}' AND  `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1";
                $alreadyfailed = $app->db->queryOneRecord($sql);
                //* login to much wrong
                if($alreadyfailed['times'] > 5) {
                    $error = $app->lng(1004);
                } else {
                    if ($loginAs){
                        $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and PASSWORT = '". $passwort. "'";
                    } else {
                        $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and ( PASSWORT = '".md5($passwort)."' or PASSWORT = password('$passwort') )";
                    }
                    $user = $app->db->queryOneRecord($sql);
                    if($user) {
                        if($user['active'] == 1) {
                            // User login right, so attempts can be deleted
                            $sql = "DELETE FROM `attempts_login` WHERE `ip`='{$ip}'";
                            $app->db->query($sql);
                            $user = $app->db->toLower($user);
                            if ($loginAs) $oldSession = $_SESSION['s'];
                            $_SESSION = array();
                            if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
                            $_SESSION['s']['user'] = $user;
                            $_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
                            $_SESSION['s']['language'] = $user['language'];
                            $_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
                            if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
                                include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
                                $_SESSION['s']['module'] = $module;
                            }
                            echo 'HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage'];
                               exit;
                         } else {
                            $error = $app->lng(1003);
                        }
                    } else {
                        if(!$alreadyfailed['times'] )
                        {
                            //* user login the first time wrong
                            $sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES ('{$ip}', 1, NOW())";
                            $app->db->query($sql);
                        } elseif($alreadyfailed['times'] >= 1) {
                            //* update times wrong
                            $sql = "UPDATE `attempts_login` SET `times`=`times`+1, `login_time`=NOW() WHERE `login_time` >= '{$time}' LIMIT 1";
                            $app->db->query($sql);
                        }
                        //* Incorrect login - Username and password incorrect
                        $error = $app->lng(1002);
                        if($app->db->errorMessage != '') $error .= '<br />'.$app->db->errorMessage != '';
                       }
                }
              } else {
                   //* Username or password empty
                $error = $app->lng(1001);
            }
        }
        if($error != ''){
              $error = '<div class="box box_error"><h1>Error</h1>'.$error.'</div>';
        }
        $app->tpl->setVar('error', $error);
        $app->tpl->setInclude('content_tpl','login/templates/index.htm');
        $app->tpl_defaults();
        $this->status = 'OK';
        return $app->tpl->grab();
    } // << end function
} // << end class
?>
interface/web/nav.php
@@ -1,103 +1,102 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$app->uses('tpl');
//die('HHH');
//** Top Naviation
if(isset($_GET['nav']) && $_GET['nav'] == 'top') {
    $app->tpl->newTemplate('topnav.tpl.htm');
    //* Check User Login and current module
    if(!isset($_SESSION['s']['user']) or !is_array($_SESSION['s']['user']) or !is_array($_SESSION['s']['module'])) {
        //*  Loading Login Module
        include_once('login/lib/module.conf.php');
        $_SESSION['s']['module'] = $module;
        $topnav[] = array(    'title'     => 'Login',
                              'active'     => 1);
        $module = null;
        unset($module);
    } else {
        //* Loading modules of the user and building top navigation
        $modules = explode(',', $_SESSION['s']['user']['modules']);
        if(is_array($modules)) {
            foreach($modules as $mt) {
                if(is_file($mt.'/lib/module.conf.php')) {
                    include_once($mt.'/lib/module.conf.php');
                    $active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0;
                    $topnav[] = array(    'title'     => $app->lng($module['title']),
                                          'active'     => $active,
                                        'module'    => $module['name']);
                }
            }
        }
    }
    //* Topnavigation
    $app->tpl->setLoop('nav_top',$topnav);
}
//** Side Naviation
if(isset($_GET['nav']) && $_GET['nav'] == 'side') {
    $app->tpl->newTemplate('sidenav.tpl.htm');
    //* translating module navigation
    $nav_translated = array();
    if(isset($_SESSION['s']['module']['nav']) && is_array($_SESSION['s']['module']['nav'])) {
        foreach($_SESSION['s']['module']['nav'] as $nav) {
            $tmp_items = array();
            foreach($nav['items'] as $item) {
                $item['title'] = $app->lng($item['title']);
                $tmp_items[] = $item;
            }
            $nav['title'] = $app->lng($nav['title']);
            $nav['startpage'] = $nav['items'][0]['link'];
            $nav['items'] = $tmp_items;
            $nav_translated[] = $nav;
        }
    } else {
        $nav_translated = null;
    }
    $app->tpl->setLoop('nav_left',$nav_translated);
}
$app->tpl_defaults();
$app->tpl->pparse();
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../lib/config.inc.php');
require_once('../lib/app.inc.php');
$app->uses('tpl');
//** Top Naviation
if(isset($_GET['nav']) && $_GET['nav'] == 'top') {
    $app->tpl->newTemplate('topnav.tpl.htm');
    //* Check User Login and current module
    if(isset($_SESSION["s"]["user"]) && $_SESSION["s"]["user"]['active'] == 1 && is_array($_SESSION['s']['module'])) {
        //* Loading modules of the user and building top navigation
        $modules = explode(',', $_SESSION['s']['user']['modules']);
        if(is_array($modules)) {
            foreach($modules as $mt) {
                if(is_file($mt.'/lib/module.conf.php')) {
                    if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.');
                    include_once($mt.'/lib/module.conf.php');
                    $active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0;
                    $topnav[] = array(    'title'     => $app->lng($module['title']),
                                          'active'     => $active,
                                        'module'    => $module['name']);
                }
            }
        }
    } else {
        //*  Loading Login Module
        include_once('login/lib/module.conf.php');
        $_SESSION['s']['module'] = $module;
        $topnav[] = array(    'title'     => 'Login',
                              'active'     => 1);
        $module = null;
        unset($module);
    }
    //* Topnavigation
    $app->tpl->setLoop('nav_top',$topnav);
}
//** Side Naviation
if(isset($_GET['nav']) && $_GET['nav'] == 'side') {
    $app->tpl->newTemplate('sidenav.tpl.htm');
    //* translating module navigation
    $nav_translated = array();
    if(isset($_SESSION['s']['module']['nav']) && is_array($_SESSION['s']['module']['nav'])) {
        foreach($_SESSION['s']['module']['nav'] as $nav) {
            $tmp_items = array();
            foreach($nav['items'] as $item) {
                $item['title'] = $app->lng($item['title']);
                $tmp_items[] = $item;
            }
            $nav['title'] = $app->lng($nav['title']);
            $nav['startpage'] = $nav['items'][0]['link'];
            $nav['items'] = $tmp_items;
            $nav_translated[] = $nav;
        }
    } else {
        $nav_translated = null;
    }
    $app->tpl->setLoop('nav_left',$nav_translated);
}
$app->tpl_defaults();
$app->tpl->pparse();
?>