예제 #1
0
파일: avssfunc.php 프로젝트: sivann/avss
function db_exec($dbh, $sql, $skipauth = 0, $skiphist = 0, &$wantlastid = 0)
{
    global $authstatus, $userdata, $remaddr, $dblogsize, $errorstr, $errorbt;
    if (!$skipauth && !$authstatus) {
        $errstr = "<big><b>Not logged in</b></big><br>";
        return 0;
    }
    if (stristr($sql, "insert ")) {
        $skiphist = 1;
    }
    //for lastid function to work.
    $r = $dbh->exec($sql);
    $error = $dbh->errorInfo();
    if ($error[0] && isset($error[2])) {
        $errorstr = "<br><b>db_exec:db Error: ({$sql}): " . $error[2] . "<br></b>";
        $errorbt = debug_backtrace();
        logerr("{$errorstr} BACKTRACE:" . $errorbt);
        return 0;
    }
    $wantlastid = $dbh->lastInsertId();
    return $r;
}
예제 #2
0
function proc_mailing(&$id, &$mailing)
{
    global $output, $mailings, $ts_regex, $id_regex, $email_regex, $from_email_regex, $to_email_regex, $single_host, $host_regex, $host_regex_noh, $user_regex, $proto_regex, $enc_regex, $auth_regex, $size_regex;
    $from_regex = "/({$ts_regex})\\s*{$id_regex}\\s*\\<\\=\\s*{$from_email_regex}\\s*(?:R\\=[\\w\\d\\-]+)?\\s*{$user_regex}\\s*{$host_regex}?\\s*{$proto_regex}\\s*{$enc_regex}\\s*{$auth_regex}\\s*{$size_regex}/";
    $matches = array();
    if (preg_match($from_regex, $mailing['from'], $matches) > 0) {
        $o = array();
        $o['id'] = $id;
        $o['ts'] = $matches[1];
        $o['from_email'] = $matches[2];
        $o['to_email'] = "DEFERRED";
        $o['to_host'] = "DEFERRED";
        $from_ip = $matches[6];
        if ($from_ip == "") {
            $from_ip = $matches[5];
        }
        $o['from_ip'] = $from_ip;
        $o['auth'] = $matches[9];
        $o['size'] = $matches[10];
        $to_regex = "/{$ts_regex}\\s*{$id_regex}\\s*(?:\\=|\\-)\\>\\s*{$to_email_regex}\\s*/";
        foreach ($mailing['to'] as $mailto) {
            $matches = array();
            if (preg_match($to_regex, $mailto, $matches) > 0) {
                $email = $matches[1];
                if ($email == "") {
                    $email = $matches[2];
                }
                $o['to_email'] = $email;
                $output[] = $o;
            } else {
                logerr("FAIL ON TO: " . $mailto);
            }
        }
    } else {
        logerr("FAIL ON FROM: " . $mailing['from']);
    }
}
예제 #3
0
include_once "dertyn.php";
if ($_POST['checksubmit']) {
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $logincheck = checkLogin($user, $pass);
    if ($logincheck == 0) {
        setLoginCookie($user);
        header("Location: {$siteurl}");
    }
}
include_once "header.php";
echo "<p>\n";
if (!$_POST['checksubmit']) {
    showLoginform();
} else {
    if ($logincheck == 0) {
        echo "thanks for logging in {$user}!<br /><b>return to <a href='{$siteurl}'>{$sitename}</a></b>.";
    } else {
        $errmsg = $user;
        echo "login failed.  try again.";
        logerr($errmsg, "login");
    }
}
echo "</p>\n";
?>

<?php 
include_once "footer.php";
?>

예제 #4
0
function read_from_socket($socket, &$buffer, $count)
{
    global $READ_WRITE_ATTEMPTS;
    $totalCount = 0;
    $retryCount = 0;
    $buffer = "";
    $readBuffer;
    do {
        if ($retryCount > 0) {
            usleep(10000);
            // 10ms
        }
        if (!$socket) {
            break;
        }
        $readBuffer = fread($socket, $count);
        $read = strlen($readBuffer);
        $buffer = $buffer . $readBuffer;
        if ($retryCount > 0) {
            logdebug("Attempt to read #" . ($retryCount + 1) . " Read: " . $read);
        }
        $totalCount += $read;
        $retryCount = $retryCount + 1;
    } while ($totalCount < $count && $retryCount < $READ_WRITE_ATTEMPTS);
    if ($totalCount != $count) {
        logerr("Failed to read from socket {$count} bytes, {$totalCount} actually read.");
    }
    return $totalCount;
}
예제 #5
0
<?php

include_once "header.php";
include_once "db.php";
include_once "dertyn.php";
if (!$_POST['checksubmit']) {
    showForgotform();
} else {
    if ($_POST['checksubmit']) {
        $email = getEmail();
        $user = getUser();
        $postemail = $_POST['email'];
        $postuser = $_POST['user'];
        $errmsg = "user " . $postuser . ",email " . $postemail;
        $errmsg = "ruser " . $user . ",remail " . $email;
        if (strcmp($email, $postemail) == 0 && strcmp($user, $postuser) == 0) {
            sendRandomPass($email);
        } else {
            echo "things didn't match.  <a href=\"forgot.php\">try again</a>!";
            logerr($errmsg, "forgot");
        }
    }
}
?>

<?php 
include_once "footer.php";
?>

예제 #6
0
function db_execute2($dbh, $sql, $params = NULL)
{
    global $errorstr, $errorbt, $errorno;
    $sth = $dbh->prepare($sql);
    $error = $dbh->errorInfo();
    if (((int) $error[0] || (int) $error[1]) && isset($error[2])) {
        $errorstr = "DB Error: ({$sql}): <br>\n" . $error[2] . "<br>\nParameters:" . "params\n";
        //implode(",",$params);
        $errorbt = debug_backtrace();
        $errorno = $error[1] + $error[0];
        logerr("{$errorstr} BACKTRACE:" . $errorbt);
        return 0;
    }
    if (is_array($params)) {
        $sth->execute($params);
    } else {
        $sth->execute();
    }
    $error = $sth->errorInfo();
    if (((int) $error[0] || (int) $error[1]) && isset($error[2])) {
        $errorstr = "DB Error: ({$sql}): <br>\n" . $error[2] . "<br>\nParameters:" . implode(",", $params);
        $errorbt = debug_backtrace();
        $errorno = $error[1] + $error[0];
        logerr("{$errorstr} BACKTRACE:" . $errorbt);
    }
    return $sth;
}