function check_remote($entry) { $port = query($entry . "/inf/web"); if ($port != "") { if (isdigit($port) != "1") { set_result("FAILED", $entry . "/inf/web", i18n("Invalid port number")); return 0; } if ($port < 1 || $port > 65535) { set_result("FAILED", $entry . "/inf/web", i18n("Invalid port range")); return 0; } } $port = query($entry . "/inf/https_rport"); if ($port != "") { if (isdigit($port) != "1") { set_result("FAILED", $entry . "/inf/https_rport", i18n("Invalid port number")); return 0; } if ($port < 1 || $port > 65535) { set_result("FAILED", $entry . "/inf/https_rport", i18n("Invalid port range")); return 0; } } $host = query($entry . "/inf/weballow/hostv4ip"); if ($host != "") { if (INET_validv4addr($host) != "1") { set_result("FAILED", $entry . "/inf/weballow/hostv4ip", i18n("Invalid host IP address")); return 0; } } set_result("OK", "", ""); return 1; }
function check_dmz_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { anchor($path); $hostid = query("hostid"); if ($hostid == "") { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } if ($addrtype == "ipv4") { $dmzip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($dmzip, $mask) == 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
function check_qos_setting($path) { $enable = query($path . "/device/qos/enable"); $auto = query($path . "/device/qos/autobandwidth"); if ($enable == "1") { if ($auto == "0") { if (isdigit(query($path . "/inf/bandwidth/upstream")) == "0" || query($path . "/inf/bandwidth/upstream") > 102400 || query($path . "/inf/bandwidth/upstream") < 1) { set_result("FAILED", $path . "/inf/bandwidth/upstream", i18n("The input uplink speed is invalid.")); return "FAILED"; } else { // Remove the leading zeros. $upstream_dec = strtoul(query($path . "/inf/bandwidth/upstream"), 10); set($path . "/inf/bandwidth/upstream", $upstream_dec); } } else { set($path . "/device/qos/autobandwidth", "1"); } $type = query($path . "/inf/bandwidth/type"); if ($type == "AUTO" || $type == "ADSL" || $type == "CABLE") { } else { set_result("FAILED", $path . "/inf/bandwidth/type", i18n("Unsupported Connection type be assigned.")); return "FAILED"; } } else { set($path . "/device/qos/enable", "0"); } return "OK"; }
function fatlady_phyinf($prefix, $inf) { /* Check the interface setting */ if (query($prefix . "/inf/uid") != $inf) { /* internet error, no i18n(). */ set_result("FAILED", $prefix . "/inf/uid", "INF UID mismatch"); return; } /* Check PHYINF */ $phy = query($prefix . "/inf/phyinf"); $phyp = XNODE_getpathbytarget($prefix, "phyinf", "uid", $phy, 0); if ($phy == "" || $phyp == "") { /* internet error, no i18n(). */ set_result("FAILED", $prefix . "/inf/phyinf", "Invalid phyinf"); return; } /* Check MACADDR */ $macaddr = query($phyp . "/macaddr"); if ($macaddr != "" && PHYINF_validmacaddr($macaddr) != "1") { set_result("FAILED", $phyp . "/macaddr", i18n("Invalid MAC address")); return; } $type = query($phyp . "/type"); if ($type == "eth") { $media = query($phyp . "/media/linktype"); if ($media != "" && $media != "AUTO" && $media != "1000F" && $media != "1000H" && $media != "100F" && $media != "100H" && $media != "10F" && $media != "10H") { set_result("FAILED", $phyp . "/media/linktype", i18n("Invalid media type")); return; } } /* We only validate the 'macaddr' & 'media' here, * so be sure to save 'macaddr' & 'media' only at 'setcfg' */ set($prefix . "/valid", 1); set_result("OK", "", ""); }
function check_datetime($prefix) { $date = query($prefix . "/date"); $time = query($prefix . "/time"); $month = cut($date, 0, "/"); $day = cut($date, 1, "/"); $year = cut($date, 2, "/"); $hour = cut($time, 0, ":"); $min = cut($time, 1, ":"); $sec = cut($time, 2, ":"); TRACE_debug("FATLADY: RUNTIME.TIME: " . $year . "/" . $month . "/" . $day); TRACE_debug("FATLADY: RUNTIME.TIME: " . $hour . ":" . $min . ":" . $sec); /* The latest time linux can support is: Tue Jan 19 11:14:07 CST 2038. */ if (isdigit($year) == 0 || $year < 1999 || $year > 2037) { set_result("FAILED", $prefix . "/date", i18n("Invalid year") . " - " . $year); return; } if (isdigit($month) == 0 || $month <= 0 || $month > 12) { set_result("FAILED", $prefix . "/date", i18n("Invalid month")); return; } if (isdigit($day) == 0 || $day <= 0 || $day > 31) { set_result("FAILED", $prefix . "/date", i18n("Invalid day")); return; } if ($month == 2 || $month == 4 || $month == 6 || $month == 9 || $month == 11) { if ($day > 30) { set_result("FAILED", $prefix . "/date", i18n("Invalid day")); return; } if ($month == 2) { if (is29year($year) == 1) { if ($day > 29) { set_result("FAILED", $prefix . "/date", i18n("Invalid day")); return; } } else { if ($day > 28) { set_result("FAILED", $prefix . "/date", i18n("Invalid day")); return; } } } } if (isdigit($hour) == 0 || $hour < 0 || $hour > 23) { set_result("FAILED", $prefix . "/time", i18n("Invalid hour")); return; } if (isdigit($min) == 0 || $min < 0 || $min > 59) { set_result("FAILED", $prefix . "/time", i18n("Invalid minute")); return; } if (isdigit($sec) == 0 || $sec < 0 || $sec > 59) { set_result("FAILED", $prefix . "/time", i18n("Invalid second")); return; } set_result("OK", "", ""); }
function check_remote($entry) { $port = query($entry . "/inf/web"); if ($port != "") { if (isdigit($port) != "1") { set_result("FAILED", $entry . "/inf/web", i18n("Invalid port number")); return 0; } if ($port < 1 || $port > 65535) { set_result("FAILED", $entry . "/inf/web", i18n("Invalid port range")); return 0; } // Check with VSVR and PFWD. Currently only with NAT-1; $nat = XNODE_getpathbytarget("/nat", "entry", "uid", "NAT-1"); if ($nat != "") { $i = 1; while ($i <= 2) { if ($i == 1) { $target = "portforward"; $svr_str = i18n("PORT FORWARDING"); } else { $target = "virtualserver"; $svr_str = i18n("VIRTUAL SERVER"); } $count = query($nat . "/" . $target . "/entry#"); TRACE_debug("FATLADY: check HTTP.WAN with " . $nat . "/" . $target . " count:" . $count); $j = 1; while ($j <= $count) { $CurBase = $nat . "/" . $target . "/entry:" . $j; if (query($CurBase . "/protocol") == "TCP+UDP" || query($CurBase . "/protocol") == "TCP") { if ($port >= query($CurBase . "/external/start") && $port <= query($CurBase . "/external/end")) { set_result("FAILED", $entry . "/inf/web", i18n("The port number is used by") . " " . i18n($svr_str) . "."); return 0; } } $j++; } $i++; } } } $host = query($entry . "/inf/weballow/hostv4ip"); if ($host != "") { if (INET_validv4addr($host) != "1") { set_result("FAILED", $entry . "/inf/weballow/hostv4ip", i18n("Invalid host IP address")); return 0; } } set_result("OK", "", ""); return 1; }
function check_tz_dst($prefix) { $maxtz = query("/runtime/services/timezone/zone#"); $tz = query($prefix . "/timezone"); if ($tz > $maxtz || $tz <= 0) { set_result("FAILED", $prefix . "/timezone", i18n("Invalid timezone setting.")); return; } if (query("device/time/dst") != "1") { set("device/time/dst", "0"); } TRACE_debug("FATLADY: DEVICE.TIME: timezone=" . $tz . ", dst=" . query("device/time/dst")); set_result("OK", "", ""); }
function verify_setting($path) { anchor($path); if (query("hostname") == "") { return set_result("FAILED", $path . "/hostname", i18n("Please input the host name.")); } if (isdomain(query("hostname")) == "0") { return set_result("FAILED", $path . "/hostname", i18n("Invalid host name.")); } if (query("username") == "") { return set_result("FAILED", $path . "/username", i18n("Please enter user account or e-mail.")); } if (query("password") == "") { return set_result("FAILED", $path . "/password", i18n("Please input the password.")); } return "OK"; }
function check_syslog_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { $hostid = query($path . "/ipv4/ipaddr"); if ($hostid == "") { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host is not a valid host ID.")); return "FAILED"; } if ($addrtype == "ipv4") { $syslogip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($syslogip, $mask) == 0) { set_result("FAILED", $path . "/ipv4/ipaddr", i18n("SYSLOG host is not a valid host ID.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
function check_ppp4($path) { anchor($path); $over = query("over"); if ($over != "eth" && $over != "pptp" && $over != "l2tp" && $over != "tty") { /* Internal error, no i18n. */ set_result("FAILED", $path . "/ipaddr", "Illegal value for over : " . $over); return; } /* IP address */ $static = query("static"); if ($static == "1") { $ipaddr = query("ipaddr"); if (INET_validv4addr($ipaddr) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP address")); return; } } else { /* if static is not 1, it should be 0. */ set("static", "0"); del("ipaddr"); } /* DNS */ $cnt = query("dns/count"); $i = 0; while ($i < $cnt) { $i++; $value = query("dns/entry:" . $i); if (INET_validv4addr($value) == 0) { set_result("FAILED", $path . "/dns:" . $i, i18n("Invalid DNS address")); return; } set("dns/entry:" . $i, INET_addr_strip0($value)); } /* MTU/MRU */ $mtu = query("mtu"); if ($mtu != "") { if (isdigit($mtu) == "0") { set_result("FAILED", $path . "/mtu", i18n("The MTU value is invalid.")); return; } if ($mtu < 576) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too small, the valid value cannot be smaller than 576.")); return; } if ($over == "pptp" && $mtu > 1460) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value for pptp is 576 ~ 1460.")); return; } else { if ($over == "l2tp" && $mtu > 1460) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value for l2tp is 576 ~ 1460.")); return; } else { if ($mtu > 1492) { if ($over == "tty") { if ($mtu > 1500) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value for 3G is 576 ~ 1500.")); return; } } else { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value is 576 ~ 1492.")); return; } } } } $mtu = $mtu + 1 - 1; /* convert to number */ set("mtu", $mtu); } $mru = query("mru"); if ($mru != "") { if (isdigit($mru) == "0") { set_result("FAILED", $path . "/mtu", i18n("Invalid MRU value.")); return; } if ($mru < 576) { set_result("FAILED", $path . "/mru", i18n("The MRU value is too small, the valid value is 576 ~ 1492.")); return; } if ($mru > 1492) { set_result("FAILED", $path . "/mru", i18n("The MRU value is too large, the valid value is 576 ~ 1492.")); return; } $mru = $mru + 1 - 1; /* convert to number */ set("mru", $mru); } /* User Name & Password */ if (query("username") == "" && $over != "tty") { set_result("FAILED", $path . "/username", i18n("The user name cannot be empty")); return; } /* dialup */ $mode = query("dialup/mode"); if ($mode != "auto" && $mode != "manual" && $mode != "ondemand") { /* no i18n */ set_result("FAILED", $path . "/dialup/mode", "Invalid value for dial up mode - " . $mode); return; } $tout = query("dialup/idletimeout"); if ($tout != "") { if (isdigit($tout) == "0" || $tout < 0 || $tout >= 10000) { set_result("FAILED", $path . "/dialup/mode", i18n("Invalid value for idle timeout.")); return; } } if ($over == "eth") { /* should check service name & ac name here. */ } else { if ($over == "pptp") { $server = query("pptp/server"); if ($server == "") { set_result("FAILED", $path . "/pptp/server", i18n("No PPTP server.")); return; } if (cut_count($server, ".") == 4 && isdigit(cut($server, 0, ".")) == 1 && isdigit(cut($server, 1, ".")) == 1 && isdigit(cut($server, 2, ".")) == 1 && isdigit(cut($server, 3, ".")) == 1) { if (INET_validv4addr($server) == 0) { set_result("FAILED", $path . "/pptp/server", i18n("Invalid server IP address")); return; } else { set("pptp/server", INET_addr_strip0($server)); } } else { if (isdomain($server) != 1) { set_result("FAILED", $path . "/pptp/server", i18n("Invalid server IP address")); return; } } } else { if ($over == "l2tp") { $server = query("l2tp/server"); if ($server == "") { set_result("FAILED", $path . "/l2tp/server", i18n("No L2TP server.")); return; } if (cut_count($server, ".") == 4 && isdigit(cut($server, 0, ".")) == 1 && isdigit(cut($server, 1, ".")) == 1 && isdigit(cut($server, 2, ".")) == 1 && isdigit(cut($server, 3, ".")) == 1) { if (INET_validv4addr($server) == 0) { set_result("FAILED", $path . "/l2tp/server", i18n("Invalid server IP address")); return; } else { set("l2tp/server", INET_addr_strip0($server)); } } else { if (isdomain($server) != 1) { set_result("FAILED", $path . "/l2tp/server", i18n("Invalid server IP address")); return; } } } } } set_result("OK", "", ""); }
<?php /* vi: set sw=4 ts=4: */ /* fatlady is used to validate the configuration for the specific service. * FATLADY_prefix was defined to the path of Session Data. * 3 variables should be returned for the result: * FATLADY_result, FATLADY_node & FATLADY_message. */ include "/htdocs/phplib/trace.php"; include "/htdocs/phplib/xnode.php"; function set_result($result, $node, $message) { $_GLOBALS["FATLADY_result"] = $result; $_GLOBALS["FATLADY_node"] = $node; $_GLOBALS["FATLADY_message"] = $message; return $result; } ////////////////////////////////////////////////////////////////////////////// $wan1_infp_fatlady = XNODE_getpathbytarget($FATLADY_prefix, "inf", "uid", "WAN-1", 0); if (query($wan1_infp_fatlady . "/open_dns/type") == "parent" && query($wan1_infp_fatlady . "/open_dns/deviceid") == "") { $ret = set_result("FAILED", $wan1_infp_fatlady . "/open_dns/deviceid", i18n("Please register your device.")); } $ret = "OK"; TRACE_debug("FATLADY: OPENDNS4: ret = " . $ret); if ($ret == "OK") { set($FATLADY_prefix . "/valid", "1"); }
function check_ipv4($path, $needgw) { anchor($path); $static = query("static"); if ($static != "1") { set("static", "0"); } TRACE_debug("FATLADY: INET_IPV4: static = " . $static); if ($static == "1") { $ip = query("ipaddr"); $mask = query("mask"); $dhcps4 = INF_getinfinfo($_GLOBALS["FATLADY_INF_UID"], "dhcps4"); TRACE_debug("FATLADY: INET_IPV4: ip = " . $ip); TRACE_debug("FATLADY: INET_IPV4: mask = " . $mask); if (INET_validv4addr($ip) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP address")); return; } if ($mask == "") { set_result("FAILED", $path . "/mask", i18n("No Subnet Mask value")); return; } if ($mask < 0 || $mask > 32) { set_result("FAILED", $path . "/mask", i18n("Invalid Subnet Mask value")); return; } if (INET_validv4host($ip, $mask) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP address")); return; } if (INET_addr_strip0($gw) == $ip) { set_result("FAILED", $path . "/gateway", i18n("The IP address and gateway address cannot be the same")); return; } set("ipaddr", INET_addr_strip0($ip)); $ip = query("ipaddr"); $gw = query("gateway"); TRACE_debug("FATLADY: INET_IPV4: gw=" . $gw); if ($gw == "") { if ($needgw == "1" && $static == "1") { set_result("FAILED", $path . "/gateway", i18n("No default gateway IP address")); return; } } else { if (INET_validv4host($gw, $mask) == 0) { set_result("FAILED", $path . "/gateway", i18n("Invalid default gateway IP address")); return; } if (ipv4networkid($gw, $mask) != ipv4networkid($ip, $mask)) { set_result("FAILED", $path . "/gateway", i18n("The default gateway should be in the same network")); return; } if (INET_addr_strip0($gw) == $ip) { set_result("FAILED", $path . "/gateway", i18n("The IP address and gateway address cannot be the same")); return; } set("gateway", INET_addr_strip0($gw)); } } else { if (query("dhcpplus/enable") != "") { /* User Name & Password */ if (query("dhcpplus/enable") == "1" && query("dhcpplus/username") == "") { set_result("FAILED", $path . "/dhcpplus/username", i18n("The user name cannot be empty")); return; } } } $cnt = query("dns/count"); $i = 0; while ($i < $cnt) { $i++; $value = query("dns/entry:" . $i); TRACE_debug("FATLADY: INET_IPV4: dns" . $i . "=" . $value); if (INET_validv4addr($value) == 0) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } set("dns/entry:" . $i, INET_addr_strip0($value)); if ($static == "1") { if (ipv4networkid($value, $mask) == ipv4networkid($ip, $mask)) { TRACE_debug("FATLADY: INET_IPV4: dns" . $i . "=" . $value . " is in the same network as IP:" . $ip); if (INET_validv4host($value, $mask) == 0) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } if ($value == $ip) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } } } if ($i > 1) { $j = $i - 1; $k = 0; while ($k < $j) { $k++; $dns = query("dns/entry:" . $k); if ($value == $dns) { set_result("FAILED", $path . "/dns/entry:2", i18n("Secondary DNS server should not be the same as Primary DNS server.")); return; } } } } $mtu = query("mtu"); TRACE_debug("FATLADY: INET_IPV4: mtu=" . $mtu); if ($mtu != "") { if (isdigit($mtu) == "0") { set_result("FAILED", $path . "/mtu", i18n("The MTU value is invalid.")); return; } if ($mtu < 576) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too small, the valid value is 576 ~ 1500.")); return; } if ($mtu > 1500) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value is 576 ~ 1500.")); return; } } set_result("OK", "", ""); }
function check_ipv4($path, $needgw) { include "/htdocs/webinc/feature.php"; anchor($path); $static = query("static"); $ipipmode = query($path . "/ipv4in6/mode"); if ($ipipmode != "") { TRACE_debug("FATLADY: INET_IPV4: IPIP mode :" . $ipipmode); $ipipremote = query($path . "/ipv4in6/remote"); if ($ipipremote != "") { TRACE_debug("FATLADY: IPIP remote IPv6 address :" . $ipipremote); //if(INET_validv6addr($ipipremote) == 0) if (ipv6checkip($ipipremote) != 1) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IPv6 address")); return; } //$type = INET_v6addrtype($ipipremote); $type = ipv6addrtype($ipipremote); TRACE_debug("FATLADY: IPIP remote IPv6 address type :" . $type); if ($type == "ANY" || $type == "MULTICAST" || $type == "LOOPBACK") { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IPv6 address type")); return; } } $ip = query("ipaddr"); /* ip address of B4 */ if ($ip != "") { $ip_part = cut($ip, 3, '.'); if ($ip_part < 2 || $ip_part > 7) { set_result("FAILED", $path . "/ipaddr", i18n("The range of B4 IPv4 address is from 192.0.0.2 to 192.0.0.7")); return; } } set_result("OK", "", ""); return; } if ($static != "1") { set("static", "0"); } TRACE_debug("FATLADY: INET_IPV4: static = " . $static); if ($static == "1") { $ip = query("ipaddr"); $mask = query("mask"); $dhcps4 = INF_getinfinfo($_GLOBALS["FATLADY_INF_UID"], "dhcps4"); TRACE_debug("FATLADY: INET_IPV4: ip = " . $ip); TRACE_debug("FATLADY: INET_IPV4: mask = " . $mask); if (INET_validv4addr($ip) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP Address")); return; } if ($mask == "") { set_result("FAILED", $path . "/mask", i18n("No Subnet Mask value")); return; } if ($mask < 0 || $mask > 32) { set_result("FAILED", $path . "/mask", i18n("Invalid Subnet Mask value")); return; } if ($mask < 8) { set_result("FAILED", $path . "/mask", i18n("The router would not support the subnet mask which length is less than Class A.")); return; } if (INET_validv4host($ip, $mask) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP Address")); return; } if (INET_addr_strip0($gw) == $ip) { set_result("FAILED", $path . "/gateway", i18n("The IP address can not be equal to the gateway address")); return; } set("ipaddr", INET_addr_strip0($ip)); $ip = query("ipaddr"); $gw = query("gateway"); TRACE_debug("FATLADY: INET_IPV4: gw=" . $gw); if ($gw == "") { if ($needgw == "1" && $static == "1") { set_result("FAILED", $path . "/gateway", i18n("No gateway address")); return; } } else { if (INET_validv4host($gw, $mask) == 0) { set_result("FAILED", $path . "/gateway", i18n("Invalid Default Gateway address")); return; } if (ipv4networkid($gw, $mask) != ipv4networkid($ip, $mask)) { set_result("FAILED", $path . "/gateway", i18n("The default gateway should be in the same network")); return; } if (INET_addr_strip0($gw) == $ip) { set_result("FAILED", $path . "/gateway", i18n("The IP address can not be equal to the Default Gateway address")); return; } set("gateway", INET_addr_strip0($gw)); } } else { if (query("dhcpplus/enable") != "") { /* User Name & Password */ if (query("dhcpplus/enable") == "1" && query("dhcpplus/username") == "") { set_result("FAILED", $path . "/dhcpplus/username", i18n("The user name can not be empty")); return; } } } $cnt = query("dns/count"); $i = 0; while ($i < $cnt) { $i++; $value = query("dns/entry:" . $i); TRACE_debug("FATLADY: INET_IPV4: dns" . $i . "=" . $value); if (INET_validv4addr($value) == 0) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } set("dns/entry:" . $i, INET_addr_strip0($value)); if ($static == "1") { if (ipv4networkid($value, $mask) == ipv4networkid($ip, $mask)) { TRACE_debug("FATLADY: INET_IPV4: dns" . $i . "=" . $value . " is in the same network as IP:" . $ip); if (INET_validv4host($value, $mask) == 0) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } if ($value == $ip) { set_result("FAILED", $path . "/dns/entry:" . $i, i18n("Invalid DNS address")); return; } } } if ($i > 1) { $j = $i - 1; $k = 0; while ($k < $j) { $k++; $dns = query("dns/entry:" . $k); if ($value == $dns) { set_result("FAILED", $path . "/dns/entry:2", i18n("Secondary DNS server should not be the same as Primary DNS server.")); return; } } } } $mtu = query("mtu"); TRACE_debug("FATLADY: INET_IPV4: mtu=" . $mtu); if ($mtu != "") { if (isdigit($mtu) == "0") { set_result("FAILED", $path . "/mtu", i18n("The MTU value is invalid.")); return; } if ($mtu < 576 && $FEATURE_NOIPV6 == 1) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too small, the valid value is 576 ~ 1500.")); return; } if ($mtu < 1280 && $FEATURE_NOIPV6 == 0) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too small, the valid value is 1280 ~ 1500.")); return; } if ($mtu > 1500) { if ($FEATURE_NOIPV6 == 0) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value is 1280 ~ 1500.")); } else { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value is 576 ~ 1500.")); } return; } } set_result("OK", "", ""); }
$total_return = "Sorry, No match found from India for '{$loc_req}'. Check your spelling and try again..."; $istoday = false; } } } else { $total_return = "Sorry, No match found for '{$loc_req}'. Check your spelling and try again..."; $istoday = false; } } } // print_r($options_list); // print_r($list); } else { $q = "SELECT msisdn,area FROM namaz_list_new WHERE msisdn = '{$numbers}'"; $r = mysql_query($q) or trigger_error("Error in {$q}: " . mysql_error(), E_USER_ERROR); if (mysql_num_rows($r)) { $row = mysql_fetch_array($r); $query = "SELECT id,matched,lat,lng FROM namaz_loc_match where id = " . $row['area']; echo "<br>{$query}<br>"; $result = mysql_query($query) or print mysql_error() . " in {$query}"; if (mysql_num_rows($result)) { echo '<h5>FOUND IN DB</h5>'; $row = mysql_fetch_array($result); $places = explode(',', $row['matched']); $msgs = getMsg($row['lat'], $row['lng'], $places[0], $getdate); set_result($row['matched'], $msgs[0]); } } else { $total_return = "Location not found.\nTo get namaz timings sms NAMAZ <your location> to {$shortcode}"; } }
$_GLOBALS["FATLADY_node"] = $node; $_GLOBALS["FATLADY_message"] = $message; } set_result("FAILED", "", ""); $rlt = "0"; $cnt = query($FATLADY_prefix . "/device/account/count"); TRACE_debug("FATLADY: DEVICE.ACCOUNT got " . $cnt . " accounts"); $i = 0; while ($i < $cnt) { $i++; $name = query($FATLADY_prefix . "/device/account/entry:" . $i . "/name"); $passwd = query($FATLADY_prefix . "/device/account/entry:" . $i . "/password"); TRACE_debug("FATLADY: account[" . $i . "]: name=" . $name . ",passwd=" . $passwd); if ($name == "") { set_result("FAILED", $FATLADY_prefix . "/device/account/entry:" . $i . "/password", i18n("Login Name cannot be empty.")); $rlt = "-1"; break; } $p = "/device/account/entry:" . $i; if (query($FATLADY_prefix . $p . "/confirmcurrentpassword/enable") == 1) { if (query($FATLADY_prefix . $p . "/confirmcurrentpassword/password") != query($p . "/password")) { set_result("FAILED", $FATLADY_prefix . $p . "/confirmcurrentpassword/password", i18n("The current password doesn't match.")); $rlt = "-1"; } break; } } if ($rlt == "0") { set($FATLADY_prefix . "/valid", "1"); set_result("OK", "", ""); }
<?php include_once '/../includes/user_function.php'; include_once '/../includes/hw_function.php'; $string = $_POST['password']; $userid = substr($string, 0, 3); $password = substr($string, 3); $result = get_single_user($userid); if (!empty($result)) { if ($result->password == $password) { $data = '<1>'; set_result($data); insert_log($result->name); } else { $data = '<0>'; set_result($data); } } else { $data = '<0>'; set_result($data); }
function check_ppp6($path) { anchor($path); /* IP address */ $static = query("static"); if ($static == "1") { $ipaddr = query("ipaddr"); if (INET_validv6addr($ipaddr) == 0) { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IP Address")); return; } $type = INET_v6addrtype($ipaddr); TRACE_debug("FATLADY: INET_PPP6: ipv6 type = " . $type); if ($type == "ANY" || $type == "MULTICAST" || $type == "LOOPBACK" || $type == "LINKLOCAL" || $type == "SITELOCAL") { set_result("FAILED", $path . "/ipaddr", i18n("Invalid IPv6 Address")); return; } } else { /* if static is not 1, it should be 0. */ set("static", "0"); del("ipaddr"); } /* DNS */ $cnt = query("dns/count"); $i = 0; while ($i < $cnt) { $i++; $value = query("dns/entry:" . $i); if (INET_validv6addr($value) == 0) { set_result("FAILED", $path . "/dns:" . $i, i18n("Invalid DNS address")); return; } } /* MTU/MRU */ $mtu = query("mtu"); if ($mtu != "") { if (isdigit($mtu) == "0") { set_result("FAILED", $path . "/mtu", i18n("The MTU value is invalid.")); return; } if ($mtu < 1280) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too small, the valid value mustn't be smaller than 1280.")); return; } if ($mtu > 1492) { set_result("FAILED", $path . "/mtu", i18n("The MTU value is too large, the valid value is 1280 ~ 1492.")); return; } $mtu = $mtu + 1 - 1; /* convert to number */ set("mtu", $mtu); } $mru = query("mru"); if ($mru != "") { if (isdigit($mru) == "0") { set_result("FAILED", $path . "/mtu", i18n("The MRU value is invalid.")); return; } if ($mru < 576) { set_result("FAILED", $path . "/mru", i18n("The MRU value is too small, the valid value is 576 ~ 1492.")); return; } if ($mru > 1492) { set_result("FAILED", $path . "/mru", i18n("The MRU value is too large, the valid value is 576 ~ 1492.")); return; } $mru = $mru + 1 - 1; /* convert to number */ set("mru", $mru); } /* User Name & Password */ if (query("username") == "") { set_result("FAILED", $path . "/username", i18n("The user name can not be empty")); return; } /* dialup */ $mode = query("dialup/mode"); if ($mode != "auto" && $mode != "manual" && $mode != "ondemand") { /* no i18n */ set_result("FAILED", $path . "/dialup/mode", "Invalid value for dial up mode - " . $mode); return; } $tout = query("dialup/idletimeout"); if ($tout != "") { if (isdigit($tout) == "0" || $tout < 0 || $tout > 10000) { set_result("FAILED", $path . "/dialup/mode", i18n("Invalid value for idle timeout.")); return; } } set_result("OK", "", ""); }