<?php

include('buiapp/partials/header.php');
include ('buiapp/phpClasses/functions.php');
if (isset($_SESSION['staff_session'])) {
    $username = $_SESSION['staff_session'];
	$csession =  currentSession();
		$role = getrole($username, $csession);
		

} else {
   header('Location: index.php');
   exit();
} 


$token = openssl_random_pseudo_bytes(16);
$token = bin2hex($token);

	$pre = "http://".$_SERVER['SERVER_NAME'];
				 $newfilename = $token;
	
	    $file_name = $_FILES['signature']['name'];
      $file_size =$_FILES['signature']['size'];
     
      $file_type=$_FILES['signature']['type'];
      
      

$tmp = explode('.', $file_name);
$ext = end($tmp);
      $dir = "signatures/$newfilename.$ext";
     
      
      
     
       
		 if(move_uploaded_file($_FILES["signature"]["tmp_name"], $dir)){
				insertsignature($dir, $username);

			header('Location:memo.php');
		 }else{
			  header('Location:prememo.php');
		 }


?>