Exemplo n.º 1
0
 } else {
     $ds->DbfTransactionStart();
     // move the subnet to another customer, template will move with as relation
     // between base and baseadd is baseindex column
     if ($duplicatesubnet == 0) {
         $result =& $ds->ds->Execute("UPDATE base\n                            SET descrip=" . $ds->ds->qstr($descrip) . ",\n                            admingrp=" . $ds->ds->qstr($grp) . ",\n                            customer={$cust},\n                            lastmod=" . $ds->ds->DBTimeStamp(time()) . ",\n                            userid=" . $ds->ds->qstr($userid) . "\n                            WHERE baseindex={$baseindex}");
         $ds->AuditLog(array("event" => 174, "action" => "move subnet", "user" => getAuthUsername(), "baseaddr" => inet_ntoa($base), "size" => $size, "newcust" => $cust));
     } else {
         // use the first group user belongs to create subnet
         if ($id = $ds->CreateSubnet($base, $size, $descrip, $cust, 0, $grp)) {
             if ($duplicatesubnet == 1) {
                 // subnet created, now move info to new subnet
                 // cant use a temp table here as database does not
                 // have enough rights - don't want to give it anymore
                 // anyway, so we need to do it the hard way
                 $result = $ds->GetSubnetDetails($baseindex);
                 while ($row = $result->FetchRow()) {
                     $tempipaddr = $row["ipaddr"];
                     $tempuser = $row["userinf"];
                     $templocation = $row["location"];
                     $temptelno = $row["telno"];
                     $tempdescrip = $row["descrip"];
                     $templastmod = $row["lastmod"];
                     $tempuserid = $row["userid"];
                     $tempresult =& $ds->ds->Execute("INSERT INTO ipaddr\n                                        (ipaddr, userinf, location, telno,\n                                         descrip, lastmod, userid, baseindex)\n                                        VALUES\n                                        (" . $ds->ds->qstr($tempipaddr) . ",\n                                         " . $ds->ds->qstr($tempuser) . ",\n                                         " . $ds->ds->qstr($templocation) . ",\n                                         " . $ds->ds->qstr($temptelno) . ",\n                                         " . $ds->ds->qstr($tempdescrip) . ",\n                                         {$templastmod},\n                                         " . $ds->ds->qstr($tempuserid) . ",\n                                         {$id})");
                 }
                 // end while
             }
             $ds->AuditLog(array("event" => 170, "action" => "create subnet", "descrip" => $descrip, "user" => getAuthUsername(), "baseaddr" => inet_ntoa($base), "size" => $size, "cust" => $cust));
         }
     }
Exemplo n.º 2
0
function __FetchSubnet($params)
{
    global $xmlrpcerruser;
    // import user errcode value
    // $params is an Array of xmlrpcval objects
    $errstr = "";
    $err = 0;
    if (IPPLAN_API_VER != DBF_API_VER) {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, "Incorrect API version");
    }
    // get the first param
    $baseindexobj = $params->getParam(0);
    // if it's there and the correct type
    if (isset($baseindexobj) && $baseindexobj->scalartyp() == "int") {
        // extract the value of the state number
        $baseindex = $baseindexobj->scalarval();
        if (!($ds = new IPplanDbf())) {
            return new xmlrpcresp(0, $xmlrpcerruser + 1, "Could not connect to database");
        }
        // get info from base table
        $result = $ds->GetSubnetDetails($baseindex);
        while ($row = $result->FetchRow()) {
            $myVal[] = new xmlrpcval(array("ipaddr" => new xmlrpcval(inet_ntoa($row["ipaddr"])), "userinf" => new xmlrpcval($row["userinf"]), "location" => new xmlrpcval($row["location"]), "descrip" => new xmlrpcval($row["descrip"]), "telno" => new xmlrpcval($row["telno"]), "lastmod" => new xmlrpcval($result->UserTimeStamp($row["lastmod"], "M d Y H:i:s"))), "struct");
        }
    } else {
        // parameter mismatch, complain
        $err = 2;
        $errstr = "Incorrect parameters";
    }
    if ($err) {
        // this is an error condition
        return new xmlrpcresp(0, $xmlrpcerruser + 1, $errstr);
    } else {
        // this is a successful value being returned
        return new xmlrpcresp(new xmlrpcval($myVal, "array"));
    }
}