From 70074ab15ca42e27f11046639ef083cd08543c06 Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Tue, 4 Sep 2012 13:51:53 +0000 Subject: [PATCH] adding upnp next step, not finished yet, almost ;) --- bureau/admin/main.php | 11 +++----- upnp/m_upnp.php | 61 +++++++++++++++++++++++++++++++++++++++++++ upnp/update_upnp.sh | 2 +- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/bureau/admin/main.php b/bureau/admin/main.php index 266bee26..6f14ad7b 100644 --- a/bureau/admin/main.php +++ b/bureau/admin/main.php @@ -1,13 +1,9 @@ query("SELECT UNIX_TIMESTAMP(lastcheck) AS lc, * FROM upnp ORDER BY lastcheck ASC;"); + $forwards=array(); + $bigcheck=false; + if (!$db->next_record()) { + $bigcheck=true; + } else { + if ($db->f("lc")+600Record["found"]=false; + $forwards[]=$db->Record; + } while ($db->next_record()); + } + + if ($bigcheck) { + // Do the check first by calling the hooks & comparing the arrays + $res=$hooks->invoke("hooks_upnp_list"); + foreach($res as $c=>$tmp) { + foreach($tmp as $name=>$v) { + + // We compare the hook array with the forwards array + $found=false; + for($i=0;$iquery("INSERT INTO upnp SET mandatory='".addslashes($v["mandatory"])."', protocol='".addslashes($v["protocol"])."', port='".addslashes($v["port"])."', name='".addslashes($name)."', action='CREATE'"); + $id=$db->last_id(); + $forwards[]=array("id"=>$id, "mandatory" => intval($v["mandatory"]), "protocol" => $v["protocol"], "port" => intval($v["port"]), "name" => $name, "action" => "CREATE"); + } + } // for each port forward in that class + } // for each hooked class + // We search the "not found" and remove them from the array + for($i=0;$iquery("UPDATE upnp SET action='DELETING' WHERE id=".$forwards[$i]["id"].";"); + } + } + + + } // bigcheck ? + } + + diff --git a/upnp/update_upnp.sh b/upnp/update_upnp.sh index a3ba022d..ab842684 100644 --- a/upnp/update_upnp.sh +++ b/upnp/update_upnp.sh @@ -1,5 +1,5 @@ #!/usr/bin/php -