示例#1
0
 function render()
 {
     $spotnntp_hdr = new SpotNntp($this->_settings['nntp_hdr']);
     # Haal de volledige spotinhoud op
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     $fullSpot = $spotsOverview->getFullSpot($this->_messageid, $spotnntp_hdr);
     # sluit de connectie voor de header, en open een nieuwe connectie voor de nzb
     $spotnntp_hdr->quit();
     $spotnntp_img = new SpotNntp($this->_settings['nntp_nzb']);
     #
     # is het een array met een segment nummer naar de image, of is het
     # een string met de URL naar de image?
     #
     if (is_array($fullSpot['image'])) {
         Header("Content-Type: image/jpeg");
         echo $spotnntp_img->getImage($fullSpot['image']['segment']);
     } else {
         $x = file_get_contents($fullSpot['image']);
         foreach ($http_response_header as $hdr) {
             if (substr($hdr, 0, strlen('Content-Type: ')) == 'Content-Type: ') {
                 header($hdr);
             }
             # if
         }
         # foreach
         echo $x;
     }
     # else
 }
示例#2
0
 function render()
 {
     $spotnntp_hdr = new SpotNntp($this->_settings->get('nntp_hdr'));
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotimage, '');
     # Haal de volledige spotinhoud op
     $fullSpot = $this->_tplHelper->getFullSpot($this->_messageid, true);
     # sluit de connectie voor de header, en open een nieuwe connectie voor de nzb
     $spotnntp_hdr->quit();
     $spotnntp_img = new SpotNntp($this->_settings->get('nntp_nzb'));
     # Images mogen gecached worden op de client
     $this->sendExpireHeaders(false);
     #
     # is het een array met een segment nummer naar de image, of is het
     # een string met de URL naar de image?
     #
     if (is_array($fullSpot['image'])) {
         Header("Content-Type: image/jpeg");
         echo $spotnntp_img->getImage($fullSpot['image']['segment']);
     } else {
         $x = file_get_contents($fullSpot['image']);
         foreach ($http_response_header as $hdr) {
             if (substr($hdr, 0, strlen('Content-Type: ')) == 'Content-Type: ') {
                 header($hdr);
             }
             # if
         }
         # foreach
         echo $x;
     }
     # else
 }
示例#3
0
文件: install.php 项目: niel/spotweb
function askNntpSettings()
{
    global $settings;
    global $_testInstall_Ok;
    $serverList = simplexml_load_file('usenetservers.xml');
    $form = array('name' => 'custom', 'host' => '', 'user' => '', 'pass' => '', 'port' => 119, 'enc' => false, 'submit' => '');
    if (isset($_POST['nntpform'])) {
        $form = array_merge($form, $_POST['nntpform']);
    }
    # if
    /*
     * Dit the user press submit? If so, try to
     * connect to the database
     */
    $nntpVerified = false;
    if ($form['submit'] === 'Verify usenet server') {
        try {
            /*
             * Convert the selected NNTP name to an actual
             * server record.
             */
            if ($form['name'] == 'custom') {
                $form['buggy'] = false;
                $form['hdr'] = $form;
                $form['nzb'] = $form;
                $form['post'] = $form;
            } else {
                foreach ($serverList->usenetservers->server as $provider) {
                    if (extension_loaded('openssl') && isset($provider->ssl)) {
                        $server = $provider->ssl;
                    } else {
                        $server = $provider->plain;
                    }
                    # if
                    if ((string) $provider['name'] == $form['name']) {
                        # Header usenet server
                        $form['hdr']['host'] = (string) $server->header;
                        $form['hdr']['user'] = $form['user'];
                        $form['hdr']['pass'] = $form['pass'];
                        if ((string) $server->header['ssl'] == 'yes') {
                            $form['hdr']['enc'] = 'ssl';
                        } else {
                            $form['hdr']['enc'] = false;
                        }
                        # else
                        $form['hdr']['port'] = (int) $server->header['port'];
                        $form['hdr']['buggy'] = (bool) $server['buggy'];
                        # NZB usenet server
                        $form['nzb']['host'] = (string) $server->nzb;
                        $form['nzb']['user'] = $form['user'];
                        $form['nzb']['pass'] = $form['pass'];
                        if ((string) $server->nzb['ssl'] == 'yes') {
                            $form['nzb']['enc'] = 'ssl';
                        } else {
                            $form['nzb']['enc'] = false;
                        }
                        # else
                        $form['nzb']['port'] = (int) $server->nzb['port'];
                        $form['nzb']['buggy'] = (bool) $server['buggy'];
                        # Posting usenet server
                        $form['post']['host'] = (string) $server->post;
                        $form['post']['user'] = $form['user'];
                        $form['post']['pass'] = $form['pass'];
                        if ((string) $server->post['ssl'] == 'yes') {
                            $form['post']['enc'] = 'ssl';
                        } else {
                            $form['post']['enc'] = false;
                        }
                        # else
                        $form['post']['port'] = (int) $server->post['port'];
                        $form['post']['buggy'] = (bool) $server['buggy'];
                    }
                    # if
                }
                # foreach
            }
            # else
            /* and try to connect to the usenet server */
            $nntp = new SpotNntp($form['hdr']);
            $nntp->validateServer();
            $nntpVerified = true;
            /*
             * Store the given NNTP settings in the 
             * SESSION object, we need it later to update
             * the settings in the database
             */
            $_SESSION['spotsettings']['nntp'] = $form;
            /*
             * and call the next stage in the setup
             */
            Header("Location: " . $_SERVER['SCRIPT_NAME'] . '?page=3');
        } catch (Exception $x) {
            ?>
				<div id='error'><?php 
            echo $x->getMessage();
            ?>
				<br /><br />
				Please correct the errors in below form and try again
				</div>
	<?php 
        }
        # exception
    }
    # if
    if (!$nntpVerified) {
        ?>
			<form name='nntpform' method='POST'>
			<table summary="PHP settings">
				<tr> <th> Usenet server settings </th> <th> </th> </tr>
				<tr> <td colspan='2'> Spotweb needs an usenet server. We have several usenet server profiles defined from which you can choose. If your server is not listed, please choose 'custom', more advanced options can be set from within Spotweb itself. </td> </tr>
				<tr> <td> Usenet server </td> 
				<td> 
					<select id='nntpselectbox' name='nntpform[name]' onchange='toggleNntpField();'> 
	<?php 
        foreach ($serverList->usenetservers->server as $provider) {
            $server = '';
            /* Make sure the server is supported, eg filter out ssl only servers when openssl is not loaded */
            if (extension_loaded('openssl') && isset($provider->ssl)) {
                $server = $provider->ssl;
            } elseif (isset($provider->plain)) {
                $server = $provider->plain;
            }
            # if
            if (!empty($server)) {
                echo "<option value='{$provider['name']}'" . ($provider['name'] == $form['name'] ? "selected='selected'" : '') . ">{$provider['name']}</option>";
            }
            # if
        }
        # foreach
        ?>
						<option value='custom'>Custom</option>
					</select> 
				</td> </tr>
				<tr id='customnntpfield' style='display: none;'> <td> server </td> <td> <input type='text' length='40' name='nntpform[host]' value='<?php 
        echo htmlspecialchars($form['host']);
        ?>
'></input> </td> </tr>
				<tr> <td> username </td> <td> <input type='text' length='40' name='nntpform[user]' value='<?php 
        echo htmlspecialchars($form['user']);
        ?>
'></input> </td> </tr>
				<tr> <td> password </td> <td> <input type='password' length='40' name='nntpform[pass]' value='<?php 
        echo htmlspecialchars($form['pass']);
        ?>
'></input> </td> </tr>
				<tr> <td colspan='2'> <input type='submit' name='nntpform[submit]' value='Verify usenet server'> </td> </tr>
			</table>
			</form>
			<br />
	<?php 
    }
    # else
}
示例#4
0
         die($x->getMessage());
     }
     # else
     # getspot
 # getspot
 case 'getnzb':
     $db = openDb();
     $spot = $db->getSpot($req->getDef('messageid', ''));
     $spot = $spot[0];
     try {
         $hdr_spotnntp = new SpotNntp($settings['nntp_hdr']['host'], $settings['nntp_hdr']['enc'], $settings['nntp_hdr']['port'], $settings['nntp_hdr']['user'], $settings['nntp_hdr']['pass']);
         if ($settings['nntp_hdr']['host'] == $settings['nntp_nzb']['host']) {
             $hdr_spotnntp->connect();
             $nzb_spotnntp = $hdr_spotnntp;
         } else {
             $nzb_spotnntp = new SpotNntp($settings['nntp_nzb']['host'], $settings['nntp_nzb']['enc'], $settings['nntp_nzb']['port'], $settings['nntp_nzb']['user'], $settings['nntp_nzb']['pass']);
             $hdr_spotnntp->connect();
             $nzb_spotnntp->connect();
         }
         # else
         $header = $hdr_spotnntp->getHeader('<' . $spot['messageid'] . '>');
         $xml = '';
         if ($header !== false) {
             foreach ($header as $str) {
                 if (substr($str, 0, 7) == 'X-XML: ') {
                     $xml .= substr($str, 7);
                 }
                 # if
             }
             # foreach
         }
示例#5
0
require_once "lib/SpotSecurity.php";
require_once "lib/SpotTiming.php";
require_once "settings.php";
require_once "lib/SpotDb.php";
define('USERID', 30);
/* -------------------------------------------------------------------- */
echo "Included PHP classes... " . PHP_EOL;
$db = new SpotDb($settings['db']);
$db->connect();
echo "Connected to the database.." . PHP_EOL;
$spotSettings = SpotSettings::singleton($db, $settings);
$spotSigning = new SpotSigning();
$spotPosting = new SpotPosting($db, $spotSettings);
$spotUserSystem = new SpotUserSystem($db, $spotSettings);
echo "Initialized classes.." . PHP_EOL;
$rsaKeys = $spotSettings->get('rsa_keys');
$retriever = new SpotRetriever_Spots($spotSettings->get('nntp_hdr'), $db, $spotSettings, $rsaKeys, '', $spotSettings->get('retrieve_full'));
$msgdata = $retriever->connect($spotSettings->get('hdr_group'));
var_dump($msgdata);
# Connct thru our own NNTP session to the server so we have an XOVER list
$headerServer = $spotSettings->get('nntp_hdr');
$spotnntp = new SpotNntp($spotSettings->get('nntp_hdr'));
$spotnntp->selectGroup($spotSettings->get('hdr_group'));
$hdrList = $spotnntp->getOverview(3244937, 3244938);
foreach ($hdrList as $msgid => $msgheader) {
    $spotParser = new SpotParser();
    $spot = $spotParser->parseXover($msgheader['Subject'], $msgheader['From'], $msgheader['Date'], $msgheader['Message-ID'], $rsaKeys);
    var_dump($spot);
}
# and signal quit
$retriever->quit();
示例#6
0
<?php

require "lib/SpotNntp.php";
require "lib/SpotParser.php";
require "NNTP/Protocol/Responsecode.php";
require "NNTP/Protocol/Client.php";
require "NNTP/Client.php";
require "lib/SpotSigning.php";
require "lib/exceptions/CustomException.php";
require "lib/exceptions/NntpException.php";
require "lib/SpotSeclibToOpenSsl.php";
$server = array('host' => $argv[1], 'enc' => false, 'port' => 119, 'user' => $argv[2], 'pass' => $argv[3]);
$nntp = new SpotNntp($server);
$nntp->selectGroup('free.pt');
try {
    $r1 = array();
    $r2 = array();
    $r1 = $nntp->getBody('<*****@*****.**>');
    $r2 = $nntp->getBody('<*****@*****.**>');
} catch (Exception $x) {
    var_dump($x);
}
var_dump($r1);
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" . PHP_EOL;
var_dump($r2);
示例#7
0
 function validateNntpServer($server)
 {
     $result = '';
     try {
         $testNntp = new SpotNntp($server);
         $testNntp->validateServer();
     } catch (Exception $x) {
         $result = $x->getMessage();
     }
     # catch
     return $result;
 }
示例#8
0
 function process($hdrList, $curMsg, $endMsg, $timer)
 {
     $this->displayStatus("progress", $curMsg . " till " . $endMsg);
     $spotParser = new SpotParser();
     $signedCount = 0;
     $hdrsRetrieved = 0;
     $fullsRetrieved = 0;
     $msgCounter = 0;
     $modCount = 0;
     $skipCount = 0;
     $lastProcessedId = '';
     $fullSpotDbList = array();
     $spotDbList = array();
     $moderationList = array();
     $processingStartTime = time();
     /*
      * Determine the cutoff date (unixtimestamp) from whereon we do not want to 
      * load the spots
      */
     if ($this->_settings->get('retention') > 0) {
         $retentionStamp = time() - $this->_settings->get('retention') * 24 * 60 * 60;
     } else {
         $retentionStamp = 0;
     }
     # else
     $this->debug('retentionStamp=' . $retentionStamp);
     $this->debug('hdrList=' . serialize($hdrList));
     /**
      * We ask the database to match our messageid's we just retrieved with
      * the list of id's we have just retrieved from the server
      */
     $dbIdList = $this->_db->matchSpotMessageIds($hdrList);
     $this->debug('dbIdList=' . serialize($dbIdList));
     # if we need to fetch images or nzb files, we need an spotsoverview instance
     if ($this->_retrieveFull && $this->_prefetch_image || $this->_prefetch_nzb) {
         $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
         $spotsOverview->setActiveRetriever(true);
         /*
          * Only create a new NZB instance if the server differs from the
          * header host, else re-use the connection
          */
         $settings_nntp_nzb = $this->_settings->get('nntp_nzb');
         if ($this->_server['host'] == $settings_nntp_nzb['host']) {
             $nntp_nzb = $this->_spotnntp;
         } else {
             $nntp_nzb = new SpotNntp($settings_nntp_nzb);
             $nntp_nzb->selectGroup($this->_settings->get('nzb_group'));
         }
         # else
     }
     # if
     foreach ($hdrList as $msgheader) {
         $msgCounter++;
         $this->debug('foreach-loop, start. msgId= ' . $msgCounter);
         /* 
          * Keep te usenet server alive when processing is slow.
          */
         if ($processingStartTime - time() > 30) {
             $this->_spotnntp->sendNoop();
             if (isset($nntp_nzb) && $nntp_nzb != $this->_spotnntp) {
                 $nntp_nzb->sendNoop();
             }
             # if
             $processingStartTime = time();
         }
         # if
         /*
          * We keep track whether we actually fetched this header and fullspot
          * to add it to the database, because only then we can update the
          * titel from the spots title or rely on our database to fetch
          * the fullspot
          */
         $didFetchHeader = false;
         $didFetchFullSpot = false;
         # Reset timelimit
         set_time_limit(120);
         # messageid to check
         $msgId = substr($msgheader['Message-ID'], 1, -1);
         /*
          * We prepare some variables to we don't have to perform an array
          * lookup for each check and the code is easier to read.
          */
         $header_isInDb = isset($dbIdList['spot'][$msgId]);
         $fullspot_isInDb = isset($dbIdList['fullspot'][$msgId]);
         /*
          * If the spotheader is not yet added to the database, parse the header
          * information.
          *
          * If the header is present, but we don't have the fullspot yet or we are
          * running in 'retro' mode, parse the header as well because some fields
          * are only in the header and not in the full.
          * 
          * We need some of those fields (for example KeyID)
          */
         if (!$header_isInDb || (!$fullspot_isInDb || $this->_retro) && $this->_retrieveFull) {
             $hdrsRetrieved++;
             $this->debug('foreach-loop, parsingXover, start. msgId= ' . $msgCounter);
             $spot = $spotParser->parseXover($msgheader['Subject'], $msgheader['From'], $msgheader['Date'], $msgheader['Message-ID'], $this->_rsakeys);
             $this->debug('foreach-loop, parsingXover, done. msgId= ' . $msgCounter);
             /*
              * When a parse error occured, we ignore the spot, also unverified
              * spots are ignored
              */
             if ($spot === false || !$spot['verified']) {
                 $this->debug('foreach-loop, spot is either false or not verified');
                 continue;
             }
             # if
             /*
              * Special moderator commands always have keyid 2
              */
             if ($spot['keyid'] == 2) {
                 $this->debug('foreach-loop, spot is a moderation spot');
                 $commandAr = explode(' ', strtolower($spot['title']));
                 $validCommands = array('delete', 'dispose', 'remove');
                 # is this one of the defined valid commands?
                 if (in_array($commandAr[0], $validCommands) !== false) {
                     $moderationList[$commandAr[1]] = 1;
                     $modCount++;
                 }
                 # if
             } else {
                 /*
                  * Don't add spots older than specified for the retention stamp
                  */
                 if ($retentionStamp > 0 && $spot['stamp'] < $retentionStamp && $this->_settings->get('retentiontype') == 'everything') {
                     $this->debug('foreach-loop, spot is expired: ' . $spot['stamp']);
                     continue;
                 } elseif ($spot['stamp'] < $this->_settings->get('retrieve_newer_than')) {
                     $this->debug('foreach-loop, spot is too old: ' . $spot['stamp']);
                     $skipCount++;
                 } else {
                     /*
                      * Do we have the header in the database? If not, lets add it
                      */
                     if (!$header_isInDb) {
                         $spotDbList[] = $spot;
                         /*
                          * Some buggy NNTP servers give us the same messageid
                          * in one XOVER statement, hence we update the list of
                          * messageid's we already have retrieved and are ready
                          * to be added to the database
                          */
                         $dbIdList['spot'][$msgId] = 1;
                         $header_isInDb = true;
                         $lastProcessedId = $msgId;
                         $didFetchHeader = true;
                         if ($spot['wassigned']) {
                             $signedCount++;
                         }
                         # if
                     }
                     # if
                 }
                 # if
             }
             # else
         } else {
             $lastProcessedId = $msgId;
         }
         # else
         /*
          * We don't want to retrieve the fullspot if we don't have the header
          * in the database. Because we try to add headers in the above code we just have
          * to check if the header is in the database.
          *
          * We cannot collapse this code with the header fetching code because we want to
          * be able to add the fullspot to a system after all the headers are retrieved
          */
         if ($header_isInDb && !$fullspot_isInDb) {
             /*
              * Don't add older fullspots than specified for the retention stamp
              */
             if ($retentionStamp > 0 && strtotime($msgheader['Date']) < $retentionStamp) {
                 continue;
             }
             # if
             if ($this->_retrieveFull) {
                 $fullSpot = array();
                 try {
                     $fullsRetrieved++;
                     $this->debug('foreach-loop, getFullSpot, start. msgId= ' . $msgId);
                     $fullSpot = $this->_spotnntp->getFullSpot($msgId);
                     $this->debug('foreach-loop, getFullSpot, done. msgId= ' . $msgId);
                     # add this spot to the database
                     $fullSpotDbList[] = $fullSpot;
                     $fullspot_isInDb = true;
                     $didFetchFullSpot = true;
                     /*
                      * Some buggy NNTP servers give us the same messageid
                      * in once XOVER statement, hence we update the list of
                      * messageid's we already have retrieved and are ready
                      * to be added to the database
                      */
                     $dbIdList['fullspot'][$msgId] = 1;
                     /* 
                      * Overwrite the spots' title because the fullspot contains the title in
                      * UTF-8 format.
                      * We also overwrite the spotterid from the spotsfull because the spotterid
                      * is only in the header in more recent spots.
                      */
                     if ($didFetchHeader) {
                         $spotDbList[count($spotDbList) - 1]['title'] = $fullSpot['title'];
                         $spotDbList[count($spotDbList) - 1]['spotterid'] = $fullSpot['spotterid'];
                     }
                     # if
                 } catch (ParseSpotXmlException $x) {
                     # swallow error
                 } catch (Exception $x) {
                     /**
                      * Sometimes we get an 'No such article' error for a header we just retrieved,
                      * if we want to retrieve the full article. This is messed up, but let's just
                      * swallow the error
                      */
                     if ($x->getCode() == 430) {
                     } elseif ($x->getMessage() == 'String could not be parsed as XML') {
                     } else {
                         throw $x;
                     }
                     # else
                 }
                 # catch
             }
             # if retrievefull
         }
         # if fullspot is not in db yet
         if ($this->_retrieveFull && $header_isInDb && ($this->_prefetch_image || $this->_prefetch_nzb)) {
             try {
                 /*
                  * If we are running in 'retro' mode, it is possible both the header and spot are in the
                  * database already, however -- we need the information from the fullspot so we retrieve it
                  * again
                  */
                 if (!$didFetchFullSpot) {
                     $fullSpot = $this->_db->getFullSpot($msgId, SPOTWEB_ANONYMOUS_USERID);
                     $fullSpot = array_merge($spotParser->parseFull($fullSpot['fullxml']), $fullSpot);
                 }
                 # if
                 /*
                  * Prefetch (cache) the spots' image
                  */
                 if ($this->_prefetch_image) {
                     /*
                      * If the spot is older than 30 days, and the image is on the web, we do not 
                      * prefetch the image.
                      */
                     if (is_array($fullSpot['image']) || $fullSpot['stamp'] > (int) time() - 30 * 24 * 60 * 60) {
                         $this->debug('foreach-loop, getImage(), start. msgId= ' . $msgId);
                         $spotsOverview->getImage($fullSpot, $nntp_nzb);
                         $this->debug('foreach-loop, getImage(), done. msgId= ' . $msgId);
                     }
                     # if
                 }
                 # if
                 /*
                  * Prefetch (cache) the spots' NZB file
                  */
                 if ($this->_prefetch_nzb) {
                     /*
                      * Only do so if we can expect an NZB file
                      */
                     if (!empty($fullSpot['nzb']) && $fullSpot['stamp'] > 1290578400) {
                         $this->debug('foreach-loop, getNzb(), start. msgId= ' . $msgId);
                         $spotsOverview->getNzb($fullSpot, $nntp_nzb);
                         $this->debug('foreach-loop, getNzb(), done. msgId= ' . $msgId);
                     }
                     # if
                 }
                 # if
             } catch (ParseSpotXmlException $x) {
                 # swallow error
             } catch (Exception $x) {
                 /**
                  * Sometimes we get an 'No such article' error for a header we just retrieved,
                  * if we want to retrieve the full article. This is messed up, but let's just
                  * swallow the error
                  */
                 if ($x->getCode() == 430) {
                 } elseif ($x->getMessage() == 'String could not be parsed as XML') {
                 } else {
                     throw $x;
                 }
                 # else
             }
             # catch
         }
         # if prefetch image and/or nzb
         $this->debug('foreach-loop, done. msgId= ' . $msgCounter);
     }
     # foreach
     if (count($hdrList) > 0) {
         $this->displayStatus("hdrparsed", $hdrsRetrieved);
         $this->displayStatus("fullretrieved", $fullsRetrieved);
         $this->displayStatus("verified", $signedCount);
         $this->displayStatus("modcount", $modCount);
         $this->displayStatus("skipcount", $skipCount);
         $this->displayStatus("loopcount", count($hdrList));
     } else {
         $this->displayStatus("hdrparsed", 0);
         $this->displayStatus("fullretrieved", 0);
         $this->displayStatus("verified", 0);
         $this->displayStatus("modcount", 0);
         $this->displayStatus("skipcount", 0);
         $this->displayStatus("loopcount", 0);
     }
     # else
     /* 
      * Add the spots to the database and update the last article
      * number found
      */
     $this->_db->addSpots($spotDbList, $fullSpotDbList);
     $this->debug('added Spots, spotDbList=' . serialize($spotDbList));
     $this->debug('added Spots, fullSpotDbList=' . serialize($fullSpotDbList));
     /*
      * Actually act on the moderation settings. We cannot process this inline
      * because a spot can be added and moderated within the same iteration
      */
     switch ($this->_settings->get('spot_moderation')) {
         case 'disable':
             break;
         case 'markspot':
             $this->_db->markCommentsModerated($moderationList);
             $this->_db->markSpotsModerated($moderationList);
             break;
             # case 'markspot'
         # case 'markspot'
         default:
             $this->_db->removeSpots($moderationList);
             $this->_db->removeComments($moderationList);
             break;
             # default
     }
     # switch
     # update the maximum article id
     if ($this->_retro) {
         $this->_db->setMaxArticleid('spots_retro', $endMsg);
     } else {
         $this->_db->setMaxArticleid($this->_server['host'], $endMsg);
     }
     # if
     $this->debug('loop finished, setMaxArticleId=' . serialize($endMsg));
     $this->displayStatus("timer", round(microtime(true) - $timer, 2));
     return array('count' => count($hdrList), 'headercount' => $hdrsRetrieved, 'lastmsgid' => $lastProcessedId);
 }
示例#9
0
<?php

require "lib/SpotNntp.php";
require "lib/SpotParser.php";
require "NNTP/Protocol/Responsecode.php";
require "NNTP/Protocol/Client.php";
require "NNTP/Client.php";
require "lib/SpotSigning.php";
require "lib/exceptions/CustomException.php";
require "lib/exceptions/NntpException.php";
require "lib/SpotSeclibToOpenSsl.php";
$server = array('host' => $argv[1], 'enc' => false, 'port' => 119, 'user' => $argv[2], 'pass' => $argv[3]);
$nntp = new SpotNntp($server);
$nntp->selectGroup('free.pt');
try {
    $r = $nntp->getHeader('<*****@*****.**>');
    $r = $nntp->getHeader('<*****@*****.**>');
} catch (Exception $x) {
    var_dump($x);
}
var_dump($r);
示例#10
0
文件: testRead.php 项目: niel/spotweb
require_once "lib/SpotTiming.php";
require_once "settings.php";
require_once "lib/SpotDb.php";
define('USERID', 30);
/* -------------------------------------------------------------------- */
echo "Included PHP classes... " . PHP_EOL;
$db = new SpotDb($settings['db']);
$db->connect();
echo "Connected to the database.." . PHP_EOL;
$spotSettings = SpotSettings::singleton($db, $settings);
$spotSigning = Services_Signing_Base::newServiceSigning();
$spotPosting = new SpotPosting($db, $spotSettings);
$spotUserSystem = new SpotUserSystem($db, $spotSettings);
echo "Initialized classes.." . PHP_EOL;
$rsaKeys = $spotSettings->get('rsa_keys');
$retriever = new SpotRetriever_Spots($spotSettings->get('nntp_hdr'), $db, $spotSettings, $rsaKeys, '', $spotSettings->get('retrieve_full'));
$msgdata = $retriever->connect($spotSettings->get('hdr_group'));
var_dump($msgdata);
# Connct thru our own NNTP session to the server so we have an XOVER list
$headerServer = $spotSettings->get('nntp_hdr');
$spotnntp = new SpotNntp($spotSettings->get('nntp_hdr'));
# $spotnntp->selectGroup($spotSettings->get('hdr_group'));
$spotnntp->selectGroup('alt.test');
$hdrList = $spotnntp->getOverview(3042000, 3042636);
foreach ($hdrList as $msgid => $msgheader) {
    $spotParser = new SpotParser();
    $spot = $spotParser->parseXover($msgheader['Subject'], $msgheader['From'], $msgheader['Date'], $msgheader['Message-ID'], $rsaKeys);
    var_dump($spot);
}
# and signal quit
$retriever->quit();
示例#11
0
require_once "NNTP/Protocol/Client.php";
require_once "NNTP/Client.php";
require_once "lib/exceptions/CustomException.php";
require_once "lib/exceptions/NntpException.php";
require_once "lib/services/Signing/Services_Signing_Base.php";
require_once "lib/SpotSecurity.php";
require_once "lib/SpotTiming.php";
require_once "settings.php";
require_once "lib/SpotDb.php";
$db = new SpotDb($settings['db']);
$db->connect();
echo "Connected to the database.." . PHP_EOL;
$spotSettings = SpotSettings::singleton($db, $settings);
$server = array('host' => $argv[1], 'enc' => false, 'port' => 119, 'user' => $argv[2], 'pass' => $argv[3]);
$rsaKeys = $spotSettings->get('rsa_keys');
$nntp = new SpotNntp($server);
$nntp->selectGroup('alt.test');
try {
    $r = $nntp->getHeader('<*****@*****.**>');
    foreach ($r as $hdr) {
        $y = explode(":", $hdr);
        $r[$y[0]] = trim($y[1]);
    }
    # foreac
    $spotParser = new SpotParser();
    $spot = $spotParser->parseXover($r['Subject'], $r['From'], $r['Date'], $r['Message-ID'], $rsaKeys);
    //	var_dump($y);
    //var_dump($r);
    var_dump($spot);
} catch (Exception $x) {
    var_dump($x);