<?php
// post a list of participants (used by killuser.htm) to server (in joinlist.txt in session directory) (todo=213)
//
// Note that content is delivered escaped, and to avoid' and " problems, is saved that way
// That means getSavedAnyData should unescape before delivery (exception: don't unescape simplehistory, it has special csv format)


require("phpVars.php");

// extract request fields (typically in  a POST)
  $sessName='';
  $content='';
  foreach ($_REQUEST as $vname=>$oof) {
     $avar=trim(strtoupper($vname)) ;
     if ($avar=='SESSION') $sessName=trim($oof);
     if ($avar=='CONTENT' || $avar=='CONTENTS') $content=trim($oof);         // content will contain escaped stuff
  }

if ($sessName=='') {
  header('Content-type:text/plain');
  print '- Error. No NAME or SESSION= in call to postParticipantFile.php ';
  exit ;
}

$content=urldecode($content);

   $newfile=$sessions_dir . $sessName . '\joinlist.txt' ;
   $fnum=fopen($newfile,'w');
   if (!$fnum) {
     print "- Error. Unable to open file: $newfile ";
     return 0 ;
   }
   if (!fwrite($fnum,$content)) {
       print "- Error. Unable to write to file: $newfile ";
       return 0 ;
   }
   fclose($fnum);


header('Content-type:text/plain');
$slen=strlen($content);
print "ok  joinlist.txt was created for $sessName " ;
exit ;
