-
Notifications
You must be signed in to change notification settings - Fork 117
/
SpotNntp.php
97 lines (82 loc) · 2.16 KB
/
SpotNntp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once "Net/NNTP/Client.php";
class SpotNntp {
private $_server;
private $_user;
private $_pass;
private $_serverenc;
private $_serverport;
private $_error;
private $_nntp;
function __construct($server, $serverenc, $serverport, $user, $pass) {
$error = '';
$this->_server = $server;
$this->_serverenc = $serverenc;
$this->_serverport = $serverport;
$this->_user = $user;
$this->_pass = $pass;
# Set pear error handling to be used by exceptions
PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);
$this->_nntp = new Net_NNTP_Client();
} # ctor
function getError() {
return $this->_error;
} # getError()
function selectGroup($group) {
$msgInfo = false;
try {
$msgInfo = $this->_nntp->selectGroup($group);
}
catch (Exception $x) {
$this->_error = $x->getMessage();
return false;
} # catch
return $msgInfo;
} # selectGroup()
function getOverview($first, $last) {
$hdrList = false;
try {
$hdrList = $this->_nntp->getOverview($first . '-' . $last);
$hdrList = array_reverse($hdrList);
}
catch(Exception $x) {
$this->_error = $x->getMessage();
return false;
} # catch
return $hdrList;
} # getOverview()
function quit() {
$this->_nntp->quit();
} # quit()
function getHeader($msgid) {
try {
return $this->_nntp->getHeader($msgid);
}
catch(Exception $x) {
$this->_error = $x->getMessage();
return false;
} # catch
} # getHeader()
function getBody($msgid) {
try {
return $this->_nntp->getBody($msgid);
}
catch(Exception $x) {
$this->_error = $x->getMessage();
return false;
} # catch
} # getBody ()
function connect() {
try {
$ret = $this->_nntp->connect($this->_server, $this->_serverenc, $this->_serverport);
if (!empty($this->_user)) {
$authed = $this->_nntp->authenticate($this->_user, $this->_pass);
} # if
}
catch(Exception $x) {
$this->_error = $x->getMessage();
return false;
} # catch
return true;
} # connect()
} # class SpotNntp