Thu, 24 Jul 2014 23:14:20 +0200
Fixed compiling on systems with wiringpi libs
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | /***************************************************************************** |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * Copyright (C) 2014 |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * Michiel Broek <mbroek at mbse dot eu> |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * This file is part of ThermFerm |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * This is free software; you can redistribute it and/or modify it |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * Free Software Foundation; either version 2, or (at your option) any |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * later version. |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * ThermFerm is distributed in the hope that it will be useful, but |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * General Public License for more details. |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | *****************************************************************************/ |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | require_once('utilities.php'); |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
27 | |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
28 | if (isset($_GET['update'])) { |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
29 | /* |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
30 | * Build the update command |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
31 | */ |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
32 | $update_cmd = "PROFILE ".$_GET['UUID'].",".$_GET['Name']; |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
33 | |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
34 | $sock = open_socket(); |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
35 | if ($sock != false) { |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
36 | /* |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
37 | * Send command and absorb the result. |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
38 | */ |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
39 | socket_write($sock, $update_cmd, 4096); |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
40 | while (1) { |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
41 | $line = socket_read($sock, 4096); |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
42 | if ($line === '') |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
43 | break; |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
44 | } |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
45 | socket_close($sock); |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
46 | } |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
47 | } |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
48 | |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
49 | |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
50 | |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
51 | /* |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
52 | * Get current profiles |
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
53 | */ |
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | $sock = open_socket(); |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | if ($sock == false) { |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | echo ""; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | return; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | } |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | socket_write($sock, "LIST PROFILES", 4096); |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | $answer = ""; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | while (1) { |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | $line = socket_read($sock, 4096); |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | if ($line === '') |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | break; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | $answer .= $line; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | } |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | socket_close($sock); |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | $arr = explode("\r\n", $answer); |
132
8bd209d1c020
Added some profile commands to the server. Profile names can be changed from the web interface. Removed obsolete commands.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
70 | $row = '['; |
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | /* We don't use json_encode because it doesn't work for our purpose */ |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | if (startsWith($arr[0], "212")) { |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | $j = 1; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | while (1) { |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | if (strcmp($arr[$j], ".") == 0) |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | break; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | if ($j > 1) |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | $row .= ','; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | $f = explode(",", $arr[$j]); |
131
528dc0bb81ab
Always use uuid to select units and remove numeric record id's.
Michiel Broek <mbroek@mbse.eu>
parents:
124
diff
changeset
|
82 | $row .= '{"UUID":"'.$f[0].'","Name":"'.$f[1].'","Steps":"'.$f[2].'"}'; |
124
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | $j++; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | } |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | } |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | $row .= ']'; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | echo $row; |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | |
350401bac16e
Added maintenance tabs and extended server output
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | ?> |