Example #1
0
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", "", "");
}
Example #2
0
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;
}
Example #3
0
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", "", "");
}
Example #4
0
function setup_dhcpc($prefix)
{
    $i = 1;
    while ($i > 0) {
        $ifname = $prefix . "-" . $i;
        $ifpath = XNODE_getpathbytarget("/runtime", "inf", "uid", $ifname, 0);
        if ($ifpath == "") {
            $i = 0;
            break;
        }
        if (query($ifpath . "/inet/addrtype") == "ipv4" && query($ifpath . "/inet/ipv4/static") == "0" && query($ifpath . "/inet/ipv4/valid") == "1") {
            TRACE_debug("Restart DHCP client: ifname = " . $ifname);
            startcmd("service INET." . $ifname . " restart");
        }
        $i++;
    }
}
Example #5
0
{
    $_GLOBALS["FATLADY_result"] = $result;
    $_GLOBALS["FATLADY_node"] = $node;
    $_GLOBALS["FATLADY_message"] = $message;
}
$wfaprefix = $FATLADY_prefix . "/webaccess";
$enable = query($wfaprefix . "/enable");
$httpenable = query($wfaprefix . "/httpenable");
$httpsenable = query($wfaprefix . "/httpsenable");
$httpport = query($wfaprefix . "/httpport");
$httpsport = query($wfaprefix . "/httpsport");
if ($enable != "1") {
    set($wfaprefix . "/enable", 0);
}
if ($httpenable != "1") {
    set($wfaprefix . "/httpenable", 0);
}
if ($httpsenable != "1") {
    set($wfaprefix . "/httpsenable", 0);
}
TRACE_debug("httpport=" . $httpenable . "https=" . $httpsenable);
if ($httpport < 1 || $httpport > 65535) {
    set_result("FAILED", $wfaprefix . "/httpport", i18n("Invalid HTTP port number."));
} else {
    if ($httpsport < 1 || $httpsport > 65535) {
        set_result("FAILED", $wfaprefix . "/httpsenable", i18n("Invalid HTTPS port number."));
    } else {
        set($FATLADY_prefix . "/valid", "1");
        set_result("OK", "", "");
    }
}
Example #6
0
<?php

/* 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";
$inet_host = query($FATLADY_prefix . "/device/diagnostic/chkconn/host/entry:4");
TRACE_debug("FATLADY: DEVICE.DIAGNOSTIC: FATLADY_prefix=" . $FATLADY_prefix);
TRACE_debug("FATLADY: DEVICE.DIAGNOSTIC: internet host=" . $inet_host);
if (isdomain($inet_host) != "0" || $inet_host == "") {
    set($FATLADY_prefix . "/valid", "1");
    $_GLOBALS["FATLADY_result"] = "OK";
    $_GLOBALS["FATLADY_node"] = "";
    $_GLOBALS["FATLADY_message"] = "";
} else {
    $_GLOBALS["FATLADY_result"] = "FAILED";
    $_GLOBALS["FATLADY_node"] = $FATLADY_prefix . "/device/diagnostic/chkconn/host/entry:4";
    $_GLOBALS["FATLADY_message"] = i18n("Invalid Internet Host");
}
Example #7
0
<?php

/* setcfg is used to move the validated session data to the configuration database.
 * The variable, 'SETCFG_prefix',  will indicate the path of the session data. */
include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
/*
 * Internet Usage Meter.
 */
TRACE_debug("enable==============" . query($SETCFG_prefix . "/callmgr/mobile/flowmeter/enable"));
movc($SETCFG_prefix . "/callmgr/mobile/flowmeter", "/callmgr/mobile/flowmeter");
TRACE_debug("enable==============" . query("/callmgr/mobile/flowmeter/enable"));
Example #8
0
function set_result($result, $node, $message)
{
    $_GLOBALS["FATLADY_result"] = $result;
    $_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") {
Example #9
0
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", "", "");
}
Example #10
0
<?php 
echo "<?";
?>
xml version="1.0" encoding="utf-8"<?php 
echo "?>";
?>

<?php 
include "/htdocs/phplib/trace.php";
echo "<" . $SIGNATURE . ">\n<runtime>\n<session>\n<" . $SESSION . ">\n";
TRACE_debug("GETCFG: serivce = " . $GETCFG_SVC);
if ($GETCFG_SVC != "") {
    $file = "/htdocs/webinc/getcfg/" . $GETCFG_SVC . ".xml.php";
    /* GETCFG_SVC will be passed to the child process. */
    if (isfile($file) == "1") {
        dophp("load", $file);
    }
}
echo "</" . $SESSION . ">\n</session>\n</runtime>\n</" . $SIGNATURE . ">\n";
Example #11
0
<?php

/* 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";
$layout = query($FATLADY_prefix . "/device/layout");
TRACE_debug("FATLADY: DEVICE.LAYOUT: layout=" . $layout);
if ($layout == "router" || $layout == "bridge" || $layout == "auto") {
    set($FATLADY_prefix . "/valid", "1");
    $_GLOBALS["FATLADY_result"] = "OK";
    $_GLOBALS["FATLADY_node"] = "";
    $_GLOBALS["FATLADY_message"] = "";
} else {
    $_GLOBALS["FATLADY_result"] = "FAILED";
    $_GLOBALS["FATLADY_node"] = $FATLADY_prefix . "/device/layout";
    $_GLOBALS["FATLADY_message"] = "unknown layout value";
    /* internal error, no i18n. */
}
Example #12
0
    $_GLOBALS["FATLADY_result"] = $result;
    $_GLOBALS["FATLADY_node"] = $node;
    $_GLOBALS["FATLADY_message"] = $message;
}
set_result("FAILED", "", "");
$rlt = "0";
$val = query($FATLADY_prefix . "/callmgr/voice_service:1/phone/analog:1/enable");
if ($val != "0") {
    set($FATLADY_prefix . "/callmgr/voice_service:1/phone/analog:1/enable", "1");
}
$val = query($FATLADY_prefix . "/callmgr/voice_service:1/phone/analog:1/callerid_display");
if ($val != "0") {
    set($FATLADY_prefix . "/callmgr/voice_service:1/phone/analog:1/callid_display", "1");
}
$service_state = query($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/service_state");
TRACE_debug("FATLADY: service_state" . $service_state);
if ($service_state != 0 && $servcie_state == "") {
    /*
     * The following check "Caller ID Delivery", "Call waiting"  and all "Call forwarding"
     */
    $val = query($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/callerid_delivery");
    if ($val != "0") {
        set($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/callerid_delivery", "1");
    }
    $val = query($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/callwaiting");
    if ($val != "0") {
        set($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/callwaiting", "1");
    }
    if (query($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/call_forward/unconditional") == 1) {
        $number = query($FATLADY_prefix . "/runtime/callmgr/voice_service:1/mobile/call_forward/unconditional_number");
        //TRACE_debug("FATLADY: unconditional_number".$number);
Example #13
0
                    $str = "Router Status";
                }
            }
        }
        fwrite("w", $logfile, "\n[" . $str . "]\n");
        fwrite("a", $logfile, "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
        DUMPLOG_append_to_file($logfile, $path);
        del($path);
        echo 'logger -p 192.1 "Log of [' . $str . '] is full."\\n';
    }
} else {
    /*write rg.log*/
    $logfile = "/var/run/rg.log";
    DUMPLOG_all_to_file($logfile);
}
TRACE_debug("SendMailFlag=" . $SendMailFlag);
$enable = query("/device/log/email/enable");
if ($enable == "1" && $SendMailFlag == 1) {
    $from = query("/device/log/email/from");
    $email_addr = query("/device/log/email/to");
    $mail_subject = get(s, "/device/log/email/subject");
    $mail_server = query("/device/log/email/smtp/server");
    $mail_port = query("/device/log/email/smtp/port");
    if ($mail_port == "") {
        $mail_port = "25";
    }
    $authenable = query("/device/log/email/authenable");
    $username = query("/device/log/email/smtp/user");
    $password = query("/device/log/email/smtp/password");
    fwrite("w", "/var/log/subject", $mail_subject);
    if ($from == "" || $email_addr == "" || $mail_server == "") {
Example #14
0
HTTP/1.1 200 OK
Content-Type: text/xml

<?php 
include "/htdocs/phplib/trace.php";
if ($AUTHORIZED_GROUP < 0) {
    $result = "Authenication fail";
} else {
    $result = "OK";
    $code = "";
    $message = "";
    TRACE_debug("CHECK_NODE=================" . $_POST["CHECK_NODE"]);
    // get value.
    if ($_POST["CHECK_NODE"] != "") {
        $code = query($_POST["CHECK_NODE"]);
        TRACE_debug("code=============" . $code);
    }
}
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<status>\n";
echo "\t<result>" . $result . "</result>\n";
echo "\t<code>" . $code . "</code>\n";
echo "\t<message></message>\n";
echo "</status>\n";
Example #15
0
<?php

include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
$i = 0;
TRACE_debug("COUNT=" . $COUNT);
TRACE_debug("PREFIX=" . $PREFIX);
while ($i < $COUNT) {
    $VALUE = "VALUE" . $i;
    TRACE_debug("VALUE" . $i . "=" . ${$VALUE});
    $i++;
}
$path_lan = XNODE_getpathbytarget($PREFIX . "/module", "inf", "uid", "LAN-1", 0);
if ($COUNT == 0) {
    $lan_dns = query($path_lan . "/dns4");
    if ($lan_dns == "DNS4-1") {
        echo "LAN DNS  ENABLED\n";
    } else {
        echo "LAN DNS DISABLED\n";
    }
    set($PREFIX . "/statue", "0");
} else {
    /*invalid parameter*/
    set($PREFIX . "/statue", "7");
}
Example #16
0
            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", "", "");
}
TRACE_debug("FATLADY: INET: inetentry=[" . $_GLOBALS["FATLADY_INET_ENTRY"] . "]");
set_result("FAILED", "", "");
if ($_GLOBALS["FATLADY_INET_ENTRY"] == "") {
    set_result("FAILED", "", "No XML document");
} else {
    check_ppp4($_GLOBALS["FATLADY_INET_ENTRY"] . "/ppp4");
}
Example #17
0
include "/htdocs/phplib/trace.php";
//TRACE_debug("SUBJECTPATH=".$SUBJECTPATH);
//TRACE_debug("MAILPATH=".$MAILPATH);
$enable = query("/device/log/email/enable");
if ($enable == "1") {
    $from = query("/device/log/email/from");
    $email_addr = query("/device/log/email/to");
    $mail_subject = "mydlink";
    $mail_server = query("/device/log/email/smtp/server");
    $mail_port = query("/device/log/email/smtp/port");
    if ($mail_port == "") {
        $mail_port = "25";
    }
    $authenable = query("/device/log/email/authenable");
    $username = $from;
    $displayfrom = "mydlink";
    $password = query("/device/log/email/smtp/password");
    $logfile = $MAILPATH;
    if ($from == "" || $email_addr == "" || $mail_server == "") {
        TRACE_error("sendmail: invalid args!!! from=[" . $from . "], to=[" . $email_addr . "], smtp server=[" . $mail_server . "]\n");
        return;
    }
    /* static options */
    if ($authenable != "0") {
        echo 'email' . ' -V ' . ' -f ' . $from . ' -n ' . $displayfrom . ' -s "' . $mail_subject . '"' . ' -W ' . $SUBJECTPATH . ' -r ' . $mail_server . ' -z ' . $logfile . ' -p ' . $mail_port . ' -html' . ' -tls ' . ' -m login' . ' -u ' . $username . ' -i ' . $password . ' ' . $email_addr . ' &\\n';
        TRACE_debug('email' . ' -V ' . ' -f ' . $from . ' -n ' . $displayfrom . ' -s "' . $mail_subject . '"' . ' -W ' . $SUBJECTPATH . ' -r ' . $mail_server . ' -z ' . $logfile . ' -p ' . $mail_port . ' -html' . ' -tls ' . ' -m login' . ' -u ' . $username . ' -i ' . $password . ' ' . $email_addr . ' &\\n');
    } else {
        echo 'email' . ' -V ' . ' -f ' . $from . ' -n ' . $username . ' -s "' . $mail_subject . '"' . ' -W ' . $SUBJECTPATH . ' -r ' . $mail_server . ' -z ' . $logfile . ' -p ' . $mail_port . ' -html' . ' ' . $email_addr . ' &\\n';
        TRACE_debug('email' . ' -V ' . ' -f ' . $from . ' -n ' . $username . ' -s "' . $mail_subject . '"' . ' -W ' . $SUBJECTPATH . ' -r ' . $mail_server . ' -z ' . $logfile . ' -p ' . $mail_port . ' -html ' . ' ' . $email_addr . ' &\\n');
    }
}
Example #18
0
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", "", "");
}
Example #19
0
<?php

/* 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/inf.php";
include "/htdocs/phplib/inet.php";
$level = query($FATLADY_prefix . "/device/log/level");
$remote = query($FATLADY_prefix . "/device/log/remote");
TRACE_debug("FATLADY: DEVICE.LOG: log level=" . $level);
if ($level == "WARNING" || $level == "NOTICE" || $level == "DEBUG") {
    set($FATLADY_prefix . "/valid", "1");
    $_GLOBALS["FATLADY_result"] = "OK";
    $_GLOBALS["FATLADY_node"] = "";
    $_GLOBALS["FATLADY_message"] = "";
} else {
    $_GLOBALS["FATLADY_result"] = "FAILED";
    $_GLOBALS["FATLADY_node"] = $FATLADY_prefix . "/device/log/level";
    $_GLOBALS["FATLADY_message"] = i18n("Unsupported log level be assigned");
    /* internal error, no i18n. */
}
function set_result($result, $node, $message)
{
    $_GLOBALS["FATLADY_result"] = $result;
    $_GLOBALS["FATLADY_node"] = $node;
    $_GLOBALS["FATLADY_message"] = $message;
}
function check_syslog_setting($path, $addrtype, $lan_ip, $mask)
{
Example #20
0
<?php

/* 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";
$hostname = query($FATLADY_prefix . "/device/hostname");
TRACE_debug("FATLADY: DEVICE.HOSTNAME: hostname=" . $hostname);
if ($hostname == "" || isdomain($hostname) == "0" || isdigit($hostname) == "1" || strchr($hostname, ".") != "") {
    $_GLOBALS["FATLADY_result"] = "FAILED";
    $_GLOBALS["FATLADY_node"] = $FATLADY_prefix . "/device/hostname";
    $_GLOBALS["FATLADY_message"] = i18n("Invalid host name");
    /* internal error, no i18n. */
} else {
    set($FATLADY_prefix . "/valid", "1");
    $_GLOBALS["FATLADY_result"] = "OK";
    $_GLOBALS["FATLADY_node"] = "";
    $_GLOBALS["FATLADY_message"] = "";
}
Example #21
0
<?php

/* setcfg is used to move the validated session data to the configuration database.
 * The variable, 'SETCFG_prefix',  will indicate the path of the session data. */
include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
$cnt = query($SETCFG_prefix . "/device/account/count");
TRACE_debug("SETCFG: DEVICE.ACCOUNT got " . $cnt . " accounts");
set("/device/account/count", $cnt);
$i = 0;
while ($i < $cnt) {
    $i++;
    $name = query($SETCFG_prefix . "/device/account/entry:" . $i . "/name");
    $pwd = query($SETCFG_prefix . "/device/account/entry:" . $i . "/password");
    $grp = query($SETCFG_prefix . "/device/account/entry:" . $i . "/group");
    set("/device/account/entry:" . $i . "/name", $name);
    if ($pwd != "==OoXxGgYy==") {
        set("/device/account/entry:" . $i . "/password", $pwd);
    }
    set("/device/account/entry:" . $i . "/group", $grp);
}
$captcha = query($SETCFG_prefix . "/device/session/captcha");
if ($captcha != "0") {
    set("/device/session/captcha", 1);
} else {
    set("/device/session/captcha", 0);
}
Example #22
0
<?php

/* setcfg is used to move the validated session data to the configuration database.
 * The variable, 'SETCFG_prefix',  will indicate the path of the session data. */
include "/htdocs/phplib/trace.php";
$inet_host = query($SETCFG_prefix . "/device/diagnostic/chkconn/host/entry:4");
TRACE_debug("SETCFG/DEVICE.DIAGNOSTIC: internet host = " . $inet_host);
set("/device/diagnostic/chkconn/host/entry:4", $inet_host);
Example #23
0
<?php

/* setcfg is used to move the validated session data to the configuration database.
 * The variable, 'SETCFG_prefix',  will indicate the path of the session data. */
include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
$date = query($SETCFG_prefix . "/runtime/device/date");
$time = query($SETCFG_prefix . "/runtime/device/time");
TRACE_debug("SETCFG/RUNTIME.TIME: " . $date . "  " . $time);
set("/runtime/device/tmp_date", $date);
set("/runtime/device/tmp_time", $time);
//set("/runtime/device/date", $date);
//set("/runtime/device/time", $time);
set("/runtime/device/ntp/state", "RUNNING");
set("/runtime/device/timestate", "RUNNING");
Example #24
0
                } else {
                    $langcode = sealpac($slp);
                    $title = i18n("Language Pack Upload Fail");
                    $message = "'" . I18N("j", "The language pack image is invalid.") . "', " . "'<a href=\"" . $referer . "\">" . i18n("Click here to return to the previous page.") . "</a>'";
                }
                unlink($slp_tmp);
            }
        }
    } else {
        if ($_POST["ACTION"] == "langclear") {
            $title = i18n("Clear Language Pack");
            $message = "'" . i18n("Clearing the language pack ...") . "', " . "'<a href=\"" . $referer . "\">" . i18n("Click here to return to the previous page.") . "</a>'";
            set("/runtime/device/langcode", "en");
            event("SEALPAC.CLEAR");
        } else {
            TRACE_debug("Unknown action - ACTION=" . $_POST["ACTION"]);
            $title = i18n("Unknown ACTION!");
            $message = "'<a href=\"./index.php\">" . i18n("Click here to redirect to the home page now.") . "</a>'";
            $referer = "./index.php";
        }
    }
}
echo "\t\tvar msgArray = [" . $message . "];\n";
if ($t > 0) {
    echo "\t\tBODY.ShowCountdown(\"" . $title . "\", msgArray, " . $t . ", \"" . $referer . "\");\n";
} else {
    echo "\t\tBODY.ShowMessage(\"" . $title . "\", msgArray);\n";
}
?>
	},
	OnUnload: function() {},
Example #25
0
function verify_dynamic_setting($path)
{
    $rip = query($path . "/rip");
    TRACE_debug("FATLADY: ROUTE6.DYNAMIC: rip=" . $rip);
    return "OK";
}
    $path_phyinf_wlan = XNODE_getpathbytarget("", "phyinf", "uid", $WLAN2_GZ, 0);
}
TRACE_debug("path_phyinf_wlan=" . $path_phyinf_wlan);
$path_wlan_wifi = XNODE_getpathbytarget("/wifi", "entry", "uid", query($path_phyinf_wlan . "/wifi"), 0);
if ($radioID != "2.4GHZ" && $radioID != "5GHZ" && $radioID != "RADIO_24GHz" && $radioID != "RADIO_5GHz" && $radioID != "RADIO_2.4GHz" && $radioID != "RADIO_2.4G_Guest" && $radioID != "RADIO_5G_Guest") {
    $result = "ERROR_BAD_RADIO";
} else {
    $result = "OK";
    $channel = query($path_phyinf_wlan . "/media/channel");
    if (query($path_phyinf_wlan . "/active") == "1" && query($path_phyinf_wlan . "/media/channel") == "0") {
        //update channel value when autochannel setup for HNAP Spec.
        //$channel=query("/runtime/stats/wireless/channel");
        $channel = "0";
    }
    $wlanMode = query($path_phyinf_wlan . "/media/wlmode");
    TRACE_debug("wlanMode=" . $wlanMode);
    if ($wlanMode == "b") {
        $wlanStr = "802.11b";
    } else {
        if ($wlanMode == "g") {
            $wlanStr = "802.11g";
        } else {
            if ($wlanMode == "bg") {
                $wlanStr = "802.11bg";
            } else {
                if ($wlanMode == "n") {
                    $wlanStr = "802.11n";
                } else {
                    if ($wlanMode == "bn") {
                        $wlanStr = "802.11bn";
                    } else {
Example #27
0
function changes_default_tz($country)
{
    if ($country != "") {
        TRACE_debug("changes_default_tz(): country=" . $country);
        if ($country == "AU") {
            set("/device/time/timezone", "67");
        } else {
            if ($country == "CA") {
                set("/device/time/timezone", "14");
            } else {
                if ($country == "CN") {
                    set("/device/time/timezone", "57");
                } else {
                    if ($country == "SG") {
                        set("/device/time/timezone", "58");
                    } else {
                        if ($country == "TW") {
                            set("/device/time/timezone", "60");
                        } else {
                            if ($country == "US" || $country == "NA") {
                                set("/device/time/timezone", "14");
                            } else {
                                if ($country == "LA") {
                                    set("/device/time/timezone", "11");
                                } else {
                                    if ($country == "EU" || $country == "GB") {
                                        set("/device/time/timezone", "28");
                                    } else {
                                        if ($country == "IL") {
                                            set("/device/time/timezone", "38");
                                        } else {
                                            if ($country == "KR") {
                                                set("/device/time/timezone", "64");
                                            } else {
                                                if ($country == "JP") {
                                                    set("/device/time/timezone", "63");
                                                } else {
                                                    if ($country == "EG") {
                                                        set("/device/time/timezone", "35");
                                                    } else {
                                                        if ($country == "BR") {
                                                            set("/device/time/timezone", "20");
                                                        } else {
                                                            if ($country == "RU") {
                                                                set("/device/time/timezone", "45");
                                                            } else {
                                                                if ($country == "DI") {
                                                                    set("/device/time/timezone", "11");
                                                                } else {
                                                                    TRACE_error("changes_default_tz(): Error unknow country code.");
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #28
0
<?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");
}
Example #29
0
<?php

include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
TRACE_debug("COUNT=" . $COUNT);
TRACE_debug("PREFIX=" . $PREFIX);
if ($COUNT == 0) {
    set($PREFIX . "/statue", "0");
    set("/runtime/session/function", "1");
} else {
    /*invalid parameter*/
    set($PREFIX . "/statue", "7");
}
Example #30
0
    if ($_GLOBALS["AUTHORIZED_GROUP"] < 0) {
        return 0;
    }
    return 1;
}
if ($_POST["CACHE"] == "true") {
    echo dump(1, "/runtime/session/" . $SESSION_UID . "/postxml");
} else {
    if (is_power_user() == 1) {
        /* cut_count() will return 0 when no or only one token. */
        $SERVICE_COUNT = cut_count($_POST["SERVICES"], ",");
        TRACE_debug("GETCFG: got " . $SERVICE_COUNT . " service(s): " . $_POST["SERVICES"]);
        $SERVICE_INDEX = 0;
        while ($SERVICE_INDEX < $SERVICE_COUNT) {
            $GETCFG_SVC = cut($_POST["SERVICES"], $SERVICE_INDEX, ",");
            TRACE_debug("GETCFG: serivce[" . $SERVICE_INDEX . "] = " . $GETCFG_SVC);
            if ($GETCFG_SVC != "") {
                $file = "/htdocs/webinc/getcfg/" . $GETCFG_SVC . ".xml.php";
                /* GETCFG_SVC will be passed to the child process. */
                if (isfile($file) == "1") {
                    dophp("load", $file);
                }
            }
            $SERVICE_INDEX++;
        }
    } else {
        /* not a power user, return error message */
        echo "\t<result>FAILED</result>\n";
        echo "\t<message>Not authorized</message>\n";
    }
}