Ejemplo n.º 1
0
function diag_start($col, $row)
{
    $row_r = $row;
    $col_r = $col;
    $col_l = $col;
    $row_l = $row;
    if ($row === Board::ROW - 1) {
        return array('col_l' => $col_l, 'row_l' => $row_l, 'col_r' => $col_r, 'row_r' => $row_r);
    }
    if ($col !== Board::COL - 1) {
        $col_r = $col + 1;
        $row_r = $row + 1;
        while ($col_r < Board::COL - 1 && $row_r < Board::ROW - 1) {
            $col_r++;
            $row_r++;
        }
    }
    if ($col !== 0) {
        $col_l = $col - 1;
        $row_l = $row + 1;
        while ($col_l > 0 && $row_l < Board::ROW - 1) {
            $col_l--;
            $row_l++;
        }
    }
    boundary($col_l, $row_l);
    boundary($col_r, $row_r);
    return array('col_l' => $col_l, 'row_l' => $row_l, 'col_r' => $col_r, 'row_r' => $row_r);
}
Ejemplo n.º 2
0
function qmail($fromname, $fromdomain, $frommail = "", $todomain, $tomail, $subject, $mailbody, $filename = "", $file = "", $eml = "", $date = false)
{
    if (!$date) {
        $date = @date("D, d M y H:i:s", 2147451247) . ' 대한민국표준시';
    } else {
        $date = @mktime();
        $date = @date('D, j M y H:i:s', $date) . ' +0900 대한민국표준시';
    }
    //		$mx_server = "mx1.mail.yahoo.co.kr";
    $mx_server = $todomain;
    $fp = fsockopen($mx_server, 25, &$err_no, &$err_str, 2);
    if (!$fp) {
        $ret_msg[0] = "error: 1. CONNECT - {$err_str}";
        $ret_msg[1] = $err_str;
        fclose($fp);
        return $ret_msg;
    }
    fwrite($fp, "HELO " . $fromdomain . "\r\n");
    $buf = fgets($fp, 100);
    if (substr($buf, 0, 3) != "220") {
        $ret_msg[0] = "error: 2. HELO - {$buf}";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    }
    $fake_mail = strtolower(randname()) . "@" . substr($buf, 4, 26);
    fwrite($fp, "MAIL FROM: <" . $fake_mail . ">\r\n");
    $buf = fgets($fp, 100);
    if (substr($buf, 0, 3) != "250") {
        $ret_msg[0] = "error: 3. MAIL FROM - {$buf}";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    }
    $tomail_list = explode(",", $tomail);
    for ($i = 0; $i < count($tomail_list); ++$i) {
        fwrite($fp, "RCPT TO: <" . $tomail_list[$i] . ">\r\n");
        $buf = fgets($fp, 100);
        if (substr($buf, 0, 3) != "250") {
            $ret_msg[0] = "error: 4. RCPT TO - [" . $tomail_list[$i] . "] " . $buf . "<br>";
            $ret_msg[1] = $buf;
        }
    }
    fwrite($fp, "DATA\r\n");
    $buf = fgets($fp, 100);
    if (substr($buf, 0, 3) != "250") {
        $ret_msg[0] = "error: 5. DATA - {$buf}";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    }
    if ($eml) {
        $linedata = explode("\r\n", $eml);
        $i = 0;
        for (; $i < count($linedata); ++$i) {
            fwrite($fp, $linedata[$i] . "\r\n");
        }
        continue;
    } else {
        $potal = array("hanmail.net", "naver.com", "korea.com", "yahoo.co.kr", "hotmail.com", "yahoo.com", "live.com", "gmail.com", "aol.com", "hotmail.co.kr");
        $fake_mail = strtolower(randname()) . "@" . $potal[rand(0, 9)];
        fwrite($fp, "From: \"" . $fromname . "\" <" . $fake_mail . ">\r\n");
        fwrite($fp, "To: \"" . substr($tomail_list[0], 0, strpos($tomail_list[0], "@")) . "\"<" . $tomail_list[0] . ">\r\n");
        fwrite($fp, "Subject: " . $subject . "\r\n");
        fwrite($fp, "Date: " . $date . "\r\n");
        fwrite($fp, "Message-ID: <" . strtoupper(md5(sha1(microtime()))) . "@" . $fromdomain . ">\r\n");
        fwrite($fp, "Mime-Version: 1.0\r\n");
        if ($filename) {
            $bind = boundary();
            fwrite($fp, "Content-Type: multipart/mixed;\r\n");
            fwrite($fp, "\tboundary=\"" . $bind[0] . "\"\r\n");
        } else {
            fwrite($fp, "Content-Type: text/html;\r\n");
            fwrite($fp, "       charset=\"euc-kr\"\r\n");
        }
        fwrite($fp, "X-Mailer: Microsoft CDO for Windows 2000\r\n");
        fwrite($fp, "Content-Class: urn:content-classes:message\r\n");
        fwrite($fp, "Importance: normal\r\n");
        fwrite($fp, "Priority: normal\r\n");
        fwrite($fp, "X-MimeOLE: Produced By Microsoft MimeOLE V6.00." . rand(3198, 3987) . "." . rand(2190, 4982) . "\r\n");
        if (!$filename) {
            fwrite($fp, "Content-Transfer-Encoding: 8bit\r\n\r\n");
            fwrite($fp, stripslashes(urldecode($mailbody)) . "\r\n");
        } else {
            fwrite($fp, "\r\n");
            fwrite($fp, "This is a multi-part message in MIME format.\r\n\r\n");
            fwrite($fp, "--" . $bind[0] . "\r\n");
            fwrite($fp, "Content-Type: multipart/alternative;\r\n");
            fwrite($fp, "\tboundary=\"" . $bind[1] . "\"\r\n\r\n\r\n");
            fwrite($fp, "--" . $bind[1] . "\r\n");
            fwrite($fp, "Content-Type: text/plain;\r\n");
            fwrite($fp, "\tcharset=\"ks_c_5601-1987\"\r\n");
            fwrite($fp, "Content-Transfer-Encoding: base64\r\n\r\n");
            fwrite($fp, $mailbody . "\r\n\r\n");
            fwrite($fp, "--" . $bind[1] . "\r\n");
            fwrite($fp, "Content-Type: text/html;\r\n");
            fwrite($fp, "\tcharset=\"EUC-KR\"\r\n");
            fwrite($fp, "Content-Transfer-Encoding: base64\r\n\r\n");
            fwrite($fp, $mailbody . "\r\n\r\n");
            fwrite($fp, "--" . $bind[1] . "--\r\n\r\n");
            fwrite($fp, "--" . $bind[0] . "\r\n");
            fwrite($fp, "Content-Type: text/html;\r\n");
            fwrite($fp, "\tname=\"" . $filename . "\"\r\n");
            fwrite($fp, "Content-Transfer-Encoding: base64\r\n");
            fwrite($fp, "Content-Disposition: attachment;\r\n");
            fwrite($fp, "\tfilename=\"" . $filename . "\"\r\n\r\n");
            fwrite($fp, $file . "\r\n\r\n");
            fwrite($fp, "--" . $bind[0] . "--\r\n\r\n");
        }
    }
    fwrite($fp, "\r\n.\r\n");
    $buf = fgets($fp, 100);
    if (substr($buf, 0, 3) != "354") {
        $ret_msg[0] = "error: 6. MAILBODY - {$buf}";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    }
    fwrite($fp, "QUIT\r\n");
    $buf = fgets($fp, 100);
    if (substr($buf, 0, 3) == "250") {
        $ret_msg[0] = "ok! - " . $buf . "\n";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    } else {
        $ret_msg[0] = "error: 7. QUIT - {$buf}";
        $ret_msg[1] = $buf;
        fclose($fp);
        return $ret_msg;
    }
}