示例#1
0
function changeText($sValue)
{
    // decode submitted data
    $errText = "";
    $sValue_array = explode("~~|~~", $sValue);
    $sCell = explode("__", $sValue_array[1]);
    // strip bad stuff
    $parsedInput = htmlspecialchars($sValue_array[0], ENT_QUOTES);
    //update DB
    if ($sCell[0]) {
        $sql = @mysql_query("UPDATE dns_records SET {$sCell['1']}= '{$parsedInput}' WHERE rid = " . ToDBString($sCell[0], true));
        $err = mysql_errno();
        $errText .= updateSerial($sCell[0]);
    }
    // create string to return to the page
    if ($err != 0) {
        $errText .= "MySQL Error: " . mysql_error();
    }
    $newText = '<div onclick="editCell(\'' . $sValue_array[1] . '\', this);">' . $parsedInput . '</div>~~|~~' . $sValue_array[1] . '~~|~~' . $errText;
    return $newText;
}
示例#2
0
if (!isset($dbr['id']) || !isset($dbr['password']) || $dbr['id'] != $USERNAME || crypt($PASSWORD, $dbr['password']) != $dbr['password']) {
    syslog(LOG_NOTICE, "Auth error by user {$USERNAME} for {$HOSTNAME}");
    authFail();
}
$dbh = $db->prepare('SELECT content FROM records WHERE name=:name');
$dbh->bindparam(':name', $HOSTNAME);
$dbh->execute();
$dbr = $dbh->fetch(PDO::FETCH_LAZY);
if ($dbr['content'] !== $IP) {
    $dbh = $db->prepare('UPDATE records SET content=:content WHERE name=:name');
    // $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbh->bindparam(':content', $IP);
    $dbh->bindparam(':name', $HOSTNAME);
    $dbh->execute();
    syslog(LOG_INFO, "IP update by {$USERNAME} for {$HOSTNAME} from {$dbr['content']} to {$IP}");
    updateSerial();
} else {
    syslog(LOG_DEBUG, "IP update attempt by {$USERNAME} for {$HOSTNAME}. No update necessary.");
}
echo 'Success.';
// $dbh->debugDumpParams();
function authFail()
{
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    exit(1);
}
function updateSerial()
{
    global $db;
    $dbh = $db->prepare("SELECT content FROM records WHERE type='SOA'");