changeset 1856:96b83aa64be3

Actually the previous commit was broken. This contains a working and more elegant way of checking for the input file length. If the input file is empty, no error is triggered.
author Giulio Moro <giuliomoro@users.noreply.github.com>
date Tue, 23 Feb 2016 14:39:06 +0000
parents 03b876101f05
children dc09a8a78c79
files save.php
diffstat 1 files changed, 1 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/save.php	Tue Feb 23 14:18:25 2016 +0000
+++ b/save.php	Tue Feb 23 14:39:06 2016 +0000
@@ -7,13 +7,6 @@
 	$datetime = date('ymdHis');
 	$xmlfile = "save".$datetime."-".$sha1_hash.".xml";
 	$fileHandle = fopen("saves/".$xmlfile, 'w');
-	if (sizeof($postText) <= 1)
-	{
-		// Filehandle failed
-		$xml = '<response state="error"><message>Input file empty</message></response>';
-		echo $xml;
-		return;
-	}
 	if ($fileHandle == FALSE)
 	{
 		// Filehandle failed
@@ -22,7 +15,7 @@
 		return;
 	}
 	$wbytes = fwrite($fileHandle, $postText);
-	if ($wbytes == FALSE)
+	if ($wbytes === FALSE)
 	{
 		// FileWrite failed
 		$xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';