/* * File: _ saveconfig. php * * Modified: 2010-7-11 * By: liulang * Note: two files are involved: _ saveconfig. php and config. php. when updating some global configuration variables in the background, * Change the config. php file in the background and then use this file to change the config. php file in the foreground (the front and back ends are all the same ), * This is a method I have used and I think it is good to 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 ('sitekeyword', $ gSite ['sitekeyword']), 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 ', $ menuhiddenp ), 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 '); ?> |