Jump to content
UBot Underground

Writing lotsa code into a new file


Recommended Posts

Here's a challenging one for you all. (Assuming I'm not blind as a bat.)

 

I'm trying to GENERATE the wp-config.php file for wordpress on the fly.

 

I have an FTP program my bot can use to upload it into place, but I need for the bot to input variables into the file, such as server Database name and password.

 

For the life of me I can't figure out how to put this much data in ubot's memory at once... I do something similar all the time will filling Text Areas in forms, but this is to save to file, not fill text area, and the blank for all that code is just one line tall... Can't wrap at all.

 

(Well yeah, I could use the $new line constant 78 times... Not doing that though!)

 

Any ideas, folks?

 

In case it helps, here's the code I'd want in the file:

 

<?php

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '{1}_{2}');

/** MySQL database username */
define('DB_USER', '{1}_{3}');

/** MySQL database password */
define('DB_PASSWORD', '{5}');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY',         '{4}');
define('SECURE_AUTH_KEY',  '{4}');
define('LOGGED_IN_KEY',    '{4}');
define('NONCE_KEY',        '{4}');
define('AUTH_SALT',        '{4}');
define('SECURE_AUTH_SALT', '{4}');
define('LOGGED_IN_SALT',   '{4}');
define('NONCE_SALT',       '{4}');


/**#@-*/

/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix  = 'wp_';

/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress.  A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de.mo to wp-content/languages and set WPLANG to 'de' to enable German
* language support.
*/
define ('WPLANG', '');

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

 

The variables are just my database, username and password, and a random spun part (#4) for the auth keys.

 

Thanks in advance!

Luke

Link to post
Share on other sites

How about this

 

http://screencast.com/t/w0r4QA1s97V

 

When you are setting up the variable you have to use Shift Enter because the window will close and assume you are done.

 

Ah... I see where you're going with that... Set variables for all the chunks inbetween the variables that I'm putting into it, so at the end there will be about 28 Variables in total. -Then just line up all 28 into a $save to file together.

 

Looks like I can make it work, I'll try in the morning when I'm not so sleepy.

 

Thanks BB! Just what I needed to go on.

-Luke

Link to post
Share on other sites

Actually the star of this show turned out to be Shift-Enter, which I guess I missed somehow before. When was that added?

 

Anyway, since you can put variables like your DB username inside variables, I chuncked it down to just 3 top-level variables in total, not 28. Pretty sweet.

 

Thanks again, Buddy!

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...