• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How would i go about making a script like this?

WarDemon666

Platinum Member
I want the script to search through a file, and find the part that is typed out, and then replace it with another input.

Is this how i would go about doing it?

Anyways thanks in advance.

<?


$myFile = fopen("c:\www\dittohost\\test.txt", "a");
$fcontents = file($myFile);

str_replace($oldpassword,$newpassword,$i_dont_know_what_to_put_here);

fclose($myFile);

?>
 
it should be..

$fcontents = str_replace($oldpassword,$newpassword,$fcontents);


be aware that will only work if your PHP is 4.0.5 or later. That's because if there are multiple lines in the file, then $fcontents is an array of string. Each of the array element is a line in the file. In earlier versions of PHP, str_replace do not support arrays in the the parameter. So, you'll need to put the above line in a FOR loop.

btw, from what I can tell you are storing passwords in a textfile.. it's generally a bad idea to do so. It's worst if you store them as plain text. At least do some encryption on the password. Encrypt the password with MD5 or something. MD5 is one-way encryption though, meaning once you encrypt a string you can't decrypt it back.
 
Back
Top