Article View: pl.comp.lang.php
Article #220136Re: wykonanie polecenia
From: BaRt
Date: Thu, 03 Sep 2009 21:49
Date: Thu, 03 Sep 2009 21:49
162 lines
5948 bytes
5948 bytes
widzę że zainteresowanie przeogromne
doklepałem coś tam i działa w FF i IE
źródełko dla potomnych :-)
<?php
//Moduł do pingowania adresów
$action = $_GET['action'];
//generowanie strony www
if (!$action) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv="Content-Language" content="pl">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-2">
<title>::: LMS : Opowiedź ping z adresu: <?php echo $_GET['ip']; ?
> :::</title>
<link href="../img/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript" src="../img/
common.js"> </script>
<script language="JavaScript" type="text/JavaScript" src="../img/
ClickShowHideMenu.js"> </script>
<script type="text/javascript">
<!--
//wartości początkowe do zliczania min/sred/max
P = new Array();
P.min = new Number(0);
P.avg = new Number(0);
P.max = new Number(0);
P.rec = new Number(0);
P.count = new Number(0);
//funkcja inicjująca
function httpGetObject() {
this.onrecv = null;
this.get = function(ip) {
var getScript = document.createElement('script')
with (getScript) {
setAttribute('id', 'ping');
setAttribute('type', 'text/javascript');
setAttribute('src', 'ping.php?ip=' + ip + '&action=ping' + '&cache='
+ P.count);
};
document.getElementsByTagName('head').item(0).appendChild
(getScript);
};
};
window.hgObj = new httpGetObject()
hgObj.onrecv = function(ip,str) {
//usuwanie nadmiernych wierszy
var tableRef = document.getElementById('tabela');
if (tableRef.getElementsByTagName('TR').length > 15) {
tableRef.deleteRow(14);
};
//dodawanie nowych wyników
var newRow = tableRef.insertRow(1);
var C = newRow.insertCell(0);
C.setAttribute((document.all ? 'className' : 'class'), 'FRIGHT');
var C = newRow.insertCell(0);
C.setAttribute('WIDTH', '20%');
C.innerHTML = str;
var C = newRow.insertCell(0);
C.setAttribute('WIDTH', '80%');
if (str == '---') {
C.style.cssText = 'color:red;';
C.innerHTML = ' Brak odpowiedzi ';
} else {
C.innerHTML = ' Odpowiedź otrzymano po upływie: ';
};
var C = newRow.insertCell(0);
C.setAttribute((document.all ? 'className' : 'class'), 'FLEFT');
//Zliczanie itp.
P.count++;
if (str != '---') {
P.rec++;
P.avg = P.avg + Number(str);
if ((P.min > Number(str)) || (P.min == 0)) P.min = str;
if (P.max < Number(str)) P.max = str;
var avg = new String(P.avg/P.rec);
document.getElementById('msm').innerHTML = P.min + ' / ' +
avg.substring(0,avg.indexOf('.') + 4) + ' / ' + P.max;
};
document.getElementById('count').innerHTML = P.rec + ' / ' +
P.count;
if (P.rec != P.count) document.getElementById
('count').style.cssText = 'width:20%; text-align:center; float:right;
color:red;';
//usuwanie starewgo skryptu
setTimeout(function(){document.getElementsByTagName('head').item
(0).removeChild(document.getElementById("ping"));}, 1);
//petla
setTimeout(function(){hgObj.get(ip);},1000);
};
//-->
</script>
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"
bgcolor="#EBE4D6" link="#800000" vlink="#800000" alink="#336600"
onLoad="hgObj.get('<?php echo $_GET['ip']; ?>');">
<center>
</br></br>
<TABLE WIDTH="400 px" CELLPADDING="3" ID="tabela" ><TBODY>
<TR CLASS="DARK">
<TD WIDTH="1%" CLASS="FLEFTU">
<IMG SRC="../img/node.gif" BORDER="0">
</TD>
<TD WIDTH="98%" CLASS="FRIGHTU" COLSPAN="3">
<B style="float:left;">Opowiedź ping z adresu: <?php echo $_GET
['ip']; ?></B>
<A HREF="javascript:window.close()" style="float:right; font-
weight:bold; margin-right:5px; border=1px;">X</A>
</TD>
</TR>
<TR CLASS="LIGHT">
<TD WIDTH="99%" COLSPAN="3" CLASS="FLEFTU">
<div ID="msm" style="width:80%; text-align:center; float:left;">0 /
0 / 0</div>
<div ID="count" valign="top" style="width:20%; text-align:center;
float:right;">0 / 0</div>
</TD>
<TD WIDTH="1%" CLASS="FRIGHTU" NOWRAP VALIGN="BOTTOM" ALIGN="RIGHT"
></TD>
</TR>
</TBODY></TABLE>
</center>
</body>
</html>
<?php
};
// funkcja pingująca
if ($action == "ping") {
$addres_to_ping = $_GET['ip'];
$ping = exec("ping " . $addres_to_ping . " -c 1");
if ($ping == "") {
echo "hgObj.onrecv('" . $addres_to_ping . "', '---')";
} else {
preg_match("/rtt min\/avg\/max\/mdev = (.*)\/(.*)\/(.*)\/(.*)
ms/", $ping, $ping);
echo "hgObj.onrecv('" . $addres_to_ping . "', '" . $ping[2] . "')";
};
};
?>
Technical Details
Message-ID:
<cf620e88-ef63-4207-9bb0-27251969a49b@r9g2000yqa.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!r9g2000yqa.googlegroups.com!not-for-mailReferences:
<4a828081$1@news.home.net.pl> <h5u14d$hse$1@atlantis.news.neostrada.pl> <c174991e-0bc1-48c8-9350-bdd9a75a9aa9@o32g2000yqm.googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!r9g2000yqa.googlegroups.com!not-for-mail From: BaRt <bartek.gut@gmail.com> Newsgroups: pl.comp.lang.php Subject: Re: wykonanie polecenia Date: Thu, 3 Sep 2009 14:49:44 -0700 (PDT) Organization: http://groups.google.com Lines: 164 Message-ID: <cf620e88-ef63-4207-9bb0-27251969a49b@r9g2000yqa.googlegroups.com> References: <4a828081$1@news.home.net.pl> <h5u14d$hse$1@atlantis.news.neostrada.pl> <c174991e-0bc1-48c8-9350-bdd9a75a9aa9@o32g2000yqm.googlegroups.com> NNTP-Posting-Host: 91.150.162.70 Mime-Version: 1.0 X-Trace: posting.google.com 1252014584 26236 127.0.0.1 (3 Sep 2009 21:49:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 3 Sep 2009 21:49:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r9g2000yqa.googlegroups.com; posting-host=91.150.162.70; posting-account=nxWwPwoAAABPzItNkSMhA1vd-XyDMb_x User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2,gzip(gfe),gzip(gfe) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit