|
1 <?php |
|
2 /***************************************************************************** |
|
3 * Copyright (C) 2014 |
|
4 * |
|
5 * Michiel Broek <mbroek at mbse dot eu> |
|
6 * |
|
7 * This file is part of ThermFerm |
|
8 * |
|
9 * This is free software; you can redistribute it and/or modify it |
|
10 * under the terms of the GNU General Public License as published by the |
|
11 * Free Software Foundation; either version 2, or (at your option) any |
|
12 * later version. |
|
13 * |
|
14 * ThermFerm is distributed in the hope that it will be useful, but |
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 * General Public License for more details. |
|
18 * |
|
19 * You should have received a copy of the GNU General Public License |
|
20 * along with ThermFerm; see the file COPYING. If not, write to the Free |
|
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
22 *****************************************************************************/ |
|
23 |
|
24 require_once('utilities.php'); |
|
25 |
|
26 profile_admin(); |
|
27 exit; |
|
28 |
|
29 |
|
30 function profile_admin() { |
|
31 if (isset($_GET['action'])) { |
|
32 switch ($_GET['action']) { |
|
33 default: break; |
|
34 } |
|
35 } elseif (isset($_POST['action'])) { |
|
36 switch ($_POST['action']) { |
|
37 default: break; |
|
38 } |
|
39 } else { |
|
40 profile_list(); |
|
41 } |
|
42 } |
|
43 |
|
44 |
|
45 |
|
46 function profile_add() { |
|
47 $cmd = "ADD PROFILE ".$_GET['Name']; |
|
48 |
|
49 $sock = open_socket(); |
|
50 if ($sock != false) { |
|
51 /* |
|
52 * Send command and absorb the result. |
|
53 */ |
|
54 socket_write($sock, $update_cmd, 4096); |
|
55 while (1) { |
|
56 $line = socket_read($sock, 4096); |
|
57 if ($line === '') |
|
58 break; |
|
59 } |
|
60 socket_close($sock); |
|
61 } |
|
62 } |
|
63 |
|
64 |
|
65 |
|
66 function profile_update() { |
|
67 /* |
|
68 * Build the update command |
|
69 */ |
|
70 $update_cmd = "PROFILE ".$_GET['UUID'].",".$_GET['Name']; |
|
71 |
|
72 $sock = open_socket(); |
|
73 if ($sock != false) { |
|
74 /* |
|
75 * Send command and absorb the result. |
|
76 */ |
|
77 socket_write($sock, $update_cmd, 4096); |
|
78 while (1) { |
|
79 $line = socket_read($sock, 4096); |
|
80 if ($line === '') |
|
81 break; |
|
82 } |
|
83 socket_close($sock); |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 function profile_list() { |
|
90 |
|
91 $sock = open_socket(); |
|
92 if ($sock == false) { |
|
93 echo ""; |
|
94 return; |
|
95 } |
|
96 |
|
97 socket_write($sock, "LIST PROFILES", 4096); |
|
98 $answer = ""; |
|
99 while (1) { |
|
100 $line = socket_read($sock, 4096); |
|
101 if ($line === '') |
|
102 break; |
|
103 $answer .= $line; |
|
104 } |
|
105 socket_close($sock); |
|
106 $arr = explode("\r\n", $answer); |
|
107 |
|
108 $outstr = build_header(); |
|
109 |
|
110 $outstr .= ' <div id="errors">'.PHP_EOL; |
|
111 $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
|
112 |
|
113 $outstr .= ' <div id="etable">'.PHP_EOL; |
|
114 $outstr .= ' <table class="setup">'.PHP_EOL; |
|
115 $outstr .= ' <tr style="background-color: #FFCC01;"><td class="setup">UUID</td><td class="setup">Name</td><td class="setup">Steps</td><td class="setup">spare</td></tr>'.PHP_EOL; |
|
116 |
|
117 if (startsWith($arr[0], "212")) { |
|
118 $j = 1; |
|
119 while (1) { |
|
120 if (strcmp($arr[$j], ".") == 0) |
|
121 break; |
|
122 $f = explode(",", $arr[$j]); |
|
123 $outstr .= ' <tr class="setup"><td class="setup">'.$f[0].'</td><td class="setup">'.$f[1].'</td><td class="setup">'.$f[2].'</td><td class="setup">bla</td></tr>'.PHP_EOL; |
|
124 $j++; |
|
125 } |
|
126 } |
|
127 |
|
128 $outstr .= ' </table>'.PHP_EOL; |
|
129 $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
|
130 $outstr .= build_footer(); |
|
131 echo $outstr; |
|
132 } |
|
133 |