I think it is, because I use SMF and when you edit its settings, /settings.php gets changed.
But how do you do this?
I think it is, because I use SMF and when you edit its settings, /settings.php gets changed.
But how do you do this?
You would want to use the file system functions in PHP. fopen, fread, fwrite, file_get_contents, and some other ones that you can see for yourself on their website (PHP.net).
A simple example of how to write to a text file:
Hope this helps.Code:<?php $filename = 'test.txt'; $string = "This is some text that will be written to the test file!"; $fp = fopen($filename, 'w'); fwrite($fp, $string); fclose($fp); ?>
Last edited by thetestingsite; 04-06-2007 at 03:13 AM.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
In the fopen call, doesn't the handle have to be a string?
Code:$fp = fopen($filename, "w");
- Mike
Ah yes, typing fast and missed my quotes; although, this will probably still work. Anyways, thanks for pointing that out Mike.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
It will still work without quotes (unless there's a define with the name w) but it shouldn't be relied upon, because it requires error-correction to work and would conflict with the aforementioned define if it were introduced.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
i have a script on my home computer that makes a text box containing the text file, you can edit it and click save and it makes the whole file look like the text box did.... i will post it later
I think the issue is simply writing to a text file, not the whole she-bang.
thetestingsite has explained what to do, anyways.
- Mike
Code:<?php if ($changefile) { $slash = stripslashes($_POST['filetest']); $filetochange = "http://site.com/file.txt"; $filetochangeOpen = fopen($filetochange,"w") or die ("Error editing."); fputs($filetochangeOpen,$slash); fclose($filetochangeOpen) or die ("Error Closing File!"); } ?> <form method=post action=""> <textarea rows="40" cols="60" name="filetest"> <? // Implode CSS $filetochange = "http://site.com/file.txt"; print (implode("",file($filetochange))); ?> </textarea><br /> <br /> <input type="submit" value="Change File" name="changefile"> </form>
1. You should use implode("\r\n", $filetochange);
2. You can dump the whole print(implode("\r\n", $filetochange)); for print(file_get_contents($filetochange));
You probably mean implode("\r\n", file($filetochange)), but the \r\n is only for Windows: UNIX-based operating systems use just \n, and the old Mac-based operating systems (pre OS X) use just \r.1. You should use implode("\r\n", $filetochange);Only in PHP 4.3.0 and later.2. You can dump the whole print(implode("\r\n", $filetochange)); for print(file_get_contents($filetochange));
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks