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

Source for file FTPHost.class.php

Documentation is available at FTPHost.class.php

  1. <?php
  2. /**
  3.  * @package    communication
  4.  */
  5.  
  6. /**
  7.  * Including various functions to manipulate arrays.
  8.  */
  9. require_onceCLASSPATH."core/Arrays.class.php" );
  10.  
  11. /**
  12.  *
  13.  */
  14. include_onceCLASSPATH."filesystem/Files.class.php" );
  15.  
  16. /**
  17.  * @see http://www.php.net/manual/en/function.ftp-chmod.php#66456
  18.  */
  19. if !function_exists('ftp_chmod') )
  20. {
  21.     /**
  22.      * Sets the permissions on the specified remote file to mode.
  23.      *
  24.      * @author rabin at rab dot in
  25.      *
  26.      * @param resource $ftp_stream 
  27.      * @param int      $mode 
  28.      * @param string   $filename 
  29.      *
  30.      * @return boolean 
  31.      */
  32.     function ftp_chmod($ftp_stream$mode$filename)
  33.     {
  34.         if is_int$mode ) )
  35.         {
  36.             return ftp_site(
  37.                                 $ftp_stream,
  38.                                 sprintf('CHMOD %o %s'$mode$filename)
  39.                            );
  40.         }
  41.         else
  42.         {
  43.             return ftp_site(
  44.                                 $ftp_stream,
  45.                                 sprintf('CHMOD %u %s'$mode$filename)
  46.                            );
  47.         }
  48.     }
  49. }
  50.  
  51. /**
  52.  * @package    communication
  53.  *
  54.  * @version    0.2.15
  55.  * @todo       Functions
  56.  *              file_exists()
  57.  * @author     Daniel Plücken <daniel@debakel.net>
  58.  * @license    http://www.gnu.org/copyleft/lesser.html
  59.  *              GNU Lesser General Public License
  60.  * @copyright  Copyright (C) 2005 Daniel Plücken <daniel@debakel.net>
  61.  *
  62.  *  This library is free software; you can redistribute it and/or
  63.  *  modify it under the terms of the GNU Lesser General Public
  64.  *  License as published by the Free Software Foundation; either
  65.  *  version 2.1 of the License.
  66.  *
  67.  *  This library is distributed in the hope that it will be useful,
  68.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  69.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  70.  *  GNU Lesser General Public License for more details.
  71.  *
  72.  *  You should have received a copy of the GNU Lesser General
  73.  *  Public License along with this library; if not, write to the
  74.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  75.  *  Boston, MA 02111-1307 USA
  76.  */
  77. class FTPHost
  78. {
  79.   /**
  80.    * The Name of the databasehost.
  81.    *
  82.    * @var    string $name 
  83.    * @access public
  84.    */
  85.   var $name;
  86.   /**
  87.    * The connection's port.
  88.    *
  89.    * @var    int    $port 
  90.    * @access public
  91.    */
  92.   var $port;
  93.   /**
  94.    * The username to log on the ftp server.
  95.    *
  96.    * @var    string $user 
  97.    * @access public
  98.    */
  99.   var $user;
  100.   /**
  101.    * The password to log on the ftp server.
  102.    *
  103.    * @var    string $password 
  104.    * @access public
  105.    */
  106.   var $password;
  107.   /**
  108.    * The connection's state of the ftp host.
  109.    *
  110.    * @var    boolean $is_connected 
  111.    * @access private
  112.    */
  113.   var $is_connected = false;
  114.  
  115.  
  116.   /**
  117.    * Constructor
  118.    *
  119.    * @access  public
  120.    * @version 1.1
  121.    * @since   0.1.0
  122.    *
  123.    * @param   string  $host 
  124.    * @param   string  $user 
  125.    * @param   string  $password 
  126.    * @param   string  $port 
  127.    *
  128.    * @return FTPHost 
  129.    */
  130.   function FTPHost$host$user$password$port 21 )
  131.   {
  132.     $this->name     = $host;
  133.     $this->user     = $user;
  134.     $this->password = $password;
  135.     $this->port     = $port;
  136.   }
  137.  
  138.  
  139.  
  140.   /**
  141.    * Attempts to change the mode of the specified file to that given in mode.
  142.    *
  143.    * @access  public
  144.    * @version 1.0
  145.    * @since   0.2.15
  146.    *
  147.    * @param string $str_path 
  148.    * @param string $str_mod 
  149.    * @param string $disconnect 
  150.    *
  151.    * @return boolean 
  152.    */
  153.   function chmod$str_path$str_mod$disconnect true )
  154.   {
  155.     if !$this->is_connected )
  156.     {   $this->connect()}
  157.  
  158.     $mix_out ftp_chmod$this->resID$str_mod$str_path );
  159.  
  160.     if $disconnect )
  161.     {    $this->disconnect()}
  162.  
  163.     return $mix_out;
  164.  
  165.   }
  166.  
  167.  
  168.  
  169.   /**
  170.    * Renames/moves a given file/directory.
  171.    *
  172.    * @access  public
  173.    * @version 1.2
  174.    * @since   0.1.0
  175.    *
  176.    * @param   string  $oldname 
  177.    * @param   string  $newname 
  178.    * @param   boolean $disconnect 
  179.    *
  180.    * @return  boolean 
  181.    */
  182.   function rename$oldname$newname$disconnect true )
  183.   {
  184.     if !$this->is_connected )
  185.         $this->connect();
  186.  
  187.     if $this->is_connected )
  188.     {
  189.         $bool_tmp ftp_rename$this->resID$oldname$newname );
  190.  
  191.         if $disconnect )
  192.             $this->disconnect();
  193.  
  194.         return $bool_tmp;
  195.     }
  196.  
  197.     return false;
  198.   }
  199.  
  200.  
  201.  
  202.   /**
  203.    * To dissolve a directory means that all containing files will be shifted up
  204.    * a level and the directory itself will be removed.
  205.    * Beware: It does not function if there are files with the same name in the
  206.    * directory which has to be dissolve and the directory one level up.
  207.    *
  208.    * @access  public
  209.    * @version 1.0
  210.    * @since   0.2.0
  211.    *
  212.    * @param   string  $str_dir 
  213.    *
  214.    * @return  boolean 
  215.    */
  216.   function dissolveDir$str_dir )
  217.   {
  218.       if !$this->is_connected )
  219.           $this->connect();
  220.  
  221.       $bool_no_err false;
  222.       if $this->is_connected )
  223.       {
  224.           $str_dir FilesystemToolkit::getCleanPath$str_dir );
  225.           $str_to_dir_arr FilesystemToolkit::separatePathAndFile$str_dir );
  226.           $str_to_dir FilesystemToolkit::getCleanPath$str_to_dir_arr[0);
  227.  
  228.           $bool_no_err true;
  229.           $file_arr $this->loadFolderContent(
  230.                               $str_dir""""false"name"false
  231.                                               );
  232.           foreach $file_arr as $str_file )
  233.               if !$bool_no_err )
  234.               {
  235.                   $this->disconnect();
  236.                   return false;
  237.               }
  238.               else
  239.               {
  240.                   $bool_no_err !$this->file_exists(
  241.                                       $str_to_dir."/".$str_file["name"]false
  242.                                                     );
  243.                   if $bool_no_err )
  244.                       $bool_no_err $this->rename(
  245.                                           $str_dir."/".$str_file["name"],
  246.                                           $str_to_dir."/".$str_file["name"],
  247.                                           false
  248.                                                   );
  249.               }
  250.  
  251.           if $bool_no_err )
  252.              $bool_no_err ftp_rmdir$this->resID$str_dir );
  253.  
  254.           $this->disconnect();
  255.       }
  256.  
  257.       return $bool_no_err;
  258.   }
  259.  
  260.  
  261.  
  262.   /**
  263.    * Copys a given file/directory.
  264.    *
  265.    * @access  public
  266.    * @version 1.01
  267.    * @since   0.1.5
  268.    *
  269.    * @param   string  $fromname 
  270.    * @param   string  $toname 
  271.    * @param   boolean $disconnect 
  272.    *
  273.    * @return  boolean 
  274.    */
  275.   function copy$fromname$toname$disconnect true )
  276.   {
  277.      if !$this->is_connected )
  278.         $this->connect();
  279.  
  280.      if $this->is_connected )
  281.      {
  282.         $tmp_file tmpfile();
  283.         $bool_tmp ftp_fget$this->resID$tmp_file$fromnameFTP_BINARY );
  284.         fseek$tmp_file);
  285.         $bool_tmp $bool_tmp
  286.                 && ftp_fput$this->resID$toname$tmp_fileFTP_BINARY );
  287.         fclose$tmp_file );
  288.  
  289.         if $disconnect )
  290.             $this->disconnect();
  291.  
  292.         return $bool_tmp;
  293.      }
  294.  
  295.      return false;
  296.   }
  297.  
  298.  
  299.  
  300.   /**
  301.    * Checks whether the given file exists.
  302.    *
  303.    * @access  public
  304.    * @version 1.0
  305.    * @since   0.1.6
  306.    *
  307.    * @param   string  $filename 
  308.    * @param   boolean $disconnect 
  309.    *
  310.    * @return  boolean 
  311.    */
  312.   function file_exists$filename$disconnect true )
  313.   {
  314.      if $this->is_dir$filename$disconnect ) )
  315.         return true;
  316.      else
  317.      {
  318.         $tmp_arr FilesystemToolkit::separatePathAndFile$filename );
  319.         $upper_dir $tmp_arr[0];
  320.  
  321.         $dir_cont_arr $this->loadFolderContent(
  322.                               $upper_dir""""false"name"$disconnect
  323.                                                 );
  324.         foreach $dir_cont_arr as $value )
  325.            if $value["name"== $tmp_arr[1)
  326.               return true;
  327.      }
  328.  
  329.      return false;
  330.   }
  331.  
  332.  
  333.  
  334.   /**
  335.    * Checks whether the given file exists.
  336.    *
  337.    * @access  public
  338.    * @version 1.0
  339.    * @since   0.1.6
  340.    *
  341.    * @param   string  $filename 
  342.    * @param   boolean $disconnect 
  343.    *
  344.    * @return  boolean 
  345.    */
  346.   function is_file$filename$disconnect true )
  347.   {
  348.      if $this->is_dir$filename$disconnect ) )
  349.         return false;
  350.      else
  351.      {
  352.         $tmp_arr FilesystemToolkit::separatePathAndFile$filename );
  353.         $upper_dir $tmp_arr[0];
  354.  
  355.         $dir_cont_arr $this->loadFolderContent(
  356.                               $upper_dir""""false"name"$disconnect
  357.                                                 );
  358.         foreach $dir_cont_arr as $value )
  359.            if $value["name"== $tmp_arr[1)
  360.               return true;
  361.      }
  362.  
  363.      return false;
  364.   }
  365.  
  366.  
  367.  
  368.   /**
  369.    * Checks whether the given directory exists.
  370.    *
  371.    * @access  public
  372.    * @version 1.0
  373.    * @since   0.1.6
  374.    *
  375.    * @param   string  $dirname 
  376.    * @param   boolean $disconnect 
  377.    *
  378.    * @return  boolean 
  379.    */
  380.   function is_dir$dirname$disconnect true )
  381.   {
  382.      if!$this->is_connected )
  383.        $this->connect();
  384.  
  385.      if$this->is_connected )
  386.      {
  387.        # remember the current directory
  388.        $mem ftp_pwd$this->resID );
  389.        $out_bool @ftp_chdir$this->resID$dirname );
  390.  
  391.        # change to root directory
  392.        while (
  393.                @ftp_cdup$this->resID )
  394.             && ftp_pwd$this->resID )
  395.             && ftp_pwd$this->resID != "/"
  396.              )
  397.              @ftp_cdup$this->resID );
  398.  
  399.        # change in the right current directory
  400.        if $mem )
  401.           @ftp_chdir$this->resID$mem );
  402.  
  403.        clearstatcache();
  404.  
  405.        if $disconnect )
  406.           $this->disconnect();
  407.  
  408.        return $out_bool;
  409.      }
  410.  
  411.      return false;
  412.   }
  413.  
  414.  
  415.  
  416.   /**
  417.    * Creates a directory with given name.
  418.    *
  419.    * @access  public
  420.    * @version 1.0
  421.    * @since   0.1.0
  422.    *
  423.    * @param   string  $dirname 
  424.    *
  425.    * @return  boolean 
  426.    */
  427.   function mkdir$dirname )
  428.   {
  429.      if!$this->is_connected )
  430.        $this->connect();
  431.  
  432.      if$this->is_connected )
  433.        return ftp_mkdir$this->resID$dirname );
  434.  
  435.      return false;
  436.   }
  437.  
  438.  
  439.  
  440.   /**
  441.    * Creates a file with given name and content.
  442.    *
  443.    * @access  public
  444.    * @version 1.0
  445.    * @since   0.1.0
  446.    *
  447.    * @param   string  $file_path 
  448.    * @param   string  $content 
  449.    *
  450.    * @return  boolean 
  451.    */
  452.   function saveFile$file_path$content )
  453.   {
  454.      if!$this->is_connected )
  455.        $this->connect();
  456.  
  457.      $f new Files();
  458.      $f->setContent$content );
  459.      $f->saveTmp();
  460.  
  461.      if$this->is_connected )
  462.      {
  463.        $out ftp_fput$this->resID$file_path$f->tmp_fhFTP_BINARY );
  464.        # free memory
  465.        $f->deleteTmp();
  466.        unset$f );
  467.  
  468.        return $out;
  469.      }
  470.      $f->deleteTmp();
  471.  
  472.  
  473.      return false;
  474.   }
  475.  
  476.  
  477.  
  478.   /**
  479.    * Puts out the size of a given file.
  480.    *
  481.    * @access  public
  482.    * @version 1.0
  483.    * @since   0.1.7
  484.    *
  485.    * @param   string  $filename   Where the file can be found.
  486.    * @param   boolean $disconnect 
  487.    *
  488.    * @return  integer 
  489.    */
  490.   function filesize$filename$disconnect true )
  491.   {
  492.      if !$this->is_connected )
  493.         $this->connect();
  494.  
  495.      $out_int ftp_size $this->resID$filename );
  496.  
  497.      if $disconnect )
  498.         $this->disconnect();
  499.  
  500.      return $out_int;
  501.   }
  502.  
  503.  
  504.  
  505.   /**
  506.    * Loads the content of a given file.
  507.    *
  508.    * @access  public
  509.    * @version 1.0
  510.    * @since   0.1.7
  511.    *
  512.    * @param   string  $filename Where the file can be found.
  513.    * @param   boolean $disconnect 
  514.    * @return  string 
  515.    */
  516.   function loadFileContent$filename$disconnect true )
  517.   {
  518.      if !$this->is_connected )
  519.         $this->connect();
  520.  
  521.      $f tmpfile();
  522.      if $this->is_connected )
  523.      {
  524.         $bool_tmp ftp_fget(
  525.                         $this->resID,
  526.                         $f,
  527.                         $filename,
  528.                         FTP_BINARY
  529.                            );
  530.  
  531.         if $disconnect )
  532.            $this->disconnect();
  533.  
  534.         if $bool_tmp )
  535.         {
  536.            fseek$f);
  537.  
  538.            $out_str fread$f$this->filesize$filename$disconnect ) );
  539.            fclose$f );
  540.            clearstatcache();
  541.  
  542.            return $out_str;
  543.         }
  544.      }
  545.   }
  546.  
  547.  
  548.  
  549.   /**
  550.    * Reads out a remote folder.
  551.    *
  552.    * @access  public
  553.    * @version 1.2
  554.    * @since   0.1.1
  555.    *
  556.    * @see     http://www.php.net/manual/en/function.ftp-rawlist.php
  557.    *
  558.    * @author  tig3r at poczta dot onet dot pl
  559.    * @author  davidknoll at o2 dot co dot uk
  560.    * @author  Daniel Plücken <daniel@debakel.net>
  561.    *
  562.    * @param   string  $dir 
  563.    * @param   string  $regExpMatchFiles 
  564.    * @param   string  $regExpMatchFolder 
  565.    * @param   boolean $filesize 
  566.    * @param   boolean $order_by 
  567.    * @param   boolean $disconnect 
  568.    *
  569.    * @return  boolean 
  570.    */
  571.   function loadFolderContent(
  572.                               $dir,
  573.                               $regExpMatchFiles  "",
  574.                               $regExpMatchFolder "",
  575.                               $filesize          false,
  576.                               $order_by          "name",
  577.                               $disconnect        true
  578.                             )
  579.   {
  580.       if!$this->is_connected )
  581.          $this->connect();
  582.  
  583.       $systype ftp_systype$this->resID );
  584.  
  585.       $list ftp_rawlist$this->resID"-a ".$dir );
  586.  
  587.       $i 0;
  588.       $parsed array ();
  589.       switch$systype )
  590.       {
  591.            case "Windows_NT":
  592.            if is_array$list ) )
  593.            foreach$list as $current )
  594.            {
  595.                 $split "";
  596.              ereg(
  597.                    "([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):"
  598.                   ."([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)",
  599.                    $current$split
  600.                  );
  601.  
  602.              if(
  603.                  is_array$split )
  604.               && $split[8!= "."
  605.               && $split[8!= ".."
  606.               && (
  607.                    $split[7== "<DIR>"
  608.                 && (
  609.                      empty$regExpMatchFolder )
  610.                   || preg_match$regExpMatchFolder$split[8)
  611.                    )
  612.                 || $split[7!= "<DIR>"
  613.                 && (
  614.                      empty$regExpMatchFiles )
  615.                   || preg_match$regExpMatchFiles$split[8)
  616.                    )
  617.                  )
  618.                )
  619.              {
  620.                if$split[370 )
  621.                  $split[3+= 2000;
  622.                else
  623.                  $split[3+= 1900// 4digit year fix
  624.  
  625.                $parsed[$i]['is_dir']    $split[7== "<DIR>";
  626.  
  627.                if$filesize )
  628.                  $parsed[$i]['size']    $split[7];
  629.  
  630.                $parsed[$i]['month']     $split[1];
  631.                $parsed[$i]['day']       $split[2];
  632.                $parsed[$i]['time/year'$split[3];
  633.                $parsed[$i]['name']      $split[8];
  634.  
  635.                $i++;
  636.              }
  637.            // foreach
  638.            break;
  639.  
  640.            case "UNIX":
  641.            default:
  642.            if is_array$list ) )
  643.            foreach $list as $current )
  644.            {
  645.              $split preg_split"[ ]"$current9PREG_SPLIT_NO_EMPTY );
  646.              if(
  647.                  $split[0!= "total"
  648.               && $split[8!= "."
  649.               && $split[8!= ".."
  650.               && (
  651.                    $split[0]{0=== "d"
  652.                 && (
  653.                      empty$regExpMatchFolder )
  654.                   || preg_match$regExpMatchFolder$split[8)
  655.                    )
  656.                 || $split[0]{0!== "d"
  657.                 && (
  658.                      empty$regExpMatchFiles )
  659.                   || preg_match$regExpMatchFiles$split[8)
  660.                    )
  661.                  )
  662.                )
  663.              {
  664.                $parsed[$i]['is_dir']    $split[0]{0=== "d";
  665.                $parsed[$i]['perms']     $split[0];
  666.                $parsed[$i]['number']    $split[1];
  667.                $parsed[$i]['owner']     $split[2];
  668.                $parsed[$i]['group']     $split[3];
  669.  
  670.                if$filesize )
  671.                  $parsed[$i]['size']    $split[4];
  672.  
  673.                $parsed[$i]['month']     $split[5];
  674.                $parsed[$i]['day']       $split[6];
  675.                $parsed[$i]['time/year'$split[7];
  676.                $parsed[$i]['name']      $split[8];
  677.                $i++;
  678.              }
  679.            // foreach
  680.            break;
  681.       // switch
  682.  
  683.       ifcount$parsed )
  684.         Arrays::sortSecondDimension(
  685.                                      $parsed$order_by,
  686.                                      is_bool$parsed[0][$order_by)
  687.                                      ? "boolcmp_desc"
  688.                                      : "strcmp"
  689.                                    );
  690.  
  691.       if$disconnect )
  692.         $this->disconnect();
  693.  
  694.       return $parsed;
  695.   }
  696.  
  697.  
  698.  
  699.   /**
  700.    * Uploads a file.
  701.    *
  702.    * @access  public
  703.    * @version 1.1
  704.    * @since   0.1.0
  705.    *
  706.    * @param   string  $local_file 
  707.    * @param   string  $remote_file 
  708.    *
  709.    * @return  boolean 
  710.    */
  711.   function uploadFile$local_file$remote_file )
  712.   {
  713.      if !$this->is_connected )
  714.         $this->connect();
  715.  
  716.      if $this->is_connected )
  717.      {
  718.         $bool_tmp ftp_put(
  719.                         $this->resID,
  720.                         $remote_file,
  721.                         $local_file,
  722.                         FTP_BINARY
  723.                            );
  724.         $this->disconnect();
  725.         return $bool_tmp;
  726.      }
  727.  
  728.      return false;
  729.   }
  730.  
  731.  
  732.  
  733.   /**
  734.    * Deletes a file or a folder. Folders will be delete recursively!
  735.    *
  736.    * @access  public
  737.    * @version 1.01
  738.    * @since   0.1.4
  739.    *
  740.    * @param   string  $filename 
  741.    * @param   string  $disconnect 
  742.    *
  743.    * @return  boolean 
  744.    */
  745.   function delete$filename$disconnect true )
  746.   {
  747.      if!$this->is_connected )
  748.        $this->connect();
  749.  
  750.      if(
  751.          $this->is_connected
  752.       && !empty$filename )
  753.       && !preg_match"!^/+$!"$filename )
  754.        )
  755.      {
  756.        if!@ftp_chdir$this->resID$filename ) )
  757.          # it is a file! -> delete it!
  758.          ftp_delete$this->resID$filename );
  759.        else
  760.        {
  761.          $tmp_arr $this->loadFolderContent(
  762.                          "."// current dir
  763.                          $regExpMatchFiles  "",
  764.                          $regExpMatchFolder "",
  765.                          $filesize          false,
  766.                          $order_by          "name",
  767.                          $disconnect        false
  768.                                             );
  769.  
  770.          for$i 0$i count$tmp_arr )$i++ )
  771.          {
  772.            if$tmp_arr[$i]["is_dir")
  773.              $this->delete$tmp_arr[$i]["name"]false );
  774.            else
  775.              ftp_delete$this->resID$tmp_arr[$i]["name");
  776.          }
  777.  
  778.          @ftp_cdup$this->resID );
  779.          ftp_rmdir$this->resIDbasename$filename ) );
  780.        }
  781.      }
  782.  
  783.      if$disconnect )
  784.        $this->disconnect();
  785.   }
  786.  
  787.  
  788.  
  789.   /**
  790.    * Returns the hostname.
  791.    *
  792.    * @access  public
  793.    * @version 1.0
  794.    * @since   0.1.0
  795.    *
  796.    * @return  string 
  797.    */
  798.   function getHost()
  799.   return $this->name}
  800.  
  801.  
  802.  
  803.   /**
  804.    * Returns the hostname. This method is an alias of the method getHost().
  805.    *
  806.    * @access  public
  807.    * @version 1.0
  808.    * @since   0.1.0
  809.    *
  810.    * @return  string 
  811.    */
  812.   function getName()
  813.   return $this->name}
  814.  
  815.  
  816.  
  817.   /**
  818.    * Returns the specified port to use to connect to the host.
  819.    *
  820.    * @access  public
  821.    * @version 1.0
  822.    * @since   0.1.0
  823.    *
  824.    * @return  int 
  825.    */
  826.   function getPort()
  827.   return $this->port}
  828.  
  829.  
  830.  
  831.   /**
  832.    * Returns the specified user who should connect with to the host.
  833.    *
  834.    * @access  public
  835.    * @version 1.0
  836.    * @since   0.1.0
  837.    *
  838.    * @return  string 
  839.    */
  840.   function getUser()
  841.   return $this->user}
  842.  
  843.  
  844.  
  845.   /**
  846.    * Returns the given password which should be usedto connect to the host.
  847.    *
  848.    * @access  public
  849.    * @version 1.0
  850.    * @since   0.1.0
  851.    *
  852.    * @return  string 
  853.    */
  854.   function getPassword()
  855.   return $this->password}
  856.  
  857.  
  858.  
  859.   /**
  860.    * Stets the connection port. Standard is 21.
  861.    *
  862.    * @access  public
  863.    * @version 1.0
  864.    * @since   0.1.9
  865.    *
  866.    * @param   integer $int 
  867.    *
  868.    * @return  void 
  869.    */
  870.   function setPort$int )
  871.   {
  872.     if preg_match"!^\d+$!"$int ) )
  873.     {   $this->port = $int}
  874.   }
  875.  
  876.  
  877.  
  878.   /**
  879.    * Opens a connection to the ftp server.
  880.    *
  881.    * @access  public
  882.    * @version 1.11
  883.    * @since   0.1.0
  884.    *
  885.    * @return  boolean 
  886.    */
  887.   function connect()
  888.   {
  889.     if !($this->resID ftp_connect$this->name$this->port )) )
  890.     {   return false}
  891.  
  892.     if !ftp_login$this->resID$this->user$this->password ) )
  893.     {   return false}
  894.     else
  895.     {
  896.         $this->is_connected = true;
  897.         return true;
  898.     }
  899.   }
  900.  
  901.  
  902.  
  903.   /**
  904.    * Closes the current connection to the ftp server.
  905.    *
  906.    * @access  public
  907.    * @version 1.0
  908.    * @since   0.1.0
  909.    *
  910.    * @return  void 
  911.    */
  912.   function disconnect()
  913.   {
  914.      if ftp_close$this->resID ) )
  915.      {   $this->is_connected = false}
  916.   }
  917. // END of class FTPHost
  918.  
  919. ?>

Documentation generated on Thu, 05 Jun 2008 19:11:50 +0200 by phpDocumentor 1.4.1