<?php
   session_start();
   if(!isSet($_SESSION["kasutajanimi"])){
      header("Location: sisenemisvorm.php");
      exit();
   }
   if(isSet($_REQUEST["salvestusnupp"])){
     if(!preg_match("/^[a-z]+\.txt$/", $_REQUEST["salvestusfail"])){
        echo "Vigane failinimi";
        exit();
     }
     if(!file_exists("../lehesisud/$_REQUEST[salvestusfail]")){
        echo "fail puudub";
        exit();
     }
     $f=fopen("../lehesisud/$_REQUEST[salvestusfail]", "w");
     fputs($f, stripslashes($_REQUEST["failisisu"]));
     fclose($f);
   }
   header("Location: haldusleht.php");
?>