Overview

Namespaces

  • MOC
    • Adapter
    • Core
      • Changelog
      • Depending
      • Drive
        • Directory
        • File
      • Error
        • Register
        • Type
      • Journal
      • Proxy
      • Template
      • Xml
    • Extension
      • Excel
      • Flot
      • Mail
      • Pdf
      • Word
      • Xml
      • YUICompressor
      • Zip
    • Generic
      • Common
      • Device
        • Extension
        • Widget
    • Module
      • Database
        • Driver
      • Drive
      • Image
        • Font
      • Installer
      • Network
        • Ftp
          • Directory
          • File
          • Transport
        • Http
        • ParcelTracker
          • Carrier
      • Office
        • Chart
          • Axis
        • Document
          • Excel
            • Cell
              • Format
              • Style
                • Border
                  • Bottom
                  • Left
                  • Right
                  • Top
                • Font
            • Close
            • Page
            • Worksheet
          • Pdf
            • Close
            • Font
            • Page
              • Margin
              • Position
            • Text
          • Xml
            • Close
        • Image
        • Mail
          • Address
          • Content
      • Packer
        • Yui
        • Zip
      • Template
    • Plugin
      • Gateway
      • Repository
      • Shared
  • PHP

Classes

  • Connection
  • RawData
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * LICENSE (BSD)
  4:  *
  5:  * Copyright (c) 2012, Gerd Christian Kunze
  6:  * All rights reserved.
  7:  *
  8:  * Redistribution and use in source and binary forms, with or without
  9:  * modification, are permitted provided that the following conditions are
 10:  * met:
 11:  *
 12:  *  * Redistributions of source code must retain the above copyright
 13:  *    notice, this list of conditions and the following disclaimer.
 14:  *
 15:  *  * Redistributions in binary form must reproduce the above copyright
 16:  *    notice, this list of conditions and the following disclaimer in the
 17:  *    documentation and/or other materials provided with the distribution.
 18:  *
 19:  *  * Neither the name of Gerd Christian Kunze nor the names of the
 20:  *    contributors may be used to endorse or promote products derived from
 21:  *    this software without specific prior written permission.
 22:  *
 23:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 24:  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 25:  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 26:  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 27:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 28:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 29:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 30:  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 31:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 32:  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 33:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 34:  *
 35:  * RawData
 36:  * 16.10.2012 09:02
 37:  */
 38: namespace MOC\Module\Network\Ftp\Transport;
 39: use MOC\Api;
 40: use MOC\Generic\Device\Module;
 41: 
 42: /**
 43:  *
 44:  */
 45: class RawData implements Module {
 46:     /**
 47:      * Get Singleton/Instance
 48:      *
 49:      * @static
 50:      * @return RawData
 51:      */
 52:     public static function InterfaceInstance() {
 53:         return new RawData();
 54:     }
 55: 
 56:     /**
 57:      * Get Dependencies
 58:      *
 59:      * @static
 60:      * @return \MOC\Core\Depending
 61:      */
 62:     public static function InterfaceDepending() {
 63:         return Api::Core()->Depending();
 64:     }
 65: 
 66:     /**
 67:      * Get Changelog
 68:      *
 69:      * @static
 70:      * @return \MOC\Core\Changelog
 71:      */
 72:     public static function InterfaceChangelog() {
 73:         return Api::Core()->Changelog()->Create( __CLASS__ );
 74:     }
 75: 
 76:     /**
 77:      * @param $RawItem
 78:      */
 79:     public function Determine( $RawItem ) {
 80:         $RawData = preg_split( '![\s]+!', $RawItem );
 81:         if( $RawData[8] != '.' && $RawData[8] != '..' ) {
 82:             switch( $RawData[0][0] ) {
 83:                 case self::RAW_DATA_TYPE_FILE: { $this->RawDataType( self::RAW_DATA_TYPE_FILE ); break; }
 84:                 case self::RAW_DATA_TYPE_DIRECTORY: { $this->RawDataType( self::RAW_DATA_TYPE_DIRECTORY ); break; }
 85:                 case self::RAW_DATA_TYPE_LINK: { $this->RawDataType( self::RAW_DATA_TYPE_LINK ); break; }
 86:                 default: { $this->RawDataType( self::RAW_DATA_TYPE_FILE ); break; }
 87:             }
 88:             $this->RawDataChMod( $RawData[0] );
 89:             $this->RawDataHardLink( $RawData[1] );
 90:             $this->RawDataOwner( $RawData[2] );
 91:             $this->RawDataGroup( $RawData[3] );
 92:             $this->RawDataSize( $RawData[4] );
 93:             $this->RawDataMonth( $RawData[5] );
 94:             $this->RawDataDay( $RawData[6] );
 95:             $this->RawDataModified( $RawData[7] );
 96:             $this->RawDataName( $RawData[8] );
 97:         }
 98:     }
 99: 
100:     const RAW_DATA_TYPE_FILE = '-';
101:     const RAW_DATA_TYPE_DIRECTORY = 'd';
102:     const RAW_DATA_TYPE_LINK = 'l';
103: 
104:     private $RawDataType = self::RAW_DATA_TYPE_DIRECTORY;
105:     private $RawDataChMod = '';
106:     private $RawDataHardLink = '';
107:     private $RawDataOwner = '';
108:     private $RawDataGroup = '';
109:     private $RawDataSize = '';
110:     private $RawDataMonth = '';
111:     private $RawDataDay = '';
112:     private $RawDataModified = '';
113:     private $RawDataName = '';
114:     private $RawDataLocation = '/';
115: 
116:     /**
117:      * @param null $Value
118:      *
119:      * @return null|string
120:      */
121:     public function RawDataType( $Value = null ) {
122:         if( null !== $Value ) {
123:             $this->RawDataType = $Value;
124:         } return $this->RawDataType;
125:     }
126: 
127:     /**
128:      * @param null $Value
129:      *
130:      * @return string
131:      */
132:     public function RawDataChMod( $Value = null ) {
133:         if( null !== $Value ) {
134:             $this->RawDataChMod = $this->ConvertToOctal( $Value );
135:         } return $this->RawDataChMod;
136:     }
137: 
138:     /**
139:      * @param null $Value
140:      *
141:      * @return null|string
142:      */
143:     public function RawDataHardLink( $Value = null ) {
144:         if( null !== $Value ) {
145:             $this->RawDataHardLink = $Value;
146:         } return $this->RawDataHardLink;
147:     }
148: 
149:     /**
150:      * @param null $Value
151:      *
152:      * @return null|string
153:      */
154:     public function RawDataOwner( $Value = null ) {
155:         if( null !== $Value ) {
156:             $this->RawDataOwner = $Value;
157:         } return $this->RawDataOwner;
158:     }
159: 
160:     /**
161:      * @param null $Value
162:      *
163:      * @return null|string
164:      */
165:     public function RawDataGroup( $Value = null ) {
166:         if( null !== $Value ) {
167:             $this->RawDataGroup = $Value;
168:         } return $this->RawDataGroup;
169:     }
170: 
171:     /**
172:      * @param null $Value
173:      *
174:      * @return null|string
175:      */
176:     public function RawDataSize( $Value = null ) {
177:         if( null !== $Value ) {
178:             $this->RawDataSize = $Value;
179:         } return $this->RawDataSize;
180:     }
181: 
182:     /**
183:      * @param null $Value
184:      *
185:      * @return null|string
186:      */
187:     public function RawDataMonth( $Value = null ) {
188:         if( null !== $Value ) {
189:             $this->RawDataMonth = $Value;
190:         } return $this->RawDataMonth;
191:     }
192: 
193:     /**
194:      * @param null $Value
195:      *
196:      * @return null|string
197:      */
198:     public function RawDataDay( $Value = null ) {
199:         if( null !== $Value ) {
200:             $this->RawDataDay = $Value;
201:         } return $this->RawDataDay;
202:     }
203: 
204:     /**
205:      * @param null $Value
206:      *
207:      * @return null|string
208:      */
209:     public function RawDataModified( $Value = null ) {
210:         if( null !== $Value ) {
211:             $this->RawDataModified = $Value;
212:         } return $this->RawDataModified;
213:     }
214: 
215:     /**
216:      * @param null $Value
217:      *
218:      * @return null|string
219:      */
220:     public function RawDataName( $Value = null ) {
221:         if( null !== $Value ) {
222:             $this->RawDataName = $Value;
223:         } return $this->RawDataName;
224:     }
225: 
226:     /**
227:      * @param null $Value
228:      *
229:      * @return null|string
230:      */
231:     public function RawDataLocation( $Value = null ) {
232:         if( null !== $Value ) {
233:             $this->RawDataLocation = $Value;
234:         } return $this->RawDataLocation;
235:     }
236: 
237:     /**
238:      * @param $ChMod
239:      *
240:      * @return string
241:      */
242:     private function ConvertToOctal( $ChMod ) {
243:         $Octal = 0;
244:         // Owner
245:         if ($ChMod[1]      == 'r') $Octal += 0400;
246:         if ($ChMod[2]      == 'w') $Octal += 0200;
247:         if ($ChMod[3]      == 'x') $Octal += 0100;
248:         else if ($ChMod[3] == 's') $Octal += 04100;
249:         else if ($ChMod[3] == 'S') $Octal += 04000;
250:         // Group
251:         if ($ChMod[4]      == 'r') $Octal += 040;
252:         if ($ChMod[5]      == 'w') $Octal += 020;
253:         if ($ChMod[6]      == 'x') $Octal += 010;
254:         else if ($ChMod[6] == 's') $Octal += 02010;
255:         else if ($ChMod[6] == 'S') $Octal += 02000;
256:         // Other
257:         if ($ChMod[7]      == 'r') $Octal += 04;
258:         if ($ChMod[8]      == 'w') $Octal += 02;
259:         if ($ChMod[9]      == 'x') $Octal += 01;
260:         else if ($ChMod[9] == 't') $Octal += 01001;
261:         else if ($ChMod[9] == 'T') $Octal += 01000;
262:         return sprintf( '%04o', $Octal );
263:     }
264: }
265: 
API documentation generated by ApiGen 2.8.0