Upstream tarball 10153
[amule.git] / src / utils / amps / index.php
blob1fa2d09b27c9fb09dfaaa9cb1ddb91b370b03a56
1 <?php
3 /**
4 * AMPS - AMule PHP Statistics
5 * Written by überpenguin, AMPS is an adaptation of BigBob's aStats
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // If you want to mess with these settings, do so at your OWN RISK
23 // They are not all fully documented and it may not be obvious to anyone
24 // except myself what they do!
26 define(VERSION, "0.7.6");
27 define(AMULESIGDAT, "/tmp/amulesig.dat");
28 define(IMAGEPATH, "./images");
29 define(IMAGETYPE, "png");
30 define(CLEANSIGIMG, "baseimage.png");
31 define(RUNNINGIMG, "running.png");
32 define(RX0TX0IMG, "rx0tx0.png");
33 define(RX0TX1IMG, "rx0tx1.png");
34 define(RX1TX0IMG, "rx1tx0.png");
35 define(RX1TX1IMG, "rx1tx1.png");
36 define(HIGHIDIMGKADON, "conn_highid_kad_on.png");
37 define(HIGHIDIMGKADOFF, "conn_highid_kad_off.png");
38 define(HIGHIDIMGKADFW, "conn_highid_kad_fw.png");
39 define(LOWIDIMGKADFW, "conn_lowid_kad_fw.png");
40 define(LOWIDIMGKADOFF, "conn_lowid_kad_off.png");
41 define(LOWIDIMGKADON, "conn_lowid_kad_on.png");
42 define(NOCONNIMGKADON, "noconn_kad_on.png");
43 define(NOCONNIMGKADFW, "noconn_kad_fw.png");
44 define(NOCONNIMGKADOFF, "noconn_kad_off.png");
45 define(TIMEGENIMG, "clock.png");
46 define(SERVERIMG, "serverbox.png");
47 define(SHAREDFILESIMG, "files.png");
48 define(QUEUEIMG, "queue.png");
49 define(ERRFONTPADDING, 5);
50 define(FONTSIZE, 9);
51 define(FONTFILE, "./LucidaSansRegular.ttf");
52 define(IMAGETEXTCOLOR, "ffffff");
53 $completelangs = array("ca", "de", "en", "es", "eu", "fr", "fi", "hu", "it",
54 "nl", "pl", "pt", "pt_BR");
55 // end constants
57 // initialize values array
59 $values = array("running"=>false, "psuptime"=>"", "connected"=>"0",
60 "servername"=>"", "serverip"=>"0.0.0.0", "highlowid"=>"", "rxspeed"=>
61 "0.0", "txspeed"=>"0.0", "queuedclients"=>"0", "sharedfiles"=>"0",
62 "nick"=>"", "rxtotal"=>"0.0", "txtotal"=>"0.0", "muleversion"=>"0.0.0"
65 // make sure gd and freetype are loaded; we need them for the signature image
66 if (!extension_loaded("gd"))
68 echo "gd extension missing";
69 exit();
72 if (!in_array("imagettftext", get_extension_funcs("gd")))
74 echo "FreeType extensions missing from gd";
75 exit();
78 // lang can come from two places; as an argument to the script (i.e.
79 // index.php?lang=xx or as an HTTP POST variable. The latter takes prescedence
80 // over the former.
82 if (isset($_GET["lang"]))
83 $lang = $_GET["lang"];
85 if (isset($_POST["lang"]))
86 $lang = $_POST["lang"];
88 if (isset($lang))
90 $temp = @fopen("./langs/".$lang.".inc", "r");
91 if (!$temp)
93 $lang = strtolower($lang);
94 $temp = @fopen("./langs/".$lang.".inc", "r");
97 if (!$temp)
99 require("./langs/en.inc");
101 else
103 require("./langs/".$lang.".inc");
104 fclose($temp);
107 else
109 $lang = "en";
110 require("./langs/en.inc");
113 // if the variable $sig_image is set, only output the signature image
115 if (isset($_GET["sig_image"]))
117 $ret = get_stats();
118 if (!$ret)
119 output_error_img($text["sigfileerr"]." (".AMULESIGDAT.
120 ")");
121 else
122 output_sig_image();
124 exit();
128 * Retrieves the statistics, of course! First checks to see if the process is
129 * actually running. If not, the function returns true without attempting to
130 * read the aMule signature file. If the process IS running, the function reads
131 * the appropriate data from the aMule signiture file, stores them in the
132 * associative array $values and returns true on success, and false if there
133 * is a failure reading the signature file.
136 function get_stats()
138 global $values, $text;
140 // the ps command should output something like 1-05:23:45, in
141 // days-hours:minutes:seconds format.
143 // alternative ps command; doesn't work on *BSD!
144 // $values["psuptime"] = trim(exec("ps --no-header -C amule -o etime"));
146 $values["psuptime"] = trim(exec("ps ax -o etime,comm --no-header | ".
147 "awk '/amule$/ {print $1}' | head -n 1"));
149 if (!$values["psuptime"])
151 $values["running"] = false;
152 return true;
154 else
156 $values["running"] = true;
158 // Uncomment to test etime parser...
159 // $values["psuptime"] = "3442-12:34:55";
160 if (strlen($values["psuptime"]) >= 5)
161 $uptimestr = substr($values["psuptime"], -5, 2).
162 $text["minabbr"]." ".substr($values["psuptime"],
163 -2).$text["secabbr"];
164 if (strlen($values["psuptime"]) >= 8)
165 $uptimestr = substr($values["psuptime"], -8, 2).
166 $text["hourabbr"]." ".$uptimestr;
167 if (strlen($values["psuptime"]) >= 10)
168 $uptimestr = substr($values["psuptime"], 0, strlen(
169 $values["psuptime"]) - 9).$text["dayabbr"]." ".
170 $uptimestr;
172 $values["psuptime"] = $uptimestr;
174 $sigfile = @fopen(AMULESIGDAT, "r");
176 if (!$sigfile)
177 return false;
178 else
180 $values["connected"] = trim(fgets($sigfile));
181 $values["servername"] = trim(fgets($sigfile));
182 $values["serverip"] = trim(fgets($sigfile));
183 $values["serverport"] = trim(fgets($sigfile));
184 $values["highlowid"] = trim(fgets($sigfile));
185 $values["kad"] = trim(fgets($sigfile));
186 $values["rxspeed"] = trim(fgets($sigfile));
187 $values["txspeed"] = trim(fgets($sigfile));
188 $values["queuedclients"] = trim(fgets($sigfile));
189 $values["sharedfiles"] = trim(fgets($sigfile));
190 $values["nick"] = trim(fgets($sigfile));
191 $values["rxtotal"] = trim(fgets($sigfile));
192 $values["txtotal"] = trim(fgets($sigfile));
193 $values["muleversion"] = trim(fgets($sigfile));
194 fclose($sigfile);
196 return true;
202 * This function creates the signiture image and writes out in JPEG format (may
203 * change this to PNG or add an option for image time in the future). The
204 * function assumes get_stats() has already been called and will use whatever
205 * values are in the $values array.
208 function output_sig_image()
210 global $values, $text;
212 // open the base image for writing on. If unsuccessful, exit with an
213 // error image.
215 $finalimg = @imagecreatefrompng(IMAGEPATH."/".CLEANSIGIMG);
217 if (!$finalimg)
219 output_error_img($text["baseimgerr"]);
220 exit();
223 // open up all the icons
225 $runningimg = @imagecreatefrompng(IMAGEPATH."/".RUNNINGIMG);
226 $sharedfilesimg = @imagecreatefrompng(IMAGEPATH."/".SHAREDFILESIMG);
227 $serverimg = @imagecreatefrompng(IMAGEPATH."/".SERVERIMG);
228 $queueimg = @imagecreatefrompng(IMAGEPATH."/".QUEUEIMG);
229 $timegenimg = @imagecreatefrompng(IMAGEPATH."/".TIMEGENIMG);
231 if($values["kad"] == "2") {
232 if ($values["highlowid"] == "H" && $values["connected"] == "1")
233 $idimg = @imagecreatefrompng(IMAGEPATH."/".HIGHIDIMGKADON);
234 else if ($values["highlowid"] == "L" && $values["connected"] == "1")
235 $idimg = @imagecreatefrompng(IMAGEPATH."/".LOWIDIMGKADON);
236 else
237 $idimg = @imagecreatefrompng(IMAGEPATH."/".NOCONNIMGKADON);
238 } else if ($values["kad"] == "1") {
239 if ($values["highlowid"] == "H" && $values["connected"] == "1")
240 $idimg = @imagecreatefrompng(IMAGEPATH."/".HIGHIDIMGKADFW);
241 else if ($values["highlowid"] == "L" && $values["connected"] == "1")
242 $idimg = @imagecreatefrompng(IMAGEPATH."/".LOWIDIMGKADFW);
243 else
244 $idimg = @imagecreatefrompng(IMAGEPATH."/".NOCONNIMGKADFW);
245 } else {
246 if ($values["highlowid"] == "H" && $values["connected"] == "1")
247 $idimg = @imagecreatefrompng(IMAGEPATH."/".HIGHIDIMGKADOFF);
248 else if ($values["highlowid"] == "L" && $values["connected"] == "1")
249 $idimg = @imagecreatefrompng(IMAGEPATH."/".LOWIDIMGKADOFF);
250 else
251 $idimg = @imagecreatefrompng(IMAGEPATH."/".NOCONNIMGKADOFF);
254 if (($values["rxspeed"] == "0.0" && $values["txspeed"] == "0.0") ||
255 !$values["running"])
256 $speedimg = @imagecreatefrompng(IMAGEPATH."/".RX0TX0IMG);
257 else if ($values["rxspeed"] == "0.0" && $values["txspeed"] != "0.0")
258 $speedimg = @imagecreatefrompng(IMAGEPATH."/".RX0TX1IMG);
259 else if ($values["rxspeed"] != "0.0" && $values["txspeed"] == "0.0")
260 $speedimg = @imagecreatefrompng(IMAGEPATH."/".RX1TX0IMG);
261 else if ($values["rxspeed"] != "0.0" && $values["txspeed"] != "0.0")
262 $speedimg = @imagecreatefrompng(IMAGEPATH."/".RX1TX1IMG);
264 // check to make sure all the icons were successfully opened. If not,
265 // output an image containing the appropriate error message and exit
266 // the script here.
268 if (! ($runningimg && $sharedfilesimg && $serverimg && $queueimg &&
269 $timegenimg && $idimg && $speedimg))
271 output_error_img($text["iconerr"]);
272 exit();
275 // place the icons onto the base image
277 imagecopy($finalimg, $runningimg, 5, 5, 0, 0, imagesx($runningimg) - 1,
278 imagesy($runningimg) - 1);
279 imagecopy($finalimg, $sharedfilesimg, 249, 71, 0, 0,
280 imagesy($sharedfilesimg) - 1, imagesy($sharedfilesimg) - 1);
281 imagecopy($finalimg, $idimg, 5, 27, 0, 0, imagesx($idimg) - 1,
282 imagesy($idimg) - 1);
283 imagecopy($finalimg, $serverimg, 5, 49, 0, 0, imagesx($serverimg) - 1,
284 imagesy($serverimg) - 1);
285 imagecopy($finalimg, $speedimg, 5, 71, 0, 0, imagesx($speedimg) - 1,
286 imagesy($speedimg) - 1);
287 imagecopy($finalimg, $queueimg, 249, 93, 0, 0, imagesx($queueimg) - 1,
288 imagesy($queueimg) - 1);
289 imagecopy($finalimg, $timegenimg, 5, 93, 0, 0, imagesx($timegenimg) -
290 1, imagesy($timegenimg) - 1);
292 // allocate white for the text color
294 sscanf(IMAGETEXTCOLOR, "%2x%2x%2x", $red, $green, $blue);
295 $fgcolor = imagecolorallocate($finalimg, $red, $green, $blue);
297 // aMule version and process status
299 if ($values["running"])
300 imagettftext($finalimg, FONTSIZE, 0, 26, 19, $fgcolor,
301 FONTFILE, "aMule ".$values["muleversion"].
302 " ".$text["runtimemsg"]." ".$values["psuptime"]);
303 else
304 imagettftext($finalimg, FONTSIZE, 0, 26, 19, $fgcolor,
305 FONTFILE, "aMule ".$text["norunmsg"]);
307 // connection status and nickname
309 if($values["kad"] == "2")
311 if ($values["running"] && $values["connected"] == "2")
312 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
313 "aMule ".$text["connmsg"]." ".$text["kadonmsg"]);
314 else if ($values["running"] && $values["connected"] != "0" &&
315 $values["highlowid"] == "H")
316 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
317 $values["nick"]." ".$text["highidmsg"]." ".$text["kadonmsg"]);
318 else if ($values["running"] && $values["connected"] != "0" &&
319 $values["highlowid"] != "H")
320 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
321 $values["nick"]." ".$text["lowidmsg"]." ".$text["kadonmsg"]);
322 else if ($values["running"] && $values["connected"] == "0")
323 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
324 $values["nick"]." ".$text["offrunmsg"]." ".
325 $text["amulenorun"]." ".$text["kadonmsg"]);
326 else
327 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
328 $text["offline"]." ".$text["amulenorun"]);
329 } else if($values["kad"] == "1")
331 if ($values["running"] && $values["connected"] == "2")
332 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
333 "aMule ".$text["connmsg"]." ".$text["kadfwmsg"]);
334 else if ($values["running"] && $values["connected"] != "0" &&
335 $values["highlowid"] == "H")
336 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
337 $values["nick"]." ".$text["highidmsg"]." ".$text["kadfwmsg"]);
338 else if ($values["running"] && $values["connected"] != "0" &&
339 $values["highlowid"] != "H")
340 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
341 $values["nick"]." ".$text["lowidmsg"]." ".$text["kadfwmsg"]);
342 else if ($values["running"] && $values["connected"] == "0")
343 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
344 $values["nick"]." ".$text["offrunmsg"]." ".
345 $text["amulenorun"]." ".$text["kadfwmsg"]);
346 else
347 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
348 $text["offline"]." ".$text["amulenorun"]);
349 } else {
350 if ($values["running"] && $values["connected"] == "2")
351 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
352 "aMule ".$text["connmsg"]." ".$text["kadoffmsg"]);
353 else if ($values["running"] && $values["connected"] != "0" &&
354 $values["highlowid"] == "H")
355 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
356 $values["nick"]." ".$text["highidmsg"]." ".$text["kadoffmsg"]);
357 else if ($values["running"] && $values["connected"] != "0" &&
358 $values["highlowid"] != "H")
359 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
360 $values["nick"]." ".$text["lowidmsg"]." ".$text["kadoffmsg"]);
361 else if ($values["running"] && $values["connected"] == "0")
362 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
363 $values["nick"]." ".$text["offrunmsg"]." ".
364 $text["amulenorun"]." ".$text["kadoffmsg"]);
365 else
366 imagettftext($finalimg, FONTSIZE, 0, 25, 41, $fgcolor, FONTFILE,
367 $text["offline"]." ".$text["amulenorun"]);
372 // shared files
374 if ($values["running"] && $values["connected"] == "1")
375 imagettftext($finalimg, FONTSIZE, 0, 270, 85, $fgcolor,
376 FONTFILE, $text["sharedfiles"].": ".
377 $values["sharedfiles"]);
378 else
379 imagettftext($finalimg, FONTSIZE, 0, 270, 85, $fgcolor,
380 FONTFILE, $text["sharedfiles"].": ".$text["na"]);
382 // server name, ip, port
384 if ($values["running"] && $values["connected"] == "1")
385 imagettftext($finalimg, FONTSIZE, 0, 25, 63, $fgcolor, FONTFILE,
386 $values["servername"]." (".$values["serverip"].":".
387 $values["serverport"].")");
388 else
389 imagettftext($finalimg, FONTSIZE, 0, 25, 63, $fgcolor, FONTFILE,
390 $text["na"]);
392 // RX & TX
394 if ($values["running"])
395 imagettftext($finalimg, FONTSIZE, 0, 25, 85, $fgcolor, FONTFILE,
396 $text["rx"].": ".$values["rxspeed"].$text["transrate"].
397 " | ".$text["tx"].": ".$values["txspeed"].
398 $text["transrate"]);
399 else
400 imagettftext($finalimg, FONTSIZE, 0, 25, 85, $fgcolor, FONTFILE,
401 $text["rx"].": ".$text["na"]." | ".$text["tx"].": ".
402 $text["na"]);
404 // queued clients
406 if ($values["running"])
407 imagettftext($finalimg, FONTSIZE, 0, 270, 107, $fgcolor,
408 FONTFILE, $text["queuedclients"].": ".
409 $values["queuedclients"]);
410 else
411 imagettftext($finalimg, FONTSIZE, 0, 270, 107, $fgcolor,
412 FONTFILE, $text["queuedclients"].": ".$text["na"]);
414 // RFC 2822 Datestamp
416 imagettftext($finalimg, FONTSIZE, 0, 25, 107, $fgcolor, FONTFILE,
417 date("r"));
419 // outputs the signature image based on the value of IMAGETYPE. The case
420 // for png and default are the same; in other words, PNG is the default
421 // image output type. Note that your installation of GD has to support
422 // the type of image you are outputting here.
424 switch (IMAGETYPE)
426 case "jpg":
427 case "jpeg":
429 header("Content-type: image/jpeg");
430 imagejpeg($finalimg, "", 100);
432 case "gif":
434 header("Content-type: image/gif");
435 imagegif($finalimg);
437 case "png":
438 default:
440 header("Content-type: image/png");
441 imagepng($finalimg);
447 * This function outputs a simple image containing an error message specified
448 * by the only parameter, $err_message. The image is black text and border on
449 * a white background.
452 function output_error_img($err_message)
454 // determine the size of the text string and add to it the amount of
455 // padding specified earlier.
457 $fontdims = imagettfbbox(FONTSIZE, 0, FONTFILE, $err_message);
459 $min_x = min($fontdims[0], $fontdims[2], $fontdims[4], $fontdims[6]);
460 $max_x = max($fontdims[0], $fontdims[2], $fontdims[4], $fontdims[6]);
461 $min_y = min($fontdims[1], $fontdims[3], $fontdims[5], $fontdims[7]);
462 $max_y = max($fontdims[1], $fontdims[3], $fontdims[5], $fontdims[7]);
464 $width = ($max_x - $min_x) + (2 * ERRFONTPADDING);
465 $height = ($max_y - $min_y) + (2 * ERRFONTPADDING);
467 $img = @imagecreate($width, $height);
469 $bgcolor = imagecolorallocate($img, 255, 255, 255);
470 $fgcolor = imagecolorallocate($img, 0, 0, 0);
471 imagesetthickness($img, 2);
473 // draw the border
475 imagerectangle($img, 1, 1, $width - 2, $height - 2, $fgcolor);
477 // print the text
479 imagettftext($img, FONTSIZE, 0, ERRFONTPADDING, ERRFONTPADDING + 0.5 *
480 $height, $fgcolor, FONTFILE, $err_message);
482 header("Content-type: image/jpeg");
483 imagejpeg($img, "", 100);
487 * Writes the non-dynamic leading part of the HTML that makes up the statistics
488 * page. Right now this is just a stub for future theme support.
491 function write_header()
495 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
497 <html>
498 <head>
499 <title>AMPS - AMule PHP Statistics</title>
500 <link href="./style.css" rel="stylesheet" type="text/css">
501 </head>
502 <body class="thebody">
504 <p align="center">
506 <table class="toplevel">
507 <tr>
508 <td>
510 <?php
515 * Writes the non-dynamic trailing part of the HTML that makes up the statistics
516 * page. Right now this is just a stub for future theme support.
519 function write_footer()
524 </td>
525 </tr>
526 </table>
528 <p align="center">
530 <i>Generated by AMPS version <?php echo VERSION; ?></i><br>
531 <i><a href="http://www.amule-project.net/">http://www.amule-project.net/</a></i><br>
532 <i>&lt;uberpenguin at hotpop dot com&gt;</i>
534 </body>
535 </html>
536 <?php
541 * Write out the stats to the browser. I will probably change this later on
542 * to be themable, but for now I lack the motivation...
545 write_header();
547 $ret = get_stats();
548 if (!$ret)
549 echo $text["sigfileerr"];
550 else
552 // html strings that are used over and over
554 $nastring = "\t\t\t\t\t<td class=\"organize\">".$text["na"].
555 "</td>\n\t\t\t\t</tr>\n";
556 $titlecolstart = "\t\t\t\t<tr>\n\t\t\t\t\t<td class=\"organize\">";
557 $titlecolend = "</td>\n";
558 $datacolstart = "\t\t\t\t\t<td class=\"organize\">";
559 $datacolend = "</td>\n\t\t\t\t</tr>\n";
561 $sectiontablestart = "\t<table class=\"sec\">\n\t\t".
562 "<tr class=\"secheader\">\n\t\t\t<td class=\"secheader\">";
563 $sectiontablenext = "</td>\n\t\t</tr>\n";
564 $sectionend = "\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n\t</table>".
565 "\n\t<p>\n";
566 $innertable = "\t\t<tr class=\"secbody\">\n\t\t\t".
567 "<td class=\"secbody\">\n";
568 $organizetable = "\t\t\t<table class=\"organize\">\n";
570 // title
572 echo "\t<table class=\"sec\">\n\t\t<tr class=\"secheader\">\n\t\t\t".
573 "<td class=\"secheader\"><center><h2>AMPS - ".
574 "AMule PHP Statistics</h2></center></td>\n\t\t</tr>\n\t".
575 "</table>\n\t<p>\n";
577 // first section
579 echo $sectiontablestart.$text["general"].$sectiontablenext;
581 echo $innertable;
582 echo $organizetable;
584 // client info
586 echo $titlecolstart.$text["client"].$titlecolend;
588 if ($values["running"])
589 echo $datacolstart."aMule ".$values["muleversion"]." ".
590 $text["runtimemsg"]." ".$values["psuptime"].$datacolend;
591 else
592 echo $datacolstart."aMule ".$text["norunmsg"].$datacolend;
594 // ed2kstatus
596 echo $titlecolstart.$text["ed2kstatus"].$titlecolend;
598 if ($values["connected"] == "2")
599 echo $datacolstart.$text["connecting"];
600 else if ($values["connected"] == "1")
601 echo $datacolstart.$text["online"];
602 else
603 echo $datacolstart.$text["offline"];
605 if (!$values["running"])
606 echo " ".$text["amulenorun"].$datacolend;
607 else
608 echo $datacolend;
610 // kadstatus
612 echo $titlecolstart.$text["kadstatus"].$titlecolend;
614 if ($values["kad"] == "2")
615 echo $datacolstart.$text["kadon"];
616 else if ($values["kad"] == "1")
617 echo $datacolstart.$text["kadfw"];
618 else
619 echo $datacolstart.$text["kadoff"];
621 if (!$values["running"])
622 echo " ".$text["amulenorun"].$datacolend;
623 else
624 echo $datacolend;
626 // nick
628 echo $titlecolstart.$text["nick"].$titlecolend;
630 if ($values["running"])
631 echo $datacolstart.$values["nick"].$datacolend;
632 else
633 echo $nastring;
635 // RFC 2282 datestamp
637 echo $titlecolstart.$text["localtime"].$titlecolend;
638 echo $datacolstart.date("r").$datacolend;
640 // RX speed
642 echo $titlecolstart.$text["rxspeed"].$titlecolend;
644 if ($values["running"])
645 echo $datacolstart.$values["rxspeed"].$text["transrate"].
646 $datacolend;
647 else
648 echo $nastring;
650 // TX speed
652 echo $titlecolstart.$text["txspeed"].$titlecolend;
654 if ($values["running"])
655 echo $datacolstart.$values["txspeed"].$text["transrate"].
656 $datacolend;
657 else
658 echo $nastring;
660 // queued clients
662 echo $titlecolstart.$text["queuedclients"].$titlecolend;
664 if ($values["running"])
665 echo $datacolstart.$values["queuedclients"].$datacolend;
666 else
667 echo $nastring;
669 // TX total
671 echo $titlecolstart.$text["txtotal"].$titlecolend;
673 if ($values["running"])
674 echo $datacolstart.round($values["txtotal"] / 1073741824, 2).
675 $text["gigabytes"].$datacolend;
676 else
677 echo $nastring;
679 // RX total
681 echo $titlecolstart.$text["rxtotal"].$titlecolend;
683 if ($values["running"])
684 echo $datacolstart.round($values["rxtotal"] / 1073741824, 2).
685 $text["gigabytes"].$datacolend;
686 else
687 echo $nastring;
689 // shared files
691 echo $titlecolstart.$text["sharedfiles"].$titlecolend;
693 if ($values["running"] && $values["connected"] == "1")
694 echo $datacolstart.$values["sharedfiles"].$datacolend;
695 else
696 echo $nastring;
698 // OS identification
700 echo $titlecolstart.$text["osversion"].$titlecolend;
701 echo $datacolstart.exec("uname -sr").$datacolend;
703 // uptime
705 echo $titlecolstart.$text["hostuptime"].$titlecolend;
706 echo $datacolstart.exec("uptime").$datacolend;
708 // break into next section
710 echo $sectionend;
711 echo $sectiontablestart.$text["server"].$sectiontablenext;
712 echo $innertable;
713 echo $organizetable;
715 // server name
717 echo $titlecolstart.$text["servername"].$titlecolend;
719 if ($values["running"] && $values["connected"] == "1")
720 echo $datacolstart.$values["servername"].$datacolend;
721 else
722 echo $nastring;
724 // server IP:port
726 echo $titlecolstart.$text["serveraddr"].$titlecolend;
728 if ($values["running"] && $values["connected"] == "1")
729 echo $datacolstart.$values["serverip"].":".
730 $values["serverport"].$datacolend;
731 else
732 echo $nastring;
734 // ED2K link
736 echo $titlecolstart.$text["ed2klink"].$titlecolend;
738 if ($values["running"] && $values["connected"] == "1")
739 echo $datacolstart."<a href=\"ed2k://".$values["servername"].
740 "|".$values["serverip"]."|".$values["serverport"].
741 "|/\">ed2k://".$values["servername"]."|".
742 $values["serverip"]."|".$values["serverport"].
743 "|/</a>".$datacolend;
744 else
745 echo $nastring;
747 // break into next section
749 echo $sectionend;
750 echo $sectiontablestart.$text["signature"].$sectiontablenext;
751 echo $innertable;
752 echo $organizetable;
754 // signature image
756 global $lang;
758 echo "\t\t\t\t<tr><td><a href=\"".$_SERVER['PHP_SELF']."?lang=".$lang."&sig_image\"><img border=\"0\"".
759 "src=\"".$_SERVER['PHP_SELF']."?lang=".$lang."&sig_image\" alt=\"\"></a></td></tr>\n";
761 // language selection
763 echo $sectionend;
764 echo $sectiontablestart;
766 echo "\n\t\t\t\t<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n\t\t\t\t\t".
767 $text["language"].":&nbsp;&nbsp;<select name=\"lang\">\n";
768 foreach ($completelangs as $langcode)
769 if ($langcode == $lang)
770 echo "\t\t\t\t\t\t<option value=\"".$langcode."\" selected>".$langcode.
771 "</option>\n";
772 else
773 echo "\t\t\t\t\t\t<option value=\"".$langcode."\">".$langcode."</option>\n";
774 echo "\t\t\t\t\t</select>\n\t\t\t\t\t&nbsp;&nbsp;<input type=\"submit\" value=\"".
775 $text["submit"]."\">\n\t\t\t\t</form>\n";
776 echo "\t\t\t</td>\n\t\t</tr>\n\t</table>";
779 write_footer();