コード例 #1
0
ファイル: cmum.php プロジェクト: grimelinse/cmum
function genxml($genxmlkey, $reqip, $option)
{
    if (file_exists("config.php")) {
        require "config.php";
    } else {
        require "../config.php";
    }
    $dogen = "";
    $xmlout = "";
    $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
    $genxmlkey = $mysqli->real_escape_string($genxmlkey);
    $opts = explode(";", $option);
    $sql = $mysqli->query("SELECT genxmlkey,genxmlusrgrp,genxmllogreq,genxmldateformat,extrausrtbl FROM settings WHERE id='1'");
    $setres = $sql->fetch_array();
    if ($setres["genxmlkey"] != "") {
        if ($setres["genxmlkey"] == $genxmlkey) {
            $dogen = "1";
            if ($setres["genxmllogreq"] == "1") {
                $mysqli->query("INSERT INTO log_genxmlreq (status,ip,genxmlkey) VALUES ('0','" . $reqip . "','')");
            }
        } else {
            if ($setres["genxmllogreq"] == "1" || $setres["genxmllogreq"] == "2") {
                $mysqli->query("INSERT INTO log_genxmlreq (status,ip,genxmlkey) VALUES ('1','" . $reqip . "','" . $genxmlkey . "')");
            }
        }
    } elseif ($setres["genxmlkey"] == "") {
        $dogen = "1";
        if ($setres["genxmllogreq"] == "1") {
            $mysqli->query("INSERT INTO log_genxmlreq (status,ip,genxmlkey) VALUES ('0','" . $reqip . "','')");
        }
    }
    if ($dogen == "1") {
        $enabledgroups = enabledgroups();
        $intstrexp = checksetting("genxmlintstrexp");
        $xmlout = "<xml-user-manager ver=\"1.0\">\n";
        $profvalues = "";
        $usql = $mysqli->query("SELECT user,password,displayname,ipmask,profiles,maxconn,admin,enabled,mapexclude,debug,email,customvalues,ecmrate,startdate,expiredate,usrgroup FROM users");
        while ($usrdata = $usql->fetch_array()) {
            $profres = "";
            if ($usrdata["profiles"] == "") {
                $profres = "";
            } else {
                $dbprof = unserialize($usrdata["profiles"]);
                $profdata = getprofiles();
                if ($dbprof != "" && $dbprof != "N;") {
                    foreach ($dbprof as $useprof) {
                        $profvalues .= $profdata[$useprof] . " ";
                    }
                    $profres = trim($profvalues);
                    $profdata = "";
                    $profvalues = "";
                } else {
                    $profres = "";
                }
            }
            if (in_array("nousername", $opts)) {
                $username = "";
            } else {
                $username = xmloutformat("name", $usrdata["user"]);
            }
            if (in_array("nopassword", $opts)) {
                $password = "";
            } else {
                $password = xmloutformat("password", $usrdata["password"]);
            }
            if (in_array("nodisplayname", $opts)) {
                $displayname = "";
            } else {
                if ($setres["genxmlusrgrp"] == "1") {
                    $displayname = xmloutformatwusrgrp("display-name", $usrdata["displayname"], $usrdata["usrgroup"]);
                } else {
                    $displayname = xmloutformat("display-name", $usrdata["displayname"]);
                }
            }
            if (in_array("noipmask", $opts)) {
                $ipmask = "";
            } else {
                $ipmask = xmloutformat("ip-mask", $usrdata["ipmask"]);
            }
            if (in_array("noprofiles", $opts)) {
                $profiles = "";
            } else {
                $profiles = xmloutformat("profiles", $profres);
            }
            if (in_array("nomaxconnections", $opts)) {
                $maxconn = "";
            } else {
                $maxconn = xmloutformat("max-connections", $usrdata["maxconn"]);
            }
            if (in_array("noadmin", $opts)) {
                $admin = "";
            } else {
                $admin = xmloutformat("admin", numbertotf($usrdata["admin"]));
            }
            if (in_array("noenabled", $opts)) {
                $enabled = "";
            } else {
                if (!in_array($usrdata["usrgroup"], $enabledgroups)) {
                    $enabled = xmloutformat("enabled", "false");
                } elseif ($intstrexp == "1") {
                    $usrexp = checkstartexpire($usrdata["startdate"], $usrdata["expiredate"], $usrdata["enabled"]);
                    if ($usrexp == "0") {
                        $enabled = xmloutformat("enabled", "false");
                    } elseif ($usrexp == "1") {
                        $enabled = xmloutformat("enabled", "true");
                    } elseif ($usrexp == "2") {
                        $enabled = xmloutformat("enabled", "false");
                    } elseif ($usrexp == "3") {
                        $enabled = xmloutformat("enabled", "false");
                    } else {
                        $enabled = xmloutformat("enabled", numbertotf($usrdata["enabled"]));
                    }
                } else {
                    $enabled = xmloutformat("enabled", numbertotf($usrdata["enabled"]));
                }
            }
            if (in_array("nomapexclude", $opts)) {
                $mapexclude = "";
            } else {
                $mapexclude = xmloutformat("map-exclude", numbertotf($usrdata["mapexclude"]));
            }
            if (in_array("nodebug", $opts)) {
                $debug = "";
            } else {
                $debug = xmloutformat("debug", numbertotf($usrdata["debug"]));
            }
            if (in_array("noemail", $opts)) {
                $email = "";
            } else {
                $email = xmloutformat("email-address", $usrdata["email"]);
            }
            if (in_array("nostartdate", $opts) || $intstrexp == "1") {
                $startdate = "";
            } else {
                $startdate = xmloutformat("start-date", formatdate($setres["genxmldateformat"], $usrdata["startdate"]));
            }
            if (in_array("noexpiredate", $opts) || $intstrexp == "1") {
                $expiredate = "";
            } else {
                $expiredate = xmloutformat("expire-date", formatdate($setres["genxmldateformat"], $usrdata["expiredate"]));
            }
            if (in_array("nocustomvalues", $opts)) {
                $customvalues = "";
            } else {
                $customvalues = $usrdata["customvalues"];
            }
            $xmlout .= "<user " . $username . $password . $displayname . $ipmask . $profiles . $maxconn . $admin . $enabled . $mapexclude . $debug . $email . $startdate . $expiredate . $customvalues . "/>\n";
        }
        $xmlout .= "</xml-user-manager>";
    }
    mysqli_close($mysqli);
    return $xmlout;
}
コード例 #2
0
ファイル: users.php プロジェクト: grimelinse/cmum
        $sql = $mysqli->query("SELECT * FROM users WHERE (user LIKE '%" . $searchstring . "%' OR password LIKE '%" . $searchstring . "%' OR displayname LIKE '%" . $searchstring . "%' OR ipmask LIKE '%" . $searchstring . "%' OR mapexclude LIKE '%" . $searchstring . "%' OR comment LIKE '%" . $searchstring . "%' OR email LIKE '%" . $searchstring . "%' OR boxtype LIKE '%" . $searchstring . "%' OR macaddress LIKE '%" . $searchstring . "%' OR serialnumber LIKE '%" . $searchstring . "%') ORDER BY " . $setres["usrorderby"] . " " . $setres["usrorder"]);
    } else {
        $sql = $mysqli->query("SELECT id,user,password,displayname,usrgroup,admin,enabled,startdate,expiredate,addedby FROM users ORDER BY " . $setres["usrorderby"] . " " . $setres["usrorder"]);
    }
} elseif ($_SESSION[$secretkey . "userlvl"] == "2" && $_SESSION[$secretkey . "usergrp"] != "0") {
    if (isset($_POST["searchfor"]) && $_POST["searchfor"] != "") {
        $searchstring = $mysqli->real_escape_string(trim($_POST["searchfor"]));
        $sql = $mysqli->query("SELECT * FROM users WHERE (user LIKE '%" . $searchstring . "%' OR password LIKE '%" . $searchstring . "%' OR displayname LIKE '%" . $searchstring . "%' OR ipmask LIKE '%" . $searchstring . "%' OR mapexclude LIKE '%" . $searchstring . "%' OR comment LIKE '%" . $searchstring . "%' OR email LIKE '%" . $searchstring . "%' OR boxtype LIKE '%" . $searchstring . "%' OR macaddress LIKE '%" . $searchstring . "%' OR serialnumber LIKE '%" . $searchstring . "%') AND usrgroup='" . $_SESSION[$secretkey . "usergrp"] . "' ORDER BY " . $setres["usrorderby"] . " " . $setres["usrorder"]);
    } else {
        $sql = $mysqli->query("SELECT id,user,password,displayname,usrgroup,admin,enabled,startdate,expiredate,addedby FROM users WHERE usrgroup='" . $mysqli->real_escape_string($_SESSION[$secretkey . "usergrp"]) . "' ORDER BY " . $setres["usrorderby"] . " " . $setres["usrorder"]);
    }
} else {
    $sql = "";
}
while ($res = $sql->fetch_array()) {
    $usrexp = checkstartexpire($res["startdate"], $res["expiredate"], $res["enabled"]);
    print "<tr>";
    if ($res["admin"] == "1") {
        print "<td>" . $res["user"] . " <span class=\"label label-warning\">A</span></td>";
    } else {
        print "<td>" . $res["user"] . "</td>";
    }
    print "<td>" . $res["displayname"] . "</td>";
    if ($setres["extrausrtbl"] == "1") {
        print "<td>" . $res["password"] . "</td>";
    } elseif ($setres["extrausrtbl"] == "2") {
        print "<td>" . printdate($res["startdate"]) . "</td>";
    } elseif ($setres["extrausrtbl"] == "3") {
        print "<td>" . printdate($res["expiredate"]) . "</td>";
    } elseif ($setres["extrausrtbl"] == "4") {
        print "<td>" . idtoadmin($res["addedby"]) . "</td>";