pugboy Posted November 8, 2008 Share Posted November 8, 2008 First question-- In almost EVERY forum and CMS package, they have a web based installer to create the configuration file for you (vBulletin might not, but I can't remember). How exactly do they do this? I was going to recreate this by using str_replace and finding a unique string in the file, but most of the time the fields are actually blank. My file is just a class: <?php //Setting file... //No need to edit this unless you are manually installing class Settings { //General Website Stuff... var $sitename = '<HIDDEN FOR SECURITY REASONS>'; //Site title... Shown in header of website var $longTitle = '<HIDDEN>'; //Long title. Shown in title bar var $siteslogan = ''; var $offline = '0'; //Is the site offline? Usually 0 (No) var $offline_message = '$sitename is currently down for maintenance.<br/>Please check again soon!'; //Database stuff... var $db_type = 'mysql'; //Possible values: mysql var $db_prefix = 'wcms_'; //Defaults to wcms_. Change if you want to install more than one script on one database (for those with smaller hosting packages) var $db_host = 'localhost'; //Database host... Usually localhost on the hosts that don't mega-oversell. You know who I am talking about. var $db_name = ''; //Database name... Get this from your webhost var $db_user = ''; //Database username. Default MySQL username is root with no password. Again, get this from your host. var $db_pass = ''; //Database password. Don't worry, no one can see this unless they have FTP access to this file } ?> Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/ Share on other sites More sharing options...
BillyBoB Posted November 8, 2008 Share Posted November 8, 2008 What exactly are you trying to do? Are you trying to create that config file by an installer script in php? Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/#findComment-685453 Share on other sites More sharing options...
genericnumber1 Posted November 8, 2008 Share Posted November 8, 2008 you could use a cached ini file for easy modification, a database config (also cached), or you could do a preg_replace with a pattern like public \$sitename = '([^']*?)'; note I used public instead of var because php 5 has been out for a long time Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/#findComment-685525 Share on other sites More sharing options...
pugboy Posted November 9, 2008 Author Share Posted November 9, 2008 I am trying to generate a config file with PHP (when installing my script). I will have to look at preg_replace (never used it before) as well... Also, is 'public' a PHP5 only thing? Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/#findComment-686023 Share on other sites More sharing options...
genericnumber1 Posted November 9, 2008 Share Posted November 9, 2008 yes, access modifiers were added in php 5. Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/#findComment-686127 Share on other sites More sharing options...
pugboy Posted November 9, 2008 Author Share Posted November 9, 2008 Ok, thanks I got it working by replacing strings like [dbname] which works for now... Thanks Link to comment https://forums.phpfreaks.com/topic/131931-solved-the-code-behind-configuration-files/#findComment-686136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.