Rev 330 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 330 | Rev 344 | ||
|---|---|---|---|
| 1 | <?php |
1 | <?php |
| 2 | 2 | ||
| 3 | ini_set('display_errors', 1); |
3 | ini_set('display_errors', 1); |
| 4 | ini_set('display_startup_errors', 1); |
4 | ini_set('display_startup_errors', 1); |
| 5 | error_reporting(E_ALL); |
5 | error_reporting(E_ALL); |
| 6 | 6 | ||
| 7 | require 'config.php'; |
7 | require 'config.php'; |
| 8 | require 'ip2coordinates.php'; |
8 | require 'ip2coordinates.php'; |
| 9 | 9 | ||
| 10 | header('Content-Type: text/event-stream'); |
10 | header('Content-Type: text/event-stream'); |
| 11 | // recommended to prevent caching of event data. |
11 | // recommended to prevent caching of event data. |
| 12 | header('Cache-Control: no-cache'); |
12 | header('Cache-Control: no-cache'); |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | function xmlWalker($xml_array, $parent) { |
15 | function xmlWalker($xml_array, $parent) { |
| 16 | $cmd=""; |
16 | $cmd=""; |
| 17 | foreach($xml_array as $tag => $value) { |
17 | foreach($xml_array as $tag => $value) { |
| 18 | if ((int)$tag === $tag) { |
18 | if ((int)$tag === $tag) { |
| 19 | $tag = substr($parent, 0, -1); |
19 | $tag = substr($parent, 0, -1); |
| 20 | } |
20 | } |
| 21 | $cmd = $cmd . "<" .$tag. ">"; |
21 | $cmd = $cmd . "<" .$tag. ">"; |
| 22 | if (is_array($value)) { |
22 | if (is_array($value)) { |
| 23 | $cmd = $cmd . xmlWalker($value, $tag); |
23 | $cmd = $cmd . xmlWalker($value, $tag); |
| 24 | } else { |
24 | } else { |
| 25 | $cmd = $cmd . $value; |
25 | $cmd = $cmd . $value; |
| 26 | } |
26 | } |
| 27 | $cmd = $cmd . "</" .$tag. ">"; |
27 | $cmd = $cmd . "</" .$tag. ">"; |
| 28 | } |
28 | } |
| 29 | return $cmd; |
29 | return $cmd; |
| 30 | } |
30 | } |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | function parseDOMNode(DOMNode $domNode) { |
35 | function parseDOMNode(DOMNode $domNode) { |
| 36 | $str=""; |
36 | $str=""; |
| 37 | $cnt=0; |
37 | $cnt=0; |
| 38 | foreach ($domNode->childNodes as $node) |
38 | foreach ($domNode->childNodes as $node) |
| 39 | { |
39 | { |
| 40 | if ($cnt){ |
40 | if ($cnt){ |
| 41 | $str .= ","; |
41 | $str .= ","; |
| 42 | } |
42 | } |
| 43 | if($node->hasChildNodes()) { |
43 | if($node->hasChildNodes()) { |
| 44 | if (!$node->childNodes->item(0)->hasChildNodes() || |
44 | if (!$node->childNodes->item(0)->hasChildNodes() || |
| 45 | strpos($node->nodeName,"list")!==false |
45 | strpos($node->nodeName,"list")!==false |
| 46 | // || $node->nodeName === "histogram" |
46 | // || $node->nodeName === "histogram" |
| 47 | ) { |
47 | ) { |
| 48 | $str .= parseDOMNode($node); |
48 | $str .= parseDOMNode($node); |
| 49 | } else { |
49 | } else { |
| 50 | $str .= $node->nodeName.'(' ; |
50 | $str .= $node->nodeName.'(' ; |
| 51 | if ( $node->nodeName === "histogram") $str .= $node->childNodes->length . ',' ; |
51 | if ( $node->nodeName === "histogram") $str .= $node->childNodes->length . ',' ; |
| 52 | $str .= parseDOMNode($node); |
52 | $str .= parseDOMNode($node); |
| 53 | $str .= ') ' ; |
53 | $str .= ') ' ; |
| 54 | } |
54 | } |
| 55 | 55 | ||
| 56 | } else { |
56 | } else { |
| 57 | 57 | ||
| 58 | if (is_numeric($node->nodeValue) || $node->parentNode->nodeName === "pid") { |
58 | if (is_numeric($node->nodeValue) || $node->parentNode->nodeName === "pid") { |
| 59 | $str .= $node->nodeValue ; |
59 | $str .= $node->nodeValue ; |
| 60 | } else { |
60 | } else { |
| 61 | if (strlen($node->nodeValue)) { |
61 | if (strlen($node->nodeValue)) { |
| 62 | $str .= '"' . $node->nodeValue . '"' ; |
62 | $str .= '"' . $node->nodeValue . '"' ; |
| 63 | } else { |
63 | } else { |
| 64 | $str .= "-1"; |
64 | $str .= "-1"; |
| 65 | } |
65 | } |
| 66 | } |
66 | } |
| 67 | } |
67 | } |
| 68 | $cnt++; |
68 | $cnt++; |
| 69 | } |
69 | } |
| 70 | return $str; |
70 | return $str; |
| 71 | } |
71 | } |
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | function stat2db($info){ |
78 | function stat2db($info){ |
| 79 | global $code; |
79 | global $code; |
| 80 | // Establish a MySQL connection and select our database using values contained in config.php. |
80 | // Establish a MySQL connection and select our database using values contained in config.php. |
| 81 | 81 | ||
| 82 | if (PHP_SAPI === 'cli') { |
82 | if (PHP_SAPI === 'cli') { |
| 83 | $ip = "171.173.43.71"; |
83 | $ip = "171.173.43.71"; |
| 84 | } else { |
84 | } else { |
| 85 | $ip = $_SERVER['REMOTE_ADDR']; |
85 | $ip = $_SERVER['REMOTE_ADDR']; |
| 86 | } |
86 | } |
| 87 | 87 | ||
| 88 | $userinfo = IPtoCoordinates($ip); |
88 | $userinfo = IPtoCoordinates($ip); |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | mysql_connect(DB_HOST, DB_USER, DB_PASS); |
91 | mysql_connect(DB_HOST, DB_USER, DB_PASS); |
| 92 | mysql_select_db(DB_NAME); |
92 | mysql_select_db(DB_NAME); |
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | $msql = 'INSERT INTO `visitor_map` (`ip`, `location`, `longitude`, `latitude`,`time`, `neve`, `realtime`, `cputime`,`code` ) VALUES (' |
95 | $msql = 'INSERT INTO `visitor_map` (`ip`, `location`, `longitude`, `latitude`,`time`, `neve`, `realtime`, `cputime`,`code` ) VALUES (' |
| 96 | . '\'' . mysql_real_escape_string($ip) . '\',' |
96 | . '\'' . mysql_real_escape_string($ip) . '\',' |
| 97 | . '\'' . $userinfo['location'] . '\', ' |
97 | . '\'' . $userinfo['location'] . '\', ' |
| 98 | . $userinfo['longitude'] . ', ' |
98 | . $userinfo['longitude'] . ', ' |
| 99 | . $userinfo['latitude'] . ' , ' |
99 | . $userinfo['latitude'] . ' , ' |
| 100 | . $info |
100 | . $info |
| 101 | . ', \'' . mysql_real_escape_string($code) . '\'' . |
101 | . ', \'' . mysql_real_escape_string($code) . '\'' . |
| 102 | 102 | ||
| 103 | ')'; |
103 | ')'; |
| 104 | 104 | ||
| 105 | send_message(0,$msql,100); |
105 | send_message(0,$msql,100); |
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | // Assign the user's IP to a variable and plot it into our function, whose return value is assigned to $userinfo |
108 | // Assign the user's IP to a variable and plot it into our function, whose return value is assigned to $userinfo |
| 109 | // Remember, the user's IP is not to be trusted 100% |
109 | // Remember, the user's IP is not to be trusted 100% |
| 110 | 110 | ||
| 111 | // We select the location column from the database |
111 | // We select the location column from the database |
| 112 | $user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = \'' . $userinfo['location'] . '\''); |
112 | $user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = \'' . $userinfo['location'] . '\''); |
| 113 | // If it does NOT return a value, and the user's IP could indeed be matched... |
113 | // If it does NOT return a value, and the user's IP could indeed be matched... |
| 114 | // (This makes sure that we have no duplicate rows (which would be a waste) and can determine the visitor's location, respectively) |
114 | // (This makes sure that we have no duplicate rows (which would be a waste) and can determine the visitor's location, respectively) |
| 115 | // ...We insert the values returned by our function into the database, escaping any possible dangerous input |
115 | // ...We insert the values returned by our function into the database, escaping any possible dangerous input |
| 116 | if(!mysql_fetch_row($user) && $userinfo) |
116 | if(!mysql_fetch_row($user) && $userinfo) |
| 117 | mysql_query($msql); |
117 | mysql_query($msql); |
| 118 | // or die(mysql_error()); |
118 | // or die(mysql_error()); |
| 119 | 119 | ||
| 120 | } |
120 | } |
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | 123 | ||
| 124 | function executeCmd($commandLine) { |
124 | function executeCmd($commandLine) { |
| 125 | 125 | ||
| 126 | $pipe = popen("$commandLine" , 'r'); |
126 | $pipe = popen("$commandLine" , 'r'); |
| 127 | 127 | ||
| 128 | if (!$pipe) { |
128 | if (!$pipe) { |
| 129 | print "pipe failed."; |
129 | print "pipe failed."; |
| 130 | return ""; |
130 | return ""; |
| 131 | } |
131 | } |
| 132 | $output = ''; |
132 | $output = ''; |
| 133 | while(!feof($pipe)) { |
133 | while(!feof($pipe)) { |
| 134 | $contents = fread($pipe, 12); |
134 | $contents = fread($pipe, 12); |
| 135 | $unpacked = unpack("l*",$contents); |
135 | $unpacked = unpack("l*",$contents); |
| 136 | $id = $unpacked[1]; |
136 | $id = $unpacked[1]; |
| 137 | $len = $unpacked[2]; |
137 | $len = $unpacked[2]; |
| 138 | $progress = $unpacked[3]; |
138 | $progress = $unpacked[3]; |
| 139 | if ($len>0){ |
139 | if ($len>0){ |
| 140 | $out= fread($pipe, $len); |
140 | $out= fread($pipe, $len); |
| 141 | if ($id == 3){ |
141 | if ($id == 3){ |
| 142 | $hostname = gethostname(); |
142 | $hostname = gethostname(); |
| 143 | if ($hostname == "belle2.ijs.si") { |
143 | if ($hostname == "belle2.ijs.si") { |
| 144 | stat2db($out); |
144 | stat2db($out); |
| 145 | } |
145 | } |
| 146 | // $out = $_SERVER['REMOTE_ADDR'] . ";" .$out ; |
146 | // $out = $_SERVER['REMOTE_ADDR'] . ";" .$out ; |
| 147 | // $retval = system("echo '$out' >> public/blab2stat.txt "); |
147 | // $retval = system("echo '$out' >> public/blab2stat.txt "); |
| 148 | // $out .= ";" . $retval; |
148 | // $out .= ";" . $retval; |
| 149 | $id = 0 ; |
149 | $id = 0 ; |
| 150 | } |
150 | } |
| 151 | send_message($id,$out,$progress); |
151 | send_message($id,$out,$progress); |
| 152 | } |
152 | } |
| 153 | $output .=$out; |
153 | $output .=$out; |
| 154 | } |
154 | } |
| 155 | pclose($pipe); |
155 | pclose($pipe); |
| 156 | return $output; |
156 | return $output; |
| 157 | } |
157 | } |
| 158 | 158 | ||
| 159 | function send_message($id, $message, $progress) { |
159 | function send_message($id, $message, $progress) { |
| 160 | $d = array('message' => $message , 'progress' => $progress); //prepare json |
160 | $d = array('message' => $message , 'progress' => $progress); //prepare json |
| 161 | 161 | ||
| 162 | echo "id: $id" . PHP_EOL; |
162 | echo "id: $id" . PHP_EOL; |
| 163 | echo "data: " . json_encode($d) . PHP_EOL; |
163 | echo "data: " . json_encode($d) . PHP_EOL; |
| 164 | 164 | ||
| 165 | if (PHP_SAPI !== 'cli') { |
165 | if (PHP_SAPI !== 'cli') { |
| 166 | echo PHP_EOL; |
166 | echo PHP_EOL; |
| 167 | ob_flush(); |
167 | ob_flush(); |
| 168 | } |
168 | } |
| 169 | flush(); |
169 | flush(); |
| 170 | } |
170 | } |
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | function removeTrailingCommas($json) |
173 | function removeTrailingCommas($json) |
| 174 | { |
174 | { |
| 175 | $json=preg_replace('/,\s*([\]}])/m', '$1', $json); |
175 | $json=preg_replace('/,\s*([\]}])/m', '$1', $json); |
| 176 | return $json; |
176 | return $json; |
| 177 | } |
177 | } |
| 178 | 178 | ||
| 179 | 179 | ||
| 180 | $code=""; |
180 | $code=""; |
| 181 | if (PHP_SAPI === 'cli') { |
181 | if (PHP_SAPI === 'cli') { |
| 182 | $code = $argv[1]; |
182 | $code = $argv[1]; |
| 183 | } else { |
183 | } else { |
| 184 | if (isset($_GET["code"])){ |
184 | if (isset($_GET["code"])){ |
| 185 | $code = $_GET["code"]; |
185 | $code = $_GET["code"]; |
| 186 | } |
186 | } |
| 187 | } |
187 | } |
| 188 | 188 | ||
| 189 | $code = removeTrailingCommas($code); |
189 | $code = removeTrailingCommas($code); |
| 190 | //send_message(0,"$code",0); |
190 | //send_message(0,"$code",0); |
| 191 | 191 | ||
| 192 | $data = json_decode($code, true); |
192 | $data = json_decode($code, true); |
| 193 | 193 | ||
| 194 | 194 | ||
| 195 | $ierr =json_last_error(); |
195 | $ierr =json_last_error(); |
| 196 | if (json_last_error() != JSON_ERROR_NONE) { |
196 | if (json_last_error() != JSON_ERROR_NONE) { |
| 197 | send_message(0,"JSON Error $ierr ! cannot convert...",0); |
197 | send_message(0,"JSON Error $ierr ! cannot convert...",0); |
| 198 | send_message('CLOSE', "Stopping...",100); |
198 | send_message('CLOSE', "Stopping...",100); |
| 199 | } |
199 | } |
| 200 | 200 | ||
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | $neve = $data['analysis']['neve']; |
203 | $neve = $data['analysis']['neve']; |
| 204 | $first = $data['analysis']['first']; |
204 | $first = $data['analysis']['first']; |
| 205 | $evprint = $data['analysis']['print']; |
205 | $evprint = $data['analysis']['print']; |
| 206 | $source= $data['analysis']['datasource']; |
206 | $source= $data['analysis']['datasource']; |
| 207 | 207 | ||
| 208 | $xml = '<?xml version="1.0" encoding="utf-8"?>' . xmlWalker($data,'start'); |
208 | $xml = '<?xml version="1.0" encoding="utf-8"?>' . xmlWalker($data,'start'); |
| 209 | $dom = new DOMDocument; |
209 | $dom = new DOMDocument; |
| 210 | $dom->loadXML($xml); |
210 | $dom->loadXML($xml); |
| 211 | /* |
211 | /* |
| 212 | echo "<pre>"; |
212 | echo "<pre>"; |
| 213 | echo $dom->saveXML(); |
213 | echo $dom->saveXML(); |
| 214 | echo "</pre>"; |
214 | echo "</pre>"; |
| 215 | echo PHP_EOL; |
215 | echo PHP_EOL; |
| 216 | */ |
216 | */ |
| 217 | 217 | ||
| 218 | $cnt=0; |
218 | $cnt=0; |
| 219 | 219 | ||
| 220 | $fstart = $dom->createElement("init"); |
220 | $fstart = $dom->createElement("init"); |
| 221 | $dom->appendChild($fstart); |
221 | $dom->appendChild($fstart); |
| 222 | 222 | ||
| 223 | $el = $dom->getElementsByTagName('neve')->item(0); |
223 | $el = $dom->getElementsByTagName('neve')->item(0); |
| 224 | $fstart->appendChild($el); |
224 | $fstart->appendChild($el); |
| 225 | $el = $dom->getElementsByTagName('first')->item(0); |
225 | $el = $dom->getElementsByTagName('first')->item(0); |
| 226 | $fstart->appendChild($el); |
226 | $fstart->appendChild($el); |
| 227 | $el = $dom->getElementsByTagName('print')->item(0); |
227 | $el = $dom->getElementsByTagName('print')->item(0); |
| 228 | $fstart->appendChild($el); |
228 | $fstart->appendChild($el); |
| 229 | $el = $dom->getElementsByTagName('datasource')->item(0); |
229 | $el = $dom->getElementsByTagName('datasource')->item(0); |
| 230 | $fstart->appendChild($el); |
230 | $fstart->appendChild($el); |
| 231 | 231 | ||
| 232 | $histogramCount = $dom->getElementsByTagName('h1d')->length; |
232 | $histogramCount = $dom->getElementsByTagName('h1d')->length; |
| 233 | for($i= $histogramCount-1;$i>=0;--$i) |
233 | for($i= $histogramCount-1;$i>=0;--$i) |
| 234 | { |
234 | { |
| 235 | $idnode=$dom->createElement("id","$i"); |
235 | $idnode=$dom->createElement("id","$i"); |
| 236 | 236 | ||
| 237 | $histo=$dom->getElementsByTagName('h1d')->item($i); |
237 | $histo=$dom->getElementsByTagName('h1d')->item($i); |
| 238 | $histo->appendChild($idnode); |
238 | $histo->appendChild($idnode); |
| 239 | 239 | ||
| 240 | $newnode=$dom->createTextNode("$i"); |
240 | $newnode=$dom->createTextNode("$i"); |
| 241 | $parent = $histo->parentNode; |
241 | $parent = $histo->parentNode; |
| 242 | //$histo->setAttribute('id',"$i"); |
242 | //$histo->setAttribute('id',"$i"); |
| 243 | $fstart->appendChild($histo); |
243 | $fstart->appendChild($histo); |
| 244 | $parent->appendChild($newnode); |
244 | $parent->appendChild($newnode); |
| 245 | 245 | ||
| 246 | } |
246 | } |
| 247 | 247 | ||
| 248 | 248 | ||
| 249 | $xpath = new DOMXpath($dom); |
249 | $xpath = new DOMXpath($dom); |
| 250 | $nodelist = $xpath->query('//selector|//combiner|//combiner3'); |
250 | $nodelist = $xpath->query('//selector|//combiner|//combiner3'); |
| 251 | $cnt=1; |
251 | $cnt=1; |
| 252 | foreach ($nodelist as $plist) { |
252 | foreach ($nodelist as $plist) { |
| 253 | $newnode=$dom->createElement("plist","$cnt"); |
253 | $newnode=$dom->createElement("plist","$cnt"); |
| 254 | $fstart->appendChild($newnode); |
254 | $fstart->appendChild($newnode); |
| 255 | $newnode=$dom->createElement("id","$cnt"); |
255 | $newnode=$dom->createElement("id","$cnt"); |
| 256 | $plist->appendChild($newnode); |
256 | $plist->appendChild($newnode); |
| 257 | $cnt++; |
257 | $cnt++; |
| 258 | } |
258 | } |
| 259 | 259 | ||
| 260 | $nodelist = $xpath->query('//list|//list1|//list2|//list3'); |
260 | $nodelist = $xpath->query('//list|//list1|//list2|//list3'); |
| 261 | $cnt=1; |
261 | $cnt=1; |
| 262 | foreach ($nodelist as $plist) { |
262 | foreach ($nodelist as $plist) { |
| 263 | if( $plist->childNodes->length === 0){ |
263 | if( $plist->childNodes->length === 0){ |
| 264 | $newnode=$dom->createTextNode("-1"); |
264 | $newnode=$dom->createTextNode("-1"); |
| 265 | $plist->appendChild($newnode); |
265 | $plist->appendChild($newnode); |
| 266 | } |
266 | } |
| 267 | } |
267 | } |
| 268 | //$isEmpty = $elem->childNodes->length === 0; |
268 | //$isEmpty = $elem->childNodes->length === 0; |
| 269 | 269 | ||
| 270 | /* |
270 | /* |
| 271 | echo "<pre>"; |
271 | echo "<pre>"; |
| 272 | echo $dom->saveXML(); |
272 | echo $dom->saveXML(); |
| 273 | echo "</pre>"; |
273 | echo "</pre>"; |
| 274 | echo PHP_EOL; |
274 | echo PHP_EOL; |
| 275 | */ |
275 | */ |
| 276 | 276 | ||
| 277 | $str=""; |
277 | $str=""; |
| 278 | foreach ($dom->getElementsByTagName('analysis') as $node){ |
278 | foreach ($dom->getElementsByTagName('analysis') as $node){ |
| 279 | $str = PHP_EOL . "void Blab2::event(){" . PHP_EOL ; |
279 | $str = PHP_EOL . "void Blab2::event(){" . PHP_EOL ; |
| 280 | $str .= parseDOMNode($node) . ";"; |
280 | $str .= parseDOMNode($node) . ";"; |
| 281 | $str .= PHP_EOL . "}" . PHP_EOL ; |
281 | $str .= PHP_EOL . "}" . PHP_EOL ; |
| 282 | } |
282 | } |
| 283 | 283 | ||
| 284 | 284 | ||
| 285 | $nodelist = $fstart->getElementsByTagName('h1d'); |
285 | $nodelist = $fstart->getElementsByTagName('h1d'); |
| 286 | $init = PHP_EOL . "void Blab2::Init(){" . PHP_EOL ; |
286 | $init = PHP_EOL . "void Blab2::Init(){" . PHP_EOL ; |
| 287 | $init .="fNeve=$neve;" . PHP_EOL ; |
287 | $init .="fNeve=$neve;" . PHP_EOL ; |
| 288 | $init .="fNfirst=$first;" . PHP_EOL ; |
288 | $init .="fNfirst=$first;" . PHP_EOL ; |
| 289 | $init .=" |
289 | $init .='fData="' . $source . '";' . PHP_EOL ; |
| 290 | $init .="fPrint=$evprint;" . PHP_EOL ; |
290 | $init .="fPrint=$evprint;" . PHP_EOL ; |
| 291 | foreach ($nodelist as $node) { |
291 | foreach ($nodelist as $node) { |
| 292 | $init .= $node->nodeName . "("; |
292 | $init .= $node->nodeName . "("; |
| 293 | $cnt=0; |
293 | $cnt=0; |
| 294 | foreach ($node->childNodes as $el) { |
294 | foreach ($node->childNodes as $el) { |
| 295 | if ($cnt) { |
295 | if ($cnt) { |
| 296 | $init .= ","; |
296 | $init .= ","; |
| 297 | } |
297 | } |
| 298 | if (is_numeric($el->nodeValue)) { |
298 | if (is_numeric($el->nodeValue)) { |
| 299 | $init .= $el->nodeValue ; |
299 | $init .= $el->nodeValue ; |
| 300 | } else { |
300 | } else { |
| 301 | $init .= '"' . $el->nodeValue . '"' ; |
301 | $init .= '"' . $el->nodeValue . '"' ; |
| 302 | } |
302 | } |
| 303 | $cnt++; |
303 | $cnt++; |
| 304 | } |
304 | } |
| 305 | $init .= ");" . PHP_EOL; |
305 | $init .= ");" . PHP_EOL; |
| 306 | } |
306 | } |
| 307 | 307 | ||
| 308 | foreach ($fstart->getElementsByTagName('plist') as $node) { |
308 | foreach ($fstart->getElementsByTagName('plist') as $node) { |
| 309 | $init .= $node->nodeName . "(" .$node->nodeValue . ");" . PHP_EOL; |
309 | $init .= $node->nodeName . "(" .$node->nodeValue . ");" . PHP_EOL; |
| 310 | } |
310 | } |
| 311 | $init .= PHP_EOL . "}" . PHP_EOL ; |
311 | $init .= PHP_EOL . "}" . PHP_EOL ; |
| 312 | 312 | ||
| 313 | 313 | ||
| 314 | $cmd0 = ".L BParticle.cc+". PHP_EOL; |
314 | $cmd0 = ".L BParticle.cc+". PHP_EOL; |
| 315 | $cmd0 .= ".L BEvent.cc+". PHP_EOL; |
315 | $cmd0 .= ".L BEvent.cc+". PHP_EOL; |
| 316 | $cmd0 .= ".L Blab2.cc". PHP_EOL; |
316 | $cmd0 .= ".L Blab2.cc". PHP_EOL; |
| 317 | $cmd0 .= $str. PHP_EOL; |
317 | $cmd0 .= $str. PHP_EOL; |
| 318 | $cmd0 .= $init. PHP_EOL; |
318 | $cmd0 .= $init. PHP_EOL; |
| 319 | $cmd0 .= "Blab2 *blab2 = new Blab2();". PHP_EOL; |
319 | $cmd0 .= "Blab2 *blab2 = new Blab2();". PHP_EOL; |
| 320 | 320 | ||
| 321 | //LONG RUNNING TASK |
321 | //LONG RUNNING TASK |
| 322 | //executeCmd(5, 'ls'); |
322 | //executeCmd(5, 'ls'); |
| 323 | //executeCmd(5, "/home/rok/public_html/blab/blockly/app/runscript.sh"); |
323 | //executeCmd(5, "/home/rok/public_html/blab/blockly/app/runscript.sh"); |
| 324 | //executeCmd(5, 'for ((i=0;i<5;i++)) ; do echo $i; sleep 1; done;'); |
324 | //executeCmd(5, 'for ((i=0;i<5;i++)) ; do echo $i; sleep 1; done;'); |
| 325 | if (file_exists('/opt/root/bin/thisroot.sh')){ |
325 | if (file_exists('/opt/root/bin/thisroot.sh')){ |
| 326 | $profile ='/opt/root/bin/thisroot.sh'; |
326 | $profile ='/opt/root/bin/thisroot.sh'; |
| 327 | } else { |
327 | } else { |
| 328 | $profile ='/home/rok/root/bin/thisroot.sh'; |
328 | $profile ='/home/rok/root/bin/thisroot.sh'; |
| 329 | } |
329 | } |
| 330 | $cmd ="bash -c 'source $profile ;cd src; root -b -l <<EOL" . PHP_EOL; |
330 | $cmd ="bash -c 'source $profile ;cd src; root -b -l <<EOL" . PHP_EOL; |
| 331 | $cmd .= $cmd0. PHP_EOL; |
331 | $cmd .= $cmd0. PHP_EOL; |
| 332 | $cmd .= "EOL'". PHP_EOL; |
332 | $cmd .= "EOL'". PHP_EOL; |
| 333 | 333 | ||
| 334 | send_message(0,$cmd0,0); |
334 | send_message(0,$cmd0,0); |
| 335 | executeCmd($cmd); |
335 | executeCmd($cmd); |
| 336 | send_message('CLOSE', $data,100); |
336 | send_message('CLOSE', $data,100); |
| 337 | ?> |
337 | ?> |
| 338 | 338 | ||