Editar TXT desde AMS

Como indica el nombre del foro en el moveremos todos los temas de dudas que se resuelvan con exito .
Este foro no tendra permisos de escritura.
Hola,
Me gustaria saber como puedo modificar un archivo .TXT desde AMS. La idea seria un .TXT prediseñado de WordPress, como este:

<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information by
* visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/

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

/** MySQL database username */
define('DB_USER', 'databaseuser');

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

/** 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.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ 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', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
/**#@-*/

/**
* 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', '');

/* 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');


Lo que quiero es poner un Label y lo que se introduzca sustituirlo en esta linea: define('DB_NAME', 'databasename');

¿Como podría hacerlo?

Gracias y un saludo!
claro...

TEXTO_COMPLETO = TextFile.ReadToString("MyFile.php");
TEXTO_QUE_QUIERES_CAMBIAR = [[define('DB_NAME', 'databasename');]]
NAME = Input.GetText("Input1"); -- yo uso el input1.
CHAR_USADO = String.Char(39);
TEXTO_NUEVO = [[define('DB_NAME',]]..CHAR_USADO..NAME..CHAR_USADO..[[);]]

TEXTO_COMPLETO_NUEVO = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR, TEXTO_NUEVO, false);
TextFile.WriteFromString("MyFile.php", TEXTO_COMPLETO_NUEVO, false);
Gracias Ceone! Pero tengo un problema. Una vez ejecutada la acción "TextFile.WriteFromString("MyFile.php", TEXTO_COMPLETO_NUEVO, false);", cuando intento volver a realizar la misma acción en otra parte del php (ej: DB_USER), no se realiza ningún cambio en el archivo.

Te pongo un ejemplo:

TEXTO_COMPLETO = TextFile.ReadToString(_SourceFolder.."\\WordPress\\wp-config.php");
TEXTO_QUE_QUIERES_CAMBIAR = [[define('DB_NAME', 'nombredetubasededatos');]]
TEXTO_QUE_QUIERES_CAMBIAR_USER = [[define('DB_USER', 'nombredeusuario');]]
NAME = INIFile.GetValue(_SourceFolder.."\\WordPress.ini", "Config", "Name");
USER = INIFile.GetValue(_SourceFolder.."\\WordPress.ini", "Config", "User");
CHAR_USADO = String.Char(39);
TEXTO_NUEVO = [[define('DB_NAME',]]..CHAR_USADO..NAME..CHAR_USADO..[[);]]
TEXTO_NUEVO_USER = [[define('DB_USER',]]..CHAR_USADO..USER..CHAR_USADO..[[);]]

TEXTO_COMPLETO_NUEVO = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR, TEXTO_NUEVO, false);
TextFile.WriteFromString(_SourceFolder.."\\WordPress\\wp-config.php", TEXTO_COMPLETO_NUEVO, false);
TEXTO_COMPLETO_NUEVO_USER = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR_USER, TEXTO_NUEVO_USER, false);
TextFile.WriteFromString(_SourceFolder.."\\WordPress\\wp-config.php", TEXTO_COMPLETO_NUEVO_USER, false);

Únicamente se realiza un cambio, el segundo no se guarda.

Gracias y un saludo.
no se q opineis vosotros pero para mi este tio se ha pasado de lerdo lol
ams8user escribió:no se q opineis vosotros pero para mi este tio se ha pasado de lerdo lol
Joder tio , como eres... para ti todo el que no tenga tu nivel no merece un respeto o que? deberían hacer lo mismo contigo los que te superan ;P
er_mejor escribió:Gracias Ceone! Pero tengo un problema. Una vez ejecutada la acción "TextFile.WriteFromString("MyFile.php", TEXTO_COMPLETO_NUEVO, false);", cuando intento volver a realizar la misma acción en otra parte del php (ej: DB_USER), no se realiza ningún cambio en el archivo.
Comprueba con string.find que el texto es correcto antes de realizar el cambio.
ams8user escribió:no se q opineis vosotros pero para mi este tio se ha pasado de lerdo lol
Gracias por aportar tu ayuda.
¿Por que no ayudas en vez de decir estupideces?
El primer fallo esta en que en el replace 2º usas el texto original no el resultante en el replace 1º asi que hay errores, esta linea :
 TEXTO_COMPLETO_NUEVO_USER = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR_USER, TEXTO_NUEVO_USER, false);
deberia ser asi :
TEXTO_COMPLETO_NUEVO_USER = String.Replace([TEXTO_COMPLETO_NUEVO, TEXTO_QUE_QUIERES_CAMBIAR_USER, TEXTO_NUEVO_USER, false);
Yo lo he echo asi y me funciona bien:
TEXTO_COMPLETO = TextFile.ReadToString(_DesktopFolder.."\\MySettings.php");
TEXTO_QUE_QUIERES_CAMBIAR = "define('DB_NAME', 'databasename');"
TEXTO_QUE_QUIERES_CAMBIAR_USER = "define('DB_USER', 'databaseuser');"
NAME = "'nuevo nombre'";
USER = "'Nuevo usser'";
TEXTO_NUEVO = "define('DB_NAME',".. NAME ..");"
TEXTO_NUEVO_USER = "define('DB_USER',".. USER ..");"
TEXTO_COMPLETO = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR, TEXTO_NUEVO, false);
TEXTO_COMPLETO = String.Replace(TEXTO_COMPLETO, TEXTO_QUE_QUIERES_CAMBIAR_USER, TEXTO_NUEVO_USER, false);
TextFile.WriteFromString(_DesktopFolder.."\\MySettings_Nuevo.php", TEXTO_COMPLETO, false);-- para remmplazar el original, cambia a 'MySettings.php'.
ams8user escribió:no se q opineis vosotros pero para mi este tio se ha pasado de lerdo lol
lolllll, eres el mejor, menudo ijoputa estas hecho, de lejos el que mejor me cae de aqui ajajaja

bueno dejando de lado el comando troll yo lo haría un poco distinto mas que nada para que sea claro y automatico.

texto=[[loquesea=%valorconfig%]]

y luego un texto=string.replace(texto,"%valorconfig%",variable)

bastante lerdillo si :)
todo viene en el arcihvo de ayuda, acaso quereis que se lo traduzcan?

Imagen
ams8user escribió:todo viene en el arcihvo de ayuda, acaso quereis que se lo traduzcan?
Mira campeón, mas te hubiese gustado a ti saber la mitad con la edad que tengo. Prefiero no dejarte en rediculo ;)

Suerte campeon!

P.D: Gracias por la ayuda Rafaxplayer.
bla bla bla, si supieras lo que ya hacia a vuestra edad no dirias nada
para cuando llegues a mi edad no abras hecho ni la mitad de lo que yo he hecho
lee el manual y ya