Commit e38d145b authored by jwarnier's avatar jwarnier
Browse files

- setup and use $conf['ispconfig_log_dir'], somehow replacing ISPC_LOG_PATH/$conf['logpath']

- replace double-quotes with single-quotes whenever appropriate
- fix indentation
parent 47f5e03b
...@@ -889,8 +889,8 @@ class installer_dist extends installer_base { ...@@ -889,8 +889,8 @@ class installer_dist extends installer_base {
// exec('chmod a+rx /usr/local/ispconfig/interface/web'); // exec('chmod a+rx /usr/local/ispconfig/interface/web');
//* Create the ispconfig log directory //* Create the ispconfig log directory
if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig'); if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir']);
if(!is_file('/var/log/ispconfig/ispconfig.log')) exec('touch /var/log/ispconfig/ispconfig.log'); if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log');
exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
exec('chown getmail /usr/local/bin/run-getmail.sh'); exec('chown getmail /usr/local/bin/run-getmail.sh');
......
...@@ -752,11 +752,11 @@ class installer extends installer_base ...@@ -752,11 +752,11 @@ class installer extends installer_base
} }
// Create the ispconfig log directory // Create the ispconfig log directory
if (!is_dir('/var/log/ispconfig')) { if (!is_dir($conf['ispconfig_log_dir'])) {
mkdir('/var/log/ispconfig'); mkdir($conf['ispconfig_log_dir']);
} }
if (!is_file('/var/log/ispconfig/ispconfig.log')) { if (!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
exec('touch /var/log/ispconfig/ispconfig.log'); exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log');
} }
exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
...@@ -765,4 +765,4 @@ class installer extends installer_base ...@@ -765,4 +765,4 @@ class installer extends installer_base
} }
} }
?> ?>
\ No newline at end of file
...@@ -901,8 +901,8 @@ class installer_dist extends installer_base { ...@@ -901,8 +901,8 @@ class installer_dist extends installer_base {
exec('chmod a+rx /usr/local/ispconfig/interface/web'); exec('chmod a+rx /usr/local/ispconfig/interface/web');
//* Create the ispconfig log directory //* Create the ispconfig log directory
if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig'); if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir']);
if(!is_file('/var/log/ispconfig/ispconfig.log')) exec('touch /var/log/ispconfig/ispconfig.log'); if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log');
exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
exec('chown getmail /usr/local/bin/run-getmail.sh'); exec('chown getmail /usr/local/bin/run-getmail.sh');
...@@ -992,4 +992,4 @@ class installer_dist extends installer_base { ...@@ -992,4 +992,4 @@ class installer_dist extends installer_base {
} }
?> ?>
\ No newline at end of file
...@@ -97,7 +97,7 @@ function get_distname() { ...@@ -97,7 +97,7 @@ function get_distname() {
} }
//** OpenSuSE //** OpenSuSE
elseif(file_exists("/etc/SuSE-release")) { elseif(file_exists('/etc/SuSE-release')) {
if(stristr(file_get_contents('/etc/SuSE-release'),'11.0')) { if(stristr(file_get_contents('/etc/SuSE-release'),'11.0')) {
$distname = 'openSUSE'; $distname = 'openSUSE';
$distver = '11.0'; $distver = '11.0';
...@@ -127,7 +127,7 @@ function get_distname() { ...@@ -127,7 +127,7 @@ function get_distname() {
//** Redhat //** Redhat
elseif(file_exists("/etc/redhat-release")) { elseif(file_exists('/etc/redhat-release')) {
$content = file_get_contents('/etc/redhat-release'); $content = file_get_contents('/etc/redhat-release');
...@@ -171,7 +171,7 @@ function get_distname() { ...@@ -171,7 +171,7 @@ function get_distname() {
} }
//** Gentoo //** Gentoo
elseif(file_exists("/etc/gentoo-release")) { elseif(file_exists('/etc/gentoo-release')) {
$content = file_get_contents('/etc/gentoo-release'); $content = file_get_contents('/etc/gentoo-release');
...@@ -183,7 +183,7 @@ function get_distname() { ...@@ -183,7 +183,7 @@ function get_distname() {
swriteln("Operating System: Gentoo $distver or compatible\n"); swriteln("Operating System: Gentoo $distver or compatible\n");
} else { } else {
die('unrecognized Linux distribution'); die('Unrecognized GNU/Linux distribution');
} }
return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid); return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
...@@ -203,7 +203,7 @@ function swriteln($text = '') { ...@@ -203,7 +203,7 @@ function swriteln($text = '') {
} }
function ilog($msg){ function ilog($msg){
exec("echo `date` \"- [ISPConfig] - \"".$msg." >> ".ISPC_LOG_FILE); exec("echo `date` \"- [ISPConfig] - \"".$msg.' >> '.ISPC_LOG_FILE);
} }
function error($msg){ function error($msg){
...@@ -501,8 +501,8 @@ function is_user($user){ ...@@ -501,8 +501,8 @@ function is_user($user){
$lines = explode("\n", $users); $lines = explode("\n", $users);
if(is_array($lines)){ if(is_array($lines)){
foreach($lines as $line){ foreach($lines as $line){
if(trim($line) != ""){ if(trim($line) != ''){
list($f1, $f2, $f3, $f4, $f5, $f6, $f7) = explode(":", $line); list($f1, $f2, $f3, $f4, $f5, $f6, $f7) = explode(':', $line);
if($f1 == $user) return true; if($f1 == $user) return true;
} }
} }
...@@ -517,8 +517,8 @@ function is_group($group){ ...@@ -517,8 +517,8 @@ function is_group($group){
$lines = explode("\n", $groups); $lines = explode("\n", $groups);
if(is_array($lines)){ if(is_array($lines)){
foreach($lines as $line){ foreach($lines as $line){
if(trim($line) != ""){ if(trim($line) != ''){
list($f1, $f2, $f3, $f4) = explode(":", $line); list($f1, $f2, $f3, $f4) = explode(':', $line);
if($f1 == $group) return true; if($f1 == $group) return true;
} }
} }
......
...@@ -963,7 +963,7 @@ class installer_base { ...@@ -963,7 +963,7 @@ class installer_base {
global $conf; global $conf;
//* Create the logging directory for the vhost logfiles //* Create the logging directory for the vhost logfiles
mkdir('/var/log/ispconfig/httpd', 0755, true); mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
if(is_file('/etc/suphp/suphp.conf')) { if(is_file('/etc/suphp/suphp.conf')) {
replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0); replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0);
...@@ -1470,10 +1470,10 @@ class installer_base { ...@@ -1470,10 +1470,10 @@ class installer_base {
if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log'); if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log');
if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log'); if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log');
//* Create the ispconfig log directory //* Create the ispconfig log file and directory
if(!is_file('/var/log/ispconfig/ispconfig.log')) { if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig', 0755); if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir'], 0755);
touch('/var/log/ispconfig/ispconfig.log'); touch($conf['ispconfig_log_dir'].'/ispconfig.log');
} }
rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh'); rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh');
...@@ -1486,14 +1486,14 @@ class installer_base { ...@@ -1486,14 +1486,14 @@ class installer_base {
/* We rotate these logs in cron_daily.php /* We rotate these logs in cron_daily.php
$fh = fopen('/etc/logrotate.d/logispc3', 'w'); $fh = fopen('/etc/logrotate.d/logispc3', 'w');
fwrite($fh, fwrite($fh,
"/var/log/ispconfig/ispconfig.log { \n" . "$conf['ispconfig_log_dir']/ispconfig.log { \n" .
" weekly \n" . " weekly \n" .
" missingok \n" . " missingok \n" .
" rotate 4 \n" . " rotate 4 \n" .
" compress \n" . " compress \n" .
" delaycompress \n" . " delaycompress \n" .
"} \n" . "} \n" .
"/var/log/ispconfig/cron.log { \n" . "$conf['ispconfig_log_dir']/cron.log { \n" .
" weekly \n" . " weekly \n" .
" missingok \n" . " missingok \n" .
" rotate 4 \n" . " rotate 4 \n" .
...@@ -1544,8 +1544,8 @@ class installer_base { ...@@ -1544,8 +1544,8 @@ class installer_base {
} }
$root_cron_jobs = array( $root_cron_jobs = array(
"* * * * * $install_dir/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log", "* * * * * $install_dir/server/server.sh > /dev/null 2>> $conf['ispconfig_log_dir']/cron.log",
"30 00 * * * $install_dir/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log" "30 00 * * * $install_dir/server/cron_daily.sh > /dev/null 2>> $conf['ispconfig_log_dir']/cron.log"
); );
foreach($root_cron_jobs as $cron_job) { foreach($root_cron_jobs as $cron_job) {
if(!in_array($cron_job."\n", $existing_root_cron_jobs)) { if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
...@@ -1563,7 +1563,7 @@ class installer_base { ...@@ -1563,7 +1563,7 @@ class installer_base {
$existing_cron_jobs = file('crontab.txt'); $existing_cron_jobs = file('crontab.txt');
$cron_jobs = array( $cron_jobs = array(
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /var/log/ispconfig/cron.log' '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> $conf['ispconfig_log_dir']/cron.log'
); );
// remove existing ispconfig cronjobs, in case the syntax has changed // remove existing ispconfig cronjobs, in case the syntax has changed
...@@ -1581,8 +1581,8 @@ class installer_base { ...@@ -1581,8 +1581,8 @@ class installer_base {
unlink('crontab.txt'); unlink('crontab.txt');
} }
touch('/var/log/ispconfig/cron.log'); touch($conf['ispconfig_log_dir'].'/cron.log');
chmod('/var/log/ispconfig/cron.log', 0666); chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
} }
......
...@@ -60,27 +60,27 @@ define('ISPC_APP_VERSION', '3.0.3'); ...@@ -60,27 +60,27 @@ define('ISPC_APP_VERSION', '3.0.3');
//** Database //** Database
$conf["db_type"] = 'mysql'; $conf['db_type'] = 'mysql';
$conf["db_host"] = '{mysql_server_host}'; $conf['db_host'] = '{mysql_server_host}';
$conf["db_database"] = '{mysql_server_database}'; $conf['db_database'] = '{mysql_server_database}';
$conf["db_user"] = '{mysql_server_ispconfig_user}'; $conf['db_user'] = '{mysql_server_ispconfig_user}';
$conf["db_password"] = '{mysql_server_ispconfig_password}'; $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") $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_TYPE',$conf['db_type']);
define("DB_HOST",$conf["db_host"]); define('DB_HOST',$conf['db_host']);
define("DB_DATABASE",$conf["db_database"]); define('DB_DATABASE',$conf['db_database']);
define("DB_USER",$conf["db_user"]); define('DB_USER',$conf['db_user']);
define("DB_PASSWORD",$conf["db_password"]); define('DB_PASSWORD',$conf['db_password']);
define("DB_CHARSET",$conf["db_charset"]); define('DB_CHARSET',$conf['db_charset']);
//** Database settings for the master DB. This setting is only used in multiserver setups //** Database settings for the master DB. This setting is only used in multiserver setups
$conf["dbmaster_type"] = 'mysql'; $conf['dbmaster_type'] = 'mysql';
$conf["dbmaster_host"] = '{mysql_master_server_host}'; $conf['dbmaster_host'] = '{mysql_master_server_host}';
$conf["dbmaster_database"] = '{mysql_master_server_database}'; $conf['dbmaster_database'] = '{mysql_master_server_database}';
$conf["dbmaster_user"] = '{mysql_master_server_ispconfig_user}'; $conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}';
$conf["dbmaster_password"] = '{mysql_master_server_ispconfig_password}'; $conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}';
//** Paths //** Paths
...@@ -91,19 +91,19 @@ define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web'); ...@@ -91,19 +91,19 @@ define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web');
define('ISPC_THEMES_PATH', ISPC_ROOT_PATH.'/web/themes'); 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_WEB_TEMP_PATH', ISPC_WEB_PATH.'/temp'); // Path for downloads, accessible via browser
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache'); define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
define('ISPC_LOG_PATH', '/var/log/ispconfig'); define('ISPC_LOG_PATH', $conf['ispconfig_log_dir']);
//** Paths (Do not change!) //** Paths (Do not change!)
$conf["rootpath"] = substr(dirname(__FILE__),0,-4); $conf['rootpath'] = substr(dirname(__FILE__),0,-4);
$conf["fs_div"] = "/"; // File system separator, "\\" on Windows and "/"" on Linux and UNIX $conf['fs_div'] = '/'; // File system separator, "\\" on Windows and "/" on Linux and UNIX
$conf["classpath"] = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes"; $conf['classpath'] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes';
$conf["temppath"] = $conf["rootpath"].$conf["fs_div"]."temp"; $conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp';
$conf["logpath"] = ISPC_LOG_PATH; $conf['logpath'] = ISPC_LOG_PATH; // Actually just a copy of $conf['ispconfig_log_dir'], might be removed in a later version
define("FS_DIV",$conf["fs_div"]); define('FS_DIV',$conf['fs_div']);
define("SERVER_ROOT",$conf["rootpath"]); define('SERVER_ROOT',$conf['rootpath']);
define("INCLUDE_ROOT",SERVER_ROOT.FS_DIV."lib"); define('INCLUDE_ROOT',SERVER_ROOT.FS_DIV.'lib');
define("CLASSES_ROOT",INCLUDE_ROOT.FS_DIV."classes"); define('CLASSES_ROOT',INCLUDE_ROOT.FS_DIV.'classes');
//** Server //** Server
...@@ -111,7 +111,7 @@ $conf['app_title'] = ISPC_APP_TITLE; ...@@ -111,7 +111,7 @@ $conf['app_title'] = ISPC_APP_TITLE;
$conf['app_version'] = ISPC_APP_VERSION; $conf['app_version'] = ISPC_APP_VERSION;
$conf['app_link'] = 'http://www.ispconfig.org/'; $conf['app_link'] = 'http://www.ispconfig.org/';
$conf['modules_available'] = 'dashboard,admin,mail,sites,monitor,client,dns,help'; $conf['modules_available'] = 'dashboard,admin,mail,sites,monitor,client,dns,help';
$conf["server_id"] = "{server_id}"; $conf['server_id'] = '{server_id}';
//** Interface //** Interface
...@@ -128,8 +128,8 @@ $conf['demo_mode'] = false; ...@@ -128,8 +128,8 @@ $conf['demo_mode'] = false;
//** Logging //** Logging
$conf["log_file"] = $conf["logpath"].$conf["fs_div"]."ispconfig.log"; $conf['log_file'] = $conf['ispconfig_log_dir'].$conf['fs_div'].'ispconfig.log';
$conf["log_priority"] = {ispconfig_log_priority}; // 0 = Debug, 1 = Warning, 2 = Error $conf['log_priority'] = {ispconfig_log_priority}; // 0 = Debug, 1 = Warning, 2 = Error
//** Allow software package installations //** Allow software package installations
...@@ -137,29 +137,29 @@ $conf['software_updates_enabled'] = false; ...@@ -137,29 +137,29 @@ $conf['software_updates_enabled'] = false;
//** Themes //** Themes
$conf["theme"] = 'default'; $conf['theme'] = 'default';
$conf["html_content_encoding"] = 'utf-8'; // example: utf-8, iso-8859-1, ... $conf['html_content_encoding'] = 'utf-8'; // example: utf-8, iso-8859-1, ...
$conf["logo"] = 'themes/default/images/ispc_logo.png'; $conf['logo'] = 'themes/default/images/ispc_logo.png';
//** Default Language //** Default Language
$conf["language"] = '{language}'; $conf['language'] = '{language}';
$conf["debug_language"] = false; $conf['debug_language'] = false;
//** Misc. //** Misc.
$conf["interface_logout_url"] = ""; // example: http://www.domain.tld/ $conf['interface_logout_url'] = ''; // example: http://www.domain.tld/
//** Auto Load Modules //** Auto Load Modules
$conf["start_db"] = true; $conf['start_db'] = true;
$conf["start_session"] = true; $conf['start_session'] = true;
//** Constants //** Constants
define("LOGLEVEL_DEBUG",0); define('LOGLEVEL_DEBUG',0);
define("LOGLEVEL_WARN",1); define('LOGLEVEL_WARN',1);
define("LOGLEVEL_ERROR",2); define('LOGLEVEL_ERROR',2);
//** include a local config-file if there is one //** include a local config-file if there is one
//** IMPORTANT!!! //** IMPORTANT!!!
......
...@@ -82,7 +82,7 @@ define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache'); ...@@ -82,7 +82,7 @@ define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
//** Paths (Do not change!) //** Paths (Do not change!)
$conf['rootpath'] = substr(dirname(__FILE__),0,-4); $conf['rootpath'] = substr(dirname(__FILE__),0,-4);
$conf['fs_div'] = '/'; // File system separator (divider), "\\" on Windows and "/"" on Linux and UNIX $conf['fs_div'] = '/'; // File system separator (divider), "\\" on Windows and "/" on Linux and UNIX
$conf['classpath'] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes'; $conf['classpath'] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes';
$conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp'; $conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp';
...@@ -114,7 +114,7 @@ $conf['demo_mode'] = false; ...@@ -114,7 +114,7 @@ $conf['demo_mode'] = false;
//** Logging //** Logging
$conf['log_file'] = '/var/log/ispconfig/ispconfig.log'; $conf['log_file'] = $conf['ispconfig_log_dir'].'/ispconfig.log';
$conf['log_priority'] = 0; // 0 = Debug, 1 = Warning, 2 = Error $conf['log_priority'] = 0; // 0 = Debug, 1 = Warning, 2 = Error
......
...@@ -228,14 +228,14 @@ foreach($records as $rec) { ...@@ -228,14 +228,14 @@ foreach($records as $rec) {
####################################################################################################### #######################################################################################################
// rotate the ispconfig.log when it exceeds a size of 10 MB // rotate the ispconfig.log when it exceeds a size of 10 MB
$logfile = '/var/log/ispconfig/ispconfig.log'; $logfile = $conf['ispconfig_log_dir'].'/ispconfig.log';
if(is_file($logfile) && filesize($logfile) > 10000000) { if(is_file($logfile) && filesize($logfile) > 10000000) {
exec("gzip -c $logfile > $logfile.1.gz"); exec("gzip -c $logfile > $logfile.1.gz");
exec("cat /dev/null > $logfile"); exec("cat /dev/null > $logfile");
} }
// rotate the cron.log when it exceeds a size of 10 MB // rotate the cron.log when it exceeds a size of 10 MB
$logfile = '/var/log/ispconfig/cron.log'; $logfile = $conf['ispconfig_log_dir'].'/cron.log';
if(is_file($logfile) && filesize($logfile) > 10000000) { if(is_file($logfile) && filesize($logfile) > 10000000) {
exec("gzip -c $logfile > $logfile.1.gz"); exec("gzip -c $logfile > $logfile.1.gz");
exec("cat /dev/null > $logfile"); exec("cat /dev/null > $logfile");
......
...@@ -36,7 +36,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -36,7 +36,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var $linkId = 0; // last result of mysql_connect() var $linkId = 0; // last result of mysql_connect()
var $queryId = 0; // last result of mysql_query() var $queryId = 0; // last result of mysql_query()
var $record = array(); // last record fetched var $record = array(); // last record fetched
var $autoCommit = 1; // Autocommit Transactions var $autoCommit = 1; // Autocommit Transactions
var $currentRow; // current row number var $currentRow; // current row number
var $errorNumber = 0; // last error number var $errorNumber = 0; // last error number
var $errorMessage = ''; // last error message var $errorMessage = ''; // last error message
...@@ -339,7 +339,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -339,7 +339,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
return true; return true;
} }
public function closeConn() public function closeConn()
{ {
if($this->linkId) if($this->linkId)
...@@ -397,17 +398,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -397,17 +398,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if($col['autoInc'] == true) $sql .= 'auto_increment '; if($col['autoInc'] == true) $sql .= 'auto_increment ';
$sql.= ','; $sql.= ',';
// key Definitionen // key Definitionen
if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),"; if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),';
if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),"; if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),';
if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),"; if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),';
} }
$sql .= $index; $sql .= $index;
$sql = substr($sql,0,-1); $sql = substr($sql,0,-1);
$sql .= ')'; $sql .= ')';
$this->query($sql); $this->query($sql);
return true; return true;
} }
/* /*
$columns = array(action => add | alter | drop $columns = array(action => add | alter | drop
...@@ -427,11 +427,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -427,11 +427,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$sql = "ALTER TABLE $table_name "; $sql = "ALTER TABLE $table_name ";
foreach($columns as $col){ foreach($columns as $col){
if($col['action'] == 'add') { if($col['action'] == 'add') {
$sql .= "ADD ".$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' '; $sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
} elseif ($col['action'] == 'alter') { } elseif ($col['action'] == 'alter') {
$sql .= "CHANGE ".$col['name']." ".$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' '; $sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
} elseif ($col['action'] == 'drop') { } elseif ($col['action'] == 'drop') {
$sql .= "DROP ".$col['name'].' '; $sql .= 'DROP '.$col['name'].' ';
} }
if($col['action'] != 'drop') { if($col['action'] != 'drop') {
if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
...@@ -442,10 +442,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -442,10 +442,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
if($col['autoInc'] == true) $sql .= 'auto_increment '; if($col['autoInc'] == true) $sql .= 'auto_increment ';
$sql.= ','; $sql.= ',';
// key Definitionen // Index definitions
if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),"; if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),';
if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),"; if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),';
if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),"; if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),';
} }
} }
$sql .= $index; $sql .= $index;
...@@ -493,7 +493,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -493,7 +493,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
global $go_api,$go_info; global $go_api,$go_info;
// Tabellenfelder einlesen