';
	$user="mcbell";
}
// template for the standard UI part
$html = '
Edit-Box™ qwnet.cfg
  Gedächtnisstütze: !mnet_<BOTNAME>. Geht nur in #messagenet.
  
  [02:59:44] (QuAd|Haui) 1. bot joinen lassen
  [02:59:51] (QuAd|Haui) 2. cfg editieren und cfg beim bot reloaden
  
  Konfuzius sagt: Mann der Textfeld neu lädt bevor er schwer denken, der Weisheit zeigen.
  
  Sein Schüler stellt fest: Mann der hinterlässt Datum und Namen seiniges, der kann haben guten Schlaf.
 
'; 
// --------------------------------------------------------------------
// 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 ''.$_POST["contents"].'
';
  
  // 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. Nochmal?');
  
}
?>