コード例 #1
0
ファイル: edit.php プロジェクト: alex1702/poweradmin
global $pdnssec_use;
$zone_id = "-1";
if (isset($_GET['id']) && v_num($_GET['id'])) {
    $zone_id = $_GET['id'];
}
if ($zone_id == "-1") {
    error(ERR_INV_INPUT);
    include_once "inc/footer.inc.php";
    exit;
}
if (isset($_POST['commit'])) {
    $error = false;
    $one_record_changed = false;
    if (isset($_POST['record'])) {
        foreach ($_POST['record'] as $record) {
            $old_record_info = get_record_from_id($record['rid']);
            // Check if a record changed and save the state
            $log = new RecordLog();
            $log->log_prior($record['rid']);
            if (!$log->has_changed($record)) {
                continue;
            } else {
                $one_record_changed = true;
            }
            $edit_record = edit_record($record);
            if (false === $edit_record) {
                $error = true;
            } else {
                // Log the state after saving and write it to logging table
                $log->log_after($record['rid']);
                $log->write();
コード例 #2
0
ファイル: edit_record.php プロジェクト: cengjing/poweradmin
            success(SUC_RECORD_UPD);
            $new_record_info = get_record_from_id($_POST["rid"]);
            log_info(sprintf('client_ip:%s user:%s operation:edit_record' . ' old_record_type:%s old_record:%s old_content:%s old_ttl:%s old_priority:%s' . ' record_type:%s record:%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $old_record_info['type'], $old_record_info['name'], $old_record_info['content'], $old_record_info['ttl'], $old_record_info['prio'], $new_record_info['type'], $new_record_info['name'], $new_record_info['content'], $new_record_info['ttl'], $new_record_info['prio']));
            if ($pdnssec_use) {
                if (dnssec_rectify_zone($zid)) {
                    success(SUC_EXEC_PDNSSEC_RECTIFY_ZONE);
                }
            }
        }
    }
}
echo "    <h2>" . _('Edit record in zone') . " \"<a href=\"edit.php?id=" . $zid . "\">" . $zone_name . "</a>\"</h2>\n";
if ($perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0") {
    error(ERR_PERM_VIEW_RECORD);
} else {
    $record = get_record_from_id($_GET["id"]);
    echo "     <form method=\"post\" action=\"edit_record.php?domain=" . $zid . "&amp;id=" . $_GET["id"] . "\">\n";
    echo "      <table>\n";
    echo "       <tr>\n";
    echo "        <th>" . _('Name') . "</th>\n";
    echo "        <th>&nbsp;</th>\n";
    echo "        <th>" . _('Type') . "</th>\n";
    echo "        <th>" . _('Content') . "</th>\n";
    echo "        <th>" . _('Priority') . "</th>\n";
    echo "        <th>" . _('TTL') . "</th>\n";
    echo "       </tr>\n";
    /*
     Sanitize content due to SPF record quoting in PowerDNS
    */
    if ($record['type'] == "SRV" || $record['type'] == "SPF" || $record['type'] == "TXT") {
        $clean_content = trim($record['content'], "\"'");
コード例 #3
0
ファイル: edit.php プロジェクト: anirut/poweradmin
}
if ($zone_id == "-1") {
    error(ERR_INV_INPUT);
    include_once "inc/footer.inc.php";
    exit;
}
if (isset($_POST['commit'])) {
    $error = false;
    if (isset($_POST['record'])) {
        foreach ($_POST['record'] as $record) {
            $old_record_info = get_record_from_id($record['rid']);
            $edit_record = edit_record($record);
            if (false === $edit_record) {
                $error = true;
            } else {
                $new_record_info = get_record_from_id($record["rid"]);
                //Figure out if record was updated
                unset($new_record_info["change_date"]);
                unset($old_record_info["change_date"]);
                if ($new_record_info != $old_record_info) {
                    //The record was changed, so log the edit_record operation
                    log_info(sprintf('client_ip:%s user:%s operation:edit_record' . ' old_record_type:%s old_record:%s old_content:%s old_ttl:%s old_priority:%s' . ' record_type:%s record:%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $old_record_info['type'], $old_record_info['name'], $old_record_info['content'], $old_record_info['ttl'], $old_record_info['prio'], $new_record_info['type'], $new_record_info['name'], $new_record_info['content'], $new_record_info['ttl'], $new_record_info['prio']));
                }
            }
        }
    }
    edit_zone_comment($_GET['id'], $_POST['comment']);
    if (false === $error) {
        update_soa_serial($_GET['id']);
        success(SUC_ZONE_UPD);
        if ($pdnssec_use) {
コード例 #4
0
ファイル: record.inc.php プロジェクト: cengjing/poweradmin
/** Get all records from a domain id.
 *
 * Retrieve all fields of the records and send it back to the function caller.
 *
 * @param int $id Domain ID
 * @param int $rowstart Starting row [default=0]
 * @param int $rowamount Number of rows to return in this query [default=999999]
 * @param string $sortby Column to sort by [default='name']
 *
 * @return int|mixed[] array of record detail, or -1 if nothing found
 */
function get_records_from_domain_id($id, $rowstart = 0, $rowamount = 999999, $sortby = 'name')
{
    global $db;
    global $db_type;
    $result = array();
    if (is_numeric($id)) {
        if (isset($_SESSION[$id . "_ispartial"]) && $_SESSION[$id . "_ispartial"] == 1) {
            $db->setLimit($rowamount, $rowstart);
            $result = $db->query("SELECT record_owners.record_id as id\n\t\t\t\t\tFROM record_owners,domains,records\n\t\t\t\t\tWHERE record_owners.user_id = " . $db->quote($_SESSION["userid"], 'integer') . "\n\t\t\t\t\tAND record_owners.record_id = records.id\n\t\t\t\t\tAND records.domain_id = " . $db->quote($id, 'integer') . "\n\t\t\t\t\tGROUP BY record_owners.record_id ORDER BY records." . $sortby);
            $ret = array();
            if ($result) {
                $ret[] = array();
                $retcount = 0;
                while ($r = $result->fetchRow()) {
                    // Call get_record_from_id for each row.
                    $fields = get_record_from_id($r["id"]);
                    if ($fields == -1) {
                        continue;
                    }
                    $ret[$retcount] = $fields;
                    $retcount++;
                }
                $result = $ret;
            } else {
                return -1;
            }
        } else {
            $db->setLimit($rowamount, $rowstart);
            $natural_sort = 'LENGTH(records.name), records.name';
            if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'sqlite' || $db_type == 'sqlite3') {
                $natural_sort = 'records.name+0<>0 DESC, records.name+0, records.name';
            }
            $sql_sortby = $sortby == 'name' ? $natural_sort : $sortby . ', ' . $natural_sort;
            $result = $db->query("SELECT id FROM records WHERE domain_id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL ORDER BY " . $sql_sortby);
            $ret = array();
            if ($result) {
                $ret[] = array();
                $retcount = 0;
                while ($r = $result->fetchRow()) {
                    // Call get_record_from_id for each row.
                    $fields = get_record_from_id($r["id"]);
                    if ($fields == -1) {
                        continue;
                    }
                    $ret[$retcount] = $fields;
                    $retcount++;
                }
                $result = $ret;
            } else {
                return -1;
            }
            $result = order_domain_results($result, $sortby);
            return $result;
        }
    } else {
        error(sprintf(ERR_INV_ARG, "get_records_from_domain_id"));
    }
}
if ($record_id == "-1") {
    error(ERR_INV_INPUT);
} else {
    if ($confirm == '1') {
        if (delete_record($record_id)) {
            success("<a href=\"edit.php?id=" . $zid . "\">" . SUC_RECORD_DEL . "</a>");
            /*
            update serial after record deletion
            */
            update_soa_serial($zid);
        }
    } else {
        $zone_id = recid_to_domid($record_id);
        $zone_name = get_zone_name_from_id($zone_id);
        $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
        $record_info = get_record_from_id($record_id);
        echo "     <h2>" . _('Delete record in zone') . " \"<a href=\"edit.php?id=" . $zid . "\">" . $zone_name . "</a>\"</h2>\n";
        if ($zone_info['type'] == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0") {
            error(ERR_PERM_EDIT_RECORD);
        } else {
            echo "     <table>\n";
            echo "      <tr>\n";
            echo "       <th>Name</th>\n";
            echo "       <th>Type</th>\n";
            echo "       <th>Content</th>\n";
            if (isset($record_info['priority'])) {
                echo "       <th>Priority</th>\n";
            }
            echo "       <th>TTL</th>\n";
            echo "      </tr>\n";
            echo "      <tr>\n";
function get_records_from_domain_id($id, $rowstart = 0, $rowamount = 999999, $sortby = 'name')
{
    global $db;
    $result = array();
    if (is_numeric($id)) {
        if (isset($_SESSION[$id . "_ispartial"]) && $_SESSION[$id . "_ispartial"] == 1) {
            $db->setLimit($rowamount, $rowstart);
            $result = $db->query("SELECT record_owners.record_id as id\n\t\t\t\t\tFROM record_owners,domains,records\n\t\t\t\t\tWHERE record_owners.user_id = " . $db->quote($_SESSION["userid"], 'integer') . "\n\t\t\t\t\tAND record_owners.record_id = records.id\n\t\t\t\t\tAND records.domain_id = " . $db->quote($id, 'integer') . "\n\t\t\t\t\tGROUP BY record_owners.record_id ORDER BY records." . $sortby);
            $ret = array();
            if ($result->numRows() == 0) {
                return -1;
            } else {
                $ret[] = array();
                $retcount = 0;
                while ($r = $result->fetchRow()) {
                    // Call get_record_from_id for each row.
                    $ret[$retcount] = get_record_from_id($r["id"]);
                    $retcount++;
                }
                $result = $ret;
            }
        } else {
            $db->setLimit($rowamount, $rowstart);
            $result = $db->query("SELECT id FROM records WHERE domain_id=" . $db->quote($id, 'integer') . " ORDER BY records." . $sortby);
            $ret = array();
            if ($result->numRows() == 0) {
                return -1;
            } else {
                $ret[] = array();
                $retcount = 0;
                while ($r = $result->fetchRow()) {
                    // Call get_record_from_id for each row.
                    $ret[$retcount] = get_record_from_id($r["id"]);
                    $retcount++;
                }
                $result = $ret;
            }
            $result = order_domain_results($result, $sortby);
            return $result;
        }
    } else {
        error(sprintf(ERR_INV_ARG, "get_records_from_domain_id"));
    }
}
コード例 #7
0
 private function getRecord($rid)
 {
     return get_record_from_id($rid);
 }