Php uses the COPY function to update the configuration file ,. Php uses the COPY function to update the configuration file. This article describes how php uses the COPY function to update the configuration file. Share it with you for your reference. The details are as follows: _ saveconfig php uses the COPY function to update the configuration file,
This example describes how php updates the configuration file using the COPY function. Share it with you for your reference. The details are as follows:
The _ saveconfig. php file is as follows:
<? Php/** File: _ saveconfig. php ** Modified: 2010-7-11 * By: liulang * Description: two files are involved: _ saveconfig. php and config. when php updates some global configuration variables in the background, * changes the background config. php then uses this file to change the front-end config. php files (front and back-end files are the same), * this is a method I have used, I think it is good, take out to share with you ** Created: * By: liulang (xujiaphp@gmail.com) **/$ srcFile = '.. /'. $ dRootDir. '# data/config. php'; $ dstFile = $ dRootDir. 'config. php '; $ content = file_get_contents ($ srcFile); $ arr = 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', $ gUplo Ad ['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 ');?>
The config. php configuration file is as follows:
<? Php/** File: config. php ** Modified: 2010-09-20 * By: admin ** Created: 2010-6-20 * By: liulang (xujiaphp@gmail.com) **/$ gVersion = '1. 0'; $ gDb = array ('host' => 'localhost', // host name 'user' => 'root', // username 'pwd' => '', // password 'DB' => 'Sino ', // database name 'prefix' => 'Sin _' // database prefix ); $ gSite = array ('sitename' => 'company name', 'sitenameen' => 'we are the company ', 'sitekeyword' => 'medicines, pharmaceuticals ', 'sitedescript Ion '=> 'company name is a 00 company'); $ gUpload = array ('dir' => 'uploads', 'imagewidth' => '123 ', 'imageheight' => '*'); $ contactus = ''; $ menuhiddenp =" "; $ FROMURL = $ _ SERVER [" HTTP_REFERER "]? $ _ SERVER ["HTTP_REFERER"]: $ HTTP_SERVER_VARS ["HTTP_REFERER"]; $ dRootDir = '.. /'; $ conn = mysql_connect ($ gDb ['host'], $ gDb ['user'], $ gDb ['pwd']); mysql_select_db ($ gDb ['DB']) or die ('database connect error! '); Mysql_query ("set names 'gbk'");?>
I hope this article will help you with php programming.
Example: php uses the COPY function to update the configuration file. Share it with you for your reference. The details are as follows: _ saveconfig...