Net_NNTP
[ class tree: Net_NNTP ] [ index: Net_NNTP ] [ all elements ]

Source for file Client.php

Documentation is available at Client.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
  3. // +-----------------------------------------------------------------------+
  4. // |                                                                       |
  5. // |                  http://www.heino.gehlsen.dk/software/license         |
  6. // |                                                                       |
  7. // +-----------------------------------------------------------------------+
  8. // |                                                                       |
  9. // | This work (including software, documents, or other related items) is  |
  10. // | being provided by the copyright holders under the following license.  |
  11. // | By obtaining, using and/or copying this work, you (the licensee)      |
  12. // | agree that you have read, understood, and will comply with the        |
  13. // | following terms and conditions:                                       |
  14. // |                                                                       |
  15. // | Permission to use, copy, modify, and distribute this software and     |
  16. // | its documentation, with or without modification, for any purpose and  |
  17. // | without fee or royalty is hereby granted, provided that you include   |
  18. // | the following on ALL copies of the software and documentation or      |
  19. // | portions thereof, including modifications, that you make:             |
  20. // |                                                                       |
  21. // | 1. The full text of this NOTICE in a location viewable to users of    |
  22. // |    the redistributed or derivative work.                              |
  23. // |                                                                       |
  24. // | 2. Any pre-existing intellectual property disclaimers, notices, or    |
  25. // |    terms and conditions. If none exist, a short notice of the         |
  26. // |    following form (hypertext is preferred, text is permitted) should  |
  27. // |    be used within the body of any redistributed or derivative code:   |
  28. // |     http://www.heino.gehlsen.dk/software/license"                     |
  29. // |                                                                       |
  30. // | 3. Notice of any changes or modifications to the files, including     |
  31. // |    the date changes were made. (We recommend you provide URIs to      |
  32. // |    the location from which the code is derived.)                      |
  33. // |                                                                       |
  34. // | THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT    |
  35. // | HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,    |
  36. // | INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR        |
  37. // | FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE    |
  38. // | OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,           |
  39. // | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.                               |
  40. // |                                                                       |
  41. // | COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT,        |
  42. // | SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE        |
  43. // | SOFTWARE OR DOCUMENTATION.                                            |
  44. // |                                                                       |
  45. // | The name and trademarks of copyright holders may NOT be used in       |
  46. // | advertising or publicity pertaining to the software without specific, |
  47. // | written prior permission. Title to copyright in this software and any |
  48. // | associated documentation will at all times remain with copyright      |
  49. // | holders.                                                              |
  50. // |                                                                       |
  51. // +-----------------------------------------------------------------------+
  52. // |                                                                       |
  53. // | except for the references to the copyright holder, which has either   |
  54. // | been changes or removed.                                              |
  55. // |                                                                       |
  56. // +-----------------------------------------------------------------------+
  57. // $Id: Client.php,v 1.5.2.7 2005/11/27 22:47:13 heino Exp $
  58.  
  59. require_once 'Net/NNTP/Protocol/Client.php';
  60. require_once 'Net/NNTP/Header.php';
  61. require_once 'Net/NNTP/Message.php';
  62.  
  63.  
  64. // {{{ constants
  65.  
  66. /* NNTP Authentication modes */
  67. define('NET_NNTP_CLIENT_AUTH_ORIGINAL''original');
  68. define('NET_NNTP_CLIENT_AUTH_SIMPLE',   'simple');
  69. define('NET_NNTP_CLIENT_AUTH_GENERIC',  'generic');
  70.  
  71. // }}}
  72. // {{{ Net_NNTP_Client
  73.  
  74. /**
  75.  * Implementation of the client side of NNTP (Network News Transfer Protocol)
  76.  *
  77.  * The Net_NNTP_Client class is a frontend class to the Net_NNTP_Protocol_Client class.
  78.  *
  79.  * @category   Net
  80.  * @package    Net_NNTP
  81.  * @author     Heino H. Gehlsen <heino@gehlsen.dk>
  82.  * @version    $Id: Client.php,v 1.5.2.7 2005/11/27 22:47:13 heino Exp $
  83.  * @access     public
  84.  * @see        Net_NNTP_Protocol_Client
  85.  * @since      Class available since Release 0.11.0
  86.  */
  87. class Net_NNTP_Client extends Net_NNTP_Protocol_Client
  88. {
  89.     // {{{ properties
  90.  
  91.     /**
  92.      * Used for storing information about the currently selected group
  93.      *
  94.      * @var array 
  95.      * @access private
  96.      * @since 0.3
  97.      */
  98.     var $_currentGroup = null;
  99.  
  100.     // }}}
  101.     // {{{ constructor
  102.  
  103.     /**
  104.      * Constructor
  105.      *
  106.      * @access public
  107.      */
  108.     function Net_NNTP_Client()
  109.     {
  110.         parent::Net_NNTP_Protocol_Client();
  111.     }
  112.  
  113.     // }}}
  114.     // {{{ connect()
  115.  
  116.     /**
  117.      * Connect to the NNTP-server.
  118.      *
  119.      * @param optional string $host The adress of the NNTP-server to connect to.
  120.      * @param optional int $port The port to connect to.
  121.      *
  122.      * @return mixed (bool) on success (true when posting allowed, otherwise false) or (object) pear_error on failure
  123.      * @access public
  124.      * @see Net_NNTP_Client::quit()
  125.      * @see Net_NNTP_Client::authenticate()
  126.      */
  127.     function connect($host = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_HOST,
  128.                      $port = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_PORT)
  129.     {
  130.         return parent::connect($host$port);
  131.     }
  132.  
  133.     // }}}
  134.     // {{{ quit()
  135.  
  136.     /**
  137.      * Close connection to the server
  138.      *
  139.      * @access public
  140.      * @see Net_NNTP_Client::connect()
  141.      */
  142.     function quit()
  143.     {
  144.         return $this->cmdQuit();
  145.     }
  146.  
  147.     // }}}
  148.     // {{{ authenticate()
  149.  
  150.     /**
  151.      * Authenticate
  152.      * 
  153.      * Experimental / Partially implemented
  154.      *
  155.      * Auth process (not yet standarized but used any way)
  156.      * http://www.mibsoftware.com/userkt/nntpext/index.html
  157.      *
  158.      * @param string $user The username
  159.      * @param optional string $pass The password
  160.      * @param optional string $mode The authentication mode (original, simple, generic).
  161.      *
  162.      * @return mixed (bool) true on success or (object) pear_error on failure
  163.      * @access public
  164.      * @see Net_NNTP_Client::connect()
  165.      */
  166.     function authenticate($user$pass$mode = NET_NNTP_CLIENT_AUTH_ORIGINAL)
  167.     {
  168.         // Username is a must...
  169.         if ($user == null{
  170.             return PEAR::throwError('No username supplied'null);
  171.         }
  172.  
  173.         // Use selected authentication method
  174.         switch ($mode{
  175.             case NET_NNTP_CLIENT_AUTH_ORIGINAL:
  176.                 return $this->cmdAuthinfo($user$pass);
  177.                 break;
  178.             case NET_NNTP_CLIENT_AUTH_SIMPLE:
  179.                 return $this->cmdAuthinfoSimple($user$pass);
  180.                 break;
  181.             case NET_NNTP_CLIENT_AUTH_GENERIC:
  182.                 return $this->cmdAuthinfoGeneric($user$pass);
  183.                 break;
  184.             default:
  185.                 return PEAR::throwError("The auth mode: '$mode' is unknown"null);
  186.         }
  187.     }
  188.  
  189.     // }}}
  190.     // {{{ isConnected()
  191.  
  192.     /**
  193.      * Test whether a connection is currently open.
  194.      *
  195.      * @return bool true or false
  196.      * @access public
  197.      * @see Net_NNTP_Client::connect()
  198.      * @see Net_NNTP_Client::quit()
  199.      */
  200.     function isConnected()
  201.     {
  202.         return parent::isConnected();
  203.     }
  204.  
  205.     // }}}
  206.     // {{{ selectGroup()
  207.  
  208.     /**
  209.      * Selects a newsgroup as the currently selected newsgroup and returns summary information about it
  210.      *
  211.      * @param string $group Newsgroup name
  212.      *
  213.      * @return mixed (array) summary about the group on success or (object) pear_error on failure
  214.      * @access public
  215.      * @see Net_NNTP_Client::group()
  216.      * @see Net_NNTP_Client::first()
  217.      * @see Net_NNTP_Client::last()
  218.      * @see Net_NNTP_Client::count()
  219.      * @see Net_NNTP_Client::getGroups()
  220.      */
  221.     function selectGroup($group)
  222.     {
  223.         $summary $this->cmdGroup($group);
  224.         if (PEAR::isError($summary)) {
  225.             return $summary;
  226.         }
  227.  
  228.         // Store group info in the object
  229.         $this->_currentGroup $summary;
  230.  
  231.         return $summary;
  232.     }
  233.  
  234.     // }}}
  235.     // {{{ getGroups()
  236.  
  237.     /**
  238.      * Returns a list of valid newsgroups and associated information
  239.      *
  240.      * @return mixed (array) nested array with informations about existing newsgroups on success or (object) pear_error on failure
  241.      * @access public
  242.      * @see Net_NNTP_Client::selectGroup()
  243.      * @see Net_NNTP_Client::getDescriptions()
  244.      */
  245.     function getGroups()
  246.     {
  247.         // Get groups
  248.         $groups $this->cmdList();
  249.         if (PEAR::isError($groups)) {
  250.             return $groups;
  251.         }
  252.  
  253.         return $groups;
  254.     }
  255.  
  256.     // }}}
  257.     // {{{ getDescriptions()
  258.  
  259.     /**
  260.      * Fetches a list of all avaible newsgroup descriptions.
  261.      *
  262.      * @return mixed (array) nested array with description of existing newsgroups on success or (object) pear_error on failure
  263.      * @access public
  264.      * @see Net_NNTP_Client::getGroups()
  265.      */
  266.     function getDescriptions()
  267.     {
  268.         // Get group descriptions
  269.         $descriptions $this->cmdListNewsgroups();
  270.         if (PEAR::isError($descriptions)) {
  271.             return $descriptions;
  272.         }
  273.     
  274.         return $descriptions;
  275.     }
  276.  
  277.     // }}}
  278.     // {{{ getOverview()
  279.  
  280.     /**
  281.      * Returns the contents of all the fields in the database for an article specified by message-id, or from a specified article, or range of articles in the currently selected newsgroup
  282.      *
  283.      * The format of the returned array is:
  284.      * $messages[message_id][header_name]
  285.      *
  286.      * @param integer $first first article to fetch
  287.      * @param integer $last  last article to fetch
  288.      *
  289.      * @return mixed (array) nested array of message and their headers on success or (object) pear_error on failure
  290.      * @access public
  291.      * @see Net_NNTP_Client::getOverviewFormat()
  292.      * @see Net_NNTP_Client::getReferencesOverview()
  293.      */
  294.     function getOverview($first$last)
  295.     {
  296.         $range $first '-' $last;
  297.  
  298.         $overview $this->cmdXOver($range);
  299.         if (PEAR::isError($overview)) {
  300.             return $overview;
  301.         }
  302.     
  303.         return $overview;
  304.     }
  305.  
  306.     // }}}
  307.     // {{{ getOverviewFormat()
  308.  
  309.     /**
  310.      * Returns a description of the fields in the database for which it is consistent
  311.      *
  312.      * @return mixed (array) header names on success or (object) pear_error on failure
  313.      * @access public
  314.      * @see Net_NNTP_Client::getOverview()
  315.      */
  316.     function getOverviewFormat()
  317.     {
  318.         $format $this->cmdListOverviewFmt();
  319.         if (PEAR::isError($format)) {
  320.             return $format;
  321.         }
  322.  
  323.         if (true{
  324.             return array_keys($format);
  325.         else {
  326.             return $format;
  327.         }
  328.     }
  329.  
  330.     // }}}
  331.     // {{{ getReferencesOverview()
  332.  
  333.     /**
  334.      * Fetch a list of each message's reference header field.
  335.      *
  336.      * @param integer $first first article to fetch
  337.      * @param integer $last  last article to fetch
  338.      *
  339.      * @return mixed (array) nested array of references on success or (object) pear_error on failure
  340.      * @access public
  341.      * @see Net_NNTP_Client::getOverview()
  342.      * @see Net_NNTP_Client::getHeaderField()
  343.      */
  344.     function getReferencesOverview($first$last)
  345.     {
  346.         $range $first '-' $last;
  347.  
  348.         $references $this->cmdXHdr('References'$range);
  349.         if (PEAR::isError($references)) {
  350.             if ($references->getCode(!= 500{
  351.                 return $references;
  352.             }
  353.  
  354.             $references $this->cmdXROver($range);
  355.             if (PEAR::isError($references)) {
  356.                 return $references;
  357.             }
  358.         }
  359.  
  360.         foreach ($references as $key => $val{
  361.             $references[$keypreg_split("/ +/"trim($val)-1PREG_SPLIT_NO_EMPTY);
  362.         }
  363.  
  364.         return $references;
  365.     }
  366.  
  367.     // }}}
  368.     // {{{ getHeaderField()
  369.  
  370.     /**
  371.      * Fetch a header field from a number of message.
  372.      *
  373.      * Experimental
  374.      *
  375.      * @param stringr $field 
  376.      * @param integer $first first article to fetch
  377.      * @param integer $last  last article to fetch
  378.      *
  379.      * @return mixed (array) nested array of references on success or (object) pear_error on failure
  380.      * @access public
  381.      * @see Net_NNTP_Client::getOverview()
  382.      * @see Net_NNTP_Client::getReferencesOverview()
  383.      */
  384.     function getHeaderField($field$first$last)
  385.     {
  386.         $range $first '-' $last;
  387.  
  388.         $fields $this->cmdXHdr($field$range);
  389.         if (PEAR::isError($fields)) {
  390.             return $fields;
  391.         }
  392.  
  393.         return $fields;
  394.     }
  395.  
  396.     // }}}
  397.     // {{{ post()
  398.  
  399.     /**
  400.      * Post an article to a number of newsgroups.
  401.      *
  402.      * (Among the aditional headers you might think of adding could be:
  403.      * "NNTP-Posting-Host: <ip-of-author>", which should contain the IP-address
  404.      * of the author of the post, so the message can be traced back to him.
  405.      * Or "Organization: <org>" which contain the name of the organization
  406.      * the post originates from)
  407.      *
  408.      * @param string $newsgroups The newsgroup to post to.
  409.      * @param string $subject The subject of the post.
  410.      * @param string $body The body of the post itself.
  411.      * @param string $from Name + email-adress of sender.
  412.      * @param optional string $aditional Aditional headers to send.
  413.      *
  414.      * @return mixed (string) server response on success or (object) pear_error on failure
  415.      * @access public
  416.      */
  417.     function post($newsgroups$subject$body$from$aditional = null)
  418.     {
  419.         return $this->cmdPost($newsgroups$subject$body$from$aditional);
  420.     }
  421.  
  422.     // }}}
  423.     // {{{ selectArticle()
  424.  
  425.     /**
  426.      * Selects an article by article message-number
  427.      *
  428.      * @param int $article The message-number (on the server) of the article to select as current article.
  429.      *
  430.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  431.      * @access public
  432.      * @see Net_NNTP_Client::selectNextArticle()
  433.      * @see Net_NNTP_Client::selectPreviousArticle()
  434.      */
  435.     function selectArticle($article)
  436.     {
  437.         $response_arr $this->cmdStat($article);
  438.  
  439.         if (PEAR::isError($response_arr)) {
  440.             switch ($response_arr->getCode()) {
  441.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_SUCH_ARTICLE_NUMBER// 423
  442.                     return false;
  443.                     break;
  444.  
  445.                 default:
  446.                     return $response_arr;
  447.             }
  448.     }
  449.  
  450.         return true;
  451.     }
  452.  
  453.     // }}}
  454.     // {{{ selectNextArticle()
  455.  
  456.     /**
  457.      * Select the next article in current group
  458.      *
  459.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  460.      * @access public
  461.      * @see Net_NNTP_Client::selectArticle()
  462.      * @see Net_NNTP_Client::selectPreviousArticle()
  463.      */
  464.     function selectNextArticle()
  465.     {
  466.         $response $this->cmdNext();
  467.  
  468.         if (PEAR::isError($response)) {
  469.             switch ($response->getCode()) {
  470.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_NEXT_ARTICLE// 421
  471.                     return false;
  472.                     break;
  473.  
  474.                 default:
  475.                     return $response;
  476.             }
  477.     }
  478.  
  479.         return true;
  480.     }
  481.  
  482.     // }}}
  483.     // {{{ selectPreviousArticle()
  484.  
  485.     /**
  486.      * Select the previous article in current group
  487.      *
  488.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  489.      * @access public
  490.      * @see Net_NNTP_Client::selectArticle()
  491.      * @see Net_NNTP_Client::selectNextArticle()
  492.      */
  493.     function selectPreviousArticle()
  494.     {
  495.         $response $this->cmdLast();
  496.  
  497.         if (PEAR::isError($response)) {
  498.             switch ($response->getCode()) {
  499.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_PREVIOUS_ARTICLE// 422
  500.                     return false;
  501.                     break;
  502.  
  503.                 default:
  504.                     return $response;
  505.             }
  506.         }
  507.  
  508.         return true;
  509.     }
  510.  
  511.     // }}}
  512.     // {{{ getArticle()
  513.  
  514.     /**
  515.      * Selects an article based on the arguments and returns the entire article.
  516.      *
  517.      * Experimental
  518.      *
  519.      * The v0.2 version of the this function (which returned the article as a string) has been renamed to getArticleRaw().
  520.      *
  521.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  522.      *
  523.      * @return mixed (object) message object on success or (object) pear_error on failure
  524.      * @access public
  525.      * @see Net_NNTP_Client::getArticleRaw()
  526.      * @see Net_NNTP_Client::getHeader()
  527.      * @see Net_NNTP_Client::getBody()
  528.      */
  529.     function getArticle($article$class 'Net_NNTP_Message'$implode = false)
  530.     {
  531.         $message $this->getArticleRaw($article$implode);
  532.         if (PEAR::isError($message)) {
  533.             return $data;
  534.         }
  535.  
  536.         if (!is_string($class)) {
  537.             return PEAR::throwError('UPS...');
  538.         }
  539.  
  540.         if (!class_exists($class)) {
  541.             return PEAR::throwError("Class '$class' does not exist!");
  542.     }
  543.  
  544.     $M = new $class($message);
  545.  
  546.         return $M;
  547.     }
  548.  
  549.     // }}}
  550.     // {{{ getArticleRaw()
  551.  
  552.     /**
  553.      * Selects an article based on the arguments and returns the entire article (raw data)
  554.      *
  555.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  556.      * @param optional bool  $implode When true the result array is imploded to a string, defaults to false.
  557.      *
  558.      * @return mixed (array/string) The article on success or (object) pear_error on failure
  559.      * @access public
  560.      * @see Net_NNTP_Client::getArticle()
  561.      * @see Net_NNTP_Client::getHeaderRaw()
  562.      * @see Net_NNTP_Client::getBodyRaw()
  563.      */
  564.     function getArticleRaw($article$implode = false)
  565.     {
  566.         $data $this->cmdArticle($article);
  567.         if (PEAR::isError($data)) {
  568.             return $data;
  569.         }
  570.  
  571.         if ($implode == true{
  572.             $data implode("\r\n"$data);
  573.         }
  574.  
  575.         return $data;
  576.     }
  577.  
  578.     // }}}
  579.     // {{{ getHeader()
  580.  
  581.     /**
  582.      * Selects an article based on the arguments and returns the article header
  583.      *
  584.      * Experimental
  585.      *
  586.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  587.      *
  588.      * @return mixed (object) header object on success or (object) pear_error on failure
  589.      * @access public
  590.      * @see Net_NNTP_Client::getHeaderRaw()
  591.      * @see Net_NNTP_Client::getArticle()
  592.      * @see Net_NNTP_Client::getBody()
  593.      */
  594.     function getHeader($article$class 'Net_NNTP_Header'$implode = false)
  595.     {
  596.         $header $this->getHeaderRaw($article$implode);
  597.         if (PEAR::isError($header)) {
  598.             return $header;
  599.         }
  600.  
  601.         if (!is_string($class)) {
  602.             return PEAR::throwError('UPS...');
  603.         }
  604.  
  605.         if (!class_exists($class)) {
  606.             return PEAR::throwError("Class '$class' does not exist!");
  607.     }
  608.  
  609.     $H = new $class($header);
  610.  
  611.         return $H;
  612.     }
  613.  
  614.     // }}}
  615.     // {{{ getHeaderRaw()
  616.  
  617.     /**
  618.      * Selects an article based on the arguments and returns the article header (raw data)
  619.      *
  620.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  621.      * @param optional bool $implode When true the result array is imploded to a string, defaults to false.
  622.      *
  623.      * @return mixed (array/string) header fields on success or (object) pear_error on failure
  624.      * @access public
  625.      * @see Net_NNTP_Client::getHeader()
  626.      * @see Net_NNTP_Client::getArticleRaw()
  627.      * @see Net_NNTP_Client::getBodyRaw()
  628.      */
  629.     function getHeaderRaw($article$implode = false)
  630.     {
  631.         $data $this->cmdHead($article);
  632.         if (PEAR::isError($data)) {
  633.             return $data;
  634.         }
  635.  
  636.         if ($implode == true{
  637.             $data implode("\r\n"$data);
  638.         }
  639.  
  640.         return $data;
  641.     }
  642.  
  643.     // }}}
  644.     // {{{ getBody()
  645.  
  646.     /**
  647.      * Selects an article based on the arguments and returns the article body
  648.      *
  649.      * Experimental
  650.      *
  651.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  652.      *
  653.      * @return mixed (object) body object on success or (object) pear_error on failure
  654.      * @access public
  655.      * @see Net_NNTP_Client::getHeader()
  656.      * @see Net_NNTP_Client::getArticle()
  657.      * @see Net_NNTP_Client::getBodyRaw()
  658.      */
  659.     function getBody($article$class$implode = false)
  660.     {
  661.         $body $this->getBodyRaw($article$implode);
  662.         if (PEAR::isError($body)) {
  663.             return $body;
  664.         }
  665.  
  666.         if (!is_string($class)) {
  667.             return PEAR::throwError('UPS...');
  668.         }
  669.  
  670.         if (!class_exists($class)) {
  671.             return PEAR::throwError("Class '$class' does not exist!");
  672.     }
  673.  
  674.     $B = new $class($body);
  675.  
  676.         return $B;
  677.     }
  678.  
  679.     // }}}
  680.     // {{{ getBodyRaw()
  681.  
  682.     /**
  683.      * Selects an article based on the arguments and returns the article body (raw data)
  684.      *
  685.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  686.      * @param optional bool $implode When true the result array is imploded to a string, defaults to false.
  687.      *
  688.      * @return mixed (array/string) body on success or (object) pear_error on failure
  689.      * @access public
  690.      * @see Net_NNTP_Client::getBody()
  691.      * @see Net_NNTP_Client::getHeaderRaw()
  692.      * @see Net_NNTP_Client::getArticleRaw()
  693.      */
  694.     function getBodyRaw($article$implode = false)
  695.     {
  696.         $data $this->cmdBody($article);
  697.         if (PEAR::isError($data)) {
  698.             return $data;
  699.         }
  700.     
  701.         if ($implode == true{
  702.             $data implode("\r\n"$data);
  703.         }
  704.     
  705.         return $data;
  706.     }
  707.  
  708.     // }}}
  709.     // {{{ getGroupArticles()
  710.  
  711.     /**
  712.      * Selects a group in the same manner as the the selectGroup method, but also provides a list of article numbers in the group
  713.      *
  714.      * Experimental
  715.      *
  716.      * @return mixed (array) on success or (object) pear_error on failure
  717.      * @access public
  718.      * @since 0.3
  719.      */
  720.     function getGroupArticles($newsgroup)
  721.     {
  722.         $data $this->cmdListgroup($newsgroup);
  723.  
  724.     return $data['articles'];
  725.     }
  726.  
  727.     // }}}
  728.     // {{{ getNewGroups()
  729.  
  730.     /**
  731.      * Returns a list of newsgroups created on the server since the specified date and time
  732.      *
  733.      * Experimental
  734.      *
  735.      * @return mixed (array) on success or (object) pear_error on failure
  736.      * @access public
  737.      * @since 0.3
  738.      */
  739.     function getNewGroups($time$distributions = null)
  740.     {
  741.         switch (gettype($time)) {
  742.             case 'integer':
  743.                 break;
  744.             case 'string':
  745.                 $time = (int) strtotime($time);
  746.                 break;
  747.             default:
  748.                 return PEAR::throwError('UPS...');
  749.         }
  750.  
  751.         return $this->cmdNewgroups($time$distributions);
  752.     }
  753.  
  754.     // }}}
  755.     // {{{ getNewNews()
  756.  
  757.     /**
  758.      * Returns a list of message-ids of new articles (since the specified date and time) in the groups whose names match the wildmat
  759.      *
  760.      * Experimental
  761.      *
  762.      * @return mixed (array) on success or (object) pear_error on failure
  763.      * @access public
  764.      * @since 0.3
  765.      */
  766.     function getNewNews($time$newsgroups '*'$distribution = null)
  767.     {
  768.         switch (gettype($time)) {
  769.             case 'integer':
  770.                 break;
  771.             case 'string':
  772.                 $time = (int) strtotime($time);
  773.                 break;
  774.             default:
  775.                 return PEAR::throwError('UPS...');
  776.         }
  777.  
  778.         return $this->cmdNewnews($time$newsgroups$distribution);
  779.     }
  780.  
  781.     // }}}
  782.     // {{{ getDate()
  783.  
  784.     /**
  785.      * Get the NNTP-server's internal date
  786.      *
  787.      * Get the date from the newsserver format of returned date:
  788.      *
  789.      * @param optional int $format
  790.      *   - 0: $date - timestamp
  791.      *   - 1: $date['y'] - year
  792.      *        $date['m'] - month
  793.      *        $date['d'] - day
  794.      *
  795.      * @return mixed (mixed) date on success or (object) pear_error on failure
  796.      * @access public
  797.      * @since 0.3
  798.      */
  799.     function getDate($format = 1)
  800.     {
  801.         $date $this->cmdDate();
  802.         if (PEAR::isError($date)) {
  803.             return $date;
  804.         }
  805.  
  806.         switch ($format{
  807.             case 1:
  808.                 return array('y' => substr($date04)'m' => substr($date42)'d' => substr($date62));
  809.                 break;
  810.  
  811.             case 0:
  812.             default:
  813.                 return $date;
  814.                 break;
  815.         }
  816.     }
  817.  
  818.     // }}}
  819.     // {{{ count()
  820.  
  821.     /**
  822.      * Number of articles in currently selected group
  823.      *
  824.      * @return integer number of article in group
  825.      * @access public
  826.      * @since 0.3
  827.      * @see Net_NNTP_Client::group()
  828.      * @see Net_NNTP_Client::first()
  829.      * @see Net_NNTP_Client::last()
  830.      * @see Net_NNTP_Client::selectGroup()
  831.      */
  832.     function count()
  833.     {
  834.         return $this->_currentGroup['count'];
  835.     }
  836.  
  837.     // }}}
  838.     // {{{ last()
  839.  
  840.     /**
  841.      * Maximum article number in currently selected group
  842.      *
  843.      * @return integer number of last article
  844.      * @access public
  845.      * @since 0.3
  846.      * @see Net_NNTP_Client::first()
  847.      * @see Net_NNTP_Client::group()
  848.      * @see Net_NNTP_Client::count()
  849.      * @see Net_NNTP_Client::selectGroup()
  850.      */
  851.     function last()
  852.     {
  853.         return $this->_currentGroup['last'];
  854.     }
  855.  
  856.     // }}}
  857.     // {{{ first()
  858.  
  859.     /**
  860.      * Minimum article number in currently selected group
  861.      *
  862.      * @return integer number of first article
  863.      * @access public
  864.      * @since 0.3
  865.      * @see Net_NNTP_Client::last()
  866.      * @see Net_NNTP_Client::group()
  867.      * @see Net_NNTP_Client::count()
  868.      * @see Net_NNTP_Client::selectGroup()
  869.      */
  870.     function first()
  871.     {
  872.         return $this->_currentGroup['first'];
  873.     }
  874.  
  875.     // }}}
  876.     // {{{ group()
  877.  
  878.     /**
  879.      * Currently selected group
  880.      *
  881.      * @return string group name
  882.      * @access public
  883.      * @since 0.3
  884.      * @see Net_NNTP_Client::first()
  885.      * @see Net_NNTP_Client::last()
  886.      * @see Net_NNTP_Client::count()
  887.      * @see Net_NNTP_Client::selectGroup()
  888.      */
  889.     function group()
  890.     {
  891.         return $this->_currentGroup['group'];
  892.     }
  893.  
  894.     // }}}
  895. }
  896.  
  897. // }}}
  898.  
  899. ?>

Documentation generated on Mon, 11 Mar 2019 14:05:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.