Wed, 30 Jul 2014 23:06:46 +0200
Update LCD even when unit is off
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | /***************************************************************************** |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * Copyright (C) 2014 |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * Michiel Broek <mbroek at mbse dot eu> |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * This file is part of ThermFerm |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * This is free software; you can redistribute it and/or modify it |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * Free Software Foundation; either version 2, or (at your option) any |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * later version. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * ThermFerm is distributed in the hope that it will be useful, but |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * General Public License for more details. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | *****************************************************************************/ |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | require_once('utilities.php'); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
26 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
27 | * Each time this page is loaded, get the profiles from the server. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
28 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
29 | $sock = open_socket(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
30 | if ($sock == false) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
31 | load('index.php'); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
32 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
33 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
34 | socket_write($sock, "LIST PROFILES", 4096); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
35 | $answer = ""; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
36 | while (1) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
37 | $line = socket_read($sock, 4096); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
38 | if ($line === '') |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
39 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
40 | $answer .= $line; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
41 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
42 | socket_close($sock); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
43 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
44 | * $arr contains the complete reply of he LIST PROFILES command. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
45 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
46 | $arr = explode("\r\n", $answer); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
47 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
48 | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
49 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
50 | if (isset($_GET['action'])) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
51 | switch ($_GET['action']) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
52 | case 'edit': profile_edit(); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
53 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
54 | case 'esteps': profile_steps(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
55 | break; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
56 | default: break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
57 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
58 | } elseif (isset($_POST['action'])) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
59 | switch ($_POST['action']) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
60 | case 'testdata': testdata(); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
61 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
62 | case 'teststeps': teststeps(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
63 | break; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
64 | default: break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
65 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
66 | } else { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
67 | profile_list(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
68 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
69 | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | exit; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
74 | /* |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
75 | * Profile steps |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
76 | */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
77 | function profile_steps() |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
78 | { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
79 | global $arr; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
80 | $UUID = $_GET['UUID']; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
81 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
82 | /* |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
83 | * $steps contains all steps of a profile |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
84 | */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
85 | $steps = array ( |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
86 | 1 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
87 | 2 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
88 | 3 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
89 | 4 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
90 | 5 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
91 | 6 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
92 | 7 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
93 | 8 => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
94 | ); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
95 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
96 | $sock = open_socket(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
97 | if ($sock == false) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
98 | load('profiles.php'); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
99 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
100 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
101 | socket_write($sock, "PROFILES GETS ".$UUID, 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
102 | $answer = ""; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
103 | while (1) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
104 | $line = socket_read($sock, 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
105 | if ($line === '') |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
106 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
107 | $answer .= $line; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
108 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
109 | socket_close($sock); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
110 | $psteps = explode("\r\n", $answer); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
111 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
112 | if (startsWith($arr[0], "212")) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
113 | $j = 1; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
114 | while (1) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
115 | if (strcmp($psteps[$j], ".") == 0) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
116 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
117 | $f = explode(",", $psteps[$j]); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
118 | $steps[$j]["steptime"] = $f[0]; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
119 | $steps[$j]["resttime"] = $f[1]; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
120 | $steps[$j]["target"] = $f[2]; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
121 | $j++; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
122 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
123 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
124 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
125 | edit_steps($UUID, $steps, "", "ThermFerm - Edit Profile Steps"); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
126 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
127 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
128 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
129 | function edit_steps($UUID, $steps, $error_message, $heading) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
130 | { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
131 | $outstr = build_header($heading); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
132 | $outstr .= ' <div id="errors">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
133 | $outstr .= ' '.$error_message.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
134 | $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
135 | $outstr .= ' <div id="etable">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
136 | $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
137 | $outstr .= ' <table class="editor">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
138 | $outstr .= ' <tr class="trhead">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
139 | $outstr .= ' <td>Step</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
140 | $outstr .= ' <td>Steptime</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
141 | $outstr .= ' <td>Resttime</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
142 | $outstr .= ' <td>Temperature</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
143 | $outstr .= ' </tr>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
144 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
145 | for ($i = 1; $i <= 8; $i++) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
146 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
147 | $outstr .= ' <td>Step '.$i.'</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
148 | $outstr .= ' <td><input type="text" name="steptime'.$i.'" size="4" value="'.$steps[$i]["steptime"].'"></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
149 | $outstr .= ' <td><input type="text" name="resttime'.$i.'" size="4" value="'.$steps[$i]["resttime"].'"></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
150 | $outstr .= ' <td><input type="text" name="target'.$i.'" size="4" value="'.$steps[$i]["target"].'"></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
151 | $outstr .= ' </tr>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
152 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
153 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
154 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
155 | $outstr .= ' <td class="editname"> </td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
156 | $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
157 | $outstr .= ' <td class="editname"><input type="submit" value="Cancel" name="key">'; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
158 | $outstr .= '<input type="hidden" value="teststeps" name="action">'; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
159 | $outstr .= '<input type="hidden" value="'.$UUID.'" name="UUID"></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
160 | $outstr .= ' <td class="editname"> </td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
161 | $outstr .= ' </tr>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
162 | $outstr .= ' </table>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
163 | $outstr .= ' </form>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
164 | $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
165 | $outstr .= ' <div id="atable" style="margin-left: 100px; width:780px;">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
166 | $outstr .= ' The steptime is the time to go from the previous to the target temperature.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
167 | $outstr .= ' The resttime is the total time in this step including the steptime.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
168 | $outstr .= ' Steps are valid if the steptime is greater then zero.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
169 | $outstr .= ' Order is important.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
170 | $outstr .= ' Lines with a steptime of zero are ignored.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
171 | $outstr .= ' The step- and resttimes are in hours.'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
172 | $outstr .= ' </div> <!-- atable -->'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
173 | $outstr .= build_footer(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
174 | echo $outstr; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
175 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
176 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
177 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
178 | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
180 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
181 | * Profile add |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
182 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
183 | * @param string $_POST['Name'] The rpofile name |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
184 | */ |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | function profile_add() { |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
186 | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
187 | if ($_POST['key'] == 'Add') { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
188 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
189 | $cmd = "ADD PROFILE ".$_POST['Name']; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
191 | $sock = open_socket(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
192 | if ($sock != false) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
193 | /* |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
194 | * Send command and absorb the result. |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
195 | */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
196 | socket_write($sock, $cmd, 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
197 | while (1) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
198 | $line = socket_read($sock, 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
199 | if ($line === '') |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
200 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
201 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
202 | socket_close($sock); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
203 | } |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | } |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
205 | unset($_POST['UUID']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
206 | unset($_POST['Name']); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
207 | unset($_POST['Steps']); |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
208 | unset($_POST['key']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
209 | unset($_POST['command']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
210 | load('profiles.php'); |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
215 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
216 | * Profile update |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
217 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
218 | * @param string $_POST['UUID'] The profile UUID |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
219 | * @param string $_POST['Name'] The profile name |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
220 | * @param string $_POST['key'] The button pressed. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
221 | */ |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | function profile_update() { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | /* |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | * Build the update command |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | */ |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
226 | if ($_POST['key'] == 'Delete') |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
227 | $update_cmd = "DEL PROFILE ".$_POST['UUID']; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
228 | else |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
229 | $update_cmd = "PROFILE ".$_POST['UUID'].",".$_POST['Name']; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | $sock = open_socket(); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | if ($sock != false) { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | /* |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | * Send command and absorb the result. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | */ |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | socket_write($sock, $update_cmd, 4096); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | while (1) { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | $line = socket_read($sock, 4096); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | if ($line === '') |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | break; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | socket_close($sock); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | } |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
244 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
245 | unset($_POST['UUID']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
246 | unset($_POST['Name']); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
247 | unset($_POST['Steps']); |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
248 | unset($_POST['key']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
249 | unset($_POST['command']); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
250 | load('profiles.php'); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
251 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
252 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
253 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
254 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
255 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
256 | * Test input of a modified or new profile. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
257 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
258 | * @param string $_POST['UUID'] Unique record UUID |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
259 | * @param int $_POST['steptime'n] Profile steptime |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
260 | * @param int $_POST['resttime'n] Profile resttime |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
261 | * @param float $_POST['target'n] Profile target temperature |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
262 | * @param string $_POST['key'] Key choice, Save or Cancel |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
263 | * |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
264 | * Return: 0 = Ok |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
265 | * 1 = Missing data |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
266 | * 2 = A resttime < steptime |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
267 | * 3 = A target temperature out of range |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
268 | * 99 = Cancel key |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
269 | */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
270 | function test_thesteps() { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
271 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
272 | global $arr; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
273 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
274 | print_r($_POST); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
275 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
276 | for ($i = 1; $i <= 8; $i++) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
277 | if ((! isset($_POST['steptime'.$i])) || (! isset($_POST['resttime'.$i])) || (! isset($_POST['target'.$i]))) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
278 | return 1; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
279 | if ((strlen($_POST['steptime'.$i]) == 0) || (strlen($_POST['resttime'.$i]) == 0) || (strlen($_POST['target'.$i]) == 0)) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
280 | return 1; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
281 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
282 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
283 | if (isset($_POST['UUID']) && isset($_POST['key'])) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
284 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
285 | if ($_POST['key'] == 'Cancel') |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
286 | return 99; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
287 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
288 | for ($i = 1; $i <= 8; $i++) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
289 | if ($_POST['resttime'.$i] < $_POST['steptime'.$i]) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
290 | return 2; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
291 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
292 | if (($_POST['target'.$i] < -5) || ($_POST['target'.$i] > 30)) |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
293 | return 3; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
294 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
295 | } else { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
296 | return 1; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
297 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
298 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
299 | return 0; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
300 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
301 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
302 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
303 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
304 | /* |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
305 | * Test result from edit_steps screen and do next action |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
306 | */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
307 | function teststeps() { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
308 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
309 | $result = test_thesteps(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
310 | $error = ''; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
311 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
312 | switch ($result) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
313 | case 0: $sock = open_socket(); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
314 | if ($sock != false) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
315 | socket_write($sock, 'PROFILE PUTS '.$_POST['UUID'], 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
316 | for ($i = 1; $i <= 8; $i++) { |
141 | 317 | /* |
318 | * Use small delays so the remote really sees single lines. | |
319 | * This is a real bug between client/server programming, | |
320 | * the PHP side is line oriented, the server is reading blocks. | |
321 | * So we just send the data slowly and the server just sees lines. | |
322 | */ | |
323 | if ($_POST['steptime'.$i] > 0) { | |
324 | usleep(20000); | |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
325 | socket_write($sock, $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target'.$i], 4096); |
141 | 326 | } |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
327 | unset($_POST['steptime'.$i]); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
328 | unset($_POST['resttime'.$i]); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
329 | unset($_POST['target'.$i]); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
330 | } |
141 | 331 | usleep(20000); |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
332 | socket_write($sock, '.', 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
333 | /* Absorb response */ |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
334 | while (1) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
335 | $line = socket_read($sock, 4096); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
336 | if ($line === '') |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
337 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
338 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
339 | socket_close($sock); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
340 | unset($_POST['UUID']); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
341 | unset($_POST['key']); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
342 | load('profiles.php'); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
343 | return; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
344 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
345 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
346 | case 1: $error = 'Missing data'; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
347 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
348 | case 2: $error = 'A resttime is shorter then the steptime'; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
349 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
350 | case 3: $error = 'A target temperature is out of range'; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
351 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
352 | case 99: |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
353 | load('profiles.php'); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
354 | break; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
355 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
356 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
357 | $steps = array ( |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
358 | 1 => array("steptime" => $_POST['steptime1'], "resttime" => $_POST['resttime1'], "target" => $_POST['target1'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
359 | 2 => array("steptime" => $_POST['steptime2'], "resttime" => $_POST['resttime2'], "target" => $_POST['target2'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
360 | 3 => array("steptime" => $_POST['steptime3'], "resttime" => $_POST['resttime3'], "target" => $_POST['target3'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
361 | 4 => array("steptime" => $_POST['steptime4'], "resttime" => $_POST['resttime4'], "target" => $_POST['target4'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
362 | 5 => array("steptime" => $_POST['steptime5'], "resttime" => $_POST['resttime5'], "target" => $_POST['target5'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
363 | 6 => array("steptime" => $_POST['steptime6'], "resttime" => $_POST['resttime6'], "target" => $_POST['target6'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
364 | 7 => array("steptime" => $_POST['steptime7'], "resttime" => $_POST['resttime7'], "target" => $_POST['target7'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
365 | 8 => array("steptime" => $_POST['steptime8'], "resttime" => $_POST['resttime8'], "target" => $_POST['target8'] ), |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
366 | ); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
367 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
368 | edit_steps($_POST['UUID'], $steps, $error, "ThermFerm - Edit Profile Steps"); |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
369 | } |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
370 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
371 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
372 | |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
373 | /* |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
374 | * Test input of a modified or new profile. |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
375 | * |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
376 | * @param string $_POST['UUID'] Unique record UUID |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
377 | * @param string $_POST['Name'] Profile name |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
378 | * @param int $_POST['Steps'] Profile steps |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
379 | * @param string $_POST['key'] Key choice, Save or Cancel |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
380 | * @param string $_POST['command'] Command used, 'add' or 'update' |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
381 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
382 | * Return: 0 = Ok |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
383 | * 1 = Missing data |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
384 | * 2 = Name field too short |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
385 | * 3 = Name already in use |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
386 | * 99 = Cancel key |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
387 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
388 | function test_thedata() { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
389 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
390 | global $arr; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
391 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
392 | if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['key']) && isset($_POST['command'])) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
393 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
394 | if ($_POST['key'] == 'Cancel') |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
395 | return 99; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
396 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
397 | if (strlen($_POST['Name']) < 2) |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
398 | return 2; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
399 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
400 | if (startsWith($arr[0], "212")) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
401 | $j = 1; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
402 | while (1) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
403 | if (strcmp($arr[$j], ".") == 0) |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
404 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
405 | $f = explode(",", $arr[$j]); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
406 | if (strcmp($f[0], $_POST['UUID']) && (strcmp($f[1], $_POST['Name']) == 0)) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
407 | return 3; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
408 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
409 | $j++; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
410 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
411 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
412 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
413 | } else { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
414 | return 1; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
415 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
416 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
417 | return 0; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
418 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
419 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
420 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
421 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
422 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
423 | * Test result from edit screen and do next action |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
424 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
425 | function testdata() { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
426 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
427 | $result = test_thedata(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
428 | $error = ''; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
429 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
430 | switch ($result) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
431 | case 0: if ($_POST['command'] == 'add') { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
432 | profile_add(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
433 | return; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
434 | } else if ($_POST['command'] == 'update') { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
435 | profile_update(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
436 | return; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
437 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
438 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
439 | case 1: $error = 'Missing data'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
440 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
441 | case 2: $error = 'The name is too short'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
442 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
443 | case 3: $error = 'The name is already in use, choose another one'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
444 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
445 | case 99: |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
446 | load('profiles.php'); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
447 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
448 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
449 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
450 | if ($_POST['command'] == 'add') { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
451 | $heading = 'ThermFerm - Add Profile'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
452 | } else { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
453 | $heading = 'ThermFerm - Edit Profile'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
454 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
455 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
456 | edit_screen($_POST['UUID'], $_POST['Name'], $_POST['command'], $heading, $error); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
457 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
458 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
459 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
460 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
461 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
462 | * Profiles edit screen. Used by profile_edit(), profile_add() and testdata() |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
463 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
464 | * @param string $UUID The record UUID (fixed). |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
465 | * @param string $Name The Profile Name. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
466 | * @param string $command 'add' or 'update' |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
467 | * @param string $heading Pagina heading title. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
468 | * @Param string $error_message Blank or previous error. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
469 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
470 | function edit_screen($UUID, $Name, $command, $heading, $error_message) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
471 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
472 | $outstr = build_header($heading); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
473 | $outstr .= ' <div id="errors">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
474 | $outstr .= ' '.$error_message.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
475 | $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
476 | $outstr .= ' <div id="etable">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
477 | $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
478 | $outstr .= ' <table class="editor">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
479 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
480 | $outstr .= ' <td class="editname">UUID</td>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
481 | $outstr .= ' <td class="editfield">'.$UUID.'</td>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
482 | $outstr .= ' </tr>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
483 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
139 | 484 | $outstr .= ' <td class="editname">Profile Name</td>'.PHP_EOL; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
485 | $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value="'.$Name.'"></td>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
486 | $outstr .= ' </tr>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
487 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
488 | $outstr .= ' <td class="editname">Profile Steps</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
489 | $outstr .= ' <td class="editfield">'.$Steps.'</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
490 | $outstr .= ' </tr>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
491 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
492 | $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
493 | $outstr .= ' <td class="editfield"><input type="submit" value="Cancel" name="key">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
494 | $outstr .= '<input type="submit" value="Delete" name="key" style="margin-left: 100px;">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
495 | $outstr .= '<input type="hidden" value="testdata" name="action">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
496 | $outstr .= '<input type="hidden" value="'.$command.'" name="command">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
497 | $outstr .= '<input type="hidden" value="'.$UUID.'" name="UUID"></td>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
498 | $outstr .= ' </tr>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
499 | $outstr .= ' </table>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
500 | $outstr .= ' </form>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
501 | $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
502 | $outstr .= build_footer(); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
503 | echo $outstr; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
504 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
505 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
506 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
507 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
508 | /* |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
509 | * Edit a Profile. Fetches the record data and shows the edit screen. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
510 | * |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
511 | * @param string $_GET['action'] Must be 'edit'. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
512 | * @param string $_GET['UUID'] The UUID of the Profile. |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
513 | */ |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
514 | function profile_edit() { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
515 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
516 | global $arr; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
517 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
518 | if ($_GET['action'] == 'edit') { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
519 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
520 | if (startsWith($arr[0], "212")) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
521 | $j = 1; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
522 | while (1) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
523 | if (strcmp($arr[$j], ".") == 0) |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
524 | break; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
525 | $f = explode(",", $arr[$j]); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
526 | if (strcmp($f[0], $_GET['UUID']) == 0) { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
527 | edit_screen($f[0], $f[1], 'update', 'ThermFerm - Edit Profile', ''); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
528 | return; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
529 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
530 | $j++; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
531 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
532 | } else { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
533 | load('profiles.php'); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
534 | } |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
535 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
536 | } else { |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
537 | load('profiles.php'); |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
538 | } |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
539 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
541 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
543 | /* |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
544 | * @link Edit profile |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
545 | * @link Add profile |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
546 | */ |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
547 | function profile_list() { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
548 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
549 | global $arr; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
550 | |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
551 | $outstr = build_header("ThermFerm - Profiles"); |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
552 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
553 | $outstr .= ' <div id="errors">'.PHP_EOL; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
554 | $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
555 | $outstr .= ' <div id="etable">'.PHP_EOL; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
556 | $outstr .= ' <table class="setup">'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
557 | $outstr .= ' <tr class="trhead">'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
558 | $outstr .= ' <td class="setup" style="width: 300px;">UUID</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
559 | $outstr .= ' <td class="setup" style="width: 300px;">Name</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
560 | $outstr .= ' <td class="setup" style="width: 40px;">Steps</td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
561 | $outstr .= ' <td class="setup" style="width: 40px;">Edit</td>'.PHP_EOL; |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
562 | $outstr .= ' </tr>'.PHP_EOL; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
563 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
564 | if (startsWith($arr[0], "212")) { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
565 | $j = 1; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
566 | while (1) { |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
567 | if (strcmp($arr[$j], ".") == 0) |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
568 | break; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
569 | $f = explode(",", $arr[$j]); |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
570 | $outstr .= ' <tr class="setup">'.PHP_EOL; |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
571 | $outstr .= ' <td class="setup">'.$f[0].'</td>'.PHP_EOL; |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
572 | $outstr .= ' <td class="setup">'.$f[1].'</td>'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
573 | if ($f[3] == 1) { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
574 | $outstr .= ' <td class="setup">'.$f[2].'</td>'.PHP_EOL; |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
575 | $outstr .= ' <td class="setup">Busy</td>'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
576 | } else { |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
577 | $outstr .= ' <td class="setup"><a href="profiles.php?action=esteps&UUID='.$f[0].'">'.$f[2].'</a></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
578 | $outstr .= ' <td class="setup"><a href="profiles.php?action=edit&UUID='.$f[0].'">Edit</a></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
579 | } |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
580 | $outstr .= ' </tr>'.PHP_EOL; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
581 | $j++; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
582 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
583 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
584 | |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
585 | $outstr .= ' </table>'.PHP_EOL; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
586 | $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
587 | $outstr .= ' <div id="atable">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
588 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
589 | $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
590 | $outstr .= ' <table class="editor">'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
591 | $outstr .= ' <tr class="trhead"><td colspan="3">Add new profile</td></tr>'.PHP_EOL; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
592 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
139 | 593 | $outstr .= ' <td class="editname">Profile Name</td>'.PHP_EOL; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
594 | $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value=""></td>'.PHP_EOL; |
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
595 | $outstr .= ' <td class="editsub"><input type="submit" value="Add" name="key"></td>'.PHP_EOL; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
596 | $outstr .= '<input type="hidden" value="testdata" name="action">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
597 | $outstr .= '<input type="hidden" value="add" name="command">'; |
140
1b001de37945
Implemented PROFILE PUTS command
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
598 | $outstr .= '<input type="hidden" value="0" name="Steps"></td>'; |
137
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
599 | $outstr .= '<input type="hidden" value="00000000-0000-0000-0000-000000000000" name="UUID">'; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
600 | $outstr .= ' </tr>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
601 | $outstr .= ' </table>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
602 | $outstr .= ' </form>'.PHP_EOL; |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
603 | |
e4518fd9b626
Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
604 | $outstr .= ' </div> <!-- atable -->'.PHP_EOL; |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
605 | $outstr .= build_footer(); |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
606 | echo $outstr; |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
607 | } |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
608 |