New wrapper function changeDataInLocalConfigurationFile() introduced
authorRoland Häder <roland@mxchange.org>
Fri, 10 Jun 2011 22:23:17 +0000 (22:23 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 10 Jun 2011 22:23:17 +0000 (22:23 +0000)
inc/install-functions.php
inc/modules/admin.php
inc/wrapper-functions.php

index c1375178da3afbb35d2dbbd5d13662b0674d1246..b989100a557945135b40972a70523d5cf7b87810 100644 (file)
@@ -46,33 +46,33 @@ function doInstallWriteLocalConfig () {
        copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getPath() . getCachePath() . 'config-local.php', 0644);
 
        // Ok, all done. So we can write the config data to the php files
        copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getPath() . getCachePath() . 'config-local.php', 0644);
 
        // Ok, all done. So we can write the config data to the php files
-       if (postRequestParameter('spath') != getPath()) changeDataInInclude(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0);
-       if (postRequestParameter('burl')  != getUrl())  changeDataInInclude(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0);
-       // @TODO DEACTIVATED: changeDataInInclude(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-HOST', "        'host'     => '", "',", postRequestParameter('mysql','host'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-DBASE', "       'dbase'    => '", "',", postRequestParameter('mysql','dbase'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', "       'login'    => '", "',", postRequestParameter('mysql','login'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', "    'password' => '", "',", postRequestParameter('mysql','pass1'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0);
-       changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0);
+       if (postRequestParameter('spath') != getPath()) changeDataInLocalConfigurationFile('SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0);
+       if (postRequestParameter('burl')  != getUrl())  changeDataInLocalConfigurationFile('HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0);
+       changeDataInLocalConfigurationFile('MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0);
+       changeDataInLocalConfigurationFile('SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0);
+       changeDataInLocalConfigurationFile('WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0);
+       changeDataInLocalConfigurationFile('NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0);
+       changeDataInLocalConfigurationFile('WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0);
+       changeDataInLocalConfigurationFile('BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0);
+       // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
+       changeDataInLocalConfigurationFile('MYSQL-HOST', "      'host'     => '", "',", postRequestParameter('mysql','host'), 0);
+       changeDataInLocalConfigurationFile('MYSQL-DBASE', "     'dbase'    => '", "',", postRequestParameter('mysql','dbase'), 0);
+       changeDataInLocalConfigurationFile('MYSQL-LOGIN', "     'login'    => '", "',", postRequestParameter('mysql','login'), 0);
+       changeDataInLocalConfigurationFile('MYSQL-PASSWORD', "  'password' => '", "',", postRequestParameter('mysql','pass1'), 0);
+       changeDataInLocalConfigurationFile('MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0);
+       changeDataInLocalConfigurationFile('TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0);
+       changeDataInLocalConfigurationFile('SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0);
+       changeDataInLocalConfigurationFile('SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0);
+       changeDataInLocalConfigurationFile('SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0);
 
        // Generate a long site key
        $siteKey = generatePassword(50);
 
        // And write it
 
        // Generate a long site key
        $siteKey = generatePassword(50);
 
        // And write it
-       changeDataInInclude(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0);
+       changeDataInLocalConfigurationFile('SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0);
 
        // Script is now installed
 
        // Script is now installed
-       changeDataInInclude(getCachePath() . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0);
+       changeDataInLocalConfigurationFile('INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0);
 }
 
 // Adds a given template with content to install output stream
 }
 
 // Adds a given template with content to install output stream
index 9068e4536a9e7ec58914b57eec7af1ce20092ef4..aa379236ede40f0cf3f238ea7191f4672ca84e01 100644 (file)
@@ -73,7 +73,7 @@ if (!isAdminRegistered()) {
                switch ($ret) {
                        case 'done':
                                // Change ADMIN_REGISTERED entry
                switch ($ret) {
                        case 'done':
                                // Change ADMIN_REGISTERED entry
-                               $done = changeDataInInclude(getCachePath() . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0);
+                               $done = changeDataInLocalConfigurationFile('ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0);
 
                                // Was it successfull?
                                if ($done === true) {
 
                                // Was it successfull?
                                if ($done === true) {
index 8925b3deb989e232f54541393bc1b639a4842953..11ef1ef287f346d112133131bcb33ed652ee1963 100644 (file)
@@ -2430,6 +2430,12 @@ function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0)
        return changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
 }
 
        return changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
 }
 
+// Wrapper for changing entries in config-local.php
+function changeDataInInclude ($comment, $prefix, $suffix, $DATA, $seek = 0) {
+       // Call the inner function
+       return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $DATA, $seek);
+}
+
 // Shortens ucfirst(strtolower()) calls
 function firstCharUpperCase ($str) {
        return ucfirst(strtolower($str));
 // Shortens ucfirst(strtolower()) calls
 function firstCharUpperCase ($str) {
        return ucfirst(strtolower($str));