www-thermferm/profiles.php

Sat, 26 Jul 2014 22:26:30 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 26 Jul 2014 22:26:30 +0200
changeset 139
ffcabb9166bf
parent 137
e4518fd9b626
child 140
1b001de37945
permissions
-rw-r--r--

Better screen 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
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
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
49 if (isset($_GET['action'])) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
50 switch ($_GET['action']) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
51 case 'edit': profile_edit();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
52 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
53 default: break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
54 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
55 } elseif (isset($_POST['action'])) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
56 switch ($_POST['action']) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
57 case 'testdata': testdata();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
58 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
59 default: break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
60 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
61 } else {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
62 profile_list();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
63 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
64
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
65 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
66
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
67
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
68
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
69
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
70 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
71 * Profile add
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
72 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
73 * @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
74 */
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
75 function profile_add() {
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
76
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
77 $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
78
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
79 $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
80 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
81 /*
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
82 * 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
83 */
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
84 socket_write($sock, $cmd, 4096);
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
85 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
86 $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
87 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
88 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
89 }
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
90 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
91 }
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
92
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
93 unset($_POST['UUID']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
94 unset($_POST['Name']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
95 unset($_POST['key']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
96 unset($_POST['command']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
97 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
98 }
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
99
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
100
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
101
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
102 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
103 * Profile update
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
104 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
105 * @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
106 * @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
107 * @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
108 */
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
109 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
110 /*
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
111 * 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
112 */
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
113 if ($_POST['key'] == 'Delete')
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
114 $update_cmd = "DEL PROFILE ".$_POST['UUID'];
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
115 else
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
116 $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
117
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
118 $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
119 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
120 /*
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
121 * 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
122 */
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
123 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
124 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
125 $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
126 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
127 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
128 }
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
129 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
130 }
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
131
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
132 unset($_POST['UUID']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
133 unset($_POST['Name']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
134 unset($_POST['key']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
135 unset($_POST['command']);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
136 load('profiles.php');
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
137 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
138
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
139
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
140
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
141 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
142 * 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
143 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
144 * @param string $_POST['UUID'] Unique record UUID
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
145 * @param string $_POST['Name'] Profile name
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
146 * @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
147 * @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
148 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
149 * Return: 0 = Ok
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
150 * 1 = Missing data
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
151 * 2 = Name field too short
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
152 * 3 = Name already in use
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
153 * 99 = Cancel key
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
154 */
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
155 function test_thedata() {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
156
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
157 global $arr;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
158
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
159 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
160
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
161 if ($_POST['key'] == 'Cancel')
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
162 return 99;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
163
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
164 if (strlen($_POST['Name']) < 2)
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
165 return 2;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
166
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
167 if (startsWith($arr[0], "212")) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
168 $j = 1;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
169 while (1) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
170 if (strcmp($arr[$j], ".") == 0)
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
171 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
172 $f = explode(",", $arr[$j]);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
173 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
174 return 3;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
175 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
176 $j++;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
177 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
178 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
179
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
180 } else {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
181 return 1;
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
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
184 return 0;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
185 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
186
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
187
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
188
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
189 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
190 * 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
191 */
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
192 function testdata() {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
193
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
194 $result = test_thedata();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
195 $error = '';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
196
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
197 switch ($result) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
198 case 0: if ($_POST['command'] == 'add') {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
199 profile_add();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
200 return;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
201 } else if ($_POST['command'] == 'update') {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
202 profile_update();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
203 return;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
204 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
205 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
206 case 1: $error = 'Missing data';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
207 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
208 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
209 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
210 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
211 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
212 case 99:
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
213 load('profiles.php');
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
214 break;
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
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
217 if ($_POST['command'] == 'add') {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
218 $heading = 'ThermFerm - Add Profile';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
219 } else {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
220 $heading = 'ThermFerm - Edit Profile';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
221 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
222
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
223 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
224 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
225
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
226
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
227
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
228 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
229 * 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
230 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
231 * @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
232 * @param string $Name The Profile Name.
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
233 * @param string $command 'add' or 'update'
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
234 * @param string $heading Pagina heading title.
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
235 * @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
236 */
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
237 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
238
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
239 $outstr = build_header($heading);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
240 $outstr .= ' <div id="errors">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
241 $outstr .= ' '.$error_message.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
242 $outstr .= ' </div> <!-- errors -->'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
243 $outstr .= ' <div id="etable">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
244 $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
245 $outstr .= ' <table class="editor">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
246 $outstr .= ' <tr class="editor">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
247 $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
248 $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
249 $outstr .= ' </tr>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
250 $outstr .= ' <tr class="editor">'.PHP_EOL;
139
ffcabb9166bf Better screen name
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
251 $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
252 $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
253 $outstr .= ' </tr>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
254 $outstr .= ' <tr class="editor">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
255 $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
256 $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
257 $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
258 $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
259 $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
260 $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
261 $outstr .= ' </tr>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
262 $outstr .= ' </table>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
263 $outstr .= ' </form>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
264 $outstr .= ' </div> <!-- etable -->'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
265 $outstr .= build_footer();
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
266 echo $outstr;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
267 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
268
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
269
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
270
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
271 /*
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
272 * 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
273 *
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
274 * @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
275 * @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
276 */
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
277 function profile_edit() {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
278
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
279 global $arr;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
280
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
281 if ($_GET['action'] == 'edit') {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
282
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
283 if (startsWith($arr[0], "212")) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
284 $j = 1;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
285 while (1) {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
286 if (strcmp($arr[$j], ".") == 0)
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
287 break;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
288 $f = explode(",", $arr[$j]);
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
289 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
290 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
291 return;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
292 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
293 $j++;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
294 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
295 } else {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
296 load('profiles.php');
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
297 }
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
298
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
299 } else {
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
300 load('profiles.php');
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
301 }
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
302 }
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
303
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
304
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
305
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
306 /*
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
307 * @link Edit profile
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
308 * @link Add profile
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
309 */
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
310 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
311
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
312 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
313
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
314 $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
315
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
316 $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
317 $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
318 $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
319 $outstr .= ' <table class="setup">'.PHP_EOL;
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
320 $outstr .= ' <tr style="background-color: #FFCC01;">'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
321 $outstr .= ' <td class="setup">UUID</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
322 $outstr .= ' <td class="setup">Name</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
323 $outstr .= ' <td class="setup">Steps</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
324 $outstr .= ' <td class="setup">Edit</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
325 $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
326
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
327 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
328 $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
329 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
330 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
331 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
332 $f = explode(",", $arr[$j]);
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
333 $outstr .= ' <tr class="setup">'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
334 $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
335 $outstr .= ' <td class="setup">'.$f[1].'</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
336 $outstr .= ' <td class="setup">'.$f[2].'</td>'.PHP_EOL;
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
337 if ($f[3] == 1)
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
338 $outstr .= ' <td class="setup">Busy</td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
339 else
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
340 $outstr .= ' <td class="setup"><a href="profiles.php?action=edit&amp;UUID='.$f[0].'">Edit</a></td>'.PHP_EOL;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
341 $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
342 $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
343 }
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
344 }
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
345
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
346 $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
347 $outstr .= ' </div> <!-- etable -->'.PHP_EOL;
137
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
348 $outstr .= ' <div id="atable">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
349
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
350 $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
351 $outstr .= ' <table class="editor">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
352 $outstr .= ' <tr class="editor">'.PHP_EOL;
139
ffcabb9166bf Better screen name
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
353 $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
354 $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
355 $outstr .= ' </tr>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
356 $outstr .= ' <tr class="editor">'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
357 $outstr .= ' <td class="editname"><input type="submit" value="Add" name="key"></td>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
358 $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
359 $outstr .= '<input type="hidden" value="add" name="command">';
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
360 $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
361 $outstr .= ' </tr>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
362 $outstr .= ' </table>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
363 $outstr .= ' </form>'.PHP_EOL;
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
364
e4518fd9b626 Profiles can be managed via the web interface
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
365 $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
366 $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
367 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
368 }
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
369

mercurial