Changeset 1073

Show
Ignore:
Timestamp:
03/23/08 14:40:46 (6 months ago)
Author:
rats
Message:

Fixed: Warnings and Notices if no Database found or no conection to it
Other small fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG

    r1071 r1073  
    11ispCP ω 1.0.0 Changelog 
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3 
     42008-03-23 Benedikt Heintel 
     5        - GUI: 
     6                * Fixed: Warnings and Notices if no Database found or no conection to it 
     7 
     82008-03-22 Benedikt Heintel 
     9        - GUI: 
     10                * Fixed: Error in input check and IP management 
     11        - DISTS: 
     12                * Fixed #1130: (FreeBSD) Fix program path in freebsd distro 
    313 
    4142008-03-22 Christian Hernmarck 
  • trunk/configs/dists/freebsd/ispcp.conf

    r1068 r1073  
    300300CMD_HTTPD = /usr/local/sbin/apachectl 
    301301 
    302 CMD_IMAP = /usr/local/etc/rc.d/courier-imap-imapd.sh 
     302CMD_IMAP = /usr/local/etc/rc.d/courier-imap-imapd 
    303303 
    304304CMD_IMAP_SSL = no 
     
    306306CMD_MTA = /usr/local/etc/rc.d/postfix 
    307307 
    308 CMD_NAMED = /usr/local/etc/named.r
    309  
    310 CMD_POP = /usr/local/etc/rc.d/courier-imap-pop3d.sh 
     308CMD_NAMED = /usr/sbin/rnd
     309 
     310CMD_POP = /usr/local/etc/rc.d/courier-imap-pop3d 
    311311 
    312312CMD_POP_SSL = no 
  • trunk/configs/dists/freebsd/postfix/main.cf

    r1059 r1073  
    2020 
    2121# Postfix directory settings; These are critical for normal Postfix MTA functionallity 
    22 command_directory            = /usr/sbin 
    23 daemon_directory             = /usr/lib/postfix 
    24 program_directory            = /usr/lib/postfix 
     22command_directory            = /usr/local/sbin 
     23daemon_directory             = /usr/local/libexec/postfix 
     24program_directory            = /usr/local/libexec/postfix 
    2525 
    2626# Some common configuration parameters 
     
    3333 
    3434smtpd_banner                 = $myhostname ESMTP ispCP {MTA_VERSION} Managed 
    35 setgid_group                 = postdrop 
     35setgid_group                 = maildrop 
    3636 
    3737# Receiving messages parameters 
  • trunk/configs/dists/opensuse/proftpd/proftpd.conf

    r1059 r1073  
    4646 
    4747DisplayLogin               welcome.msg 
    48 DisplayFirstChdir          message 
     48DisplayChdir               message 
    4949 
    5050ListOptions                "-l" 
     
    161161 
    162162# ispCP SQL Managment 
    163 # Activate for proftpd >= 1.3 
    164 #SQLBackend                 mysql 
     163SQLBackend                 mysql 
    165164SQLAuthTypes               Crypt 
    166165SQLAuthenticate            on 
  • trunk/docs/OpenSuse/opensuse103-packages

    r1002 r1073  
    8080php5 
    8181php5-fastcgi 
     82php5-ftp 
    8283php5-mbstring 
    8384php5-mcrypt 
  • trunk/gui/admin/ip_manage.php

    r1068 r1073  
    133133        } 
    134134 
    135         if (!isset($sucess)) { 
     135        if (!isset($sucess) && isset($_POST['ip_number_1'])) { 
    136136                $tpl->assign( 
    137137                        array( 
  • trunk/gui/include/input-checks.php

    r1068 r1073  
    150150        } 
    151151 
    152         if (preg_match($pemitted, $password)) { 
     152        if (!empty($permitted) && preg_match($pemitted, $password)) { 
    153153                return false; 
    154154        } 
  • trunk/gui/include/ispcp-config.php

    r1072 r1073  
    2828$cfg_obj = new Config($cfgfile); 
    2929 
    30 /* Status not ok -> Try to get the error and display a message */ 
     30// Status not ok -> Try to get the error and display a message 
    3131if ($cfg_obj->status != 'ok') { 
    3232        if ($cfg_obj->status == 'err') { 
    33                 /* cannot open ispcp.conf file - we must show warning */ 
    34                 print "<center><b><font color=red>Cannot open the ispcp.conf config file !<br><br>Please contact your system administrator</font></b></center>"; 
    35                 die(); 
     33                // cannot open ispcp.conf file - we must show warning 
     34                print 
     35                die("<center><b><font color=red>Cannot open the ispcp.conf config file!<br />Please contact your system administrator</font></b></center>"); 
    3636        } 
    3737 
    3838        if (substr($cfg_obj->status, 0, 24) == 'missing config variable:') { 
    39                 /* cannot open ispcp.conf file - we must show warning */ 
    40                 print "<center><b><font color=red>config variable " . substr($cfg_obj->status, 25) . " is missing!<br><br>Please contact your system administrator</font></b></center>"; 
    41                 die(); 
     39                // cannot open ispcp.conf file - we must show warning 
     40                die("<center><b><font color=red>Config variable " . substr($cfg_obj->status, 25) . " is missing!<br />Please contact your system administrator</font></b></center>"); 
    4241        } 
    4342} 
     
    4544$cfg = $cfg_obj->getValues(); 
    4645 
     46// this class will parse config file and get all variables avaible in PHP 
    4747class Config { 
    48         /* this class will parse config file and get all variables avaible in PHP */ 
     48        // config filename 
    4949        var $config_file; 
    50         /* config filename */ 
    51  
    52         /* IMPORTANT: any adding & removing of variables in /etc/ispcp/ispcp.conf should also be made here! */ 
    53         var $cfg_values = array(/* array with all options from config file - predefined with null */ 
     50 
     51        // IMPORTANT: any adding & removing of variables in /etc/ispcp/ispcp.conf should also be made here! 
     52        // array with all options from config file - predefined with null 
     53        var $cfg_values = array( 
    5454                'BuildDate' => null, 
    5555                'Version' => null, 
     
    225225 
    226226        function parseFile() { 
    227                 /* open file ... parse it and put it in $cfg_values */ 
     227                // open file ... parse it and put it in $cfg_values 
    228228                @$fd = fopen($this->config_file, 'r'); 
    229229                if ($fd == false) { 
    230                         /* ooops error */ 
    231230                        $this->status = 'err'; 
    232231                        return false; 
    233232                } while (!feof($fd)) { 
    234233                        $buffer = fgets($fd, 4096); 
    235                         /* remove spaces  */ 
     234                        // remove spaces 
    236235                        $buffer = ltrim($buffer); 
    237                         if (strlen($buffer) < 3) { 
    238                                 /* empty */ 
    239                         } else if ($buffer[0] == '#' || $buffer[0] == ';') { 
    240                                 /* this is comment */ 
    241                         } else if (strpos($buffer, '=') === false) { 
    242                                 /* have no = :( */ 
    243                         } else { 
     236                        if (strlen($buffer) > 3 && $buffer[0] != '#' && $buffer[0] != ';' && 
     237                                strpos($buffer, '=') !== false) { 
    244238                                $pair = explode('=', $buffer, 2); 
    245239 
    246                                 $pair[0] = ltrim($pair[0]); 
    247                                 $pair[0] = rtrim($pair[0]); 
    248  
    249                                 $pair[1] = ltrim($pair[1]); 
    250                                 $pair[1] = rtrim($pair[1]); 
    251  
    252                                 /* ok we have it :) */ 
     240                                $pair[0] = trim($pair[0]); 
     241                                $pair[1] = trim($pair[1]); 
     242 
     243                                // ok we have it :) 
    253244                                $this->cfg_values[$pair[0]] = $pair[1]; 
    254245                        } 
     
    279270        if (extension_loaded('mcrypt') || @dl('mcrypt.' . PHP_SHLIB_SUFFIX)) { 
    280271                $text = @base64_decode($db_pass . "\n"); 
    281                 /* Open the cipher */ 
     272                // Open the cipher 
    282273                $td = @mcrypt_module_open ('blowfish', '', 'cbc', ''); 
    283                 /* Create key */ 
     274                // Create key 
    284275                $key = $ispcp_db_pass_key; 
    285                 /* Create the IV and determine the keysize length */ 
     276                // Create the IV and determine the keysize length 
    286277                $iv = $ispcp_db_pass_iv; 
    287278 
    288                 /* Intialize encryption */ 
     279                // Intialize encryption 
    289280                @mcrypt_generic_init ($td, $key, $iv); 
    290                 /* Decrypt encrypted string */ 
     281                // Decrypt encrypted string 
    291282                $decrypted = @mdecrypt_generic ($td, $text); 
    292283                @mcrypt_module_close ($td); 
    293284 
    294                 /* Show string */ 
     285                // Show string 
    295286                return trim($decrypted); 
    296287        } else { 
    297                 system_message("ERROR: The php-extension 'mcrypt' not loaded !"); 
     288                system_message("ERROR: The php-extension 'mcrypt' not loaded!"); 
    298289                die(); 
    299290        } 
  • trunk/gui/include/ispcp-lib.php

    r1070 r1073  
    3030//error_reporting(0); 
    3131// setting for development edition - see all error messages 
    32 error_reporting(E_ALL|E_STRICT); 
     32error_reporting(E_ALL); 
    3333 
    3434require_once(INCLUDEPATH.'/spGzip.php'); 
    3535require_once(INCLUDEPATH.'/class.pTemplate.php'); 
    3636require_once(INCLUDEPATH.'/i18n.php'); 
     37 
     38// Template pathes 
     39$cfg['ROOT_TEMPLATE_PATH'] = 'themes/'; 
     40$cfg['USER_INITIAL_THEME'] = 'omega_original'; 
     41$cfg['LOGIN_TEMPLATE_PATH'] = $cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME']; 
     42$cfg['ADMIN_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/admin'; 
     43$cfg['RESELLER_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/reseller'; 
     44$cfg['CLIENT_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/client'; 
     45$cfg['IPS_LOGO_PATH'] = '../themes/user_logos'; 
     46$cfg['PURCHASE_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/orderpanel'; 
     47 
     48// Standard Language (if not set) 
     49$cfg['USER_INITIAL_LANG'] = 'lang_English'; 
     50 
    3751require_once(INCLUDEPATH.'/system-message.php'); 
    3852require_once(INCLUDEPATH.'/ispcp-db-keys.php'); 
     
    6074$cfg['MAX_SQL_USER_LENGTH'] = 16; 
    6175$cfg['MAX_SQL_PASS_LENGTH'] = 32; 
    62 // Template pathes 
    63 $cfg['ROOT_TEMPLATE_PATH'] = 'themes/'; 
    64 $cfg['LOGIN_TEMPLATE_PATH'] = $cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME']; 
    65 $cfg['ADMIN_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/admin'; 
    66 $cfg['RESELLER_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/reseller'; 
    67 $cfg['CLIENT_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/client'; 
    68 $cfg['IPS_LOGO_PATH'] = '../themes/user_logos'; 
    69 $cfg['PURCHASE_TEMPLATE_PATH'] = '../'.$cfg['ROOT_TEMPLATE_PATH'].$cfg['USER_INITIAL_THEME'].'/orderpanel'; 
    7076 
    7177// the following variables are overriden via admin cp 
     
    7480// 'reseller' => hosting plans are available only in reseller level 
    7581$cfg['HOSTING_PLANS_LEVEL'] = 'reseller'; 
    76 $cfg['USER_INITIAL_LANG'] = 'lang_English'; 
    7782 
    7883// enable or disable supportsystem 
  • trunk/gui/include/sql.php

    r993 r1073  
    11<?php 
    22/** 
    3  * ispCP (OMEGA) a Virtual Hosting Control Panel 
     3 * ispCP ω (OMEGA) a Virtual Hosting Control System 
    44 * 
    5  *  @copyright  2001-2006 by moleSoftware GmbH 
    6  *  @copyright  2006-2007 by ispCP | http://isp-control.net 
    7  *  @link               http://isp-control.net 
    8  *  @author             ispCP Team (2007) 
    9  * 
    10  *  @license 
    11  *  This program is free software; you can redistribute it and/or modify it under 
    12  *  the terms of the MPL General Public License as published by the Free Software 
    13  *  Foundation; either version 1.1 of the License, or (at your option) any later 
    14  *  version. 
    15  *  You should have received a copy of the MPL Mozilla Public License along with 
    16  *  this program; if not, write to the Open Source Initiative (OSI) 
    17  *  http://opensource.org | osi@opensource.org 
    18  * 
    19  **/ 
     5 * @copyright 2001-2006 by moleSoftware GmbH 
     6 * @copyright 2006-2008 by ispCP | http://isp-control.net 
     7 * @version SVN: $ID$ 
     8 * @link http://isp-control.net 
     9 * @author ispCP Team 
     10 * @license This program is free software; you can redistribute it and/or modify it under 
     11 *    the terms of the MPL General Public License as published by the Free Software 
     12 *    Foundation; either version 1.1 of the License, or (at your option) any later 
     13 *    version. 
     14 *    You should have received a copy of the MPL Mozilla Public License along with 
     15 *    this program; if not, write to the Open Source Initiative (OSI) 
     16 *    http://opensource.org | osi@opensource.org 
     17 */ 
    2018 
    21 require (INCLUDEPATH.'/adodb/adodb.inc.php'); 
    22  
    23 require (INCLUDEPATH.'/adodb/adodb-pager.inc.php'); 
     19require (INCLUDEPATH . '/adodb/adodb.inc.php'); 
     20require (INCLUDEPATH . '/adodb/adodb-pager.inc.php'); 
    2421 
    2522$cfg['DB_TYPE'] = $cfg['DATABASE_TYPE']; 
    26  
    2723$cfg['DB_HOST'] = $cfg['DATABASE_HOST']; 
    28  
    2924$cfg['DB_USER'] = $cfg['DATABASE_USER']; 
    30  
    3125$cfg['DB_PASS'] = decrypt_db_password($cfg['DATABASE_PASSWORD']); 
    32  
    3326$cfg['DB_NAME'] = $cfg['DATABASE_NAME']; 
    3427 
    3528$sql = &ADONewConnection($cfg['DB_TYPE']); 
    3629 
    37 @$sql -> Connect($cfg['DB_HOST'], $cfg['DB_USER'], $cfg['DB_PASS'], $cfg['DB_NAME']) OR 
    38         system_message('ERROR: Unable to connect to SQL server !<br>SQL returned: '.$sql -> ErrorMsg() ); 
     30@$sql->Connect($cfg['DB_HOST'], $cfg['DB_USER'], $cfg['DB_PASS'], $cfg['DB_NAME']) or 
     31        system_message('ERROR: Unable to connect to SQL server !<br>SQL returned: ' . $sql->ErrorMsg()); 
    3932 
    40 /* switch optionally to utf8 based communication with the database */ 
     33// switch optionally to utf8 based communication with the database 
    4134if (isset($cfg['DATABASE_UTF8']) && $cfg['DATABASE_UTF8'] == 'yes') { 
    42  @$sql->Execute("SET NAMES 'utf8'"); 
     35       @$sql->Execute("SET NAMES 'utf8'"); 
    4336} 
    4437 
    45 /* No longer needed */ 
     38// No longer needed - unset for safety 
    4639unset($cfg['DB_USER']); 
    47  
    4840unset($cfg['DB_PASS']); 
    49 /* unset for safety */ 
    5041 
    5142function execute_query (&$sql, $query) { 
    52         $rs = $sql -> Execute($query); 
    53         if (!$rs) system_message($sql -> ErrorMsg()); 
     43        $rs = $sql->Execute($query); 
     44        if (!$rs) system_message($sql->ErrorMsg()); 
    5445        return $rs; 
    5546} 
     
    6051 
    6152        if (!$rs && $failDie) { 
    62             system_message($sql->ErrorMsg()); 
     53               system_message($sql->ErrorMsg()); 
    6354        } 
    6455 
     
    6758 
    6859function quoteIdentifier($identifier) { 
    69     global $sql; 
     60       global $sql; 
    7061 
    71     $identifier = str_replace($sql->nameQuote, '\\' . $sql->nameQuote, $identifier); 
     62       $identifier = str_replace($sql->nameQuote, '\\' . $sql->nameQuote, $identifier); 
    7263 
    73     return $sql->nameQuote . $identifier . $sql->nameQuote; 
     64       return $sql->nameQuote . $identifier . $sql->nameQuote; 
    7465} 
    7566 
    7667function match_sqlinjection($value, &$matches) { 
    77     $matches = array(); 
    78         return (preg_match("/((DELETE)|(INSERT)|(UPDATE)|(ALTER)|(CREATE)|( TABLE)|(DROP))\s[A-Za-z0-9 ]{0,200}(\s(FROM)|(INTO)|(TABLE)\s)/i", $value, $matches)>0); 
     68       $matches = array(); 
     69        return (preg_match("/((DELETE)|(INSERT)|(UPDATE)|(ALTER)|(CREATE)|( TABLE)|(DROP))\s[A-Za-z0-9 ]{0,200}(\s(FROM)|(INTO)|(TABLE)\s)/i", $value, $matches) > 0); 
    7970} 
    8071 
    8172function check_query($exclude = array()) { 
    82     $matches = null; 
     73       $matches = null; 
    8374 
    84     if (phpversion() <= '4.2.2') { //why? _ REQUEST was introduced in 4.1.0, not 4.2.2 
    85         die('ERROR: Your PHP version is older than 4.2.2!'); 
    86     } 
     75        if (phpversion() <= '4.2.2') { 
     76                $message = "Your PHP version is older than 4.2.2!"; 
     77                write_log($message); 
     78                system_message($message); 
     79                die('ERROR: Your PHP version is older than 4.2.2!'); 
     80        } 
    8781 
    88     if (!is_array($exclude)) { 
    89         $exclude = array($exclude); 
    90    
     82       if (!is_array($exclude)) { 
     83               $exclude = array($exclude); 
     84       
    9185 
    92     foreach($_REQUEST as $key => $value) { 
     86        foreach($_REQUEST as $key => $value) { 
     87                if (in_array($key, $exclude)) { 
     88                        continue; 
     89                } 
    9390 
    94         if (in_array($key, $exclude)) { 
    95             continue; 
    96         } 
     91                if (!is_array($value)) { 
     92                        if (match_sqlinjection($value, $matches)) { 
     93                                $message = "Possible SQL injection detected: $key=>$value. <b>${matches[0]}</b>. Script terminated."; 
     94                                write_log($message); 
     95                                system_message($message); 
     96                                die('<b>WARNING</b>: Possible SQL injection detected. Script terminated.'); 
     97                        } 
     98                } else { 
     99                        foreach($value as $skey => $svalue) { 
     100                                if (!is_array($svalue)) { 
     101                                        if (match_sqlinjection($svalue, $matches)) { 
     102                                                $message = "Possible SQL injection detected: $skey=>$svalue <b>${matches[0]}</b>. Script terminated."; 
     103                                                write_log($message); 
     104                                                system_message($message); 
     105                                                die('<b>WARNING</b>: Possible SQL injection detected. Script terminated.'); 
     106                                        } 
     107                                } 
     108                        } 
     109                } 
     110        } 
     111
    97112 
    98         if (!is_array($value)) { 
    99             if (match_sqlinjection($value, $matches)) { 
    100                 $message = "Possible SQL injection detected: $key=>$value. <b>${matches[0]}</b>. Script terminated."; 
    101                 write_log($message); 
    102                 system_message($message); 
    103                 die('<b>WARNING</b>: Possible SQL injection detected. Script terminated.'); 
    104             } 
    105         } else { 
    106             foreach($value as $skey=>$svalue) { 
    107                 if (!is_array($svalue)) { 
    108                     if (match_sqlinjection($svalue, $matches)) { 
    109                         $message = "Possible SQL injection detected: $skey=>$svalue <b>${matches[0]}</b>. Script terminated."; 
    110                         write_log($message); 
    111                         system_message($message); 
    112                         die('<b>WARNING</b>: Possible SQL injection detected. Script terminated.'); 
    113                     } 
    114                 } 
    115             } 
    116         } 
    117     } 
    118 } 
    119113?> 
  • trunk/gui/include/system-message.php

    r776 r1073  
    11<?php 
    22/** 
    3  * ispCP (OMEGA) - Virtual Hosting Control System | Omega Version 
     3 * ispCP ω (OMEGA) a Virtual Hosting Control System 
    44 * 
    5  *  @copyright  2001-2006 by moleSoftware GmbH 
    6  *  @copyright  2006-2007 by ispCP | http://isp-control.net 
    7  *  @link               http://isp-control.net 
    8  *  @author             ispCP Team (2007) 
     5 * @copyright   2001-2006 by moleSoftware GmbH 
     6 * @copyright   2006-2008 by ispCP | http://isp-control.net 
     7 * @version     SVN: $ID$ 
     8 * @link                http://isp-control.net 
     9 * @author              ispCP Team 
    910 * 
    10  *  @license 
    11  *  This program is free software; you can redistribute it and/or modify it under 
    12  *  the terms of the MPL General Public License as published by the Free Software 
    13  *  Foundation; either version 1.1 of the License, or (at your option) any later 
    14  *  version. 
    15  *  You should have received a copy of the MPL Mozilla Public License along with 
    16  *  this program; if not, write to the Open Source Initiative (OSI) 
    17  *  http://opensource.org | osi@opensource.org 
    18  * 
    19  **/ 
     11 * @license 
     12 *   This program is free software; you can redistribute it and/or modify it under 
     13 *   the terms of the MPL General Public License as published by the Free Software 
     14 *   Foundation; either version 1.1 of the License, or (at your option) any later 
     15 *   version. 
     16 *   You should have received a copy of the MPL Mozilla Public License along with 
     17 *   this program; if not, write to the Open Source Initiative (OSI) 
     18 *   http://opensource.org | osi@opensource.org 
     19 */ 
     20 
     21check_login(__FILE__); 
    2022 
    2123function system_message($msg) { 
     
    2325 
    2426        if (isset($_SESSION['user_theme'])) { 
    25  
    2627                $theme_color = $_SESSION['user_theme']; 
    27  
    2828        } else { 
    29  
    3029                $theme_color = $cfg['USER_INITIAL_THEME']; 
    31  
    3230        } 
    3331