{"id":844,"date":"2009-06-27T08:47:36","date_gmt":"2009-06-27T00:47:36","guid":{"rendered":"https:\/\/www.dremi.info\/?p=844"},"modified":"2009-06-27T08:47:36","modified_gmt":"2009-06-27T00:47:36","slug":"creating-auto-checker-for-ip-network-lifetime","status":"publish","type":"post","link":"https:\/\/www.dremi.info\/tutorials\/jquery\/creating-auto-checker-for-ip-network-lifetime.html","title":{"rendered":"Creating Auto Checker for IP Network Lifetime"},"content":{"rendered":"

\"\"Hi! I have a tutorial to check lifetime connectivity for IP and PORT in your Network. You may use it as component of enterpise application to check IP and PORT.
\nSo, what next ???
\n<\/p>\n

 <\/div>\n

Offcourse, we need this files: ipchecker.php, frame_ip.php, index.php, and jquery framework.
\nFirst create ipchecker.php for function handler:
\nCode:<\/p>\n

\n&lt;?\n\/**\n#\n# Auto Checker for IP Network Lifetime\n# Author  hairul azami a.k.a dr.emi &lt;webmaster@dremi.info&gt;\n# Website http:\/\/dremi.info\n# License: GPL\n#\n**\/\nerror_reporting(0);\ndefine(&quot;_IMAGES&quot;, &quot;images\/&quot;);\ndefine(&quot;_IPROUTER&quot;, &quot;192.168.1.1&quot;);\nfunction checkIP($ip, $p)\n{\n\/\/error_reporting(E_ALL);\n@set_time_limit(0);\n$address = &quot;$ip&quot;; \/\/your public IP\n$port = $p; \/\/ your IP open port\n$fp = @fsockopen($address,$port,$errno,$errstr,10);\nstream_set_timeout($fp, 1);\nif ($fp)\n{\n$statusIPport =  &quot;&lt;font color=green&gt;Connected&lt;\/font&gt;&quot;;\n$imgTitle = &quot;Connected&quot;;\n$imgStats = &quot;accepted_32.png&quot;;\n}\nelse\n{\n$statusIPport =  &quot;&lt;font color=#CCCCCC&gt;Disconnect&lt;\/font&gt;&quot;;\n$imgTitle = &quot;Disconnect&quot;;\n$imgStats = &quot;warning_32.png&quot;;\n}\n$info = stream_get_meta_data($fp);\nif($info['timed_out'])\n{\n$statusIPport =  &quot;&lt;font color=#CCCCCC&gt;Time Out&lt;\/font&gt;&quot;;\n$imgTitle = &quot;Time Out&quot;;\n$imgStats = &quot;cancel_32.png&quot;;\n}\nflush();\n$checkID = strtoupper(gethostbyaddr($address));\nif($checkID != $address)\n{\n$comname = $checkID;\n}\nelseif($checkID == _IPROUTER)\n{\n$comname = &quot;ROUTER&quot;;\n}\nelse\n{\n$comname = &quot;NONAME&quot;;\n}\necho &quot;\n&lt;div style='text-align:center;'&gt;\n&lt;img src='&quot;._IMAGES . $imgStats.&quot;' alt='$imgTitle' title='$imgTitle' border=0&gt;&lt;br&gt;\n&lt;strong&gt;$imgTitle&lt;\/strong&gt;&lt;br&gt;\n$address:$port&lt;br&gt;\n$comname\n&lt;\/dvi&gt;&quot;;\n}\ncheckIP($_GET['ip'], $_GET['port']);\n?&gt;\n<\/pre>\n

The function will used as checker for each of variable IP and PORT
\nSecond, create an jQuery Auto Load for file, called as frame_ip.php
\nIn this file, you must load jQuery framework to complete javascript function bellow
\nCode:<\/p>\n

\n&lt;script language=&quot;javascript&quot; src=&quot;jquery-1.2.6.min.js&quot;&gt;&lt;\/script&gt;\n&lt;script language=&quot;javascript&quot;&gt;\n\/\/show animation\n$(function(){\n$(&quot;#ajax_display&quot;).ajaxStart(function(){\n$(this).html('&lt;div style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;images\/ajax-loader-trans.gif&quot;\/&gt;&lt;br&gt;Checking Target...&lt;\/div&gt;');\n});\n$(&quot;#ajax_display&quot;).ajaxSuccess(function(){\n$(this).html('');\n});\n$(&quot;#ajax_display&quot;).ajaxError(function(url){\nalert('jqSajax is error ');\n});\n});\n&lt;\/script&gt;\n<\/pre>\n

Then to load ipchecker.php, I use this code:<\/p>\n

\n&lt;div id=&quot;ajax_display&quot;&gt;&lt;\/div&gt;\n&lt;script type=&quot;text\/javascript&quot;&gt;\nfunction getRandom() {\n$(&quot;#random&quot;).hide(&quot;slow&quot;);\n$(&quot;#random&quot;).load(&quot;ipchecker.php?ip=&lt;? echo $_GET['ip']; ?&gt;&amp;port=&lt;? echo $_GET['port']; ?&gt;&quot;, '', callback);\n}\nfunction callback() {\n$(&quot;#random&quot;).show(&quot;slow&quot;);\nsetTimeout(&quot;getRandom();&quot;, 10000*2);\n}\n$(document).ready(getRandom);\n&lt;\/script&gt;\n&lt;div id=&quot;random&quot;&gt;&lt;\/div&gt;\n<\/pre>\n

While ip and port was defined in iframe URL, PHP function checkIP($ip, $p) will work.
\nI use this line for set the time while load ipchecker.php from first time to next load progress.<\/p>\n

setTimeout(&quot;getRandom();&quot;, 10000*2);<\/pre>\n

The last is index.php
\nThis file will give you GUI of all process<\/p>\n

\n&lt;?\nfor($i=1;$i&lt;=10;$i++)\n{\n?&gt;\n&lt;div id=&quot;ipslot&quot;&gt;\n&lt;iframe scrolling=&quot;No&quot; frameborder=&quot;0&quot; class=&quot;frameloader&quot; width=&quot;100px&quot; height=&quot;100px&quot; name=&quot;ajax_ipchecker&quot; src=&quot;frame_ip.php?ip=192.168.1.&lt;? echo $i; ?&gt;&amp;port=80&quot;&gt;\n&lt;\/iframe&gt;\n&lt;\/div&gt;\n&lt;?\n}\n?&gt;\n<\/pre>\n

While index.php loaded, frame_ip.php will work as “data sender” from URL, so we can check it in checkIP function.
\nWell this is screenshoot while you access index.php from http:\/\/localhost\/[foldername]\/index.php<\/p>\n

\"\"<\/div>\n

OK, I think it’s really good time to see you here, thanks for read \ud83d\ude42
\nIf you find any bug \/ report, just comment here ..<\/p>\n

Share on Facebook<\/a><\/p>","protected":false},"excerpt":{"rendered":"

Hi! I have a tutorial to check lifetime connectivity for IP and PORT in your Network. You may use it as component of enterpise application to check IP and PORT. So, what next ??? Share on Facebook<\/p>\n

Share on Facebook<\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,20],"tags":[99,135,210],"_links":{"self":[{"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/posts\/844"}],"collection":[{"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/comments?post=844"}],"version-history":[{"count":0,"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dremi.info\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}