> Posta lo script, in particolare la parte che instaura la connessione, e magari anche > l'url diretto ad esso.
L'url diretto posso dartelo in privato perche ci sarebbero user e pass
di connessione al mio newserver ?
allora si basa su questo http://amrhein.eu/newsportal/
La parte che instaura la connessione e' piu o meno questa
Codice PHP:
*\Khis\webnews\nntp.php
define("NNTP_PORT", 119);
che si appoggia su *\Khis\config\webnews.cfg.php
// NNTP Server setting
$nntp_server = "news01.khis.de";
$user = "USER";
$pass = "PASSWORD";
comunque e' abbastanza complicato e non posso postare il tutto qui
posto una parte
function NNTP($server, $user = "", $pass = "", $proxy_server = "", $proxy_port = "", $proxy_user = "", $proxy_pass = "") {
$this->server = $server;
$this->user = $user;
$this->pass = $pass;
$this->proxy_server = $proxy_server;
$this->proxy_port = $proxy_port;
$this->proxy_user = $proxy_user;
$this->proxy_pass = $proxy_pass;
if ((strcmp($this->proxy_server, "") != 0) && (strcmp($this->proxy_port, "") != 0)) {
$this->use_proxy = TRUE;
} else {
$this->use_proxy = FALSE;
}
}
/* Open a TCP connection to the specific server
Return: TRUE - open succeeded
FALSE - open failed
*/
function connect() {
if ($this->nntp) { // We won't try to re-connect an already opened connection
return TRUE;
}
if ($this->use_proxy) {
$this->nntp = fsockopen($this->proxy_server, $this->proxy_port, $this->error_number, $this->error_message);
} else {
$this->nntp = fsockopen($this->server, NNTP_PORT, $this->error_number, $this->error_message);
}
if ($this->nntp) {
if ($this->use_proxy) {
$response = "CONNECT ".$this->server.":".NNTP_PORT." HTTP/1.0\r\n";
if ((strcmp($this->proxy_user, "") != 0) && (strcmp($this->proxy_pass, "") != 0)) {
$response .= "Proxy-Authorization: Basic "; // Only support Basic authentication type
$response .= base64_encode($this->proxy_user.":".$this->proxy_pass);
$response .= "\r\n";
}
$response = $this->send_request($response);
if (strstr($response, "200 Connection established")) {
fgets($this->nntp, 4096); // Skip an empty line
$response = $this->parse_response(fgets($this->nntp, 4096));
} else {
$response["status"] = NO_PERMISSION; // Assign it to something dummy
$response["message"] = "No permission";
}
} else {
$response = $this->parse_response(fgets($this->nntp, 4096));
}
if (($response["status"] == SERVER_READY) || ($response["status"] == SERVER_READY_NO_POST)) {
$this->send_request("mode reader");
if (strcmp($this->user, "") != 0) {
$response = $this->parse_response($this->send_request("authinfo user ".$this->user));
if ($response["status"] == MORE_AUTH_INFO) {
$response = $this->parse_response($this->send_request("authinfo pass ".$this->pass));
if ($response["status"] == AUTH_ACCEPT) {
return TRUE;
}
}
} else {
return TRUE;
}
}
$this->error_number = $response["status"];
$this->error_message = $response["message"];
}
return FALSE;
}