Fixed profile steps updateing from the web interface.

Fri, 26 Jun 2015 13:42:05 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 26 Jun 2015 13:42:05 +0200
changeset 378
313efe6bf5b3
parent 377
6570b282eaef
child 379
50675fd80fed

Fixed profile steps updateing from the web interface.

www-thermferm/profiles.php file | annotate | diff | comparison | revisions
--- a/www-thermferm/profiles.php	Sun Jun 21 20:15:43 2015 +0200
+++ b/www-thermferm/profiles.php	Fri Jun 26 13:42:05 2015 +0200
@@ -257,38 +257,21 @@
     $error = '';
 
     switch ($result) {
-    	case 0: $sock = open_socket();
-		if ($sock != false) {
-		    socket_write($sock, 'PROFILE PUTS '.$_POST['UUID'], 4096);
-		    for ($i = 1; $i <= 8; $i++) {
-			/*
-			 * Use small delays so the remote really sees single lines.
-			 * This is a real bug between client/server programming,
-			 * the PHP side is line oriented, the server is reading blocks.
-			 * So we just send the data slowly and the server just sees lines.
-			 */
+        case 0: $cmd = array("PROFILE PUTS ".$_POST['UUID']);
+		for ($i = 1; $i <= 8; $i++) {
 			if (($_POST['steptime'.$i] > 0) || ($_POST['resttime'.$i] > 0)) {
-			    usleep(20000);
-			    socket_write($sock, $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target'.$i], 4096);
-			}
-			unset($_POST['steptime'.$i]);
-			unset($_POST['resttime'.$i]);
-			unset($_POST['target'.$i]);
+			    $cmd[] = $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target'.$i];
 		    }
-		    usleep(20000);
-		    socket_write($sock, '.', 4096);
-		    /* Absorb response */
-		    while (1) {
-			$line = socket_read($sock, 4096);
-			if ($line === '')
-			    break;
-		    }
-		    socket_close($sock);
-		    unset($_POST['UUID']);
-		    unset($_POST['key']);
-		    load('profiles.php');
-		    return;
-    		}
+		    unset($_POST['steptime'.$i]);
+		    unset($_POST['resttime'.$i]);
+		    unset($_POST['target'.$i]);
+		}
+		$cmd[] = ".";
+		send_array($cmd);
+		unset($_POST['UUID']);
+		unset($_POST['key']);
+		load('profiles.php');
+		return;
 		break;
         case 1: $error = 'Missing data';
 		break;

mercurial