Hier einmal ein Script zur Darstellung und Kontrolle eines Routers mit dd-wrt Firmware. ( dazu hier: Infos zum flashen usw. www.dd-wrt.com | Unleash Your Router )
Bei mir läuft die „mini“ Version. Es sollte aber keine Probleme zu anderen Versionen geben. Den Reconnect habe ich auch mit php hinbekommen. Dazu habe ich aber die php_curl.dll benötigt, da man zum Reconnect Variablen mit POST übergeben muss.
Icons gibt es unten als Archiv. Stammen tun sie von Icon Archive - 31,400+ free icons, buddy icons, xp icons, vista icons, desktop icons. Manche sind von mir dann angepasst oder umgebaut worden.
Die Funktionen hab ich aus dem Tankstellenscript von paresy.
How-to-install:
- neue Kategorie anlegen
- icons nach \webfront\user\icons\fixed kopieren
- php_curl.dll nach \ext kopieren
- IPS neu starten
- script erstellen, einfügen; User, Pass und IP eintragen
- ausführen
Script:
<?
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////KONFIGURATION//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
$routerip = "IP";
$user = "USER";
$pass = "PASS";
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////SCRIPT/////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
$object = IPS_GetObject($IPS_SELF);
$parentID = $object['ParentID'];
$umlaute = array("ü");
$replace = array("ü");
if ( $IPS_SENDER == "WebFront" ) {
if (IPS_SemaphoreEnter("reconnect", 1))
{
if(GetValue(IPS_GetVariableIDByName('WAN Status', $parentID))==1){
connection('Disconnect', $user, $pass, $routerip);
sleep(5);
}
elseif(GetValue(IPS_GetVariableIDByName('WAN Status', $parentID))==0){
connection('Connect', $user, $pass, $routerip);
sleep(10);
}
IPS_SemaphoreLeave("reconnect");
}
}
if(!IPS_VariableProfileExists("Connection")) {
IPS_CreateVariableProfile("Connection", 0);
IPS_SetVariableProfileAssociation("Connection", 0, "Getrennt", "off");
IPS_SetVariableProfileAssociation("Connection", 1, "Verbunden", "on");
}
if(!IPS_VariableProfileExists("Traffic")) {
IPS_CreateVariableProfile("Traffic", 1);
IPS_SetVariableProfileText("Traffic", "", " MB");
}
////////////////////////////////////////////////////////////////////////////////
$url = "http://".$user.":".$pass."@".$routerip."/Status_Internet.live.asp";
$site = file_get_contents($url);
$data = $site;
IPS_CutBefore($data, "wan_status::");
$value = IPS_GetText($data, " ");
$vid = CreateVariableByName($parentID, "WAN Status", 0, "Connection", 1);
if($value == "Verbunden"){$value = true;}
elseif($value == "Getrennt"){$value = false;}
SetValueBoolean($vid, $value);
$data = $site;
IPS_CutBefore($data, "wan_ipaddr::");
$value = IPS_GetText($data, "}");
$vid = CreateVariableByName($parentID, "WAN IP", 3, "~String", 2, "wan");
SetValue($vid, $value);
$data = $site;
IPS_CutBefore($data, "wan_uptime::");
$value = IPS_GetText($data, "}");
$vid = CreateVariableByName($parentID, "WAN Uptime", 3, "~String", 3, "uptime");
SetValue($vid, str_replace($umlaute, $replace, $value));
////////////////////////////////////////////////////////////////////////////////
$url = "http://".$user.":".$pass."@".$routerip."/Status_Lan.live.asp";
$site = file_get_contents($url);
$data = $site;
IPS_CutBefore($data, "{arp_table:: ");
$value = IPS_GetText($data, "}");
$value = explode(",", $value);
$clients = "<center><table>";
$clients .= "<tr><td width='200'><b>Hostname</b></td><td width='200'><b>IP</b></td><td width='200'><b>MAC</b></td><td width='200'><b>Verbindungen</b></td></tr>";
for ($i = 0; $i <= count($value)-1; $i=$i+4) {
$clients .= "<tr><td>".substr($value[$i],1,-1)."</td><td>".substr($value[$i+1],1,-1)."</td><td>".substr($value[$i+2],1,-1)."</td><td>".substr($value[$i+3],1,-1)."</td></tr>";
}
$clients .= "</table></center>";
$vid = CreateVariableByName($parentID, "Clients", 3, "~HTMLBox", 4, "lan");
SetValue($vid, $clients);
////////////////////////////////////////////////////////////////////////////////
$url = "http://".$user.":".$pass."@".$routerip."/ttgraph.cgi?".date("n-Y");
$site = file_get_contents($url);
$data = $site;
IPS_CutBefore($data, date("j, Y")." (Incoming: ");
$value = IPS_GetText($data, " MB)')");
$vid = CreateVariableByName($parentID, "Download heute", 1, "Traffic", 5, "Download");
$down = IPS_GetText($value, " MB / ");
SetValue($vid, $down);
$vid = CreateVariableByName($parentID, "Upload heute", 1, "Traffic", 5, "Upload");
IPS_CutBefore($value, "Outgoing: ");
SetValue($vid, $value);
////////////////////////////////////////////////////////////////////////////////
$url = "http://".$user.":".$pass."@".$routerip."/DDNS.live.asp";
$site = file_get_contents($url);
$data = $site;
IPS_CutBefore($data, "ddns_status::");
$value = "<center><table><tr><td width='890'>";
$value .= IPS_GetText($data, "}");
$value .= "</td></tr></table></center>";
$vid = CreateVariableByName($parentID, "DynDNS", 3, "~HTMLBox", 6, "dyndns");
SetValue($vid, $value);
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////FUNKTIONEN/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function IPS_CutBefore(&$data, $str) {
$data = substr($data, strpos($data, $str)+strlen($str));
}
function IPS_GetText(&$data, $str) {
$value = substr($data, 0, strpos($data, $str));
IPS_CutBefore($data, $str);
return $value;
}
function CreateVariableByName($id, $name, $type, $profile = "", $position = "", $icon = "") {
global $IPS_SELF;
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid === false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "this variable was created by script #$IPS_SELF");
if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); }
if($position !== "") { IPS_SetPosition($vid, $position); }
if($icon !== "") { IPS_SetIcon($vid, $icon); }
}
return $vid;
}
function connection($status, $user, $pass, $routerip) {
$ch = curl_init('http://'.$user.':'.$pass.'@'.$routerip.'/apply.cgi');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "submit_button=Status_Internet&action=Apply&change_action=gozila_cgi&submit_type=".$status."_pppoe");
curl_exec ($ch);
curl_close ($ch);
}
?>
Wenn ich was vergessen habe einfach meckern
Gruß Cord
icons.rar (28.1 KB)
php_curl.rar (164 KB)