/* * File: _saveconfig.php * * MODIFIED:2010-7-11 * By:liulang * Description: Involves two files: _saveconfig.php and config.php When you update some of the global configuration variables in the background, * Change the background of the config.php and then through this file to change the foreground config.php file (the former background files are the same), * This is one of the methods I have used, I think it's not bad, take it out and share it with you * * created:2010-6-20 * By:liulang (xujiaphp@gmail.com) * */ $srcFile = '. /'. $dRootDir. ' #data/config.php '; $dstFile = $dRootDir. ' config.php '; $content = file_get_contents ($srcFile); $arr = array ( Array (' SITENAME ', $gSite [' SITENAME ']), Array (' Sitenameen ', $gSite [' Sitenameen ']), Array (' Sitekeywords ', $gSite [' sitekeywords ']), Array (' Sitedescription ', $gSite [' sitedescription ']), Array (' URLPrefix ', $gUrlPrefix), Array (' Dbhost ', $gDb [' Host ']), Array (' DBUSER ', $gDb [' User ']), Array (' Dbpwd ', $gDb [' pwd ']), Array (' DBNAME ', $gDb [' DB ']), Array (' Dbprefix ', $gDb [' prefix ']), Array (' dir ', $gUpload [' dir ']), Array (' ImageWidth ', $gUpload [' imagewidth ']), Array (' ImageHeight ', $gUpload [' ImageHeight ']), Array (' ContactUs ', $contactus), Array (' Menuhiddendiv ', $menuhiddendiv), Array (' THEME ', $gTheme), Array (' Date ', date (' y-m-d ')), Array (' USER ', $dAdminName) ); for ($i = 0; $i < count ($arr); $i + +) { $content = Str_replace (' ~ ' ~ '. $arr [$i][0]. ' ~ ' ~ ', $arr [$i][1], $content); } Copy ($dRootDir. ' config.php ', $dRootDir. ' bak.config.php '); Copy ($dRootDir. ' bak.config.php ', '. /'. $dRootDir. ' config.php '); $done = File_put_contents ($dstFile, $content); Copy ($dstFile, '.. /'. $dRootDir. ' config.php '); ?> |