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.4 2005/10/20 17:23:33 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.4 2005/10/20 17:23:33 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) true on success or (object) pear_error on failure
  123.      * @access public
  124.      * @see Net_NNTP_Client::quit()
  125.      * @see Net_NNTP_Client::authenticate()
  126.      * @see Net_NNTP_Client::connectAuthenticated()
  127.      */
  128.     function connect($host = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_HOST,
  129.                      $port = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_PORT)
  130.     {
  131.         return parent::connect($host$port);
  132.     }
  133.  
  134.     // }}}
  135.     // {{{ connectAuthenticated()
  136.  
  137.     /**
  138.      * Connect to the NNTP-server, and authenticate using given username and password.
  139.      *
  140.      * @param optional string $user The username.
  141.      * @param optional string $pass The password.
  142.      * @param optional string $host The IP-address of the NNTP-server to connect to.
  143.      * @param optional int $port The port to connect to.
  144.      * @param optional string $authmode The authentication mode.
  145.      *
  146.      * @return mixed (bool) true on success or (object) pear_error on failure
  147.      * @access public
  148.      * @since 0.3
  149.      * @deprecated use connect() and authenticate() instead
  150.      * @see Net_NNTP_Client::connect()
  151.      * @see Net_NNTP_Client::authenticate()
  152.      * @see Net_NNTP_Client::quit()
  153.      */
  154.     function connectAuthenticated($user = null,
  155.                                   $pass = null,
  156.                                   $host = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_HOST,
  157.                                   $port = NET_NNTP_PROTOCOL_CLIENT_DEFAULT_PORT,
  158.                                   $authmode = NET_NNTP_CLIENT_AUTH_ORIGINAL)
  159.     {
  160.     $R $this->connect($host$port);
  161.     if (PEAR::isError($R)) {
  162.         return $R;
  163.     }
  164.  
  165.     // Authenticate if username is given
  166.     if ($user != null{
  167.             $R $this->authenticate($user$pass$authmode);
  168.             if (PEAR::isError($R)) {
  169.                 return $R;
  170.             }
  171.     }
  172.  
  173.         return true;
  174.     }
  175.  
  176.     // }}}
  177.     // {{{ quit()
  178.  
  179.     /**
  180.      * Close connection to the newsserver
  181.      *
  182.      * @access public
  183.      * @see Net_NNTP_Client::connect()
  184.      */
  185.     function quit()
  186.     {
  187.         return $this->cmdQuit();
  188.     }
  189.  
  190.     // }}}
  191.     // {{{ authenticate()
  192.  
  193.     /**
  194.      * Authenticate
  195.      * 
  196.      * Auth process (not yet standarized but used any way)
  197.      * http://www.mibsoftware.com/userkt/nntpext/index.html
  198.      *
  199.      * @param string $user The username
  200.      * @param optional string $pass The password
  201.      * @param optional string $mode The authentication mode (original, simple, generic).
  202.      *
  203.      * @return mixed (bool) true on success or (object) pear_error on failure
  204.      * @access public
  205.      * @see Net_NNTP_Client::connect()
  206.      * @see Net_NNTP_Client::connectAuthenticated()
  207.      */
  208.     function authenticate($user$pass$mode = NET_NNTP_CLIENT_AUTH_ORIGINAL)
  209.     {
  210.         // Username is a must...
  211.         if ($user == null{
  212.             return PEAR::throwError('No username supplied'null);
  213.         }
  214.  
  215.         // Use selected authentication method
  216.         switch ($mode{
  217.             case NET_NNTP_CLIENT_AUTH_ORIGINAL:
  218.                 return $this->cmdAuthinfo($user$pass);
  219.                 break;
  220.             case NET_NNTP_CLIENT_AUTH_SIMPLE:
  221.                 return $this->cmdAuthinfoSimple($user$pass);
  222.                 break;
  223.             case NET_NNTP_CLIENT_AUTH_GENERIC:
  224.                 return $this->cmdAuthinfoGeneric($user$pass);
  225.                 break;
  226.             default:
  227.                 return PEAR::throwError("The auth mode: '$mode' is unknown"null);
  228.         }
  229.     }
  230.  
  231.     // }}}
  232.     // {{{ isConnected()
  233.  
  234.     /**
  235.      * Test whether a connection is currently open.
  236.      *
  237.      * @return bool true or false
  238.      * @access public
  239.      * @see Net_NNTP_Client::connect()
  240.      * @see Net_NNTP_Client::quit()
  241.      */
  242.     function isConnected()
  243.     {
  244.         return parent::isConnected();
  245.     }
  246.  
  247.     // }}}
  248.     // {{{ selectGroup()
  249.  
  250.     /**
  251.      * Selects a newsgroup
  252.      *
  253.      * @param string $newsgroup Newsgroup name
  254.      *
  255.      * @return mixed (array) Info about the newsgroup on success or (object) pear_error on failure
  256.      * @access public
  257.      * @see Net_NNTP_Client::group()
  258.      * @see Net_NNTP_Client::first()
  259.      * @see Net_NNTP_Client::last()
  260.      * @see Net_NNTP_Client::count()
  261.      * @see Net_NNTP_Client::getGroups()
  262.      */
  263.     function selectGroup($newsgroup)
  264.     {
  265.         $response_arr $this->cmdGroup($newsgroup);
  266.         if (PEAR::isError($response_arr)) {
  267.             return $response_arr;
  268.         }
  269.  
  270.         // Store group info in the object
  271.         $this->_currentGroup $response_arr;
  272.  
  273.         return $response_arr;
  274.     }
  275.  
  276.     // }}}
  277.     // {{{ getGroups()
  278.  
  279.     /**
  280.      * Fetches a list of all avaible newsgroups
  281.      *
  282.      * @return mixed (array) nested array with informations about existing newsgroups on success or (object) pear_error on failure
  283.      * @access public
  284.      * @see Net_NNTP_Client::selectGroup()
  285.      * @see Net_NNTP_Client::getDescriptions()
  286.      */
  287.     function getGroups()
  288.     {
  289.         // Get groups
  290.         $groups $this->cmdList();
  291.         if (PEAR::isError($groups)) {
  292.             return $groups;
  293.         }
  294.  
  295.         return $groups;
  296.     }
  297.  
  298.     // }}}
  299.     // {{{ getDescriptions()
  300.  
  301.     /**
  302.      * Fetches a list of all avaible newsgroup descriptions.
  303.      *
  304.      * @return mixed (array) nested array with description of existing newsgroups on success or (object) pear_error on failure
  305.      * @access public
  306.      * @see Net_NNTP_Client::getGroups()
  307.      */
  308.     function getDescriptions()
  309.     {
  310.         // Get group descriptions
  311.         $descriptions $this->cmdListNewsgroups();
  312.         if (PEAR::isError($descriptions)) {
  313.             return $descriptions;
  314.         }
  315.     
  316.         return $descriptions;
  317.     }
  318.  
  319.     // }}}
  320.     // {{{ getOverview()
  321.  
  322.     /**
  323.      * Fetch message header fields from message number $first to $last
  324.      *
  325.      * The format of the returned array is:
  326.      * $messages[message_id][header_name]
  327.      *
  328.      * @param integer $first first article to fetch
  329.      * @param integer $last  last article to fetch
  330.      *
  331.      * @return mixed (array) nested array of message and their headers on success or (object) pear_error on failure
  332.      * @access public
  333.      * @see Net_NNTP_Client::getOverviewFormat()
  334.      * @see Net_NNTP_Client::getReferencesOverview()
  335.      */
  336.     function getOverview($first$last)
  337.     {
  338.         $overview $this->cmdXOver($first.'-'.$last);
  339.         if (PEAR::isError($overview)) {
  340.             return $overview;
  341.         }
  342.     
  343.         return $overview;
  344.     }
  345.  
  346.     // }}}
  347.     // {{{ getOverviewFmt()
  348.  
  349.     /**
  350.      * Returns a list of avaible headers which are send from NNTP-server to the client for every news message
  351.      *
  352.      * @return mixed (array) header names on success or (object) pear_error on failure
  353.      * @access public
  354.      * @see Net_NNTP_Client::getOverview()
  355.      */
  356.     function getOverviewFormat()
  357.     {
  358.         return $this->cmdListOverviewFmt();
  359.     }
  360.  
  361.     // }}}
  362.     // {{{ getReferencesOverview()
  363.  
  364.     /**
  365.      * Fetch a list of each message's reference header.
  366.      *
  367.      * @param integer $first first article to fetch
  368.      * @param integer $last  last article to fetch
  369.      *
  370.      * @return mixed (array) nested array of references on success or (object) pear_error on failure
  371.      * @access public
  372.      * @see Net_NNTP_Client::getOverview()
  373.      */
  374.     function getReferencesOverview($first$last)
  375.     {
  376.         $overview $this->cmdXROver($first.'-'.$last);
  377.         if (PEAR::isError($overview)) {
  378.             return $overview;
  379.         }
  380.     
  381.         return $overview;
  382.     }
  383.  
  384.     // }}}
  385.     // {{{ post()
  386.  
  387.     /**
  388.      * Post an article to a number of newsgroups.
  389.      *
  390.      * (Among the aditional headers you might think of adding could be:
  391.      * "NNTP-Posting-Host: <ip-of-author>", which should contain the IP-address
  392.      * of the author of the post, so the message can be traced back to him.
  393.      * Or "Organization: <org>" which contain the name of the organization
  394.      * the post originates from)
  395.      *
  396.      * @param string $newsgroups The newsgroup to post to.
  397.      * @param string $subject The subject of the post.
  398.      * @param string $body The body of the post itself.
  399.      * @param string $from Name + email-adress of sender.
  400.      * @param optional string $aditional Aditional headers to send.
  401.      *
  402.      * @return mixed (string) server response on success or (object) pear_error on failure
  403.      * @access public
  404.      */
  405.     function post($newsgroups$subject$body$from$aditional = null)
  406.     {
  407.         return $this->cmdPost($newsgroups$subject$body$from$aditional);
  408.     }
  409.  
  410.     // }}}
  411.     // {{{ selectArticle()
  412.  
  413.     /**
  414.      * Selects an article by article message-number
  415.      *
  416.      * @param int $article The message-number (on the server) of the article to select as current article.
  417.      *
  418.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  419.      * @access public
  420.      * @see Net_NNTP_Client::selectNextArticle()
  421.      * @see Net_NNTP_Client::selectPreviousArticle()
  422.      */
  423.     function selectArticle($article)
  424.     {
  425.         $response_arr $this->cmdStat($article);
  426.  
  427.         if (PEAR::isError($response_arr)) {
  428.             switch ($response_arr->getCode()) {
  429.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_SUCH_ARTICLE_NUMBER// 423
  430.                     return false;
  431.                     break;
  432.  
  433.                 default:
  434.                     return $response_arr;
  435.             }
  436.     }
  437.  
  438.         return true;
  439.     }
  440.  
  441.     // }}}
  442.     // {{{ selectNextArticle()
  443.  
  444.     /**
  445.      * Select the next article in current group
  446.      *
  447.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  448.      * @access public
  449.      * @see Net_NNTP_Client::selectArticle()
  450.      * @see Net_NNTP_Client::selectPreviousArticle()
  451.      */
  452.     function selectNextArticle()
  453.     {
  454.         $response $this->cmdNext();
  455.  
  456.         if (PEAR::isError($response)) {
  457.             switch ($response->getCode()) {
  458.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_NEXT_ARTICLE// 421
  459.                     return false;
  460.                     break;
  461.  
  462.                 default:
  463.                     return $response;
  464.             }
  465.     }
  466.  
  467.         return true;
  468.     }
  469.  
  470.     // }}}
  471.     // {{{ selectPreviousArticle()
  472.  
  473.     /**
  474.      * Select the previous article in current group
  475.      *
  476.      * @return mixed true on success, false if article doesn't exist, and (object) pear_error on unexpected failure
  477.      * @access public
  478.      * @see Net_NNTP_Client::selectArticle()
  479.      * @see Net_NNTP_Client::selectNextArticle()
  480.      */
  481.     function selectPreviousArticle()
  482.     {
  483.         $response $this->cmdLast();
  484.  
  485.         if (PEAR::isError($response)) {
  486.             switch ($response->getCode()) {
  487.                 case NET_NNTP_PROTOCOL_RESPONSECODE_NO_PREVIOUS_ARTICLE// 422
  488.                     return false;
  489.                     break;
  490.  
  491.                 default:
  492.                     return $response;
  493.             }
  494.         }
  495.  
  496.         return true;
  497.     }
  498.  
  499.     // }}}
  500.     // {{{ getArticle()
  501.  
  502.     /**
  503.      * Get an article
  504.      *
  505.      * Experimental
  506.      *
  507.      * The v0.2 version of the this function (which returned the article as a string) has been renamed to getArticleRaw().
  508.      *
  509.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  510.      *
  511.      * @return mixed (object) message object on success or (object) pear_error on failure
  512.      * @access public
  513.      * @see Net_NNTP_Client::getArticleRaw()
  514.      * @see Net_NNTP_Client::getHeader()
  515.      * @see Net_NNTP_Client::getBody()
  516.      */
  517.     function getArticle($article$class 'Net_NNTP_Message'$implode = false)
  518.     {
  519.         $message $this->getArticleRaw($article$implode);
  520.         if (PEAR::isError($message)) {
  521.             return $data;
  522.         }
  523.  
  524.         if (!is_string($class)) {
  525.             return PEAR::throwError('UPS...');
  526.         }
  527.  
  528.         if (!class_exists($class)) {
  529.             return PEAR::throwError("Class '$class' does not exist!");
  530.     }
  531.  
  532.     $M = new $class($message);
  533.  
  534.         return $M;
  535.     }
  536.  
  537.     // }}}
  538.     // {{{ getArticleRaw()
  539.  
  540.     /**
  541.      * Get a article (raw data)
  542.      *
  543.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  544.      * @param optional bool  $implode When true the result array is imploded to a string, defaults to false.
  545.      *
  546.      * @return mixed (array/string) The article on success or (object) pear_error on failure
  547.      * @access public
  548.      * @see Net_NNTP_Client::getArticle()
  549.      * @see Net_NNTP_Client::getHeaderRaw()
  550.      * @see Net_NNTP_Client::getBodyRaw()
  551.      */
  552.     function getArticleRaw($article$implode = false)
  553.     {
  554.         $data $this->cmdArticle($article);
  555.         if (PEAR::isError($data)) {
  556.             return $data;
  557.         }
  558.  
  559.         if ($implode == true{
  560.             $data implode("\r\n"$data);
  561.         }
  562.  
  563.         return $data;
  564.     }
  565.  
  566.     // }}}
  567.     // {{{ getHeader()
  568.  
  569.     /**
  570.      * Get the header of an article
  571.      *
  572.      * Experimental
  573.      *
  574.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  575.      *
  576.      * @return mixed (object) header object on success or (object) pear_error on failure
  577.      * @access public
  578.      * @see Net_NNTP_Client::getHeaderRaw()
  579.      * @see Net_NNTP_Client::getArticle()
  580.      * @see Net_NNTP_Client::getBody()
  581.      */
  582.     function getHeader($article$class 'Net_NNTP_Header'$implode = false)
  583.     {
  584.         $header $this->getHeaderRaw($article$implode);
  585.         if (PEAR::isError($header)) {
  586.             return $header;
  587.         }
  588.  
  589.         if (!is_string($class)) {
  590.             return PEAR::throwError('UPS...');
  591.         }
  592.  
  593.         if (!class_exists($class)) {
  594.             return PEAR::throwError("Class '$class' does not exist!");
  595.     }
  596.  
  597.     $H = new $class($header);
  598.  
  599.         return $H;
  600.     }
  601.  
  602.     // }}}
  603.     // {{{ getHeaderRaw()
  604.  
  605.     /**
  606.      * Get the header of an article (raw data)
  607.      *
  608.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  609.      * @param optional bool $implode When true the result array is imploded to a string, defaults to false.
  610.      *
  611.      * @return mixed (array/string) header fields on success or (object) pear_error on failure
  612.      * @access public
  613.      * @see Net_NNTP_Client::getHeader()
  614.      * @see Net_NNTP_Client::getArticleRaw()
  615.      * @see Net_NNTP_Client::getBodyRaw()
  616.      */
  617.     function getHeaderRaw($article$implode = false)
  618.     {
  619.         $data $this->cmdHead($article);
  620.         if (PEAR::isError($data)) {
  621.             return $data;
  622.         }
  623.  
  624.         if ($implode == true{
  625.             $data implode("\r\n"$data);
  626.         }
  627.  
  628.         return $data;
  629.     }
  630.  
  631.     // }}}
  632.     // {{{ getBody()
  633.  
  634.     /**
  635.      * Get the body of an article
  636.      *
  637.      * Experimental
  638.      *
  639.      * @param mixed $article Either the (string) message-id or the (int) message-number on the server of the article to fetch.
  640.      *
  641.      * @return mixed (object) body object on success or (object) pear_error on failure
  642.      * @access public
  643.      * @see Net_NNTP_Client::getHeader()
  644.      * @see Net_NNTP_Client::getArticle()
  645.      * @see Net_NNTP_Client::getBodyRaw()
  646.      */
  647.     function getBody($article$class$implode = false)
  648.     {
  649.         $body $this->getBodyRaw($article$implode);
  650.         if (PEAR::isError($body)) {
  651.             return $body;
  652.         }
  653.  
  654.         if (!is_string($class)) {
  655.             return PEAR::throwError('UPS...');
  656.         }
  657.  
  658.         if (!class_exists($class)) {
  659.             return PEAR::throwError("Class '$class' does not exist!");
  660.     }
  661.  
  662.     $B = new $class($body);
  663.  
  664.         return $B;
  665.     }
  666.  
  667.     // }}}
  668.     // {{{ getBodyRaw()
  669.  
  670.     /**
  671.      * Get the body of an article (raw data)
  672.      *
  673.      * @param mixed $article Either the message-id or the message-number on the server of the article to fetch.
  674.      * @param optional bool $implode When true the result array is imploded to a string, defaults to false.
  675.      *
  676.      * @return mixed (array/string) body on success or (object) pear_error on failure
  677.      * @access public
  678.      * @see Net_NNTP_Client::getBody()
  679.      * @see Net_NNTP_Client::getHeaderRaw()
  680.      * @see Net_NNTP_Client::getArticleRaw()
  681.      */
  682.     function getBodyRaw($article$implode = false)
  683.     {
  684.         $data $this->cmdBody($article);
  685.         if (PEAR::isError($data)) {
  686.             return $data;
  687.         }
  688.     
  689.         if ($implode == true{
  690.             $data implode("\r\n"$data);
  691.         }
  692.     
  693.         return $data;
  694.     }
  695.  
  696.     // }}}
  697.     // {{{ getGroupArticles()
  698.  
  699.     /**
  700.      * Experimental
  701.      *
  702.      * @access public
  703.      * @since 0.3
  704.      */
  705.     function getGroupArticles($newsgroup)
  706.     {
  707.         $data $this->cmdListgroup($newsgroup);
  708.  
  709.     return $data['articles'];
  710.     }
  711.  
  712.     // }}}
  713.     // {{{ getNewGroups()
  714.  
  715.     /**
  716.      * Experimental
  717.      *
  718.      * @access public
  719.      * @since 0.3
  720.      */
  721.     function getNewGroups($time$distributions = null)
  722.     {
  723.         switch (gettype($time)) {
  724.             case 'integer':
  725.                 break;
  726.             case 'string':
  727.                 $time = (int) strtotime($time);
  728.                 break;
  729.             default:
  730.                 return PEAR::throwError('UPS...');
  731.         }
  732.  
  733.         return $this->cmdNewgroups($time$distributions);
  734.     }
  735.  
  736.     // }}}
  737.     // {{{ getNewNews()
  738.  
  739.     /**
  740.      * Experimental
  741.      *
  742.      * @access public
  743.      * @since 0.3
  744.      */
  745.     function getNewNews($time$newsgroups '*'$distribution = null)
  746.     {
  747.         switch (gettype($time)) {
  748.             case 'integer':
  749.                 break;
  750.             case 'string':
  751.                 $time = (int) strtotime($time);
  752.                 break;
  753.             default:
  754.                 return PEAR::throwError('UPS...');
  755.         }
  756.  
  757.         return $this->cmdNewnews($time$newsgroups$distribution);
  758.     }
  759.  
  760.     // }}}
  761.     // {{{ getDate()
  762.  
  763.     /**
  764.      * Get the NNTP-server's internal date
  765.      *
  766.      * Get the date from the newsserver format of returned date:
  767.      *
  768.      * @param optional int $format
  769.      *   - 0: $date - timestamp
  770.      *   - 1: $date['y'] - year
  771.      *        $date['m'] - month
  772.      *        $date['d'] - day
  773.      *
  774.      * @return mixed (mixed) date on success or (object) pear_error on failure
  775.      * @access public
  776.      * @since 0.3
  777.      */
  778.     function getDate($format = 1)
  779.     {
  780.         $date $this->cmdDate();
  781.         if (PEAR::isError($date)) {
  782.             return $date;
  783.         }
  784.  
  785.         switch ($format{
  786.             case 1:
  787.                 return array('y' => substr($date04)'m' => substr($date42)'d' => substr($date62));
  788.                 break;
  789.  
  790.             case 0:
  791.             default:
  792.                 return $date;
  793.                 break;
  794.         }
  795.     }
  796.  
  797.     // }}}
  798.     // {{{ count()
  799.  
  800.     /**
  801.      * Number of articles in currently selected group
  802.      *
  803.      * @return integer number of article in group
  804.      * @access public
  805.      * @since 0.3
  806.      * @see Net_NNTP_Client::group()
  807.      * @see Net_NNTP_Client::first()
  808.      * @see Net_NNTP_Client::last()
  809.      * @see Net_NNTP_Client::selectGroup()
  810.      */
  811.     function count()
  812.     {
  813.         return $this->_currentGroup['count'];
  814.     }
  815.  
  816.     // }}}
  817.     // {{{ last()
  818.  
  819.     /**
  820.      * Maximum article number in currently selected group
  821.      *
  822.      * @return integer number of last article
  823.      * @access public
  824.      * @since 0.3
  825.      * @see Net_NNTP_Client::first()
  826.      * @see Net_NNTP_Client::group()
  827.      * @see Net_NNTP_Client::count()
  828.      * @see Net_NNTP_Client::selectGroup()
  829.      */
  830.     function last()
  831.     {
  832.         return $this->_currentGroup['last'];
  833.     }
  834.  
  835.     // }}}
  836.     // {{{ first()
  837.  
  838.     /**
  839.      * Minimum article number in currently selected group
  840.      *
  841.      * @return integer number of first article
  842.      * @access public
  843.      * @since 0.3
  844.      * @see Net_NNTP_Client::last()
  845.      * @see Net_NNTP_Client::group()
  846.      * @see Net_NNTP_Client::count()
  847.      * @see Net_NNTP_Client::selectGroup()
  848.      */
  849.     function first()
  850.     {
  851.         return $this->_currentGroup['first'];
  852.     }
  853.  
  854.     // }}}
  855.     // {{{ group()
  856.  
  857.     /**
  858.      * Currently selected group
  859.      *
  860.      * @return string group name
  861.      * @access public
  862.      * @since 0.3
  863.      * @see Net_NNTP_Client::first()
  864.      * @see Net_NNTP_Client::last()
  865.      * @see Net_NNTP_Client::count()
  866.      * @see Net_NNTP_Client::selectGroup()
  867.      */
  868.     function group()
  869.     {
  870.         return $this->_currentGroup['group'];
  871.     }
  872.  
  873.     // }}}
  874. }
  875.  
  876. // }}}
  877.  
  878. ?>

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