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

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