FreeBSD 使用PHP 透過FTP連線拋檔 備份

<?php
define(“FTP_TIMEOUT",90);
// FTP Statuscodes
define(“FTP_COMMAND_OK",200);
define(“FTP_FILE_ACTION_OK",250);
define(“FTP_FILE_TRANSFER_OK",226);
define(“FTP_COMMAND_NOT_IMPLEMENTED",502);
define(“FTP_FILE_STATUS",213);
define(“FTP_NAME_SYSTEM_TYPE",215);
define(“FTP_PASSIVE_MODE",227);
define(“FTP_PATHNAME",257);
define(“FTP_SERVICE_READY",220);
define(“FTP_USER_LOGGED_IN",230);
define(“FTP_PASSWORD_NEEDED",331);
define(“FTP_USER_NOT_LOGGED_IN",530);

if (!defined(“FTP_ASCII")) define(“FTP_ASCII",0);
if (!defined(“FTP_BINARY")) define(“FTP_BINARY",1);

class FTP {

var $passiveMode = TRUE;
var $lastLines = array();
var $lastLine = “";
var $controlSocket = NULL;
var $newResult = FALSE;
var $lastResult = -1;
var $pasvAddr = NULL;

var $error_no = NULL;
var $error_msg = NULL;

function FTP() {
}

function connect($host, $port=21, $timeout=FTP_TIMEOUT) { //Opens an FTP connection
$this->_resetError();

$err_no = 0;
$err_msg = “";
$this->controlSocket = @fsockopen($host, $port, $err_no, $err_msg, $timeout) or $this->_setError(-1,"fsockopen failed");
if ($err_no<>0) $this->setError($err_no,$err_msg);

if ($this->_isError()) return false;

@socket_set_timeout($this->controlSocket,$timeout) or $this->_setError(-1,"socket_set_timeout failed");
if ($this->_isError()) return false;

$this->_waitForResult();
if ($this->_isError()) return false;

return $this->getLastResult() == FTP_SERVICE_READY;
}

function isConnected() {
return $this->controlSocket != NULL;
}

function disconnect() {
if (!$this->isConnected()) return;
@fclose($this->controlSocket);
}

function close() { //Closes an FTP connection
$this->disconnect();
}

function login($user, $pass) { //Logs in to an FTP connection
$this->_resetError();

$this->_printCommand(“USER $user");
if ($this->_isError()) return false;

$this->_waitForResult();
if ($this->_isError()) return false;

if ($this->getLastResult() == FTP_PASSWORD_NEEDED){
$this->_printCommand(“PASS $pass");
if ($this->_isError()) return FALSE;

$this->_waitForResult();
if ($this->_isError()) return FALSE;
}

$result = $this->getLastResult() == FTP_USER_LOGGED_IN;
return $result;
}

function cdup() { //Changes to the parent directory
$this->_resetError();

$this->_printCommand(“CDUP");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function cwd($path) {
$this->_resetError();

$this->_printCommand(“CWD $path");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function cd($path) {
return $this->cwd($path);
}

function chdir($path) { //Changes directories on a FTP server
return $this->cwd($path);
}

function chmod($mode,$filename) { //Set permissions on a file via FTP
return $this->site(“CHMOD $mode $filename");
}

function delete($filename) { //Deletes a file on the FTP server
$this->_resetError();

$this->_printCommand(“DELE $filename");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function exec($cmd) { //Requests execution of a program on the FTP server
return $this->site(“EXEC $cmd");
}

function fget($fp,$remote,$mode=FTP_BINARY,$resumepos=0) { //Downloads a file from the FTP server and saves to an open file
$this->_resetError();

$type = “I";
if ($mode==FTP_ASCII) $type = “A";

$this->_printCommand(“TYPE $type");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;

$result = $this->_download(“RETR $remote");
if ($result) {
fwrite($fp,$result);
}
return $result;
}

function fput($remote,$resource,$mode=FTP_BINARY,$startpos=0) { //Uploads from an open file to the FTP server
$this->_resetError();

$type = “I";
if ($mode==FTP_ASCII) $type = “A";

$this->_printCommand(“TYPE $type");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;

if ($startpos>0) fseek($resource,$startpos);
$result = $this->_uploadResource(“STOR $remote",$resource);
return $result;
}

function get_option($option) { //Retrieves various runtime behaviours of the current FTP stream
$this->_resetError();

switch ($option) {
case “FTP_TIMEOUT_SEC" : return FTP_TIMEOUT;
case “PHP_FTP_OPT_AUTOSEEK" : return FALSE;
}
setError(-1,"Unknown option: $option");
return false;
}

function get($locale,$remote,$mode=FTP_BINARY,$resumepos=0) { //Downloads a file from the FTP server
if (!($fp = @fopen($locale,"wb"))) return FALSE;
$result = $this->fget($fp,$remote,$mode,$resumepos);
@fclose($fp);
if (!$result) @unlink($locale);
return $result;
}
function mdtm($name) { //Returns the last modified time of the given file
$this->_resetError();

$this->_printCommand(“MDTM $name");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
if ($lr!=FTP_FILE_STATUS) return FALSE;
$subject = trim(substr($this->lastLine,4));
$lucifer = array();
if (preg_match(“/([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/",$subject,$lucifer)) return mktime($lucifer[4],$lucifer[5],$lucifer[6],$lucifer[2],$lucifer[3],$lucifer[1],0);
return FALSE;
}

function mkdir($name) { //Creates a directory
$this->_resetError();

$this->_printCommand(“MKD $name");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_PATHNAME || $lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function nb_continue() { //Continues retrieving/sending a file (non-blocking)
$this->_resetError();
// todo
}

function nb_fget() { //Retrieves a file from the FTP server and writes it to an open file (non-blocking)
$this->_resetError();
// todo
}

function nb_fput() { //Stores a file from an open file to the FTP server (non-blocking)
$this->_resetError();
// todo
}

function nb_get() { //Retrieves a file from the FTP server and writes it to a local file (non-blocking)
$this->_resetError();
// todo
}

function nb_put() { //Stores a file on the FTP server (non-blocking)
$this->_resetError();
// todo
}

function nlist($remote_filespec="") { //Returns a list of files in the given directory
$this->_resetError();
$result = $this->_download(trim(“NLST $remote_filespec"));
return ($result !== FALSE) ? explode(“\n",str_replace(“\r","",trim($result))) : $result;
}

function pasv($pasv) { //Turns passive mode on or off
if (!$pasv) {
$this->_setError(“Active (PORT) mode is not supported");
return false;
}
return true;
}

function put($remote,$local,$mode=FTP_BINARY,$startpos=0) { //Uploads a file to the FTP server
if (!($fp = @fopen($local,"rb"))) return FALSE;
$result = $this->fput($remote,$fp,$mode,$startpos);
@fclose($fp);
return $result;
}

function pwd() { //Returns the current directory name
$this->_resetError();

$this->_printCommand(“PWD");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
if ($lr!=FTP_PATHNAME) return FALSE;
$subject = trim(substr($this->lastLine,4));
$lucifer = array();
if (preg_match(“/\"(.*)\"/",$subject,$lucifer)) return $lucifer[1];
return FALSE;
}

function quit() { //Alias of close
$this->close();
}

function raw($cmd) { //Sends an arbitrary command to an FTP server
$this->_resetError();

$this->_printCommand($cmd);
$this->_waitForResult();
$this->getLastResult();
return array($this->lastLine);
}

function rawlist($remote_filespec="") { //Returns a detailed list of files in the given directory
$this->_resetError();
$result = $this->_download(trim(“LIST $remote_filespec"));
return ($result !== FALSE) ? explode(“\n",str_replace(“\r","",trim($result))) : $result;
}

function ls($remote_filespec="") { //Returns a parsed rawlist in an assoc array
$a = $this->rawlist($remote_filespec);
if (!$a) return $a;
$systype = $this->systype();
$is_windows = stristr($systype,"WIN")!==FALSE;
$b = array();
while (list($i,$line) = each($a)) {
if ($is_windows && preg_match(“/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) {
$b[$i] = array();
if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
$b[$i][‘isdir’] = ($lucifer[7]=="<DIR>");
$b[$i][‘size’] = $lucifer[7];
$b[$i][‘month’] = $lucifer[1];
$b[$i][‘day’] = $lucifer[2];
$b[$i][‘year’] = $lucifer[3];
$b[$i][‘hour’] = $lucifer[4];
$b[$i][‘minute’] = $lucifer[5];
$b[$i][‘time’] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
$b[$i][‘am/pm’] = $lucifer[6];
$b[$i][‘name’] = $lucifer[8];
} else if (!$is_windows && $lucifer=preg_split(“/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
echo $line."\n";
$lcount=count($lucifer);
if ($lcount<8) continue;
$b[$i] = array();
$b[$i][‘isdir’] = $lucifer[0]{0} === “d";
$b[$i][‘islink’] = $lucifer[0]{0} === “l";
$b[$i][‘perms’] = $lucifer[0];
$b[$i][‘number’] = $lucifer[1];
$b[$i][‘owner’] = $lucifer[2];
$b[$i][‘group’] = $lucifer[3];
$b[$i][‘size’] = $lucifer[4];
if ($lcount==8) {
sscanf($lucifer[5],"%d-%d-%d",$b[$i][‘year’],$b[$i][‘month’],$b[$i][‘day’]);
sscanf($lucifer[6],"%d:%d",$b[$i][‘hour’],$b[$i][‘minute’]);
$b[$i][‘time’] = @mktime($b[$i][‘hour’],$b[$i][‘minute’],0,$b[$i][‘month’],$b[$i][‘day’],$b[$i][‘year’]);
$b[$i][‘name’] = $lucifer[7];
} else {
$b[$i][‘month’] = $lucifer[5];
$b[$i][‘day’] = $lucifer[6];
if (preg_match(“/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
$b[$i][‘year’] = date(“Y");
$b[$i][‘hour’] = $l2[1];
$b[$i][‘minute’] = $l2[2];
} else {
$b[$i][‘year’] = $lucifer[7];
$b[$i][‘hour’] = 0;
$b[$i][‘minute’] = 0;
}
$b[$i][‘time’] = strtotime(sprintf(“%d %s %d %02d:%02d",$b[$i][‘day’],$b[$i][‘month’],$b[$i][‘year’],$b[$i][‘hour’],$b[$i][‘minute’]));
$b[$i][‘name’] = $lucifer[8];
}
}
}
return $b;
}

function rename($from,$to) { //Renames a file on the FTP server
$this->_resetError();

$this->_printCommand(“RNFR $from");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
$this->_printCommand(“RNTO $to");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function rmdir($name) { //Removes a directory
$this->_resetError();

$this->_printCommand(“RMD $name");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return ($lr==FTP_FILE_ACTION_OK || $lr==FTP_COMMAND_OK);
}

function set_option() { //Set miscellaneous runtime FTP options
$this->_resetError();
$this->_setError(-1,"set_option not supported");
return false;
}

function site($cmd) { //Sends a SITE command to the server
$this->_resetError();

$this->_printCommand(“SITE $cmd");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return true;
}

function size($name) { //Returns the size of the given file
$this->_resetError();

$this->_printCommand(“SIZE $name");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return $lr==FTP_FILE_STATUS ? trim(substr($this->lastLine,4)) : FALSE;
}

function ssl_connect() { //Opens an Secure SSL-FTP connection
$this->_resetError();
$this->_setError(-1,"ssl_connect not supported");
return false;
}

function systype() { // Returns the system type identifier of the remote FTP server
$this->_resetError();

$this->_printCommand(“SYST");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
return $lr==FTP_NAME_SYSTEM_TYPE ? trim(substr($this->lastLine,4)) : FALSE;
}

function getLastResult() {
$this->newResult = FALSE;
return $this->lastResult;
}

/* private */
function _hasNewResult() {
return $this->newResult;
}

/* private */
function _waitForResult() {
while(!$this->_hasNewResult() && $this->_readln()!==FALSE && !$this->_isError()) { /* noop */ }
}

/* private */
function _readln() {
$line = fgets($this->controlSocket);
if ($line === FALSE) {
$this->_setError(-1,"fgets failed in _readln");
return FALSE;
}
if (strlen($line)==0) return $line;

$lucifer = array();
if (preg_match(“/^[0-9][0-9][0-9] /",$line,$lucifer)) {
//its a resultline
$this->lastResult = intval($lucifer[0]);
$this->newResult = TRUE;
if (substr($lucifer[0],0,1)==’5′) {
$this->_setError($this->lastResult,trim(substr($line,4)));
}
}

$this->lastLine = trim($line);
$this->lastLines[] = “< “.trim($line);
return $line;
}

/* private */
function _printCommand($line) {
$this->lastLines[] = “> “.$line;
fwrite($this->controlSocket,$line."\r\n");
fflush($this->controlSocket);
}

/* private */
function _pasv() {
$this->_resetError();
$this->_printCommand(“PASV");
$this->_waitForResult();
$lr = $this->getLastResult();
if ($this->_isError()) return FALSE;
if ($lr!=FTP_PASSIVE_MODE) return FALSE;
$subject = trim(substr($this->lastLine,4));
$lucifer = array();
if (preg_match(“/\\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\\)/",$subject,$lucifer)) {
$this->pasvAddr=$lucifer;

$host = sprintf(“%d.%d.%d.%d",$lucifer[1],$lucifer[2],$lucifer[3],$lucifer[4]);
$port = $lucifer[5]*256 + $lucifer[6];

$err_no=0;
$err_msg="";
$passiveConnection = fsockopen($host,$port,$err_no,$err_msg, FTP_TIMEOUT);
if ($err_no!=0) {
$this->_setError($err_no,$err_msg);
return FALSE;
}

return $passiveConnection;
}
return FALSE;
}

/* private */
function _download($cmd) {
if (!($passiveConnection = $this->_pasv())) return FALSE;
$this->_printCommand($cmd);
$this->_waitForResult();
$lr = $this->getLastResult();
if (!$this->_isError()) {
$result = “";
while (!feof($passiveConnection)) {
$result .= fgets($passiveConnection);
}
fclose($passiveConnection);
$this->_waitForResult();
$lr = $this->getLastResult();
return ($lr==FTP_FILE_TRANSFER_OK) || ($lr==FTP_FILE_ACTION_OK) || ($lr==FTP_COMMAND_OK) ? $result : FALSE;
} else {
fclose($passiveConnection);
return FALSE;
}
}

/* upload */
function _uploadResource($cmd,$resource) {
if (!($passiveConnection = $this->_pasv())) return FALSE;
$this->_printCommand($cmd);
$this->_waitForResult();
$lr = $this->getLastResult();
if (!$this->_isError()) {
$result = “";
while (!feof($resource)) {
$buf = fread($resource,1024);
fwrite($passiveConnection,$buf);
}
fclose($passiveConnection);
$this->_waitForResult();
$lr = $this->getLastResult();
return ($lr==FTP_FILE_TRANSFER_OK) || ($lr==FTP_FILE_ACTION_OK) || ($lr==FTP_COMMAND_OK) ? $result : FALSE;
} else {
fclose($passiveConnection);
return FALSE;
}
}

/* private */
function _resetError() {
$this->error_no = NULL;
$this->error_msg = NULL;
}

/* private */
function _setError($no,$msg) {
if (is_array($this->error_no)) {
$this->error_no[] = $no;
$this->error_msg[] = $msg;
} else if ($this->error_no!=NULL) {
$this->error_no = array($this->error_no,$no);
$this->error_msg = array($this->error_msg,$msg);
} else {
$this->error_no = $no;
$this->error_msg = $msg;
}
}

/* private */
function _isError() {
return ($this->error_no != NULL) && ($this->error_no !== 0);
}

}

//echo “argv[] = “;
//print_r($argv); // just to see what was passed in

if ($argc > 0)
{
for ($i=1;$i < $argc;$i++)
{
parse_str($argv[$i],$tmp);
$_REQUEST = array_merge($_REQUEST, $tmp);
}
}

//echo “\$_REQUEST = “;
//print_r($_REQUEST);

$backup_dir = ‘/var/backup’;
$www= ‘/var/www’;
$db=’/var/db/mysql’;
$etc= ‘/usr/local/etc’;
$dates = date(“Ymd");
$filename_www = $backup_dir.’/’.$dates.’www.tar.gz’;
$filename_db = $backup_dir.’/’.$dates.’db.tar.gz’;
$filename_etc = $backup_dir.’/’.$dates.’etc.tar.gz’;
$ftp_www = $dates.’www.tar.gz’;
$ftp_db = $dates.’db.tar.gz’;
$ftp_etc = $dates.’etc.tar.gz’;
if (file_exists($backup_dir)) {
echo “備份目錄存在 $filename 開始備份 www 備份到 $filename_www \n";
} else {
echo “備份目錄不存在 $backup_dir \n";
mkdir($backup_dir, 755);
echo “\n 備份目錄建立 開始備份 $www 備份到 $filename_www \n";
}
$run = ‘tar -zcpf ‘.$filename_www.’ ‘.$www.’ > /dev/null’;
$output = shell_exec($run);
echo “\n 備份資料庫 開始備份 $db 備份到 $filename_db \n";
$run = ‘/usr/local/etc/rc.d/mysql-server stop > /dev/null’;
$output = shell_exec($run);
echo “\n mysql 停止 \n";
$run = ‘tar -zcpf ‘.$filename_db.’ ‘.$db.’ > /dev/null’;
$output = shell_exec($run);
$run = ‘/usr/local/etc/rc.d/mysql-server start > /dev/null’;
$output = shell_exec($run);
echo “\n mysql 啟動 \n";
echo “\n 設定檔備份 $etc 備份到 $filename_etc \n";
$run = ‘tar -zcpf ‘.$filename_etc.’ ‘.$etc.’ > /dev/null’;
$output = shell_exec($run);

$ftp_server = “ip";
$ftp_user = “backup";
$ftp_passwd = “passwd";

echo “連線到 $ftp_server $ftp_user $ftp_passwd \n";
/* direct object methods */
$ftp =& new FTP();
if ($ftp->connect($ftp_server)) {
if ($ftp->login($ftp_user,$ftp_passwd)) {
echo “\n".$ftp->sysType() . “\n";
echo $ftp->pwd() . “\n";
$ftp->put($ftp_www,$filename_www );
$ftp->put($ftp_db,$filename_db );
$ftp->put($ftp_etc,$filename_etc );
} else {
echo “連線失敗: “;
print_r($ftp->error_no);
print_r($ftp->error_msg);
}
$ftp->disconnect();
$end=$ftp->lastLines;
} else {
echo “連線失敗: “;
print_r($ftp->error_no);
print_r($ftp->error_msg);
}
echo “$end \n";

?>

一個小巧的程式(於英文console顯示BIG5文件)

一個小巧的程式(於英文console顯示BIG5文件)

作者 mison

在純英文的 text console 之下,既不跑 X-win、也不跑 jmcce,但是
偶爾需要看一份BIG5編碼的文件,有什麼簡便的方法嗎﹖最快的途徑是
自己寫一個程式。大致看一下 kernel-doc 有關 frame buffer 文件,
發現這樣的程式不會太難。找出以前寫給印表機用的驅動程式,稍微改
一改,可以在英文模式看漢字檔案的 itwv 完成了。
下載:
http://www.geocities.com/labourvanity/pub/itw-0.1.tar.gz

安裝:
tar -xzvf itw-0.1.tar.gz
cd itw-0.1
../configure –font_dir=/usr/local/share/font/et
make
make install

組態參數:
../configure –help 可以看到簡要說明。
–font_dir 是用來指定字形檔存放路徑。
配合 frame buffer 的解析度設定,另外可以給予如下參數,
–colors=64K –1024×768 這是相對於 vga=791
–colors=16M –1024×768 這是相對於 vga=792
–colors=256 –640×480 這是相對於 vga=769
其他解析度應該也可以,只是我沒有測試過,使用 17 吋 LCD
的朋友可以試試 –1280×1024
字形:
支援 24×24 以及 16×16 兩種字形,可於執行時指定,
itwv [ -s | -b ] files…
-s 是小字 -b 是大字,預設是大字,
files… 是你想要看的BIG5碼文件。
於 1024×768 16×16 可顯示 128×51 個半形字,
於 1024×768 24×24 可顯示 85×32 個半形字。
字形檔使用古代的倚天字形,請自行準備,
ascfont.24 stdfont.24 spcfont.24 spcfsupp.24
ascfont.15 stdfont.15 spcfont.15 spcfsupp.15
如果你沒有這些檔案,也可以借用 jmcce 的字形檔,
han-asc.15 han-std.15 han-spc.15 han-supp.15
但要改成與倚天一樣的檔名。當然,缺了 24×24 字形,
就不能以大字顯示了。

執行:
按 space 繼續看下一頁,
按 Q 跳到下一個檔案,
若已經是最後一個檔案,按 Q 結束。

未完成事項:

一、
程式主要是在64K色彩之下發展、測試,其他模式並未做
太多測試;已知256色模式的文字顯示變得有點破破的,
bug還沒找到。

二、
預計要再寫一個 itws 直接以擷取螢幕的方式把 console
上面的亂碼變成正確的漢字。

三、
README 還沒寫,若有使用上的問題,請自行 hack source code
反正程式碼也沒幾行 🙂

FreeBsd上使用bt

mldonkey 是一套免費的 e-Donkey 用戶端

http://freebsd.sinica.edu.tw/zh-tut/mldonkey.html

mldonkey 是一套免費的 e-Donkey 用戶端。 不過在文字介面的搜尋有點簡陋,筆者通常都是利用網頁介面來存取, 也有 GTK 圖形介面。

# cd /usr/ports/net/mldonkey
# make WITHOUT_TK=yes WITHOUT_X11=yes install clean
然後最好自己選個共同的地方放,像是建立一個新使用者 mldonkey, 然後將檔案都由該使用者來執行。

# mkdir -p /home/mldonkey
# cd /home/mldonkey

第一次執行會產生一些設定檔,接著先暫停執行, 修改一些設定檔後,利用遠端網頁來控制。

% mlnet-real &
% sh /usr/local/bin/kill_mldonkey
% vi servers.ini
known_servers = [
{ server_network = Donkey
server_age = 59138548
server_addr = (“140.123.108.139″, 7654)
server_desc = “TLF Taiwan ED Server"
server_name = “TLF Taiwan ED Server"
};]
% vi downloads.ini
allowed_ips = [
“127.0.0.1″;
“203.204.8.177″;]
% mlnet-real &

然後就可以開啟遠端 http://127.0.0.1:4080/ 來抓檔案囉。

如果要使用中文搜尋,則先在搜尋介面先按右鍵, 編碼 -> 繁體中文, 然後再輸入你要搜尋的中文名稱即可。 或是安裝 outta-port/mldonkey, 也可以直接把 outta-port/mldonkey/files 底下的檔案複製到 net/mldonkey/files 底下。 因為 mldonkey 直接在 http header 中設定了 charset=iso-8859-1, 因此最好的做法是希望作者提供其他編碼的選項, 不然只能 patch source 了。
FREEBSD上養動物,直接想到的就是mldonkey,隨手裝好以後用是可以用,但是用他的網頁管理介面來下載檔案實在有點麻煩,得要手動把ed2k的連結貼上網路管理介面才能開始一個新的下載,而不像原本在Windows中養動物只要無腦點連結就可以直接交給eMule處理了。經過一番研究,我找到sancho這個小玩意兒.