Jump to content

PHP Script Installation. File Modding


mrjohn117

Recommended Posts

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

 

Link to comment
Share on other sites

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? :o!]

Link to comment
Share on other sites

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. 

 

 

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

  • 2 weeks later...

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 ?>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.