Hi,
I am writing a PHP script to get a ping reply from my LAN PC. So, my idea is like this, when i mouseover/mouse click to the "hostname" display on the web. There will be a hint box appear and show me the ping result. Below is the php function to perform exec:
[CODE=php]
function getdetail($user 1)
{
$auser=$user1;
exec("ping $auser", $coutput);
foreach ($coutput as $line) {
echo $line."<br />";
}
}
[/CODE]
Below is the hint box javascript from dynamicdrive.co m:
[CODE=javascript]
<script type="text/javascript">
/*************** *************** *************** **
* Show Hint script- ? Dynamic Drive (www.dynamicdri ve.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdriv e.com/ for this script and 100s more.
*************** *************** *************** **/
var horizontal_offs et="9px" //horizontal offset of hint box from anchor link
/////No further editting needed
var vertical_offset ="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.ge tElementById&&! document.all
function getposOffset(wh at, offsettype){
var totaloffset=(of fsettype=="left ")? what.offsetLeft : what.offsetTop;
var parentEl=what.o ffsetParent;
while (parentEl!=null ){
totaloffset=(of fsettype=="left ")? totaloffset+par entEl.offsetLef t : totaloffset+par entEl.offsetTop ;
parentEl=parent El.offsetParent ;
}
return totaloffset;
}
function iecompattest(){
return (document.compa tMode && document.compat Mode!="BackComp at")? document.docume ntElement : document.body
}
function clearbrowseredg e(obj, whichedge){
var edgeoffset=(whi chedge=="righte dge")? parseInt(horizo ntal_offset)*-1 : parseInt(vertic al_offset)*-1
if (whichedge=="ri ghtedge"){
var windowedge=ie && !window.opera? iecompattest(). scrollLeft+ieco mpattest().clie ntWidth-30 : window.pageXOff set+window.inne rWidth-40
dropmenuobj.con tentmeasure=dro pmenuobj.offset Width
if (windowedge-dropmenuobj.x < dropmenuobj.con tentmeasure)
edgeoffset=drop menuobj.content measure+obj.off setWidth+parseI nt(horizontal_o ffset)
}
else{
var windowedge=ie && !window.opera? iecompattest(). scrollTop+iecom pattest().clien tHeight-15 : window.pageYOff set+window.inne rHeight-18
dropmenuobj.con tentmeasure=dro pmenuobj.offset Height
if (windowedge-dropmenuobj.y < dropmenuobj.con tentmeasure)
edgeoffset=drop menuobj.content measure-obj.offsetHeigh t
}
return edgeoffset
}
function showhint(menuco ntents, obj, e, tipwidth){
if ((ie||ns6) && document.getEle mentById("hintb ox")){
dropmenuobj=doc ument.getElemen tById("hintbox" )
dropmenuobj.inn erHTML=menucont ents
dropmenuobj.sty le.left=dropmen uobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.wid thobj=dropmenuo bj.style
dropmenuobj.wid thobj.width=tip width
}
dropmenuobj.x=g etposOffset(obj , "left")
dropmenuobj.y=g etposOffset(obj , "top")
dropmenuobj.sty le.left=dropmen uobj.x-clearbrowseredg e(obj, "rightedge")+ob j.offsetWidth+" px"
dropmenuobj.sty le.top=dropmenu obj.y-clearbrowseredg e(obj, "bottomedge")+" px"
dropmenuobj.sty le.visibility=" visible"
obj.onmouseout= hidetip
}
}
function hidetip(e){
dropmenuobj.sty le.visibility=" hidden"
dropmenuobj.sty le.left="-500px"
}
function createhintbox() {
var divblock=docume nt.createElemen t("div")
divblock.setAtt ribute("id", "hintbox")
document.body.a ppendChild(divb lock)
}
if (window.addEven tListener)
window.addEvent Listener("load" , createhintbox, false)
else if (window.attachE vent)
window.attachEv ent("onload", createhintbox)
else if (document.getEl ementById)
window.onload=c reatehintbox
/* get id from <a> */
function getValue()
{
var x=document.getE lementById("com puter1").id
document.write( x)
}
</script>
[/CODE]
finally, the host display:
[CODE=html]
<a href="#" id="computer1" onclick="showhi nt('<? getdetail(?>get Value()<?); ?>', this, event, '200px')">tiwli m</a>
[/CODE]
May i know why the final code above is not working? How do i get value from javascript -> php?
Thanks!
I am writing a PHP script to get a ping reply from my LAN PC. So, my idea is like this, when i mouseover/mouse click to the "hostname" display on the web. There will be a hint box appear and show me the ping result. Below is the php function to perform exec:
[CODE=php]
function getdetail($user 1)
{
$auser=$user1;
exec("ping $auser", $coutput);
foreach ($coutput as $line) {
echo $line."<br />";
}
}
[/CODE]
Below is the hint box javascript from dynamicdrive.co m:
[CODE=javascript]
<script type="text/javascript">
/*************** *************** *************** **
* Show Hint script- ? Dynamic Drive (www.dynamicdri ve.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdriv e.com/ for this script and 100s more.
*************** *************** *************** **/
var horizontal_offs et="9px" //horizontal offset of hint box from anchor link
/////No further editting needed
var vertical_offset ="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.ge tElementById&&! document.all
function getposOffset(wh at, offsettype){
var totaloffset=(of fsettype=="left ")? what.offsetLeft : what.offsetTop;
var parentEl=what.o ffsetParent;
while (parentEl!=null ){
totaloffset=(of fsettype=="left ")? totaloffset+par entEl.offsetLef t : totaloffset+par entEl.offsetTop ;
parentEl=parent El.offsetParent ;
}
return totaloffset;
}
function iecompattest(){
return (document.compa tMode && document.compat Mode!="BackComp at")? document.docume ntElement : document.body
}
function clearbrowseredg e(obj, whichedge){
var edgeoffset=(whi chedge=="righte dge")? parseInt(horizo ntal_offset)*-1 : parseInt(vertic al_offset)*-1
if (whichedge=="ri ghtedge"){
var windowedge=ie && !window.opera? iecompattest(). scrollLeft+ieco mpattest().clie ntWidth-30 : window.pageXOff set+window.inne rWidth-40
dropmenuobj.con tentmeasure=dro pmenuobj.offset Width
if (windowedge-dropmenuobj.x < dropmenuobj.con tentmeasure)
edgeoffset=drop menuobj.content measure+obj.off setWidth+parseI nt(horizontal_o ffset)
}
else{
var windowedge=ie && !window.opera? iecompattest(). scrollTop+iecom pattest().clien tHeight-15 : window.pageYOff set+window.inne rHeight-18
dropmenuobj.con tentmeasure=dro pmenuobj.offset Height
if (windowedge-dropmenuobj.y < dropmenuobj.con tentmeasure)
edgeoffset=drop menuobj.content measure-obj.offsetHeigh t
}
return edgeoffset
}
function showhint(menuco ntents, obj, e, tipwidth){
if ((ie||ns6) && document.getEle mentById("hintb ox")){
dropmenuobj=doc ument.getElemen tById("hintbox" )
dropmenuobj.inn erHTML=menucont ents
dropmenuobj.sty le.left=dropmen uobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.wid thobj=dropmenuo bj.style
dropmenuobj.wid thobj.width=tip width
}
dropmenuobj.x=g etposOffset(obj , "left")
dropmenuobj.y=g etposOffset(obj , "top")
dropmenuobj.sty le.left=dropmen uobj.x-clearbrowseredg e(obj, "rightedge")+ob j.offsetWidth+" px"
dropmenuobj.sty le.top=dropmenu obj.y-clearbrowseredg e(obj, "bottomedge")+" px"
dropmenuobj.sty le.visibility=" visible"
obj.onmouseout= hidetip
}
}
function hidetip(e){
dropmenuobj.sty le.visibility=" hidden"
dropmenuobj.sty le.left="-500px"
}
function createhintbox() {
var divblock=docume nt.createElemen t("div")
divblock.setAtt ribute("id", "hintbox")
document.body.a ppendChild(divb lock)
}
if (window.addEven tListener)
window.addEvent Listener("load" , createhintbox, false)
else if (window.attachE vent)
window.attachEv ent("onload", createhintbox)
else if (document.getEl ementById)
window.onload=c reatehintbox
/* get id from <a> */
function getValue()
{
var x=document.getE lementById("com puter1").id
document.write( x)
}
</script>
[/CODE]
finally, the host display:
[CODE=html]
<a href="#" id="computer1" onclick="showhi nt('<? getdetail(?>get Value()<?); ?>', this, event, '200px')">tiwli m</a>
[/CODE]
May i know why the final code above is not working? How do i get value from javascript -> php?
Thanks!
Comment