- if ($person == "russ") {
- $myFile = "russ.txt";
- $fh = fopen($myFile, 'w') or die("can't open file");
- fwrite($fh, $status);
+ $myFile = "summon.txt";
+ $list = file("summon.txt");
+ $fh = fopen($myFile, 'w') or die("can't open file");
+ $matched=0;
+ foreach ($list as $summoned) {
+ list($item,$flag) = split("=",trim($summoned));
+ if ($person == $item) {
+ fwrite($fh, "$person=$status\n");
+ $matched=1;
+ } else {
+ if (strlen($item) > 0) {
+ fwrite($fh, "$item=$flag\n");
+ }
+ }
+ }
+ fclose($fh);
+ if ($matched==0) {
+ $fh = fopen($myFile, 'a') or die("can't open file");
+ fwrite($fh, "$person=$status\n");