mrjohn117 Posted March 6, 2010 Share Posted March 6, 2010 Hey Alright so. I have made some scripts. Pretty sick scripts. Now i wanna create an installation that will edit PHP file and insert MYSQL stuff. I have MYSQL sorted. But how do I create an installation that will edit PHP files during install. Thanks Matt Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/ Share on other sites More sharing options...
PravinS Posted March 6, 2010 Share Posted March 6, 2010 Refer http://php.net/manual/en/function.fwrite.php Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022258 Share on other sites More sharing options...
mrjohn117 Posted March 6, 2010 Author Share Posted March 6, 2010 Alright so like what do i do lol? I'm not super bright. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022260 Share on other sites More sharing options...
mrjohn117 Posted March 6, 2010 Author Share Posted March 6, 2010 basically i want it to fill in the Mysql details of config files. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022261 Share on other sites More sharing options...
PravinS Posted March 6, 2010 Share Posted March 6, 2010 basically you can directly create new config file and write all config content in that file, it will overwrite your old config file. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022262 Share on other sites More sharing options...
True`Logic Posted March 6, 2010 Share Posted March 6, 2010 Everywhere where installing is going to modify the file put a character tht is unused (Like ¶ or $chr(173), which is an invisible character that takes up no space.). Then load the file into a variable; explode("¶", $var-name) or explode($chr(173), $var-name) into another variable. for example: TitlePage.html contains: <html> <title>¶</title> <body><h1><center>Welcome To ¶ </center></h1></body> </html> you will: <?php $new_title = "Page Title"; $site_name = "Site Name"; $base = fread(fopen("TitlePage.html", "r"), filesize("TitlePage.html")); $data = explode("¶", $base); $ret = $data[0] . $new_title . $data[1] . $site_name . $data[2]; @fwrite(fopen("TitlePage.html", "w"), $ret) or die("Failed to edit TitlePage.html"); echo "Title Page Editted."; ?> From ehre you should be able to understand and modify what you need. If you need further help, feel free to post! -T`L [First psot since July 2006... who remembers me? !] Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022398 Share on other sites More sharing options...
mrjohn117 Posted March 6, 2010 Author Share Posted March 6, 2010 alright i think i have sort of an idea. thanks Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022492 Share on other sites More sharing options...
mrjohn117 Posted March 6, 2010 Author Share Posted March 6, 2010 Wait no this will not work. The files i want it to edit are Config.php and a few otherws. All PHP. will it work? Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022496 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 php files are no different to any other text file. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022520 Share on other sites More sharing options...
mrjohn117 Posted March 7, 2010 Author Share Posted March 7, 2010 alright ill give it a shot. Ill say how it goes. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022540 Share on other sites More sharing options...
mrjohn117 Posted March 7, 2010 Author Share Posted March 7, 2010 Alright heres the thing. I need it to insert the same MYSQL details as this file (details arn't real) $dbhost = "localhost"; // DATABASE HOST IT IS USUALLY LOCALHOST $dbuser = "mrjohn1_btcs"; // DATABASE USERNAME $dbpass = "startrek"; // DATABASE PASSWORD $dbname = "mrjohn1_bcstcs"; // DATABASE NAME $dbprefix = ""; // DATABASE PREFIX (if needed, used for multiple sites and 1 database) Then they have to goin into this // ***** Config **************************************************************** // The list of admin users. // To add multiple admins, use a code like this: array('admin1', 'admin2', 'admin3'); $chat_admins = array('admin'); // The number of messages to keep $chat_histlen = 1000; // Interval in seconds to wait before setting status to away $chat_t_away = 30; // Interval in seconds to wait before disconnecting a user $chat_t_logout = 9; // Interval in seconds between refreshes $chat_t_refresh = 1; // Messages sent to the users $chat_err_inval = 'Invalid username or password!'; $chat_err_inuse = 'The username you selected is already in use!'; $chat_err_kick = 'You are not allowed to enter the chat. Contact admin for explanation.'; $chat_err_mute = 'You are not allowed to post in the chat. Contact admin for explanation.'; // Use this function to validate registered users' login information. function chat_chk($username, $password, &$gender, &$status) { $gender = 'none'; $status = 'none'; // Remove this line return true; // Enter MySQL access information $MySQL_username = ''; $MySQL_password = ''; $MySQL_database = ''; // Enter the location of user data in MySQL database $MySQL_table = ''; $MySQL_username_field = ''; $MySQL_password_field = ''; This is Ajax chat board i think its name is. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022543 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 Where are you stuck exactly, can we see your code? Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022554 Share on other sites More sharing options...
Rustywolf Posted March 7, 2010 Share Posted March 7, 2010 you could sotre them in a variables.php include that file and write it as fwrite($fp, '<?php $username = ' . $_POST['username'] . "; /n " . '$password = ' . $_POST['password'] . "; /n " . '$host = ' . $_POST['host'] . "; /n ?>"); or something Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022556 Share on other sites More sharing options...
mrjohn117 Posted March 7, 2010 Author Share Posted March 7, 2010 Alright. During installation i want "install.php" to read the MYSQL details from "config.php" and then put them into "init.php" I attached the files because it was over 40,000 characters. Thanks. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022586 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 We know what you want to do. You haven't posted any code relating to your attempts to do this nor any description of the problem your having however. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022588 Share on other sites More sharing options...
mrjohn117 Posted March 7, 2010 Author Share Posted March 7, 2010 Well can you code it for me? Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022603 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 No. That is not the point of this board. Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1022651 Share on other sites More sharing options...
True`Logic Posted March 19, 2010 Share Posted March 19, 2010 Try this: in "phpdata.php" put <?php /*---¶ $dbhost = "localhost"; // DATABASE HOST IT IS USUALLY LOCALHOST $dbuser = "mrjohn1_btcs"; // DATABASE USERNAME $dbpass = "startrek"; // DATABASE PASSWORD $dbname = "mrjohn1_bcstcs"; // DATABASE NAME $dbprefix = ""; // DATABASE PREFIX (if needed, used for multiple sites and 1 database) ¶--*/ ?> then in your isntall script: $phpdata = ""; $php_get_data1 = fread(fopen("phpdata.php", "r") filesize("phpdata.php")); $php_get_data2 = explode("¶", $php_get_data1); $phpdata .= $php_get_data2[1]; $ret .= "<?php\r\n" . $phpdata . "\r\n ?>"; Quote Link to comment https://forums.phpfreaks.com/topic/194321-php-script-installation-file-modding/#findComment-1028632 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.