如果什麼認證都要架RADIUS就太麻煩啦!!
在沒有資料庫的狀況下要做到即時認證, 就只有借用其他既有的認證機制囉!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function CheckPOP3($server, $id, $passwd, $port = 110) | |
{ | |
//若任一欄位為空白則無效 | |
if (empty($server) || empty($id) || empty($passwd)) | |
return false; | |
// connect to POP3 Server | |
$fs = fsockopen ($server, $port, &$errno, &$errstr, 5); | |
// check if connection valid | |
if (!$fs) | |
return false; | |
//connected.. | |
$msg = fgets($fs,256); | |
// step 1. send ID | |
fputs($fs, "USER $id\r\n"); | |
$msg = fgets($fs,256); | |
if (strpos($msg,"+OK")===false) | |
return false; | |
// step 2. send password | |
fputs($fs, "PASS $passwd\r\n"); | |
$msg = fgets($fs,256); | |
if (strpos($msg,"+OK")===false) | |
return false; | |
//step 3. auth passwd, QUIT | |
fputs($fs, "QUIT \r\n"); | |
fclose($fs); | |
return true; | |
} | |
?> |
Basic POP3 Command:
- USER 帳號
- PASS 密碼
- STAT 狀態
- UIDL 郵件列表
- RETR 接受郵件
- DELE 刪除
- QUIT 離線