123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- // filewriter 0.1, NickK, 2004-12-28
- // Provides an Edit Box for text files on server's hdd.
- // Original on /home/nick/scripts
- error_reporting(E_ALL^E_NOTICE);
- // Files to read/write - absolute path
- $READFILE = "/home/haui/httpd/quadaver.mine.nu/htdocs/qw-serveme/qwnet.cfg";
- $WRITEFILE = "/home/haui/httpd/quadaver.mine.nu/htdocs/qw-serveme/qwnet.cfg";
- // --------------------------------------------------------------------
- // make a textarea size depending on our adminusers :) (and their monitor resolutions)
- $txt_cols = "110";
- $txt_rows = "21";
- if ($_REQUEST['user']=="mcbell") {
- $txt_cols = "140";
- $txt_rows = "35";
- $hidden_uservalue = '<input type="hidden" name="user" value="mcbell"/>';
- $user="mcbell";
- }
- // template for the standard UI part
- $html = '<html>
- <body style="font-family: sans-serif">
- <h1>Edit-Box™ qwnet.cfg</h1>
- <p style="background-color: #e0c0c0; padding:5pt">
- <strong>Gedächtnisstütze:</strong> !mnet_<BOTNAME>. Geht nur in #messagenet.
- <br />
- <span style="font-size:smaller">[02:59:44] (QuAd|Haui) 1. bot joinen lassen
- [02:59:51] (QuAd|Haui) 2. cfg editieren und cfg beim bot reloaden</span>
- <br />
- Konfuzius sagt: <em>Mann der Textfeld neu lädt bevor er schwer denken, der Weisheit zeigen.</em>
- <br />
- Sein Schüler stellt fest: <em>Mann der hinterlässt Datum und Namen seiniges, der kann haben guten Schlaf.</em>
- </p>
- <form method="POST" action="#SELF#">
- '.$hidden_uservalue.'
- <textarea cols="'.$txt_cols.'" rows="'.$txt_rows.'" name="contents">
- #CONTENTS#</textarea>
- <br />
- <input type="submit" value="Speichern" />
- </form>
- </body>
- </html>';
- // --------------------------------------------------------------------
- // first check: Can we write at all?
- if (!is_writable($WRITEFILE)) {
- print("(1) Sorry. $WRITEFILE ist nicht schreibbar (+w flag missing).");
- exit;
- }
- // "contents" is given via POST. If it's not there, build the
- // HTML user interface. (See template $html above)
- if (!array_key_exists("contents", $_POST)) {
- // fetch template/old content
- $contents = file_get_contents ($READFILE);
- if ($contents == FALSE) {
- print("(2) Probleme beim Lesen von $READFILE.");
- exit;
- }
- // fill template (see $html above)
- $html = preg_replace("/#CONTENTS#/", $contents, $html);
- $html = preg_replace("/#SELF#/", basename(__FILE__), $html);
- print ($html);
- }
- else {
- // the active part of the script goes here. Write stuff.
- if (!$file = fopen($WRITEFILE, "w")) {
- print("(3) Sorry. Kann $WRITEFILE nicht öffnen, d.h. es wurde nichts geschrieben.");
- exit;
- }
- // echo '<pre>'.$_POST["contents"].'</pre>';
-
- // stripslashes needed because of php.ini directive magic quotes = on
- if (!fwrite($file, stripslashes($_POST["contents"]))) {
- print("(4) Konnte $WRITEFILE nicht schreiben. Sorry.");
- exit;
- }
- if (!fclose($file)) {
- print("(5) Konnte den Filehandler nicht schließen. Das macht aber nicht wirklich was.");
- }
- print('Fertig. <a href="' . $_SERVER["SCRIPT_NAME"] . '?user='.$user.'">Nochmal?</a>');
-
- }
- ?>
|