@@ -791,7 +791,7 @@ |
||
| 791 | 791 | * returns a sample serialization of a given type, or false if no type by the given name |
| 792 | 792 | * |
| 793 | 793 | * @param string $type name of type |
| 794 | - * @return mixed |
|
| 794 | + * @return string|false |
|
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
@@ -14,275 +14,275 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class nusoap_xmlschema extends nusoap_base {
|
| 16 | 16 | |
| 17 | - // files |
|
| 18 | - var $schema = ''; |
|
| 19 | - var $xml = ''; |
|
| 20 | - // namespaces |
|
| 21 | - var $enclosingNamespaces; |
|
| 22 | - // schema info |
|
| 23 | - var $schemaInfo = array(); |
|
| 24 | - var $schemaTargetNamespace = ''; |
|
| 25 | - // types, elements, attributes defined by the schema |
|
| 26 | - var $attributes = array(); |
|
| 27 | - var $complexTypes = array(); |
|
| 28 | - var $complexTypeStack = array(); |
|
| 29 | - var $currentComplexType = null; |
|
| 30 | - var $elements = array(); |
|
| 31 | - var $elementStack = array(); |
|
| 32 | - var $currentElement = null; |
|
| 33 | - var $simpleTypes = array(); |
|
| 34 | - var $simpleTypeStack = array(); |
|
| 35 | - var $currentSimpleType = null; |
|
| 36 | - // imports |
|
| 37 | - var $imports = array(); |
|
| 38 | - // parser vars |
|
| 39 | - var $parser; |
|
| 40 | - var $position = 0; |
|
| 41 | - var $depth = 0; |
|
| 42 | - var $depth_array = array(); |
|
| 43 | - var $message = array(); |
|
| 44 | - var $defaultNamespace = array(); |
|
| 17 | + // files |
|
| 18 | + var $schema = ''; |
|
| 19 | + var $xml = ''; |
|
| 20 | + // namespaces |
|
| 21 | + var $enclosingNamespaces; |
|
| 22 | + // schema info |
|
| 23 | + var $schemaInfo = array(); |
|
| 24 | + var $schemaTargetNamespace = ''; |
|
| 25 | + // types, elements, attributes defined by the schema |
|
| 26 | + var $attributes = array(); |
|
| 27 | + var $complexTypes = array(); |
|
| 28 | + var $complexTypeStack = array(); |
|
| 29 | + var $currentComplexType = null; |
|
| 30 | + var $elements = array(); |
|
| 31 | + var $elementStack = array(); |
|
| 32 | + var $currentElement = null; |
|
| 33 | + var $simpleTypes = array(); |
|
| 34 | + var $simpleTypeStack = array(); |
|
| 35 | + var $currentSimpleType = null; |
|
| 36 | + // imports |
|
| 37 | + var $imports = array(); |
|
| 38 | + // parser vars |
|
| 39 | + var $parser; |
|
| 40 | + var $position = 0; |
|
| 41 | + var $depth = 0; |
|
| 42 | + var $depth_array = array(); |
|
| 43 | + var $message = array(); |
|
| 44 | + var $defaultNamespace = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * constructor |
|
| 48 | - * |
|
| 49 | - * @param string $schema schema document URI |
|
| 50 | - * @param string $xml xml document URI |
|
| 51 | - * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | - * @access public |
|
| 53 | - */ |
|
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | - parent::nusoap_base(); |
|
| 56 | - $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | - // files |
|
| 58 | - $this->schema = $schema; |
|
| 59 | - $this->xml = $xml; |
|
| 46 | + /** |
|
| 47 | + * constructor |
|
| 48 | + * |
|
| 49 | + * @param string $schema schema document URI |
|
| 50 | + * @param string $xml xml document URI |
|
| 51 | + * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | + * @access public |
|
| 53 | + */ |
|
| 54 | + function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | + parent::nusoap_base(); |
|
| 56 | + $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | + // files |
|
| 58 | + $this->schema = $schema; |
|
| 59 | + $this->xml = $xml; |
|
| 60 | 60 | |
| 61 | - // namespaces |
|
| 62 | - $this->enclosingNamespaces = $namespaces; |
|
| 63 | - $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 61 | + // namespaces |
|
| 62 | + $this->enclosingNamespaces = $namespaces; |
|
| 63 | + $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 64 | 64 | |
| 65 | - // parse schema file |
|
| 66 | - if($schema != ''){
|
|
| 67 | - $this->debug('initial schema file: '.$schema);
|
|
| 68 | - $this->parseFile($schema, 'schema'); |
|
| 69 | - } |
|
| 65 | + // parse schema file |
|
| 66 | + if($schema != ''){
|
|
| 67 | + $this->debug('initial schema file: '.$schema);
|
|
| 68 | + $this->parseFile($schema, 'schema'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - // parse xml file |
|
| 72 | - if($xml != ''){
|
|
| 73 | - $this->debug('initial xml file: '.$xml);
|
|
| 74 | - $this->parseFile($xml, 'xml'); |
|
| 75 | - } |
|
| 71 | + // parse xml file |
|
| 72 | + if($xml != ''){
|
|
| 73 | + $this->debug('initial xml file: '.$xml);
|
|
| 74 | + $this->parseFile($xml, 'xml'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * parse an XML file |
|
| 81 | - * |
|
| 82 | - * @param string $xml path/URL to XML file |
|
| 83 | - * @param string $type (schema | xml) |
|
| 84 | - * @return boolean |
|
| 85 | - * @access public |
|
| 86 | - */ |
|
| 87 | - function parseFile($xml,$type){
|
|
| 88 | - // parse xml file |
|
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 92 | - $msg = 'Error reading XML from '.$xml; |
|
| 93 | - $this->setError($msg); |
|
| 94 | - $this->debug($msg); |
|
| 95 | - return false; |
|
| 96 | - } else {
|
|
| 97 | - $this->debug("parsing $xml");
|
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 99 | - $this->debug("done parsing $xml");
|
|
| 100 | - return true; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return false; |
|
| 104 | - } |
|
| 80 | + * parse an XML file |
|
| 81 | + * |
|
| 82 | + * @param string $xml path/URL to XML file |
|
| 83 | + * @param string $type (schema | xml) |
|
| 84 | + * @return boolean |
|
| 85 | + * @access public |
|
| 86 | + */ |
|
| 87 | + function parseFile($xml,$type){
|
|
| 88 | + // parse xml file |
|
| 89 | + if($xml != ""){
|
|
| 90 | + $xmlStr = @join("",@file($xml));
|
|
| 91 | + if($xmlStr == ""){
|
|
| 92 | + $msg = 'Error reading XML from '.$xml; |
|
| 93 | + $this->setError($msg); |
|
| 94 | + $this->debug($msg); |
|
| 95 | + return false; |
|
| 96 | + } else {
|
|
| 97 | + $this->debug("parsing $xml");
|
|
| 98 | + $this->parseString($xmlStr,$type); |
|
| 99 | + $this->debug("done parsing $xml");
|
|
| 100 | + return true; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * parse an XML string |
|
| 108 | - * |
|
| 109 | - * @param string $xml path or URL |
|
| 110 | - * @param string $type (schema|xml) |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 113 | - function parseString($xml,$type){
|
|
| 114 | - // parse xml string |
|
| 115 | - if($xml != ""){
|
|
| 106 | + /** |
|
| 107 | + * parse an XML string |
|
| 108 | + * |
|
| 109 | + * @param string $xml path or URL |
|
| 110 | + * @param string $type (schema|xml) |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | + function parseString($xml,$type){
|
|
| 114 | + // parse xml string |
|
| 115 | + if($xml != ""){
|
|
| 116 | 116 | |
| 117 | - // Create an XML parser. |
|
| 118 | - $this->parser = xml_parser_create(); |
|
| 119 | - // Set the options for parsing the XML data. |
|
| 120 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 117 | + // Create an XML parser. |
|
| 118 | + $this->parser = xml_parser_create(); |
|
| 119 | + // Set the options for parsing the XML data. |
|
| 120 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 121 | 121 | |
| 122 | - // Set the object for the parser. |
|
| 123 | - xml_set_object($this->parser, $this); |
|
| 122 | + // Set the object for the parser. |
|
| 123 | + xml_set_object($this->parser, $this); |
|
| 124 | 124 | |
| 125 | - // Set the element handlers for the parser. |
|
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | - } |
|
| 125 | + // Set the element handlers for the parser. |
|
| 126 | + if($type == "schema"){
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | + } elseif($type == "xml"){
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Parse the XML file. |
|
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | - // Display an error message. |
|
| 137 | - $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | - xml_get_current_line_number($this->parser), |
|
| 139 | - xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | - ); |
|
| 141 | - $this->debug($errstr); |
|
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 143 | - $this->setError($errstr); |
|
| 144 | - } |
|
| 134 | + // Parse the XML file. |
|
| 135 | + if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | + // Display an error message. |
|
| 137 | + $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | + xml_get_current_line_number($this->parser), |
|
| 139 | + xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | + ); |
|
| 141 | + $this->debug($errstr); |
|
| 142 | + $this->debug("XML payload:\n" . $xml);
|
|
| 143 | + $this->setError($errstr); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - xml_parser_free($this->parser); |
|
| 147 | - } else{
|
|
| 148 | - $this->debug('no xml passed to parseString()!!');
|
|
| 149 | - $this->setError('no xml passed to parseString()!!');
|
|
| 150 | - } |
|
| 151 | - } |
|
| 146 | + xml_parser_free($this->parser); |
|
| 147 | + } else{
|
|
| 148 | + $this->debug('no xml passed to parseString()!!');
|
|
| 149 | + $this->setError('no xml passed to parseString()!!');
|
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * gets a type name for an unnamed type |
|
| 155 | - * |
|
| 156 | - * @param string Element name |
|
| 157 | - * @return string A type name for an unnamed type |
|
| 158 | - * @access private |
|
| 159 | - */ |
|
| 160 | - function CreateTypeName($ename) {
|
|
| 161 | - $scope = ''; |
|
| 162 | - for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | - } |
|
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 166 | - } |
|
| 153 | + /** |
|
| 154 | + * gets a type name for an unnamed type |
|
| 155 | + * |
|
| 156 | + * @param string Element name |
|
| 157 | + * @return string A type name for an unnamed type |
|
| 158 | + * @access private |
|
| 159 | + */ |
|
| 160 | + function CreateTypeName($ename) {
|
|
| 161 | + $scope = ''; |
|
| 162 | + for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | + $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | + } |
|
| 165 | + return $scope . $ename . '_ContainedType'; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * start-element handler |
|
| 170 | - * |
|
| 171 | - * @param string $parser XML parser object |
|
| 172 | - * @param string $name element name |
|
| 173 | - * @param string $attrs associative array of attributes |
|
| 174 | - * @access private |
|
| 175 | - */ |
|
| 176 | - function schemaStartElement($parser, $name, $attrs) {
|
|
| 168 | + /** |
|
| 169 | + * start-element handler |
|
| 170 | + * |
|
| 171 | + * @param string $parser XML parser object |
|
| 172 | + * @param string $name element name |
|
| 173 | + * @param string $attrs associative array of attributes |
|
| 174 | + * @access private |
|
| 175 | + */ |
|
| 176 | + function schemaStartElement($parser, $name, $attrs) {
|
|
| 177 | 177 | |
| 178 | - // position in the total number of elements, starting from 0 |
|
| 179 | - $pos = $this->position++; |
|
| 180 | - $depth = $this->depth++; |
|
| 181 | - // set self as current value for this depth |
|
| 182 | - $this->depth_array[$depth] = $pos; |
|
| 183 | - $this->message[$pos] = array('cdata' => '');
|
|
| 184 | - if ($depth > 0) {
|
|
| 185 | - $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | - } else {
|
|
| 187 | - $this->defaultNamespace[$pos] = false; |
|
| 188 | - } |
|
| 178 | + // position in the total number of elements, starting from 0 |
|
| 179 | + $pos = $this->position++; |
|
| 180 | + $depth = $this->depth++; |
|
| 181 | + // set self as current value for this depth |
|
| 182 | + $this->depth_array[$depth] = $pos; |
|
| 183 | + $this->message[$pos] = array('cdata' => '');
|
|
| 184 | + if ($depth > 0) {
|
|
| 185 | + $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | + } else {
|
|
| 187 | + $this->defaultNamespace[$pos] = false; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - // get element prefix |
|
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 192 | - // get unqualified name |
|
| 193 | - $name = $this->getLocalPart($name); |
|
| 194 | - } else {
|
|
| 195 | - $prefix = ''; |
|
| 190 | + // get element prefix |
|
| 191 | + if($prefix = $this->getPrefix($name)){
|
|
| 192 | + // get unqualified name |
|
| 193 | + $name = $this->getLocalPart($name); |
|
| 194 | + } else {
|
|
| 195 | + $prefix = ''; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | 199 | if(count($attrs) > 0){
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 200 | + foreach($attrs as $k => $v){
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 203 | - //$this->xdebug("$k: $v");
|
|
| 204 | - //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | - //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | - $this->namespaces[$ns_prefix] = $v; |
|
| 208 | - } else {
|
|
| 209 | - $this->defaultNamespace[$pos] = $v; |
|
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | - $this->XMLSchemaVersion = $v; |
|
| 216 | - $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - foreach($attrs as $k => $v){
|
|
| 202 | + if(preg_match('/^xmlns/',$k)){
|
|
| 203 | + //$this->xdebug("$k: $v");
|
|
| 204 | + //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | + if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | + //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | + $this->namespaces[$ns_prefix] = $v; |
|
| 208 | + } else {
|
|
| 209 | + $this->defaultNamespace[$pos] = $v; |
|
| 210 | + if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | + $this->XMLSchemaVersion = $v; |
|
| 216 | + $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + foreach($attrs as $k => $v){
|
|
| 221 | 221 | // expand each attribute |
| 222 | 222 | $k = strpos($k,':') ? $this->expandQname($k) : $k; |
| 223 | 223 | $v = strpos($v,':') ? $this->expandQname($v) : $v; |
| 224 | - $eAttrs[$k] = $v; |
|
| 225 | - } |
|
| 226 | - $attrs = $eAttrs; |
|
| 224 | + $eAttrs[$k] = $v; |
|
| 225 | + } |
|
| 226 | + $attrs = $eAttrs; |
|
| 227 | 227 | } else {
|
| 228 | - $attrs = array(); |
|
| 228 | + $attrs = array(); |
|
| 229 | 229 | } |
| 230 | - // find status, register data |
|
| 231 | - switch($name){
|
|
| 232 | - case 'all': // (optional) compositor content for a complexType |
|
| 233 | - case 'choice': |
|
| 234 | - case 'group': |
|
| 235 | - case 'sequence': |
|
| 236 | - //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | - $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | - //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | - // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | - //} |
|
| 241 | - break; |
|
| 242 | - case 'attribute': // complexType attribute |
|
| 243 | - //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | - $this->xdebug("parsing attribute:");
|
|
| 245 | - $this->appendDebug($this->varDump($attrs)); |
|
| 246 | - if (!isset($attrs['form'])) {
|
|
| 247 | - // TODO: handle globals |
|
| 248 | - $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | - } |
|
| 250 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | - if (!strpos($v, ':')) {
|
|
| 253 | - // no namespace in arrayType attribute value... |
|
| 254 | - if ($this->defaultNamespace[$pos]) {
|
|
| 255 | - // ...so use the default |
|
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 230 | + // find status, register data |
|
| 231 | + switch($name){
|
|
| 232 | + case 'all': // (optional) compositor content for a complexType |
|
| 233 | + case 'choice': |
|
| 234 | + case 'group': |
|
| 235 | + case 'sequence': |
|
| 236 | + //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | + $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | + //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | + // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | + //} |
|
| 241 | + break; |
|
| 242 | + case 'attribute': // complexType attribute |
|
| 243 | + //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | + $this->xdebug("parsing attribute:");
|
|
| 245 | + $this->appendDebug($this->varDump($attrs)); |
|
| 246 | + if (!isset($attrs['form'])) {
|
|
| 247 | + // TODO: handle globals |
|
| 248 | + $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | + } |
|
| 250 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | + if (!strpos($v, ':')) {
|
|
| 253 | + // no namespace in arrayType attribute value... |
|
| 254 | + if ($this->defaultNamespace[$pos]) {
|
|
| 255 | + // ...so use the default |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | if(isset($attrs['name'])){
|
| 261 | - $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | - $aname = $attrs['name']; |
|
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | - } else {
|
|
| 267 | - $aname = ''; |
|
| 268 | - } |
|
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 270 | - $aname = $attrs['ref']; |
|
| 261 | + $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | + $aname = $attrs['name']; |
|
| 263 | + } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | + $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | + } else {
|
|
| 267 | + $aname = ''; |
|
| 268 | + } |
|
| 269 | + } elseif(isset($attrs['ref'])){
|
|
| 270 | + $aname = $attrs['ref']; |
|
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 275 | - $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | - } |
|
| 277 | - // arrayType attribute |
|
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | - $prefix = $this->getPrefix($aname); |
|
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | - } else {
|
|
| 284 | - $v = ''; |
|
| 285 | - } |
|
| 274 | + if($this->currentComplexType){ // This should *always* be
|
|
| 275 | + $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | + } |
|
| 277 | + // arrayType attribute |
|
| 278 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | + $prefix = $this->getPrefix($aname); |
|
| 281 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | + } else {
|
|
| 284 | + $v = ''; |
|
| 285 | + } |
|
| 286 | 286 | if(strpos($v,'[,]')){
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
@@ -291,676 +291,676 @@ discard block |
||
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
| 294 | - } |
|
| 295 | - break; |
|
| 296 | - case 'complexContent': // (optional) content for a complexType |
|
| 297 | - $this->xdebug("do nothing for element $name");
|
|
| 298 | - break; |
|
| 299 | - case 'complexType': |
|
| 300 | - array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | - if(isset($attrs['name'])){
|
|
| 302 | - // TODO: what is the scope of named complexTypes that appear |
|
| 303 | - // nested within other c complexTypes? |
|
| 304 | - $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | - //$this->currentElement = false; |
|
| 306 | - $this->currentComplexType = $attrs['name']; |
|
| 307 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | - // This is for constructs like |
|
| 310 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | - // <sequence> |
|
| 312 | - // <element name="string" type="xsd:string" |
|
| 313 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | - // </sequence> |
|
| 315 | - // </complexType> |
|
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | - $this->xdebug('complexType is unusual array');
|
|
| 318 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | - } else {
|
|
| 320 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | - } |
|
| 322 | - } else {
|
|
| 323 | - $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | - $this->currentComplexType = $name; |
|
| 326 | - //$this->currentElement = false; |
|
| 327 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | - // This is for constructs like |
|
| 330 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | - // <sequence> |
|
| 332 | - // <element name="string" type="xsd:string" |
|
| 333 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | - // </sequence> |
|
| 335 | - // </complexType> |
|
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | - $this->xdebug('complexType is unusual array');
|
|
| 338 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | - } else {
|
|
| 340 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | - break; |
|
| 345 | - case 'element': |
|
| 346 | - array_push($this->elementStack, $this->currentElement); |
|
| 347 | - if (!isset($attrs['form'])) {
|
|
| 348 | - if ($this->currentComplexType) {
|
|
| 349 | - $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | - } else {
|
|
| 351 | - // global |
|
| 352 | - $attrs['form'] = 'qualified'; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - if(isset($attrs['type'])){
|
|
| 356 | - $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | - if ($this->defaultNamespace[$pos]) {
|
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - // This is for constructs like |
|
| 364 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | - // <sequence> |
|
| 366 | - // <element name="string" type="xsd:string" |
|
| 367 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | - // </sequence> |
|
| 369 | - // </complexType> |
|
| 370 | - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | - $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | - } |
|
| 374 | - $this->currentElement = $attrs['name']; |
|
| 375 | - $ename = $attrs['name']; |
|
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 377 | - $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | - $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | - $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | - } else {
|
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | - $this->currentElement = $attrs['name']; |
|
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | - $ename = $attrs['name']; |
|
| 386 | - } |
|
| 387 | - if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | - $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | - $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | - } elseif (!isset($attrs['ref'])) {
|
|
| 391 | - $this->xdebug("add element $ename to elements array");
|
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | - } |
|
| 395 | - break; |
|
| 396 | - case 'enumeration': // restriction value list member |
|
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | - if ($this->currentSimpleType) {
|
|
| 399 | - $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | - } elseif ($this->currentComplexType) {
|
|
| 401 | - $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | - } |
|
| 403 | - break; |
|
| 404 | - case 'extension': // simpleContent or complexContent type extension |
|
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | - if ($this->currentComplexType) {
|
|
| 407 | - $ns = $this->getPrefix($attrs['base']); |
|
| 408 | - if ($ns == '') {
|
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | - } else {
|
|
| 411 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | - } |
|
| 413 | - } else {
|
|
| 414 | - $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | - } |
|
| 416 | - break; |
|
| 417 | - case 'import': |
|
| 418 | - if (isset($attrs['schemaLocation'])) {
|
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 294 | + } |
|
| 295 | + break; |
|
| 296 | + case 'complexContent': // (optional) content for a complexType |
|
| 297 | + $this->xdebug("do nothing for element $name");
|
|
| 298 | + break; |
|
| 299 | + case 'complexType': |
|
| 300 | + array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | + if(isset($attrs['name'])){
|
|
| 302 | + // TODO: what is the scope of named complexTypes that appear |
|
| 303 | + // nested within other c complexTypes? |
|
| 304 | + $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | + //$this->currentElement = false; |
|
| 306 | + $this->currentComplexType = $attrs['name']; |
|
| 307 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | + // This is for constructs like |
|
| 310 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | + // <sequence> |
|
| 312 | + // <element name="string" type="xsd:string" |
|
| 313 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | + // </sequence> |
|
| 315 | + // </complexType> |
|
| 316 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | + $this->xdebug('complexType is unusual array');
|
|
| 318 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | + } else {
|
|
| 320 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | + } |
|
| 322 | + } else {
|
|
| 323 | + $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | + $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | + $this->currentComplexType = $name; |
|
| 326 | + //$this->currentElement = false; |
|
| 327 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | + // This is for constructs like |
|
| 330 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | + // <sequence> |
|
| 332 | + // <element name="string" type="xsd:string" |
|
| 333 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | + // </sequence> |
|
| 335 | + // </complexType> |
|
| 336 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | + $this->xdebug('complexType is unusual array');
|
|
| 338 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | + } else {
|
|
| 340 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | + break; |
|
| 345 | + case 'element': |
|
| 346 | + array_push($this->elementStack, $this->currentElement); |
|
| 347 | + if (!isset($attrs['form'])) {
|
|
| 348 | + if ($this->currentComplexType) {
|
|
| 349 | + $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | + } else {
|
|
| 351 | + // global |
|
| 352 | + $attrs['form'] = 'qualified'; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + if(isset($attrs['type'])){
|
|
| 356 | + $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | + if ($this->defaultNamespace[$pos]) {
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + // This is for constructs like |
|
| 364 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | + // <sequence> |
|
| 366 | + // <element name="string" type="xsd:string" |
|
| 367 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | + // </sequence> |
|
| 369 | + // </complexType> |
|
| 370 | + if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | + $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | + $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | + } |
|
| 374 | + $this->currentElement = $attrs['name']; |
|
| 375 | + $ename = $attrs['name']; |
|
| 376 | + } elseif(isset($attrs['ref'])){
|
|
| 377 | + $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | + $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | + $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | + } else {
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | + $this->currentElement = $attrs['name']; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | + $ename = $attrs['name']; |
|
| 386 | + } |
|
| 387 | + if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | + $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | + $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | + } elseif (!isset($attrs['ref'])) {
|
|
| 391 | + $this->xdebug("add element $ename to elements array");
|
|
| 392 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | + } |
|
| 395 | + break; |
|
| 396 | + case 'enumeration': // restriction value list member |
|
| 397 | + $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | + if ($this->currentSimpleType) {
|
|
| 399 | + $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | + } elseif ($this->currentComplexType) {
|
|
| 401 | + $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | + } |
|
| 403 | + break; |
|
| 404 | + case 'extension': // simpleContent or complexContent type extension |
|
| 405 | + $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | + if ($this->currentComplexType) {
|
|
| 407 | + $ns = $this->getPrefix($attrs['base']); |
|
| 408 | + if ($ns == '') {
|
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | + } else {
|
|
| 411 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | + } |
|
| 413 | + } else {
|
|
| 414 | + $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | + } |
|
| 416 | + break; |
|
| 417 | + case 'import': |
|
| 418 | + if (isset($attrs['schemaLocation'])) {
|
|
| 419 | + $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | - } else {
|
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 421 | + } else {
|
|
| 422 | + $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - break; |
|
| 429 | - case 'include': |
|
| 430 | - if (isset($attrs['schemaLocation'])) {
|
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 424 | + if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + break; |
|
| 429 | + case 'include': |
|
| 430 | + if (isset($attrs['schemaLocation'])) {
|
|
| 431 | + $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | - } else {
|
|
| 434 | - $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | - } |
|
| 436 | - break; |
|
| 437 | - case 'list': // simpleType value list |
|
| 438 | - $this->xdebug("do nothing for element $name");
|
|
| 439 | - break; |
|
| 440 | - case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 443 | - $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | - } elseif($this->currentComplexType){
|
|
| 445 | - $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - break; |
|
| 451 | - case 'schema': |
|
| 452 | - $this->schemaInfo = $attrs; |
|
| 453 | - $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | - if (isset($attrs['targetNamespace'])) {
|
|
| 455 | - $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | - } |
|
| 457 | - if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | - $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | - } |
|
| 460 | - if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | - $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | - } |
|
| 463 | - break; |
|
| 464 | - case 'simpleContent': // (optional) content for a complexType |
|
| 465 | - if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | - } else {
|
|
| 468 | - $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | - } |
|
| 470 | - break; |
|
| 471 | - case 'simpleType': |
|
| 472 | - array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | - $this->currentSimpleType = $attrs['name']; |
|
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | - } else {
|
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | - $this->currentSimpleType = $name; |
|
| 483 | - //$this->currentElement = false; |
|
| 484 | - $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | - $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | - } |
|
| 487 | - break; |
|
| 488 | - case 'union': // simpleType type list |
|
| 489 | - $this->xdebug("do nothing for element $name");
|
|
| 490 | - break; |
|
| 491 | - default: |
|
| 492 | - $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | - } |
|
| 494 | - } |
|
| 433 | + } else {
|
|
| 434 | + $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | + } |
|
| 436 | + break; |
|
| 437 | + case 'list': // simpleType value list |
|
| 438 | + $this->xdebug("do nothing for element $name");
|
|
| 439 | + break; |
|
| 440 | + case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | + $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | + if($this->currentSimpleType){
|
|
| 443 | + $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | + } elseif($this->currentComplexType){
|
|
| 445 | + $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | + if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + break; |
|
| 451 | + case 'schema': |
|
| 452 | + $this->schemaInfo = $attrs; |
|
| 453 | + $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | + if (isset($attrs['targetNamespace'])) {
|
|
| 455 | + $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | + } |
|
| 457 | + if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | + $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | + } |
|
| 460 | + if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | + $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | + } |
|
| 463 | + break; |
|
| 464 | + case 'simpleContent': // (optional) content for a complexType |
|
| 465 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | + } else {
|
|
| 468 | + $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | + } |
|
| 470 | + break; |
|
| 471 | + case 'simpleType': |
|
| 472 | + array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | + if(isset($attrs['name'])){
|
|
| 474 | + $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | + $this->currentSimpleType = $attrs['name']; |
|
| 476 | + $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | + $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | + } else {
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | + $this->currentSimpleType = $name; |
|
| 483 | + //$this->currentElement = false; |
|
| 484 | + $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | + $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | + } |
|
| 487 | + break; |
|
| 488 | + case 'union': // simpleType type list |
|
| 489 | + $this->xdebug("do nothing for element $name");
|
|
| 490 | + break; |
|
| 491 | + default: |
|
| 492 | + $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * end-element handler |
|
| 498 | - * |
|
| 499 | - * @param string $parser XML parser object |
|
| 500 | - * @param string $name element name |
|
| 501 | - * @access private |
|
| 502 | - */ |
|
| 503 | - function schemaEndElement($parser, $name) {
|
|
| 504 | - // bring depth down a notch |
|
| 505 | - $this->depth--; |
|
| 506 | - // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 508 | - $pos = $this->depth_array[$this->depth]; |
|
| 496 | + /** |
|
| 497 | + * end-element handler |
|
| 498 | + * |
|
| 499 | + * @param string $parser XML parser object |
|
| 500 | + * @param string $name element name |
|
| 501 | + * @access private |
|
| 502 | + */ |
|
| 503 | + function schemaEndElement($parser, $name) {
|
|
| 504 | + // bring depth down a notch |
|
| 505 | + $this->depth--; |
|
| 506 | + // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | + if(isset($this->depth_array[$this->depth])){
|
|
| 508 | + $pos = $this->depth_array[$this->depth]; |
|
| 509 | + } |
|
| 510 | + // get element prefix |
|
| 511 | + if ($prefix = $this->getPrefix($name)){
|
|
| 512 | + // get unqualified name |
|
| 513 | + $name = $this->getLocalPart($name); |
|
| 514 | + } else {
|
|
| 515 | + $prefix = ''; |
|
| 516 | + } |
|
| 517 | + // move on... |
|
| 518 | + if($name == 'complexType'){
|
|
| 519 | + $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | + $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | + $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | + //$this->currentElement = false; |
|
| 509 | 523 | } |
| 510 | - // get element prefix |
|
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 512 | - // get unqualified name |
|
| 513 | - $name = $this->getLocalPart($name); |
|
| 514 | - } else {
|
|
| 515 | - $prefix = ''; |
|
| 524 | + if($name == 'element'){
|
|
| 525 | + $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | + $this->currentElement = array_pop($this->elementStack); |
|
| 516 | 527 | } |
| 517 | - // move on... |
|
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | - $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | - $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | - //$this->currentElement = false; |
|
| 523 | - } |
|
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | - $this->currentElement = array_pop($this->elementStack); |
|
| 527 | - } |
|
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | - $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | - $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | - } |
|
| 533 | - } |
|
| 528 | + if($name == 'simpleType'){
|
|
| 529 | + $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | + $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | + $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | + } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * element content handler |
|
| 537 | - * |
|
| 538 | - * @param string $parser XML parser object |
|
| 539 | - * @param string $data element content |
|
| 540 | - * @access private |
|
| 541 | - */ |
|
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 543 | - $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | - $this->message[$pos]['cdata'] .= $data; |
|
| 545 | - } |
|
| 535 | + /** |
|
| 536 | + * element content handler |
|
| 537 | + * |
|
| 538 | + * @param string $parser XML parser object |
|
| 539 | + * @param string $data element content |
|
| 540 | + * @access private |
|
| 541 | + */ |
|
| 542 | + function schemaCharacterData($parser, $data){
|
|
| 543 | + $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | + $this->message[$pos]['cdata'] .= $data; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * serialize the schema |
|
| 549 | - * |
|
| 550 | - * @access public |
|
| 551 | - */ |
|
| 552 | - function serializeSchema(){
|
|
| 547 | + /** |
|
| 548 | + * serialize the schema |
|
| 549 | + * |
|
| 550 | + * @access public |
|
| 551 | + */ |
|
| 552 | + function serializeSchema(){
|
|
| 553 | 553 | |
| 554 | - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | - $xml = ''; |
|
| 556 | - // imports |
|
| 557 | - if (sizeof($this->imports) > 0) {
|
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 559 | - foreach ($list as $ii) {
|
|
| 560 | - if ($ii['location'] != '') {
|
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | - } else {
|
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - } |
|
| 568 | - // complex types |
|
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | - $contentStr = ''; |
|
| 571 | - // serialize child elements |
|
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 575 | - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | - } else {
|
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | - foreach ($eParts as $aName => $aValue) {
|
|
| 579 | - // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | - if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | - $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $contentStr .= "/>\n"; |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - // compositor wraps elements |
|
| 588 | - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | - $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | - } |
|
| 591 | - } |
|
| 592 | - // attributes |
|
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | - $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | - foreach ($aParts as $a => $v) {
|
|
| 597 | - if ($a == 'ref' || $a == 'type') {
|
|
| 598 | - $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | - $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | - $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | - } else {
|
|
| 603 | - $contentStr .= " $a=\"$v\""; |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - $contentStr .= "/>\n"; |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - // if restriction |
|
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | - $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | - // complex or simple content |
|
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | - $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - // finalize complex type |
|
| 618 | - if($contentStr != ''){
|
|
| 619 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | - } else {
|
|
| 621 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | - } |
|
| 623 | - $xml .= $contentStr; |
|
| 624 | - } |
|
| 625 | - // simple types |
|
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | - $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | - if (isset($eParts['enumeration'])) {
|
|
| 630 | - foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - // elements |
|
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 640 | - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - // attributes |
|
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 646 | - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - // finish 'er up |
|
| 650 | - $attr = ''; |
|
| 651 | - foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | - $attr .= " $k=\"$v\""; |
|
| 654 | - } |
|
| 655 | - } |
|
| 656 | - $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | - foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | - $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | - } |
|
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | - return $xml; |
|
| 662 | - } |
|
| 554 | + $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | + $xml = ''; |
|
| 556 | + // imports |
|
| 557 | + if (sizeof($this->imports) > 0) {
|
|
| 558 | + foreach($this->imports as $ns => $list) {
|
|
| 559 | + foreach ($list as $ii) {
|
|
| 560 | + if ($ii['location'] != '') {
|
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | + } else {
|
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + // complex types |
|
| 569 | + foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | + $contentStr = ''; |
|
| 571 | + // serialize child elements |
|
| 572 | + if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | + foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | + if(isset($eParts['ref'])){
|
|
| 575 | + $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | + } else {
|
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | + foreach ($eParts as $aName => $aValue) {
|
|
| 579 | + // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | + if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | + $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $contentStr .= "/>\n"; |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + // compositor wraps elements |
|
| 588 | + if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | + $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | + // attributes |
|
| 593 | + if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | + foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | + $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | + foreach ($aParts as $a => $v) {
|
|
| 597 | + if ($a == 'ref' || $a == 'type') {
|
|
| 598 | + $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | + } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | + $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | + $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | + } else {
|
|
| 603 | + $contentStr .= " $a=\"$v\""; |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + $contentStr .= "/>\n"; |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + // if restriction |
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | + $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | + // complex or simple content |
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | + $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + // finalize complex type |
|
| 618 | + if($contentStr != ''){
|
|
| 619 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | + } else {
|
|
| 621 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | + } |
|
| 623 | + $xml .= $contentStr; |
|
| 624 | + } |
|
| 625 | + // simple types |
|
| 626 | + if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | + foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | + $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | + if (isset($eParts['enumeration'])) {
|
|
| 630 | + foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | + $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + // elements |
|
| 638 | + if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | + foreach($this->elements as $element => $eParts){
|
|
| 640 | + $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + // attributes |
|
| 644 | + if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | + foreach($this->attributes as $attr => $aParts){
|
|
| 646 | + $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + // finish 'er up |
|
| 650 | + $attr = ''; |
|
| 651 | + foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | + if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | + $attr .= " $k=\"$v\""; |
|
| 654 | + } |
|
| 655 | + } |
|
| 656 | + $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | + foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | + $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | + } |
|
| 660 | + $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | + return $xml; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - /** |
|
| 665 | - * adds debug data to the clas level debug string |
|
| 666 | - * |
|
| 667 | - * @param string $string debug data |
|
| 668 | - * @access private |
|
| 669 | - */ |
|
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | - } |
|
| 664 | + /** |
|
| 665 | + * adds debug data to the clas level debug string |
|
| 666 | + * |
|
| 667 | + * @param string $string debug data |
|
| 668 | + * @access private |
|
| 669 | + */ |
|
| 670 | + function xdebug($string){
|
|
| 671 | + $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | - * get the PHP type of a user defined type in the schema |
|
| 676 | - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | - * returns false if no type exists, or not w/ the given namespace |
|
| 678 | - * else returns a string that is either a native php type, or 'struct' |
|
| 679 | - * |
|
| 680 | - * @param string $type name of defined type |
|
| 681 | - * @param string $ns namespace of type |
|
| 682 | - * @return mixed |
|
| 683 | - * @access public |
|
| 684 | - * @deprecated |
|
| 685 | - */ |
|
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 688 | - //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | - return $this->typemap[$ns][$type]; |
|
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | - //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | - return $this->complexTypes[$type]['phpType']; |
|
| 693 | - } |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 675 | + * get the PHP type of a user defined type in the schema |
|
| 676 | + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | + * returns false if no type exists, or not w/ the given namespace |
|
| 678 | + * else returns a string that is either a native php type, or 'struct' |
|
| 679 | + * |
|
| 680 | + * @param string $type name of defined type |
|
| 681 | + * @param string $ns namespace of type |
|
| 682 | + * @return mixed |
|
| 683 | + * @access public |
|
| 684 | + * @deprecated |
|
| 685 | + */ |
|
| 686 | + function getPHPType($type,$ns){
|
|
| 687 | + if(isset($this->typemap[$ns][$type])){
|
|
| 688 | + //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | + return $this->typemap[$ns][$type]; |
|
| 690 | + } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | + //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | + return $this->complexTypes[$type]['phpType']; |
|
| 693 | + } |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - /** |
|
| 698 | - * returns an associative array of information about a given type |
|
| 699 | - * returns false if no type exists by the given name |
|
| 700 | - * |
|
| 701 | - * For a complexType typeDef = array( |
|
| 702 | - * 'restrictionBase' => '', |
|
| 703 | - * 'phpType' => '', |
|
| 704 | - * 'compositor' => '(sequence|all)', |
|
| 705 | - * 'elements' => array(), // refs to elements array |
|
| 706 | - * 'attrs' => array() // refs to attributes array |
|
| 707 | - * ... and so on (see addComplexType) |
|
| 708 | - * ) |
|
| 709 | - * |
|
| 710 | - * For simpleType or element, the array has different keys. |
|
| 711 | - * |
|
| 712 | - * @param string $type |
|
| 713 | - * @return mixed |
|
| 714 | - * @access public |
|
| 715 | - * @see addComplexType |
|
| 716 | - * @see addSimpleType |
|
| 717 | - * @see addElement |
|
| 718 | - */ |
|
| 719 | - function getTypeDef($type){
|
|
| 720 | - //$this->debug("in getTypeDef for type $type");
|
|
| 721 | - if (substr($type, -1) == '^') {
|
|
| 722 | - $is_element = 1; |
|
| 723 | - $type = substr($type, 0, -1); |
|
| 724 | - } else {
|
|
| 725 | - $is_element = 0; |
|
| 726 | - } |
|
| 697 | + /** |
|
| 698 | + * returns an associative array of information about a given type |
|
| 699 | + * returns false if no type exists by the given name |
|
| 700 | + * |
|
| 701 | + * For a complexType typeDef = array( |
|
| 702 | + * 'restrictionBase' => '', |
|
| 703 | + * 'phpType' => '', |
|
| 704 | + * 'compositor' => '(sequence|all)', |
|
| 705 | + * 'elements' => array(), // refs to elements array |
|
| 706 | + * 'attrs' => array() // refs to attributes array |
|
| 707 | + * ... and so on (see addComplexType) |
|
| 708 | + * ) |
|
| 709 | + * |
|
| 710 | + * For simpleType or element, the array has different keys. |
|
| 711 | + * |
|
| 712 | + * @param string $type |
|
| 713 | + * @return mixed |
|
| 714 | + * @access public |
|
| 715 | + * @see addComplexType |
|
| 716 | + * @see addSimpleType |
|
| 717 | + * @see addElement |
|
| 718 | + */ |
|
| 719 | + function getTypeDef($type){
|
|
| 720 | + //$this->debug("in getTypeDef for type $type");
|
|
| 721 | + if (substr($type, -1) == '^') {
|
|
| 722 | + $is_element = 1; |
|
| 723 | + $type = substr($type, 0, -1); |
|
| 724 | + } else {
|
|
| 725 | + $is_element = 0; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | - $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | - return $this->complexTypes[$type]; |
|
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | - $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | - if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | - // get info for type to tack onto the simple type |
|
| 735 | - // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | - $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | - $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | - $etype = $this->getTypeDef($uqType); |
|
| 739 | - if ($etype) {
|
|
| 740 | - $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | - $this->xdebug($this->varDump($etype)); |
|
| 742 | - if (isset($etype['phpType'])) {
|
|
| 743 | - $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | - } |
|
| 745 | - if (isset($etype['elements'])) {
|
|
| 746 | - $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - return $this->simpleTypes[$type]; |
|
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 752 | - $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | - if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | - // get info for type to tack onto the element |
|
| 755 | - $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | - $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | - $etype = $this->getTypeDef($uqType); |
|
| 758 | - if ($etype) {
|
|
| 759 | - $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | - $this->xdebug($this->varDump($etype)); |
|
| 761 | - if (isset($etype['phpType'])) {
|
|
| 762 | - $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | - } |
|
| 764 | - if (isset($etype['elements'])) {
|
|
| 765 | - $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | - } |
|
| 767 | - if (isset($etype['extensionBase'])) {
|
|
| 768 | - $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | - } |
|
| 770 | - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | - $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | - $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - return $this->elements[$type]; |
|
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 777 | - $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | - return $this->attributes[$type]; |
|
| 779 | - } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | - $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | - $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | - $typeDef['phpType'] = 'scalar'; |
|
| 783 | - $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | - return $typeDef; |
|
| 785 | - } |
|
| 786 | - $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | - return false; |
|
| 788 | - } |
|
| 728 | + if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | + $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | + return $this->complexTypes[$type]; |
|
| 731 | + } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | + $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | + if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | + // get info for type to tack onto the simple type |
|
| 735 | + // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | + $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | + $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | + $etype = $this->getTypeDef($uqType); |
|
| 739 | + if ($etype) {
|
|
| 740 | + $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | + $this->xdebug($this->varDump($etype)); |
|
| 742 | + if (isset($etype['phpType'])) {
|
|
| 743 | + $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | + } |
|
| 745 | + if (isset($etype['elements'])) {
|
|
| 746 | + $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + return $this->simpleTypes[$type]; |
|
| 751 | + } elseif(isset($this->elements[$type])){
|
|
| 752 | + $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | + if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | + // get info for type to tack onto the element |
|
| 755 | + $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | + $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | + $etype = $this->getTypeDef($uqType); |
|
| 758 | + if ($etype) {
|
|
| 759 | + $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | + $this->xdebug($this->varDump($etype)); |
|
| 761 | + if (isset($etype['phpType'])) {
|
|
| 762 | + $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | + } |
|
| 764 | + if (isset($etype['elements'])) {
|
|
| 765 | + $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | + } |
|
| 767 | + if (isset($etype['extensionBase'])) {
|
|
| 768 | + $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | + } |
|
| 770 | + } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | + $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | + $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + return $this->elements[$type]; |
|
| 776 | + } elseif(isset($this->attributes[$type])){
|
|
| 777 | + $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | + return $this->attributes[$type]; |
|
| 779 | + } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | + $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | + $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | + $typeDef['phpType'] = 'scalar'; |
|
| 783 | + $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | + return $typeDef; |
|
| 785 | + } |
|
| 786 | + $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | + return false; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - /** |
|
| 791 | - * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | - * |
|
| 793 | - * @param string $type name of type |
|
| 794 | - * @return mixed |
|
| 795 | - * @access public |
|
| 796 | - * @deprecated |
|
| 797 | - */ |
|
| 790 | + /** |
|
| 791 | + * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | + * |
|
| 793 | + * @param string $type name of type |
|
| 794 | + * @return mixed |
|
| 795 | + * @access public |
|
| 796 | + * @deprecated |
|
| 797 | + */ |
|
| 798 | 798 | function serializeTypeDef($type){
|
| 799 | - //print "in sTD() for type $type<br>"; |
|
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | - $str .= '<'.$type; |
|
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | - $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 809 | - $str .= ">"; |
|
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | - $str .= $this->serializeTypeDef($element); |
|
| 812 | - } |
|
| 813 | - $str .= "</$type>"; |
|
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | - $str .= "></$type>"; |
|
| 816 | - } else {
|
|
| 817 | - $str .= "/>"; |
|
| 818 | - } |
|
| 819 | - return $str; |
|
| 820 | - } |
|
| 821 | - return false; |
|
| 799 | + //print "in sTD() for type $type<br>"; |
|
| 800 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | + $str .= '<'.$type; |
|
| 802 | + if(is_array($typeDef['attrs'])){
|
|
| 803 | + foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | + $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | + if(count($typeDef['elements']) > 0){
|
|
| 809 | + $str .= ">"; |
|
| 810 | + foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | + $str .= $this->serializeTypeDef($element); |
|
| 812 | + } |
|
| 813 | + $str .= "</$type>"; |
|
| 814 | + } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | + $str .= "></$type>"; |
|
| 816 | + } else {
|
|
| 817 | + $str .= "/>"; |
|
| 818 | + } |
|
| 819 | + return $str; |
|
| 820 | + } |
|
| 821 | + return false; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | - * returns HTML form elements that allow a user |
|
| 826 | - * to enter values for creating an instance of the given type. |
|
| 827 | - * |
|
| 828 | - * @param string $name name for type instance |
|
| 829 | - * @param string $type name of type |
|
| 830 | - * @return string |
|
| 831 | - * @access public |
|
| 832 | - * @deprecated |
|
| 833 | - */ |
|
| 834 | - function typeToForm($name,$type){
|
|
| 835 | - // get typedef |
|
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | - // if struct |
|
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 839 | - $buffer .= '<table>'; |
|
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | - $buffer .= " |
|
| 825 | + * returns HTML form elements that allow a user |
|
| 826 | + * to enter values for creating an instance of the given type. |
|
| 827 | + * |
|
| 828 | + * @param string $name name for type instance |
|
| 829 | + * @param string $type name of type |
|
| 830 | + * @return string |
|
| 831 | + * @access public |
|
| 832 | + * @deprecated |
|
| 833 | + */ |
|
| 834 | + function typeToForm($name,$type){
|
|
| 835 | + // get typedef |
|
| 836 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | + // if struct |
|
| 838 | + if($typeDef['phpType'] == 'struct'){
|
|
| 839 | + $buffer .= '<table>'; |
|
| 840 | + foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | + $buffer .= " |
|
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | - } |
|
| 845 | - $buffer .= '</table>'; |
|
| 846 | - // if array |
|
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | - $buffer .= '<table>'; |
|
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 850 | - $buffer .= " |
|
| 844 | + } |
|
| 845 | + $buffer .= '</table>'; |
|
| 846 | + // if array |
|
| 847 | + } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | + $buffer .= '<table>'; |
|
| 849 | + for($i=0;$i < 3; $i++){
|
|
| 850 | + $buffer .= " |
|
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
| 853 | - } |
|
| 854 | - $buffer .= '</table>'; |
|
| 855 | - // if scalar |
|
| 856 | - } else {
|
|
| 857 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | - } |
|
| 859 | - } else {
|
|
| 860 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | - } |
|
| 862 | - return $buffer; |
|
| 863 | - } |
|
| 853 | + } |
|
| 854 | + $buffer .= '</table>'; |
|
| 855 | + // if scalar |
|
| 856 | + } else {
|
|
| 857 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | + } |
|
| 859 | + } else {
|
|
| 860 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | + } |
|
| 862 | + return $buffer; |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * adds a complex type to the schema |
|
| 867 | - * |
|
| 868 | - * example: array |
|
| 869 | - * |
|
| 870 | - * addType( |
|
| 871 | - * 'ArrayOfstring', |
|
| 872 | - * 'complexType', |
|
| 873 | - * 'array', |
|
| 874 | - * '', |
|
| 875 | - * 'SOAP-ENC:Array', |
|
| 876 | - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | - * 'xsd:string' |
|
| 878 | - * ); |
|
| 879 | - * |
|
| 880 | - * example: PHP associative array ( SOAP Struct ) |
|
| 881 | - * |
|
| 882 | - * addType( |
|
| 883 | - * 'SOAPStruct', |
|
| 884 | - * 'complexType', |
|
| 885 | - * 'struct', |
|
| 886 | - * 'all', |
|
| 887 | - * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | - * ); |
|
| 889 | - * |
|
| 890 | - * @param name |
|
| 891 | - * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | - * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | - * @param compositor (all|sequence|choice) |
|
| 894 | - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | - * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | - * @param attrs = array( |
|
| 897 | - * array( |
|
| 898 | - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | - * ) |
|
| 901 | - * ) |
|
| 902 | - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | - * @access public |
|
| 904 | - * @see getTypeDef |
|
| 905 | - */ |
|
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | - $this->complexTypes[$name] = array( |
|
| 908 | - 'name' => $name, |
|
| 909 | - 'typeClass' => $typeClass, |
|
| 910 | - 'phpType' => $phpType, |
|
| 911 | - 'compositor'=> $compositor, |
|
| 912 | - 'restrictionBase' => $restrictionBase, |
|
| 913 | - 'elements' => $elements, |
|
| 914 | - 'attrs' => $attrs, |
|
| 915 | - 'arrayType' => $arrayType |
|
| 916 | - ); |
|
| 865 | + /** |
|
| 866 | + * adds a complex type to the schema |
|
| 867 | + * |
|
| 868 | + * example: array |
|
| 869 | + * |
|
| 870 | + * addType( |
|
| 871 | + * 'ArrayOfstring', |
|
| 872 | + * 'complexType', |
|
| 873 | + * 'array', |
|
| 874 | + * '', |
|
| 875 | + * 'SOAP-ENC:Array', |
|
| 876 | + * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | + * 'xsd:string' |
|
| 878 | + * ); |
|
| 879 | + * |
|
| 880 | + * example: PHP associative array ( SOAP Struct ) |
|
| 881 | + * |
|
| 882 | + * addType( |
|
| 883 | + * 'SOAPStruct', |
|
| 884 | + * 'complexType', |
|
| 885 | + * 'struct', |
|
| 886 | + * 'all', |
|
| 887 | + * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | + * ); |
|
| 889 | + * |
|
| 890 | + * @param name |
|
| 891 | + * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | + * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | + * @param compositor (all|sequence|choice) |
|
| 894 | + * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | + * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | + * @param attrs = array( |
|
| 897 | + * array( |
|
| 898 | + * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | + * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | + * ) |
|
| 901 | + * ) |
|
| 902 | + * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | + * @access public |
|
| 904 | + * @see getTypeDef |
|
| 905 | + */ |
|
| 906 | + function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | + $this->complexTypes[$name] = array( |
|
| 908 | + 'name' => $name, |
|
| 909 | + 'typeClass' => $typeClass, |
|
| 910 | + 'phpType' => $phpType, |
|
| 911 | + 'compositor'=> $compositor, |
|
| 912 | + 'restrictionBase' => $restrictionBase, |
|
| 913 | + 'elements' => $elements, |
|
| 914 | + 'attrs' => $attrs, |
|
| 915 | + 'arrayType' => $arrayType |
|
| 916 | + ); |
|
| 917 | 917 | |
| 918 | - $this->xdebug("addComplexType $name:");
|
|
| 919 | - $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | - } |
|
| 918 | + $this->xdebug("addComplexType $name:");
|
|
| 919 | + $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - /** |
|
| 923 | - * adds a simple type to the schema |
|
| 924 | - * |
|
| 925 | - * @param string $name |
|
| 926 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | - * @param string $typeClass (should always be simpleType) |
|
| 928 | - * @param string $phpType (should always be scalar) |
|
| 929 | - * @param array $enumeration array of values |
|
| 930 | - * @access public |
|
| 931 | - * @see nusoap_xmlschema |
|
| 932 | - * @see getTypeDef |
|
| 933 | - */ |
|
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | - $this->simpleTypes[$name] = array( |
|
| 936 | - 'name' => $name, |
|
| 937 | - 'typeClass' => $typeClass, |
|
| 938 | - 'phpType' => $phpType, |
|
| 939 | - 'type' => $restrictionBase, |
|
| 940 | - 'enumeration' => $enumeration |
|
| 941 | - ); |
|
| 922 | + /** |
|
| 923 | + * adds a simple type to the schema |
|
| 924 | + * |
|
| 925 | + * @param string $name |
|
| 926 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | + * @param string $typeClass (should always be simpleType) |
|
| 928 | + * @param string $phpType (should always be scalar) |
|
| 929 | + * @param array $enumeration array of values |
|
| 930 | + * @access public |
|
| 931 | + * @see nusoap_xmlschema |
|
| 932 | + * @see getTypeDef |
|
| 933 | + */ |
|
| 934 | + function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | + $this->simpleTypes[$name] = array( |
|
| 936 | + 'name' => $name, |
|
| 937 | + 'typeClass' => $typeClass, |
|
| 938 | + 'phpType' => $phpType, |
|
| 939 | + 'type' => $restrictionBase, |
|
| 940 | + 'enumeration' => $enumeration |
|
| 941 | + ); |
|
| 942 | 942 | |
| 943 | - $this->xdebug("addSimpleType $name:");
|
|
| 944 | - $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | - } |
|
| 943 | + $this->xdebug("addSimpleType $name:");
|
|
| 944 | + $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - /** |
|
| 948 | - * adds an element to the schema |
|
| 949 | - * |
|
| 950 | - * @param array $attrs attributes that must include name and type |
|
| 951 | - * @see nusoap_xmlschema |
|
| 952 | - * @access public |
|
| 953 | - */ |
|
| 954 | - function addElement($attrs) {
|
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | - } |
|
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 947 | + /** |
|
| 948 | + * adds an element to the schema |
|
| 949 | + * |
|
| 950 | + * @param array $attrs attributes that must include name and type |
|
| 951 | + * @see nusoap_xmlschema |
|
| 952 | + * @access public |
|
| 953 | + */ |
|
| 954 | + function addElement($attrs) {
|
|
| 955 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | + } |
|
| 958 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | - } |
|
| 961 | + $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | + } |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @version $Id: class.xmlschema.php,v 1.53 2010/04/26 20:15:08 snichol Exp $ |
| 13 | 13 | * @access public |
| 14 | 14 | */ |
| 15 | -class nusoap_xmlschema extends nusoap_base {
|
|
| 15 | +class nusoap_xmlschema extends nusoap_base {
|
|
| 16 | 16 | |
| 17 | 17 | // files |
| 18 | 18 | var $schema = ''; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string $namespaces namespaces defined in enclosing XML |
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 54 | + function nusoap_xmlschema($schema = '', $xml = '', $namespaces = array()) {
|
|
| 55 | 55 | parent::nusoap_base(); |
| 56 | 56 | $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
| 57 | 57 | // files |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | $this->namespaces = array_merge($this->namespaces, $namespaces); |
| 64 | 64 | |
| 65 | 65 | // parse schema file |
| 66 | - if($schema != ''){
|
|
| 66 | + if ($schema != '') {
|
|
| 67 | 67 | $this->debug('initial schema file: '.$schema);
|
| 68 | 68 | $this->parseFile($schema, 'schema'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // parse xml file |
| 72 | - if($xml != ''){
|
|
| 72 | + if ($xml != '') {
|
|
| 73 | 73 | $this->debug('initial xml file: '.$xml);
|
| 74 | 74 | $this->parseFile($xml, 'xml'); |
| 75 | 75 | } |
@@ -84,18 +84,18 @@ discard block |
||
| 84 | 84 | * @return boolean |
| 85 | 85 | * @access public |
| 86 | 86 | */ |
| 87 | - function parseFile($xml,$type){
|
|
| 87 | + function parseFile($xml, $type) {
|
|
| 88 | 88 | // parse xml file |
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 89 | + if ($xml != "") {
|
|
| 90 | + $xmlStr = @join("", @file($xml));
|
|
| 91 | + if ($xmlStr == "") {
|
|
| 92 | 92 | $msg = 'Error reading XML from '.$xml; |
| 93 | 93 | $this->setError($msg); |
| 94 | 94 | $this->debug($msg); |
| 95 | 95 | return false; |
| 96 | 96 | } else {
|
| 97 | 97 | $this->debug("parsing $xml");
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 98 | + $this->parseString($xmlStr, $type); |
|
| 99 | 99 | $this->debug("done parsing $xml");
|
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param string $type (schema|xml) |
| 111 | 111 | * @access private |
| 112 | 112 | */ |
| 113 | - function parseString($xml,$type){
|
|
| 113 | + function parseString($xml, $type) {
|
|
| 114 | 114 | // parse xml string |
| 115 | - if($xml != ""){
|
|
| 115 | + if ($xml != "") {
|
|
| 116 | 116 | |
| 117 | 117 | // Create an XML parser. |
| 118 | 118 | $this->parser = xml_parser_create(); |
@@ -123,28 +123,28 @@ discard block |
||
| 123 | 123 | xml_set_object($this->parser, $this); |
| 124 | 124 | |
| 125 | 125 | // Set the element handlers for the parser. |
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 126 | + if ($type == "schema") {
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser, 'schemaCharacterData'); |
|
| 129 | + } elseif ($type == "xml") {
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser, 'xmlCharacterData'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Parse the XML file. |
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 135 | + if (!xml_parse($this->parser, $xml, true)) {
|
|
| 136 | 136 | // Display an error message. |
| 137 | 137 | $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
| 138 | 138 | xml_get_current_line_number($this->parser), |
| 139 | 139 | xml_error_string(xml_get_error_code($this->parser)) |
| 140 | 140 | ); |
| 141 | 141 | $this->debug($errstr); |
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 142 | + $this->debug("XML payload:\n".$xml);
|
|
| 143 | 143 | $this->setError($errstr); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | xml_parser_free($this->parser); |
| 147 | - } else{
|
|
| 147 | + } else {
|
|
| 148 | 148 | $this->debug('no xml passed to parseString()!!');
|
| 149 | 149 | $this->setError('no xml passed to parseString()!!');
|
| 150 | 150 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | function CreateTypeName($ename) {
|
| 161 | 161 | $scope = ''; |
| 162 | 162 | for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 163 | + $scope .= $this->complexTypeStack[$i].'_'; |
|
| 164 | 164 | } |
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 165 | + return $scope.$ename.'_ContainedType'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // get element prefix |
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 191 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 192 | 192 | // get unqualified name |
| 193 | 193 | $name = $this->getLocalPart($name); |
| 194 | 194 | } else {
|
@@ -196,31 +196,31 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | - if(count($attrs) > 0){
|
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 199 | + if (count($attrs) > 0) {
|
|
| 200 | + foreach ($attrs as $k => $v) {
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 202 | + if (preg_match('/^xmlns/', $k)) {
|
|
| 203 | 203 | //$this->xdebug("$k: $v");
|
| 204 | 204 | //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 205 | + if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
|
|
| 206 | 206 | //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
| 207 | 207 | $this->namespaces[$ns_prefix] = $v; |
| 208 | 208 | } else {
|
| 209 | 209 | $this->defaultNamespace[$pos] = $v; |
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 210 | + if (!$this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 214 | + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
|
|
| 215 | 215 | $this->XMLSchemaVersion = $v; |
| 216 | 216 | $this->namespaces['xsi'] = $v.'-instance'; |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - foreach($attrs as $k => $v){
|
|
| 220 | + foreach ($attrs as $k => $v) {
|
|
| 221 | 221 | // expand each attribute |
| 222 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 223 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 222 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 223 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 224 | 224 | $eAttrs[$k] = $v; |
| 225 | 225 | } |
| 226 | 226 | $attrs = $eAttrs; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $attrs = array(); |
| 229 | 229 | } |
| 230 | 230 | // find status, register data |
| 231 | - switch($name){
|
|
| 231 | + switch ($name) {
|
|
| 232 | 232 | case 'all': // (optional) compositor content for a complexType |
| 233 | 233 | case 'choice': |
| 234 | 234 | case 'group': |
@@ -253,41 +253,41 @@ discard block |
||
| 253 | 253 | // no namespace in arrayType attribute value... |
| 254 | 254 | if ($this->defaultNamespace[$pos]) {
|
| 255 | 255 | // ...so use the default |
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].':'.$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | - if(isset($attrs['name'])){
|
|
| 260 | + if (isset($attrs['name'])) {
|
|
| 261 | 261 | $this->attributes[$attrs['name']] = $attrs; |
| 262 | 262 | $aname = $attrs['name']; |
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 263 | + } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
|
|
| 264 | 264 | if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
| 265 | 265 | $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 266 | 266 | } else {
|
| 267 | 267 | $aname = ''; |
| 268 | 268 | } |
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 269 | + } elseif (isset($attrs['ref'])) {
|
|
| 270 | 270 | $aname = $attrs['ref']; |
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 274 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 275 | 275 | $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
| 276 | 276 | } |
| 277 | 277 | // arrayType attribute |
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 278 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
|
|
| 279 | 279 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 280 | 280 | $prefix = $this->getPrefix($aname); |
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 281 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 282 | 282 | $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 283 | 283 | } else {
|
| 284 | 284 | $v = ''; |
| 285 | 285 | } |
| 286 | - if(strpos($v,'[,]')){
|
|
| 286 | + if (strpos($v, '[,]')) {
|
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
| 289 | - $v = substr($v,0,strpos($v,'[')); // clip the [] |
|
| 290 | - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
|
|
| 289 | + $v = substr($v, 0, strpos($v, '[')); // clip the [] |
|
| 290 | + if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
|
|
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | break; |
| 299 | 299 | case 'complexType': |
| 300 | 300 | array_push($this->complexTypeStack, $this->currentComplexType); |
| 301 | - if(isset($attrs['name'])){
|
|
| 301 | + if (isset($attrs['name'])) {
|
|
| 302 | 302 | // TODO: what is the scope of named complexTypes that appear |
| 303 | 303 | // nested within other c complexTypes? |
| 304 | 304 | $this->xdebug('processing named complexType '.$attrs['name']);
|
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // minOccurs="0" maxOccurs="unbounded" /> |
| 314 | 314 | // </sequence> |
| 315 | 315 | // </complexType> |
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 316 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 317 | 317 | $this->xdebug('complexType is unusual array');
|
| 318 | 318 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 319 | 319 | } else {
|
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | } else {
|
| 323 | 323 | $name = $this->CreateTypeName($this->currentElement); |
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 324 | + $this->xdebug('processing unnamed complexType for element '.$this->currentElement.' named '.$name);
|
|
| 325 | 325 | $this->currentComplexType = $name; |
| 326 | 326 | //$this->currentElement = false; |
| 327 | 327 | $this->complexTypes[$this->currentComplexType] = $attrs; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | // minOccurs="0" maxOccurs="unbounded" /> |
| 334 | 334 | // </sequence> |
| 335 | 335 | // </complexType> |
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 336 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 337 | 337 | $this->xdebug('complexType is unusual array');
|
| 338 | 338 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 339 | 339 | } else {
|
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | $attrs['form'] = 'qualified'; |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | - if(isset($attrs['type'])){
|
|
| 355 | + if (isset($attrs['type'])) {
|
|
| 356 | 356 | $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 357 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 358 | 358 | if ($this->defaultNamespace[$pos]) {
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos].':'.$attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type '.$attrs['type']);
|
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | // This is for constructs like |
@@ -368,20 +368,20 @@ discard block |
||
| 368 | 368 | // </sequence> |
| 369 | 369 | // </complexType> |
| 370 | 370 | if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 371 | + $this->xdebug('arrayType for unusual array is '.$attrs['type']);
|
|
| 372 | 372 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
| 373 | 373 | } |
| 374 | 374 | $this->currentElement = $attrs['name']; |
| 375 | 375 | $ename = $attrs['name']; |
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 376 | + } elseif (isset($attrs['ref'])) {
|
|
| 377 | 377 | $this->xdebug("processing element as ref to ".$attrs['ref']);
|
| 378 | 378 | $this->currentElement = "ref to ".$attrs['ref']; |
| 379 | 379 | $ename = $this->getLocalPart($attrs['ref']); |
| 380 | 380 | } else {
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType.'_'.$attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element ".$attrs['name'].' type '.$type);
|
|
| 383 | 383 | $this->currentElement = $attrs['name']; |
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$type; |
|
| 385 | 385 | $ename = $attrs['name']; |
| 386 | 386 | } |
| 387 | 387 | if (isset($ename) && $this->currentComplexType) {
|
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
| 390 | 390 | } elseif (!isset($attrs['ref'])) {
|
| 391 | 391 | $this->xdebug("add element $ename to elements array");
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 392 | + $this->elements[$attrs['name']] = $attrs; |
|
| 393 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 394 | 394 | } |
| 395 | 395 | break; |
| 396 | 396 | case 'enumeration': // restriction value list member |
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 397 | + $this->xdebug('enumeration '.$attrs['value']);
|
|
| 398 | 398 | if ($this->currentSimpleType) {
|
| 399 | 399 | $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
| 400 | 400 | } elseif ($this->currentComplexType) {
|
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | break; |
| 404 | 404 | case 'extension': // simpleContent or complexContent type extension |
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 405 | + $this->xdebug('extension '.$attrs['base']);
|
|
| 406 | 406 | if ($this->currentComplexType) {
|
| 407 | 407 | $ns = $this->getPrefix($attrs['base']); |
| 408 | 408 | if ($ns == '') {
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace.':'.$attrs['base']; |
|
| 410 | 410 | } else {
|
| 411 | 411 | $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
| 412 | 412 | } |
@@ -416,19 +416,19 @@ discard block |
||
| 416 | 416 | break; |
| 417 | 417 | case 'import': |
| 418 | 418 | if (isset($attrs['schemaLocation'])) {
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 419 | + $this->xdebug('import namespace '.$attrs['namespace'].' from '.$attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | 421 | } else {
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 422 | + $this->xdebug('import namespace '.$attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 424 | + if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace']; |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | break; |
| 429 | 429 | case 'include': |
| 430 | 430 | if (isset($attrs['schemaLocation'])) {
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 431 | + $this->xdebug('include into namespace '.$this->schemaTargetNamespace.' from '.$attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | 433 | } else {
|
| 434 | 434 | $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
@@ -438,12 +438,12 @@ discard block |
||
| 438 | 438 | $this->xdebug("do nothing for element $name");
|
| 439 | 439 | break; |
| 440 | 440 | case 'restriction': // simpleType, simpleContent or complexContent value restriction |
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 441 | + $this->xdebug('restriction '.$attrs['base']);
|
|
| 442 | + if ($this->currentSimpleType) {
|
|
| 443 | 443 | $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
| 444 | - } elseif($this->currentComplexType){
|
|
| 444 | + } elseif ($this->currentComplexType) {
|
|
| 445 | 445 | $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 446 | + if (strstr($attrs['base'], ':') == ':Array') {
|
|
| 447 | 447 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 448 | 448 | } |
| 449 | 449 | } |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | break; |
| 471 | 471 | case 'simpleType': |
| 472 | 472 | array_push($this->simpleTypeStack, $this->currentSimpleType); |
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 473 | + if (isset($attrs['name'])) {
|
|
| 474 | + $this->xdebug("processing simpleType for name ".$attrs['name']);
|
|
| 475 | 475 | $this->currentSimpleType = $attrs['name']; |
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 476 | + $this->simpleTypes[$attrs['name']] = $attrs; |
|
| 477 | + $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar'; |
|
| 479 | 479 | } else {
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType.'_'.$this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element '.$this->currentElement.' named '.$name);
|
|
| 482 | 482 | $this->currentSimpleType = $name; |
| 483 | 483 | //$this->currentElement = false; |
| 484 | 484 | $this->simpleTypes[$this->currentSimpleType] = $attrs; |
@@ -504,29 +504,29 @@ discard block |
||
| 504 | 504 | // bring depth down a notch |
| 505 | 505 | $this->depth--; |
| 506 | 506 | // position of current element is equal to the last value left in depth_array for my depth |
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 507 | + if (isset($this->depth_array[$this->depth])) {
|
|
| 508 | 508 | $pos = $this->depth_array[$this->depth]; |
| 509 | 509 | } |
| 510 | 510 | // get element prefix |
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 511 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 512 | 512 | // get unqualified name |
| 513 | 513 | $name = $this->getLocalPart($name); |
| 514 | 514 | } else {
|
| 515 | 515 | $prefix = ''; |
| 516 | 516 | } |
| 517 | 517 | // move on... |
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 518 | + if ($name == 'complexType') {
|
|
| 519 | + $this->xdebug('done processing complexType '.($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | 520 | $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
| 521 | 521 | $this->currentComplexType = array_pop($this->complexTypeStack); |
| 522 | 522 | //$this->currentElement = false; |
| 523 | 523 | } |
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 524 | + if ($name == 'element') {
|
|
| 525 | + $this->xdebug('done processing element '.($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | 526 | $this->currentElement = array_pop($this->elementStack); |
| 527 | 527 | } |
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 528 | + if ($name == 'simpleType') {
|
|
| 529 | + $this->xdebug('done processing simpleType '.($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | 530 | $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
| 531 | 531 | $this->currentSimpleType = array_pop($this->simpleTypeStack); |
| 532 | 532 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param string $data element content |
| 540 | 540 | * @access private |
| 541 | 541 | */ |
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 542 | + function schemaCharacterData($parser, $data) {
|
|
| 543 | 543 | $pos = $this->depth_array[$this->depth - 1]; |
| 544 | 544 | $this->message[$pos]['cdata'] .= $data; |
| 545 | 545 | } |
@@ -549,32 +549,32 @@ discard block |
||
| 549 | 549 | * |
| 550 | 550 | * @access public |
| 551 | 551 | */ |
| 552 | - function serializeSchema(){
|
|
| 552 | + function serializeSchema() {
|
|
| 553 | 553 | |
| 554 | 554 | $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
| 555 | 555 | $xml = ''; |
| 556 | 556 | // imports |
| 557 | 557 | if (sizeof($this->imports) > 0) {
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 558 | + foreach ($this->imports as $ns => $list) {
|
|
| 559 | 559 | foreach ($list as $ii) {
|
| 560 | 560 | if ($ii['location'] != '') {
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"".$ii['location'].'" namespace="'.$ns."\" />\n"; |
|
| 562 | 562 | } else {
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"".$ns."\" />\n"; |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | // complex types |
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 569 | + foreach ($this->complexTypes as $typeName => $attrs) {
|
|
| 570 | 570 | $contentStr = ''; |
| 571 | 571 | // serialize child elements |
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 572 | + if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
|
|
| 573 | + foreach ($attrs['elements'] as $element => $eParts) {
|
|
| 574 | + if (isset($eParts['ref'])) {
|
|
| 575 | 575 | $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
| 576 | 576 | } else {
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\""; |
|
| 578 | 578 | foreach ($eParts as $aName => $aValue) {
|
| 579 | 579 | // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
| 580 | 580 | if ($aName != 'name' && $aName != 'type') {
|
@@ -590,8 +590,8 @@ discard block |
||
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | // attributes |
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 593 | + if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
|
|
| 594 | + foreach ($attrs['attrs'] as $attr => $aParts) {
|
|
| 595 | 595 | $contentStr .= " <$schemaPrefix:attribute"; |
| 596 | 596 | foreach ($aParts as $a => $v) {
|
| 597 | 597 | if ($a == 'ref' || $a == 'type') {
|
@@ -607,15 +607,15 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | // if restriction |
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
|
|
| 611 | 611 | $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
| 612 | 612 | // complex or simple content |
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
|
|
| 614 | 614 | $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | // finalize complex type |
| 618 | - if($contentStr != ''){
|
|
| 618 | + if ($contentStr != '') {
|
|
| 619 | 619 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
| 620 | 620 | } else {
|
| 621 | 621 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | $xml .= $contentStr; |
| 624 | 624 | } |
| 625 | 625 | // simple types |
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 626 | + if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
|
|
| 627 | + foreach ($this->simpleTypes as $typeName => $eParts) {
|
|
| 628 | 628 | $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
| 629 | 629 | if (isset($eParts['enumeration'])) {
|
| 630 | 630 | foreach ($eParts['enumeration'] as $e) {
|
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | // elements |
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 638 | + if (isset($this->elements) && count($this->elements) > 0) {
|
|
| 639 | + foreach ($this->elements as $element => $eParts) {
|
|
| 640 | 640 | $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | // attributes |
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 644 | + if (isset($this->attributes) && count($this->attributes) > 0) {
|
|
| 645 | + foreach ($this->attributes as $attr => $aParts) {
|
|
| 646 | 646 | $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
| 658 | 658 | $el .= " xmlns:$nsp=\"$ns\""; |
| 659 | 659 | } |
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 660 | + $xml = $el.">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | 661 | return $xml; |
| 662 | 662 | } |
| 663 | 663 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | * @param string $string debug data |
| 668 | 668 | * @access private |
| 669 | 669 | */ |
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 670 | + function xdebug($string) {
|
|
| 671 | + $this->debug('<'.$this->schemaTargetNamespace.'> '.$string);
|
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | * @access public |
| 684 | 684 | * @deprecated |
| 685 | 685 | */ |
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 686 | + function getPHPType($type, $ns) {
|
|
| 687 | + if (isset($this->typemap[$ns][$type])) {
|
|
| 688 | 688 | //print "found type '$type' and ns $ns in typemap<br>"; |
| 689 | 689 | return $this->typemap[$ns][$type]; |
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 690 | + } elseif (isset($this->complexTypes[$type])) {
|
|
| 691 | 691 | //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
| 692 | 692 | return $this->complexTypes[$type]['phpType']; |
| 693 | 693 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | * @see addSimpleType |
| 717 | 717 | * @see addElement |
| 718 | 718 | */ |
| 719 | - function getTypeDef($type){
|
|
| 719 | + function getTypeDef($type) {
|
|
| 720 | 720 | //$this->debug("in getTypeDef for type $type");
|
| 721 | 721 | if (substr($type, -1) == '^') {
|
| 722 | 722 | $is_element = 1; |
@@ -725,10 +725,10 @@ discard block |
||
| 725 | 725 | $is_element = 0; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 728 | + if ((!$is_element) && isset($this->complexTypes[$type])) {
|
|
| 729 | 729 | $this->xdebug("in getTypeDef, found complexType $type");
|
| 730 | 730 | return $this->complexTypes[$type]; |
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 731 | + } elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
|
|
| 732 | 732 | $this->xdebug("in getTypeDef, found simpleType $type");
|
| 733 | 733 | if (!isset($this->simpleTypes[$type]['phpType'])) {
|
| 734 | 734 | // get info for type to tack onto the simple type |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | return $this->simpleTypes[$type]; |
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 751 | + } elseif (isset($this->elements[$type])) {
|
|
| 752 | 752 | $this->xdebug("in getTypeDef, found element $type");
|
| 753 | 753 | if (!isset($this->elements[$type]['phpType'])) {
|
| 754 | 754 | // get info for type to tack onto the element |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | return $this->elements[$type]; |
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 776 | + } elseif (isset($this->attributes[$type])) {
|
|
| 777 | 777 | $this->xdebug("in getTypeDef, found attribute $type");
|
| 778 | 778 | return $this->attributes[$type]; |
| 779 | 779 | } elseif (preg_match('/_ContainedType$/', $type)) {
|
@@ -795,23 +795,23 @@ discard block |
||
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
| 798 | - function serializeTypeDef($type){
|
|
| 798 | + function serializeTypeDef($type) {
|
|
| 799 | 799 | //print "in sTD() for type $type<br>"; |
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 800 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 801 | 801 | $str .= '<'.$type; |
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 802 | + if (is_array($typeDef['attrs'])) {
|
|
| 803 | + foreach ($typeDef['attrs'] as $attName => $data) {
|
|
| 804 | 804 | $str .= " $attName=\"{type = ".$data['type']."}\"";
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 808 | + if (count($typeDef['elements']) > 0) {
|
|
| 809 | 809 | $str .= ">"; |
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 810 | + foreach ($typeDef['elements'] as $element => $eData) {
|
|
| 811 | 811 | $str .= $this->serializeTypeDef($element); |
| 812 | 812 | } |
| 813 | 813 | $str .= "</$type>"; |
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 814 | + } elseif ($typeDef['typeClass'] == 'element') {
|
|
| 815 | 815 | $str .= "></$type>"; |
| 816 | 816 | } else {
|
| 817 | 817 | $str .= "/>"; |
@@ -831,22 +831,22 @@ discard block |
||
| 831 | 831 | * @access public |
| 832 | 832 | * @deprecated |
| 833 | 833 | */ |
| 834 | - function typeToForm($name,$type){
|
|
| 834 | + function typeToForm($name, $type) {
|
|
| 835 | 835 | // get typedef |
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 836 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 837 | 837 | // if struct |
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 838 | + if ($typeDef['phpType'] == 'struct') {
|
|
| 839 | 839 | $buffer .= '<table>'; |
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 840 | + foreach ($typeDef['elements'] as $child => $childDef) {
|
|
| 841 | 841 | $buffer .= " |
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | 844 | } |
| 845 | 845 | $buffer .= '</table>'; |
| 846 | 846 | // if array |
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 847 | + } elseif ($typeDef['phpType'] == 'array') {
|
|
| 848 | 848 | $buffer .= '<table>'; |
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 849 | + for ($i = 0; $i < 3; $i++) {
|
|
| 850 | 850 | $buffer .= " |
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @access public |
| 904 | 904 | * @see getTypeDef |
| 905 | 905 | */ |
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 906 | + function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
|
|
| 907 | 907 | $this->complexTypes[$name] = array( |
| 908 | 908 | 'name' => $name, |
| 909 | 909 | 'typeClass' => $typeClass, |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * @see nusoap_xmlschema |
| 932 | 932 | * @see getTypeDef |
| 933 | 933 | */ |
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 934 | + function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
|
|
| 935 | 935 | $this->simpleTypes[$name] = array( |
| 936 | 936 | 'name' => $name, |
| 937 | 937 | 'typeClass' => $typeClass, |
@@ -952,14 +952,14 @@ discard block |
||
| 952 | 952 | * @access public |
| 953 | 953 | */ |
| 954 | 954 | function addElement($attrs) {
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 955 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$attrs['type']; |
|
| 957 | 957 | } |
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 958 | + $this->elements[$attrs['name']] = $attrs; |
|
| 959 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 961 | + $this->xdebug("addElement ".$attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[$attrs['name']])); |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
@@ -447,7 +447,7 @@ |
||
| 447 | 447 | * |
| 448 | 448 | * @param array $headers The HTTP headers |
| 449 | 449 | * @param string $data unprocessed request data from client |
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 450 | + * @return false|null value of the message, decoded into a PHP type |
|
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
@@ -52,224 +52,224 @@ discard block |
||
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | 54 | class nusoap_client_mime extends nusoap_client {
|
| 55 | - /** |
|
| 56 | - * @var array Each array element in the return is an associative array with keys |
|
| 57 | - * data, filename, contenttype, cid |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $requestAttachments = array(); |
|
| 61 | - /** |
|
| 62 | - * @var array Each array element in the return is an associative array with keys |
|
| 63 | - * data, filename, contenttype, cid |
|
| 64 | - * @access private |
|
| 65 | - */ |
|
| 66 | - var $responseAttachments; |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $mimeContentType; |
|
| 55 | + /** |
|
| 56 | + * @var array Each array element in the return is an associative array with keys |
|
| 57 | + * data, filename, contenttype, cid |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $requestAttachments = array(); |
|
| 61 | + /** |
|
| 62 | + * @var array Each array element in the return is an associative array with keys |
|
| 63 | + * data, filename, contenttype, cid |
|
| 64 | + * @access private |
|
| 65 | + */ |
|
| 66 | + var $responseAttachments; |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $mimeContentType; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * adds a MIME attachment to the current request. |
|
| 75 | - * |
|
| 76 | - * If the $data parameter contains an empty string, this method will read |
|
| 77 | - * the contents of the file named by the $filename parameter. |
|
| 78 | - * |
|
| 79 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | - * |
|
| 81 | - * @param string $data The data of the attachment |
|
| 82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | - * @return string The content-id (cid) of the attachment |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 88 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | - if (! $cid) {
|
|
| 90 | - $cid = md5(uniqid(time())); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $info['data'] = $data; |
|
| 94 | - $info['filename'] = $filename; |
|
| 95 | - $info['contenttype'] = $contenttype; |
|
| 96 | - $info['cid'] = $cid; |
|
| 73 | + /** |
|
| 74 | + * adds a MIME attachment to the current request. |
|
| 75 | + * |
|
| 76 | + * If the $data parameter contains an empty string, this method will read |
|
| 77 | + * the contents of the file named by the $filename parameter. |
|
| 78 | + * |
|
| 79 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | + * |
|
| 81 | + * @param string $data The data of the attachment |
|
| 82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | + * @return string The content-id (cid) of the attachment |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | + if (! $cid) {
|
|
| 90 | + $cid = md5(uniqid(time())); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $info['data'] = $data; |
|
| 94 | + $info['filename'] = $filename; |
|
| 95 | + $info['contenttype'] = $contenttype; |
|
| 96 | + $info['cid'] = $cid; |
|
| 97 | 97 | |
| 98 | - $this->requestAttachments[] = $info; |
|
| 99 | - |
|
| 100 | - return $cid; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * clears the MIME attachments for the current request. |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - */ |
|
| 108 | - function clearAttachments() {
|
|
| 109 | - $this->requestAttachments = array(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * gets the MIME attachments from the current response. |
|
| 114 | - * |
|
| 115 | - * Each array element in the return is an associative array with keys |
|
| 116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | - * for addAttachment. |
|
| 118 | - * |
|
| 119 | - * @return array The attachments. |
|
| 120 | - * @access public |
|
| 121 | - */ |
|
| 122 | - function getAttachments() {
|
|
| 123 | - return $this->responseAttachments; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * gets the HTTP body for the current request. |
|
| 128 | - * |
|
| 129 | - * @param string $soapmsg The SOAP payload |
|
| 130 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | - * @access private |
|
| 132 | - */ |
|
| 133 | - function getHTTPBody($soapmsg) {
|
|
| 134 | - if (count($this->requestAttachments) > 0) {
|
|
| 135 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | - unset($params); |
|
| 138 | - |
|
| 139 | - $params['content_type'] = 'text/xml'; |
|
| 140 | - $params['encoding'] = '8bit'; |
|
| 141 | - $params['charset'] = $this->soap_defencoding; |
|
| 142 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 98 | + $this->requestAttachments[] = $info; |
|
| 99 | + |
|
| 100 | + return $cid; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * clears the MIME attachments for the current request. |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + */ |
|
| 108 | + function clearAttachments() {
|
|
| 109 | + $this->requestAttachments = array(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * gets the MIME attachments from the current response. |
|
| 114 | + * |
|
| 115 | + * Each array element in the return is an associative array with keys |
|
| 116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | + * for addAttachment. |
|
| 118 | + * |
|
| 119 | + * @return array The attachments. |
|
| 120 | + * @access public |
|
| 121 | + */ |
|
| 122 | + function getAttachments() {
|
|
| 123 | + return $this->responseAttachments; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * gets the HTTP body for the current request. |
|
| 128 | + * |
|
| 129 | + * @param string $soapmsg The SOAP payload |
|
| 130 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | + * @access private |
|
| 132 | + */ |
|
| 133 | + function getHTTPBody($soapmsg) {
|
|
| 134 | + if (count($this->requestAttachments) > 0) {
|
|
| 135 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | + unset($params); |
|
| 138 | + |
|
| 139 | + $params['content_type'] = 'text/xml'; |
|
| 140 | + $params['encoding'] = '8bit'; |
|
| 141 | + $params['charset'] = $this->soap_defencoding; |
|
| 142 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 143 | 143 | |
| 144 | - foreach ($this->requestAttachments as $att) {
|
|
| 145 | - unset($params); |
|
| 146 | - |
|
| 147 | - $params['content_type'] = $att['contenttype']; |
|
| 148 | - $params['encoding'] = 'base64'; |
|
| 149 | - $params['disposition'] = 'attachment'; |
|
| 150 | - $params['dfilename'] = $att['filename']; |
|
| 151 | - $params['cid'] = $att['cid']; |
|
| 152 | - |
|
| 153 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | - $data = fread($fd, filesize($att['filename'])); |
|
| 156 | - fclose($fd); |
|
| 157 | - } else {
|
|
| 158 | - $data = ''; |
|
| 159 | - } |
|
| 160 | - $mimeMessage->addSubpart($data, $params); |
|
| 161 | - } else {
|
|
| 162 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $output = $mimeMessage->encode(); |
|
| 167 | - $mimeHeaders = $output['headers']; |
|
| 144 | + foreach ($this->requestAttachments as $att) {
|
|
| 145 | + unset($params); |
|
| 146 | + |
|
| 147 | + $params['content_type'] = $att['contenttype']; |
|
| 148 | + $params['encoding'] = 'base64'; |
|
| 149 | + $params['disposition'] = 'attachment'; |
|
| 150 | + $params['dfilename'] = $att['filename']; |
|
| 151 | + $params['cid'] = $att['cid']; |
|
| 152 | + |
|
| 153 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | + $data = fread($fd, filesize($att['filename'])); |
|
| 156 | + fclose($fd); |
|
| 157 | + } else {
|
|
| 158 | + $data = ''; |
|
| 159 | + } |
|
| 160 | + $mimeMessage->addSubpart($data, $params); |
|
| 161 | + } else {
|
|
| 162 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $output = $mimeMessage->encode(); |
|
| 167 | + $mimeHeaders = $output['headers']; |
|
| 168 | 168 | |
| 169 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | - $this->debug("MIME header $k: $v");
|
|
| 171 | - if (strtolower($k) == 'content-type') {
|
|
| 172 | - // PHP header() seems to strip leading whitespace starting |
|
| 173 | - // the second line, so force everything to one line |
|
| 174 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | - } |
|
| 176 | - } |
|
| 169 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | + $this->debug("MIME header $k: $v");
|
|
| 171 | + if (strtolower($k) == 'content-type') {
|
|
| 172 | + // PHP header() seems to strip leading whitespace starting |
|
| 173 | + // the second line, so force everything to one line |
|
| 174 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - return $output['body']; |
|
| 179 | - } |
|
| 178 | + return $output['body']; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - return parent::getHTTPBody($soapmsg); |
|
| 182 | - } |
|
| 181 | + return parent::getHTTPBody($soapmsg); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * gets the HTTP content type for the current request. |
|
| 186 | - * |
|
| 187 | - * Note: getHTTPBody must be called before this. |
|
| 188 | - * |
|
| 189 | - * @return string the HTTP content type for the current request. |
|
| 190 | - * @access private |
|
| 191 | - */ |
|
| 192 | - function getHTTPContentType() {
|
|
| 193 | - if (count($this->requestAttachments) > 0) {
|
|
| 194 | - return $this->mimeContentType; |
|
| 195 | - } |
|
| 196 | - return parent::getHTTPContentType(); |
|
| 197 | - } |
|
| 184 | + /** |
|
| 185 | + * gets the HTTP content type for the current request. |
|
| 186 | + * |
|
| 187 | + * Note: getHTTPBody must be called before this. |
|
| 188 | + * |
|
| 189 | + * @return string the HTTP content type for the current request. |
|
| 190 | + * @access private |
|
| 191 | + */ |
|
| 192 | + function getHTTPContentType() {
|
|
| 193 | + if (count($this->requestAttachments) > 0) {
|
|
| 194 | + return $this->mimeContentType; |
|
| 195 | + } |
|
| 196 | + return parent::getHTTPContentType(); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * gets the HTTP content type charset for the current request. |
|
| 201 | - * returns false for non-text content types. |
|
| 202 | - * |
|
| 203 | - * Note: getHTTPBody must be called before this. |
|
| 204 | - * |
|
| 205 | - * @return string the HTTP content type charset for the current request. |
|
| 206 | - * @access private |
|
| 207 | - */ |
|
| 208 | - function getHTTPContentTypeCharset() {
|
|
| 209 | - if (count($this->requestAttachments) > 0) {
|
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - return parent::getHTTPContentTypeCharset(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * processes SOAP message returned from server |
|
| 217 | - * |
|
| 218 | - * @param array $headers The HTTP headers |
|
| 219 | - * @param string $data unprocessed response data from server |
|
| 220 | - * @return mixed value of the message, decoded into a PHP type |
|
| 221 | - * @access private |
|
| 222 | - */ |
|
| 199 | + /** |
|
| 200 | + * gets the HTTP content type charset for the current request. |
|
| 201 | + * returns false for non-text content types. |
|
| 202 | + * |
|
| 203 | + * Note: getHTTPBody must be called before this. |
|
| 204 | + * |
|
| 205 | + * @return string the HTTP content type charset for the current request. |
|
| 206 | + * @access private |
|
| 207 | + */ |
|
| 208 | + function getHTTPContentTypeCharset() {
|
|
| 209 | + if (count($this->requestAttachments) > 0) {
|
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + return parent::getHTTPContentTypeCharset(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * processes SOAP message returned from server |
|
| 217 | + * |
|
| 218 | + * @param array $headers The HTTP headers |
|
| 219 | + * @param string $data unprocessed response data from server |
|
| 220 | + * @return mixed value of the message, decoded into a PHP type |
|
| 221 | + * @access private |
|
| 222 | + */ |
|
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | - $this->responseAttachments = array(); |
|
| 226 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | - $this->debug('Decode multipart/related');
|
|
| 228 | - $input = ''; |
|
| 229 | - foreach ($headers as $k => $v) {
|
|
| 230 | - $input .= "$k: $v\r\n"; |
|
| 231 | - } |
|
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 233 | - $params['include_bodies'] = true; |
|
| 234 | - $params['decode_bodies'] = true; |
|
| 235 | - $params['decode_headers'] = true; |
|
| 224 | + $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | + $this->responseAttachments = array(); |
|
| 226 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | + $this->debug('Decode multipart/related');
|
|
| 228 | + $input = ''; |
|
| 229 | + foreach ($headers as $k => $v) {
|
|
| 230 | + $input .= "$k: $v\r\n"; |
|
| 231 | + } |
|
| 232 | + $params['input'] = $input . "\r\n" . $data; |
|
| 233 | + $params['include_bodies'] = true; |
|
| 234 | + $params['decode_bodies'] = true; |
|
| 235 | + $params['decode_headers'] = true; |
|
| 236 | 236 | |
| 237 | - $structure = Mail_mimeDecode::decode($params); |
|
| 238 | - |
|
| 239 | - foreach ($structure->parts as $part) {
|
|
| 240 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | - $root = $part->body; |
|
| 243 | - $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | - } else {
|
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | - $info['data'] = $part->body; |
|
| 247 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | - $info['cid'] = $part->headers['content-id']; |
|
| 250 | - $this->responseAttachments[] = $info; |
|
| 251 | - } |
|
| 252 | - } |
|
| 237 | + $structure = Mail_mimeDecode::decode($params); |
|
| 238 | + |
|
| 239 | + foreach ($structure->parts as $part) {
|
|
| 240 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | + $root = $part->body; |
|
| 243 | + $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | + } else {
|
|
| 245 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | + $info['data'] = $part->body; |
|
| 247 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | + $info['cid'] = $part->headers['content-id']; |
|
| 250 | + $this->responseAttachments[] = $info; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - if (isset($return)) {
|
|
| 255 | - $this->responseData = $root; |
|
| 256 | - return $return; |
|
| 257 | - } |
|
| 254 | + if (isset($return)) {
|
|
| 255 | + $this->responseData = $root; |
|
| 256 | + return $return; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $this->setError('No root part found in multipart/related content');
|
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - $this->debug('Not multipart/related');
|
|
| 263 | - return parent::parseResponse($headers, $data); |
|
| 264 | - } |
|
| 259 | + $this->setError('No root part found in multipart/related content');
|
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + $this->debug('Not multipart/related');
|
|
| 263 | + return parent::parseResponse($headers, $data); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /* |
| 268 | 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. |
| 269 | 269 | */ |
| 270 | 270 | if (!extension_loaded('soap')) {
|
| 271 | - class soapclientmime extends nusoap_client_mime {
|
|
| 272 | - } |
|
| 271 | + class soapclientmime extends nusoap_client_mime {
|
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,214 +282,214 @@ discard block |
||
| 282 | 282 | * @access public |
| 283 | 283 | */ |
| 284 | 284 | class nusoap_server_mime extends nusoap_server {
|
| 285 | - /** |
|
| 286 | - * @var array Each array element in the return is an associative array with keys |
|
| 287 | - * data, filename, contenttype, cid |
|
| 288 | - * @access private |
|
| 289 | - */ |
|
| 290 | - var $requestAttachments = array(); |
|
| 291 | - /** |
|
| 292 | - * @var array Each array element in the return is an associative array with keys |
|
| 293 | - * data, filename, contenttype, cid |
|
| 294 | - * @access private |
|
| 295 | - */ |
|
| 296 | - var $responseAttachments; |
|
| 297 | - /** |
|
| 298 | - * @var string |
|
| 299 | - * @access private |
|
| 300 | - */ |
|
| 301 | - var $mimeContentType; |
|
| 285 | + /** |
|
| 286 | + * @var array Each array element in the return is an associative array with keys |
|
| 287 | + * data, filename, contenttype, cid |
|
| 288 | + * @access private |
|
| 289 | + */ |
|
| 290 | + var $requestAttachments = array(); |
|
| 291 | + /** |
|
| 292 | + * @var array Each array element in the return is an associative array with keys |
|
| 293 | + * data, filename, contenttype, cid |
|
| 294 | + * @access private |
|
| 295 | + */ |
|
| 296 | + var $responseAttachments; |
|
| 297 | + /** |
|
| 298 | + * @var string |
|
| 299 | + * @access private |
|
| 300 | + */ |
|
| 301 | + var $mimeContentType; |
|
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * adds a MIME attachment to the current response. |
|
| 305 | - * |
|
| 306 | - * If the $data parameter contains an empty string, this method will read |
|
| 307 | - * the contents of the file named by the $filename parameter. |
|
| 308 | - * |
|
| 309 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | - * |
|
| 311 | - * @param string $data The data of the attachment |
|
| 312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | - * @return string The content-id (cid) of the attachment |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 318 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | - if (! $cid) {
|
|
| 320 | - $cid = md5(uniqid(time())); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $info['data'] = $data; |
|
| 324 | - $info['filename'] = $filename; |
|
| 325 | - $info['contenttype'] = $contenttype; |
|
| 326 | - $info['cid'] = $cid; |
|
| 303 | + /** |
|
| 304 | + * adds a MIME attachment to the current response. |
|
| 305 | + * |
|
| 306 | + * If the $data parameter contains an empty string, this method will read |
|
| 307 | + * the contents of the file named by the $filename parameter. |
|
| 308 | + * |
|
| 309 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | + * |
|
| 311 | + * @param string $data The data of the attachment |
|
| 312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | + * @return string The content-id (cid) of the attachment |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | + if (! $cid) {
|
|
| 320 | + $cid = md5(uniqid(time())); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $info['data'] = $data; |
|
| 324 | + $info['filename'] = $filename; |
|
| 325 | + $info['contenttype'] = $contenttype; |
|
| 326 | + $info['cid'] = $cid; |
|
| 327 | 327 | |
| 328 | - $this->responseAttachments[] = $info; |
|
| 329 | - |
|
| 330 | - return $cid; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * clears the MIME attachments for the current response. |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - */ |
|
| 338 | - function clearAttachments() {
|
|
| 339 | - $this->responseAttachments = array(); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * gets the MIME attachments from the current request. |
|
| 344 | - * |
|
| 345 | - * Each array element in the return is an associative array with keys |
|
| 346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | - * for addAttachment. |
|
| 348 | - * |
|
| 349 | - * @return array The attachments. |
|
| 350 | - * @access public |
|
| 351 | - */ |
|
| 352 | - function getAttachments() {
|
|
| 353 | - return $this->requestAttachments; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * gets the HTTP body for the current response. |
|
| 358 | - * |
|
| 359 | - * @param string $soapmsg The SOAP payload |
|
| 360 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | - * @access private |
|
| 362 | - */ |
|
| 363 | - function getHTTPBody($soapmsg) {
|
|
| 364 | - if (count($this->responseAttachments) > 0) {
|
|
| 365 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | - unset($params); |
|
| 368 | - |
|
| 369 | - $params['content_type'] = 'text/xml'; |
|
| 370 | - $params['encoding'] = '8bit'; |
|
| 371 | - $params['charset'] = $this->soap_defencoding; |
|
| 372 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 328 | + $this->responseAttachments[] = $info; |
|
| 329 | + |
|
| 330 | + return $cid; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * clears the MIME attachments for the current response. |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + */ |
|
| 338 | + function clearAttachments() {
|
|
| 339 | + $this->responseAttachments = array(); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * gets the MIME attachments from the current request. |
|
| 344 | + * |
|
| 345 | + * Each array element in the return is an associative array with keys |
|
| 346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | + * for addAttachment. |
|
| 348 | + * |
|
| 349 | + * @return array The attachments. |
|
| 350 | + * @access public |
|
| 351 | + */ |
|
| 352 | + function getAttachments() {
|
|
| 353 | + return $this->requestAttachments; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * gets the HTTP body for the current response. |
|
| 358 | + * |
|
| 359 | + * @param string $soapmsg The SOAP payload |
|
| 360 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | + * @access private |
|
| 362 | + */ |
|
| 363 | + function getHTTPBody($soapmsg) {
|
|
| 364 | + if (count($this->responseAttachments) > 0) {
|
|
| 365 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | + unset($params); |
|
| 368 | + |
|
| 369 | + $params['content_type'] = 'text/xml'; |
|
| 370 | + $params['encoding'] = '8bit'; |
|
| 371 | + $params['charset'] = $this->soap_defencoding; |
|
| 372 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 373 | 373 | |
| 374 | - foreach ($this->responseAttachments as $att) {
|
|
| 375 | - unset($params); |
|
| 376 | - |
|
| 377 | - $params['content_type'] = $att['contenttype']; |
|
| 378 | - $params['encoding'] = 'base64'; |
|
| 379 | - $params['disposition'] = 'attachment'; |
|
| 380 | - $params['dfilename'] = $att['filename']; |
|
| 381 | - $params['cid'] = $att['cid']; |
|
| 382 | - |
|
| 383 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | - $data = fread($fd, filesize($att['filename'])); |
|
| 386 | - fclose($fd); |
|
| 387 | - } else {
|
|
| 388 | - $data = ''; |
|
| 389 | - } |
|
| 390 | - $mimeMessage->addSubpart($data, $params); |
|
| 391 | - } else {
|
|
| 392 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $output = $mimeMessage->encode(); |
|
| 397 | - $mimeHeaders = $output['headers']; |
|
| 374 | + foreach ($this->responseAttachments as $att) {
|
|
| 375 | + unset($params); |
|
| 376 | + |
|
| 377 | + $params['content_type'] = $att['contenttype']; |
|
| 378 | + $params['encoding'] = 'base64'; |
|
| 379 | + $params['disposition'] = 'attachment'; |
|
| 380 | + $params['dfilename'] = $att['filename']; |
|
| 381 | + $params['cid'] = $att['cid']; |
|
| 382 | + |
|
| 383 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | + $data = fread($fd, filesize($att['filename'])); |
|
| 386 | + fclose($fd); |
|
| 387 | + } else {
|
|
| 388 | + $data = ''; |
|
| 389 | + } |
|
| 390 | + $mimeMessage->addSubpart($data, $params); |
|
| 391 | + } else {
|
|
| 392 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $output = $mimeMessage->encode(); |
|
| 397 | + $mimeHeaders = $output['headers']; |
|
| 398 | 398 | |
| 399 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | - $this->debug("MIME header $k: $v");
|
|
| 401 | - if (strtolower($k) == 'content-type') {
|
|
| 402 | - // PHP header() seems to strip leading whitespace starting |
|
| 403 | - // the second line, so force everything to one line |
|
| 404 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | - } |
|
| 406 | - } |
|
| 399 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | + $this->debug("MIME header $k: $v");
|
|
| 401 | + if (strtolower($k) == 'content-type') {
|
|
| 402 | + // PHP header() seems to strip leading whitespace starting |
|
| 403 | + // the second line, so force everything to one line |
|
| 404 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - return $output['body']; |
|
| 409 | - } |
|
| 408 | + return $output['body']; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - return parent::getHTTPBody($soapmsg); |
|
| 412 | - } |
|
| 411 | + return parent::getHTTPBody($soapmsg); |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - /** |
|
| 415 | - * gets the HTTP content type for the current response. |
|
| 416 | - * |
|
| 417 | - * Note: getHTTPBody must be called before this. |
|
| 418 | - * |
|
| 419 | - * @return string the HTTP content type for the current response. |
|
| 420 | - * @access private |
|
| 421 | - */ |
|
| 422 | - function getHTTPContentType() {
|
|
| 423 | - if (count($this->responseAttachments) > 0) {
|
|
| 424 | - return $this->mimeContentType; |
|
| 425 | - } |
|
| 426 | - return parent::getHTTPContentType(); |
|
| 427 | - } |
|
| 414 | + /** |
|
| 415 | + * gets the HTTP content type for the current response. |
|
| 416 | + * |
|
| 417 | + * Note: getHTTPBody must be called before this. |
|
| 418 | + * |
|
| 419 | + * @return string the HTTP content type for the current response. |
|
| 420 | + * @access private |
|
| 421 | + */ |
|
| 422 | + function getHTTPContentType() {
|
|
| 423 | + if (count($this->responseAttachments) > 0) {
|
|
| 424 | + return $this->mimeContentType; |
|
| 425 | + } |
|
| 426 | + return parent::getHTTPContentType(); |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * gets the HTTP content type charset for the current response. |
|
| 431 | - * returns false for non-text content types. |
|
| 432 | - * |
|
| 433 | - * Note: getHTTPBody must be called before this. |
|
| 434 | - * |
|
| 435 | - * @return string the HTTP content type charset for the current response. |
|
| 436 | - * @access private |
|
| 437 | - */ |
|
| 438 | - function getHTTPContentTypeCharset() {
|
|
| 439 | - if (count($this->responseAttachments) > 0) {
|
|
| 440 | - return false; |
|
| 441 | - } |
|
| 442 | - return parent::getHTTPContentTypeCharset(); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * processes SOAP message received from client |
|
| 447 | - * |
|
| 448 | - * @param array $headers The HTTP headers |
|
| 449 | - * @param string $data unprocessed request data from client |
|
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 451 | - * @access private |
|
| 452 | - */ |
|
| 429 | + /** |
|
| 430 | + * gets the HTTP content type charset for the current response. |
|
| 431 | + * returns false for non-text content types. |
|
| 432 | + * |
|
| 433 | + * Note: getHTTPBody must be called before this. |
|
| 434 | + * |
|
| 435 | + * @return string the HTTP content type charset for the current response. |
|
| 436 | + * @access private |
|
| 437 | + */ |
|
| 438 | + function getHTTPContentTypeCharset() {
|
|
| 439 | + if (count($this->responseAttachments) > 0) {
|
|
| 440 | + return false; |
|
| 441 | + } |
|
| 442 | + return parent::getHTTPContentTypeCharset(); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * processes SOAP message received from client |
|
| 447 | + * |
|
| 448 | + * @param array $headers The HTTP headers |
|
| 449 | + * @param string $data unprocessed request data from client |
|
| 450 | + * @return mixed value of the message, decoded into a PHP type |
|
| 451 | + * @access private |
|
| 452 | + */ |
|
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | - $this->requestAttachments = array(); |
|
| 456 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | - $this->debug('Decode multipart/related');
|
|
| 458 | - $input = ''; |
|
| 459 | - foreach ($headers as $k => $v) {
|
|
| 460 | - $input .= "$k: $v\r\n"; |
|
| 461 | - } |
|
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 463 | - $params['include_bodies'] = true; |
|
| 464 | - $params['decode_bodies'] = true; |
|
| 465 | - $params['decode_headers'] = true; |
|
| 454 | + $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | + $this->requestAttachments = array(); |
|
| 456 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | + $this->debug('Decode multipart/related');
|
|
| 458 | + $input = ''; |
|
| 459 | + foreach ($headers as $k => $v) {
|
|
| 460 | + $input .= "$k: $v\r\n"; |
|
| 461 | + } |
|
| 462 | + $params['input'] = $input . "\r\n" . $data; |
|
| 463 | + $params['include_bodies'] = true; |
|
| 464 | + $params['decode_bodies'] = true; |
|
| 465 | + $params['decode_headers'] = true; |
|
| 466 | 466 | |
| 467 | - $structure = Mail_mimeDecode::decode($params); |
|
| 468 | - |
|
| 469 | - foreach ($structure->parts as $part) {
|
|
| 470 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | - $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | - $info['data'] = $part->body; |
|
| 476 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | - $info['cid'] = $part->headers['content-id']; |
|
| 479 | - $this->requestAttachments[] = $info; |
|
| 480 | - } |
|
| 481 | - } |
|
| 467 | + $structure = Mail_mimeDecode::decode($params); |
|
| 468 | + |
|
| 469 | + foreach ($structure->parts as $part) {
|
|
| 470 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | + $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | + $info['data'] = $part->body; |
|
| 476 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | + $info['cid'] = $part->headers['content-id']; |
|
| 479 | + $this->requestAttachments[] = $info; |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - if (isset($return)) {
|
|
| 484 | - return $return; |
|
| 485 | - } |
|
| 483 | + if (isset($return)) {
|
|
| 484 | + return $return; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - $this->setError('No root part found in multipart/related content');
|
|
| 488 | - return; |
|
| 489 | - } |
|
| 490 | - $this->debug('Not multipart/related');
|
|
| 491 | - return parent::parseRequest($headers, $data); |
|
| 492 | - } |
|
| 487 | + $this->setError('No root part found in multipart/related content');
|
|
| 488 | + return; |
|
| 489 | + } |
|
| 490 | + $this->debug('Not multipart/related');
|
|
| 491 | + return parent::parseRequest($headers, $data); |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /* |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | */ |
| 88 | 88 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 89 | - if (! $cid) {
|
|
| 89 | + if (!$cid) {
|
|
| 90 | 90 | $cid = md5(uniqid(time())); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @access private |
| 222 | 222 | */ |
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 224 | + $this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 225 | 225 | $this->responseAttachments = array(); |
| 226 | 226 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 227 | 227 | $this->debug('Decode multipart/related');
|
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | foreach ($headers as $k => $v) {
|
| 230 | 230 | $input .= "$k: $v\r\n"; |
| 231 | 231 | } |
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 232 | + $params['input'] = $input."\r\n".$data; |
|
| 233 | 233 | $params['include_bodies'] = true; |
| 234 | 234 | $params['decode_bodies'] = true; |
| 235 | 235 | $params['decode_headers'] = true; |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | foreach ($structure->parts as $part) {
|
| 240 | 240 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 241 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 242 | 242 | $root = $part->body; |
| 243 | 243 | $return = parent::parseResponse($part->headers, $part->body); |
| 244 | 244 | } else {
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 245 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 246 | 246 | $info['data'] = $part->body; |
| 247 | 247 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 248 | 248 | $info['contenttype'] = $part->headers['content-type']; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @access public |
| 317 | 317 | */ |
| 318 | 318 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 319 | - if (! $cid) {
|
|
| 319 | + if (!$cid) {
|
|
| 320 | 320 | $cid = md5(uniqid(time())); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 454 | + $this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 455 | 455 | $this->requestAttachments = array(); |
| 456 | 456 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 457 | 457 | $this->debug('Decode multipart/related');
|
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | foreach ($headers as $k => $v) {
|
| 460 | 460 | $input .= "$k: $v\r\n"; |
| 461 | 461 | } |
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 462 | + $params['input'] = $input."\r\n".$data; |
|
| 463 | 463 | $params['include_bodies'] = true; |
| 464 | 464 | $params['decode_bodies'] = true; |
| 465 | 465 | $params['decode_headers'] = true; |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | foreach ($structure->parts as $part) {
|
| 470 | 470 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 471 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 472 | 472 | $return = parent::parseRequest($part->headers, $part->body); |
| 473 | 473 | } else {
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 474 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 475 | 475 | $info['data'] = $part->body; |
| 476 | 476 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 477 | 477 | $info['contenttype'] = $part->headers['content-type']; |
@@ -208,6 +208,8 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | /** |
| 210 | 210 | * Gives a list of people online now (and in the last $valid minutes) |
| 211 | + * @param integer $from |
|
| 212 | + * @param integer $time_limit |
|
| 211 | 213 | * @return array For each line, a list of user IDs and login dates, or FALSE on error or empty results |
| 212 | 214 | */ |
| 213 | 215 | function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false) |
@@ -424,6 +426,9 @@ discard block |
||
| 424 | 426 | } |
| 425 | 427 | } |
| 426 | 428 | |
| 429 | +/** |
|
| 430 | + * @param integer $uid |
|
| 431 | + */ |
|
| 427 | 432 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 428 | 433 | { |
| 429 | 434 | if (empty($coursecode)) { |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function LoginDelete($user_id) |
| 168 | 168 | { |
| 169 | - $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 169 | + $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 170 | 170 | $user_id = intval($user_id); |
| 171 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 172 | - Database::query($query); |
|
| 171 | + $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 172 | + Database::query($query); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,17 +178,17 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | function user_is_online($user_id) |
| 180 | 180 | { |
| 181 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 182 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 181 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 182 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 183 | 183 | |
| 184 | - $access_url_id = api_get_current_access_url_id(); |
|
| 185 | - $time_limit = api_get_setting('time_limit_whosonline'); |
|
| 184 | + $access_url_id = api_get_current_access_url_id(); |
|
| 185 | + $time_limit = api_get_setting('time_limit_whosonline'); |
|
| 186 | 186 | |
| 187 | 187 | $online_time = time() - $time_limit*60; |
| 188 | 188 | $limit_date = api_get_utc_datetime($online_time); |
| 189 | 189 | $user_id = intval($user_id); |
| 190 | 190 | |
| 191 | - $query = " SELECT login_user_id,login_date |
|
| 191 | + $query = " SELECT login_user_id,login_date |
|
| 192 | 192 | FROM $track_online_table track |
| 193 | 193 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 194 | 194 | WHERE |
@@ -197,13 +197,13 @@ discard block |
||
| 197 | 197 | u.id = $user_id |
| 198 | 198 | LIMIT 1 "; |
| 199 | 199 | |
| 200 | - $result = Database::query($query); |
|
| 201 | - if (Database::num_rows($result)) { |
|
| 200 | + $result = Database::query($query); |
|
| 201 | + if (Database::num_rows($result)) { |
|
| 202 | 202 | |
| 203 | - return true; |
|
| 204 | - } |
|
| 203 | + return true; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - return false; |
|
| 206 | + return false; |
|
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | /** |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $online_time = time() - $time_limit * 60; |
| 241 | 241 | $current_date = api_get_utc_datetime($online_time); |
| 242 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 243 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 244 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 242 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 243 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 244 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 245 | 245 | |
| 246 | - if ($friends) { |
|
| 247 | - // who friends from social network is online |
|
| 248 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
| 246 | + if ($friends) { |
|
| 247 | + // who friends from social network is online |
|
| 248 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
| 249 | 249 | FROM $track_online_table INNER JOIN $friend_user_table |
| 250 | 250 | ON (friend_user_id = login_user_id) |
| 251 | 251 | WHERE |
@@ -255,21 +255,21 @@ discard block |
||
| 255 | 255 | user_id = '".api_get_user_id()."' |
| 256 | 256 | ORDER BY $column $direction |
| 257 | 257 | LIMIT $from, $number_of_items"; |
| 258 | - } else { |
|
| 259 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
| 258 | + } else { |
|
| 259 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
| 260 | 260 | FROM ".$track_online_table ." e |
| 261 | 261 | INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
| 262 | 262 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 263 | 263 | ORDER BY $column $direction |
| 264 | 264 | LIMIT $from, $number_of_items"; |
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (api_get_multiple_access_url()) { |
|
| 268 | - $access_url_id = api_get_current_access_url_id(); |
|
| 269 | - if ($access_url_id != -1) { |
|
| 270 | - if ($friends) { |
|
| 271 | - // friends from social network is online |
|
| 272 | - $query = "SELECT distinct login_user_id, login_date |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (api_get_multiple_access_url()) { |
|
| 268 | + $access_url_id = api_get_current_access_url_id(); |
|
| 269 | + if ($access_url_id != -1) { |
|
| 270 | + if ($friends) { |
|
| 271 | + // friends from social network is online |
|
| 272 | + $query = "SELECT distinct login_user_id, login_date |
|
| 273 | 273 | FROM $track_online_table track INNER JOIN $friend_user_table |
| 274 | 274 | ON (friend_user_id = login_user_id) |
| 275 | 275 | WHERE track.access_url_id = $access_url_id AND |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | relation_type='".USER_RELATION_TYPE_FRIEND."' |
| 279 | 279 | ORDER BY $column $direction |
| 280 | 280 | LIMIT $from, $number_of_items"; |
| 281 | - } else { |
|
| 282 | - // all users online |
|
| 283 | - $query = "SELECT login_user_id, login_date |
|
| 281 | + } else { |
|
| 282 | + // all users online |
|
| 283 | + $query = "SELECT login_user_id, login_date |
|
| 284 | 284 | FROM ".$track_online_table ." track |
| 285 | 285 | INNER JOIN ".$table_user ." u |
| 286 | 286 | ON (u.id=track.login_user_id) |
@@ -288,26 +288,26 @@ discard block |
||
| 288 | 288 | login_date >= '".$current_date."' |
| 289 | 289 | ORDER BY $column $direction |
| 290 | 290 | LIMIT $from, $number_of_items"; |
| 291 | - } |
|
| 292 | - } |
|
| 293 | - } |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - //This query will show all registered users. Only for dev purposes. |
|
| 296 | - /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 295 | + //This query will show all registered users. Only for dev purposes. |
|
| 296 | + /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 297 | 297 | GROUP by u.id |
| 298 | 298 | ORDER BY $column $direction |
| 299 | 299 | LIMIT $from, $number_of_items";*/ |
| 300 | 300 | |
| 301 | - $result = Database::query($query); |
|
| 302 | - if ($result) { |
|
| 303 | - $users_online = array(); |
|
| 304 | - while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 301 | + $result = Database::query($query); |
|
| 302 | + if ($result) { |
|
| 303 | + $users_online = array(); |
|
| 304 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 305 | 305 | $users_online[] = $login_user_id; |
| 306 | - } |
|
| 307 | - return $users_online; |
|
| 308 | - } else { |
|
| 309 | - return false; |
|
| 310 | - } |
|
| 306 | + } |
|
| 307 | + return $users_online; |
|
| 308 | + } else { |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | function who_is_online_count($time_limit = null, $friends = false) |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | } else { |
| 318 | 318 | $time_limit = intval($time_limit); |
| 319 | 319 | } |
| 320 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | - $online_time = time() - $time_limit * 60; |
|
| 324 | - $current_date = api_get_utc_datetime($online_time); |
|
| 325 | - |
|
| 326 | - if ($friends) { |
|
| 327 | - // who friends from social network is online |
|
| 328 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 320 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 321 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 322 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 323 | + $online_time = time() - $time_limit * 60; |
|
| 324 | + $current_date = api_get_utc_datetime($online_time); |
|
| 325 | + |
|
| 326 | + if ($friends) { |
|
| 327 | + // who friends from social network is online |
|
| 328 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 329 | 329 | FROM $track_online_table INNER JOIN $friend_user_table |
| 330 | 330 | ON (friend_user_id = login_user_id) |
| 331 | 331 | WHERE |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | friend_user_id <> '".api_get_user_id()."' AND |
| 334 | 334 | relation_type='".USER_RELATION_TYPE_FRIEND."' AND |
| 335 | 335 | user_id = '".api_get_user_id()."' "; |
| 336 | - } else { |
|
| 337 | - // All users online |
|
| 338 | - $query = "SELECT count(login_id) as count |
|
| 336 | + } else { |
|
| 337 | + // All users online |
|
| 338 | + $query = "SELECT count(login_id) as count |
|
| 339 | 339 | FROM $track_online_table track INNER JOIN $table_user u |
| 340 | 340 | ON (u.id=track.login_user_id) |
| 341 | 341 | WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date' "; |
| 342 | - } |
|
| 343 | - |
|
| 344 | - if (api_get_multiple_access_url()) { |
|
| 345 | - $access_url_id = api_get_current_access_url_id(); |
|
| 346 | - if ($access_url_id != -1) { |
|
| 347 | - if ($friends) { |
|
| 348 | - // friends from social network is online |
|
| 349 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + if (api_get_multiple_access_url()) { |
|
| 345 | + $access_url_id = api_get_current_access_url_id(); |
|
| 346 | + if ($access_url_id != -1) { |
|
| 347 | + if ($friends) { |
|
| 348 | + // friends from social network is online |
|
| 349 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 350 | 350 | FROM $track_online_table track |
| 351 | 351 | INNER JOIN $friend_user_table ON (friend_user_id = login_user_id) |
| 352 | 352 | WHERE |
@@ -354,29 +354,29 @@ discard block |
||
| 354 | 354 | login_date >= '".$current_date."' AND |
| 355 | 355 | friend_user_id <> '".api_get_user_id()."' AND |
| 356 | 356 | relation_type='".USER_RELATION_TYPE_FRIEND."' "; |
| 357 | - } else { |
|
| 358 | - // all users online |
|
| 359 | - $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 357 | + } else { |
|
| 358 | + // all users online |
|
| 359 | + $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 360 | 360 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 361 | 361 | WHERE |
| 362 | 362 | u.status != ".ANONYMOUS." AND |
| 363 | 363 | track.access_url_id = $access_url_id AND |
| 364 | 364 | login_date >= '$current_date' "; |
| 365 | - } |
|
| 366 | - } |
|
| 367 | - } |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | // Dev purposes show all users online |
| 370 | 370 | /*$table_user = Database::get_main_table(TABLE_MAIN_USER); |
| 371 | 371 | $query = "SELECT count(*) as count FROM ".$table_user;*/ |
| 372 | 372 | |
| 373 | - $result = Database::query($query); |
|
| 374 | - if (Database::num_rows($result) > 0) { |
|
| 375 | - $row = Database::fetch_array($result); |
|
| 376 | - return $row['count']; |
|
| 377 | - } else { |
|
| 378 | - return false; |
|
| 379 | - } |
|
| 373 | + $result = Database::query($query); |
|
| 374 | + if (Database::num_rows($result) > 0) { |
|
| 375 | + $row = Database::fetch_array($result); |
|
| 376 | + return $row['count']; |
|
| 377 | + } else { |
|
| 378 | + return false; |
|
| 379 | + } |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code) |
| 391 | 391 | { |
| 392 | - if (empty($course_code)) return false; |
|
| 392 | + if (empty($course_code)) return false; |
|
| 393 | 393 | |
| 394 | 394 | if (empty($time_limit)) { |
| 395 | 395 | $time_limit = api_get_setting('time_limit_whosonline'); |
@@ -401,56 +401,56 @@ discard block |
||
| 401 | 401 | $current_date = api_get_utc_datetime($online_time); |
| 402 | 402 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 403 | 403 | $course_code = Database::escape_string($course_code); |
| 404 | - $courseInfo = api_get_course_info($course_code); |
|
| 405 | - $courseId = $courseInfo['real_id']; |
|
| 404 | + $courseInfo = api_get_course_info($course_code); |
|
| 405 | + $courseId = $courseInfo['real_id']; |
|
| 406 | 406 | |
| 407 | 407 | $from = intval($from); |
| 408 | 408 | $number_of_items = intval($number_of_items); |
| 409 | 409 | |
| 410 | - $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 410 | + $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 411 | 411 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' |
| 412 | 412 | LIMIT $from, $number_of_items "; |
| 413 | 413 | |
| 414 | - $result = Database::query($query); |
|
| 415 | - if ($result) { |
|
| 416 | - $users_online = array(); |
|
| 414 | + $result = Database::query($query); |
|
| 415 | + if ($result) { |
|
| 416 | + $users_online = array(); |
|
| 417 | 417 | |
| 418 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 418 | + while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 419 | 419 | $users_online[] = $login_user_id; |
| 420 | - } |
|
| 421 | - return $users_online; |
|
| 422 | - } else { |
|
| 423 | - return false; |
|
| 424 | - } |
|
| 420 | + } |
|
| 421 | + return $users_online; |
|
| 422 | + } else { |
|
| 423 | + return false; |
|
| 424 | + } |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 428 | 428 | { |
| 429 | - if (empty($coursecode)) { |
|
| 430 | - return false; |
|
| 431 | - } |
|
| 432 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 433 | - $coursecode = Database::escape_string($coursecode); |
|
| 434 | - $time_limit = Database::escape_string($time_limit); |
|
| 429 | + if (empty($coursecode)) { |
|
| 430 | + return false; |
|
| 431 | + } |
|
| 432 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 433 | + $coursecode = Database::escape_string($coursecode); |
|
| 434 | + $time_limit = Database::escape_string($time_limit); |
|
| 435 | 435 | |
| 436 | 436 | $online_time = time() - $time_limit * 60; |
| 437 | 437 | $current_date = api_get_utc_datetime($online_time); |
| 438 | - $courseId = api_get_course_int_id($coursecode); |
|
| 438 | + $courseId = api_get_course_int_id($coursecode); |
|
| 439 | 439 | |
| 440 | - if (empty($courseId)) { |
|
| 441 | - return false; |
|
| 442 | - } |
|
| 440 | + if (empty($courseId)) { |
|
| 441 | + return false; |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - $query = "SELECT count(login_user_id) as count |
|
| 444 | + $query = "SELECT count(login_user_id) as count |
|
| 445 | 445 | FROM $track_online_table |
| 446 | 446 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' "; |
| 447 | - $result = Database::query($query); |
|
| 448 | - if (Database::num_rows($result) > 0) { |
|
| 449 | - $row = Database::fetch_array($result); |
|
| 450 | - return $row['count']; |
|
| 451 | - } else { |
|
| 452 | - return false; |
|
| 453 | - } |
|
| 447 | + $result = Database::query($query); |
|
| 448 | + if (Database::num_rows($result) > 0) { |
|
| 449 | + $row = Database::fetch_array($result); |
|
| 450 | + return $row['count']; |
|
| 451 | + } else { |
|
| 452 | + return false; |
|
| 453 | + } |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -460,17 +460,17 @@ discard block |
||
| 460 | 460 | * @deprecated user api_get_user_info($user_id) |
| 461 | 461 | */ |
| 462 | 462 | function GetFullUserName($uid) { |
| 463 | - $uid = (int) $uid; |
|
| 464 | - $uid = intval($uid); |
|
| 465 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 466 | - $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
| 467 | - $result = @Database::query($query); |
|
| 468 | - if (count($result)>0) { |
|
| 469 | - while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 470 | - $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
| 471 | - return $str; |
|
| 472 | - } |
|
| 473 | - } |
|
| 463 | + $uid = (int) $uid; |
|
| 464 | + $uid = intval($uid); |
|
| 465 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 466 | + $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
| 467 | + $result = @Database::query($query); |
|
| 468 | + if (count($result)>0) { |
|
| 469 | + while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 470 | + $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
| 471 | + return $str; |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -482,44 +482,44 @@ discard block |
||
| 482 | 482 | $_cid = api_get_course_id(); |
| 483 | 483 | $_user = api_get_user_info(); |
| 484 | 484 | |
| 485 | - if (!$_user['user_id']) { |
|
| 486 | - return (false); |
|
| 487 | - } |
|
| 485 | + if (!$_user['user_id']) { |
|
| 486 | + return (false); |
|
| 487 | + } |
|
| 488 | 488 | $userId = intval($_user['user_id']); |
| 489 | - $track_user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 490 | - $sql="SELECT chatcall_user_id, chatcall_date FROM $track_user_table |
|
| 489 | + $track_user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 490 | + $sql="SELECT chatcall_user_id, chatcall_date FROM $track_user_table |
|
| 491 | 491 | WHERE ( id = $userId )"; |
| 492 | - $result=Database::query($sql); |
|
| 493 | - $row=Database::fetch_array($result); |
|
| 494 | - |
|
| 495 | - $login_date=$row['chatcall_date']; |
|
| 496 | - $hour = substr($login_date,11,2); |
|
| 497 | - $minute = substr($login_date,14,2); |
|
| 498 | - $second = substr($login_date,17,2); |
|
| 499 | - $month = substr($login_date,5,2); |
|
| 500 | - $day = substr($login_date,8,2); |
|
| 501 | - $year = substr($login_date,0,4); |
|
| 502 | - $calltime = mktime($hour,$minute,$second,$month,$day,$year); |
|
| 503 | - |
|
| 504 | - $time = api_get_utc_datetime(); |
|
| 505 | - $minute_passed=5; //within this limit, the chat call request is valid |
|
| 506 | - $limittime = mktime(date("H"),date("i")-$minute_passed,date("s"),date("m"),date("d"),date("Y")); |
|
| 507 | - |
|
| 508 | - if (($row['chatcall_user_id']) and ($calltime>$limittime)) { |
|
| 509 | - $webpath=api_get_path(WEB_CODE_PATH); |
|
| 510 | - $message=get_lang('YouWereCalled').' : '.GetFullUserName($row['chatcall_user_id'],'').'<br>'.get_lang('DoYouAccept') |
|
| 511 | - ."<p>" |
|
| 512 | - ."<a href=\"".$webpath."chat/chat.php?cidReq=".$_cid."&origin=whoisonlinejoin\">" |
|
| 513 | - . get_lang("Yes") |
|
| 514 | - ."</a>" |
|
| 515 | - ." | " |
|
| 516 | - ."<a href=\"".api_get_path(WEB_PATH)."webchatdeny.php\">" |
|
| 517 | - . get_lang("No") |
|
| 518 | - ."</a>" |
|
| 519 | - ."</p>"; |
|
| 520 | - |
|
| 521 | - return($message); |
|
| 522 | - } else { |
|
| 523 | - return false; |
|
| 524 | - } |
|
| 492 | + $result=Database::query($sql); |
|
| 493 | + $row=Database::fetch_array($result); |
|
| 494 | + |
|
| 495 | + $login_date=$row['chatcall_date']; |
|
| 496 | + $hour = substr($login_date,11,2); |
|
| 497 | + $minute = substr($login_date,14,2); |
|
| 498 | + $second = substr($login_date,17,2); |
|
| 499 | + $month = substr($login_date,5,2); |
|
| 500 | + $day = substr($login_date,8,2); |
|
| 501 | + $year = substr($login_date,0,4); |
|
| 502 | + $calltime = mktime($hour,$minute,$second,$month,$day,$year); |
|
| 503 | + |
|
| 504 | + $time = api_get_utc_datetime(); |
|
| 505 | + $minute_passed=5; //within this limit, the chat call request is valid |
|
| 506 | + $limittime = mktime(date("H"),date("i")-$minute_passed,date("s"),date("m"),date("d"),date("Y")); |
|
| 507 | + |
|
| 508 | + if (($row['chatcall_user_id']) and ($calltime>$limittime)) { |
|
| 509 | + $webpath=api_get_path(WEB_CODE_PATH); |
|
| 510 | + $message=get_lang('YouWereCalled').' : '.GetFullUserName($row['chatcall_user_id'],'').'<br>'.get_lang('DoYouAccept') |
|
| 511 | + ."<p>" |
|
| 512 | + ."<a href=\"".$webpath."chat/chat.php?cidReq=".$_cid."&origin=whoisonlinejoin\">" |
|
| 513 | + . get_lang("Yes") |
|
| 514 | + ."</a>" |
|
| 515 | + ." | " |
|
| 516 | + ."<a href=\"".api_get_path(WEB_PATH)."webchatdeny.php\">" |
|
| 517 | + . get_lang("No") |
|
| 518 | + ."</a>" |
|
| 519 | + ."</p>"; |
|
| 520 | + |
|
| 521 | + return($message); |
|
| 522 | + } else { |
|
| 523 | + return false; |
|
| 524 | + } |
|
| 525 | 525 | } |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $login_date = api_get_utc_datetime(); |
| 34 | 34 | $access_url_id = 1; |
| 35 | - if (api_get_multiple_access_url() && api_get_current_access_url_id()!=-1) { |
|
| 35 | + if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) { |
|
| 36 | 36 | $access_url_id = api_get_current_access_url_id(); |
| 37 | 37 | } |
| 38 | 38 | $session_id = api_get_session_id(); |
| 39 | 39 | // if the $_course array exists this means we are in a course and we have to store this in the who's online table also |
| 40 | 40 | // to have the x users in this course feature working |
| 41 | - if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) { |
|
| 42 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 41 | + if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) { |
|
| 42 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 43 | 43 | VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; |
| 44 | 44 | } else { |
| 45 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 45 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 46 | 46 | VALUES ($uid,$uid,'$login_date','$user_ip', 0, '$session_id', '$access_url_id')"; |
| 47 | 47 | } |
| 48 | 48 | Database::query($query); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $isFirstLogin = Session::read('first_user_login'); |
| 64 | 64 | if (empty($isFirstLogin)) { |
| 65 | 65 | $sql = "SELECT login_id FROM $table |
| 66 | - WHERE login_user_id = " . $userId . " LIMIT 1"; |
|
| 66 | + WHERE login_user_id = ".$userId." LIMIT 1"; |
|
| 67 | 67 | |
| 68 | 68 | $result = Database::query($sql); |
| 69 | 69 | $loginData = array(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | ORDER BY login_date DESC |
| 118 | 118 | LIMIT 0,1"; |
| 119 | 119 | $q_last_connection = Database::query($sql); |
| 120 | - if (Database::num_rows($q_last_connection)>0) { |
|
| 121 | - $i_id_last_connection = Database::result($q_last_connection,0,"login_id"); |
|
| 120 | + if (Database::num_rows($q_last_connection) > 0) { |
|
| 121 | + $i_id_last_connection = Database::result($q_last_connection, 0, "login_id"); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | if (!isset($_SESSION['login_as'])) { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php'; |
|
| 152 | + require_once api_get_path(SYS_PATH).'main/chat/chat_functions.lib.php'; |
|
| 153 | 153 | exit_of_chat($user_id); |
| 154 | 154 | session_regenerate_id(); |
| 155 | 155 | Session::destroy(); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 170 | 170 | $user_id = intval($user_id); |
| 171 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 171 | + $query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id"; |
|
| 172 | 172 | Database::query($query); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $access_url_id = api_get_current_access_url_id(); |
| 185 | 185 | $time_limit = api_get_setting('time_limit_whosonline'); |
| 186 | 186 | |
| 187 | - $online_time = time() - $time_limit*60; |
|
| 187 | + $online_time = time() - $time_limit * 60; |
|
| 188 | 188 | $limit_date = api_get_utc_datetime($online_time); |
| 189 | 189 | $user_id = intval($user_id); |
| 190 | 190 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $current_date = api_get_utc_datetime($online_time); |
| 242 | 242 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 243 | 243 | $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
| 244 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 244 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 245 | 245 | |
| 246 | 246 | if ($friends) { |
| 247 | 247 | // who friends from social network is online |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | LIMIT $from, $number_of_items"; |
| 258 | 258 | } else { |
| 259 | 259 | $query = "SELECT DISTINCT login_user_id, login_date |
| 260 | - FROM ".$track_online_table ." e |
|
| 261 | - INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
|
| 260 | + FROM ".$track_online_table." e |
|
| 261 | + INNER JOIN ".$table_user." u ON (u.id = e.login_user_id) |
|
| 262 | 262 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 263 | 263 | ORDER BY $column $direction |
| 264 | 264 | LIMIT $from, $number_of_items"; |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | } else { |
| 282 | 282 | // all users online |
| 283 | 283 | $query = "SELECT login_user_id, login_date |
| 284 | - FROM ".$track_online_table ." track |
|
| 285 | - INNER JOIN ".$table_user ." u |
|
| 284 | + FROM ".$track_online_table." track |
|
| 285 | + INNER JOIN ".$table_user." u |
|
| 286 | 286 | ON (u.id=track.login_user_id) |
| 287 | 287 | WHERE u.status != ".ANONYMOUS." AND track.access_url_id = $access_url_id AND |
| 288 | 288 | login_date >= '".$current_date."' |
@@ -397,10 +397,10 @@ discard block |
||
| 397 | 397 | $time_limit = intval($time_limit); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $online_time = time() - $time_limit*60; |
|
| 400 | + $online_time = time() - $time_limit * 60; |
|
| 401 | 401 | $current_date = api_get_utc_datetime($online_time); |
| 402 | 402 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 403 | - $course_code = Database::escape_string($course_code); |
|
| 403 | + $course_code = Database::escape_string($course_code); |
|
| 404 | 404 | $courseInfo = api_get_course_info($course_code); |
| 405 | 405 | $courseId = $courseInfo['real_id']; |
| 406 | 406 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | if ($result) { |
| 416 | 416 | $users_online = array(); |
| 417 | 417 | |
| 418 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 418 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 419 | 419 | $users_online[] = $login_user_id; |
| 420 | 420 | } |
| 421 | 421 | return $users_online; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | -function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
|
| 427 | +function who_is_online_in_this_course_count($uid, $time_limit, $coursecode = null) |
|
| 428 | 428 | { |
| 429 | 429 | if (empty($coursecode)) { |
| 430 | 430 | return false; |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
| 466 | 466 | $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
| 467 | 467 | $result = @Database::query($query); |
| 468 | - if (count($result)>0) { |
|
| 469 | - while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 468 | + if (count($result) > 0) { |
|
| 469 | + while (list($firstname, $lastname) = Database::fetch_array($result)) { |
|
| 470 | 470 | $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
| 471 | 471 | return $str; |
| 472 | 472 | } |
@@ -487,27 +487,27 @@ discard block |
||
| 487 | 487 | } |
| 488 | 488 | $userId = intval($_user['user_id']); |
| 489 | 489 | $track_user_table = Database::get_main_table(TABLE_MAIN_USER); |
| 490 | - $sql="SELECT chatcall_user_id, chatcall_date FROM $track_user_table |
|
| 490 | + $sql = "SELECT chatcall_user_id, chatcall_date FROM $track_user_table |
|
| 491 | 491 | WHERE ( id = $userId )"; |
| 492 | - $result=Database::query($sql); |
|
| 493 | - $row=Database::fetch_array($result); |
|
| 494 | - |
|
| 495 | - $login_date=$row['chatcall_date']; |
|
| 496 | - $hour = substr($login_date,11,2); |
|
| 497 | - $minute = substr($login_date,14,2); |
|
| 498 | - $second = substr($login_date,17,2); |
|
| 499 | - $month = substr($login_date,5,2); |
|
| 500 | - $day = substr($login_date,8,2); |
|
| 501 | - $year = substr($login_date,0,4); |
|
| 502 | - $calltime = mktime($hour,$minute,$second,$month,$day,$year); |
|
| 492 | + $result = Database::query($sql); |
|
| 493 | + $row = Database::fetch_array($result); |
|
| 494 | + |
|
| 495 | + $login_date = $row['chatcall_date']; |
|
| 496 | + $hour = substr($login_date, 11, 2); |
|
| 497 | + $minute = substr($login_date, 14, 2); |
|
| 498 | + $second = substr($login_date, 17, 2); |
|
| 499 | + $month = substr($login_date, 5, 2); |
|
| 500 | + $day = substr($login_date, 8, 2); |
|
| 501 | + $year = substr($login_date, 0, 4); |
|
| 502 | + $calltime = mktime($hour, $minute, $second, $month, $day, $year); |
|
| 503 | 503 | |
| 504 | 504 | $time = api_get_utc_datetime(); |
| 505 | - $minute_passed=5; //within this limit, the chat call request is valid |
|
| 506 | - $limittime = mktime(date("H"),date("i")-$minute_passed,date("s"),date("m"),date("d"),date("Y")); |
|
| 505 | + $minute_passed = 5; //within this limit, the chat call request is valid |
|
| 506 | + $limittime = mktime(date("H"), date("i") - $minute_passed, date("s"), date("m"), date("d"), date("Y")); |
|
| 507 | 507 | |
| 508 | - if (($row['chatcall_user_id']) and ($calltime>$limittime)) { |
|
| 509 | - $webpath=api_get_path(WEB_CODE_PATH); |
|
| 510 | - $message=get_lang('YouWereCalled').' : '.GetFullUserName($row['chatcall_user_id'],'').'<br>'.get_lang('DoYouAccept') |
|
| 508 | + if (($row['chatcall_user_id']) and ($calltime > $limittime)) { |
|
| 509 | + $webpath = api_get_path(WEB_CODE_PATH); |
|
| 510 | + $message = get_lang('YouWereCalled').' : '.GetFullUserName($row['chatcall_user_id'], '').'<br>'.get_lang('DoYouAccept') |
|
| 511 | 511 | ."<p>" |
| 512 | 512 | ."<a href=\"".$webpath."chat/chat.php?cidReq=".$_cid."&origin=whoisonlinejoin\">" |
| 513 | 513 | . get_lang("Yes") |
@@ -389,7 +389,9 @@ |
||
| 389 | 389 | */ |
| 390 | 390 | function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code) |
| 391 | 391 | { |
| 392 | - if (empty($course_code)) return false; |
|
| 392 | + if (empty($course_code)) { |
|
| 393 | + return false; |
|
| 394 | + } |
|
| 393 | 395 | |
| 394 | 396 | if (empty($time_limit)) { |
| 395 | 397 | $time_limit = api_get_setting('time_limit_whosonline'); |
@@ -39,6 +39,11 @@ discard block |
||
| 39 | 39 | // http://php.net/manual/en/function.gzopen.php |
| 40 | 40 | // -------------------------------------------------------------------------------- |
| 41 | 41 | if (!function_exists('gzopen') && function_exists('gzopen64')) {
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param string $filename |
|
| 45 | + * @param string $mode |
|
| 46 | + */ |
|
| 42 | 47 | function gzopen($filename, $mode, $use_include_path = 0) {
|
| 43 | 48 | return gzopen64($filename, $mode, $use_include_path); |
| 44 | 49 | } |
@@ -288,6 +293,10 @@ discard block |
||
| 288 | 293 | // The list of the added files, with a status of the add action. |
| 289 | 294 | // (see PclZip::listContent() for list entry format) |
| 290 | 295 | // -------------------------------------------------------------------------------- |
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * @param string $p_filelist |
|
| 299 | + */ |
|
| 291 | 300 | function create($p_filelist) |
| 292 | 301 | {
|
| 293 | 302 | $v_result=1; |
@@ -2355,6 +2364,10 @@ discard block |
||
| 2355 | 2364 | // Description : |
| 2356 | 2365 | // Parameters : |
| 2357 | 2366 | // -------------------------------------------------------------------------------- |
| 2367 | + |
|
| 2368 | + /** |
|
| 2369 | + * @param string $p_mode |
|
| 2370 | + */ |
|
| 2358 | 2371 | function privOpenFd($p_mode) |
| 2359 | 2372 | {
|
| 2360 | 2373 | $v_result=1; |
@@ -4171,6 +4184,10 @@ discard block |
||
| 4171 | 4184 | // Parameters : |
| 4172 | 4185 | // Return Values : |
| 4173 | 4186 | // -------------------------------------------------------------------------------- |
| 4187 | + |
|
| 4188 | + /** |
|
| 4189 | + * @param string $p_string |
|
| 4190 | + */ |
|
| 4174 | 4191 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4175 | 4192 | {
|
| 4176 | 4193 | $v_result=1; |
@@ -5071,6 +5088,10 @@ discard block |
||
| 5071 | 5088 | // Parameters : |
| 5072 | 5089 | // Return Values : |
| 5073 | 5090 | // -------------------------------------------------------------------------------- |
| 5091 | + |
|
| 5092 | + /** |
|
| 5093 | + * @param PclZip $p_archive_to_add |
|
| 5094 | + */ |
|
| 5074 | 5095 | function privMerge(&$p_archive_to_add) |
| 5075 | 5096 | {
|
| 5076 | 5097 | $v_result=1; |
@@ -5578,6 +5599,11 @@ discard block |
||
| 5578 | 5599 | // 3 : src & dest gzip |
| 5579 | 5600 | // Return Values : |
| 5580 | 5601 | // -------------------------------------------------------------------------------- |
| 5602 | + |
|
| 5603 | + /** |
|
| 5604 | + * @param integer $p_src |
|
| 5605 | + * @param integer $p_dest |
|
| 5606 | + */ |
|
| 5581 | 5607 | function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
| 5582 | 5608 | {
|
| 5583 | 5609 | $v_result = 1; |
@@ -5640,6 +5666,11 @@ discard block |
||
| 5640 | 5666 | // Return Values : |
| 5641 | 5667 | // 1 on success, 0 on failure. |
| 5642 | 5668 | // -------------------------------------------------------------------------------- |
| 5669 | + |
|
| 5670 | + /** |
|
| 5671 | + * @param string $p_src |
|
| 5672 | + * @param string $p_dest |
|
| 5673 | + */ |
|
| 5643 | 5674 | function PclZipUtilRename($p_src, $p_dest) |
| 5644 | 5675 | {
|
| 5645 | 5676 | $v_result = 1; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // ----- Constants |
| 49 | 49 | if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
|
| 50 | - define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|
| 50 | + define('PCLZIP_READ_BLOCK_SIZE', 2048);
|
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // ----- File list separator |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | //define( 'PCLZIP_SEPARATOR', ' ' ); |
| 62 | 62 | // Recommanded values for smart separation of filenames. |
| 63 | 63 | if (!defined('PCLZIP_SEPARATOR')) {
|
| 64 | - define( 'PCLZIP_SEPARATOR', '|' ); |
|
| 64 | + define('PCLZIP_SEPARATOR', '|');
|
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // ----- Error configuration |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | // you must ensure that you have included PclError library. |
| 71 | 71 | // [2,...] : reserved for futur use |
| 72 | 72 | if (!defined('PCLZIP_ERROR_EXTERNAL')) {
|
| 73 | - define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|
| 73 | + define('PCLZIP_ERROR_EXTERNAL', 0);
|
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // ----- Optional static temporary directory |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
| 84 | 84 | // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
| 85 | 85 | if (!defined('PCLZIP_TEMPORARY_DIR')) {
|
| 86 | - define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|
| 86 | + define('PCLZIP_TEMPORARY_DIR', '');
|
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // ----- Optional threshold ratio for use of temporary files |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // Samples : |
| 96 | 96 | // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); |
| 97 | 97 | if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
|
| 98 | - define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); |
|
| 98 | + define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
|
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // -------------------------------------------------------------------------------- |
@@ -120,72 +120,72 @@ discard block |
||
| 120 | 120 | // -12 : Unable to rename file (rename) |
| 121 | 121 | // -13 : Invalid header checksum |
| 122 | 122 | // -14 : Invalid archive size |
| 123 | - define( 'PCLZIP_ERR_USER_ABORTED', 2 ); |
|
| 124 | - define( 'PCLZIP_ERR_NO_ERROR', 0 ); |
|
| 125 | - define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); |
|
| 126 | - define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); |
|
| 127 | - define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); |
|
| 128 | - define( 'PCLZIP_ERR_MISSING_FILE', -4 ); |
|
| 129 | - define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); |
|
| 130 | - define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); |
|
| 131 | - define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); |
|
| 132 | - define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); |
|
| 133 | - define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); |
|
| 134 | - define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); |
|
| 135 | - define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); |
|
| 136 | - define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); |
|
| 137 | - define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); |
|
| 138 | - define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); |
|
| 139 | - define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); |
|
| 140 | - define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); |
|
| 141 | - define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); |
|
| 142 | - define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); |
|
| 143 | - define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); |
|
| 144 | - define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); |
|
| 145 | - define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); |
|
| 123 | + define('PCLZIP_ERR_USER_ABORTED', 2);
|
|
| 124 | + define('PCLZIP_ERR_NO_ERROR', 0);
|
|
| 125 | + define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
|
|
| 126 | + define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
|
|
| 127 | + define('PCLZIP_ERR_INVALID_PARAMETER', -3);
|
|
| 128 | + define('PCLZIP_ERR_MISSING_FILE', -4);
|
|
| 129 | + define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
|
|
| 130 | + define('PCLZIP_ERR_INVALID_ZIP', -6);
|
|
| 131 | + define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
|
|
| 132 | + define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
|
|
| 133 | + define('PCLZIP_ERR_BAD_EXTENSION', -9);
|
|
| 134 | + define('PCLZIP_ERR_BAD_FORMAT', -10);
|
|
| 135 | + define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
|
|
| 136 | + define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
|
|
| 137 | + define('PCLZIP_ERR_BAD_CHECKSUM', -13);
|
|
| 138 | + define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
|
|
| 139 | + define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
|
|
| 140 | + define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
|
|
| 141 | + define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
|
|
| 142 | + define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
|
|
| 143 | + define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
|
|
| 144 | + define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
|
|
| 145 | + define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
|
|
| 146 | 146 | |
| 147 | 147 | // ----- Options values |
| 148 | - define( 'PCLZIP_OPT_PATH', 77001 ); |
|
| 149 | - define( 'PCLZIP_OPT_ADD_PATH', 77002 ); |
|
| 150 | - define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); |
|
| 151 | - define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); |
|
| 152 | - define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); |
|
| 153 | - define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); |
|
| 154 | - define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); |
|
| 155 | - define( 'PCLZIP_OPT_BY_NAME', 77008 ); |
|
| 156 | - define( 'PCLZIP_OPT_BY_INDEX', 77009 ); |
|
| 157 | - define( 'PCLZIP_OPT_BY_EREG', 77010 ); |
|
| 158 | - define( 'PCLZIP_OPT_BY_PREG', 77011 ); |
|
| 159 | - define( 'PCLZIP_OPT_COMMENT', 77012 ); |
|
| 160 | - define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); |
|
| 161 | - define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); |
|
| 162 | - define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); |
|
| 163 | - define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); |
|
| 164 | - define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); |
|
| 148 | + define('PCLZIP_OPT_PATH', 77001);
|
|
| 149 | + define('PCLZIP_OPT_ADD_PATH', 77002);
|
|
| 150 | + define('PCLZIP_OPT_REMOVE_PATH', 77003);
|
|
| 151 | + define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
|
|
| 152 | + define('PCLZIP_OPT_SET_CHMOD', 77005);
|
|
| 153 | + define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
|
|
| 154 | + define('PCLZIP_OPT_NO_COMPRESSION', 77007);
|
|
| 155 | + define('PCLZIP_OPT_BY_NAME', 77008);
|
|
| 156 | + define('PCLZIP_OPT_BY_INDEX', 77009);
|
|
| 157 | + define('PCLZIP_OPT_BY_EREG', 77010);
|
|
| 158 | + define('PCLZIP_OPT_BY_PREG', 77011);
|
|
| 159 | + define('PCLZIP_OPT_COMMENT', 77012);
|
|
| 160 | + define('PCLZIP_OPT_ADD_COMMENT', 77013);
|
|
| 161 | + define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
|
|
| 162 | + define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
|
|
| 163 | + define('PCLZIP_OPT_REPLACE_NEWER', 77016);
|
|
| 164 | + define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
|
|
| 165 | 165 | // Having big trouble with crypt. Need to multiply 2 long int |
| 166 | 166 | // which is not correctly supported by PHP ... |
| 167 | 167 | //define( 'PCLZIP_OPT_CRYPT', 77018 ); |
| 168 | - define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); |
|
| 169 | - define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); |
|
| 170 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias |
|
| 171 | - define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); |
|
| 172 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias |
|
| 173 | - define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); |
|
| 174 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias |
|
| 168 | + define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
|
|
| 169 | + define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
|
|
| 170 | + define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
|
|
| 171 | + define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
|
|
| 172 | + define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
|
|
| 173 | + define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
|
|
| 174 | + define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
|
|
| 175 | 175 | |
| 176 | 176 | // ----- File description attributes |
| 177 | - define( 'PCLZIP_ATT_FILE_NAME', 79001 ); |
|
| 178 | - define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
|
| 179 | - define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); |
|
| 180 | - define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); |
|
| 181 | - define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); |
|
| 182 | - define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); |
|
| 177 | + define('PCLZIP_ATT_FILE_NAME', 79001);
|
|
| 178 | + define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
|
|
| 179 | + define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
|
|
| 180 | + define('PCLZIP_ATT_FILE_MTIME', 79004);
|
|
| 181 | + define('PCLZIP_ATT_FILE_CONTENT', 79005);
|
|
| 182 | + define('PCLZIP_ATT_FILE_COMMENT', 79006);
|
|
| 183 | 183 | |
| 184 | 184 | // ----- Call backs values |
| 185 | - define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); |
|
| 186 | - define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); |
|
| 187 | - define( 'PCLZIP_CB_PRE_ADD', 78003 ); |
|
| 188 | - define( 'PCLZIP_CB_POST_ADD', 78004 ); |
|
| 185 | + define('PCLZIP_CB_PRE_EXTRACT', 78001);
|
|
| 186 | + define('PCLZIP_CB_POST_EXTRACT', 78002);
|
|
| 187 | + define('PCLZIP_CB_PRE_ADD', 78003);
|
|
| 188 | + define('PCLZIP_CB_POST_ADD', 78004);
|
|
| 189 | 189 | /* For futur use |
| 190 | 190 | define( 'PCLZIP_CB_PRE_LIST', 78005 ); |
| 191 | 191 | define( 'PCLZIP_CB_POST_LIST', 78006 ); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // -------------------------------------------------------------------------------- |
| 291 | 291 | function create($p_filelist) |
| 292 | 292 | {
|
| 293 | - $v_result=1; |
|
| 293 | + $v_result = 1; |
|
| 294 | 294 | |
| 295 | 295 | // ----- Reset the error handler |
| 296 | 296 | $this->privErrorReset(); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // ----- Parse the options |
| 318 | 318 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 319 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 319 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 320 | 320 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 321 | 321 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 322 | 322 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | // ----- For each file in the list check the attributes |
| 404 | 404 | $v_supported_attributes |
| 405 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 405 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 406 | 406 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 407 | 407 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 408 | 408 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | // -------------------------------------------------------------------------------- |
| 474 | 474 | function add($p_filelist) |
| 475 | 475 | {
|
| 476 | - $v_result=1; |
|
| 476 | + $v_result = 1; |
|
| 477 | 477 | |
| 478 | 478 | // ----- Reset the error handler |
| 479 | 479 | $this->privErrorReset(); |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | // ----- Parse the options |
| 501 | 501 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 502 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 502 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 503 | 503 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 504 | 504 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 505 | 505 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | // ----- For each file in the list check the attributes |
| 587 | 587 | $v_supported_attributes |
| 588 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 588 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 589 | 589 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 590 | 590 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 591 | 591 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | // -------------------------------------------------------------------------------- |
| 663 | 663 | function listContent() |
| 664 | 664 | {
|
| 665 | - $v_result=1; |
|
| 665 | + $v_result = 1; |
|
| 666 | 666 | |
| 667 | 667 | // ----- Reset the error handler |
| 668 | 668 | $this->privErrorReset(); |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | // -------------------------------------------------------------------------------- |
| 720 | 720 | function extract() |
| 721 | 721 | {
|
| 722 | - $v_result=1; |
|
| 722 | + $v_result = 1; |
|
| 723 | 723 | |
| 724 | 724 | // ----- Reset the error handler |
| 725 | 725 | $this->privErrorReset(); |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | // ----- Parse the options |
| 754 | 754 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 755 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 755 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 756 | 756 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 757 | 757 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 758 | 758 | PCLZIP_OPT_ADD_PATH => 'optional', |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | //function extractByIndex($p_index, options...) |
| 877 | 877 | function extractByIndex($p_index) |
| 878 | 878 | {
|
| 879 | - $v_result=1; |
|
| 879 | + $v_result = 1; |
|
| 880 | 880 | |
| 881 | 881 | // ----- Reset the error handler |
| 882 | 882 | $this->privErrorReset(); |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | |
| 914 | 914 | // ----- Parse the options |
| 915 | 915 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 916 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 916 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 917 | 917 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 918 | 918 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 919 | 919 | PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
@@ -983,10 +983,10 @@ discard block |
||
| 983 | 983 | // ----- Trick |
| 984 | 984 | // Here I want to reuse extractByRule(), so I need to parse the $p_index |
| 985 | 985 | // with privParseOptions() |
| 986 | - $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 986 | + $v_arg_trick = array(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 987 | 987 | $v_options_trick = array(); |
| 988 | 988 | $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
| 989 | - array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 989 | + array(PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 990 | 990 | if ($v_result != 1) {
|
| 991 | 991 | return 0; |
| 992 | 992 | } |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | // -------------------------------------------------------------------------------- |
| 1026 | 1026 | function delete() |
| 1027 | 1027 | {
|
| 1028 | - $v_result=1; |
|
| 1028 | + $v_result = 1; |
|
| 1029 | 1029 | |
| 1030 | 1030 | // ----- Reset the error handler |
| 1031 | 1031 | $this->privErrorReset(); |
@@ -1048,10 +1048,10 @@ discard block |
||
| 1048 | 1048 | |
| 1049 | 1049 | // ----- Parse the options |
| 1050 | 1050 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 1051 | - array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1051 | + array(PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1052 | 1052 | PCLZIP_OPT_BY_EREG => 'optional', |
| 1053 | 1053 | PCLZIP_OPT_BY_PREG => 'optional', |
| 1054 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1054 | + PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 1055 | 1055 | if ($v_result != 1) {
|
| 1056 | 1056 | return 0; |
| 1057 | 1057 | } |
@@ -1305,9 +1305,9 @@ discard block |
||
| 1305 | 1305 | // Description : |
| 1306 | 1306 | // Parameters : |
| 1307 | 1307 | // -------------------------------------------------------------------------------- |
| 1308 | - function errorName($p_with_code=false) |
|
| 1308 | + function errorName($p_with_code = false) |
|
| 1309 | 1309 | {
|
| 1310 | - $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1310 | + $v_name = array(PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1311 | 1311 | PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
| 1312 | 1312 | PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
| 1313 | 1313 | PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | // Description : |
| 1352 | 1352 | // Parameters : |
| 1353 | 1353 | // -------------------------------------------------------------------------------- |
| 1354 | - function errorInfo($p_full=false) |
|
| 1354 | + function errorInfo($p_full = false) |
|
| 1355 | 1355 | {
|
| 1356 | 1356 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 1357 | 1357 | return(PclErrorString()); |
@@ -1390,7 +1390,7 @@ discard block |
||
| 1390 | 1390 | // true on success, |
| 1391 | 1391 | // false on error, the error code is set. |
| 1392 | 1392 | // -------------------------------------------------------------------------------- |
| 1393 | - function privCheckFormat($p_level=0) |
|
| 1393 | + function privCheckFormat($p_level = 0) |
|
| 1394 | 1394 | {
|
| 1395 | 1395 | $v_result = true; |
| 1396 | 1396 | |
@@ -1443,13 +1443,13 @@ discard block |
||
| 1443 | 1443 | // 1 on success. |
| 1444 | 1444 | // 0 on failure. |
| 1445 | 1445 | // -------------------------------------------------------------------------------- |
| 1446 | - function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
|
| 1446 | + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false) |
|
| 1447 | 1447 | {
|
| 1448 | - $v_result=1; |
|
| 1448 | + $v_result = 1; |
|
| 1449 | 1449 | |
| 1450 | 1450 | // ----- Read the options |
| 1451 | - $i=0; |
|
| 1452 | - while ($i<$p_size) {
|
|
| 1451 | + $i = 0; |
|
| 1452 | + while ($i < $p_size) {
|
|
| 1453 | 1453 | |
| 1454 | 1454 | // ----- Check if the option is supported |
| 1455 | 1455 | if (!isset($v_requested_options[$p_options_list[$i]])) {
|
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | case PCLZIP_OPT_REMOVE_PATH : |
| 1468 | 1468 | case PCLZIP_OPT_ADD_PATH : |
| 1469 | 1469 | // ----- Check the number of parameters |
| 1470 | - if (($i+1) >= $p_size) {
|
|
| 1470 | + if (($i + 1) >= $p_size) {
|
|
| 1471 | 1471 | // ----- Error log |
| 1472 | 1472 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1473 | 1473 | |
@@ -1476,13 +1476,13 @@ discard block |
||
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | 1478 | // ----- Get the value |
| 1479 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1479 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1480 | 1480 | $i++; |
| 1481 | 1481 | break; |
| 1482 | 1482 | |
| 1483 | 1483 | case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
| 1484 | 1484 | // ----- Check the number of parameters |
| 1485 | - if (($i+1) >= $p_size) {
|
|
| 1485 | + if (($i + 1) >= $p_size) {
|
|
| 1486 | 1486 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1487 | 1487 | return PclZip::errorCode(); |
| 1488 | 1488 | } |
@@ -1494,14 +1494,14 @@ discard block |
||
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | // ----- Check the value |
| 1497 | - $v_value = $p_options_list[$i+1]; |
|
| 1498 | - if ((!is_integer($v_value)) || ($v_value<0)) {
|
|
| 1497 | + $v_value = $p_options_list[$i + 1]; |
|
| 1498 | + if ((!is_integer($v_value)) || ($v_value < 0)) {
|
|
| 1499 | 1499 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1500 | 1500 | return PclZip::errorCode(); |
| 1501 | 1501 | } |
| 1502 | 1502 | |
| 1503 | 1503 | // ----- Get the value (and convert it in bytes) |
| 1504 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1504 | + $v_result_list[$p_options_list[$i]] = $v_value * 1048576; |
|
| 1505 | 1505 | $i++; |
| 1506 | 1506 | break; |
| 1507 | 1507 | |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | |
| 1533 | 1533 | case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
| 1534 | 1534 | // ----- Check the number of parameters |
| 1535 | - if (($i+1) >= $p_size) {
|
|
| 1535 | + if (($i + 1) >= $p_size) {
|
|
| 1536 | 1536 | // ----- Error log |
| 1537 | 1537 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1538 | 1538 | |
@@ -1541,9 +1541,9 @@ discard block |
||
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | // ----- Get the value |
| 1544 | - if ( is_string($p_options_list[$i+1]) |
|
| 1545 | - && ($p_options_list[$i+1] != '')) {
|
|
| 1546 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1544 | + if (is_string($p_options_list[$i + 1]) |
|
| 1545 | + && ($p_options_list[$i + 1] != '')) {
|
|
| 1546 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1547 | 1547 | $i++; |
| 1548 | 1548 | } |
| 1549 | 1549 | else {
|
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | // ----- Look for options that request an array of string for value |
| 1554 | 1554 | case PCLZIP_OPT_BY_NAME : |
| 1555 | 1555 | // ----- Check the number of parameters |
| 1556 | - if (($i+1) >= $p_size) {
|
|
| 1556 | + if (($i + 1) >= $p_size) {
|
|
| 1557 | 1557 | // ----- Error log |
| 1558 | 1558 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1559 | 1559 | |
@@ -1562,11 +1562,11 @@ discard block |
||
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | // ----- Get the value |
| 1565 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1566 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1565 | + if (is_string($p_options_list[$i + 1])) {
|
|
| 1566 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1]; |
|
| 1567 | 1567 | } |
| 1568 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1569 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1568 | + else if (is_array($p_options_list[$i + 1])) {
|
|
| 1569 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1570 | 1570 | } |
| 1571 | 1571 | else {
|
| 1572 | 1572 | // ----- Error log |
@@ -1586,7 +1586,7 @@ discard block |
||
| 1586 | 1586 | case PCLZIP_OPT_BY_PREG : |
| 1587 | 1587 | //case PCLZIP_OPT_CRYPT : |
| 1588 | 1588 | // ----- Check the number of parameters |
| 1589 | - if (($i+1) >= $p_size) {
|
|
| 1589 | + if (($i + 1) >= $p_size) {
|
|
| 1590 | 1590 | // ----- Error log |
| 1591 | 1591 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1592 | 1592 | |
@@ -1595,8 +1595,8 @@ discard block |
||
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | // ----- Get the value |
| 1598 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1599 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1598 | + if (is_string($p_options_list[$i + 1])) {
|
|
| 1599 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1600 | 1600 | } |
| 1601 | 1601 | else {
|
| 1602 | 1602 | // ----- Error log |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | case PCLZIP_OPT_ADD_COMMENT : |
| 1614 | 1614 | case PCLZIP_OPT_PREPEND_COMMENT : |
| 1615 | 1615 | // ----- Check the number of parameters |
| 1616 | - if (($i+1) >= $p_size) {
|
|
| 1616 | + if (($i + 1) >= $p_size) {
|
|
| 1617 | 1617 | // ----- Error log |
| 1618 | 1618 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
| 1619 | 1619 | "Missing parameter value for option '" |
@@ -1625,8 +1625,8 @@ discard block |
||
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | // ----- Get the value |
| 1628 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1629 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1628 | + if (is_string($p_options_list[$i + 1])) {
|
|
| 1629 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1630 | 1630 | } |
| 1631 | 1631 | else {
|
| 1632 | 1632 | // ----- Error log |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | // ----- Look for options that request an array of index |
| 1645 | 1645 | case PCLZIP_OPT_BY_INDEX : |
| 1646 | 1646 | // ----- Check the number of parameters |
| 1647 | - if (($i+1) >= $p_size) {
|
|
| 1647 | + if (($i + 1) >= $p_size) {
|
|
| 1648 | 1648 | // ----- Error log |
| 1649 | 1649 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1650 | 1650 | |
@@ -1654,19 +1654,19 @@ discard block |
||
| 1654 | 1654 | |
| 1655 | 1655 | // ----- Get the value |
| 1656 | 1656 | $v_work_list = array(); |
| 1657 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1657 | + if (is_string($p_options_list[$i + 1])) {
|
|
| 1658 | 1658 | |
| 1659 | 1659 | // ----- Remove spaces |
| 1660 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1660 | + $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', ''); |
|
| 1661 | 1661 | |
| 1662 | 1662 | // ----- Parse items |
| 1663 | - $v_work_list = explode(",", $p_options_list[$i+1]);
|
|
| 1663 | + $v_work_list = explode(",", $p_options_list[$i + 1]);
|
|
| 1664 | 1664 | } |
| 1665 | - else if (is_integer($p_options_list[$i+1])) {
|
|
| 1666 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1665 | + else if (is_integer($p_options_list[$i + 1])) {
|
|
| 1666 | + $v_work_list[0] = $p_options_list[$i + 1].'-'.$p_options_list[$i + 1]; |
|
| 1667 | 1667 | } |
| 1668 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1669 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1668 | + else if (is_array($p_options_list[$i + 1])) {
|
|
| 1669 | + $v_work_list = $p_options_list[$i + 1]; |
|
| 1670 | 1670 | } |
| 1671 | 1671 | else {
|
| 1672 | 1672 | // ----- Error log |
@@ -1680,9 +1680,9 @@ discard block |
||
| 1680 | 1680 | // each index item in the list must be a couple with a start and |
| 1681 | 1681 | // an end value : [0,3], [5-5], [8-10], ... |
| 1682 | 1682 | // ----- Check the format of each item |
| 1683 | - $v_sort_flag=false; |
|
| 1684 | - $v_sort_value=0; |
|
| 1685 | - for ($j=0; $j<sizeof($v_work_list); $j++) {
|
|
| 1683 | + $v_sort_flag = false; |
|
| 1684 | + $v_sort_value = 0; |
|
| 1685 | + for ($j = 0; $j < sizeof($v_work_list); $j++) {
|
|
| 1686 | 1686 | // ----- Explode the item |
| 1687 | 1687 | $v_item_list = explode("-", $v_work_list[$j]);
|
| 1688 | 1688 | $v_size_item_list = sizeof($v_item_list); |
@@ -1712,7 +1712,7 @@ discard block |
||
| 1712 | 1712 | |
| 1713 | 1713 | // ----- Look for list sort |
| 1714 | 1714 | if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
|
| 1715 | - $v_sort_flag=true; |
|
| 1715 | + $v_sort_flag = true; |
|
| 1716 | 1716 | |
| 1717 | 1717 | // ----- TBC : An automatic sort should be writen ... |
| 1718 | 1718 | // ----- Error log |
@@ -1746,7 +1746,7 @@ discard block |
||
| 1746 | 1746 | // ----- Look for options that request an octal value |
| 1747 | 1747 | case PCLZIP_OPT_SET_CHMOD : |
| 1748 | 1748 | // ----- Check the number of parameters |
| 1749 | - if (($i+1) >= $p_size) {
|
|
| 1749 | + if (($i + 1) >= $p_size) {
|
|
| 1750 | 1750 | // ----- Error log |
| 1751 | 1751 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1752 | 1752 | |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | // ----- Get the value |
| 1758 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1758 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1759 | 1759 | $i++; |
| 1760 | 1760 | break; |
| 1761 | 1761 | |
@@ -1771,7 +1771,7 @@ discard block |
||
| 1771 | 1771 | case PCLZIP_CB_POST_LIST : |
| 1772 | 1772 | */ |
| 1773 | 1773 | // ----- Check the number of parameters |
| 1774 | - if (($i+1) >= $p_size) {
|
|
| 1774 | + if (($i + 1) >= $p_size) {
|
|
| 1775 | 1775 | // ----- Error log |
| 1776 | 1776 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1777 | 1777 | |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | 1782 | // ----- Get the value |
| 1783 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1783 | + $v_function_name = $p_options_list[$i + 1]; |
|
| 1784 | 1784 | |
| 1785 | 1785 | // ----- Check that the value is a valid existing function |
| 1786 | 1786 | if (!function_exists($v_function_name)) {
|
@@ -1812,7 +1812,7 @@ discard block |
||
| 1812 | 1812 | |
| 1813 | 1813 | // ----- Look for mandatory options |
| 1814 | 1814 | if ($v_requested_options !== false) {
|
| 1815 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
|
| 1815 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
|
|
| 1816 | 1816 | // ----- Look for mandatory option |
| 1817 | 1817 | if ($v_requested_options[$key] == 'mandatory') {
|
| 1818 | 1818 | // ----- Look if present |
@@ -1845,7 +1845,7 @@ discard block |
||
| 1845 | 1845 | // -------------------------------------------------------------------------------- |
| 1846 | 1846 | function privOptionDefaultThreshold(&$p_options) |
| 1847 | 1847 | {
|
| 1848 | - $v_result=1; |
|
| 1848 | + $v_result = 1; |
|
| 1849 | 1849 | |
| 1850 | 1850 | if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 1851 | 1851 | || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
@@ -1857,16 +1857,16 @@ discard block |
||
| 1857 | 1857 | $v_memory_limit = trim($v_memory_limit); |
| 1858 | 1858 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1859 | 1859 | |
| 1860 | - if($last == 'g') |
|
| 1860 | + if ($last == 'g') |
|
| 1861 | 1861 | //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
| 1862 | - $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1863 | - if($last == 'm') |
|
| 1862 | + $v_memory_limit = $v_memory_limit * 1073741824; |
|
| 1863 | + if ($last == 'm') |
|
| 1864 | 1864 | //$v_memory_limit = $v_memory_limit*1024*1024; |
| 1865 | - $v_memory_limit = $v_memory_limit*1048576; |
|
| 1866 | - if($last == 'k') |
|
| 1867 | - $v_memory_limit = $v_memory_limit*1024; |
|
| 1865 | + $v_memory_limit = $v_memory_limit * 1048576; |
|
| 1866 | + if ($last == 'k') |
|
| 1867 | + $v_memory_limit = $v_memory_limit * 1024; |
|
| 1868 | 1868 | |
| 1869 | - $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1869 | + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit * PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1870 | 1870 | |
| 1871 | 1871 | |
| 1872 | 1872 | // ----- Sanity check : No threshold if value lower than 1M |
@@ -1887,9 +1887,9 @@ discard block |
||
| 1887 | 1887 | // 1 on success. |
| 1888 | 1888 | // 0 on failure. |
| 1889 | 1889 | // -------------------------------------------------------------------------------- |
| 1890 | - function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
|
| 1890 | + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false) |
|
| 1891 | 1891 | {
|
| 1892 | - $v_result=1; |
|
| 1892 | + $v_result = 1; |
|
| 1893 | 1893 | |
| 1894 | 1894 | // ----- For each file in the list check the attributes |
| 1895 | 1895 | foreach ($p_file_list as $v_key => $v_value) {
|
@@ -1982,7 +1982,7 @@ discard block |
||
| 1982 | 1982 | |
| 1983 | 1983 | // ----- Look for mandatory options |
| 1984 | 1984 | if ($v_requested_options !== false) {
|
| 1985 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
|
| 1985 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
|
|
| 1986 | 1986 | // ----- Look for mandatory option |
| 1987 | 1987 | if ($v_requested_options[$key] == 'mandatory') {
|
| 1988 | 1988 | // ----- Look if present |
@@ -2018,13 +2018,13 @@ discard block |
||
| 2018 | 2018 | // -------------------------------------------------------------------------------- |
| 2019 | 2019 | function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
| 2020 | 2020 | {
|
| 2021 | - $v_result=1; |
|
| 2021 | + $v_result = 1; |
|
| 2022 | 2022 | |
| 2023 | 2023 | // ----- Create a result list |
| 2024 | 2024 | $v_result_list = array(); |
| 2025 | 2025 | |
| 2026 | 2026 | // ----- Look each entry |
| 2027 | - for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
|
|
| 2027 | + for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
|
|
| 2028 | 2028 | |
| 2029 | 2029 | // ----- Get filedescr |
| 2030 | 2030 | $v_descr = $p_filedescr_list[$i]; |
@@ -2143,7 +2143,7 @@ discard block |
||
| 2143 | 2143 | // -------------------------------------------------------------------------------- |
| 2144 | 2144 | function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2145 | 2145 | {
|
| 2146 | - $v_result=1; |
|
| 2146 | + $v_result = 1; |
|
| 2147 | 2147 | $v_list_detail = array(); |
| 2148 | 2148 | |
| 2149 | 2149 | // ----- Magic quotes trick |
@@ -2178,7 +2178,7 @@ discard block |
||
| 2178 | 2178 | // -------------------------------------------------------------------------------- |
| 2179 | 2179 | function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2180 | 2180 | {
|
| 2181 | - $v_result=1; |
|
| 2181 | + $v_result = 1; |
|
| 2182 | 2182 | $v_list_detail = array(); |
| 2183 | 2183 | |
| 2184 | 2184 | // ----- Look if the archive exists or is empty |
@@ -2195,7 +2195,7 @@ discard block |
||
| 2195 | 2195 | $this->privDisableMagicQuotes(); |
| 2196 | 2196 | |
| 2197 | 2197 | // ----- Open the zip file |
| 2198 | - if (($v_result=$this->privOpenFd('rb')) != 1)
|
|
| 2198 | + if (($v_result = $this->privOpenFd('rb')) != 1)
|
|
| 2199 | 2199 | {
|
| 2200 | 2200 | // ----- Magic quotes trick |
| 2201 | 2201 | $this->privSwapBackMagicQuotes(); |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | } |
| 2277 | 2277 | |
| 2278 | 2278 | // ----- Create the Central Dir files header |
| 2279 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2279 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2280 | 2280 | {
|
| 2281 | 2281 | // ----- Create the file header |
| 2282 | 2282 | if ($v_header_list[$i]['status'] == 'ok') {
|
@@ -2309,10 +2309,10 @@ discard block |
||
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | // ----- Calculate the size of the central header |
| 2312 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2312 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2313 | 2313 | |
| 2314 | 2314 | // ----- Create the central dir footer |
| 2315 | - if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2315 | + if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2316 | 2316 | {
|
| 2317 | 2317 | // ----- Reset the file list |
| 2318 | 2318 | unset($v_header_list); |
@@ -2357,7 +2357,7 @@ discard block |
||
| 2357 | 2357 | // -------------------------------------------------------------------------------- |
| 2358 | 2358 | function privOpenFd($p_mode) |
| 2359 | 2359 | {
|
| 2360 | - $v_result=1; |
|
| 2360 | + $v_result = 1; |
|
| 2361 | 2361 | |
| 2362 | 2362 | // ----- Look if already open |
| 2363 | 2363 | if ($this->zip_fd != 0) |
@@ -2391,7 +2391,7 @@ discard block |
||
| 2391 | 2391 | // -------------------------------------------------------------------------------- |
| 2392 | 2392 | function privCloseFd() |
| 2393 | 2393 | {
|
| 2394 | - $v_result=1; |
|
| 2394 | + $v_result = 1; |
|
| 2395 | 2395 | |
| 2396 | 2396 | if ($this->zip_fd != 0) |
| 2397 | 2397 | @fclose($this->zip_fd); |
@@ -2418,7 +2418,7 @@ discard block |
||
| 2418 | 2418 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2419 | 2419 | function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2420 | 2420 | {
|
| 2421 | - $v_result=1; |
|
| 2421 | + $v_result = 1; |
|
| 2422 | 2422 | |
| 2423 | 2423 | // ----- Add the files |
| 2424 | 2424 | $v_header_list = array(); |
@@ -2432,7 +2432,7 @@ discard block |
||
| 2432 | 2432 | $v_offset = @ftell($this->zip_fd); |
| 2433 | 2433 | |
| 2434 | 2434 | // ----- Create the Central Dir files header |
| 2435 | - for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2435 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2436 | 2436 | {
|
| 2437 | 2437 | // ----- Create the file header |
| 2438 | 2438 | if ($v_header_list[$i]['status'] == 'ok') {
|
@@ -2454,7 +2454,7 @@ discard block |
||
| 2454 | 2454 | } |
| 2455 | 2455 | |
| 2456 | 2456 | // ----- Calculate the size of the central header |
| 2457 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2457 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2458 | 2458 | |
| 2459 | 2459 | // ----- Create the central dir footer |
| 2460 | 2460 | if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
@@ -2482,14 +2482,14 @@ discard block |
||
| 2482 | 2482 | // -------------------------------------------------------------------------------- |
| 2483 | 2483 | function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2484 | 2484 | {
|
| 2485 | - $v_result=1; |
|
| 2485 | + $v_result = 1; |
|
| 2486 | 2486 | $v_header = array(); |
| 2487 | 2487 | |
| 2488 | 2488 | // ----- Recuperate the current number of elt in list |
| 2489 | 2489 | $v_nb = sizeof($p_result_list); |
| 2490 | 2490 | |
| 2491 | 2491 | // ----- Loop on the files |
| 2492 | - for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
|
|
| 2492 | + for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
|
|
| 2493 | 2493 | // ----- Format the filename |
| 2494 | 2494 | $p_filedescr_list[$j]['filename'] |
| 2495 | 2495 | = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
@@ -2502,7 +2502,7 @@ discard block |
||
| 2502 | 2502 | } |
| 2503 | 2503 | |
| 2504 | 2504 | // ----- Check the filename |
| 2505 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2505 | + if (($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2506 | 2506 | && (!file_exists($p_filedescr_list[$j]['filename']))) {
|
| 2507 | 2507 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
| 2508 | 2508 | return PclZip::errorCode(); |
@@ -2512,10 +2512,10 @@ discard block |
||
| 2512 | 2512 | // or a dir with all its path removed |
| 2513 | 2513 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2514 | 2514 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2515 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2515 | + if (($p_filedescr_list[$j]['type'] == 'file') |
|
| 2516 | 2516 | || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
| 2517 | - || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2518 | - && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2517 | + || (($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2518 | + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2519 | 2519 | || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
| 2520 | 2520 | ) {
|
| 2521 | 2521 | |
@@ -2544,7 +2544,7 @@ discard block |
||
| 2544 | 2544 | // -------------------------------------------------------------------------------- |
| 2545 | 2545 | function privAddFile($p_filedescr, &$p_header, &$p_options) |
| 2546 | 2546 | {
|
| 2547 | - $v_result=1; |
|
| 2547 | + $v_result = 1; |
|
| 2548 | 2548 | |
| 2549 | 2549 | // ----- Working variable |
| 2550 | 2550 | $p_filename = $p_filedescr['filename']; |
@@ -2589,13 +2589,13 @@ discard block |
||
| 2589 | 2589 | $p_header['index'] = -1; |
| 2590 | 2590 | |
| 2591 | 2591 | // ----- Look for regular file |
| 2592 | - if ($p_filedescr['type']=='file') {
|
|
| 2592 | + if ($p_filedescr['type'] == 'file') {
|
|
| 2593 | 2593 | $p_header['external'] = 0x00000000; |
| 2594 | 2594 | $p_header['size'] = filesize($p_filename); |
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | 2597 | // ----- Look for regular folder |
| 2598 | - else if ($p_filedescr['type']=='folder') {
|
|
| 2598 | + else if ($p_filedescr['type'] == 'folder') {
|
|
| 2599 | 2599 | $p_header['external'] = 0x00000010; |
| 2600 | 2600 | $p_header['mtime'] = filemtime($p_filename); |
| 2601 | 2601 | $p_header['size'] = filesize($p_filename); |
@@ -2670,10 +2670,10 @@ discard block |
||
| 2670 | 2670 | // ----- Look for a file |
| 2671 | 2671 | if ($p_filedescr['type'] == 'file') {
|
| 2672 | 2672 | // ----- Look for using temporary file to zip |
| 2673 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2673 | + if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2674 | 2674 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 2675 | 2675 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 2676 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
|
|
| 2676 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) {
|
|
| 2677 | 2677 | $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
| 2678 | 2678 | if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
| 2679 | 2679 | return $v_result; |
@@ -2773,7 +2773,7 @@ discard block |
||
| 2773 | 2773 | // ----- Set the file properties |
| 2774 | 2774 | $p_header['size'] = 0; |
| 2775 | 2775 | //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
| 2776 | - $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2776 | + $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2777 | 2777 | |
| 2778 | 2778 | // ----- Call the header generation |
| 2779 | 2779 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
@@ -2817,7 +2817,7 @@ discard block |
||
| 2817 | 2817 | // -------------------------------------------------------------------------------- |
| 2818 | 2818 | function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
| 2819 | 2819 | {
|
| 2820 | - $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2820 | + $v_result = PCLZIP_ERR_NO_ERROR; |
|
| 2821 | 2821 | |
| 2822 | 2822 | // ----- Working variable |
| 2823 | 2823 | $p_filename = $p_filedescr['filename']; |
@@ -2871,7 +2871,7 @@ discard block |
||
| 2871 | 2871 | $v_data_header['os'] = bin2hex($v_data_header['os']); |
| 2872 | 2872 | |
| 2873 | 2873 | // ----- Read the gzip file footer |
| 2874 | - @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2874 | + @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8); |
|
| 2875 | 2875 | $v_binary_data = @fread($v_file_compressed, 8); |
| 2876 | 2876 | $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
|
| 2877 | 2877 | |
@@ -2879,7 +2879,7 @@ discard block |
||
| 2879 | 2879 | $p_header['compression'] = ord($v_data_header['cm']); |
| 2880 | 2880 | //$p_header['mtime'] = $v_data_header['mtime']; |
| 2881 | 2881 | $p_header['crc'] = $v_data_footer['crc']; |
| 2882 | - $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2882 | + $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18; |
|
| 2883 | 2883 | |
| 2884 | 2884 | // ----- Close the file |
| 2885 | 2885 | @fclose($v_file_compressed); |
@@ -2929,7 +2929,7 @@ discard block |
||
| 2929 | 2929 | // -------------------------------------------------------------------------------- |
| 2930 | 2930 | function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
| 2931 | 2931 | {
|
| 2932 | - $v_result=1; |
|
| 2932 | + $v_result = 1; |
|
| 2933 | 2933 | |
| 2934 | 2934 | // ----- Working variables |
| 2935 | 2935 | $p_filename = $p_filedescr['filename']; |
@@ -2986,14 +2986,14 @@ discard block |
||
| 2986 | 2986 | if (substr($p_remove_dir, -1) != '/') |
| 2987 | 2987 | $p_remove_dir .= "/"; |
| 2988 | 2988 | |
| 2989 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2989 | + if ((substr($p_filename, 0, 2) == "./") |
|
| 2990 | 2990 | || (substr($p_remove_dir, 0, 2) == "./")) {
|
| 2991 | 2991 | |
| 2992 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2992 | + if ((substr($p_filename, 0, 2) == "./") |
|
| 2993 | 2993 | && (substr($p_remove_dir, 0, 2) != "./")) {
|
| 2994 | 2994 | $p_remove_dir = "./".$p_remove_dir; |
| 2995 | 2995 | } |
| 2996 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2996 | + if ((substr($p_filename, 0, 2) != "./") |
|
| 2997 | 2997 | && (substr($p_remove_dir, 0, 2) == "./")) {
|
| 2998 | 2998 | $p_remove_dir = substr($p_remove_dir, 2); |
| 2999 | 2999 | } |
@@ -3041,15 +3041,15 @@ discard block |
||
| 3041 | 3041 | // -------------------------------------------------------------------------------- |
| 3042 | 3042 | function privWriteFileHeader(&$p_header) |
| 3043 | 3043 | {
|
| 3044 | - $v_result=1; |
|
| 3044 | + $v_result = 1; |
|
| 3045 | 3045 | |
| 3046 | 3046 | // ----- Store the offset position of the file |
| 3047 | 3047 | $p_header['offset'] = ftell($this->zip_fd); |
| 3048 | 3048 | |
| 3049 | 3049 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3050 | 3050 | $v_date = getdate($p_header['mtime']); |
| 3051 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3052 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3051 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3052 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3053 | 3053 | |
| 3054 | 3054 | // ----- Packed data |
| 3055 | 3055 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
|
@@ -3086,7 +3086,7 @@ discard block |
||
| 3086 | 3086 | // -------------------------------------------------------------------------------- |
| 3087 | 3087 | function privWriteCentralFileHeader(&$p_header) |
| 3088 | 3088 | {
|
| 3089 | - $v_result=1; |
|
| 3089 | + $v_result = 1; |
|
| 3090 | 3090 | |
| 3091 | 3091 | // TBC |
| 3092 | 3092 | //for(reset($p_header); $key = key($p_header); next($p_header)) {
|
@@ -3094,8 +3094,8 @@ discard block |
||
| 3094 | 3094 | |
| 3095 | 3095 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3096 | 3096 | $v_date = getdate($p_header['mtime']); |
| 3097 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3098 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3097 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3098 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3099 | 3099 | |
| 3100 | 3100 | |
| 3101 | 3101 | // ----- Packed data |
@@ -3139,7 +3139,7 @@ discard block |
||
| 3139 | 3139 | // -------------------------------------------------------------------------------- |
| 3140 | 3140 | function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 3141 | 3141 | {
|
| 3142 | - $v_result=1; |
|
| 3142 | + $v_result = 1; |
|
| 3143 | 3143 | |
| 3144 | 3144 | // ----- Packed data |
| 3145 | 3145 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
|
@@ -3168,7 +3168,7 @@ discard block |
||
| 3168 | 3168 | // -------------------------------------------------------------------------------- |
| 3169 | 3169 | function privList(&$p_list) |
| 3170 | 3170 | {
|
| 3171 | - $v_result=1; |
|
| 3171 | + $v_result = 1; |
|
| 3172 | 3172 | |
| 3173 | 3173 | // ----- Magic quotes trick |
| 3174 | 3174 | $this->privDisableMagicQuotes(); |
@@ -3208,7 +3208,7 @@ discard block |
||
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | // ----- Read each entry |
| 3211 | - for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3211 | + for ($i = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3212 | 3212 | {
|
| 3213 | 3213 | // ----- Read the file header |
| 3214 | 3214 | if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
@@ -3255,7 +3255,7 @@ discard block |
||
| 3255 | 3255 | // -------------------------------------------------------------------------------- |
| 3256 | 3256 | function privConvertHeader2FileInfo($p_header, &$p_info) |
| 3257 | 3257 | {
|
| 3258 | - $v_result=1; |
|
| 3258 | + $v_result = 1; |
|
| 3259 | 3259 | |
| 3260 | 3260 | // ----- Get the interesting attributes |
| 3261 | 3261 | $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
@@ -3266,7 +3266,7 @@ discard block |
||
| 3266 | 3266 | $p_info['compressed_size'] = $p_header['compressed_size']; |
| 3267 | 3267 | $p_info['mtime'] = $p_header['mtime']; |
| 3268 | 3268 | $p_info['comment'] = $p_header['comment']; |
| 3269 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3269 | + $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010); |
|
| 3270 | 3270 | $p_info['index'] = $p_header['index']; |
| 3271 | 3271 | $p_info['status'] = $p_header['status']; |
| 3272 | 3272 | $p_info['crc'] = $p_header['crc']; |
@@ -3294,16 +3294,16 @@ discard block |
||
| 3294 | 3294 | // -------------------------------------------------------------------------------- |
| 3295 | 3295 | function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3296 | 3296 | {
|
| 3297 | - $v_result=1; |
|
| 3297 | + $v_result = 1; |
|
| 3298 | 3298 | |
| 3299 | 3299 | // ----- Magic quotes trick |
| 3300 | 3300 | $this->privDisableMagicQuotes(); |
| 3301 | 3301 | |
| 3302 | 3302 | // ----- Check the path |
| 3303 | - if ( ($p_path == "") |
|
| 3304 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3303 | + if (($p_path == "") |
|
| 3304 | + || ((substr($p_path, 0, 1) != "/") |
|
| 3305 | 3305 | && (substr($p_path, 0, 3) != "../") |
| 3306 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3306 | + && (substr($p_path, 1, 2) != ":/"))) |
|
| 3307 | 3307 | $p_path = "./".$p_path; |
| 3308 | 3308 | |
| 3309 | 3309 | // ----- Reduce the path last (and duplicated) '/' |
@@ -3312,7 +3312,7 @@ discard block |
||
| 3312 | 3312 | // ----- Look for the path end '/' |
| 3313 | 3313 | while (substr($p_path, -1) == "/") |
| 3314 | 3314 | {
|
| 3315 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3315 | + $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
| 3316 | 3316 | } |
| 3317 | 3317 | } |
| 3318 | 3318 | |
@@ -3346,7 +3346,7 @@ discard block |
||
| 3346 | 3346 | |
| 3347 | 3347 | // ----- Read each entry |
| 3348 | 3348 | $j_start = 0; |
| 3349 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3349 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3350 | 3350 | {
|
| 3351 | 3351 | |
| 3352 | 3352 | // ----- Read next Central dir entry |
@@ -3385,17 +3385,17 @@ discard block |
||
| 3385 | 3385 | $v_extract = false; |
| 3386 | 3386 | |
| 3387 | 3387 | // ----- Look for extract by name rule |
| 3388 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3388 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3389 | 3389 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
| 3390 | 3390 | |
| 3391 | 3391 | // ----- Look if the filename is in the list |
| 3392 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
|
|
| 3392 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
|
|
| 3393 | 3393 | |
| 3394 | 3394 | // ----- Look for a directory |
| 3395 | 3395 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
| 3396 | 3396 | |
| 3397 | 3397 | // ----- Look if the directory is in the filename path |
| 3398 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3398 | + if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3399 | 3399 | && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 3400 | 3400 | $v_extract = true; |
| 3401 | 3401 | } |
@@ -3420,7 +3420,7 @@ discard block |
||
| 3420 | 3420 | */ |
| 3421 | 3421 | |
| 3422 | 3422 | // ----- Look for extract by preg rule |
| 3423 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3423 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3424 | 3424 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
| 3425 | 3425 | |
| 3426 | 3426 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
|
@@ -3429,20 +3429,20 @@ discard block |
||
| 3429 | 3429 | } |
| 3430 | 3430 | |
| 3431 | 3431 | // ----- Look for extract by index rule |
| 3432 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3432 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3433 | 3433 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
| 3434 | 3434 | |
| 3435 | 3435 | // ----- Look if the index is in the list |
| 3436 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
|
|
| 3436 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
|
|
| 3437 | 3437 | |
| 3438 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 3438 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 3439 | 3439 | $v_extract = true; |
| 3440 | 3440 | } |
| 3441 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 3442 | - $j_start = $j+1; |
|
| 3441 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 3442 | + $j_start = $j + 1; |
|
| 3443 | 3443 | } |
| 3444 | 3444 | |
| 3445 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 3445 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
|
|
| 3446 | 3446 | break; |
| 3447 | 3447 | } |
| 3448 | 3448 | } |
@@ -3454,14 +3454,14 @@ discard block |
||
| 3454 | 3454 | } |
| 3455 | 3455 | |
| 3456 | 3456 | // ----- Check compression method |
| 3457 | - if ( ($v_extract) |
|
| 3458 | - && ( ($v_header['compression'] != 8) |
|
| 3457 | + if (($v_extract) |
|
| 3458 | + && (($v_header['compression'] != 8) |
|
| 3459 | 3459 | && ($v_header['compression'] != 0))) {
|
| 3460 | 3460 | $v_header['status'] = 'unsupported_compression'; |
| 3461 | 3461 | |
| 3462 | 3462 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3463 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3464 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3463 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3464 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
|
| 3465 | 3465 | |
| 3466 | 3466 | $this->privSwapBackMagicQuotes(); |
| 3467 | 3467 | |
@@ -3479,8 +3479,8 @@ discard block |
||
| 3479 | 3479 | $v_header['status'] = 'unsupported_encryption'; |
| 3480 | 3480 | |
| 3481 | 3481 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3482 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3483 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3482 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3483 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
|
| 3484 | 3484 | |
| 3485 | 3485 | $this->privSwapBackMagicQuotes(); |
| 3486 | 3486 | |
@@ -3561,7 +3561,7 @@ discard block |
||
| 3561 | 3561 | } |
| 3562 | 3562 | } |
| 3563 | 3563 | // ----- Look for extraction in standard output |
| 3564 | - elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3564 | + elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3565 | 3565 | && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
|
| 3566 | 3566 | // ----- Extracting the file in standard output |
| 3567 | 3567 | $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
@@ -3634,7 +3634,7 @@ discard block |
||
| 3634 | 3634 | // -------------------------------------------------------------------------------- |
| 3635 | 3635 | function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3636 | 3636 | {
|
| 3637 | - $v_result=1; |
|
| 3637 | + $v_result = 1; |
|
| 3638 | 3638 | |
| 3639 | 3639 | // ----- Read the file header |
| 3640 | 3640 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
@@ -3652,7 +3652,7 @@ discard block |
||
| 3652 | 3652 | // ----- Look for all path to remove |
| 3653 | 3653 | if ($p_remove_all_path == true) {
|
| 3654 | 3654 | // ----- Look for folder entry that not need to be extracted |
| 3655 | - if (($p_entry['external']&0x00000010)==0x00000010) {
|
|
| 3655 | + if (($p_entry['external'] & 0x00000010) == 0x00000010) {
|
|
| 3656 | 3656 | |
| 3657 | 3657 | $p_entry['status'] = "filtered"; |
| 3658 | 3658 | |
@@ -3754,8 +3754,8 @@ discard block |
||
| 3754 | 3754 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3755 | 3755 | // For historical reason first PclZip implementation does not stop |
| 3756 | 3756 | // when this kind of error occurs. |
| 3757 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3758 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3757 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3758 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
|
| 3759 | 3759 | |
| 3760 | 3760 | PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
| 3761 | 3761 | "Filename '".$p_entry['filename']."' is " |
@@ -3774,8 +3774,8 @@ discard block |
||
| 3774 | 3774 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3775 | 3775 | // For historical reason first PclZip implementation does not stop |
| 3776 | 3776 | // when this kind of error occurs. |
| 3777 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3778 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3777 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3778 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
|
| 3779 | 3779 | |
| 3780 | 3780 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3781 | 3781 | "Filename '".$p_entry['filename']."' exists " |
@@ -3789,8 +3789,8 @@ discard block |
||
| 3789 | 3789 | else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
| 3790 | 3790 | {
|
| 3791 | 3791 | // ----- Change the file status |
| 3792 | - if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3793 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
|
|
| 3792 | + if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3793 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) {
|
|
| 3794 | 3794 | } |
| 3795 | 3795 | else {
|
| 3796 | 3796 | $p_entry['status'] = "newer_exist"; |
@@ -3798,8 +3798,8 @@ discard block |
||
| 3798 | 3798 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3799 | 3799 | // For historical reason first PclZip implementation does not stop |
| 3800 | 3800 | // when this kind of error occurs. |
| 3801 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3802 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3801 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3802 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
|
| 3803 | 3803 | |
| 3804 | 3804 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3805 | 3805 | "Newer version of '".$p_entry['filename']."' exists " |
@@ -3815,14 +3815,14 @@ discard block |
||
| 3815 | 3815 | |
| 3816 | 3816 | // ----- Check the directory availability and create it if necessary |
| 3817 | 3817 | else {
|
| 3818 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3818 | + if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3819 | 3819 | $v_dir_to_check = $p_entry['filename']; |
| 3820 | 3820 | else if (!strstr($p_entry['filename'], "/")) |
| 3821 | 3821 | $v_dir_to_check = ""; |
| 3822 | 3822 | else |
| 3823 | 3823 | $v_dir_to_check = dirname($p_entry['filename']); |
| 3824 | 3824 | |
| 3825 | - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
|
|
| 3825 | + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) {
|
|
| 3826 | 3826 | |
| 3827 | 3827 | // ----- Change the file status |
| 3828 | 3828 | $p_entry['status'] = "path_creation_fail"; |
@@ -3838,7 +3838,7 @@ discard block |
||
| 3838 | 3838 | if ($p_entry['status'] == 'ok') {
|
| 3839 | 3839 | |
| 3840 | 3840 | // ----- Do the extraction (if not a folder) |
| 3841 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3841 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) |
|
| 3842 | 3842 | {
|
| 3843 | 3843 | // ----- Look for not compressed file |
| 3844 | 3844 | if ($p_entry['compression'] == 0) {
|
@@ -3887,10 +3887,10 @@ discard block |
||
| 3887 | 3887 | |
| 3888 | 3888 | |
| 3889 | 3889 | // ----- Look for using temporary file to unzip |
| 3890 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3890 | + if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3891 | 3891 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 3892 | 3892 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 3893 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
|
|
| 3893 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) {
|
|
| 3894 | 3894 | $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
| 3895 | 3895 | if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
| 3896 | 3896 | return $v_result; |
@@ -3985,7 +3985,7 @@ discard block |
||
| 3985 | 3985 | // -------------------------------------------------------------------------------- |
| 3986 | 3986 | function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
| 3987 | 3987 | {
|
| 3988 | - $v_result=1; |
|
| 3988 | + $v_result = 1; |
|
| 3989 | 3989 | |
| 3990 | 3990 | // ----- Creates a temporary file |
| 3991 | 3991 | $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
|
@@ -4061,7 +4061,7 @@ discard block |
||
| 4061 | 4061 | // -------------------------------------------------------------------------------- |
| 4062 | 4062 | function privExtractFileInOutput(&$p_entry, &$p_options) |
| 4063 | 4063 | {
|
| 4064 | - $v_result=1; |
|
| 4064 | + $v_result = 1; |
|
| 4065 | 4065 | |
| 4066 | 4066 | // ----- Read the file header |
| 4067 | 4067 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
|
@@ -4110,7 +4110,7 @@ discard block |
||
| 4110 | 4110 | if ($p_entry['status'] == 'ok') {
|
| 4111 | 4111 | |
| 4112 | 4112 | // ----- Do the extraction (if not a folder) |
| 4113 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4113 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
|
|
| 4114 | 4114 | // ----- Look for not compressed file |
| 4115 | 4115 | if ($p_entry['compressed_size'] == $p_entry['size']) {
|
| 4116 | 4116 | |
@@ -4173,7 +4173,7 @@ discard block |
||
| 4173 | 4173 | // -------------------------------------------------------------------------------- |
| 4174 | 4174 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4175 | 4175 | {
|
| 4176 | - $v_result=1; |
|
| 4176 | + $v_result = 1; |
|
| 4177 | 4177 | |
| 4178 | 4178 | // ----- Read the file header |
| 4179 | 4179 | $v_header = array(); |
@@ -4224,7 +4224,7 @@ discard block |
||
| 4224 | 4224 | if ($p_entry['status'] == 'ok') {
|
| 4225 | 4225 | |
| 4226 | 4226 | // ----- Do the extraction (if not a folder) |
| 4227 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4227 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
|
|
| 4228 | 4228 | // ----- Look for not compressed file |
| 4229 | 4229 | // if ($p_entry['compressed_size'] == $p_entry['size']) |
| 4230 | 4230 | if ($p_entry['compression'] == 0) {
|
@@ -4296,7 +4296,7 @@ discard block |
||
| 4296 | 4296 | // -------------------------------------------------------------------------------- |
| 4297 | 4297 | function privReadFileHeader(&$p_header) |
| 4298 | 4298 | {
|
| 4299 | - $v_result=1; |
|
| 4299 | + $v_result = 1; |
|
| 4300 | 4300 | |
| 4301 | 4301 | // ----- Read the 4 bytes signature |
| 4302 | 4302 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4360,7 +4360,7 @@ discard block |
||
| 4360 | 4360 | // ----- Extract time |
| 4361 | 4361 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4362 | 4362 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4363 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4363 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4364 | 4364 | |
| 4365 | 4365 | // ----- Extract date |
| 4366 | 4366 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4399,7 +4399,7 @@ discard block |
||
| 4399 | 4399 | // -------------------------------------------------------------------------------- |
| 4400 | 4400 | function privReadCentralFileHeader(&$p_header) |
| 4401 | 4401 | {
|
| 4402 | - $v_result=1; |
|
| 4402 | + $v_result = 1; |
|
| 4403 | 4403 | |
| 4404 | 4404 | // ----- Read the 4 bytes signature |
| 4405 | 4405 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4470,7 +4470,7 @@ discard block |
||
| 4470 | 4470 | // ----- Extract time |
| 4471 | 4471 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4472 | 4472 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4473 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4473 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4474 | 4474 | |
| 4475 | 4475 | // ----- Extract date |
| 4476 | 4476 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4514,7 +4514,7 @@ discard block |
||
| 4514 | 4514 | // -------------------------------------------------------------------------------- |
| 4515 | 4515 | function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
| 4516 | 4516 | {
|
| 4517 | - $v_result=1; |
|
| 4517 | + $v_result = 1; |
|
| 4518 | 4518 | |
| 4519 | 4519 | // ----- Check the static values |
| 4520 | 4520 | // TBC |
@@ -4551,7 +4551,7 @@ discard block |
||
| 4551 | 4551 | // -------------------------------------------------------------------------------- |
| 4552 | 4552 | function privReadEndCentralDir(&$p_central_dir) |
| 4553 | 4553 | {
|
| 4554 | - $v_result=1; |
|
| 4554 | + $v_result = 1; |
|
| 4555 | 4555 | |
| 4556 | 4556 | // ----- Go to the end of the zip file |
| 4557 | 4557 | $v_size = filesize($this->zipname); |
@@ -4569,8 +4569,8 @@ discard block |
||
| 4569 | 4569 | // in this case the end of central dir is at 22 bytes of the file end |
| 4570 | 4570 | $v_found = 0; |
| 4571 | 4571 | if ($v_size > 26) {
|
| 4572 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4573 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4572 | + @fseek($this->zip_fd, $v_size - 22); |
|
| 4573 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22)) |
|
| 4574 | 4574 | {
|
| 4575 | 4575 | // ----- Error log |
| 4576 | 4576 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
@@ -4596,8 +4596,8 @@ discard block |
||
| 4596 | 4596 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4597 | 4597 | if ($v_maximum_size > $v_size) |
| 4598 | 4598 | $v_maximum_size = $v_size; |
| 4599 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4600 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4599 | + @fseek($this->zip_fd, $v_size - $v_maximum_size); |
|
| 4600 | + if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size)) |
|
| 4601 | 4601 | {
|
| 4602 | 4602 | // ----- Error log |
| 4603 | 4603 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
@@ -4618,7 +4618,7 @@ discard block |
||
| 4618 | 4618 | //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
| 4619 | 4619 | // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
| 4620 | 4620 | // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
| 4621 | - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4621 | + $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4622 | 4622 | |
| 4623 | 4623 | // ----- Compare the bytes |
| 4624 | 4624 | if ($v_bytes == 0x504b0506) |
@@ -4708,11 +4708,11 @@ discard block |
||
| 4708 | 4708 | // -------------------------------------------------------------------------------- |
| 4709 | 4709 | function privDeleteByRule(&$p_result_list, &$p_options) |
| 4710 | 4710 | {
|
| 4711 | - $v_result=1; |
|
| 4711 | + $v_result = 1; |
|
| 4712 | 4712 | $v_list_detail = array(); |
| 4713 | 4713 | |
| 4714 | 4714 | // ----- Open the zip file |
| 4715 | - if (($v_result=$this->privOpenFd('rb')) != 1)
|
|
| 4715 | + if (($v_result = $this->privOpenFd('rb')) != 1)
|
|
| 4716 | 4716 | {
|
| 4717 | 4717 | // ----- Return |
| 4718 | 4718 | return $v_result; |
@@ -4748,7 +4748,7 @@ discard block |
||
| 4748 | 4748 | // ----- Read each entry |
| 4749 | 4749 | $v_header_list = array(); |
| 4750 | 4750 | $j_start = 0; |
| 4751 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4751 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 4752 | 4752 | {
|
| 4753 | 4753 | |
| 4754 | 4754 | // ----- Read the file header |
@@ -4769,21 +4769,21 @@ discard block |
||
| 4769 | 4769 | $v_found = false; |
| 4770 | 4770 | |
| 4771 | 4771 | // ----- Look for extract by name rule |
| 4772 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4772 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4773 | 4773 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
| 4774 | 4774 | |
| 4775 | 4775 | // ----- Look if the filename is in the list |
| 4776 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
|
|
| 4776 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
|
|
| 4777 | 4777 | |
| 4778 | 4778 | // ----- Look for a directory |
| 4779 | 4779 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
| 4780 | 4780 | |
| 4781 | 4781 | // ----- Look if the directory is in the filename path |
| 4782 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4782 | + if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4783 | 4783 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4784 | 4784 | $v_found = true; |
| 4785 | 4785 | } |
| 4786 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4786 | + elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */ |
|
| 4787 | 4787 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4788 | 4788 | $v_found = true; |
| 4789 | 4789 | } |
@@ -4808,7 +4808,7 @@ discard block |
||
| 4808 | 4808 | */ |
| 4809 | 4809 | |
| 4810 | 4810 | // ----- Look for extract by preg rule |
| 4811 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4811 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4812 | 4812 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
| 4813 | 4813 | |
| 4814 | 4814 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
@@ -4817,20 +4817,20 @@ discard block |
||
| 4817 | 4817 | } |
| 4818 | 4818 | |
| 4819 | 4819 | // ----- Look for extract by index rule |
| 4820 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4820 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4821 | 4821 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
| 4822 | 4822 | |
| 4823 | 4823 | // ----- Look if the index is in the list |
| 4824 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
|
|
| 4824 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
|
|
| 4825 | 4825 | |
| 4826 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 4826 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 4827 | 4827 | $v_found = true; |
| 4828 | 4828 | } |
| 4829 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 4830 | - $j_start = $j+1; |
|
| 4829 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 4830 | + $j_start = $j + 1; |
|
| 4831 | 4831 | } |
| 4832 | 4832 | |
| 4833 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 4833 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
|
|
| 4834 | 4834 | break; |
| 4835 | 4835 | } |
| 4836 | 4836 | } |
@@ -4868,11 +4868,11 @@ discard block |
||
| 4868 | 4868 | } |
| 4869 | 4869 | |
| 4870 | 4870 | // ----- Look which file need to be kept |
| 4871 | - for ($i=0; $i<sizeof($v_header_list); $i++) {
|
|
| 4871 | + for ($i = 0; $i < sizeof($v_header_list); $i++) {
|
|
| 4872 | 4872 | |
| 4873 | 4873 | // ----- Calculate the position of the header |
| 4874 | 4874 | @rewind($this->zip_fd); |
| 4875 | - if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
|
|
| 4875 | + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
|
|
| 4876 | 4876 | // ----- Close the zip file |
| 4877 | 4877 | $this->privCloseFd(); |
| 4878 | 4878 | $v_temp_zip->privCloseFd(); |
@@ -4931,7 +4931,7 @@ discard block |
||
| 4931 | 4931 | $v_offset = @ftell($v_temp_zip->zip_fd); |
| 4932 | 4932 | |
| 4933 | 4933 | // ----- Re-Create the Central Dir files header |
| 4934 | - for ($i=0; $i<sizeof($v_header_list); $i++) {
|
|
| 4934 | + for ($i = 0; $i < sizeof($v_header_list); $i++) {
|
|
| 4935 | 4935 | // ----- Create the file header |
| 4936 | 4936 | if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
| 4937 | 4937 | $v_temp_zip->privCloseFd(); |
@@ -4954,7 +4954,7 @@ discard block |
||
| 4954 | 4954 | } |
| 4955 | 4955 | |
| 4956 | 4956 | // ----- Calculate the size of the central header |
| 4957 | - $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4957 | + $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset; |
|
| 4958 | 4958 | |
| 4959 | 4959 | // ----- Create the central dir footer |
| 4960 | 4960 | if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
|
@@ -5016,15 +5016,15 @@ discard block |
||
| 5016 | 5016 | // 1 : OK |
| 5017 | 5017 | // -1 : Unable to create directory |
| 5018 | 5018 | // -------------------------------------------------------------------------------- |
| 5019 | - function privDirCheck($p_dir, $p_is_dir=false) |
|
| 5019 | + function privDirCheck($p_dir, $p_is_dir = false) |
|
| 5020 | 5020 | {
|
| 5021 | 5021 | $v_result = 1; |
| 5022 | 5022 | |
| 5023 | 5023 | |
| 5024 | 5024 | // ----- Remove the final '/' |
| 5025 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 5025 | + if (($p_is_dir) && (substr($p_dir, -1) == '/')) |
|
| 5026 | 5026 | {
|
| 5027 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5027 | + $p_dir = substr($p_dir, 0, strlen($p_dir) - 1); |
|
| 5028 | 5028 | } |
| 5029 | 5029 | |
| 5030 | 5030 | // ----- Check the directory availability |
@@ -5073,7 +5073,7 @@ discard block |
||
| 5073 | 5073 | // -------------------------------------------------------------------------------- |
| 5074 | 5074 | function privMerge(&$p_archive_to_add) |
| 5075 | 5075 | {
|
| 5076 | - $v_result=1; |
|
| 5076 | + $v_result = 1; |
|
| 5077 | 5077 | |
| 5078 | 5078 | // ----- Look if the archive_to_add exists |
| 5079 | 5079 | if (!is_file($p_archive_to_add->zipname)) |
@@ -5098,7 +5098,7 @@ discard block |
||
| 5098 | 5098 | } |
| 5099 | 5099 | |
| 5100 | 5100 | // ----- Open the zip file |
| 5101 | - if (($v_result=$this->privOpenFd('rb')) != 1)
|
|
| 5101 | + if (($v_result = $this->privOpenFd('rb')) != 1)
|
|
| 5102 | 5102 | {
|
| 5103 | 5103 | // ----- Return |
| 5104 | 5104 | return $v_result; |
@@ -5116,7 +5116,7 @@ discard block |
||
| 5116 | 5116 | @rewind($this->zip_fd); |
| 5117 | 5117 | |
| 5118 | 5118 | // ----- Open the archive_to_add file |
| 5119 | - if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
|
|
| 5119 | + if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1)
|
|
| 5120 | 5120 | {
|
| 5121 | 5121 | $this->privCloseFd(); |
| 5122 | 5122 | |
@@ -5200,7 +5200,7 @@ discard block |
||
| 5200 | 5200 | $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
| 5201 | 5201 | |
| 5202 | 5202 | // ----- Calculate the size of the (new) central header |
| 5203 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5203 | + $v_size = @ftell($v_zip_temp_fd) - $v_offset; |
|
| 5204 | 5204 | |
| 5205 | 5205 | // ----- Swap the file descriptor |
| 5206 | 5206 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
@@ -5210,7 +5210,7 @@ discard block |
||
| 5210 | 5210 | $v_zip_temp_fd = $v_swap; |
| 5211 | 5211 | |
| 5212 | 5212 | // ----- Create the central dir footer |
| 5213 | - if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5213 | + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5214 | 5214 | {
|
| 5215 | 5215 | $this->privCloseFd(); |
| 5216 | 5216 | $p_archive_to_add->privCloseFd(); |
@@ -5258,7 +5258,7 @@ discard block |
||
| 5258 | 5258 | // -------------------------------------------------------------------------------- |
| 5259 | 5259 | function privDuplicate($p_archive_filename) |
| 5260 | 5260 | {
|
| 5261 | - $v_result=1; |
|
| 5261 | + $v_result = 1; |
|
| 5262 | 5262 | |
| 5263 | 5263 | // ----- Look if the $p_archive_filename exists |
| 5264 | 5264 | if (!is_file($p_archive_filename)) |
@@ -5272,7 +5272,7 @@ discard block |
||
| 5272 | 5272 | } |
| 5273 | 5273 | |
| 5274 | 5274 | // ----- Open the zip file |
| 5275 | - if (($v_result=$this->privOpenFd('wb')) != 1)
|
|
| 5275 | + if (($v_result = $this->privOpenFd('wb')) != 1)
|
|
| 5276 | 5276 | {
|
| 5277 | 5277 | // ----- Return |
| 5278 | 5278 | return $v_result; |
@@ -5316,7 +5316,7 @@ discard block |
||
| 5316 | 5316 | // Description : |
| 5317 | 5317 | // Parameters : |
| 5318 | 5318 | // -------------------------------------------------------------------------------- |
| 5319 | - function privErrorLog($p_error_code=0, $p_error_string='') |
|
| 5319 | + function privErrorLog($p_error_code = 0, $p_error_string = '') |
|
| 5320 | 5320 | {
|
| 5321 | 5321 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 5322 | 5322 | PclError($p_error_code, $p_error_string); |
@@ -5353,10 +5353,10 @@ discard block |
||
| 5353 | 5353 | // -------------------------------------------------------------------------------- |
| 5354 | 5354 | function privDisableMagicQuotes() |
| 5355 | 5355 | {
|
| 5356 | - $v_result=1; |
|
| 5356 | + $v_result = 1; |
|
| 5357 | 5357 | |
| 5358 | 5358 | // ----- Look if function exists |
| 5359 | - if ( (!function_exists("get_magic_quotes_runtime"))
|
|
| 5359 | + if ((!function_exists("get_magic_quotes_runtime"))
|
|
| 5360 | 5360 | || (!function_exists("set_magic_quotes_runtime"))) {
|
| 5361 | 5361 | return $v_result; |
| 5362 | 5362 | } |
@@ -5387,10 +5387,10 @@ discard block |
||
| 5387 | 5387 | // -------------------------------------------------------------------------------- |
| 5388 | 5388 | function privSwapBackMagicQuotes() |
| 5389 | 5389 | {
|
| 5390 | - $v_result=1; |
|
| 5390 | + $v_result = 1; |
|
| 5391 | 5391 | |
| 5392 | 5392 | // ----- Look if function exists |
| 5393 | - if ( (!function_exists("get_magic_quotes_runtime"))
|
|
| 5393 | + if ((!function_exists("get_magic_quotes_runtime"))
|
|
| 5394 | 5394 | || (!function_exists("set_magic_quotes_runtime"))) {
|
| 5395 | 5395 | return $v_result; |
| 5396 | 5396 | } |
@@ -5431,7 +5431,7 @@ discard block |
||
| 5431 | 5431 | |
| 5432 | 5432 | // ----- Study directories from last to first |
| 5433 | 5433 | $v_skip = 0; |
| 5434 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) {
|
|
| 5434 | + for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
|
|
| 5435 | 5435 | // ----- Look for current path |
| 5436 | 5436 | if ($v_list[$i] == ".") {
|
| 5437 | 5437 | // ----- Ignore this directory |
@@ -5452,7 +5452,7 @@ discard block |
||
| 5452 | 5452 | } |
| 5453 | 5453 | } |
| 5454 | 5454 | // ----- Last '/' i.e. indicates a directory |
| 5455 | - else if ($i == (sizeof($v_list)-1)) {
|
|
| 5455 | + else if ($i == (sizeof($v_list) - 1)) {
|
|
| 5456 | 5456 | $v_result = $v_list[$i]; |
| 5457 | 5457 | } |
| 5458 | 5458 | // ----- Double '/' inside the path |
@@ -5467,7 +5467,7 @@ discard block |
||
| 5467 | 5467 | $v_skip--; |
| 5468 | 5468 | } |
| 5469 | 5469 | else {
|
| 5470 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5470 | + $v_result = $v_list[$i].($i != (sizeof($v_list) - 1) ? "/".$v_result : ""); |
|
| 5471 | 5471 | } |
| 5472 | 5472 | } |
| 5473 | 5473 | } |
@@ -5506,12 +5506,12 @@ discard block |
||
| 5506 | 5506 | $v_result = 1; |
| 5507 | 5507 | |
| 5508 | 5508 | // ----- Look for path beginning by ./ |
| 5509 | - if ( ($p_dir == '.') |
|
| 5510 | - || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
|
|
| 5509 | + if (($p_dir == '.') |
|
| 5510 | + || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) {
|
|
| 5511 | 5511 | $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
| 5512 | 5512 | } |
| 5513 | - if ( ($p_path == '.') |
|
| 5514 | - || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
|
|
| 5513 | + if (($p_path == '.') |
|
| 5514 | + || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) {
|
|
| 5515 | 5515 | $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
| 5516 | 5516 | } |
| 5517 | 5517 | |
@@ -5537,7 +5537,7 @@ discard block |
||
| 5537 | 5537 | } |
| 5538 | 5538 | |
| 5539 | 5539 | // ----- Compare the items |
| 5540 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
|
|
| 5540 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
|
|
| 5541 | 5541 | $v_result = 0; |
| 5542 | 5542 | } |
| 5543 | 5543 | |
@@ -5578,11 +5578,11 @@ discard block |
||
| 5578 | 5578 | // 3 : src & dest gzip |
| 5579 | 5579 | // Return Values : |
| 5580 | 5580 | // -------------------------------------------------------------------------------- |
| 5581 | - function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 5581 | + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0) |
|
| 5582 | 5582 | {
|
| 5583 | 5583 | $v_result = 1; |
| 5584 | 5584 | |
| 5585 | - if ($p_mode==0) |
|
| 5585 | + if ($p_mode == 0) |
|
| 5586 | 5586 | {
|
| 5587 | 5587 | while ($p_size != 0) |
| 5588 | 5588 | {
|
@@ -5592,7 +5592,7 @@ discard block |
||
| 5592 | 5592 | $p_size -= $v_read_size; |
| 5593 | 5593 | } |
| 5594 | 5594 | } |
| 5595 | - else if ($p_mode==1) |
|
| 5595 | + else if ($p_mode == 1) |
|
| 5596 | 5596 | {
|
| 5597 | 5597 | while ($p_size != 0) |
| 5598 | 5598 | {
|
@@ -5602,7 +5602,7 @@ discard block |
||
| 5602 | 5602 | $p_size -= $v_read_size; |
| 5603 | 5603 | } |
| 5604 | 5604 | } |
| 5605 | - else if ($p_mode==2) |
|
| 5605 | + else if ($p_mode == 2) |
|
| 5606 | 5606 | {
|
| 5607 | 5607 | while ($p_size != 0) |
| 5608 | 5608 | {
|
@@ -5612,7 +5612,7 @@ discard block |
||
| 5612 | 5612 | $p_size -= $v_read_size; |
| 5613 | 5613 | } |
| 5614 | 5614 | } |
| 5615 | - else if ($p_mode==3) |
|
| 5615 | + else if ($p_mode == 3) |
|
| 5616 | 5616 | {
|
| 5617 | 5617 | while ($p_size != 0) |
| 5618 | 5618 | {
|
@@ -5676,7 +5676,7 @@ discard block |
||
| 5676 | 5676 | $v_list = get_defined_constants(); |
| 5677 | 5677 | for (reset($v_list); $v_key = key($v_list); next($v_list)) {
|
| 5678 | 5678 | $v_prefix = substr($v_key, 0, 10); |
| 5679 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5679 | + if ((($v_prefix == 'PCLZIP_OPT') |
|
| 5680 | 5680 | || ($v_prefix == 'PCLZIP_CB_') |
| 5681 | 5681 | || ($v_prefix == 'PCLZIP_ATT')) |
| 5682 | 5682 | && ($v_list[$v_key] == $p_option)) {
|
@@ -5701,15 +5701,15 @@ discard block |
||
| 5701 | 5701 | // Return Values : |
| 5702 | 5702 | // The path translated. |
| 5703 | 5703 | // -------------------------------------------------------------------------------- |
| 5704 | - function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 5704 | + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) |
|
| 5705 | 5705 | {
|
| 5706 | 5706 | if (stristr(php_uname(), 'windows')) {
|
| 5707 | 5707 | // ----- Look for potential disk letter |
| 5708 | 5708 | if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
|
| 5709 | - $p_path = substr($p_path, $v_position+1); |
|
| 5709 | + $p_path = substr($p_path, $v_position + 1); |
|
| 5710 | 5710 | } |
| 5711 | 5711 | // ----- Change potential windows directory separator |
| 5712 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
|
|
| 5712 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
|
|
| 5713 | 5713 | $p_path = strtr($p_path, '\\', '/'); |
| 5714 | 5714 | } |
| 5715 | 5715 | } |
@@ -344,8 +344,7 @@ discard block |
||
| 344 | 344 | // ----- Look for the optional second argument |
| 345 | 345 | if ($v_size == 2) {
|
| 346 | 346 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 347 | - } |
|
| 348 | - else if ($v_size > 2) {
|
|
| 347 | + } else if ($v_size > 2) {
|
|
| 349 | 348 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 350 | 349 | "Invalid number / type of arguments"); |
| 351 | 350 | return 0; |
@@ -394,8 +393,7 @@ discard block |
||
| 394 | 393 | foreach ($v_string_list as $v_string) {
|
| 395 | 394 | if ($v_string != '') {
|
| 396 | 395 | $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
| 397 | - } |
|
| 398 | - else {
|
|
| 396 | + } else {
|
|
| 399 | 397 | } |
| 400 | 398 | } |
| 401 | 399 | } |
@@ -529,8 +527,7 @@ discard block |
||
| 529 | 527 | // ----- Look for the optional second argument |
| 530 | 528 | if ($v_size == 2) {
|
| 531 | 529 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 532 | - } |
|
| 533 | - else if ($v_size > 2) {
|
|
| 530 | + } else if ($v_size > 2) {
|
|
| 534 | 531 | // ----- Error log |
| 535 | 532 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 536 | 533 | |
@@ -806,8 +803,7 @@ discard block |
||
| 806 | 803 | // ----- Look for the optional second argument |
| 807 | 804 | if ($v_size == 2) {
|
| 808 | 805 | $v_remove_path = $v_arg_list[1]; |
| 809 | - } |
|
| 810 | - else if ($v_size > 2) {
|
|
| 806 | + } else if ($v_size > 2) {
|
|
| 811 | 807 | // ----- Error log |
| 812 | 808 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 813 | 809 | |
@@ -951,8 +947,7 @@ discard block |
||
| 951 | 947 | } |
| 952 | 948 | if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
|
| 953 | 949 | $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
| 954 | - } |
|
| 955 | - else {
|
|
| 950 | + } else {
|
|
| 956 | 951 | } |
| 957 | 952 | } |
| 958 | 953 | |
@@ -967,8 +962,7 @@ discard block |
||
| 967 | 962 | // ----- Look for the optional second argument |
| 968 | 963 | if ($v_size == 2) {
|
| 969 | 964 | $v_remove_path = $v_arg_list[1]; |
| 970 | - } |
|
| 971 | - else if ($v_size > 2) {
|
|
| 965 | + } else if ($v_size > 2) {
|
|
| 972 | 966 | // ----- Error log |
| 973 | 967 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 974 | 968 | |
@@ -1204,8 +1198,7 @@ discard block |
||
| 1204 | 1198 | // ----- Error log |
| 1205 | 1199 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
| 1206 | 1200 | $v_result = PCLZIP_ERR_MISSING_FILE; |
| 1207 | - } |
|
| 1208 | - else {
|
|
| 1201 | + } else {
|
|
| 1209 | 1202 | // ----- Duplicate the archive |
| 1210 | 1203 | $v_result = $this->privDuplicate($p_archive); |
| 1211 | 1204 | } |
@@ -1293,8 +1286,7 @@ discard block |
||
| 1293 | 1286 | {
|
| 1294 | 1287 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 1295 | 1288 | return(PclErrorCode()); |
| 1296 | - } |
|
| 1297 | - else {
|
|
| 1289 | + } else {
|
|
| 1298 | 1290 | return($this->error_code); |
| 1299 | 1291 | } |
| 1300 | 1292 | } |
@@ -1332,15 +1324,13 @@ discard block |
||
| 1332 | 1324 | |
| 1333 | 1325 | if (isset($v_name[$this->error_code])) {
|
| 1334 | 1326 | $v_value = $v_name[$this->error_code]; |
| 1335 | - } |
|
| 1336 | - else {
|
|
| 1327 | + } else {
|
|
| 1337 | 1328 | $v_value = 'NoName'; |
| 1338 | 1329 | } |
| 1339 | 1330 | |
| 1340 | 1331 | if ($p_with_code) {
|
| 1341 | 1332 | return($v_value.' ('.$this->error_code.')');
|
| 1342 | - } |
|
| 1343 | - else {
|
|
| 1333 | + } else {
|
|
| 1344 | 1334 | return($v_value); |
| 1345 | 1335 | } |
| 1346 | 1336 | } |
@@ -1355,12 +1345,10 @@ discard block |
||
| 1355 | 1345 | {
|
| 1356 | 1346 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 1357 | 1347 | return(PclErrorString()); |
| 1358 | - } |
|
| 1359 | - else {
|
|
| 1348 | + } else {
|
|
| 1360 | 1349 | if ($p_full) {
|
| 1361 | 1350 | return($this->errorName(true)." : ".$this->error_string); |
| 1362 | - } |
|
| 1363 | - else {
|
|
| 1351 | + } else {
|
|
| 1364 | 1352 | return($this->error_string." [code ".$this->error_code."]"); |
| 1365 | 1353 | } |
| 1366 | 1354 | } |
@@ -1545,8 +1533,7 @@ discard block |
||
| 1545 | 1533 | && ($p_options_list[$i+1] != '')) {
|
| 1546 | 1534 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
| 1547 | 1535 | $i++; |
| 1548 | - } |
|
| 1549 | - else {
|
|
| 1536 | + } else {
|
|
| 1550 | 1537 | } |
| 1551 | 1538 | break; |
| 1552 | 1539 | |
@@ -1564,11 +1551,9 @@ discard block |
||
| 1564 | 1551 | // ----- Get the value |
| 1565 | 1552 | if (is_string($p_options_list[$i+1])) {
|
| 1566 | 1553 | $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
| 1567 | - } |
|
| 1568 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1554 | + } else if (is_array($p_options_list[$i+1])) {
|
|
| 1569 | 1555 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1570 | - } |
|
| 1571 | - else {
|
|
| 1556 | + } else {
|
|
| 1572 | 1557 | // ----- Error log |
| 1573 | 1558 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1574 | 1559 | |
@@ -1597,8 +1582,7 @@ discard block |
||
| 1597 | 1582 | // ----- Get the value |
| 1598 | 1583 | if (is_string($p_options_list[$i+1])) {
|
| 1599 | 1584 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1600 | - } |
|
| 1601 | - else {
|
|
| 1585 | + } else {
|
|
| 1602 | 1586 | // ----- Error log |
| 1603 | 1587 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1604 | 1588 | |
@@ -1627,8 +1611,7 @@ discard block |
||
| 1627 | 1611 | // ----- Get the value |
| 1628 | 1612 | if (is_string($p_options_list[$i+1])) {
|
| 1629 | 1613 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1630 | - } |
|
| 1631 | - else {
|
|
| 1614 | + } else {
|
|
| 1632 | 1615 | // ----- Error log |
| 1633 | 1616 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
| 1634 | 1617 | "Wrong parameter value for option '" |
@@ -1661,14 +1644,11 @@ discard block |
||
| 1661 | 1644 | |
| 1662 | 1645 | // ----- Parse items |
| 1663 | 1646 | $v_work_list = explode(",", $p_options_list[$i+1]);
|
| 1664 | - } |
|
| 1665 | - else if (is_integer($p_options_list[$i+1])) {
|
|
| 1647 | + } else if (is_integer($p_options_list[$i+1])) {
|
|
| 1666 | 1648 | $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
| 1667 | - } |
|
| 1668 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1649 | + } else if (is_array($p_options_list[$i+1])) {
|
|
| 1669 | 1650 | $v_work_list = $p_options_list[$i+1]; |
| 1670 | - } |
|
| 1671 | - else {
|
|
| 1651 | + } else {
|
|
| 1672 | 1652 | // ----- Error log |
| 1673 | 1653 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1674 | 1654 | |
@@ -1695,13 +1675,11 @@ discard block |
||
| 1695 | 1675 | // ----- Set the option value |
| 1696 | 1676 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1697 | 1677 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
| 1698 | - } |
|
| 1699 | - elseif ($v_size_item_list == 2) {
|
|
| 1678 | + } elseif ($v_size_item_list == 2) {
|
|
| 1700 | 1679 | // ----- Set the option value |
| 1701 | 1680 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1702 | 1681 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
| 1703 | - } |
|
| 1704 | - else {
|
|
| 1682 | + } else {
|
|
| 1705 | 1683 | // ----- Error log |
| 1706 | 1684 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1707 | 1685 | |
@@ -1857,14 +1835,17 @@ discard block |
||
| 1857 | 1835 | $v_memory_limit = trim($v_memory_limit); |
| 1858 | 1836 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1859 | 1837 | |
| 1860 | - if($last == 'g') |
|
| 1861 | - //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1862 | - $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1863 | - if($last == 'm') |
|
| 1864 | - //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1865 | - $v_memory_limit = $v_memory_limit*1048576; |
|
| 1866 | - if($last == 'k') |
|
| 1867 | - $v_memory_limit = $v_memory_limit*1024; |
|
| 1838 | + if($last == 'g') { |
|
| 1839 | + //$v_memory_limit = $v_memory_limit*1024*1024*1024; |
|
| 1840 | + $v_memory_limit = $v_memory_limit*1073741824; |
|
| 1841 | + } |
|
| 1842 | + if($last == 'm') { |
|
| 1843 | + //$v_memory_limit = $v_memory_limit*1024*1024; |
|
| 1844 | + $v_memory_limit = $v_memory_limit*1048576; |
|
| 1845 | + } |
|
| 1846 | + if($last == 'k') { |
|
| 1847 | + $v_memory_limit = $v_memory_limit*1024; |
|
| 1848 | + } |
|
| 1868 | 1849 | |
| 1869 | 1850 | $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); |
| 1870 | 1851 | |
@@ -2037,15 +2018,12 @@ discard block |
||
| 2037 | 2018 | if (file_exists($v_descr['filename'])) {
|
| 2038 | 2019 | if (@is_file($v_descr['filename'])) {
|
| 2039 | 2020 | $v_descr['type'] = 'file'; |
| 2040 | - } |
|
| 2041 | - else if (@is_dir($v_descr['filename'])) {
|
|
| 2021 | + } else if (@is_dir($v_descr['filename'])) {
|
|
| 2042 | 2022 | $v_descr['type'] = 'folder'; |
| 2043 | - } |
|
| 2044 | - else if (@is_link($v_descr['filename'])) {
|
|
| 2023 | + } else if (@is_link($v_descr['filename'])) {
|
|
| 2045 | 2024 | // skip |
| 2046 | 2025 | continue; |
| 2047 | - } |
|
| 2048 | - else {
|
|
| 2026 | + } else {
|
|
| 2049 | 2027 | // skip |
| 2050 | 2028 | continue; |
| 2051 | 2029 | } |
@@ -2094,8 +2072,7 @@ discard block |
||
| 2094 | 2072 | && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
|
| 2095 | 2073 | if ($v_descr['stored_filename'] != '') {
|
| 2096 | 2074 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2097 | - } |
|
| 2098 | - else {
|
|
| 2075 | + } else {
|
|
| 2099 | 2076 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
| 2100 | 2077 | } |
| 2101 | 2078 | } |
@@ -2104,8 +2081,7 @@ discard block |
||
| 2104 | 2081 | } |
| 2105 | 2082 | |
| 2106 | 2083 | @closedir($v_folder_handler); |
| 2107 | - } |
|
| 2108 | - else {
|
|
| 2084 | + } else {
|
|
| 2109 | 2085 | // TBC : unable to open folder in read mode |
| 2110 | 2086 | } |
| 2111 | 2087 | |
@@ -2118,8 +2094,7 @@ discard block |
||
| 2118 | 2094 | |
| 2119 | 2095 | // ----- Concat the resulting list |
| 2120 | 2096 | $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
| 2121 | - } |
|
| 2122 | - else {
|
|
| 2097 | + } else {
|
|
| 2123 | 2098 | } |
| 2124 | 2099 | |
| 2125 | 2100 | // ----- Free local array |
@@ -2393,8 +2368,9 @@ discard block |
||
| 2393 | 2368 | {
|
| 2394 | 2369 | $v_result=1; |
| 2395 | 2370 | |
| 2396 | - if ($this->zip_fd != 0) |
|
| 2397 | - @fclose($this->zip_fd); |
|
| 2371 | + if ($this->zip_fd != 0) { |
|
| 2372 | + @fclose($this->zip_fd); |
|
| 2373 | + } |
|
| 2398 | 2374 | $this->zip_fd = 0; |
| 2399 | 2375 | |
| 2400 | 2376 | // ----- Return |
@@ -2611,11 +2587,9 @@ discard block |
||
| 2611 | 2587 | // ----- Look for filetime |
| 2612 | 2588 | if (isset($p_filedescr['mtime'])) {
|
| 2613 | 2589 | $p_header['mtime'] = $p_filedescr['mtime']; |
| 2614 | - } |
|
| 2615 | - else if ($p_filedescr['type'] == 'virtual_file') {
|
|
| 2590 | + } else if ($p_filedescr['type'] == 'virtual_file') {
|
|
| 2616 | 2591 | $p_header['mtime'] = time(); |
| 2617 | - } |
|
| 2618 | - else {
|
|
| 2592 | + } else {
|
|
| 2619 | 2593 | $p_header['mtime'] = filemtime($p_filename); |
| 2620 | 2594 | } |
| 2621 | 2595 | |
@@ -2623,8 +2597,7 @@ discard block |
||
| 2623 | 2597 | if (isset($p_filedescr['comment'])) {
|
| 2624 | 2598 | $p_header['comment_len'] = strlen($p_filedescr['comment']); |
| 2625 | 2599 | $p_header['comment'] = $p_filedescr['comment']; |
| 2626 | - } |
|
| 2627 | - else {
|
|
| 2600 | + } else {
|
|
| 2628 | 2601 | $p_header['comment_len'] = 0; |
| 2629 | 2602 | $p_header['comment'] = ''; |
| 2630 | 2603 | } |
@@ -2935,20 +2908,17 @@ discard block |
||
| 2935 | 2908 | $p_filename = $p_filedescr['filename']; |
| 2936 | 2909 | if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
|
| 2937 | 2910 | $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
| 2938 | - } |
|
| 2939 | - else {
|
|
| 2911 | + } else {
|
|
| 2940 | 2912 | $p_add_dir = ''; |
| 2941 | 2913 | } |
| 2942 | 2914 | if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
|
| 2943 | 2915 | $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
| 2944 | - } |
|
| 2945 | - else {
|
|
| 2916 | + } else {
|
|
| 2946 | 2917 | $p_remove_dir = ''; |
| 2947 | 2918 | } |
| 2948 | 2919 | if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
| 2949 | 2920 | $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
| 2950 | - } |
|
| 2951 | - else {
|
|
| 2921 | + } else {
|
|
| 2952 | 2922 | $p_remove_all_dir = 0; |
| 2953 | 2923 | } |
| 2954 | 2924 | |
@@ -2971,8 +2941,7 @@ discard block |
||
| 2971 | 2941 | $v_dir = $v_path_info['dirname'].'/'; |
| 2972 | 2942 | } |
| 2973 | 2943 | $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
| 2974 | - } |
|
| 2975 | - else {
|
|
| 2944 | + } else {
|
|
| 2976 | 2945 | // ----- Calculate the stored filename |
| 2977 | 2946 | $v_stored_filename = $p_filename; |
| 2978 | 2947 | } |
@@ -2983,8 +2952,9 @@ discard block |
||
| 2983 | 2952 | } |
| 2984 | 2953 | // ----- Look for partial path remove |
| 2985 | 2954 | else if ($p_remove_dir != "") {
|
| 2986 | - if (substr($p_remove_dir, -1) != '/') |
|
| 2987 | - $p_remove_dir .= "/"; |
|
| 2955 | + if (substr($p_remove_dir, -1) != '/') { |
|
| 2956 | + $p_remove_dir .= "/"; |
|
| 2957 | + } |
|
| 2988 | 2958 | |
| 2989 | 2959 | if ( (substr($p_filename, 0, 2) == "./") |
| 2990 | 2960 | || (substr($p_remove_dir, 0, 2) == "./")) {
|
@@ -3004,8 +2974,7 @@ discard block |
||
| 3004 | 2974 | if ($v_compare > 0) {
|
| 3005 | 2975 | if ($v_compare == 2) {
|
| 3006 | 2976 | $v_stored_filename = ""; |
| 3007 | - } |
|
| 3008 | - else {
|
|
| 2977 | + } else {
|
|
| 3009 | 2978 | $v_stored_filename = substr($v_stored_filename, |
| 3010 | 2979 | strlen($p_remove_dir)); |
| 3011 | 2980 | } |
@@ -3017,10 +2986,11 @@ discard block |
||
| 3017 | 2986 | |
| 3018 | 2987 | // ----- Look for path to add |
| 3019 | 2988 | if ($p_add_dir != "") {
|
| 3020 | - if (substr($p_add_dir, -1) == "/") |
|
| 3021 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3022 | - else |
|
| 3023 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2989 | + if (substr($p_add_dir, -1) == "/") { |
|
| 2990 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 2991 | + } else { |
|
| 2992 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2993 | + } |
|
| 3024 | 2994 | } |
| 3025 | 2995 | } |
| 3026 | 2996 | |
@@ -3303,8 +3273,9 @@ discard block |
||
| 3303 | 3273 | if ( ($p_path == "") |
| 3304 | 3274 | || ( (substr($p_path, 0, 1) != "/") |
| 3305 | 3275 | && (substr($p_path, 0, 3) != "../") |
| 3306 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3307 | - $p_path = "./".$p_path; |
|
| 3276 | + && (substr($p_path,1,2)!=":/"))) { |
|
| 3277 | + $p_path = "./".$p_path; |
|
| 3278 | + } |
|
| 3308 | 3279 | |
| 3309 | 3280 | // ----- Reduce the path last (and duplicated) '/' |
| 3310 | 3281 | if (($p_path != "./") && ($p_path != "/")) |
@@ -3791,8 +3762,7 @@ discard block |
||
| 3791 | 3762 | // ----- Change the file status |
| 3792 | 3763 | if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
| 3793 | 3764 | && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
|
| 3794 | - } |
|
| 3795 | - else {
|
|
| 3765 | + } else {
|
|
| 3796 | 3766 | $p_entry['status'] = "newer_exist"; |
| 3797 | 3767 | |
| 3798 | 3768 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
@@ -3808,19 +3778,19 @@ discard block |
||
| 3808 | 3778 | return PclZip::errorCode(); |
| 3809 | 3779 | } |
| 3810 | 3780 | } |
| 3811 | - } |
|
| 3812 | - else {
|
|
| 3781 | + } else {
|
|
| 3813 | 3782 | } |
| 3814 | 3783 | } |
| 3815 | 3784 | |
| 3816 | 3785 | // ----- Check the directory availability and create it if necessary |
| 3817 | 3786 | else {
|
| 3818 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3819 | - $v_dir_to_check = $p_entry['filename']; |
|
| 3820 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3821 | - $v_dir_to_check = ""; |
|
| 3822 | - else |
|
| 3823 | - $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3787 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { |
|
| 3788 | + $v_dir_to_check = $p_entry['filename']; |
|
| 3789 | + } else if (!strstr($p_entry['filename'], "/")) { |
|
| 3790 | + $v_dir_to_check = ""; |
|
| 3791 | + } else { |
|
| 3792 | + $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3793 | + } |
|
| 3824 | 3794 | |
| 3825 | 3795 | if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
|
| 3826 | 3796 | |
@@ -3876,8 +3846,7 @@ discard block |
||
| 3876 | 3846 | touch($p_entry['filename'], $p_entry['mtime']); |
| 3877 | 3847 | |
| 3878 | 3848 | |
| 3879 | - } |
|
| 3880 | - else {
|
|
| 3849 | + } else {
|
|
| 3881 | 3850 | // ----- TBC |
| 3882 | 3851 | // Need to be finished |
| 3883 | 3852 | if (($p_entry['flag'] & 1) == 1) {
|
@@ -4120,8 +4089,7 @@ discard block |
||
| 4120 | 4089 | // ----- Send the file to the output |
| 4121 | 4090 | echo $v_buffer; |
| 4122 | 4091 | unset($v_buffer); |
| 4123 | - } |
|
| 4124 | - else {
|
|
| 4092 | + } else {
|
|
| 4125 | 4093 | |
| 4126 | 4094 | // ----- Read the compressed file in a buffer (one shot) |
| 4127 | 4095 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4231,8 +4199,7 @@ discard block |
||
| 4231 | 4199 | |
| 4232 | 4200 | // ----- Reading the file |
| 4233 | 4201 | $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 4234 | - } |
|
| 4235 | - else {
|
|
| 4202 | + } else {
|
|
| 4236 | 4203 | |
| 4237 | 4204 | // ----- Reading the file |
| 4238 | 4205 | $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4244,8 +4211,7 @@ discard block |
||
| 4244 | 4211 | } |
| 4245 | 4212 | |
| 4246 | 4213 | // ----- Trace |
| 4247 | - } |
|
| 4248 | - else {
|
|
| 4214 | + } else {
|
|
| 4249 | 4215 | // TBC : error : can not extract a folder in a string |
| 4250 | 4216 | } |
| 4251 | 4217 | |
@@ -4338,8 +4304,7 @@ discard block |
||
| 4338 | 4304 | // ----- Get extra_fields |
| 4339 | 4305 | if ($v_data['extra_len'] != 0) {
|
| 4340 | 4306 | $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
| 4341 | - } |
|
| 4342 | - else {
|
|
| 4307 | + } else {
|
|
| 4343 | 4308 | $p_header['extra'] = ''; |
| 4344 | 4309 | } |
| 4345 | 4310 | |
@@ -4370,8 +4335,7 @@ discard block |
||
| 4370 | 4335 | // ----- Get UNIX date format |
| 4371 | 4336 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4372 | 4337 | |
| 4373 | - } |
|
| 4374 | - else |
|
| 4338 | + } else |
|
| 4375 | 4339 | {
|
| 4376 | 4340 | $p_header['mtime'] = time(); |
| 4377 | 4341 | } |
@@ -4436,29 +4400,33 @@ discard block |
||
| 4436 | 4400 | $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
|
| 4437 | 4401 | |
| 4438 | 4402 | // ----- Get filename |
| 4439 | - if ($p_header['filename_len'] != 0) |
|
| 4440 | - // |
|
| 4403 | + if ($p_header['filename_len'] != 0) { |
|
| 4404 | + // |
|
| 4441 | 4405 | // -------------------------------------------------------------------------------- |
| 4442 | 4406 | // A patch about stored filenames with backslash directory separator (Windows style). |
| 4443 | 4407 | // Archives created by the utility IZArc 3.81 (possibly new versions too) need this patch. |
| 4444 | 4408 | //$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
| 4445 | - $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len']));
|
|
| 4409 | + $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len'])); |
|
| 4410 | + } |
|
| 4446 | 4411 | // -------------------------------------------------------------------------------- |
| 4447 | 4412 | // |
| 4448 | - else |
|
| 4449 | - $p_header['filename'] = ''; |
|
| 4413 | + else { |
|
| 4414 | + $p_header['filename'] = ''; |
|
| 4415 | + } |
|
| 4450 | 4416 | |
| 4451 | 4417 | // ----- Get extra |
| 4452 | - if ($p_header['extra_len'] != 0) |
|
| 4453 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4454 | - else |
|
| 4455 | - $p_header['extra'] = ''; |
|
| 4418 | + if ($p_header['extra_len'] != 0) { |
|
| 4419 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4420 | + } else { |
|
| 4421 | + $p_header['extra'] = ''; |
|
| 4422 | + } |
|
| 4456 | 4423 | |
| 4457 | 4424 | // ----- Get comment |
| 4458 | - if ($p_header['comment_len'] != 0) |
|
| 4459 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4460 | - else |
|
| 4461 | - $p_header['comment'] = ''; |
|
| 4425 | + if ($p_header['comment_len'] != 0) { |
|
| 4426 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4427 | + } else { |
|
| 4428 | + $p_header['comment'] = ''; |
|
| 4429 | + } |
|
| 4462 | 4430 | |
| 4463 | 4431 | // ----- Extract properties |
| 4464 | 4432 | |
@@ -4480,8 +4448,7 @@ discard block |
||
| 4480 | 4448 | // ----- Get UNIX date format |
| 4481 | 4449 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4482 | 4450 | |
| 4483 | - } |
|
| 4484 | - else |
|
| 4451 | + } else |
|
| 4485 | 4452 | {
|
| 4486 | 4453 | $p_header['mtime'] = time(); |
| 4487 | 4454 | } |
@@ -4594,8 +4561,9 @@ discard block |
||
| 4594 | 4561 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 4595 | 4562 | if (!$v_found) {
|
| 4596 | 4563 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4597 | - if ($v_maximum_size > $v_size) |
|
| 4598 | - $v_maximum_size = $v_size; |
|
| 4564 | + if ($v_maximum_size > $v_size) { |
|
| 4565 | + $v_maximum_size = $v_size; |
|
| 4566 | + } |
|
| 4599 | 4567 | @fseek($this->zip_fd, $v_size-$v_maximum_size); |
| 4600 | 4568 | if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
| 4601 | 4569 | {
|
@@ -4680,9 +4648,9 @@ discard block |
||
| 4680 | 4648 | // ----- Get comment |
| 4681 | 4649 | if ($v_data['comment_size'] != 0) {
|
| 4682 | 4650 | $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
| 4683 | - } |
|
| 4684 | - else |
|
| 4685 | - $p_central_dir['comment'] = ''; |
|
| 4651 | + } else { |
|
| 4652 | + $p_central_dir['comment'] = ''; |
|
| 4653 | + } |
|
| 4686 | 4654 | |
| 4687 | 4655 | $p_central_dir['entries'] = $v_data['entries']; |
| 4688 | 4656 | $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
@@ -4782,8 +4750,7 @@ discard block |
||
| 4782 | 4750 | if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
| 4783 | 4751 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4784 | 4752 | $v_found = true; |
| 4785 | - } |
|
| 4786 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4753 | + } elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4787 | 4754 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4788 | 4755 | $v_found = true; |
| 4789 | 4756 | } |
@@ -4834,8 +4801,7 @@ discard block |
||
| 4834 | 4801 | break; |
| 4835 | 4802 | } |
| 4836 | 4803 | } |
| 4837 | - } |
|
| 4838 | - else {
|
|
| 4804 | + } else {
|
|
| 4839 | 4805 | $v_found = true; |
| 4840 | 4806 | } |
| 4841 | 4807 | |
@@ -4843,8 +4809,7 @@ discard block |
||
| 4843 | 4809 | if ($v_found) |
| 4844 | 4810 | {
|
| 4845 | 4811 | unset($v_header_list[$v_nb_extracted]); |
| 4846 | - } |
|
| 4847 | - else |
|
| 4812 | + } else |
|
| 4848 | 4813 | {
|
| 4849 | 4814 | $v_nb_extracted++; |
| 4850 | 4815 | } |
@@ -5320,8 +5285,7 @@ discard block |
||
| 5320 | 5285 | {
|
| 5321 | 5286 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 5322 | 5287 | PclError($p_error_code, $p_error_string); |
| 5323 | - } |
|
| 5324 | - else {
|
|
| 5288 | + } else {
|
|
| 5325 | 5289 | $this->error_code = $p_error_code; |
| 5326 | 5290 | $this->error_string = $p_error_string; |
| 5327 | 5291 | } |
@@ -5337,8 +5301,7 @@ discard block |
||
| 5337 | 5301 | {
|
| 5338 | 5302 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 5339 | 5303 | PclErrorReset(); |
| 5340 | - } |
|
| 5341 | - else {
|
|
| 5304 | + } else {
|
|
| 5342 | 5305 | $this->error_code = 0; |
| 5343 | 5306 | $this->error_string = ''; |
| 5344 | 5307 | } |
@@ -5436,11 +5399,9 @@ discard block |
||
| 5436 | 5399 | if ($v_list[$i] == ".") {
|
| 5437 | 5400 | // ----- Ignore this directory |
| 5438 | 5401 | // Should be the first $i=0, but no check is done |
| 5439 | - } |
|
| 5440 | - else if ($v_list[$i] == "..") {
|
|
| 5402 | + } else if ($v_list[$i] == "..") {
|
|
| 5441 | 5403 | $v_skip++; |
| 5442 | - } |
|
| 5443 | - else if ($v_list[$i] == "") {
|
|
| 5404 | + } else if ($v_list[$i] == "") {
|
|
| 5444 | 5405 | // ----- First '/' i.e. root slash |
| 5445 | 5406 | if ($i == 0) {
|
| 5446 | 5407 | $v_result = "/".$v_result; |
@@ -5460,13 +5421,11 @@ discard block |
||
| 5460 | 5421 | // ----- Ignore only the double '//' in path, |
| 5461 | 5422 | // but not the first and last '/' |
| 5462 | 5423 | } |
| 5463 | - } |
|
| 5464 | - else {
|
|
| 5424 | + } else {
|
|
| 5465 | 5425 | // ----- Look for item to skip |
| 5466 | 5426 | if ($v_skip > 0) {
|
| 5467 | 5427 | $v_skip--; |
| 5468 | - } |
|
| 5469 | - else {
|
|
| 5428 | + } else {
|
|
| 5470 | 5429 | $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
| 5471 | 5430 | } |
| 5472 | 5431 | } |
@@ -5549,14 +5508,17 @@ discard block |
||
| 5549 | 5508 | // ----- Look if everything seems to be the same |
| 5550 | 5509 | if ($v_result) {
|
| 5551 | 5510 | // ----- Skip all the empty items |
| 5552 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5553 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5511 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
| 5512 | + $j++; |
|
| 5513 | + } |
|
| 5514 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { |
|
| 5515 | + $i++; |
|
| 5516 | + } |
|
| 5554 | 5517 | |
| 5555 | 5518 | if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
|
| 5556 | 5519 | // ----- There are exactly the same |
| 5557 | 5520 | $v_result = 2; |
| 5558 | - } |
|
| 5559 | - else if ($i < $v_list_dir_size) {
|
|
| 5521 | + } else if ($i < $v_list_dir_size) {
|
|
| 5560 | 5522 | // ----- The path is shorter than the dir |
| 5561 | 5523 | $v_result = 0; |
| 5562 | 5524 | } |
@@ -5591,8 +5553,7 @@ discard block |
||
| 5591 | 5553 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5592 | 5554 | $p_size -= $v_read_size; |
| 5593 | 5555 | } |
| 5594 | - } |
|
| 5595 | - else if ($p_mode==1) |
|
| 5556 | + } else if ($p_mode==1) |
|
| 5596 | 5557 | {
|
| 5597 | 5558 | while ($p_size != 0) |
| 5598 | 5559 | {
|
@@ -5601,8 +5562,7 @@ discard block |
||
| 5601 | 5562 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5602 | 5563 | $p_size -= $v_read_size; |
| 5603 | 5564 | } |
| 5604 | - } |
|
| 5605 | - else if ($p_mode==2) |
|
| 5565 | + } else if ($p_mode==2) |
|
| 5606 | 5566 | {
|
| 5607 | 5567 | while ($p_size != 0) |
| 5608 | 5568 | {
|
@@ -5611,8 +5571,7 @@ discard block |
||
| 5611 | 5571 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 5612 | 5572 | $p_size -= $v_read_size; |
| 5613 | 5573 | } |
| 5614 | - } |
|
| 5615 | - else if ($p_mode==3) |
|
| 5574 | + } else if ($p_mode==3) |
|
| 5616 | 5575 | {
|
| 5617 | 5576 | while ($p_size != 0) |
| 5618 | 5577 | {
|
@@ -5650,8 +5609,7 @@ discard block |
||
| 5650 | 5609 | // ----- Try to copy & unlink the src |
| 5651 | 5610 | if (!@copy($p_src, $p_dest)) {
|
| 5652 | 5611 | $v_result = 0; |
| 5653 | - } |
|
| 5654 | - else if (!@unlink($p_src)) {
|
|
| 5612 | + } else if (!@unlink($p_src)) {
|
|
| 5655 | 5613 | $v_result = 0; |
| 5656 | 5614 | } |
| 5657 | 5615 | } |
@@ -39,154 +39,154 @@ discard block |
||
| 39 | 39 | // http://php.net/manual/en/function.gzopen.php |
| 40 | 40 | // -------------------------------------------------------------------------------- |
| 41 | 41 | if (!function_exists('gzopen') && function_exists('gzopen64')) {
|
| 42 | - function gzopen($filename, $mode, $use_include_path = 0) {
|
|
| 43 | - return gzopen64($filename, $mode, $use_include_path); |
|
| 44 | - } |
|
| 42 | + function gzopen($filename, $mode, $use_include_path = 0) {
|
|
| 43 | + return gzopen64($filename, $mode, $use_include_path); |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | // -------------------------------------------------------------------------------- |
| 47 | 47 | |
| 48 | - // ----- Constants |
|
| 49 | - if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
|
|
| 48 | + // ----- Constants |
|
| 49 | + if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
|
|
| 50 | 50 | define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
| 51 | - } |
|
| 52 | - |
|
| 53 | - // ----- File list separator |
|
| 54 | - // In version 1.x of PclZip, the separator for file list is a space |
|
| 55 | - // (which is not a very smart choice, specifically for windows paths !). |
|
| 56 | - // A better separator should be a comma (,). This constant gives you the |
|
| 57 | - // abilty to change that. |
|
| 58 | - // However notice that changing this value, may have impact on existing |
|
| 59 | - // scripts, using space separated filenames. |
|
| 60 | - // Recommanded values for compatibility with older versions : |
|
| 61 | - //define( 'PCLZIP_SEPARATOR', ' ' ); |
|
| 62 | - // Recommanded values for smart separation of filenames. |
|
| 63 | - if (!defined('PCLZIP_SEPARATOR')) {
|
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // ----- File list separator |
|
| 54 | + // In version 1.x of PclZip, the separator for file list is a space |
|
| 55 | + // (which is not a very smart choice, specifically for windows paths !). |
|
| 56 | + // A better separator should be a comma (,). This constant gives you the |
|
| 57 | + // abilty to change that. |
|
| 58 | + // However notice that changing this value, may have impact on existing |
|
| 59 | + // scripts, using space separated filenames. |
|
| 60 | + // Recommanded values for compatibility with older versions : |
|
| 61 | + //define( 'PCLZIP_SEPARATOR', ' ' ); |
|
| 62 | + // Recommanded values for smart separation of filenames. |
|
| 63 | + if (!defined('PCLZIP_SEPARATOR')) {
|
|
| 64 | 64 | define( 'PCLZIP_SEPARATOR', '|' ); |
| 65 | - } |
|
| 66 | - |
|
| 67 | - // ----- Error configuration |
|
| 68 | - // 0 : PclZip Class integrated error handling |
|
| 69 | - // 1 : PclError external library error handling. By enabling this |
|
| 70 | - // you must ensure that you have included PclError library. |
|
| 71 | - // [2,...] : reserved for futur use |
|
| 72 | - if (!defined('PCLZIP_ERROR_EXTERNAL')) {
|
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // ----- Error configuration |
|
| 68 | + // 0 : PclZip Class integrated error handling |
|
| 69 | + // 1 : PclError external library error handling. By enabling this |
|
| 70 | + // you must ensure that you have included PclError library. |
|
| 71 | + // [2,...] : reserved for futur use |
|
| 72 | + if (!defined('PCLZIP_ERROR_EXTERNAL')) {
|
|
| 73 | 73 | define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
| 74 | - } |
|
| 75 | - |
|
| 76 | - // ----- Optional static temporary directory |
|
| 77 | - // By default temporary files are generated in the script current |
|
| 78 | - // path. |
|
| 79 | - // If defined : |
|
| 80 | - // - MUST BE terminated by a '/'. |
|
| 81 | - // - MUST be a valid, already created directory |
|
| 82 | - // Samples : |
|
| 83 | - // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
|
| 84 | - // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
| 85 | - if (!defined('PCLZIP_TEMPORARY_DIR')) {
|
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // ----- Optional static temporary directory |
|
| 77 | + // By default temporary files are generated in the script current |
|
| 78 | + // path. |
|
| 79 | + // If defined : |
|
| 80 | + // - MUST BE terminated by a '/'. |
|
| 81 | + // - MUST be a valid, already created directory |
|
| 82 | + // Samples : |
|
| 83 | + // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
|
| 84 | + // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
| 85 | + if (!defined('PCLZIP_TEMPORARY_DIR')) {
|
|
| 86 | 86 | define( 'PCLZIP_TEMPORARY_DIR', '' ); |
| 87 | - } |
|
| 88 | - |
|
| 89 | - // ----- Optional threshold ratio for use of temporary files |
|
| 90 | - // Pclzip sense the size of the file to add/extract and decide to |
|
| 91 | - // use or not temporary file. The algorythm is looking for |
|
| 92 | - // memory_limit of PHP and apply a ratio. |
|
| 93 | - // threshold = memory_limit * ratio. |
|
| 94 | - // Recommended values are under 0.5. Default 0.47. |
|
| 95 | - // Samples : |
|
| 96 | - // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); |
|
| 97 | - if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
|
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + // ----- Optional threshold ratio for use of temporary files |
|
| 90 | + // Pclzip sense the size of the file to add/extract and decide to |
|
| 91 | + // use or not temporary file. The algorythm is looking for |
|
| 92 | + // memory_limit of PHP and apply a ratio. |
|
| 93 | + // threshold = memory_limit * ratio. |
|
| 94 | + // Recommended values are under 0.5. Default 0.47. |
|
| 95 | + // Samples : |
|
| 96 | + // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); |
|
| 97 | + if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
|
|
| 98 | 98 | define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | // -------------------------------------------------------------------------------- |
| 102 | 102 | // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED ***** |
| 103 | 103 | // -------------------------------------------------------------------------------- |
| 104 | 104 | |
| 105 | - // ----- Global variables |
|
| 106 | - $g_pclzip_version = "2.8.2"; |
|
| 107 | - |
|
| 108 | - // ----- Error codes |
|
| 109 | - // -1 : Unable to open file in binary write mode |
|
| 110 | - // -2 : Unable to open file in binary read mode |
|
| 111 | - // -3 : Invalid parameters |
|
| 112 | - // -4 : File does not exist |
|
| 113 | - // -5 : Filename is too long (max. 255) |
|
| 114 | - // -6 : Not a valid zip file |
|
| 115 | - // -7 : Invalid extracted file size |
|
| 116 | - // -8 : Unable to create directory |
|
| 117 | - // -9 : Invalid archive extension |
|
| 118 | - // -10 : Invalid archive format |
|
| 119 | - // -11 : Unable to delete file (unlink) |
|
| 120 | - // -12 : Unable to rename file (rename) |
|
| 121 | - // -13 : Invalid header checksum |
|
| 122 | - // -14 : Invalid archive size |
|
| 123 | - define( 'PCLZIP_ERR_USER_ABORTED', 2 ); |
|
| 124 | - define( 'PCLZIP_ERR_NO_ERROR', 0 ); |
|
| 125 | - define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); |
|
| 126 | - define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); |
|
| 127 | - define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); |
|
| 128 | - define( 'PCLZIP_ERR_MISSING_FILE', -4 ); |
|
| 129 | - define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); |
|
| 130 | - define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); |
|
| 131 | - define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); |
|
| 132 | - define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); |
|
| 133 | - define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); |
|
| 134 | - define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); |
|
| 135 | - define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); |
|
| 136 | - define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); |
|
| 137 | - define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); |
|
| 138 | - define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); |
|
| 139 | - define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); |
|
| 140 | - define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); |
|
| 141 | - define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); |
|
| 142 | - define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); |
|
| 143 | - define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); |
|
| 144 | - define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); |
|
| 145 | - define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); |
|
| 146 | - |
|
| 147 | - // ----- Options values |
|
| 148 | - define( 'PCLZIP_OPT_PATH', 77001 ); |
|
| 149 | - define( 'PCLZIP_OPT_ADD_PATH', 77002 ); |
|
| 150 | - define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); |
|
| 151 | - define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); |
|
| 152 | - define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); |
|
| 153 | - define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); |
|
| 154 | - define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); |
|
| 155 | - define( 'PCLZIP_OPT_BY_NAME', 77008 ); |
|
| 156 | - define( 'PCLZIP_OPT_BY_INDEX', 77009 ); |
|
| 157 | - define( 'PCLZIP_OPT_BY_EREG', 77010 ); |
|
| 158 | - define( 'PCLZIP_OPT_BY_PREG', 77011 ); |
|
| 159 | - define( 'PCLZIP_OPT_COMMENT', 77012 ); |
|
| 160 | - define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); |
|
| 161 | - define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); |
|
| 162 | - define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); |
|
| 163 | - define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); |
|
| 164 | - define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); |
|
| 165 | - // Having big trouble with crypt. Need to multiply 2 long int |
|
| 166 | - // which is not correctly supported by PHP ... |
|
| 167 | - //define( 'PCLZIP_OPT_CRYPT', 77018 ); |
|
| 168 | - define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); |
|
| 169 | - define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); |
|
| 170 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias |
|
| 171 | - define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); |
|
| 172 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias |
|
| 173 | - define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); |
|
| 174 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias |
|
| 175 | - |
|
| 176 | - // ----- File description attributes |
|
| 177 | - define( 'PCLZIP_ATT_FILE_NAME', 79001 ); |
|
| 178 | - define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
|
| 179 | - define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); |
|
| 180 | - define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); |
|
| 181 | - define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); |
|
| 182 | - define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); |
|
| 183 | - |
|
| 184 | - // ----- Call backs values |
|
| 185 | - define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); |
|
| 186 | - define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); |
|
| 187 | - define( 'PCLZIP_CB_PRE_ADD', 78003 ); |
|
| 188 | - define( 'PCLZIP_CB_POST_ADD', 78004 ); |
|
| 189 | - /* For futur use |
|
| 105 | + // ----- Global variables |
|
| 106 | + $g_pclzip_version = "2.8.2"; |
|
| 107 | + |
|
| 108 | + // ----- Error codes |
|
| 109 | + // -1 : Unable to open file in binary write mode |
|
| 110 | + // -2 : Unable to open file in binary read mode |
|
| 111 | + // -3 : Invalid parameters |
|
| 112 | + // -4 : File does not exist |
|
| 113 | + // -5 : Filename is too long (max. 255) |
|
| 114 | + // -6 : Not a valid zip file |
|
| 115 | + // -7 : Invalid extracted file size |
|
| 116 | + // -8 : Unable to create directory |
|
| 117 | + // -9 : Invalid archive extension |
|
| 118 | + // -10 : Invalid archive format |
|
| 119 | + // -11 : Unable to delete file (unlink) |
|
| 120 | + // -12 : Unable to rename file (rename) |
|
| 121 | + // -13 : Invalid header checksum |
|
| 122 | + // -14 : Invalid archive size |
|
| 123 | + define( 'PCLZIP_ERR_USER_ABORTED', 2 ); |
|
| 124 | + define( 'PCLZIP_ERR_NO_ERROR', 0 ); |
|
| 125 | + define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); |
|
| 126 | + define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); |
|
| 127 | + define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); |
|
| 128 | + define( 'PCLZIP_ERR_MISSING_FILE', -4 ); |
|
| 129 | + define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); |
|
| 130 | + define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); |
|
| 131 | + define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); |
|
| 132 | + define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); |
|
| 133 | + define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); |
|
| 134 | + define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); |
|
| 135 | + define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); |
|
| 136 | + define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); |
|
| 137 | + define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); |
|
| 138 | + define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); |
|
| 139 | + define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); |
|
| 140 | + define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); |
|
| 141 | + define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); |
|
| 142 | + define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); |
|
| 143 | + define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); |
|
| 144 | + define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); |
|
| 145 | + define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); |
|
| 146 | + |
|
| 147 | + // ----- Options values |
|
| 148 | + define( 'PCLZIP_OPT_PATH', 77001 ); |
|
| 149 | + define( 'PCLZIP_OPT_ADD_PATH', 77002 ); |
|
| 150 | + define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); |
|
| 151 | + define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); |
|
| 152 | + define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); |
|
| 153 | + define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); |
|
| 154 | + define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); |
|
| 155 | + define( 'PCLZIP_OPT_BY_NAME', 77008 ); |
|
| 156 | + define( 'PCLZIP_OPT_BY_INDEX', 77009 ); |
|
| 157 | + define( 'PCLZIP_OPT_BY_EREG', 77010 ); |
|
| 158 | + define( 'PCLZIP_OPT_BY_PREG', 77011 ); |
|
| 159 | + define( 'PCLZIP_OPT_COMMENT', 77012 ); |
|
| 160 | + define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); |
|
| 161 | + define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); |
|
| 162 | + define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); |
|
| 163 | + define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); |
|
| 164 | + define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); |
|
| 165 | + // Having big trouble with crypt. Need to multiply 2 long int |
|
| 166 | + // which is not correctly supported by PHP ... |
|
| 167 | + //define( 'PCLZIP_OPT_CRYPT', 77018 ); |
|
| 168 | + define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); |
|
| 169 | + define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); |
|
| 170 | + define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias |
|
| 171 | + define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); |
|
| 172 | + define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias |
|
| 173 | + define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); |
|
| 174 | + define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias |
|
| 175 | + |
|
| 176 | + // ----- File description attributes |
|
| 177 | + define( 'PCLZIP_ATT_FILE_NAME', 79001 ); |
|
| 178 | + define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
|
| 179 | + define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); |
|
| 180 | + define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); |
|
| 181 | + define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); |
|
| 182 | + define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); |
|
| 183 | + |
|
| 184 | + // ----- Call backs values |
|
| 185 | + define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); |
|
| 186 | + define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); |
|
| 187 | + define( 'PCLZIP_CB_PRE_ADD', 78003 ); |
|
| 188 | + define( 'PCLZIP_CB_POST_ADD', 78004 ); |
|
| 189 | + /* For futur use |
|
| 190 | 190 | define( 'PCLZIP_CB_PRE_LIST', 78005 ); |
| 191 | 191 | define( 'PCLZIP_CB_POST_LIST', 78006 ); |
| 192 | 192 | define( 'PCLZIP_CB_PRE_DELETE', 78007 ); |
@@ -224,21 +224,21 @@ discard block |
||
| 224 | 224 | // The class can then disable the magic_quotes and reset it after |
| 225 | 225 | var $magic_quotes_status; |
| 226 | 226 | |
| 227 | - // -------------------------------------------------------------------------------- |
|
| 228 | - // Function : PclZip() |
|
| 229 | - // Description : |
|
| 230 | - // Creates a PclZip object and set the name of the associated Zip archive |
|
| 231 | - // filename. |
|
| 232 | - // Note that no real action is taken, if the archive does not exist it is not |
|
| 233 | - // created. Use create() for that. |
|
| 234 | - // -------------------------------------------------------------------------------- |
|
| 235 | - function PclZip($p_zipname) |
|
| 236 | - {
|
|
| 227 | + // -------------------------------------------------------------------------------- |
|
| 228 | + // Function : PclZip() |
|
| 229 | + // Description : |
|
| 230 | + // Creates a PclZip object and set the name of the associated Zip archive |
|
| 231 | + // filename. |
|
| 232 | + // Note that no real action is taken, if the archive does not exist it is not |
|
| 233 | + // created. Use create() for that. |
|
| 234 | + // -------------------------------------------------------------------------------- |
|
| 235 | + function PclZip($p_zipname) |
|
| 236 | + {
|
|
| 237 | 237 | |
| 238 | 238 | // ----- Tests the zlib |
| 239 | 239 | if (!function_exists('gzopen'))
|
| 240 | 240 | {
|
| 241 | - die('Abort '.basename(__FILE__).' : Missing zlib extensions');
|
|
| 241 | + die('Abort '.basename(__FILE__).' : Missing zlib extensions');
|
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // ----- Set the attributes |
@@ -248,48 +248,48 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | // ----- Return |
| 250 | 250 | return; |
| 251 | - } |
|
| 252 | - // -------------------------------------------------------------------------------- |
|
| 253 | - |
|
| 254 | - // -------------------------------------------------------------------------------- |
|
| 255 | - // Function : |
|
| 256 | - // create($p_filelist, $p_add_dir="", $p_remove_dir="") |
|
| 257 | - // create($p_filelist, $p_option, $p_option_value, ...) |
|
| 258 | - // Description : |
|
| 259 | - // This method supports two different synopsis. The first one is historical. |
|
| 260 | - // This method creates a Zip Archive. The Zip file is created in the |
|
| 261 | - // filesystem. The files and directories indicated in $p_filelist |
|
| 262 | - // are added in the archive. See the parameters description for the |
|
| 263 | - // supported format of $p_filelist. |
|
| 264 | - // When a directory is in the list, the directory and its content is added |
|
| 265 | - // in the archive. |
|
| 266 | - // In this synopsis, the function takes an optional variable list of |
|
| 267 | - // options. See bellow the supported options. |
|
| 268 | - // Parameters : |
|
| 269 | - // $p_filelist : An array containing file or directory names, or |
|
| 270 | - // a string containing one filename or one directory name, or |
|
| 271 | - // a string containing a list of filenames and/or directory |
|
| 272 | - // names separated by spaces. |
|
| 273 | - // $p_add_dir : A path to add before the real path of the archived file, |
|
| 274 | - // in order to have it memorized in the archive. |
|
| 275 | - // $p_remove_dir : A path to remove from the real path of the file to archive, |
|
| 276 | - // in order to have a shorter path memorized in the archive. |
|
| 277 | - // When $p_add_dir and $p_remove_dir are set, $p_remove_dir |
|
| 278 | - // is removed first, before $p_add_dir is added. |
|
| 279 | - // Options : |
|
| 280 | - // PCLZIP_OPT_ADD_PATH : |
|
| 281 | - // PCLZIP_OPT_REMOVE_PATH : |
|
| 282 | - // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 283 | - // PCLZIP_OPT_COMMENT : |
|
| 284 | - // PCLZIP_CB_PRE_ADD : |
|
| 285 | - // PCLZIP_CB_POST_ADD : |
|
| 286 | - // Return Values : |
|
| 287 | - // 0 on failure, |
|
| 288 | - // The list of the added files, with a status of the add action. |
|
| 289 | - // (see PclZip::listContent() for list entry format) |
|
| 290 | - // -------------------------------------------------------------------------------- |
|
| 291 | - function create($p_filelist) |
|
| 292 | - {
|
|
| 251 | + } |
|
| 252 | + // -------------------------------------------------------------------------------- |
|
| 253 | + |
|
| 254 | + // -------------------------------------------------------------------------------- |
|
| 255 | + // Function : |
|
| 256 | + // create($p_filelist, $p_add_dir="", $p_remove_dir="") |
|
| 257 | + // create($p_filelist, $p_option, $p_option_value, ...) |
|
| 258 | + // Description : |
|
| 259 | + // This method supports two different synopsis. The first one is historical. |
|
| 260 | + // This method creates a Zip Archive. The Zip file is created in the |
|
| 261 | + // filesystem. The files and directories indicated in $p_filelist |
|
| 262 | + // are added in the archive. See the parameters description for the |
|
| 263 | + // supported format of $p_filelist. |
|
| 264 | + // When a directory is in the list, the directory and its content is added |
|
| 265 | + // in the archive. |
|
| 266 | + // In this synopsis, the function takes an optional variable list of |
|
| 267 | + // options. See bellow the supported options. |
|
| 268 | + // Parameters : |
|
| 269 | + // $p_filelist : An array containing file or directory names, or |
|
| 270 | + // a string containing one filename or one directory name, or |
|
| 271 | + // a string containing a list of filenames and/or directory |
|
| 272 | + // names separated by spaces. |
|
| 273 | + // $p_add_dir : A path to add before the real path of the archived file, |
|
| 274 | + // in order to have it memorized in the archive. |
|
| 275 | + // $p_remove_dir : A path to remove from the real path of the file to archive, |
|
| 276 | + // in order to have a shorter path memorized in the archive. |
|
| 277 | + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir |
|
| 278 | + // is removed first, before $p_add_dir is added. |
|
| 279 | + // Options : |
|
| 280 | + // PCLZIP_OPT_ADD_PATH : |
|
| 281 | + // PCLZIP_OPT_REMOVE_PATH : |
|
| 282 | + // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 283 | + // PCLZIP_OPT_COMMENT : |
|
| 284 | + // PCLZIP_CB_PRE_ADD : |
|
| 285 | + // PCLZIP_CB_POST_ADD : |
|
| 286 | + // Return Values : |
|
| 287 | + // 0 on failure, |
|
| 288 | + // The list of the added files, with a status of the add action. |
|
| 289 | + // (see PclZip::listContent() for list entry format) |
|
| 290 | + // -------------------------------------------------------------------------------- |
|
| 291 | + function create($p_filelist) |
|
| 292 | + {
|
|
| 293 | 293 | $v_result=1; |
| 294 | 294 | |
| 295 | 295 | // ----- Reset the error handler |
@@ -304,53 +304,53 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | // ----- Look for arguments |
| 306 | 306 | if ($v_size > 1) {
|
| 307 | - // ----- Get the arguments |
|
| 308 | - $v_arg_list = func_get_args(); |
|
| 307 | + // ----- Get the arguments |
|
| 308 | + $v_arg_list = func_get_args(); |
|
| 309 | 309 | |
| 310 | - // ----- Remove from the options list the first argument |
|
| 311 | - array_shift($v_arg_list); |
|
| 312 | - $v_size--; |
|
| 310 | + // ----- Remove from the options list the first argument |
|
| 311 | + array_shift($v_arg_list); |
|
| 312 | + $v_size--; |
|
| 313 | 313 | |
| 314 | - // ----- Look for first arg |
|
| 315 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 314 | + // ----- Look for first arg |
|
| 315 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 316 | 316 | |
| 317 | 317 | // ----- Parse the options |
| 318 | 318 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 319 | 319 | array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 320 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 321 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 322 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 323 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 324 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 325 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 326 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 327 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 328 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 329 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 330 | - )); |
|
| 320 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 321 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 322 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 323 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 324 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 325 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 326 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 327 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 328 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 329 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 330 | + )); |
|
| 331 | 331 | if ($v_result != 1) {
|
| 332 | - return 0; |
|
| 332 | + return 0; |
|
| 333 | + } |
|
| 333 | 334 | } |
| 334 | - } |
|
| 335 | 335 | |
| 336 | - // ----- Look for 2 args |
|
| 337 | - // Here we need to support the first historic synopsis of the |
|
| 338 | - // method. |
|
| 339 | - else {
|
|
| 336 | + // ----- Look for 2 args |
|
| 337 | + // Here we need to support the first historic synopsis of the |
|
| 338 | + // method. |
|
| 339 | + else {
|
|
| 340 | 340 | |
| 341 | 341 | // ----- Get the first argument |
| 342 | 342 | $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; |
| 343 | 343 | |
| 344 | 344 | // ----- Look for the optional second argument |
| 345 | 345 | if ($v_size == 2) {
|
| 346 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 346 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 347 | 347 | } |
| 348 | 348 | else if ($v_size > 2) {
|
| 349 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 350 | - "Invalid number / type of arguments"); |
|
| 351 | - return 0; |
|
| 349 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 350 | + "Invalid number / type of arguments"); |
|
| 351 | + return 0; |
|
| 352 | + } |
|
| 352 | 353 | } |
| 353 | - } |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // ----- Look for default option values |
@@ -365,114 +365,114 @@ discard block |
||
| 365 | 365 | // ----- Look if the $p_filelist is really an array |
| 366 | 366 | if (is_array($p_filelist)) {
|
| 367 | 367 | |
| 368 | - // ----- Look if the first element is also an array |
|
| 369 | - // This will mean that this is a file description entry |
|
| 370 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
|
| 368 | + // ----- Look if the first element is also an array |
|
| 369 | + // This will mean that this is a file description entry |
|
| 370 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
|
| 371 | 371 | $v_att_list = $p_filelist; |
| 372 | - } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - // ----- The list is a list of string names |
|
| 375 | - else {
|
|
| 374 | + // ----- The list is a list of string names |
|
| 375 | + else {
|
|
| 376 | 376 | $v_string_list = $p_filelist; |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // ----- Look if the $p_filelist is a string |
| 381 | 381 | else if (is_string($p_filelist)) {
|
| 382 | - // ----- Create a list from the string |
|
| 383 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 382 | + // ----- Create a list from the string |
|
| 383 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // ----- Invalid variable type for $p_filelist |
| 387 | 387 | else {
|
| 388 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 389 | - return 0; |
|
| 388 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 389 | + return 0; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // ----- Reformat the string list |
| 393 | 393 | if (sizeof($v_string_list) != 0) {
|
| 394 | - foreach ($v_string_list as $v_string) {
|
|
| 394 | + foreach ($v_string_list as $v_string) {
|
|
| 395 | 395 | if ($v_string != '') {
|
| 396 | - $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 396 | + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 397 | 397 | } |
| 398 | 398 | else {
|
| 399 | 399 | } |
| 400 | - } |
|
| 400 | + } |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // ----- For each file in the list check the attributes |
| 404 | 404 | $v_supported_attributes |
| 405 | 405 | = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
| 406 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 407 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 408 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 409 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 410 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 411 | - ); |
|
| 406 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 407 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 408 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 409 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 410 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 411 | + ); |
|
| 412 | 412 | foreach ($v_att_list as $v_entry) {
|
| 413 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 414 | - $v_filedescr_list[], |
|
| 415 | - $v_options, |
|
| 416 | - $v_supported_attributes); |
|
| 417 | - if ($v_result != 1) {
|
|
| 413 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 414 | + $v_filedescr_list[], |
|
| 415 | + $v_options, |
|
| 416 | + $v_supported_attributes); |
|
| 417 | + if ($v_result != 1) {
|
|
| 418 | 418 | return 0; |
| 419 | - } |
|
| 419 | + } |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // ----- Expand the filelist (expand directories) |
| 423 | 423 | $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
| 424 | 424 | if ($v_result != 1) {
|
| 425 | - return 0; |
|
| 425 | + return 0; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | // ----- Call the create fct |
| 429 | 429 | $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); |
| 430 | 430 | if ($v_result != 1) {
|
| 431 | - return 0; |
|
| 431 | + return 0; |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // ----- Return |
| 435 | 435 | return $p_result_list; |
| 436 | - } |
|
| 437 | - // -------------------------------------------------------------------------------- |
|
| 438 | - |
|
| 439 | - // -------------------------------------------------------------------------------- |
|
| 440 | - // Function : |
|
| 441 | - // add($p_filelist, $p_add_dir="", $p_remove_dir="") |
|
| 442 | - // add($p_filelist, $p_option, $p_option_value, ...) |
|
| 443 | - // Description : |
|
| 444 | - // This method supports two synopsis. The first one is historical. |
|
| 445 | - // This methods add the list of files in an existing archive. |
|
| 446 | - // If a file with the same name already exists, it is added at the end of the |
|
| 447 | - // archive, the first one is still present. |
|
| 448 | - // If the archive does not exist, it is created. |
|
| 449 | - // Parameters : |
|
| 450 | - // $p_filelist : An array containing file or directory names, or |
|
| 451 | - // a string containing one filename or one directory name, or |
|
| 452 | - // a string containing a list of filenames and/or directory |
|
| 453 | - // names separated by spaces. |
|
| 454 | - // $p_add_dir : A path to add before the real path of the archived file, |
|
| 455 | - // in order to have it memorized in the archive. |
|
| 456 | - // $p_remove_dir : A path to remove from the real path of the file to archive, |
|
| 457 | - // in order to have a shorter path memorized in the archive. |
|
| 458 | - // When $p_add_dir and $p_remove_dir are set, $p_remove_dir |
|
| 459 | - // is removed first, before $p_add_dir is added. |
|
| 460 | - // Options : |
|
| 461 | - // PCLZIP_OPT_ADD_PATH : |
|
| 462 | - // PCLZIP_OPT_REMOVE_PATH : |
|
| 463 | - // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 464 | - // PCLZIP_OPT_COMMENT : |
|
| 465 | - // PCLZIP_OPT_ADD_COMMENT : |
|
| 466 | - // PCLZIP_OPT_PREPEND_COMMENT : |
|
| 467 | - // PCLZIP_CB_PRE_ADD : |
|
| 468 | - // PCLZIP_CB_POST_ADD : |
|
| 469 | - // Return Values : |
|
| 470 | - // 0 on failure, |
|
| 471 | - // The list of the added files, with a status of the add action. |
|
| 472 | - // (see PclZip::listContent() for list entry format) |
|
| 473 | - // -------------------------------------------------------------------------------- |
|
| 474 | - function add($p_filelist) |
|
| 475 | - {
|
|
| 436 | + } |
|
| 437 | + // -------------------------------------------------------------------------------- |
|
| 438 | + |
|
| 439 | + // -------------------------------------------------------------------------------- |
|
| 440 | + // Function : |
|
| 441 | + // add($p_filelist, $p_add_dir="", $p_remove_dir="") |
|
| 442 | + // add($p_filelist, $p_option, $p_option_value, ...) |
|
| 443 | + // Description : |
|
| 444 | + // This method supports two synopsis. The first one is historical. |
|
| 445 | + // This methods add the list of files in an existing archive. |
|
| 446 | + // If a file with the same name already exists, it is added at the end of the |
|
| 447 | + // archive, the first one is still present. |
|
| 448 | + // If the archive does not exist, it is created. |
|
| 449 | + // Parameters : |
|
| 450 | + // $p_filelist : An array containing file or directory names, or |
|
| 451 | + // a string containing one filename or one directory name, or |
|
| 452 | + // a string containing a list of filenames and/or directory |
|
| 453 | + // names separated by spaces. |
|
| 454 | + // $p_add_dir : A path to add before the real path of the archived file, |
|
| 455 | + // in order to have it memorized in the archive. |
|
| 456 | + // $p_remove_dir : A path to remove from the real path of the file to archive, |
|
| 457 | + // in order to have a shorter path memorized in the archive. |
|
| 458 | + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir |
|
| 459 | + // is removed first, before $p_add_dir is added. |
|
| 460 | + // Options : |
|
| 461 | + // PCLZIP_OPT_ADD_PATH : |
|
| 462 | + // PCLZIP_OPT_REMOVE_PATH : |
|
| 463 | + // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 464 | + // PCLZIP_OPT_COMMENT : |
|
| 465 | + // PCLZIP_OPT_ADD_COMMENT : |
|
| 466 | + // PCLZIP_OPT_PREPEND_COMMENT : |
|
| 467 | + // PCLZIP_CB_PRE_ADD : |
|
| 468 | + // PCLZIP_CB_POST_ADD : |
|
| 469 | + // Return Values : |
|
| 470 | + // 0 on failure, |
|
| 471 | + // The list of the added files, with a status of the add action. |
|
| 472 | + // (see PclZip::listContent() for list entry format) |
|
| 473 | + // -------------------------------------------------------------------------------- |
|
| 474 | + function add($p_filelist) |
|
| 475 | + {
|
|
| 476 | 476 | $v_result=1; |
| 477 | 477 | |
| 478 | 478 | // ----- Reset the error handler |
@@ -487,57 +487,57 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | // ----- Look for arguments |
| 489 | 489 | if ($v_size > 1) {
|
| 490 | - // ----- Get the arguments |
|
| 491 | - $v_arg_list = func_get_args(); |
|
| 490 | + // ----- Get the arguments |
|
| 491 | + $v_arg_list = func_get_args(); |
|
| 492 | 492 | |
| 493 | - // ----- Remove form the options list the first argument |
|
| 494 | - array_shift($v_arg_list); |
|
| 495 | - $v_size--; |
|
| 493 | + // ----- Remove form the options list the first argument |
|
| 494 | + array_shift($v_arg_list); |
|
| 495 | + $v_size--; |
|
| 496 | 496 | |
| 497 | - // ----- Look for first arg |
|
| 498 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 497 | + // ----- Look for first arg |
|
| 498 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 499 | 499 | |
| 500 | 500 | // ----- Parse the options |
| 501 | 501 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 502 | 502 | array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 503 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 504 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 505 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 506 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 507 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 508 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 509 | - PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 510 | - PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 511 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 512 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 513 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 514 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 515 | - )); |
|
| 503 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 504 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 505 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 506 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 507 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 508 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 509 | + PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 510 | + PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 511 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 512 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 513 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 514 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 515 | + )); |
|
| 516 | 516 | if ($v_result != 1) {
|
| 517 | - return 0; |
|
| 517 | + return 0; |
|
| 518 | + } |
|
| 518 | 519 | } |
| 519 | - } |
|
| 520 | 520 | |
| 521 | - // ----- Look for 2 args |
|
| 522 | - // Here we need to support the first historic synopsis of the |
|
| 523 | - // method. |
|
| 524 | - else {
|
|
| 521 | + // ----- Look for 2 args |
|
| 522 | + // Here we need to support the first historic synopsis of the |
|
| 523 | + // method. |
|
| 524 | + else {
|
|
| 525 | 525 | |
| 526 | 526 | // ----- Get the first argument |
| 527 | 527 | $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; |
| 528 | 528 | |
| 529 | 529 | // ----- Look for the optional second argument |
| 530 | 530 | if ($v_size == 2) {
|
| 531 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 531 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 532 | 532 | } |
| 533 | 533 | else if ($v_size > 2) {
|
| 534 | - // ----- Error log |
|
| 535 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 534 | + // ----- Error log |
|
| 535 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 536 | 536 | |
| 537 | - // ----- Return |
|
| 538 | - return 0; |
|
| 537 | + // ----- Return |
|
| 538 | + return 0; |
|
| 539 | + } |
|
| 539 | 540 | } |
| 540 | - } |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | // ----- Look for default option values |
@@ -552,116 +552,116 @@ discard block |
||
| 552 | 552 | // ----- Look if the $p_filelist is really an array |
| 553 | 553 | if (is_array($p_filelist)) {
|
| 554 | 554 | |
| 555 | - // ----- Look if the first element is also an array |
|
| 556 | - // This will mean that this is a file description entry |
|
| 557 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
|
| 555 | + // ----- Look if the first element is also an array |
|
| 556 | + // This will mean that this is a file description entry |
|
| 557 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
|
| 558 | 558 | $v_att_list = $p_filelist; |
| 559 | - } |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | - // ----- The list is a list of string names |
|
| 562 | - else {
|
|
| 561 | + // ----- The list is a list of string names |
|
| 562 | + else {
|
|
| 563 | 563 | $v_string_list = $p_filelist; |
| 564 | - } |
|
| 564 | + } |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | // ----- Look if the $p_filelist is a string |
| 568 | 568 | else if (is_string($p_filelist)) {
|
| 569 | - // ----- Create a list from the string |
|
| 570 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 569 | + // ----- Create a list from the string |
|
| 570 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | // ----- Invalid variable type for $p_filelist |
| 574 | 574 | else {
|
| 575 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 576 | - return 0; |
|
| 575 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 576 | + return 0; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | // ----- Reformat the string list |
| 580 | 580 | if (sizeof($v_string_list) != 0) {
|
| 581 | - foreach ($v_string_list as $v_string) {
|
|
| 581 | + foreach ($v_string_list as $v_string) {
|
|
| 582 | 582 | $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
| 583 | - } |
|
| 583 | + } |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | // ----- For each file in the list check the attributes |
| 587 | 587 | $v_supported_attributes |
| 588 | 588 | = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
| 589 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 590 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 591 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 592 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 593 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 594 | - ); |
|
| 589 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 590 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 591 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 592 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 593 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 594 | + ); |
|
| 595 | 595 | foreach ($v_att_list as $v_entry) {
|
| 596 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 597 | - $v_filedescr_list[], |
|
| 598 | - $v_options, |
|
| 599 | - $v_supported_attributes); |
|
| 600 | - if ($v_result != 1) {
|
|
| 596 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 597 | + $v_filedescr_list[], |
|
| 598 | + $v_options, |
|
| 599 | + $v_supported_attributes); |
|
| 600 | + if ($v_result != 1) {
|
|
| 601 | 601 | return 0; |
| 602 | - } |
|
| 602 | + } |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | // ----- Expand the filelist (expand directories) |
| 606 | 606 | $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
| 607 | 607 | if ($v_result != 1) {
|
| 608 | - return 0; |
|
| 608 | + return 0; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // ----- Call the create fct |
| 612 | 612 | $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); |
| 613 | 613 | if ($v_result != 1) {
|
| 614 | - return 0; |
|
| 614 | + return 0; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | // ----- Return |
| 618 | 618 | return $p_result_list; |
| 619 | - } |
|
| 620 | - // -------------------------------------------------------------------------------- |
|
| 621 | - |
|
| 622 | - // -------------------------------------------------------------------------------- |
|
| 623 | - // Function : listContent() |
|
| 624 | - // Description : |
|
| 625 | - // This public method, gives the list of the files and directories, with their |
|
| 626 | - // properties. |
|
| 627 | - // The properties of each entries in the list are (used also in other functions) : |
|
| 628 | - // filename : Name of the file. For a create or add action it is the filename |
|
| 629 | - // given by the user. For an extract function it is the filename |
|
| 630 | - // of the extracted file. |
|
| 631 | - // stored_filename : Name of the file / directory stored in the archive. |
|
| 632 | - // size : Size of the stored file. |
|
| 633 | - // compressed_size : Size of the file's data compressed in the archive |
|
| 634 | - // (without the headers overhead) |
|
| 635 | - // mtime : Last known modification date of the file (UNIX timestamp) |
|
| 636 | - // comment : Comment associated with the file |
|
| 637 | - // folder : true | false |
|
| 638 | - // index : index of the file in the archive |
|
| 639 | - // status : status of the action (depending of the action) : |
|
| 640 | - // Values are : |
|
| 641 | - // ok : OK ! |
|
| 642 | - // filtered : the file / dir is not extracted (filtered by user) |
|
| 643 | - // already_a_directory : the file can not be extracted because a |
|
| 644 | - // directory with the same name already exists |
|
| 645 | - // write_protected : the file can not be extracted because a file |
|
| 646 | - // with the same name already exists and is |
|
| 647 | - // write protected |
|
| 648 | - // newer_exist : the file was not extracted because a newer file exists |
|
| 649 | - // path_creation_fail : the file is not extracted because the folder |
|
| 650 | - // does not exist and can not be created |
|
| 651 | - // write_error : the file was not extracted because there was a |
|
| 652 | - // error while writing the file |
|
| 653 | - // read_error : the file was not extracted because there was a error |
|
| 654 | - // while reading the file |
|
| 655 | - // invalid_header : the file was not extracted because of an archive |
|
| 656 | - // format error (bad file header) |
|
| 657 | - // Note that each time a method can continue operating when there |
|
| 658 | - // is an action error on a file, the error is only logged in the file status. |
|
| 659 | - // Return Values : |
|
| 660 | - // 0 on an unrecoverable failure, |
|
| 661 | - // The list of the files in the archive. |
|
| 662 | - // -------------------------------------------------------------------------------- |
|
| 663 | - function listContent() |
|
| 664 | - {
|
|
| 619 | + } |
|
| 620 | + // -------------------------------------------------------------------------------- |
|
| 621 | + |
|
| 622 | + // -------------------------------------------------------------------------------- |
|
| 623 | + // Function : listContent() |
|
| 624 | + // Description : |
|
| 625 | + // This public method, gives the list of the files and directories, with their |
|
| 626 | + // properties. |
|
| 627 | + // The properties of each entries in the list are (used also in other functions) : |
|
| 628 | + // filename : Name of the file. For a create or add action it is the filename |
|
| 629 | + // given by the user. For an extract function it is the filename |
|
| 630 | + // of the extracted file. |
|
| 631 | + // stored_filename : Name of the file / directory stored in the archive. |
|
| 632 | + // size : Size of the stored file. |
|
| 633 | + // compressed_size : Size of the file's data compressed in the archive |
|
| 634 | + // (without the headers overhead) |
|
| 635 | + // mtime : Last known modification date of the file (UNIX timestamp) |
|
| 636 | + // comment : Comment associated with the file |
|
| 637 | + // folder : true | false |
|
| 638 | + // index : index of the file in the archive |
|
| 639 | + // status : status of the action (depending of the action) : |
|
| 640 | + // Values are : |
|
| 641 | + // ok : OK ! |
|
| 642 | + // filtered : the file / dir is not extracted (filtered by user) |
|
| 643 | + // already_a_directory : the file can not be extracted because a |
|
| 644 | + // directory with the same name already exists |
|
| 645 | + // write_protected : the file can not be extracted because a file |
|
| 646 | + // with the same name already exists and is |
|
| 647 | + // write protected |
|
| 648 | + // newer_exist : the file was not extracted because a newer file exists |
|
| 649 | + // path_creation_fail : the file is not extracted because the folder |
|
| 650 | + // does not exist and can not be created |
|
| 651 | + // write_error : the file was not extracted because there was a |
|
| 652 | + // error while writing the file |
|
| 653 | + // read_error : the file was not extracted because there was a error |
|
| 654 | + // while reading the file |
|
| 655 | + // invalid_header : the file was not extracted because of an archive |
|
| 656 | + // format error (bad file header) |
|
| 657 | + // Note that each time a method can continue operating when there |
|
| 658 | + // is an action error on a file, the error is only logged in the file status. |
|
| 659 | + // Return Values : |
|
| 660 | + // 0 on an unrecoverable failure, |
|
| 661 | + // The list of the files in the archive. |
|
| 662 | + // -------------------------------------------------------------------------------- |
|
| 663 | + function listContent() |
|
| 664 | + {
|
|
| 665 | 665 | $v_result=1; |
| 666 | 666 | |
| 667 | 667 | // ----- Reset the error handler |
@@ -669,56 +669,56 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | // ----- Check archive |
| 671 | 671 | if (!$this->privCheckFormat()) {
|
| 672 | - return(0); |
|
| 672 | + return(0); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | // ----- Call the extracting fct |
| 676 | 676 | $p_list = array(); |
| 677 | 677 | if (($v_result = $this->privList($p_list)) != 1) |
| 678 | 678 | {
|
| 679 | - unset($p_list); |
|
| 680 | - return(0); |
|
| 679 | + unset($p_list); |
|
| 680 | + return(0); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | // ----- Return |
| 684 | 684 | return $p_list; |
| 685 | - } |
|
| 686 | - // -------------------------------------------------------------------------------- |
|
| 687 | - |
|
| 688 | - // -------------------------------------------------------------------------------- |
|
| 689 | - // Function : |
|
| 690 | - // extract($p_path="./", $p_remove_path="") |
|
| 691 | - // extract([$p_option, $p_option_value, ...]) |
|
| 692 | - // Description : |
|
| 693 | - // This method supports two synopsis. The first one is historical. |
|
| 694 | - // This method extract all the files / directories from the archive to the |
|
| 695 | - // folder indicated in $p_path. |
|
| 696 | - // If you want to ignore the 'root' part of path of the memorized files |
|
| 697 | - // you can indicate this in the optional $p_remove_path parameter. |
|
| 698 | - // By default, if a newer file with the same name already exists, the |
|
| 699 | - // file is not extracted. |
|
| 700 | - // |
|
| 701 | - // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions |
|
| 702 | - // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append |
|
| 703 | - // at the end of the path value of PCLZIP_OPT_PATH. |
|
| 704 | - // Parameters : |
|
| 705 | - // $p_path : Path where the files and directories are to be extracted |
|
| 706 | - // $p_remove_path : First part ('root' part) of the memorized path
|
|
| 707 | - // (if any similar) to remove while extracting. |
|
| 708 | - // Options : |
|
| 709 | - // PCLZIP_OPT_PATH : |
|
| 710 | - // PCLZIP_OPT_ADD_PATH : |
|
| 711 | - // PCLZIP_OPT_REMOVE_PATH : |
|
| 712 | - // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 713 | - // PCLZIP_CB_PRE_EXTRACT : |
|
| 714 | - // PCLZIP_CB_POST_EXTRACT : |
|
| 715 | - // Return Values : |
|
| 716 | - // 0 or a negative value on failure, |
|
| 717 | - // The list of the extracted files, with a status of the action. |
|
| 718 | - // (see PclZip::listContent() for list entry format) |
|
| 719 | - // -------------------------------------------------------------------------------- |
|
| 720 | - function extract() |
|
| 721 | - {
|
|
| 685 | + } |
|
| 686 | + // -------------------------------------------------------------------------------- |
|
| 687 | + |
|
| 688 | + // -------------------------------------------------------------------------------- |
|
| 689 | + // Function : |
|
| 690 | + // extract($p_path="./", $p_remove_path="") |
|
| 691 | + // extract([$p_option, $p_option_value, ...]) |
|
| 692 | + // Description : |
|
| 693 | + // This method supports two synopsis. The first one is historical. |
|
| 694 | + // This method extract all the files / directories from the archive to the |
|
| 695 | + // folder indicated in $p_path. |
|
| 696 | + // If you want to ignore the 'root' part of path of the memorized files |
|
| 697 | + // you can indicate this in the optional $p_remove_path parameter. |
|
| 698 | + // By default, if a newer file with the same name already exists, the |
|
| 699 | + // file is not extracted. |
|
| 700 | + // |
|
| 701 | + // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions |
|
| 702 | + // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append |
|
| 703 | + // at the end of the path value of PCLZIP_OPT_PATH. |
|
| 704 | + // Parameters : |
|
| 705 | + // $p_path : Path where the files and directories are to be extracted |
|
| 706 | + // $p_remove_path : First part ('root' part) of the memorized path
|
|
| 707 | + // (if any similar) to remove while extracting. |
|
| 708 | + // Options : |
|
| 709 | + // PCLZIP_OPT_PATH : |
|
| 710 | + // PCLZIP_OPT_ADD_PATH : |
|
| 711 | + // PCLZIP_OPT_REMOVE_PATH : |
|
| 712 | + // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 713 | + // PCLZIP_CB_PRE_EXTRACT : |
|
| 714 | + // PCLZIP_CB_POST_EXTRACT : |
|
| 715 | + // Return Values : |
|
| 716 | + // 0 or a negative value on failure, |
|
| 717 | + // The list of the extracted files, with a status of the action. |
|
| 718 | + // (see PclZip::listContent() for list entry format) |
|
| 719 | + // -------------------------------------------------------------------------------- |
|
| 720 | + function extract() |
|
| 721 | + {
|
|
| 722 | 722 | $v_result=1; |
| 723 | 723 | |
| 724 | 724 | // ----- Reset the error handler |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | |
| 727 | 727 | // ----- Check archive |
| 728 | 728 | if (!$this->privCheckFormat()) {
|
| 729 | - return(0); |
|
| 729 | + return(0); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | // ----- Set default values |
@@ -744,77 +744,77 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | // ----- Look for arguments |
| 746 | 746 | if ($v_size > 0) {
|
| 747 | - // ----- Get the arguments |
|
| 748 | - $v_arg_list = func_get_args(); |
|
| 747 | + // ----- Get the arguments |
|
| 748 | + $v_arg_list = func_get_args(); |
|
| 749 | 749 | |
| 750 | - // ----- Look for first arg |
|
| 751 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 750 | + // ----- Look for first arg |
|
| 751 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 752 | 752 | |
| 753 | 753 | // ----- Parse the options |
| 754 | 754 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 755 | 755 | array (PCLZIP_OPT_PATH => 'optional', |
| 756 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 757 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 758 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 759 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 760 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 761 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 762 | - PCLZIP_OPT_BY_NAME => 'optional', |
|
| 763 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 764 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 765 | - PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 766 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 767 | - PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 768 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 769 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 770 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 771 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 772 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 773 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 774 | - )); |
|
| 756 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 757 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 758 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 759 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 760 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 761 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 762 | + PCLZIP_OPT_BY_NAME => 'optional', |
|
| 763 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 764 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 765 | + PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 766 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 767 | + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 768 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 769 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 770 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 771 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 772 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 773 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 774 | + )); |
|
| 775 | 775 | if ($v_result != 1) {
|
| 776 | - return 0; |
|
| 776 | + return 0; |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | // ----- Set the arguments |
| 780 | 780 | if (isset($v_options[PCLZIP_OPT_PATH])) {
|
| 781 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 781 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 782 | 782 | } |
| 783 | 783 | if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
|
| 784 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 784 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 785 | 785 | } |
| 786 | 786 | if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
| 787 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 787 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 788 | 788 | } |
| 789 | 789 | if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
|
| 790 | - // ----- Check for '/' in last path char |
|
| 791 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
|
| 790 | + // ----- Check for '/' in last path char |
|
| 791 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
|
| 792 | 792 | $v_path .= '/'; |
| 793 | - } |
|
| 794 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 793 | + } |
|
| 794 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 795 | + } |
|
| 795 | 796 | } |
| 796 | - } |
|
| 797 | 797 | |
| 798 | - // ----- Look for 2 args |
|
| 799 | - // Here we need to support the first historic synopsis of the |
|
| 800 | - // method. |
|
| 801 | - else {
|
|
| 798 | + // ----- Look for 2 args |
|
| 799 | + // Here we need to support the first historic synopsis of the |
|
| 800 | + // method. |
|
| 801 | + else {
|
|
| 802 | 802 | |
| 803 | 803 | // ----- Get the first argument |
| 804 | 804 | $v_path = $v_arg_list[0]; |
| 805 | 805 | |
| 806 | 806 | // ----- Look for the optional second argument |
| 807 | 807 | if ($v_size == 2) {
|
| 808 | - $v_remove_path = $v_arg_list[1]; |
|
| 808 | + $v_remove_path = $v_arg_list[1]; |
|
| 809 | 809 | } |
| 810 | 810 | else if ($v_size > 2) {
|
| 811 | - // ----- Error log |
|
| 812 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 811 | + // ----- Error log |
|
| 812 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 813 | 813 | |
| 814 | - // ----- Return |
|
| 815 | - return 0; |
|
| 814 | + // ----- Return |
|
| 815 | + return 0; |
|
| 816 | + } |
|
| 816 | 817 | } |
| 817 | - } |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | // ----- Look for default option values |
@@ -825,57 +825,57 @@ discard block |
||
| 825 | 825 | // ----- Call the extracting fct |
| 826 | 826 | $p_list = array(); |
| 827 | 827 | $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, |
| 828 | - $v_remove_all_path, $v_options); |
|
| 828 | + $v_remove_all_path, $v_options); |
|
| 829 | 829 | if ($v_result < 1) {
|
| 830 | - unset($p_list); |
|
| 831 | - return(0); |
|
| 830 | + unset($p_list); |
|
| 831 | + return(0); |
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | // ----- Return |
| 835 | 835 | return $p_list; |
| 836 | - } |
|
| 837 | - // -------------------------------------------------------------------------------- |
|
| 838 | - |
|
| 839 | - |
|
| 840 | - // -------------------------------------------------------------------------------- |
|
| 841 | - // Function : |
|
| 842 | - // extractByIndex($p_index, $p_path="./", $p_remove_path="") |
|
| 843 | - // extractByIndex($p_index, [$p_option, $p_option_value, ...]) |
|
| 844 | - // Description : |
|
| 845 | - // This method supports two synopsis. The first one is historical. |
|
| 846 | - // This method is doing a partial extract of the archive. |
|
| 847 | - // The extracted files or folders are identified by their index in the |
|
| 848 | - // archive (from 0 to n). |
|
| 849 | - // Note that if the index identify a folder, only the folder entry is |
|
| 850 | - // extracted, not all the files included in the archive. |
|
| 851 | - // Parameters : |
|
| 852 | - // $p_index : A single index (integer) or a string of indexes of files to |
|
| 853 | - // extract. The form of the string is "0,4-6,8-12" with only numbers |
|
| 854 | - // and '-' for range or ',' to separate ranges. No spaces or ';' |
|
| 855 | - // are allowed. |
|
| 856 | - // $p_path : Path where the files and directories are to be extracted |
|
| 857 | - // $p_remove_path : First part ('root' part) of the memorized path
|
|
| 858 | - // (if any similar) to remove while extracting. |
|
| 859 | - // Options : |
|
| 860 | - // PCLZIP_OPT_PATH : |
|
| 861 | - // PCLZIP_OPT_ADD_PATH : |
|
| 862 | - // PCLZIP_OPT_REMOVE_PATH : |
|
| 863 | - // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 864 | - // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and |
|
| 865 | - // not as files. |
|
| 866 | - // The resulting content is in a new field 'content' in the file |
|
| 867 | - // structure. |
|
| 868 | - // This option must be used alone (any other options are ignored). |
|
| 869 | - // PCLZIP_CB_PRE_EXTRACT : |
|
| 870 | - // PCLZIP_CB_POST_EXTRACT : |
|
| 871 | - // Return Values : |
|
| 872 | - // 0 on failure, |
|
| 873 | - // The list of the extracted files, with a status of the action. |
|
| 874 | - // (see PclZip::listContent() for list entry format) |
|
| 875 | - // -------------------------------------------------------------------------------- |
|
| 876 | - //function extractByIndex($p_index, options...) |
|
| 877 | - function extractByIndex($p_index) |
|
| 878 | - {
|
|
| 836 | + } |
|
| 837 | + // -------------------------------------------------------------------------------- |
|
| 838 | + |
|
| 839 | + |
|
| 840 | + // -------------------------------------------------------------------------------- |
|
| 841 | + // Function : |
|
| 842 | + // extractByIndex($p_index, $p_path="./", $p_remove_path="") |
|
| 843 | + // extractByIndex($p_index, [$p_option, $p_option_value, ...]) |
|
| 844 | + // Description : |
|
| 845 | + // This method supports two synopsis. The first one is historical. |
|
| 846 | + // This method is doing a partial extract of the archive. |
|
| 847 | + // The extracted files or folders are identified by their index in the |
|
| 848 | + // archive (from 0 to n). |
|
| 849 | + // Note that if the index identify a folder, only the folder entry is |
|
| 850 | + // extracted, not all the files included in the archive. |
|
| 851 | + // Parameters : |
|
| 852 | + // $p_index : A single index (integer) or a string of indexes of files to |
|
| 853 | + // extract. The form of the string is "0,4-6,8-12" with only numbers |
|
| 854 | + // and '-' for range or ',' to separate ranges. No spaces or ';' |
|
| 855 | + // are allowed. |
|
| 856 | + // $p_path : Path where the files and directories are to be extracted |
|
| 857 | + // $p_remove_path : First part ('root' part) of the memorized path
|
|
| 858 | + // (if any similar) to remove while extracting. |
|
| 859 | + // Options : |
|
| 860 | + // PCLZIP_OPT_PATH : |
|
| 861 | + // PCLZIP_OPT_ADD_PATH : |
|
| 862 | + // PCLZIP_OPT_REMOVE_PATH : |
|
| 863 | + // PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 864 | + // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and |
|
| 865 | + // not as files. |
|
| 866 | + // The resulting content is in a new field 'content' in the file |
|
| 867 | + // structure. |
|
| 868 | + // This option must be used alone (any other options are ignored). |
|
| 869 | + // PCLZIP_CB_PRE_EXTRACT : |
|
| 870 | + // PCLZIP_CB_POST_EXTRACT : |
|
| 871 | + // Return Values : |
|
| 872 | + // 0 on failure, |
|
| 873 | + // The list of the extracted files, with a status of the action. |
|
| 874 | + // (see PclZip::listContent() for list entry format) |
|
| 875 | + // -------------------------------------------------------------------------------- |
|
| 876 | + //function extractByIndex($p_index, options...) |
|
| 877 | + function extractByIndex($p_index) |
|
| 878 | + {
|
|
| 879 | 879 | $v_result=1; |
| 880 | 880 | |
| 881 | 881 | // ----- Reset the error handler |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | // ----- Check archive |
| 885 | 885 | if (!$this->privCheckFormat()) {
|
| 886 | - return(0); |
|
| 886 | + return(0); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | // ----- Set default values |
@@ -901,81 +901,81 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | // ----- Look for arguments |
| 903 | 903 | if ($v_size > 1) {
|
| 904 | - // ----- Get the arguments |
|
| 905 | - $v_arg_list = func_get_args(); |
|
| 904 | + // ----- Get the arguments |
|
| 905 | + $v_arg_list = func_get_args(); |
|
| 906 | 906 | |
| 907 | - // ----- Remove form the options list the first argument |
|
| 908 | - array_shift($v_arg_list); |
|
| 909 | - $v_size--; |
|
| 907 | + // ----- Remove form the options list the first argument |
|
| 908 | + array_shift($v_arg_list); |
|
| 909 | + $v_size--; |
|
| 910 | 910 | |
| 911 | - // ----- Look for first arg |
|
| 912 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 911 | + // ----- Look for first arg |
|
| 912 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
|
| 913 | 913 | |
| 914 | 914 | // ----- Parse the options |
| 915 | 915 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 916 | 916 | array (PCLZIP_OPT_PATH => 'optional', |
| 917 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 918 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 919 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 920 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 921 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 922 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 923 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 924 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 925 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 926 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 927 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 928 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 929 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 930 | - )); |
|
| 917 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 918 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 919 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 920 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 921 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 922 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 923 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 924 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 925 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 926 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 927 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 928 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 929 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 930 | + )); |
|
| 931 | 931 | if ($v_result != 1) {
|
| 932 | - return 0; |
|
| 932 | + return 0; |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | // ----- Set the arguments |
| 936 | 936 | if (isset($v_options[PCLZIP_OPT_PATH])) {
|
| 937 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 937 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 938 | 938 | } |
| 939 | 939 | if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
|
| 940 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 940 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 941 | 941 | } |
| 942 | 942 | if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
| 943 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 943 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 944 | 944 | } |
| 945 | 945 | if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
|
| 946 | - // ----- Check for '/' in last path char |
|
| 947 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
|
| 946 | + // ----- Check for '/' in last path char |
|
| 947 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
|
| 948 | 948 | $v_path .= '/'; |
| 949 | - } |
|
| 950 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 949 | + } |
|
| 950 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 951 | 951 | } |
| 952 | 952 | if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
|
| 953 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 953 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 954 | 954 | } |
| 955 | 955 | else {
|
| 956 | 956 | } |
| 957 | - } |
|
| 957 | + } |
|
| 958 | 958 | |
| 959 | - // ----- Look for 2 args |
|
| 960 | - // Here we need to support the first historic synopsis of the |
|
| 961 | - // method. |
|
| 962 | - else {
|
|
| 959 | + // ----- Look for 2 args |
|
| 960 | + // Here we need to support the first historic synopsis of the |
|
| 961 | + // method. |
|
| 962 | + else {
|
|
| 963 | 963 | |
| 964 | 964 | // ----- Get the first argument |
| 965 | 965 | $v_path = $v_arg_list[0]; |
| 966 | 966 | |
| 967 | 967 | // ----- Look for the optional second argument |
| 968 | 968 | if ($v_size == 2) {
|
| 969 | - $v_remove_path = $v_arg_list[1]; |
|
| 969 | + $v_remove_path = $v_arg_list[1]; |
|
| 970 | 970 | } |
| 971 | 971 | else if ($v_size > 2) {
|
| 972 | - // ----- Error log |
|
| 973 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 972 | + // ----- Error log |
|
| 973 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 974 | 974 | |
| 975 | - // ----- Return |
|
| 976 | - return 0; |
|
| 975 | + // ----- Return |
|
| 976 | + return 0; |
|
| 977 | + } |
|
| 977 | 978 | } |
| 978 | - } |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | // ----- Trace |
@@ -1002,29 +1002,29 @@ discard block |
||
| 1002 | 1002 | |
| 1003 | 1003 | // ----- Return |
| 1004 | 1004 | return $p_list; |
| 1005 | - } |
|
| 1006 | - // -------------------------------------------------------------------------------- |
|
| 1007 | - |
|
| 1008 | - // -------------------------------------------------------------------------------- |
|
| 1009 | - // Function : |
|
| 1010 | - // delete([$p_option, $p_option_value, ...]) |
|
| 1011 | - // Description : |
|
| 1012 | - // This method removes files from the archive. |
|
| 1013 | - // If no parameters are given, then all the archive is emptied. |
|
| 1014 | - // Parameters : |
|
| 1015 | - // None or optional arguments. |
|
| 1016 | - // Options : |
|
| 1017 | - // PCLZIP_OPT_BY_INDEX : |
|
| 1018 | - // PCLZIP_OPT_BY_NAME : |
|
| 1019 | - // PCLZIP_OPT_BY_EREG : |
|
| 1020 | - // PCLZIP_OPT_BY_PREG : |
|
| 1021 | - // Return Values : |
|
| 1022 | - // 0 on failure, |
|
| 1023 | - // The list of the files which are still present in the archive. |
|
| 1024 | - // (see PclZip::listContent() for list entry format) |
|
| 1025 | - // -------------------------------------------------------------------------------- |
|
| 1026 | - function delete() |
|
| 1027 | - {
|
|
| 1005 | + } |
|
| 1006 | + // -------------------------------------------------------------------------------- |
|
| 1007 | + |
|
| 1008 | + // -------------------------------------------------------------------------------- |
|
| 1009 | + // Function : |
|
| 1010 | + // delete([$p_option, $p_option_value, ...]) |
|
| 1011 | + // Description : |
|
| 1012 | + // This method removes files from the archive. |
|
| 1013 | + // If no parameters are given, then all the archive is emptied. |
|
| 1014 | + // Parameters : |
|
| 1015 | + // None or optional arguments. |
|
| 1016 | + // Options : |
|
| 1017 | + // PCLZIP_OPT_BY_INDEX : |
|
| 1018 | + // PCLZIP_OPT_BY_NAME : |
|
| 1019 | + // PCLZIP_OPT_BY_EREG : |
|
| 1020 | + // PCLZIP_OPT_BY_PREG : |
|
| 1021 | + // Return Values : |
|
| 1022 | + // 0 on failure, |
|
| 1023 | + // The list of the files which are still present in the archive. |
|
| 1024 | + // (see PclZip::listContent() for list entry format) |
|
| 1025 | + // -------------------------------------------------------------------------------- |
|
| 1026 | + function delete() |
|
| 1027 | + {
|
|
| 1028 | 1028 | $v_result=1; |
| 1029 | 1029 | |
| 1030 | 1030 | // ----- Reset the error handler |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | // ----- Check archive |
| 1034 | 1034 | if (!$this->privCheckFormat()) {
|
| 1035 | - return(0); |
|
| 1035 | + return(0); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | // ----- Set default values |
@@ -1043,18 +1043,18 @@ discard block |
||
| 1043 | 1043 | |
| 1044 | 1044 | // ----- Look for arguments |
| 1045 | 1045 | if ($v_size > 0) {
|
| 1046 | - // ----- Get the arguments |
|
| 1047 | - $v_arg_list = func_get_args(); |
|
| 1046 | + // ----- Get the arguments |
|
| 1047 | + $v_arg_list = func_get_args(); |
|
| 1048 | 1048 | |
| 1049 | - // ----- Parse the options |
|
| 1050 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1049 | + // ----- Parse the options |
|
| 1050 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1051 | 1051 | array (PCLZIP_OPT_BY_NAME => 'optional', |
| 1052 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1053 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1054 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1055 | - if ($v_result != 1) {
|
|
| 1056 | - return 0; |
|
| 1057 | - } |
|
| 1052 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1053 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1054 | + PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1055 | + if ($v_result != 1) {
|
|
| 1056 | + return 0; |
|
| 1057 | + } |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | // ----- Magic quotes trick |
@@ -1063,9 +1063,9 @@ discard block |
||
| 1063 | 1063 | // ----- Call the delete fct |
| 1064 | 1064 | $v_list = array(); |
| 1065 | 1065 | if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
|
| 1066 | - $this->privSwapBackMagicQuotes(); |
|
| 1067 | - unset($v_list); |
|
| 1068 | - return(0); |
|
| 1066 | + $this->privSwapBackMagicQuotes(); |
|
| 1067 | + unset($v_list); |
|
| 1068 | + return(0); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | // ----- Magic quotes trick |
@@ -1073,41 +1073,41 @@ discard block |
||
| 1073 | 1073 | |
| 1074 | 1074 | // ----- Return |
| 1075 | 1075 | return $v_list; |
| 1076 | - } |
|
| 1077 | - // -------------------------------------------------------------------------------- |
|
| 1078 | - |
|
| 1079 | - // -------------------------------------------------------------------------------- |
|
| 1080 | - // Function : deleteByIndex() |
|
| 1081 | - // Description : |
|
| 1082 | - // ***** Deprecated ***** |
|
| 1083 | - // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. |
|
| 1084 | - // -------------------------------------------------------------------------------- |
|
| 1085 | - function deleteByIndex($p_index) |
|
| 1086 | - {
|
|
| 1076 | + } |
|
| 1077 | + // -------------------------------------------------------------------------------- |
|
| 1078 | + |
|
| 1079 | + // -------------------------------------------------------------------------------- |
|
| 1080 | + // Function : deleteByIndex() |
|
| 1081 | + // Description : |
|
| 1082 | + // ***** Deprecated ***** |
|
| 1083 | + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. |
|
| 1084 | + // -------------------------------------------------------------------------------- |
|
| 1085 | + function deleteByIndex($p_index) |
|
| 1086 | + {
|
|
| 1087 | 1087 | |
| 1088 | 1088 | $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
| 1089 | 1089 | |
| 1090 | 1090 | // ----- Return |
| 1091 | 1091 | return $p_list; |
| 1092 | - } |
|
| 1093 | - // -------------------------------------------------------------------------------- |
|
| 1094 | - |
|
| 1095 | - // -------------------------------------------------------------------------------- |
|
| 1096 | - // Function : properties() |
|
| 1097 | - // Description : |
|
| 1098 | - // This method gives the properties of the archive. |
|
| 1099 | - // The properties are : |
|
| 1100 | - // nb : Number of files in the archive |
|
| 1101 | - // comment : Comment associated with the archive file |
|
| 1102 | - // status : not_exist, ok |
|
| 1103 | - // Parameters : |
|
| 1104 | - // None |
|
| 1105 | - // Return Values : |
|
| 1106 | - // 0 on failure, |
|
| 1107 | - // An array with the archive properties. |
|
| 1108 | - // -------------------------------------------------------------------------------- |
|
| 1109 | - function properties() |
|
| 1110 | - {
|
|
| 1092 | + } |
|
| 1093 | + // -------------------------------------------------------------------------------- |
|
| 1094 | + |
|
| 1095 | + // -------------------------------------------------------------------------------- |
|
| 1096 | + // Function : properties() |
|
| 1097 | + // Description : |
|
| 1098 | + // This method gives the properties of the archive. |
|
| 1099 | + // The properties are : |
|
| 1100 | + // nb : Number of files in the archive |
|
| 1101 | + // comment : Comment associated with the archive file |
|
| 1102 | + // status : not_exist, ok |
|
| 1103 | + // Parameters : |
|
| 1104 | + // None |
|
| 1105 | + // Return Values : |
|
| 1106 | + // 0 on failure, |
|
| 1107 | + // An array with the archive properties. |
|
| 1108 | + // -------------------------------------------------------------------------------- |
|
| 1109 | + function properties() |
|
| 1110 | + {
|
|
| 1111 | 1111 | |
| 1112 | 1112 | // ----- Reset the error handler |
| 1113 | 1113 | $this->privErrorReset(); |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | |
| 1118 | 1118 | // ----- Check archive |
| 1119 | 1119 | if (!$this->privCheckFormat()) {
|
| 1120 | - $this->privSwapBackMagicQuotes(); |
|
| 1121 | - return(0); |
|
| 1120 | + $this->privSwapBackMagicQuotes(); |
|
| 1121 | + return(0); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | // ----- Default properties |
@@ -1130,9 +1130,9 @@ discard block |
||
| 1130 | 1130 | // ----- Look if file exists |
| 1131 | 1131 | if (@is_file($this->zipname)) |
| 1132 | 1132 | {
|
| 1133 | - // ----- Open the zip file |
|
| 1134 | - if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1135 | - {
|
|
| 1133 | + // ----- Open the zip file |
|
| 1134 | + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1135 | + {
|
|
| 1136 | 1136 | $this->privSwapBackMagicQuotes(); |
| 1137 | 1137 | |
| 1138 | 1138 | // ----- Error log |
@@ -1140,23 +1140,23 @@ discard block |
||
| 1140 | 1140 | |
| 1141 | 1141 | // ----- Return |
| 1142 | 1142 | return 0; |
| 1143 | - } |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | - // ----- Read the central directory informations |
|
| 1146 | - $v_central_dir = array(); |
|
| 1147 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1148 | - {
|
|
| 1145 | + // ----- Read the central directory informations |
|
| 1146 | + $v_central_dir = array(); |
|
| 1147 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1148 | + {
|
|
| 1149 | 1149 | $this->privSwapBackMagicQuotes(); |
| 1150 | 1150 | return 0; |
| 1151 | - } |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | - // ----- Close the zip file |
|
| 1154 | - $this->privCloseFd(); |
|
| 1153 | + // ----- Close the zip file |
|
| 1154 | + $this->privCloseFd(); |
|
| 1155 | 1155 | |
| 1156 | - // ----- Set the user attributes |
|
| 1157 | - $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1158 | - $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1159 | - $v_prop['status'] = 'ok'; |
|
| 1156 | + // ----- Set the user attributes |
|
| 1157 | + $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1158 | + $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1159 | + $v_prop['status'] = 'ok'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | 1162 | // ----- Magic quotes trick |
@@ -1164,23 +1164,23 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | // ----- Return |
| 1166 | 1166 | return $v_prop; |
| 1167 | - } |
|
| 1168 | - // -------------------------------------------------------------------------------- |
|
| 1169 | - |
|
| 1170 | - // -------------------------------------------------------------------------------- |
|
| 1171 | - // Function : duplicate() |
|
| 1172 | - // Description : |
|
| 1173 | - // This method creates an archive by copying the content of an other one. If |
|
| 1174 | - // the archive already exist, it is replaced by the new one without any warning. |
|
| 1175 | - // Parameters : |
|
| 1176 | - // $p_archive : The filename of a valid archive, or |
|
| 1177 | - // a valid PclZip object. |
|
| 1178 | - // Return Values : |
|
| 1179 | - // 1 on success. |
|
| 1180 | - // 0 or a negative value on error (error code). |
|
| 1181 | - // -------------------------------------------------------------------------------- |
|
| 1182 | - function duplicate($p_archive) |
|
| 1183 | - {
|
|
| 1167 | + } |
|
| 1168 | + // -------------------------------------------------------------------------------- |
|
| 1169 | + |
|
| 1170 | + // -------------------------------------------------------------------------------- |
|
| 1171 | + // Function : duplicate() |
|
| 1172 | + // Description : |
|
| 1173 | + // This method creates an archive by copying the content of an other one. If |
|
| 1174 | + // the archive already exist, it is replaced by the new one without any warning. |
|
| 1175 | + // Parameters : |
|
| 1176 | + // $p_archive : The filename of a valid archive, or |
|
| 1177 | + // a valid PclZip object. |
|
| 1178 | + // Return Values : |
|
| 1179 | + // 1 on success. |
|
| 1180 | + // 0 or a negative value on error (error code). |
|
| 1181 | + // -------------------------------------------------------------------------------- |
|
| 1182 | + function duplicate($p_archive) |
|
| 1183 | + {
|
|
| 1184 | 1184 | $v_result = 1; |
| 1185 | 1185 | |
| 1186 | 1186 | // ----- Reset the error handler |
@@ -1190,56 +1190,56 @@ discard block |
||
| 1190 | 1190 | if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) |
| 1191 | 1191 | {
|
| 1192 | 1192 | |
| 1193 | - // ----- Duplicate the archive |
|
| 1194 | - $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1193 | + // ----- Duplicate the archive |
|
| 1194 | + $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | // ----- Look if the $p_archive is a string (so a filename) |
| 1198 | 1198 | else if (is_string($p_archive)) |
| 1199 | 1199 | {
|
| 1200 | 1200 | |
| 1201 | - // ----- Check that $p_archive is a valid zip file |
|
| 1202 | - // TBC : Should also check the archive format |
|
| 1203 | - if (!is_file($p_archive)) {
|
|
| 1201 | + // ----- Check that $p_archive is a valid zip file |
|
| 1202 | + // TBC : Should also check the archive format |
|
| 1203 | + if (!is_file($p_archive)) {
|
|
| 1204 | 1204 | // ----- Error log |
| 1205 | 1205 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
| 1206 | 1206 | $v_result = PCLZIP_ERR_MISSING_FILE; |
| 1207 | - } |
|
| 1208 | - else {
|
|
| 1207 | + } |
|
| 1208 | + else {
|
|
| 1209 | 1209 | // ----- Duplicate the archive |
| 1210 | 1210 | $v_result = $this->privDuplicate($p_archive); |
| 1211 | - } |
|
| 1211 | + } |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | // ----- Invalid variable |
| 1215 | 1215 | else |
| 1216 | 1216 | {
|
| 1217 | - // ----- Error log |
|
| 1218 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1219 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1217 | + // ----- Error log |
|
| 1218 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1219 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | // ----- Return |
| 1223 | 1223 | return $v_result; |
| 1224 | - } |
|
| 1225 | - // -------------------------------------------------------------------------------- |
|
| 1226 | - |
|
| 1227 | - // -------------------------------------------------------------------------------- |
|
| 1228 | - // Function : merge() |
|
| 1229 | - // Description : |
|
| 1230 | - // This method merge the $p_archive_to_add archive at the end of the current |
|
| 1231 | - // one ($this). |
|
| 1232 | - // If the archive ($this) does not exist, the merge becomes a duplicate. |
|
| 1233 | - // If the $p_archive_to_add archive does not exist, the merge is a success. |
|
| 1234 | - // Parameters : |
|
| 1235 | - // $p_archive_to_add : It can be directly the filename of a valid zip archive, |
|
| 1236 | - // or a PclZip object archive. |
|
| 1237 | - // Return Values : |
|
| 1238 | - // 1 on success, |
|
| 1239 | - // 0 or negative values on error (see below). |
|
| 1240 | - // -------------------------------------------------------------------------------- |
|
| 1241 | - function merge($p_archive_to_add) |
|
| 1242 | - {
|
|
| 1224 | + } |
|
| 1225 | + // -------------------------------------------------------------------------------- |
|
| 1226 | + |
|
| 1227 | + // -------------------------------------------------------------------------------- |
|
| 1228 | + // Function : merge() |
|
| 1229 | + // Description : |
|
| 1230 | + // This method merge the $p_archive_to_add archive at the end of the current |
|
| 1231 | + // one ($this). |
|
| 1232 | + // If the archive ($this) does not exist, the merge becomes a duplicate. |
|
| 1233 | + // If the $p_archive_to_add archive does not exist, the merge is a success. |
|
| 1234 | + // Parameters : |
|
| 1235 | + // $p_archive_to_add : It can be directly the filename of a valid zip archive, |
|
| 1236 | + // or a PclZip object archive. |
|
| 1237 | + // Return Values : |
|
| 1238 | + // 1 on success, |
|
| 1239 | + // 0 or negative values on error (see below). |
|
| 1240 | + // -------------------------------------------------------------------------------- |
|
| 1241 | + function merge($p_archive_to_add) |
|
| 1242 | + {
|
|
| 1243 | 1243 | $v_result = 1; |
| 1244 | 1244 | |
| 1245 | 1245 | // ----- Reset the error handler |
@@ -1247,125 +1247,125 @@ discard block |
||
| 1247 | 1247 | |
| 1248 | 1248 | // ----- Check archive |
| 1249 | 1249 | if (!$this->privCheckFormat()) {
|
| 1250 | - return(0); |
|
| 1250 | + return(0); |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | // ----- Look if the $p_archive_to_add is a PclZip object |
| 1254 | 1254 | if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) |
| 1255 | 1255 | {
|
| 1256 | 1256 | |
| 1257 | - // ----- Merge the archive |
|
| 1258 | - $v_result = $this->privMerge($p_archive_to_add); |
|
| 1257 | + // ----- Merge the archive |
|
| 1258 | + $v_result = $this->privMerge($p_archive_to_add); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | // ----- Look if the $p_archive_to_add is a string (so a filename) |
| 1262 | 1262 | else if (is_string($p_archive_to_add)) |
| 1263 | 1263 | {
|
| 1264 | 1264 | |
| 1265 | - // ----- Create a temporary archive |
|
| 1266 | - $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1265 | + // ----- Create a temporary archive |
|
| 1266 | + $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1267 | 1267 | |
| 1268 | - // ----- Merge the archive |
|
| 1269 | - $v_result = $this->privMerge($v_object_archive); |
|
| 1268 | + // ----- Merge the archive |
|
| 1269 | + $v_result = $this->privMerge($v_object_archive); |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | // ----- Invalid variable |
| 1273 | 1273 | else |
| 1274 | 1274 | {
|
| 1275 | - // ----- Error log |
|
| 1276 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1277 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1275 | + // ----- Error log |
|
| 1276 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1277 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | // ----- Return |
| 1281 | 1281 | return $v_result; |
| 1282 | - } |
|
| 1283 | - // -------------------------------------------------------------------------------- |
|
| 1282 | + } |
|
| 1283 | + // -------------------------------------------------------------------------------- |
|
| 1284 | 1284 | |
| 1285 | 1285 | |
| 1286 | 1286 | |
| 1287 | - // -------------------------------------------------------------------------------- |
|
| 1288 | - // Function : errorCode() |
|
| 1289 | - // Description : |
|
| 1290 | - // Parameters : |
|
| 1291 | - // -------------------------------------------------------------------------------- |
|
| 1292 | - function errorCode() |
|
| 1293 | - {
|
|
| 1287 | + // -------------------------------------------------------------------------------- |
|
| 1288 | + // Function : errorCode() |
|
| 1289 | + // Description : |
|
| 1290 | + // Parameters : |
|
| 1291 | + // -------------------------------------------------------------------------------- |
|
| 1292 | + function errorCode() |
|
| 1293 | + {
|
|
| 1294 | 1294 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 1295 | - return(PclErrorCode()); |
|
| 1295 | + return(PclErrorCode()); |
|
| 1296 | 1296 | } |
| 1297 | 1297 | else {
|
| 1298 | - return($this->error_code); |
|
| 1299 | - } |
|
| 1300 | - } |
|
| 1301 | - // -------------------------------------------------------------------------------- |
|
| 1302 | - |
|
| 1303 | - // -------------------------------------------------------------------------------- |
|
| 1304 | - // Function : errorName() |
|
| 1305 | - // Description : |
|
| 1306 | - // Parameters : |
|
| 1307 | - // -------------------------------------------------------------------------------- |
|
| 1308 | - function errorName($p_with_code=false) |
|
| 1309 | - {
|
|
| 1298 | + return($this->error_code); |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | + // -------------------------------------------------------------------------------- |
|
| 1302 | + |
|
| 1303 | + // -------------------------------------------------------------------------------- |
|
| 1304 | + // Function : errorName() |
|
| 1305 | + // Description : |
|
| 1306 | + // Parameters : |
|
| 1307 | + // -------------------------------------------------------------------------------- |
|
| 1308 | + function errorName($p_with_code=false) |
|
| 1309 | + {
|
|
| 1310 | 1310 | $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
| 1311 | - PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1312 | - PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1313 | - PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1314 | - PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1315 | - PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1316 | - PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1317 | - PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1318 | - PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1319 | - PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1320 | - PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1321 | - PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1322 | - PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1323 | - PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1324 | - PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1325 | - PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1326 | - PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1327 | - PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1328 | - PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1329 | - ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1330 | - ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1311 | + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1312 | + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1313 | + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1314 | + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1315 | + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1316 | + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1317 | + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1318 | + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1319 | + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1320 | + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1321 | + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1322 | + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1323 | + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1324 | + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1325 | + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1326 | + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1327 | + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1328 | + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1329 | + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1330 | + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1331 | 1331 | ); |
| 1332 | 1332 | |
| 1333 | 1333 | if (isset($v_name[$this->error_code])) {
|
| 1334 | - $v_value = $v_name[$this->error_code]; |
|
| 1334 | + $v_value = $v_name[$this->error_code]; |
|
| 1335 | 1335 | } |
| 1336 | 1336 | else {
|
| 1337 | - $v_value = 'NoName'; |
|
| 1337 | + $v_value = 'NoName'; |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | if ($p_with_code) {
|
| 1341 | - return($v_value.' ('.$this->error_code.')');
|
|
| 1341 | + return($v_value.' ('.$this->error_code.')');
|
|
| 1342 | 1342 | } |
| 1343 | 1343 | else {
|
| 1344 | - return($v_value); |
|
| 1345 | - } |
|
| 1346 | - } |
|
| 1347 | - // -------------------------------------------------------------------------------- |
|
| 1348 | - |
|
| 1349 | - // -------------------------------------------------------------------------------- |
|
| 1350 | - // Function : errorInfo() |
|
| 1351 | - // Description : |
|
| 1352 | - // Parameters : |
|
| 1353 | - // -------------------------------------------------------------------------------- |
|
| 1354 | - function errorInfo($p_full=false) |
|
| 1355 | - {
|
|
| 1344 | + return($v_value); |
|
| 1345 | + } |
|
| 1346 | + } |
|
| 1347 | + // -------------------------------------------------------------------------------- |
|
| 1348 | + |
|
| 1349 | + // -------------------------------------------------------------------------------- |
|
| 1350 | + // Function : errorInfo() |
|
| 1351 | + // Description : |
|
| 1352 | + // Parameters : |
|
| 1353 | + // -------------------------------------------------------------------------------- |
|
| 1354 | + function errorInfo($p_full=false) |
|
| 1355 | + {
|
|
| 1356 | 1356 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 1357 | - return(PclErrorString()); |
|
| 1357 | + return(PclErrorString()); |
|
| 1358 | 1358 | } |
| 1359 | 1359 | else {
|
| 1360 | - if ($p_full) {
|
|
| 1360 | + if ($p_full) {
|
|
| 1361 | 1361 | return($this->errorName(true)." : ".$this->error_string); |
| 1362 | - } |
|
| 1363 | - else {
|
|
| 1362 | + } |
|
| 1363 | + else {
|
|
| 1364 | 1364 | return($this->error_string." [code ".$this->error_code."]"); |
| 1365 | - } |
|
| 1365 | + } |
|
| 1366 | + } |
|
| 1366 | 1367 | } |
| 1367 | - } |
|
| 1368 | - // -------------------------------------------------------------------------------- |
|
| 1368 | + // -------------------------------------------------------------------------------- |
|
| 1369 | 1369 | |
| 1370 | 1370 | |
| 1371 | 1371 | // -------------------------------------------------------------------------------- |
@@ -1376,25 +1376,25 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | |
| 1378 | 1378 | |
| 1379 | - // -------------------------------------------------------------------------------- |
|
| 1380 | - // Function : privCheckFormat() |
|
| 1381 | - // Description : |
|
| 1382 | - // This method check that the archive exists and is a valid zip archive. |
|
| 1383 | - // Several level of check exists. (futur) |
|
| 1384 | - // Parameters : |
|
| 1385 | - // $p_level : Level of check. Default 0. |
|
| 1386 | - // 0 : Check the first bytes (magic codes) (default value)) |
|
| 1387 | - // 1 : 0 + Check the central directory (futur) |
|
| 1388 | - // 2 : 1 + Check each file header (futur) |
|
| 1389 | - // Return Values : |
|
| 1390 | - // true on success, |
|
| 1391 | - // false on error, the error code is set. |
|
| 1392 | - // -------------------------------------------------------------------------------- |
|
| 1393 | - function privCheckFormat($p_level=0) |
|
| 1394 | - {
|
|
| 1379 | + // -------------------------------------------------------------------------------- |
|
| 1380 | + // Function : privCheckFormat() |
|
| 1381 | + // Description : |
|
| 1382 | + // This method check that the archive exists and is a valid zip archive. |
|
| 1383 | + // Several level of check exists. (futur) |
|
| 1384 | + // Parameters : |
|
| 1385 | + // $p_level : Level of check. Default 0. |
|
| 1386 | + // 0 : Check the first bytes (magic codes) (default value)) |
|
| 1387 | + // 1 : 0 + Check the central directory (futur) |
|
| 1388 | + // 2 : 1 + Check each file header (futur) |
|
| 1389 | + // Return Values : |
|
| 1390 | + // true on success, |
|
| 1391 | + // false on error, the error code is set. |
|
| 1392 | + // -------------------------------------------------------------------------------- |
|
| 1393 | + function privCheckFormat($p_level=0) |
|
| 1394 | + {
|
|
| 1395 | 1395 | $v_result = true; |
| 1396 | 1396 | |
| 1397 | - // ----- Reset the file system cache |
|
| 1397 | + // ----- Reset the file system cache |
|
| 1398 | 1398 | clearstatcache(); |
| 1399 | 1399 | |
| 1400 | 1400 | // ----- Reset the error handler |
@@ -1402,16 +1402,16 @@ discard block |
||
| 1402 | 1402 | |
| 1403 | 1403 | // ----- Look if the file exits |
| 1404 | 1404 | if (!is_file($this->zipname)) {
|
| 1405 | - // ----- Error log |
|
| 1406 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1407 | - return(false); |
|
| 1405 | + // ----- Error log |
|
| 1406 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1407 | + return(false); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | // ----- Check that the file is readeable |
| 1411 | 1411 | if (!is_readable($this->zipname)) {
|
| 1412 | - // ----- Error log |
|
| 1413 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1414 | - return(false); |
|
| 1412 | + // ----- Error log |
|
| 1413 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1414 | + return(false); |
|
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | 1417 | // ----- Check the magic code |
@@ -1425,43 +1425,43 @@ discard block |
||
| 1425 | 1425 | |
| 1426 | 1426 | // ----- Return |
| 1427 | 1427 | return $v_result; |
| 1428 | - } |
|
| 1429 | - // -------------------------------------------------------------------------------- |
|
| 1430 | - |
|
| 1431 | - // -------------------------------------------------------------------------------- |
|
| 1432 | - // Function : privParseOptions() |
|
| 1433 | - // Description : |
|
| 1434 | - // This internal methods reads the variable list of arguments ($p_options_list, |
|
| 1435 | - // $p_size) and generate an array with the options and values ($v_result_list). |
|
| 1436 | - // $v_requested_options contains the options that can be present and those that |
|
| 1437 | - // must be present. |
|
| 1438 | - // $v_requested_options is an array, with the option value as key, and 'optional', |
|
| 1439 | - // or 'mandatory' as value. |
|
| 1440 | - // Parameters : |
|
| 1441 | - // See above. |
|
| 1442 | - // Return Values : |
|
| 1443 | - // 1 on success. |
|
| 1444 | - // 0 on failure. |
|
| 1445 | - // -------------------------------------------------------------------------------- |
|
| 1446 | - function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
|
| 1447 | - {
|
|
| 1428 | + } |
|
| 1429 | + // -------------------------------------------------------------------------------- |
|
| 1430 | + |
|
| 1431 | + // -------------------------------------------------------------------------------- |
|
| 1432 | + // Function : privParseOptions() |
|
| 1433 | + // Description : |
|
| 1434 | + // This internal methods reads the variable list of arguments ($p_options_list, |
|
| 1435 | + // $p_size) and generate an array with the options and values ($v_result_list). |
|
| 1436 | + // $v_requested_options contains the options that can be present and those that |
|
| 1437 | + // must be present. |
|
| 1438 | + // $v_requested_options is an array, with the option value as key, and 'optional', |
|
| 1439 | + // or 'mandatory' as value. |
|
| 1440 | + // Parameters : |
|
| 1441 | + // See above. |
|
| 1442 | + // Return Values : |
|
| 1443 | + // 1 on success. |
|
| 1444 | + // 0 on failure. |
|
| 1445 | + // -------------------------------------------------------------------------------- |
|
| 1446 | + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
|
| 1447 | + {
|
|
| 1448 | 1448 | $v_result=1; |
| 1449 | 1449 | |
| 1450 | 1450 | // ----- Read the options |
| 1451 | 1451 | $i=0; |
| 1452 | 1452 | while ($i<$p_size) {
|
| 1453 | 1453 | |
| 1454 | - // ----- Check if the option is supported |
|
| 1455 | - if (!isset($v_requested_options[$p_options_list[$i]])) {
|
|
| 1454 | + // ----- Check if the option is supported |
|
| 1455 | + if (!isset($v_requested_options[$p_options_list[$i]])) {
|
|
| 1456 | 1456 | // ----- Error log |
| 1457 | 1457 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
| 1458 | 1458 | |
| 1459 | 1459 | // ----- Return |
| 1460 | 1460 | return PclZip::errorCode(); |
| 1461 | - } |
|
| 1461 | + } |
|
| 1462 | 1462 | |
| 1463 | - // ----- Look for next option |
|
| 1464 | - switch ($p_options_list[$i]) {
|
|
| 1463 | + // ----- Look for next option |
|
| 1464 | + switch ($p_options_list[$i]) {
|
|
| 1465 | 1465 | // ----- Look for options that request a path value |
| 1466 | 1466 | case PCLZIP_OPT_PATH : |
| 1467 | 1467 | case PCLZIP_OPT_REMOVE_PATH : |
@@ -1473,11 +1473,11 @@ discard block |
||
| 1473 | 1473 | |
| 1474 | 1474 | // ----- Return |
| 1475 | 1475 | return PclZip::errorCode(); |
| 1476 | - } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | - // ----- Get the value |
|
| 1479 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1480 | - $i++; |
|
| 1478 | + // ----- Get the value |
|
| 1479 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1480 | + $i++; |
|
| 1481 | 1481 | break; |
| 1482 | 1482 | |
| 1483 | 1483 | case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
@@ -1485,24 +1485,24 @@ discard block |
||
| 1485 | 1485 | if (($i+1) >= $p_size) {
|
| 1486 | 1486 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1487 | 1487 | return PclZip::errorCode(); |
| 1488 | - } |
|
| 1488 | + } |
|
| 1489 | 1489 | |
| 1490 | - // ----- Check for incompatible options |
|
| 1491 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
|
| 1490 | + // ----- Check for incompatible options |
|
| 1491 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
|
| 1492 | 1492 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
| 1493 | 1493 | return PclZip::errorCode(); |
| 1494 | - } |
|
| 1494 | + } |
|
| 1495 | 1495 | |
| 1496 | - // ----- Check the value |
|
| 1497 | - $v_value = $p_options_list[$i+1]; |
|
| 1498 | - if ((!is_integer($v_value)) || ($v_value<0)) {
|
|
| 1496 | + // ----- Check the value |
|
| 1497 | + $v_value = $p_options_list[$i+1]; |
|
| 1498 | + if ((!is_integer($v_value)) || ($v_value<0)) {
|
|
| 1499 | 1499 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1500 | 1500 | return PclZip::errorCode(); |
| 1501 | - } |
|
| 1501 | + } |
|
| 1502 | 1502 | |
| 1503 | - // ----- Get the value (and convert it in bytes) |
|
| 1504 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1505 | - $i++; |
|
| 1503 | + // ----- Get the value (and convert it in bytes) |
|
| 1504 | + $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1505 | + $i++; |
|
| 1506 | 1506 | break; |
| 1507 | 1507 | |
| 1508 | 1508 | case PCLZIP_OPT_TEMP_FILE_ON : |
@@ -1510,9 +1510,9 @@ discard block |
||
| 1510 | 1510 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
| 1511 | 1511 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
| 1512 | 1512 | return PclZip::errorCode(); |
| 1513 | - } |
|
| 1513 | + } |
|
| 1514 | 1514 | |
| 1515 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1515 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1516 | 1516 | break; |
| 1517 | 1517 | |
| 1518 | 1518 | case PCLZIP_OPT_TEMP_FILE_OFF : |
@@ -1520,14 +1520,14 @@ discard block |
||
| 1520 | 1520 | if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
|
| 1521 | 1521 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
| 1522 | 1522 | return PclZip::errorCode(); |
| 1523 | - } |
|
| 1524 | - // ----- Check for incompatible options |
|
| 1525 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
|
|
| 1523 | + } |
|
| 1524 | + // ----- Check for incompatible options |
|
| 1525 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
|
|
| 1526 | 1526 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
| 1527 | 1527 | return PclZip::errorCode(); |
| 1528 | - } |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1530 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1531 | 1531 | break; |
| 1532 | 1532 | |
| 1533 | 1533 | case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
@@ -1538,16 +1538,16 @@ discard block |
||
| 1538 | 1538 | |
| 1539 | 1539 | // ----- Return |
| 1540 | 1540 | return PclZip::errorCode(); |
| 1541 | - } |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | - // ----- Get the value |
|
| 1544 | - if ( is_string($p_options_list[$i+1]) |
|
| 1543 | + // ----- Get the value |
|
| 1544 | + if ( is_string($p_options_list[$i+1]) |
|
| 1545 | 1545 | && ($p_options_list[$i+1] != '')) {
|
| 1546 | 1546 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
| 1547 | 1547 | $i++; |
| 1548 | - } |
|
| 1549 | - else {
|
|
| 1550 | - } |
|
| 1548 | + } |
|
| 1549 | + else {
|
|
| 1550 | + } |
|
| 1551 | 1551 | break; |
| 1552 | 1552 | |
| 1553 | 1553 | // ----- Look for options that request an array of string for value |
@@ -1559,23 +1559,23 @@ discard block |
||
| 1559 | 1559 | |
| 1560 | 1560 | // ----- Return |
| 1561 | 1561 | return PclZip::errorCode(); |
| 1562 | - } |
|
| 1562 | + } |
|
| 1563 | 1563 | |
| 1564 | - // ----- Get the value |
|
| 1565 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1566 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1567 | - } |
|
| 1568 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1569 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1570 | - } |
|
| 1571 | - else {
|
|
| 1564 | + // ----- Get the value |
|
| 1565 | + if (is_string($p_options_list[$i+1])) {
|
|
| 1566 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1567 | + } |
|
| 1568 | + else if (is_array($p_options_list[$i+1])) {
|
|
| 1569 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1570 | + } |
|
| 1571 | + else {
|
|
| 1572 | 1572 | // ----- Error log |
| 1573 | 1573 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1574 | 1574 | |
| 1575 | 1575 | // ----- Return |
| 1576 | 1576 | return PclZip::errorCode(); |
| 1577 | - } |
|
| 1578 | - $i++; |
|
| 1577 | + } |
|
| 1578 | + $i++; |
|
| 1579 | 1579 | break; |
| 1580 | 1580 | |
| 1581 | 1581 | // ----- Look for options that request an EREG or PREG expression |
@@ -1592,20 +1592,20 @@ discard block |
||
| 1592 | 1592 | |
| 1593 | 1593 | // ----- Return |
| 1594 | 1594 | return PclZip::errorCode(); |
| 1595 | - } |
|
| 1595 | + } |
|
| 1596 | 1596 | |
| 1597 | - // ----- Get the value |
|
| 1598 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1599 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1600 | - } |
|
| 1601 | - else {
|
|
| 1597 | + // ----- Get the value |
|
| 1598 | + if (is_string($p_options_list[$i+1])) {
|
|
| 1599 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1600 | + } |
|
| 1601 | + else {
|
|
| 1602 | 1602 | // ----- Error log |
| 1603 | 1603 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1604 | 1604 | |
| 1605 | 1605 | // ----- Return |
| 1606 | 1606 | return PclZip::errorCode(); |
| 1607 | - } |
|
| 1608 | - $i++; |
|
| 1607 | + } |
|
| 1608 | + $i++; |
|
| 1609 | 1609 | break; |
| 1610 | 1610 | |
| 1611 | 1611 | // ----- Look for options that takes a string |
@@ -1616,29 +1616,29 @@ discard block |
||
| 1616 | 1616 | if (($i+1) >= $p_size) {
|
| 1617 | 1617 | // ----- Error log |
| 1618 | 1618 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
| 1619 | - "Missing parameter value for option '" |
|
| 1620 | - .PclZipUtilOptionText($p_options_list[$i]) |
|
| 1621 | - ."'"); |
|
| 1619 | + "Missing parameter value for option '" |
|
| 1620 | + .PclZipUtilOptionText($p_options_list[$i]) |
|
| 1621 | + ."'"); |
|
| 1622 | 1622 | |
| 1623 | 1623 | // ----- Return |
| 1624 | 1624 | return PclZip::errorCode(); |
| 1625 | - } |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | - // ----- Get the value |
|
| 1628 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1629 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1630 | - } |
|
| 1631 | - else {
|
|
| 1627 | + // ----- Get the value |
|
| 1628 | + if (is_string($p_options_list[$i+1])) {
|
|
| 1629 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1630 | + } |
|
| 1631 | + else {
|
|
| 1632 | 1632 | // ----- Error log |
| 1633 | 1633 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
| 1634 | - "Wrong parameter value for option '" |
|
| 1635 | - .PclZipUtilOptionText($p_options_list[$i]) |
|
| 1636 | - ."'"); |
|
| 1634 | + "Wrong parameter value for option '" |
|
| 1635 | + .PclZipUtilOptionText($p_options_list[$i]) |
|
| 1636 | + ."'"); |
|
| 1637 | 1637 | |
| 1638 | 1638 | // ----- Return |
| 1639 | 1639 | return PclZip::errorCode(); |
| 1640 | - } |
|
| 1641 | - $i++; |
|
| 1640 | + } |
|
| 1641 | + $i++; |
|
| 1642 | 1642 | break; |
| 1643 | 1643 | |
| 1644 | 1644 | // ----- Look for options that request an array of index |
@@ -1650,87 +1650,87 @@ discard block |
||
| 1650 | 1650 | |
| 1651 | 1651 | // ----- Return |
| 1652 | 1652 | return PclZip::errorCode(); |
| 1653 | - } |
|
| 1653 | + } |
|
| 1654 | 1654 | |
| 1655 | - // ----- Get the value |
|
| 1656 | - $v_work_list = array(); |
|
| 1657 | - if (is_string($p_options_list[$i+1])) {
|
|
| 1655 | + // ----- Get the value |
|
| 1656 | + $v_work_list = array(); |
|
| 1657 | + if (is_string($p_options_list[$i+1])) {
|
|
| 1658 | 1658 | |
| 1659 | - // ----- Remove spaces |
|
| 1660 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1659 | + // ----- Remove spaces |
|
| 1660 | + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1661 | 1661 | |
| 1662 | - // ----- Parse items |
|
| 1663 | - $v_work_list = explode(",", $p_options_list[$i+1]);
|
|
| 1664 | - } |
|
| 1665 | - else if (is_integer($p_options_list[$i+1])) {
|
|
| 1666 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1667 | - } |
|
| 1668 | - else if (is_array($p_options_list[$i+1])) {
|
|
| 1669 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1670 | - } |
|
| 1671 | - else {
|
|
| 1662 | + // ----- Parse items |
|
| 1663 | + $v_work_list = explode(",", $p_options_list[$i+1]);
|
|
| 1664 | + } |
|
| 1665 | + else if (is_integer($p_options_list[$i+1])) {
|
|
| 1666 | + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1667 | + } |
|
| 1668 | + else if (is_array($p_options_list[$i+1])) {
|
|
| 1669 | + $v_work_list = $p_options_list[$i+1]; |
|
| 1670 | + } |
|
| 1671 | + else {
|
|
| 1672 | 1672 | // ----- Error log |
| 1673 | 1673 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1674 | 1674 | |
| 1675 | 1675 | // ----- Return |
| 1676 | 1676 | return PclZip::errorCode(); |
| 1677 | - } |
|
| 1677 | + } |
|
| 1678 | 1678 | |
| 1679 | - // ----- Reduce the index list |
|
| 1680 | - // each index item in the list must be a couple with a start and |
|
| 1681 | - // an end value : [0,3], [5-5], [8-10], ... |
|
| 1682 | - // ----- Check the format of each item |
|
| 1683 | - $v_sort_flag=false; |
|
| 1684 | - $v_sort_value=0; |
|
| 1685 | - for ($j=0; $j<sizeof($v_work_list); $j++) {
|
|
| 1686 | - // ----- Explode the item |
|
| 1687 | - $v_item_list = explode("-", $v_work_list[$j]);
|
|
| 1688 | - $v_size_item_list = sizeof($v_item_list); |
|
| 1689 | - |
|
| 1690 | - // ----- TBC : Here we might check that each item is a |
|
| 1691 | - // real integer ... |
|
| 1692 | - |
|
| 1693 | - // ----- Look for single value |
|
| 1694 | - if ($v_size_item_list == 1) {
|
|
| 1695 | - // ----- Set the option value |
|
| 1696 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1697 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1698 | - } |
|
| 1699 | - elseif ($v_size_item_list == 2) {
|
|
| 1700 | - // ----- Set the option value |
|
| 1701 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1702 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1703 | - } |
|
| 1704 | - else {
|
|
| 1705 | - // ----- Error log |
|
| 1706 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1707 | - |
|
| 1708 | - // ----- Return |
|
| 1709 | - return PclZip::errorCode(); |
|
| 1710 | - } |
|
| 1711 | - |
|
| 1712 | - |
|
| 1713 | - // ----- Look for list sort |
|
| 1714 | - if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
|
|
| 1715 | - $v_sort_flag=true; |
|
| 1716 | - |
|
| 1717 | - // ----- TBC : An automatic sort should be writen ... |
|
| 1718 | - // ----- Error log |
|
| 1719 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1720 | - |
|
| 1721 | - // ----- Return |
|
| 1722 | - return PclZip::errorCode(); |
|
| 1723 | - } |
|
| 1724 | - $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1725 | - } |
|
| 1679 | + // ----- Reduce the index list |
|
| 1680 | + // each index item in the list must be a couple with a start and |
|
| 1681 | + // an end value : [0,3], [5-5], [8-10], ... |
|
| 1682 | + // ----- Check the format of each item |
|
| 1683 | + $v_sort_flag=false; |
|
| 1684 | + $v_sort_value=0; |
|
| 1685 | + for ($j=0; $j<sizeof($v_work_list); $j++) {
|
|
| 1686 | + // ----- Explode the item |
|
| 1687 | + $v_item_list = explode("-", $v_work_list[$j]);
|
|
| 1688 | + $v_size_item_list = sizeof($v_item_list); |
|
| 1689 | + |
|
| 1690 | + // ----- TBC : Here we might check that each item is a |
|
| 1691 | + // real integer ... |
|
| 1692 | + |
|
| 1693 | + // ----- Look for single value |
|
| 1694 | + if ($v_size_item_list == 1) {
|
|
| 1695 | + // ----- Set the option value |
|
| 1696 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1697 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1698 | + } |
|
| 1699 | + elseif ($v_size_item_list == 2) {
|
|
| 1700 | + // ----- Set the option value |
|
| 1701 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1702 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1703 | + } |
|
| 1704 | + else {
|
|
| 1705 | + // ----- Error log |
|
| 1706 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1707 | + |
|
| 1708 | + // ----- Return |
|
| 1709 | + return PclZip::errorCode(); |
|
| 1710 | + } |
|
| 1711 | + |
|
| 1712 | + |
|
| 1713 | + // ----- Look for list sort |
|
| 1714 | + if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
|
|
| 1715 | + $v_sort_flag=true; |
|
| 1716 | + |
|
| 1717 | + // ----- TBC : An automatic sort should be writen ... |
|
| 1718 | + // ----- Error log |
|
| 1719 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1720 | + |
|
| 1721 | + // ----- Return |
|
| 1722 | + return PclZip::errorCode(); |
|
| 1723 | + } |
|
| 1724 | + $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1725 | + } |
|
| 1726 | 1726 | |
| 1727 | - // ----- Sort the items |
|
| 1728 | - if ($v_sort_flag) {
|
|
| 1729 | - // TBC : To Be Completed |
|
| 1730 | - } |
|
| 1727 | + // ----- Sort the items |
|
| 1728 | + if ($v_sort_flag) {
|
|
| 1729 | + // TBC : To Be Completed |
|
| 1730 | + } |
|
| 1731 | 1731 | |
| 1732 | - // ----- Next option |
|
| 1733 | - $i++; |
|
| 1732 | + // ----- Next option |
|
| 1733 | + $i++; |
|
| 1734 | 1734 | break; |
| 1735 | 1735 | |
| 1736 | 1736 | // ----- Look for options that request no value |
@@ -1752,11 +1752,11 @@ discard block |
||
| 1752 | 1752 | |
| 1753 | 1753 | // ----- Return |
| 1754 | 1754 | return PclZip::errorCode(); |
| 1755 | - } |
|
| 1755 | + } |
|
| 1756 | 1756 | |
| 1757 | - // ----- Get the value |
|
| 1758 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1759 | - $i++; |
|
| 1757 | + // ----- Get the value |
|
| 1758 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1759 | + $i++; |
|
| 1760 | 1760 | break; |
| 1761 | 1761 | |
| 1762 | 1762 | // ----- Look for options that request a call-back |
@@ -1777,54 +1777,54 @@ discard block |
||
| 1777 | 1777 | |
| 1778 | 1778 | // ----- Return |
| 1779 | 1779 | return PclZip::errorCode(); |
| 1780 | - } |
|
| 1780 | + } |
|
| 1781 | 1781 | |
| 1782 | - // ----- Get the value |
|
| 1783 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1782 | + // ----- Get the value |
|
| 1783 | + $v_function_name = $p_options_list[$i+1]; |
|
| 1784 | 1784 | |
| 1785 | - // ----- Check that the value is a valid existing function |
|
| 1786 | - if (!function_exists($v_function_name)) {
|
|
| 1785 | + // ----- Check that the value is a valid existing function |
|
| 1786 | + if (!function_exists($v_function_name)) {
|
|
| 1787 | 1787 | // ----- Error log |
| 1788 | 1788 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1789 | 1789 | |
| 1790 | 1790 | // ----- Return |
| 1791 | 1791 | return PclZip::errorCode(); |
| 1792 | - } |
|
| 1792 | + } |
|
| 1793 | 1793 | |
| 1794 | - // ----- Set the attribute |
|
| 1795 | - $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1796 | - $i++; |
|
| 1794 | + // ----- Set the attribute |
|
| 1795 | + $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1796 | + $i++; |
|
| 1797 | 1797 | break; |
| 1798 | 1798 | |
| 1799 | 1799 | default : |
| 1800 | 1800 | // ----- Error log |
| 1801 | 1801 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 1802 | - "Unknown parameter '" |
|
| 1803 | - .$p_options_list[$i]."'"); |
|
| 1802 | + "Unknown parameter '" |
|
| 1803 | + .$p_options_list[$i]."'"); |
|
| 1804 | 1804 | |
| 1805 | - // ----- Return |
|
| 1806 | - return PclZip::errorCode(); |
|
| 1807 | - } |
|
| 1805 | + // ----- Return |
|
| 1806 | + return PclZip::errorCode(); |
|
| 1807 | + } |
|
| 1808 | 1808 | |
| 1809 | - // ----- Next options |
|
| 1810 | - $i++; |
|
| 1809 | + // ----- Next options |
|
| 1810 | + $i++; |
|
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | 1813 | // ----- Look for mandatory options |
| 1814 | 1814 | if ($v_requested_options !== false) {
|
| 1815 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
|
| 1815 | + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
|
| 1816 | 1816 | // ----- Look for mandatory option |
| 1817 | 1817 | if ($v_requested_options[$key] == 'mandatory') {
|
| 1818 | - // ----- Look if present |
|
| 1819 | - if (!isset($v_result_list[$key])) {
|
|
| 1818 | + // ----- Look if present |
|
| 1819 | + if (!isset($v_result_list[$key])) {
|
|
| 1820 | 1820 | // ----- Error log |
| 1821 | 1821 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
|
| 1822 | 1822 | |
| 1823 | 1823 | // ----- Return |
| 1824 | 1824 | return PclZip::errorCode(); |
| 1825 | - } |
|
| 1825 | + } |
|
| 1826 | + } |
|
| 1826 | 1827 | } |
| 1827 | - } |
|
| 1828 | 1828 | } |
| 1829 | 1829 | |
| 1830 | 1830 | // ----- Look for default values |
@@ -1834,22 +1834,22 @@ discard block |
||
| 1834 | 1834 | |
| 1835 | 1835 | // ----- Return |
| 1836 | 1836 | return $v_result; |
| 1837 | - } |
|
| 1838 | - // -------------------------------------------------------------------------------- |
|
| 1839 | - |
|
| 1840 | - // -------------------------------------------------------------------------------- |
|
| 1841 | - // Function : privOptionDefaultThreshold() |
|
| 1842 | - // Description : |
|
| 1843 | - // Parameters : |
|
| 1844 | - // Return Values : |
|
| 1845 | - // -------------------------------------------------------------------------------- |
|
| 1846 | - function privOptionDefaultThreshold(&$p_options) |
|
| 1847 | - {
|
|
| 1837 | + } |
|
| 1838 | + // -------------------------------------------------------------------------------- |
|
| 1839 | + |
|
| 1840 | + // -------------------------------------------------------------------------------- |
|
| 1841 | + // Function : privOptionDefaultThreshold() |
|
| 1842 | + // Description : |
|
| 1843 | + // Parameters : |
|
| 1844 | + // Return Values : |
|
| 1845 | + // -------------------------------------------------------------------------------- |
|
| 1846 | + function privOptionDefaultThreshold(&$p_options) |
|
| 1847 | + {
|
|
| 1848 | 1848 | $v_result=1; |
| 1849 | 1849 | |
| 1850 | 1850 | if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 1851 | 1851 | || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
| 1852 | - return $v_result; |
|
| 1852 | + return $v_result; |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | // ----- Get 'memory_limit' configuration value |
@@ -1871,52 +1871,52 @@ discard block |
||
| 1871 | 1871 | |
| 1872 | 1872 | // ----- Sanity check : No threshold if value lower than 1M |
| 1873 | 1873 | if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
|
| 1874 | - unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1874 | + unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | // ----- Return |
| 1878 | 1878 | return $v_result; |
| 1879 | - } |
|
| 1880 | - // -------------------------------------------------------------------------------- |
|
| 1881 | - |
|
| 1882 | - // -------------------------------------------------------------------------------- |
|
| 1883 | - // Function : privFileDescrParseAtt() |
|
| 1884 | - // Description : |
|
| 1885 | - // Parameters : |
|
| 1886 | - // Return Values : |
|
| 1887 | - // 1 on success. |
|
| 1888 | - // 0 on failure. |
|
| 1889 | - // -------------------------------------------------------------------------------- |
|
| 1890 | - function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
|
| 1891 | - {
|
|
| 1879 | + } |
|
| 1880 | + // -------------------------------------------------------------------------------- |
|
| 1881 | + |
|
| 1882 | + // -------------------------------------------------------------------------------- |
|
| 1883 | + // Function : privFileDescrParseAtt() |
|
| 1884 | + // Description : |
|
| 1885 | + // Parameters : |
|
| 1886 | + // Return Values : |
|
| 1887 | + // 1 on success. |
|
| 1888 | + // 0 on failure. |
|
| 1889 | + // -------------------------------------------------------------------------------- |
|
| 1890 | + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
|
| 1891 | + {
|
|
| 1892 | 1892 | $v_result=1; |
| 1893 | 1893 | |
| 1894 | 1894 | // ----- For each file in the list check the attributes |
| 1895 | 1895 | foreach ($p_file_list as $v_key => $v_value) {
|
| 1896 | 1896 | |
| 1897 | - // ----- Check if the option is supported |
|
| 1898 | - if (!isset($v_requested_options[$v_key])) {
|
|
| 1897 | + // ----- Check if the option is supported |
|
| 1898 | + if (!isset($v_requested_options[$v_key])) {
|
|
| 1899 | 1899 | // ----- Error log |
| 1900 | 1900 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
| 1901 | 1901 | |
| 1902 | 1902 | // ----- Return |
| 1903 | 1903 | return PclZip::errorCode(); |
| 1904 | - } |
|
| 1904 | + } |
|
| 1905 | 1905 | |
| 1906 | - // ----- Look for attribute |
|
| 1907 | - switch ($v_key) {
|
|
| 1906 | + // ----- Look for attribute |
|
| 1907 | + switch ($v_key) {
|
|
| 1908 | 1908 | case PCLZIP_ATT_FILE_NAME : |
| 1909 | 1909 | if (!is_string($v_value)) {
|
| 1910 | 1910 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1911 | 1911 | return PclZip::errorCode(); |
| 1912 | - } |
|
| 1912 | + } |
|
| 1913 | 1913 | |
| 1914 | - $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1914 | + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1915 | 1915 | |
| 1916 | - if ($p_filedescr['filename'] == '') {
|
|
| 1916 | + if ($p_filedescr['filename'] == '') {
|
|
| 1917 | 1917 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1918 | 1918 | return PclZip::errorCode(); |
| 1919 | - } |
|
| 1919 | + } |
|
| 1920 | 1920 | |
| 1921 | 1921 | break; |
| 1922 | 1922 | |
@@ -1924,28 +1924,28 @@ discard block |
||
| 1924 | 1924 | if (!is_string($v_value)) {
|
| 1925 | 1925 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1926 | 1926 | return PclZip::errorCode(); |
| 1927 | - } |
|
| 1927 | + } |
|
| 1928 | 1928 | |
| 1929 | - $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1929 | + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1930 | 1930 | |
| 1931 | - if ($p_filedescr['new_short_name'] == '') {
|
|
| 1931 | + if ($p_filedescr['new_short_name'] == '') {
|
|
| 1932 | 1932 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1933 | 1933 | return PclZip::errorCode(); |
| 1934 | - } |
|
| 1934 | + } |
|
| 1935 | 1935 | break; |
| 1936 | 1936 | |
| 1937 | 1937 | case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
| 1938 | 1938 | if (!is_string($v_value)) {
|
| 1939 | 1939 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1940 | 1940 | return PclZip::errorCode(); |
| 1941 | - } |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1943 | + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1944 | 1944 | |
| 1945 | - if ($p_filedescr['new_full_name'] == '') {
|
|
| 1945 | + if ($p_filedescr['new_full_name'] == '') {
|
|
| 1946 | 1946 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1947 | 1947 | return PclZip::errorCode(); |
| 1948 | - } |
|
| 1948 | + } |
|
| 1949 | 1949 | break; |
| 1950 | 1950 | |
| 1951 | 1951 | // ----- Look for options that takes a string |
@@ -1953,18 +1953,18 @@ discard block |
||
| 1953 | 1953 | if (!is_string($v_value)) {
|
| 1954 | 1954 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1955 | 1955 | return PclZip::errorCode(); |
| 1956 | - } |
|
| 1956 | + } |
|
| 1957 | 1957 | |
| 1958 | - $p_filedescr['comment'] = $v_value; |
|
| 1958 | + $p_filedescr['comment'] = $v_value; |
|
| 1959 | 1959 | break; |
| 1960 | 1960 | |
| 1961 | 1961 | case PCLZIP_ATT_FILE_MTIME : |
| 1962 | 1962 | if (!is_integer($v_value)) {
|
| 1963 | 1963 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1964 | 1964 | return PclZip::errorCode(); |
| 1965 | - } |
|
| 1965 | + } |
|
| 1966 | 1966 | |
| 1967 | - $p_filedescr['mtime'] = $v_value; |
|
| 1967 | + $p_filedescr['mtime'] = $v_value; |
|
| 1968 | 1968 | break; |
| 1969 | 1969 | |
| 1970 | 1970 | case PCLZIP_ATT_FILE_CONTENT : |
@@ -1974,50 +1974,50 @@ discard block |
||
| 1974 | 1974 | default : |
| 1975 | 1975 | // ----- Error log |
| 1976 | 1976 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 1977 | - "Unknown parameter '".$v_key."'"); |
|
| 1977 | + "Unknown parameter '".$v_key."'"); |
|
| 1978 | 1978 | |
| 1979 | - // ----- Return |
|
| 1980 | - return PclZip::errorCode(); |
|
| 1981 | - } |
|
| 1979 | + // ----- Return |
|
| 1980 | + return PclZip::errorCode(); |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - // ----- Look for mandatory options |
|
| 1984 | - if ($v_requested_options !== false) {
|
|
| 1983 | + // ----- Look for mandatory options |
|
| 1984 | + if ($v_requested_options !== false) {
|
|
| 1985 | 1985 | for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
| 1986 | - // ----- Look for mandatory option |
|
| 1987 | - if ($v_requested_options[$key] == 'mandatory') {
|
|
| 1986 | + // ----- Look for mandatory option |
|
| 1987 | + if ($v_requested_options[$key] == 'mandatory') {
|
|
| 1988 | 1988 | // ----- Look if present |
| 1989 | 1989 | if (!isset($p_file_list[$key])) {
|
| 1990 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
|
|
| 1991 | - return PclZip::errorCode(); |
|
| 1990 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
|
|
| 1991 | + return PclZip::errorCode(); |
|
| 1992 | + } |
|
| 1992 | 1993 | } |
| 1993 | - } |
|
| 1994 | 1994 | } |
| 1995 | - } |
|
| 1995 | + } |
|
| 1996 | 1996 | |
| 1997 | 1997 | // end foreach |
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | // ----- Return |
| 2001 | 2001 | return $v_result; |
| 2002 | - } |
|
| 2003 | - // -------------------------------------------------------------------------------- |
|
| 2004 | - |
|
| 2005 | - // -------------------------------------------------------------------------------- |
|
| 2006 | - // Function : privFileDescrExpand() |
|
| 2007 | - // Description : |
|
| 2008 | - // This method look for each item of the list to see if its a file, a folder |
|
| 2009 | - // or a string to be added as file. For any other type of files (link, other) |
|
| 2010 | - // just ignore the item. |
|
| 2011 | - // Then prepare the information that will be stored for that file. |
|
| 2012 | - // When its a folder, expand the folder with all the files that are in that |
|
| 2013 | - // folder (recursively). |
|
| 2014 | - // Parameters : |
|
| 2015 | - // Return Values : |
|
| 2016 | - // 1 on success. |
|
| 2017 | - // 0 on failure. |
|
| 2018 | - // -------------------------------------------------------------------------------- |
|
| 2019 | - function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
|
| 2020 | - {
|
|
| 2002 | + } |
|
| 2003 | + // -------------------------------------------------------------------------------- |
|
| 2004 | + |
|
| 2005 | + // -------------------------------------------------------------------------------- |
|
| 2006 | + // Function : privFileDescrExpand() |
|
| 2007 | + // Description : |
|
| 2008 | + // This method look for each item of the list to see if its a file, a folder |
|
| 2009 | + // or a string to be added as file. For any other type of files (link, other) |
|
| 2010 | + // just ignore the item. |
|
| 2011 | + // Then prepare the information that will be stored for that file. |
|
| 2012 | + // When its a folder, expand the folder with all the files that are in that |
|
| 2013 | + // folder (recursively). |
|
| 2014 | + // Parameters : |
|
| 2015 | + // Return Values : |
|
| 2016 | + // 1 on success. |
|
| 2017 | + // 0 on failure. |
|
| 2018 | + // -------------------------------------------------------------------------------- |
|
| 2019 | + function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
|
| 2020 | + {
|
|
| 2021 | 2021 | $v_result=1; |
| 2022 | 2022 | |
| 2023 | 2023 | // ----- Create a result list |
@@ -2026,58 +2026,58 @@ discard block |
||
| 2026 | 2026 | // ----- Look each entry |
| 2027 | 2027 | for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
|
| 2028 | 2028 | |
| 2029 | - // ----- Get filedescr |
|
| 2030 | - $v_descr = $p_filedescr_list[$i]; |
|
| 2029 | + // ----- Get filedescr |
|
| 2030 | + $v_descr = $p_filedescr_list[$i]; |
|
| 2031 | 2031 | |
| 2032 | - // ----- Reduce the filename |
|
| 2033 | - $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2034 | - $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2032 | + // ----- Reduce the filename |
|
| 2033 | + $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2034 | + $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2035 | 2035 | |
| 2036 | - // ----- Look for real file or folder |
|
| 2037 | - if (file_exists($v_descr['filename'])) {
|
|
| 2036 | + // ----- Look for real file or folder |
|
| 2037 | + if (file_exists($v_descr['filename'])) {
|
|
| 2038 | 2038 | if (@is_file($v_descr['filename'])) {
|
| 2039 | - $v_descr['type'] = 'file'; |
|
| 2039 | + $v_descr['type'] = 'file'; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | else if (@is_dir($v_descr['filename'])) {
|
| 2042 | - $v_descr['type'] = 'folder'; |
|
| 2042 | + $v_descr['type'] = 'folder'; |
|
| 2043 | 2043 | } |
| 2044 | 2044 | else if (@is_link($v_descr['filename'])) {
|
| 2045 | - // skip |
|
| 2046 | - continue; |
|
| 2045 | + // skip |
|
| 2046 | + continue; |
|
| 2047 | 2047 | } |
| 2048 | 2048 | else {
|
| 2049 | - // skip |
|
| 2050 | - continue; |
|
| 2049 | + // skip |
|
| 2050 | + continue; |
|
| 2051 | + } |
|
| 2051 | 2052 | } |
| 2052 | - } |
|
| 2053 | 2053 | |
| 2054 | - // ----- Look for string added as file |
|
| 2055 | - else if (isset($v_descr['content'])) {
|
|
| 2054 | + // ----- Look for string added as file |
|
| 2055 | + else if (isset($v_descr['content'])) {
|
|
| 2056 | 2056 | $v_descr['type'] = 'virtual_file'; |
| 2057 | - } |
|
| 2057 | + } |
|
| 2058 | 2058 | |
| 2059 | - // ----- Missing file |
|
| 2060 | - else {
|
|
| 2059 | + // ----- Missing file |
|
| 2060 | + else {
|
|
| 2061 | 2061 | // ----- Error log |
| 2062 | 2062 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
| 2063 | 2063 | |
| 2064 | 2064 | // ----- Return |
| 2065 | 2065 | return PclZip::errorCode(); |
| 2066 | - } |
|
| 2066 | + } |
|
| 2067 | 2067 | |
| 2068 | - // ----- Calculate the stored filename |
|
| 2069 | - $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2068 | + // ----- Calculate the stored filename |
|
| 2069 | + $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2070 | 2070 | |
| 2071 | - // ----- Add the descriptor in result list |
|
| 2072 | - $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2071 | + // ----- Add the descriptor in result list |
|
| 2072 | + $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2073 | 2073 | |
| 2074 | - // ----- Look for folder |
|
| 2075 | - if ($v_descr['type'] == 'folder') {
|
|
| 2074 | + // ----- Look for folder |
|
| 2075 | + if ($v_descr['type'] == 'folder') {
|
|
| 2076 | 2076 | // ----- List of items in folder |
| 2077 | 2077 | $v_dirlist_descr = array(); |
| 2078 | 2078 | $v_dirlist_nb = 0; |
| 2079 | 2079 | if ($v_folder_handler = @opendir($v_descr['filename'])) {
|
| 2080 | - while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
|
|
| 2080 | + while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
|
|
| 2081 | 2081 | |
| 2082 | 2082 | // ----- Skip '.' and '..' |
| 2083 | 2083 | if (($v_item_handler == '.') || ($v_item_handler == '..')) {
|
@@ -2092,39 +2092,39 @@ discard block |
||
| 2092 | 2092 | // files/sub-folders also change |
| 2093 | 2093 | if (($v_descr['stored_filename'] != $v_descr['filename']) |
| 2094 | 2094 | && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
|
| 2095 | - if ($v_descr['stored_filename'] != '') {
|
|
| 2095 | + if ($v_descr['stored_filename'] != '') {
|
|
| 2096 | 2096 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2097 | - } |
|
| 2098 | - else {
|
|
| 2097 | + } |
|
| 2098 | + else {
|
|
| 2099 | 2099 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
| 2100 | - } |
|
| 2100 | + } |
|
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | $v_dirlist_nb++; |
| 2104 | - } |
|
| 2104 | + } |
|
| 2105 | 2105 | |
| 2106 | - @closedir($v_folder_handler); |
|
| 2106 | + @closedir($v_folder_handler); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | else {
|
| 2109 | - // TBC : unable to open folder in read mode |
|
| 2109 | + // TBC : unable to open folder in read mode |
|
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | 2112 | // ----- Expand each element of the list |
| 2113 | 2113 | if ($v_dirlist_nb != 0) {
|
| 2114 | - // ----- Expand |
|
| 2115 | - if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
|
|
| 2114 | + // ----- Expand |
|
| 2115 | + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
|
|
| 2116 | 2116 | return $v_result; |
| 2117 | - } |
|
| 2117 | + } |
|
| 2118 | 2118 | |
| 2119 | - // ----- Concat the resulting list |
|
| 2120 | - $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2119 | + // ----- Concat the resulting list |
|
| 2120 | + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2121 | 2121 | } |
| 2122 | 2122 | else {
|
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | // ----- Free local array |
| 2126 | 2126 | unset($v_dirlist_descr); |
| 2127 | - } |
|
| 2127 | + } |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | 2130 | // ----- Get the result list |
@@ -2132,17 +2132,17 @@ discard block |
||
| 2132 | 2132 | |
| 2133 | 2133 | // ----- Return |
| 2134 | 2134 | return $v_result; |
| 2135 | - } |
|
| 2136 | - // -------------------------------------------------------------------------------- |
|
| 2137 | - |
|
| 2138 | - // -------------------------------------------------------------------------------- |
|
| 2139 | - // Function : privCreate() |
|
| 2140 | - // Description : |
|
| 2141 | - // Parameters : |
|
| 2142 | - // Return Values : |
|
| 2143 | - // -------------------------------------------------------------------------------- |
|
| 2144 | - function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2145 | - {
|
|
| 2135 | + } |
|
| 2136 | + // -------------------------------------------------------------------------------- |
|
| 2137 | + |
|
| 2138 | + // -------------------------------------------------------------------------------- |
|
| 2139 | + // Function : privCreate() |
|
| 2140 | + // Description : |
|
| 2141 | + // Parameters : |
|
| 2142 | + // Return Values : |
|
| 2143 | + // -------------------------------------------------------------------------------- |
|
| 2144 | + function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2145 | + {
|
|
| 2146 | 2146 | $v_result=1; |
| 2147 | 2147 | $v_list_detail = array(); |
| 2148 | 2148 | |
@@ -2152,8 +2152,8 @@ discard block |
||
| 2152 | 2152 | // ----- Open the file in write mode |
| 2153 | 2153 | if (($v_result = $this->privOpenFd('wb')) != 1)
|
| 2154 | 2154 | {
|
| 2155 | - // ----- Return |
|
| 2156 | - return $v_result; |
|
| 2155 | + // ----- Return |
|
| 2156 | + return $v_result; |
|
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | 2159 | // ----- Add the list of files |
@@ -2167,17 +2167,17 @@ discard block |
||
| 2167 | 2167 | |
| 2168 | 2168 | // ----- Return |
| 2169 | 2169 | return $v_result; |
| 2170 | - } |
|
| 2171 | - // -------------------------------------------------------------------------------- |
|
| 2172 | - |
|
| 2173 | - // -------------------------------------------------------------------------------- |
|
| 2174 | - // Function : privAdd() |
|
| 2175 | - // Description : |
|
| 2176 | - // Parameters : |
|
| 2177 | - // Return Values : |
|
| 2178 | - // -------------------------------------------------------------------------------- |
|
| 2179 | - function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2180 | - {
|
|
| 2170 | + } |
|
| 2171 | + // -------------------------------------------------------------------------------- |
|
| 2172 | + |
|
| 2173 | + // -------------------------------------------------------------------------------- |
|
| 2174 | + // Function : privAdd() |
|
| 2175 | + // Description : |
|
| 2176 | + // Parameters : |
|
| 2177 | + // Return Values : |
|
| 2178 | + // -------------------------------------------------------------------------------- |
|
| 2179 | + function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2180 | + {
|
|
| 2181 | 2181 | $v_result=1; |
| 2182 | 2182 | $v_list_detail = array(); |
| 2183 | 2183 | |
@@ -2185,11 +2185,11 @@ discard block |
||
| 2185 | 2185 | if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
| 2186 | 2186 | {
|
| 2187 | 2187 | |
| 2188 | - // ----- Do a create |
|
| 2189 | - $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2188 | + // ----- Do a create |
|
| 2189 | + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2190 | 2190 | |
| 2191 | - // ----- Return |
|
| 2192 | - return $v_result; |
|
| 2191 | + // ----- Return |
|
| 2192 | + return $v_result; |
|
| 2193 | 2193 | } |
| 2194 | 2194 | // ----- Magic quotes trick |
| 2195 | 2195 | $this->privDisableMagicQuotes(); |
@@ -2197,20 +2197,20 @@ discard block |
||
| 2197 | 2197 | // ----- Open the zip file |
| 2198 | 2198 | if (($v_result=$this->privOpenFd('rb')) != 1)
|
| 2199 | 2199 | {
|
| 2200 | - // ----- Magic quotes trick |
|
| 2201 | - $this->privSwapBackMagicQuotes(); |
|
| 2200 | + // ----- Magic quotes trick |
|
| 2201 | + $this->privSwapBackMagicQuotes(); |
|
| 2202 | 2202 | |
| 2203 | - // ----- Return |
|
| 2204 | - return $v_result; |
|
| 2203 | + // ----- Return |
|
| 2204 | + return $v_result; |
|
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | // ----- Read the central directory informations |
| 2208 | 2208 | $v_central_dir = array(); |
| 2209 | 2209 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 2210 | 2210 | {
|
| 2211 | - $this->privCloseFd(); |
|
| 2212 | - $this->privSwapBackMagicQuotes(); |
|
| 2213 | - return $v_result; |
|
| 2211 | + $this->privCloseFd(); |
|
| 2212 | + $this->privSwapBackMagicQuotes(); |
|
| 2213 | + return $v_result; |
|
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | // ----- Go to beginning of File |
@@ -2222,13 +2222,13 @@ discard block |
||
| 2222 | 2222 | // ----- Open the temporary file in write mode |
| 2223 | 2223 | if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
| 2224 | 2224 | {
|
| 2225 | - $this->privCloseFd(); |
|
| 2226 | - $this->privSwapBackMagicQuotes(); |
|
| 2225 | + $this->privCloseFd(); |
|
| 2226 | + $this->privSwapBackMagicQuotes(); |
|
| 2227 | 2227 | |
| 2228 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2228 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2229 | 2229 | |
| 2230 | - // ----- Return |
|
| 2231 | - return PclZip::errorCode(); |
|
| 2230 | + // ----- Return |
|
| 2231 | + return PclZip::errorCode(); |
|
| 2232 | 2232 | } |
| 2233 | 2233 | |
| 2234 | 2234 | // ----- Copy the files from the archive to the temporary file |
@@ -2236,10 +2236,10 @@ discard block |
||
| 2236 | 2236 | $v_size = $v_central_dir['offset']; |
| 2237 | 2237 | while ($v_size != 0) |
| 2238 | 2238 | {
|
| 2239 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2240 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2241 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2242 | - $v_size -= $v_read_size; |
|
| 2239 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2240 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2241 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2242 | + $v_size -= $v_read_size; |
|
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | 2245 | // ----- Swap the file descriptor |
@@ -2253,13 +2253,13 @@ discard block |
||
| 2253 | 2253 | $v_header_list = array(); |
| 2254 | 2254 | if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
| 2255 | 2255 | {
|
| 2256 | - fclose($v_zip_temp_fd); |
|
| 2257 | - $this->privCloseFd(); |
|
| 2258 | - @unlink($v_zip_temp_name); |
|
| 2259 | - $this->privSwapBackMagicQuotes(); |
|
| 2256 | + fclose($v_zip_temp_fd); |
|
| 2257 | + $this->privCloseFd(); |
|
| 2258 | + @unlink($v_zip_temp_name); |
|
| 2259 | + $this->privSwapBackMagicQuotes(); |
|
| 2260 | 2260 | |
| 2261 | - // ----- Return |
|
| 2262 | - return $v_result; |
|
| 2261 | + // ----- Return |
|
| 2262 | + return $v_result; |
|
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | 2265 | // ----- Store the offset of the central dir |
@@ -2269,43 +2269,43 @@ discard block |
||
| 2269 | 2269 | $v_size = $v_central_dir['size']; |
| 2270 | 2270 | while ($v_size != 0) |
| 2271 | 2271 | {
|
| 2272 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2273 | - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2274 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2275 | - $v_size -= $v_read_size; |
|
| 2272 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2273 | + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2274 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2275 | + $v_size -= $v_read_size; |
|
| 2276 | 2276 | } |
| 2277 | 2277 | |
| 2278 | 2278 | // ----- Create the Central Dir files header |
| 2279 | 2279 | for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
| 2280 | 2280 | {
|
| 2281 | - // ----- Create the file header |
|
| 2282 | - if ($v_header_list[$i]['status'] == 'ok') {
|
|
| 2281 | + // ----- Create the file header |
|
| 2282 | + if ($v_header_list[$i]['status'] == 'ok') {
|
|
| 2283 | 2283 | if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
| 2284 | - fclose($v_zip_temp_fd); |
|
| 2285 | - $this->privCloseFd(); |
|
| 2286 | - @unlink($v_zip_temp_name); |
|
| 2287 | - $this->privSwapBackMagicQuotes(); |
|
| 2284 | + fclose($v_zip_temp_fd); |
|
| 2285 | + $this->privCloseFd(); |
|
| 2286 | + @unlink($v_zip_temp_name); |
|
| 2287 | + $this->privSwapBackMagicQuotes(); |
|
| 2288 | 2288 | |
| 2289 | - // ----- Return |
|
| 2290 | - return $v_result; |
|
| 2289 | + // ----- Return |
|
| 2290 | + return $v_result; |
|
| 2291 | 2291 | } |
| 2292 | 2292 | $v_count++; |
| 2293 | - } |
|
| 2293 | + } |
|
| 2294 | 2294 | |
| 2295 | - // ----- Transform the header to a 'usable' info |
|
| 2296 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2295 | + // ----- Transform the header to a 'usable' info |
|
| 2296 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | 2299 | // ----- Zip file comment |
| 2300 | 2300 | $v_comment = $v_central_dir['comment']; |
| 2301 | 2301 | if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
| 2302 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2302 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2303 | 2303 | } |
| 2304 | 2304 | if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
|
| 2305 | - $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2305 | + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2306 | 2306 | } |
| 2307 | 2307 | if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
|
| 2308 | - $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2308 | + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | // ----- Calculate the size of the central header |
@@ -2314,12 +2314,12 @@ discard block |
||
| 2314 | 2314 | // ----- Create the central dir footer |
| 2315 | 2315 | if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
| 2316 | 2316 | {
|
| 2317 | - // ----- Reset the file list |
|
| 2318 | - unset($v_header_list); |
|
| 2319 | - $this->privSwapBackMagicQuotes(); |
|
| 2317 | + // ----- Reset the file list |
|
| 2318 | + unset($v_header_list); |
|
| 2319 | + $this->privSwapBackMagicQuotes(); |
|
| 2320 | 2320 | |
| 2321 | - // ----- Return |
|
| 2322 | - return $v_result; |
|
| 2321 | + // ----- Return |
|
| 2322 | + return $v_result; |
|
| 2323 | 2323 | } |
| 2324 | 2324 | |
| 2325 | 2325 | // ----- Swap back the file descriptor |
@@ -2347,85 +2347,85 @@ discard block |
||
| 2347 | 2347 | |
| 2348 | 2348 | // ----- Return |
| 2349 | 2349 | return $v_result; |
| 2350 | - } |
|
| 2351 | - // -------------------------------------------------------------------------------- |
|
| 2352 | - |
|
| 2353 | - // -------------------------------------------------------------------------------- |
|
| 2354 | - // Function : privOpenFd() |
|
| 2355 | - // Description : |
|
| 2356 | - // Parameters : |
|
| 2357 | - // -------------------------------------------------------------------------------- |
|
| 2358 | - function privOpenFd($p_mode) |
|
| 2359 | - {
|
|
| 2350 | + } |
|
| 2351 | + // -------------------------------------------------------------------------------- |
|
| 2352 | + |
|
| 2353 | + // -------------------------------------------------------------------------------- |
|
| 2354 | + // Function : privOpenFd() |
|
| 2355 | + // Description : |
|
| 2356 | + // Parameters : |
|
| 2357 | + // -------------------------------------------------------------------------------- |
|
| 2358 | + function privOpenFd($p_mode) |
|
| 2359 | + {
|
|
| 2360 | 2360 | $v_result=1; |
| 2361 | 2361 | |
| 2362 | 2362 | // ----- Look if already open |
| 2363 | 2363 | if ($this->zip_fd != 0) |
| 2364 | 2364 | {
|
| 2365 | - // ----- Error log |
|
| 2366 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2365 | + // ----- Error log |
|
| 2366 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2367 | 2367 | |
| 2368 | - // ----- Return |
|
| 2369 | - return PclZip::errorCode(); |
|
| 2368 | + // ----- Return |
|
| 2369 | + return PclZip::errorCode(); |
|
| 2370 | 2370 | } |
| 2371 | 2371 | |
| 2372 | 2372 | // ----- Open the zip file |
| 2373 | 2373 | if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
| 2374 | 2374 | {
|
| 2375 | - // ----- Error log |
|
| 2376 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2375 | + // ----- Error log |
|
| 2376 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2377 | 2377 | |
| 2378 | - // ----- Return |
|
| 2379 | - return PclZip::errorCode(); |
|
| 2378 | + // ----- Return |
|
| 2379 | + return PclZip::errorCode(); |
|
| 2380 | 2380 | } |
| 2381 | 2381 | |
| 2382 | 2382 | // ----- Return |
| 2383 | 2383 | return $v_result; |
| 2384 | - } |
|
| 2385 | - // -------------------------------------------------------------------------------- |
|
| 2386 | - |
|
| 2387 | - // -------------------------------------------------------------------------------- |
|
| 2388 | - // Function : privCloseFd() |
|
| 2389 | - // Description : |
|
| 2390 | - // Parameters : |
|
| 2391 | - // -------------------------------------------------------------------------------- |
|
| 2392 | - function privCloseFd() |
|
| 2393 | - {
|
|
| 2384 | + } |
|
| 2385 | + // -------------------------------------------------------------------------------- |
|
| 2386 | + |
|
| 2387 | + // -------------------------------------------------------------------------------- |
|
| 2388 | + // Function : privCloseFd() |
|
| 2389 | + // Description : |
|
| 2390 | + // Parameters : |
|
| 2391 | + // -------------------------------------------------------------------------------- |
|
| 2392 | + function privCloseFd() |
|
| 2393 | + {
|
|
| 2394 | 2394 | $v_result=1; |
| 2395 | 2395 | |
| 2396 | 2396 | if ($this->zip_fd != 0) |
| 2397 | - @fclose($this->zip_fd); |
|
| 2397 | + @fclose($this->zip_fd); |
|
| 2398 | 2398 | $this->zip_fd = 0; |
| 2399 | 2399 | |
| 2400 | 2400 | // ----- Return |
| 2401 | 2401 | return $v_result; |
| 2402 | - } |
|
| 2403 | - // -------------------------------------------------------------------------------- |
|
| 2404 | - |
|
| 2405 | - // -------------------------------------------------------------------------------- |
|
| 2406 | - // Function : privAddList() |
|
| 2407 | - // Description : |
|
| 2408 | - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 2409 | - // different from the real path of the file. This is usefull if you want to have PclTar |
|
| 2410 | - // running in any directory, and memorize relative path from an other directory. |
|
| 2411 | - // Parameters : |
|
| 2412 | - // $p_list : An array containing the file or directory names to add in the tar |
|
| 2413 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
| 2414 | - // $p_add_dir : Path to add in the filename path archived |
|
| 2415 | - // $p_remove_dir : Path to remove in the filename path archived |
|
| 2416 | - // Return Values : |
|
| 2417 | - // -------------------------------------------------------------------------------- |
|
| 2402 | + } |
|
| 2403 | + // -------------------------------------------------------------------------------- |
|
| 2404 | + |
|
| 2405 | + // -------------------------------------------------------------------------------- |
|
| 2406 | + // Function : privAddList() |
|
| 2407 | + // Description : |
|
| 2408 | + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 2409 | + // different from the real path of the file. This is usefull if you want to have PclTar |
|
| 2410 | + // running in any directory, and memorize relative path from an other directory. |
|
| 2411 | + // Parameters : |
|
| 2412 | + // $p_list : An array containing the file or directory names to add in the tar |
|
| 2413 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
| 2414 | + // $p_add_dir : Path to add in the filename path archived |
|
| 2415 | + // $p_remove_dir : Path to remove in the filename path archived |
|
| 2416 | + // Return Values : |
|
| 2417 | + // -------------------------------------------------------------------------------- |
|
| 2418 | 2418 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2419 | - function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2420 | - {
|
|
| 2419 | + function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2420 | + {
|
|
| 2421 | 2421 | $v_result=1; |
| 2422 | 2422 | |
| 2423 | 2423 | // ----- Add the files |
| 2424 | 2424 | $v_header_list = array(); |
| 2425 | 2425 | if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
| 2426 | 2426 | {
|
| 2427 | - // ----- Return |
|
| 2428 | - return $v_result; |
|
| 2427 | + // ----- Return |
|
| 2428 | + return $v_result; |
|
| 2429 | 2429 | } |
| 2430 | 2430 | |
| 2431 | 2431 | // ----- Store the offset of the central dir |
@@ -2434,23 +2434,23 @@ discard block |
||
| 2434 | 2434 | // ----- Create the Central Dir files header |
| 2435 | 2435 | for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
| 2436 | 2436 | {
|
| 2437 | - // ----- Create the file header |
|
| 2438 | - if ($v_header_list[$i]['status'] == 'ok') {
|
|
| 2437 | + // ----- Create the file header |
|
| 2438 | + if ($v_header_list[$i]['status'] == 'ok') {
|
|
| 2439 | 2439 | if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
| 2440 | - // ----- Return |
|
| 2441 | - return $v_result; |
|
| 2440 | + // ----- Return |
|
| 2441 | + return $v_result; |
|
| 2442 | 2442 | } |
| 2443 | 2443 | $v_count++; |
| 2444 | - } |
|
| 2444 | + } |
|
| 2445 | 2445 | |
| 2446 | - // ----- Transform the header to a 'usable' info |
|
| 2447 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2446 | + // ----- Transform the header to a 'usable' info |
|
| 2447 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2448 | 2448 | } |
| 2449 | 2449 | |
| 2450 | 2450 | // ----- Zip file comment |
| 2451 | 2451 | $v_comment = ''; |
| 2452 | 2452 | if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
| 2453 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2453 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2454 | 2454 | } |
| 2455 | 2455 | |
| 2456 | 2456 | // ----- Calculate the size of the central header |
@@ -2459,29 +2459,29 @@ discard block |
||
| 2459 | 2459 | // ----- Create the central dir footer |
| 2460 | 2460 | if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
| 2461 | 2461 | {
|
| 2462 | - // ----- Reset the file list |
|
| 2463 | - unset($v_header_list); |
|
| 2462 | + // ----- Reset the file list |
|
| 2463 | + unset($v_header_list); |
|
| 2464 | 2464 | |
| 2465 | - // ----- Return |
|
| 2466 | - return $v_result; |
|
| 2465 | + // ----- Return |
|
| 2466 | + return $v_result; |
|
| 2467 | 2467 | } |
| 2468 | 2468 | |
| 2469 | 2469 | // ----- Return |
| 2470 | 2470 | return $v_result; |
| 2471 | - } |
|
| 2472 | - // -------------------------------------------------------------------------------- |
|
| 2473 | - |
|
| 2474 | - // -------------------------------------------------------------------------------- |
|
| 2475 | - // Function : privAddFileList() |
|
| 2476 | - // Description : |
|
| 2477 | - // Parameters : |
|
| 2478 | - // $p_filedescr_list : An array containing the file description |
|
| 2479 | - // or directory names to add in the zip |
|
| 2480 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
| 2481 | - // Return Values : |
|
| 2482 | - // -------------------------------------------------------------------------------- |
|
| 2483 | - function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2484 | - {
|
|
| 2471 | + } |
|
| 2472 | + // -------------------------------------------------------------------------------- |
|
| 2473 | + |
|
| 2474 | + // -------------------------------------------------------------------------------- |
|
| 2475 | + // Function : privAddFileList() |
|
| 2476 | + // Description : |
|
| 2477 | + // Parameters : |
|
| 2478 | + // $p_filedescr_list : An array containing the file description |
|
| 2479 | + // or directory names to add in the zip |
|
| 2480 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
| 2481 | + // Return Values : |
|
| 2482 | + // -------------------------------------------------------------------------------- |
|
| 2483 | + function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
|
| 2484 | + {
|
|
| 2485 | 2485 | $v_result=1; |
| 2486 | 2486 | $v_header = array(); |
| 2487 | 2487 | |
@@ -2490,60 +2490,60 @@ discard block |
||
| 2490 | 2490 | |
| 2491 | 2491 | // ----- Loop on the files |
| 2492 | 2492 | for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
|
| 2493 | - // ----- Format the filename |
|
| 2494 | - $p_filedescr_list[$j]['filename'] |
|
| 2495 | - = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2493 | + // ----- Format the filename |
|
| 2494 | + $p_filedescr_list[$j]['filename'] |
|
| 2495 | + = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2496 | 2496 | |
| 2497 | 2497 | |
| 2498 | - // ----- Skip empty file names |
|
| 2499 | - // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2500 | - if ($p_filedescr_list[$j]['filename'] == "") {
|
|
| 2498 | + // ----- Skip empty file names |
|
| 2499 | + // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2500 | + if ($p_filedescr_list[$j]['filename'] == "") {
|
|
| 2501 | 2501 | continue; |
| 2502 | - } |
|
| 2502 | + } |
|
| 2503 | 2503 | |
| 2504 | - // ----- Check the filename |
|
| 2505 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2504 | + // ----- Check the filename |
|
| 2505 | + if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2506 | 2506 | && (!file_exists($p_filedescr_list[$j]['filename']))) {
|
| 2507 | 2507 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
| 2508 | 2508 | return PclZip::errorCode(); |
| 2509 | - } |
|
| 2509 | + } |
|
| 2510 | 2510 | |
| 2511 | - // ----- Look if it is a file or a dir with no all path remove option |
|
| 2512 | - // or a dir with all its path removed |
|
| 2511 | + // ----- Look if it is a file or a dir with no all path remove option |
|
| 2512 | + // or a dir with all its path removed |
|
| 2513 | 2513 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2514 | 2514 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2515 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2515 | + if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2516 | 2516 | || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
| 2517 | 2517 | || ( ($p_filedescr_list[$j]['type'] == 'folder') |
| 2518 | 2518 | && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
| 2519 | 2519 | || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
| 2520 | - ) {
|
|
| 2520 | + ) {
|
|
| 2521 | 2521 | |
| 2522 | 2522 | // ----- Add the file |
| 2523 | 2523 | $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, |
| 2524 | - $p_options); |
|
| 2524 | + $p_options); |
|
| 2525 | 2525 | if ($v_result != 1) {
|
| 2526 | - return $v_result; |
|
| 2526 | + return $v_result; |
|
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | 2529 | // ----- Store the file infos |
| 2530 | 2530 | $p_result_list[$v_nb++] = $v_header; |
| 2531 | - } |
|
| 2531 | + } |
|
| 2532 | 2532 | } |
| 2533 | 2533 | |
| 2534 | 2534 | // ----- Return |
| 2535 | 2535 | return $v_result; |
| 2536 | - } |
|
| 2537 | - // -------------------------------------------------------------------------------- |
|
| 2538 | - |
|
| 2539 | - // -------------------------------------------------------------------------------- |
|
| 2540 | - // Function : privAddFile() |
|
| 2541 | - // Description : |
|
| 2542 | - // Parameters : |
|
| 2543 | - // Return Values : |
|
| 2544 | - // -------------------------------------------------------------------------------- |
|
| 2545 | - function privAddFile($p_filedescr, &$p_header, &$p_options) |
|
| 2546 | - {
|
|
| 2536 | + } |
|
| 2537 | + // -------------------------------------------------------------------------------- |
|
| 2538 | + |
|
| 2539 | + // -------------------------------------------------------------------------------- |
|
| 2540 | + // Function : privAddFile() |
|
| 2541 | + // Description : |
|
| 2542 | + // Parameters : |
|
| 2543 | + // Return Values : |
|
| 2544 | + // -------------------------------------------------------------------------------- |
|
| 2545 | + function privAddFile($p_filedescr, &$p_header, &$p_options) |
|
| 2546 | + {
|
|
| 2547 | 2547 | $v_result=1; |
| 2548 | 2548 | |
| 2549 | 2549 | // ----- Working variable |
@@ -2551,11 +2551,11 @@ discard block |
||
| 2551 | 2551 | |
| 2552 | 2552 | // TBC : Already done in the fileAtt check ... ? |
| 2553 | 2553 | if ($p_filename == "") {
|
| 2554 | - // ----- Error log |
|
| 2555 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2554 | + // ----- Error log |
|
| 2555 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2556 | 2556 | |
| 2557 | - // ----- Return |
|
| 2558 | - return PclZip::errorCode(); |
|
| 2557 | + // ----- Return |
|
| 2558 | + return PclZip::errorCode(); |
|
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | 2561 | // ----- Look for a stored different filename |
@@ -2590,94 +2590,94 @@ discard block |
||
| 2590 | 2590 | |
| 2591 | 2591 | // ----- Look for regular file |
| 2592 | 2592 | if ($p_filedescr['type']=='file') {
|
| 2593 | - $p_header['external'] = 0x00000000; |
|
| 2594 | - $p_header['size'] = filesize($p_filename); |
|
| 2593 | + $p_header['external'] = 0x00000000; |
|
| 2594 | + $p_header['size'] = filesize($p_filename); |
|
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | 2597 | // ----- Look for regular folder |
| 2598 | 2598 | else if ($p_filedescr['type']=='folder') {
|
| 2599 | - $p_header['external'] = 0x00000010; |
|
| 2600 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2601 | - $p_header['size'] = filesize($p_filename); |
|
| 2599 | + $p_header['external'] = 0x00000010; |
|
| 2600 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2601 | + $p_header['size'] = filesize($p_filename); |
|
| 2602 | 2602 | } |
| 2603 | 2603 | |
| 2604 | 2604 | // ----- Look for virtual file |
| 2605 | 2605 | else if ($p_filedescr['type'] == 'virtual_file') {
|
| 2606 | - $p_header['external'] = 0x00000000; |
|
| 2607 | - $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2606 | + $p_header['external'] = 0x00000000; |
|
| 2607 | + $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2608 | 2608 | } |
| 2609 | 2609 | |
| 2610 | 2610 | |
| 2611 | 2611 | // ----- Look for filetime |
| 2612 | 2612 | if (isset($p_filedescr['mtime'])) {
|
| 2613 | - $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2613 | + $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2614 | 2614 | } |
| 2615 | 2615 | else if ($p_filedescr['type'] == 'virtual_file') {
|
| 2616 | - $p_header['mtime'] = time(); |
|
| 2616 | + $p_header['mtime'] = time(); |
|
| 2617 | 2617 | } |
| 2618 | 2618 | else {
|
| 2619 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2619 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2620 | 2620 | } |
| 2621 | 2621 | |
| 2622 | 2622 | // ------ Look for file comment |
| 2623 | 2623 | if (isset($p_filedescr['comment'])) {
|
| 2624 | - $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2625 | - $p_header['comment'] = $p_filedescr['comment']; |
|
| 2624 | + $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2625 | + $p_header['comment'] = $p_filedescr['comment']; |
|
| 2626 | 2626 | } |
| 2627 | 2627 | else {
|
| 2628 | - $p_header['comment_len'] = 0; |
|
| 2629 | - $p_header['comment'] = ''; |
|
| 2628 | + $p_header['comment_len'] = 0; |
|
| 2629 | + $p_header['comment'] = ''; |
|
| 2630 | 2630 | } |
| 2631 | 2631 | |
| 2632 | 2632 | // ----- Look for pre-add callback |
| 2633 | 2633 | if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
|
| 2634 | 2634 | |
| 2635 | - // ----- Generate a local information |
|
| 2636 | - $v_local_header = array(); |
|
| 2637 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2635 | + // ----- Generate a local information |
|
| 2636 | + $v_local_header = array(); |
|
| 2637 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2638 | 2638 | |
| 2639 | - // ----- Call the callback |
|
| 2640 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2641 | - // header. |
|
| 2639 | + // ----- Call the callback |
|
| 2640 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2641 | + // header. |
|
| 2642 | 2642 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
|
| 2643 | - $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2644 | - if ($v_result == 0) {
|
|
| 2643 | + $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2644 | + if ($v_result == 0) {
|
|
| 2645 | 2645 | // ----- Change the file status |
| 2646 | 2646 | $p_header['status'] = "skipped"; |
| 2647 | 2647 | $v_result = 1; |
| 2648 | - } |
|
| 2648 | + } |
|
| 2649 | 2649 | |
| 2650 | - // ----- Update the informations |
|
| 2651 | - // Only some fields can be modified |
|
| 2652 | - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
|
|
| 2650 | + // ----- Update the informations |
|
| 2651 | + // Only some fields can be modified |
|
| 2652 | + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
|
|
| 2653 | 2653 | $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); |
| 2654 | - } |
|
| 2654 | + } |
|
| 2655 | 2655 | } |
| 2656 | 2656 | |
| 2657 | 2657 | // ----- Look for empty stored filename |
| 2658 | 2658 | if ($p_header['stored_filename'] == "") {
|
| 2659 | - $p_header['status'] = "filtered"; |
|
| 2659 | + $p_header['status'] = "filtered"; |
|
| 2660 | 2660 | } |
| 2661 | 2661 | |
| 2662 | 2662 | // ----- Check the path length |
| 2663 | 2663 | if (strlen($p_header['stored_filename']) > 0xFF) {
|
| 2664 | - $p_header['status'] = 'filename_too_long'; |
|
| 2664 | + $p_header['status'] = 'filename_too_long'; |
|
| 2665 | 2665 | } |
| 2666 | 2666 | |
| 2667 | 2667 | // ----- Look if no error, or file not skipped |
| 2668 | 2668 | if ($p_header['status'] == 'ok') {
|
| 2669 | 2669 | |
| 2670 | - // ----- Look for a file |
|
| 2671 | - if ($p_filedescr['type'] == 'file') {
|
|
| 2670 | + // ----- Look for a file |
|
| 2671 | + if ($p_filedescr['type'] == 'file') {
|
|
| 2672 | 2672 | // ----- Look for using temporary file to zip |
| 2673 | 2673 | if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
| 2674 | 2674 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 2675 | 2675 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 2676 | 2676 | && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
|
| 2677 | - $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2678 | - if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
|
| 2677 | + $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2678 | + if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
|
| 2679 | 2679 | return $v_result; |
| 2680 | - } |
|
| 2680 | + } |
|
| 2681 | 2681 | } |
| 2682 | 2682 | |
| 2683 | 2683 | // ----- Use "in memory" zip algo |
@@ -2685,8 +2685,8 @@ discard block |
||
| 2685 | 2685 | |
| 2686 | 2686 | // ----- Open the source file |
| 2687 | 2687 | if (($v_file = @fopen($p_filename, "rb")) == 0) {
|
| 2688 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2689 | - return PclZip::errorCode(); |
|
| 2688 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2689 | + return PclZip::errorCode(); |
|
| 2690 | 2690 | } |
| 2691 | 2691 | |
| 2692 | 2692 | // ----- Read the file content |
@@ -2700,25 +2700,25 @@ discard block |
||
| 2700 | 2700 | |
| 2701 | 2701 | // ----- Look for no compression |
| 2702 | 2702 | if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
|
| 2703 | - // ----- Set header parameters |
|
| 2704 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2705 | - $p_header['compression'] = 0; |
|
| 2703 | + // ----- Set header parameters |
|
| 2704 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2705 | + $p_header['compression'] = 0; |
|
| 2706 | 2706 | } |
| 2707 | 2707 | |
| 2708 | 2708 | // ----- Look for normal compression |
| 2709 | 2709 | else {
|
| 2710 | - // ----- Compress the content |
|
| 2711 | - $v_content = @gzdeflate($v_content); |
|
| 2710 | + // ----- Compress the content |
|
| 2711 | + $v_content = @gzdeflate($v_content); |
|
| 2712 | 2712 | |
| 2713 | - // ----- Set header parameters |
|
| 2714 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2715 | - $p_header['compression'] = 8; |
|
| 2713 | + // ----- Set header parameters |
|
| 2714 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2715 | + $p_header['compression'] = 8; |
|
| 2716 | 2716 | } |
| 2717 | 2717 | |
| 2718 | 2718 | // ----- Call the header generation |
| 2719 | 2719 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
| 2720 | - @fclose($v_file); |
|
| 2721 | - return $v_result; |
|
| 2720 | + @fclose($v_file); |
|
| 2721 | + return $v_result; |
|
| 2722 | 2722 | } |
| 2723 | 2723 | |
| 2724 | 2724 | // ----- Write the compressed (or not) content |
@@ -2726,10 +2726,10 @@ discard block |
||
| 2726 | 2726 | |
| 2727 | 2727 | } |
| 2728 | 2728 | |
| 2729 | - } |
|
| 2729 | + } |
|
| 2730 | 2730 | |
| 2731 | - // ----- Look for a virtual file (a file from string) |
|
| 2732 | - else if ($p_filedescr['type'] == 'virtual_file') {
|
|
| 2731 | + // ----- Look for a virtual file (a file from string) |
|
| 2732 | + else if ($p_filedescr['type'] == 'virtual_file') {
|
|
| 2733 | 2733 | |
| 2734 | 2734 | $v_content = $p_filedescr['content']; |
| 2735 | 2735 | |
@@ -2738,36 +2738,36 @@ discard block |
||
| 2738 | 2738 | |
| 2739 | 2739 | // ----- Look for no compression |
| 2740 | 2740 | if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
|
| 2741 | - // ----- Set header parameters |
|
| 2742 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2743 | - $p_header['compression'] = 0; |
|
| 2741 | + // ----- Set header parameters |
|
| 2742 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2743 | + $p_header['compression'] = 0; |
|
| 2744 | 2744 | } |
| 2745 | 2745 | |
| 2746 | 2746 | // ----- Look for normal compression |
| 2747 | 2747 | else {
|
| 2748 | - // ----- Compress the content |
|
| 2749 | - $v_content = @gzdeflate($v_content); |
|
| 2748 | + // ----- Compress the content |
|
| 2749 | + $v_content = @gzdeflate($v_content); |
|
| 2750 | 2750 | |
| 2751 | - // ----- Set header parameters |
|
| 2752 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2753 | - $p_header['compression'] = 8; |
|
| 2751 | + // ----- Set header parameters |
|
| 2752 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2753 | + $p_header['compression'] = 8; |
|
| 2754 | 2754 | } |
| 2755 | 2755 | |
| 2756 | 2756 | // ----- Call the header generation |
| 2757 | 2757 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
| 2758 | - @fclose($v_file); |
|
| 2759 | - return $v_result; |
|
| 2758 | + @fclose($v_file); |
|
| 2759 | + return $v_result; |
|
| 2760 | 2760 | } |
| 2761 | 2761 | |
| 2762 | 2762 | // ----- Write the compressed (or not) content |
| 2763 | 2763 | @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
| 2764 | - } |
|
| 2764 | + } |
|
| 2765 | 2765 | |
| 2766 | - // ----- Look for a directory |
|
| 2767 | - else if ($p_filedescr['type'] == 'folder') {
|
|
| 2766 | + // ----- Look for a directory |
|
| 2767 | + else if ($p_filedescr['type'] == 'folder') {
|
|
| 2768 | 2768 | // ----- Look for directory last '/' |
| 2769 | 2769 | if (@substr($p_header['stored_filename'], -1) != '/') {
|
| 2770 | - $p_header['stored_filename'] .= '/'; |
|
| 2770 | + $p_header['stored_filename'] .= '/'; |
|
| 2771 | 2771 | } |
| 2772 | 2772 | |
| 2773 | 2773 | // ----- Set the file properties |
@@ -2778,45 +2778,45 @@ discard block |
||
| 2778 | 2778 | // ----- Call the header generation |
| 2779 | 2779 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
| 2780 | 2780 | {
|
| 2781 | - return $v_result; |
|
| 2781 | + return $v_result; |
|
| 2782 | + } |
|
| 2782 | 2783 | } |
| 2783 | - } |
|
| 2784 | 2784 | } |
| 2785 | 2785 | |
| 2786 | 2786 | // ----- Look for post-add callback |
| 2787 | 2787 | if (isset($p_options[PCLZIP_CB_POST_ADD])) {
|
| 2788 | 2788 | |
| 2789 | - // ----- Generate a local information |
|
| 2790 | - $v_local_header = array(); |
|
| 2791 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2789 | + // ----- Generate a local information |
|
| 2790 | + $v_local_header = array(); |
|
| 2791 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2792 | 2792 | |
| 2793 | - // ----- Call the callback |
|
| 2794 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2795 | - // header. |
|
| 2793 | + // ----- Call the callback |
|
| 2794 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2795 | + // header. |
|
| 2796 | 2796 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
|
| 2797 | - $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2798 | - if ($v_result == 0) {
|
|
| 2797 | + $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2798 | + if ($v_result == 0) {
|
|
| 2799 | 2799 | // ----- Ignored |
| 2800 | 2800 | $v_result = 1; |
| 2801 | - } |
|
| 2801 | + } |
|
| 2802 | 2802 | |
| 2803 | - // ----- Update the informations |
|
| 2804 | - // Nothing can be modified |
|
| 2803 | + // ----- Update the informations |
|
| 2804 | + // Nothing can be modified |
|
| 2805 | 2805 | } |
| 2806 | 2806 | |
| 2807 | 2807 | // ----- Return |
| 2808 | 2808 | return $v_result; |
| 2809 | - } |
|
| 2810 | - // -------------------------------------------------------------------------------- |
|
| 2811 | - |
|
| 2812 | - // -------------------------------------------------------------------------------- |
|
| 2813 | - // Function : privAddFileUsingTempFile() |
|
| 2814 | - // Description : |
|
| 2815 | - // Parameters : |
|
| 2816 | - // Return Values : |
|
| 2817 | - // -------------------------------------------------------------------------------- |
|
| 2818 | - function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
|
| 2819 | - {
|
|
| 2809 | + } |
|
| 2810 | + // -------------------------------------------------------------------------------- |
|
| 2811 | + |
|
| 2812 | + // -------------------------------------------------------------------------------- |
|
| 2813 | + // Function : privAddFileUsingTempFile() |
|
| 2814 | + // Description : |
|
| 2815 | + // Parameters : |
|
| 2816 | + // Return Values : |
|
| 2817 | + // -------------------------------------------------------------------------------- |
|
| 2818 | + function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
|
| 2819 | + {
|
|
| 2820 | 2820 | $v_result=PCLZIP_ERR_NO_ERROR; |
| 2821 | 2821 | |
| 2822 | 2822 | // ----- Working variable |
@@ -2825,26 +2825,26 @@ discard block |
||
| 2825 | 2825 | |
| 2826 | 2826 | // ----- Open the source file |
| 2827 | 2827 | if (($v_file = @fopen($p_filename, "rb")) == 0) {
|
| 2828 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2829 | - return PclZip::errorCode(); |
|
| 2828 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2829 | + return PclZip::errorCode(); |
|
| 2830 | 2830 | } |
| 2831 | 2831 | |
| 2832 | 2832 | // ----- Creates a compressed temporary file |
| 2833 | 2833 | $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
|
| 2834 | 2834 | if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
|
| 2835 | - fclose($v_file); |
|
| 2836 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2837 | - return PclZip::errorCode(); |
|
| 2835 | + fclose($v_file); |
|
| 2836 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2837 | + return PclZip::errorCode(); |
|
| 2838 | 2838 | } |
| 2839 | 2839 | |
| 2840 | 2840 | // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
| 2841 | 2841 | $v_size = filesize($p_filename); |
| 2842 | 2842 | while ($v_size != 0) {
|
| 2843 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2844 | - $v_buffer = @fread($v_file, $v_read_size); |
|
| 2845 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 2846 | - @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2847 | - $v_size -= $v_read_size; |
|
| 2843 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2844 | + $v_buffer = @fread($v_file, $v_read_size); |
|
| 2845 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 2846 | + @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2847 | + $v_size -= $v_read_size; |
|
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | // ----- Close the file |
@@ -2853,14 +2853,14 @@ discard block |
||
| 2853 | 2853 | |
| 2854 | 2854 | // ----- Check the minimum file size |
| 2855 | 2855 | if (filesize($v_gzip_temp_name) < 18) {
|
| 2856 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2857 | - return PclZip::errorCode(); |
|
| 2856 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2857 | + return PclZip::errorCode(); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | |
| 2860 | 2860 | // ----- Extract the compressed attributes |
| 2861 | 2861 | if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
|
| 2862 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2863 | - return PclZip::errorCode(); |
|
| 2862 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2863 | + return PclZip::errorCode(); |
|
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | 2866 | // ----- Read the gzip file header |
@@ -2886,14 +2886,14 @@ discard block |
||
| 2886 | 2886 | |
| 2887 | 2887 | // ----- Call the header generation |
| 2888 | 2888 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
| 2889 | - return $v_result; |
|
| 2889 | + return $v_result; |
|
| 2890 | 2890 | } |
| 2891 | 2891 | |
| 2892 | 2892 | // ----- Add the compressed data |
| 2893 | 2893 | if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
| 2894 | 2894 | {
|
| 2895 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2896 | - return PclZip::errorCode(); |
|
| 2895 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2896 | + return PclZip::errorCode(); |
|
| 2897 | 2897 | } |
| 2898 | 2898 | |
| 2899 | 2899 | // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
@@ -2901,11 +2901,11 @@ discard block |
||
| 2901 | 2901 | $v_size = $p_header['compressed_size']; |
| 2902 | 2902 | while ($v_size != 0) |
| 2903 | 2903 | {
|
| 2904 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2905 | - $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2906 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 2907 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2908 | - $v_size -= $v_read_size; |
|
| 2904 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2905 | + $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2906 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 2907 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2908 | + $v_size -= $v_read_size; |
|
| 2909 | 2909 | } |
| 2910 | 2910 | |
| 2911 | 2911 | // ----- Close the file |
@@ -2916,112 +2916,112 @@ discard block |
||
| 2916 | 2916 | |
| 2917 | 2917 | // ----- Return |
| 2918 | 2918 | return $v_result; |
| 2919 | - } |
|
| 2920 | - // -------------------------------------------------------------------------------- |
|
| 2921 | - |
|
| 2922 | - // -------------------------------------------------------------------------------- |
|
| 2923 | - // Function : privCalculateStoredFilename() |
|
| 2924 | - // Description : |
|
| 2925 | - // Based on file descriptor properties and global options, this method |
|
| 2926 | - // calculate the filename that will be stored in the archive. |
|
| 2927 | - // Parameters : |
|
| 2928 | - // Return Values : |
|
| 2929 | - // -------------------------------------------------------------------------------- |
|
| 2930 | - function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
|
| 2931 | - {
|
|
| 2919 | + } |
|
| 2920 | + // -------------------------------------------------------------------------------- |
|
| 2921 | + |
|
| 2922 | + // -------------------------------------------------------------------------------- |
|
| 2923 | + // Function : privCalculateStoredFilename() |
|
| 2924 | + // Description : |
|
| 2925 | + // Based on file descriptor properties and global options, this method |
|
| 2926 | + // calculate the filename that will be stored in the archive. |
|
| 2927 | + // Parameters : |
|
| 2928 | + // Return Values : |
|
| 2929 | + // -------------------------------------------------------------------------------- |
|
| 2930 | + function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
|
| 2931 | + {
|
|
| 2932 | 2932 | $v_result=1; |
| 2933 | 2933 | |
| 2934 | 2934 | // ----- Working variables |
| 2935 | 2935 | $p_filename = $p_filedescr['filename']; |
| 2936 | 2936 | if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
|
| 2937 | - $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2937 | + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2938 | 2938 | } |
| 2939 | 2939 | else {
|
| 2940 | - $p_add_dir = ''; |
|
| 2940 | + $p_add_dir = ''; |
|
| 2941 | 2941 | } |
| 2942 | 2942 | if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
|
| 2943 | - $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2943 | + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2944 | 2944 | } |
| 2945 | 2945 | else {
|
| 2946 | - $p_remove_dir = ''; |
|
| 2946 | + $p_remove_dir = ''; |
|
| 2947 | 2947 | } |
| 2948 | 2948 | if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
| 2949 | - $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2949 | + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2950 | 2950 | } |
| 2951 | 2951 | else {
|
| 2952 | - $p_remove_all_dir = 0; |
|
| 2952 | + $p_remove_all_dir = 0; |
|
| 2953 | 2953 | } |
| 2954 | 2954 | |
| 2955 | 2955 | |
| 2956 | 2956 | // ----- Look for full name change |
| 2957 | 2957 | if (isset($p_filedescr['new_full_name'])) {
|
| 2958 | - // ----- Remove drive letter if any |
|
| 2959 | - $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2958 | + // ----- Remove drive letter if any |
|
| 2959 | + $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2960 | 2960 | } |
| 2961 | 2961 | |
| 2962 | 2962 | // ----- Look for path and/or short name change |
| 2963 | 2963 | else {
|
| 2964 | 2964 | |
| 2965 | - // ----- Look for short name change |
|
| 2966 | - // Its when we cahnge just the filename but not the path |
|
| 2967 | - if (isset($p_filedescr['new_short_name'])) {
|
|
| 2965 | + // ----- Look for short name change |
|
| 2966 | + // Its when we cahnge just the filename but not the path |
|
| 2967 | + if (isset($p_filedescr['new_short_name'])) {
|
|
| 2968 | 2968 | $v_path_info = pathinfo($p_filename); |
| 2969 | 2969 | $v_dir = ''; |
| 2970 | 2970 | if ($v_path_info['dirname'] != '') {
|
| 2971 | - $v_dir = $v_path_info['dirname'].'/'; |
|
| 2971 | + $v_dir = $v_path_info['dirname'].'/'; |
|
| 2972 | 2972 | } |
| 2973 | 2973 | $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
| 2974 | - } |
|
| 2975 | - else {
|
|
| 2974 | + } |
|
| 2975 | + else {
|
|
| 2976 | 2976 | // ----- Calculate the stored filename |
| 2977 | 2977 | $v_stored_filename = $p_filename; |
| 2978 | - } |
|
| 2978 | + } |
|
| 2979 | 2979 | |
| 2980 | - // ----- Look for all path to remove |
|
| 2981 | - if ($p_remove_all_dir) {
|
|
| 2980 | + // ----- Look for all path to remove |
|
| 2981 | + if ($p_remove_all_dir) {
|
|
| 2982 | 2982 | $v_stored_filename = basename($p_filename); |
| 2983 | - } |
|
| 2984 | - // ----- Look for partial path remove |
|
| 2985 | - else if ($p_remove_dir != "") {
|
|
| 2983 | + } |
|
| 2984 | + // ----- Look for partial path remove |
|
| 2985 | + else if ($p_remove_dir != "") {
|
|
| 2986 | 2986 | if (substr($p_remove_dir, -1) != '/') |
| 2987 | - $p_remove_dir .= "/"; |
|
| 2987 | + $p_remove_dir .= "/"; |
|
| 2988 | 2988 | |
| 2989 | 2989 | if ( (substr($p_filename, 0, 2) == "./") |
| 2990 | 2990 | || (substr($p_remove_dir, 0, 2) == "./")) {
|
| 2991 | 2991 | |
| 2992 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2992 | + if ( (substr($p_filename, 0, 2) == "./") |
|
| 2993 | 2993 | && (substr($p_remove_dir, 0, 2) != "./")) {
|
| 2994 | 2994 | $p_remove_dir = "./".$p_remove_dir; |
| 2995 | - } |
|
| 2996 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2995 | + } |
|
| 2996 | + if ( (substr($p_filename, 0, 2) != "./") |
|
| 2997 | 2997 | && (substr($p_remove_dir, 0, 2) == "./")) {
|
| 2998 | 2998 | $p_remove_dir = substr($p_remove_dir, 2); |
| 2999 | - } |
|
| 2999 | + } |
|
| 3000 | 3000 | } |
| 3001 | 3001 | |
| 3002 | 3002 | $v_compare = PclZipUtilPathInclusion($p_remove_dir, |
| 3003 | - $v_stored_filename); |
|
| 3003 | + $v_stored_filename); |
|
| 3004 | 3004 | if ($v_compare > 0) {
|
| 3005 | - if ($v_compare == 2) {
|
|
| 3005 | + if ($v_compare == 2) {
|
|
| 3006 | 3006 | $v_stored_filename = ""; |
| 3007 | - } |
|
| 3008 | - else {
|
|
| 3007 | + } |
|
| 3008 | + else {
|
|
| 3009 | 3009 | $v_stored_filename = substr($v_stored_filename, |
| 3010 | 3010 | strlen($p_remove_dir)); |
| 3011 | - } |
|
| 3011 | + } |
|
| 3012 | + } |
|
| 3012 | 3013 | } |
| 3013 | - } |
|
| 3014 | 3014 | |
| 3015 | - // ----- Remove drive letter if any |
|
| 3016 | - $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 3015 | + // ----- Remove drive letter if any |
|
| 3016 | + $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 3017 | 3017 | |
| 3018 | - // ----- Look for path to add |
|
| 3019 | - if ($p_add_dir != "") {
|
|
| 3018 | + // ----- Look for path to add |
|
| 3019 | + if ($p_add_dir != "") {
|
|
| 3020 | 3020 | if (substr($p_add_dir, -1) == "/") |
| 3021 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3021 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3022 | 3022 | else |
| 3023 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3024 | - } |
|
| 3023 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3024 | + } |
|
| 3025 | 3025 | } |
| 3026 | 3026 | |
| 3027 | 3027 | // ----- Filename (reduce the path of stored name) |
@@ -3030,17 +3030,17 @@ discard block |
||
| 3030 | 3030 | |
| 3031 | 3031 | // ----- Return |
| 3032 | 3032 | return $v_result; |
| 3033 | - } |
|
| 3034 | - // -------------------------------------------------------------------------------- |
|
| 3035 | - |
|
| 3036 | - // -------------------------------------------------------------------------------- |
|
| 3037 | - // Function : privWriteFileHeader() |
|
| 3038 | - // Description : |
|
| 3039 | - // Parameters : |
|
| 3040 | - // Return Values : |
|
| 3041 | - // -------------------------------------------------------------------------------- |
|
| 3042 | - function privWriteFileHeader(&$p_header) |
|
| 3043 | - {
|
|
| 3033 | + } |
|
| 3034 | + // -------------------------------------------------------------------------------- |
|
| 3035 | + |
|
| 3036 | + // -------------------------------------------------------------------------------- |
|
| 3037 | + // Function : privWriteFileHeader() |
|
| 3038 | + // Description : |
|
| 3039 | + // Parameters : |
|
| 3040 | + // Return Values : |
|
| 3041 | + // -------------------------------------------------------------------------------- |
|
| 3042 | + function privWriteFileHeader(&$p_header) |
|
| 3043 | + {
|
|
| 3044 | 3044 | $v_result=1; |
| 3045 | 3045 | |
| 3046 | 3046 | // ----- Store the offset position of the file |
@@ -3053,12 +3053,12 @@ discard block |
||
| 3053 | 3053 | |
| 3054 | 3054 | // ----- Packed data |
| 3055 | 3055 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
|
| 3056 | - $p_header['version_extracted'], $p_header['flag'], |
|
| 3057 | - $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3058 | - $p_header['crc'], $p_header['compressed_size'], |
|
| 3059 | - $p_header['size'], |
|
| 3060 | - strlen($p_header['stored_filename']), |
|
| 3061 | - $p_header['extra_len']); |
|
| 3056 | + $p_header['version_extracted'], $p_header['flag'], |
|
| 3057 | + $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3058 | + $p_header['crc'], $p_header['compressed_size'], |
|
| 3059 | + $p_header['size'], |
|
| 3060 | + strlen($p_header['stored_filename']), |
|
| 3061 | + $p_header['extra_len']); |
|
| 3062 | 3062 | |
| 3063 | 3063 | // ----- Write the first 148 bytes of the header in the archive |
| 3064 | 3064 | fputs($this->zip_fd, $v_binary_data, 30); |
@@ -3066,26 +3066,26 @@ discard block |
||
| 3066 | 3066 | // ----- Write the variable fields |
| 3067 | 3067 | if (strlen($p_header['stored_filename']) != 0) |
| 3068 | 3068 | {
|
| 3069 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3069 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3070 | 3070 | } |
| 3071 | 3071 | if ($p_header['extra_len'] != 0) |
| 3072 | 3072 | {
|
| 3073 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3073 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3074 | 3074 | } |
| 3075 | 3075 | |
| 3076 | 3076 | // ----- Return |
| 3077 | 3077 | return $v_result; |
| 3078 | - } |
|
| 3079 | - // -------------------------------------------------------------------------------- |
|
| 3080 | - |
|
| 3081 | - // -------------------------------------------------------------------------------- |
|
| 3082 | - // Function : privWriteCentralFileHeader() |
|
| 3083 | - // Description : |
|
| 3084 | - // Parameters : |
|
| 3085 | - // Return Values : |
|
| 3086 | - // -------------------------------------------------------------------------------- |
|
| 3087 | - function privWriteCentralFileHeader(&$p_header) |
|
| 3088 | - {
|
|
| 3078 | + } |
|
| 3079 | + // -------------------------------------------------------------------------------- |
|
| 3080 | + |
|
| 3081 | + // -------------------------------------------------------------------------------- |
|
| 3082 | + // Function : privWriteCentralFileHeader() |
|
| 3083 | + // Description : |
|
| 3084 | + // Parameters : |
|
| 3085 | + // Return Values : |
|
| 3086 | + // -------------------------------------------------------------------------------- |
|
| 3087 | + function privWriteCentralFileHeader(&$p_header) |
|
| 3088 | + {
|
|
| 3089 | 3089 | $v_result=1; |
| 3090 | 3090 | |
| 3091 | 3091 | // TBC |
@@ -3100,14 +3100,14 @@ discard block |
||
| 3100 | 3100 | |
| 3101 | 3101 | // ----- Packed data |
| 3102 | 3102 | $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
|
| 3103 | - $p_header['version'], $p_header['version_extracted'], |
|
| 3104 | - $p_header['flag'], $p_header['compression'], |
|
| 3105 | - $v_mtime, $v_mdate, $p_header['crc'], |
|
| 3106 | - $p_header['compressed_size'], $p_header['size'], |
|
| 3107 | - strlen($p_header['stored_filename']), |
|
| 3108 | - $p_header['extra_len'], $p_header['comment_len'], |
|
| 3109 | - $p_header['disk'], $p_header['internal'], |
|
| 3110 | - $p_header['external'], $p_header['offset']); |
|
| 3103 | + $p_header['version'], $p_header['version_extracted'], |
|
| 3104 | + $p_header['flag'], $p_header['compression'], |
|
| 3105 | + $v_mtime, $v_mdate, $p_header['crc'], |
|
| 3106 | + $p_header['compressed_size'], $p_header['size'], |
|
| 3107 | + strlen($p_header['stored_filename']), |
|
| 3108 | + $p_header['extra_len'], $p_header['comment_len'], |
|
| 3109 | + $p_header['disk'], $p_header['internal'], |
|
| 3110 | + $p_header['external'], $p_header['offset']); |
|
| 3111 | 3111 | |
| 3112 | 3112 | // ----- Write the 42 bytes of the header in the zip file |
| 3113 | 3113 | fputs($this->zip_fd, $v_binary_data, 46); |
@@ -3115,36 +3115,36 @@ discard block |
||
| 3115 | 3115 | // ----- Write the variable fields |
| 3116 | 3116 | if (strlen($p_header['stored_filename']) != 0) |
| 3117 | 3117 | {
|
| 3118 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3118 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3119 | 3119 | } |
| 3120 | 3120 | if ($p_header['extra_len'] != 0) |
| 3121 | 3121 | {
|
| 3122 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3122 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3123 | 3123 | } |
| 3124 | 3124 | if ($p_header['comment_len'] != 0) |
| 3125 | 3125 | {
|
| 3126 | - fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3126 | + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3127 | 3127 | } |
| 3128 | 3128 | |
| 3129 | 3129 | // ----- Return |
| 3130 | 3130 | return $v_result; |
| 3131 | - } |
|
| 3132 | - // -------------------------------------------------------------------------------- |
|
| 3133 | - |
|
| 3134 | - // -------------------------------------------------------------------------------- |
|
| 3135 | - // Function : privWriteCentralHeader() |
|
| 3136 | - // Description : |
|
| 3137 | - // Parameters : |
|
| 3138 | - // Return Values : |
|
| 3139 | - // -------------------------------------------------------------------------------- |
|
| 3140 | - function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
| 3141 | - {
|
|
| 3131 | + } |
|
| 3132 | + // -------------------------------------------------------------------------------- |
|
| 3133 | + |
|
| 3134 | + // -------------------------------------------------------------------------------- |
|
| 3135 | + // Function : privWriteCentralHeader() |
|
| 3136 | + // Description : |
|
| 3137 | + // Parameters : |
|
| 3138 | + // Return Values : |
|
| 3139 | + // -------------------------------------------------------------------------------- |
|
| 3140 | + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
| 3141 | + {
|
|
| 3142 | 3142 | $v_result=1; |
| 3143 | 3143 | |
| 3144 | 3144 | // ----- Packed data |
| 3145 | 3145 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
|
| 3146 | - $p_nb_entries, $p_size, |
|
| 3147 | - $p_offset, strlen($p_comment)); |
|
| 3146 | + $p_nb_entries, $p_size, |
|
| 3147 | + $p_offset, strlen($p_comment)); |
|
| 3148 | 3148 | |
| 3149 | 3149 | // ----- Write the 22 bytes of the header in the zip file |
| 3150 | 3150 | fputs($this->zip_fd, $v_binary_data, 22); |
@@ -3152,22 +3152,22 @@ discard block |
||
| 3152 | 3152 | // ----- Write the variable fields |
| 3153 | 3153 | if (strlen($p_comment) != 0) |
| 3154 | 3154 | {
|
| 3155 | - fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3155 | + fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3156 | 3156 | } |
| 3157 | 3157 | |
| 3158 | 3158 | // ----- Return |
| 3159 | 3159 | return $v_result; |
| 3160 | - } |
|
| 3161 | - // -------------------------------------------------------------------------------- |
|
| 3162 | - |
|
| 3163 | - // -------------------------------------------------------------------------------- |
|
| 3164 | - // Function : privList() |
|
| 3165 | - // Description : |
|
| 3166 | - // Parameters : |
|
| 3167 | - // Return Values : |
|
| 3168 | - // -------------------------------------------------------------------------------- |
|
| 3169 | - function privList(&$p_list) |
|
| 3170 | - {
|
|
| 3160 | + } |
|
| 3161 | + // -------------------------------------------------------------------------------- |
|
| 3162 | + |
|
| 3163 | + // -------------------------------------------------------------------------------- |
|
| 3164 | + // Function : privList() |
|
| 3165 | + // Description : |
|
| 3166 | + // Parameters : |
|
| 3167 | + // Return Values : |
|
| 3168 | + // -------------------------------------------------------------------------------- |
|
| 3169 | + function privList(&$p_list) |
|
| 3170 | + {
|
|
| 3171 | 3171 | $v_result=1; |
| 3172 | 3172 | |
| 3173 | 3173 | // ----- Magic quotes trick |
@@ -3176,51 +3176,51 @@ discard block |
||
| 3176 | 3176 | // ----- Open the zip file |
| 3177 | 3177 | if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
| 3178 | 3178 | {
|
| 3179 | - // ----- Magic quotes trick |
|
| 3180 | - $this->privSwapBackMagicQuotes(); |
|
| 3179 | + // ----- Magic quotes trick |
|
| 3180 | + $this->privSwapBackMagicQuotes(); |
|
| 3181 | 3181 | |
| 3182 | - // ----- Error log |
|
| 3183 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3182 | + // ----- Error log |
|
| 3183 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3184 | 3184 | |
| 3185 | - // ----- Return |
|
| 3186 | - return PclZip::errorCode(); |
|
| 3185 | + // ----- Return |
|
| 3186 | + return PclZip::errorCode(); |
|
| 3187 | 3187 | } |
| 3188 | 3188 | |
| 3189 | 3189 | // ----- Read the central directory informations |
| 3190 | 3190 | $v_central_dir = array(); |
| 3191 | 3191 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 3192 | 3192 | {
|
| 3193 | - $this->privSwapBackMagicQuotes(); |
|
| 3194 | - return $v_result; |
|
| 3193 | + $this->privSwapBackMagicQuotes(); |
|
| 3194 | + return $v_result; |
|
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | 3197 | // ----- Go to beginning of Central Dir |
| 3198 | 3198 | @rewind($this->zip_fd); |
| 3199 | 3199 | if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
| 3200 | 3200 | {
|
| 3201 | - $this->privSwapBackMagicQuotes(); |
|
| 3201 | + $this->privSwapBackMagicQuotes(); |
|
| 3202 | 3202 | |
| 3203 | - // ----- Error log |
|
| 3204 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3203 | + // ----- Error log |
|
| 3204 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3205 | 3205 | |
| 3206 | - // ----- Return |
|
| 3207 | - return PclZip::errorCode(); |
|
| 3206 | + // ----- Return |
|
| 3207 | + return PclZip::errorCode(); |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | // ----- Read each entry |
| 3211 | 3211 | for ($i=0; $i<$v_central_dir['entries']; $i++) |
| 3212 | 3212 | {
|
| 3213 | - // ----- Read the file header |
|
| 3214 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3215 | - {
|
|
| 3213 | + // ----- Read the file header |
|
| 3214 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3215 | + {
|
|
| 3216 | 3216 | $this->privSwapBackMagicQuotes(); |
| 3217 | 3217 | return $v_result; |
| 3218 | - } |
|
| 3219 | - $v_header['index'] = $i; |
|
| 3218 | + } |
|
| 3219 | + $v_header['index'] = $i; |
|
| 3220 | 3220 | |
| 3221 | - // ----- Get the only interesting attributes |
|
| 3222 | - $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3223 | - unset($v_header); |
|
| 3221 | + // ----- Get the only interesting attributes |
|
| 3222 | + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3223 | + unset($v_header); |
|
| 3224 | 3224 | } |
| 3225 | 3225 | |
| 3226 | 3226 | // ----- Close the zip file |
@@ -3231,30 +3231,30 @@ discard block |
||
| 3231 | 3231 | |
| 3232 | 3232 | // ----- Return |
| 3233 | 3233 | return $v_result; |
| 3234 | - } |
|
| 3235 | - // -------------------------------------------------------------------------------- |
|
| 3236 | - |
|
| 3237 | - // -------------------------------------------------------------------------------- |
|
| 3238 | - // Function : privConvertHeader2FileInfo() |
|
| 3239 | - // Description : |
|
| 3240 | - // This function takes the file informations from the central directory |
|
| 3241 | - // entries and extract the interesting parameters that will be given back. |
|
| 3242 | - // The resulting file infos are set in the array $p_info |
|
| 3243 | - // $p_info['filename'] : Filename with full path. Given by user (add), |
|
| 3244 | - // extracted in the filesystem (extract). |
|
| 3245 | - // $p_info['stored_filename'] : Stored filename in the archive. |
|
| 3246 | - // $p_info['size'] = Size of the file. |
|
| 3247 | - // $p_info['compressed_size'] = Compressed size of the file. |
|
| 3248 | - // $p_info['mtime'] = Last modification date of the file. |
|
| 3249 | - // $p_info['comment'] = Comment associated with the file. |
|
| 3250 | - // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
| 3251 | - // $p_info['status'] = status of the action on the file. |
|
| 3252 | - // $p_info['crc'] = CRC of the file content. |
|
| 3253 | - // Parameters : |
|
| 3254 | - // Return Values : |
|
| 3255 | - // -------------------------------------------------------------------------------- |
|
| 3256 | - function privConvertHeader2FileInfo($p_header, &$p_info) |
|
| 3257 | - {
|
|
| 3234 | + } |
|
| 3235 | + // -------------------------------------------------------------------------------- |
|
| 3236 | + |
|
| 3237 | + // -------------------------------------------------------------------------------- |
|
| 3238 | + // Function : privConvertHeader2FileInfo() |
|
| 3239 | + // Description : |
|
| 3240 | + // This function takes the file informations from the central directory |
|
| 3241 | + // entries and extract the interesting parameters that will be given back. |
|
| 3242 | + // The resulting file infos are set in the array $p_info |
|
| 3243 | + // $p_info['filename'] : Filename with full path. Given by user (add), |
|
| 3244 | + // extracted in the filesystem (extract). |
|
| 3245 | + // $p_info['stored_filename'] : Stored filename in the archive. |
|
| 3246 | + // $p_info['size'] = Size of the file. |
|
| 3247 | + // $p_info['compressed_size'] = Compressed size of the file. |
|
| 3248 | + // $p_info['mtime'] = Last modification date of the file. |
|
| 3249 | + // $p_info['comment'] = Comment associated with the file. |
|
| 3250 | + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
| 3251 | + // $p_info['status'] = status of the action on the file. |
|
| 3252 | + // $p_info['crc'] = CRC of the file content. |
|
| 3253 | + // Parameters : |
|
| 3254 | + // Return Values : |
|
| 3255 | + // -------------------------------------------------------------------------------- |
|
| 3256 | + function privConvertHeader2FileInfo($p_header, &$p_info) |
|
| 3257 | + {
|
|
| 3258 | 3258 | $v_result=1; |
| 3259 | 3259 | |
| 3260 | 3260 | // ----- Get the interesting attributes |
@@ -3273,27 +3273,27 @@ discard block |
||
| 3273 | 3273 | |
| 3274 | 3274 | // ----- Return |
| 3275 | 3275 | return $v_result; |
| 3276 | - } |
|
| 3277 | - // -------------------------------------------------------------------------------- |
|
| 3278 | - |
|
| 3279 | - // -------------------------------------------------------------------------------- |
|
| 3280 | - // Function : privExtractByRule() |
|
| 3281 | - // Description : |
|
| 3282 | - // Extract a file or directory depending of rules (by index, by name, ...) |
|
| 3283 | - // Parameters : |
|
| 3284 | - // $p_file_list : An array where will be placed the properties of each |
|
| 3285 | - // extracted file |
|
| 3286 | - // $p_path : Path to add while writing the extracted files |
|
| 3287 | - // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
| 3288 | - // extracted files. If the path does not match the file path, |
|
| 3289 | - // the file is extracted with its memorized path. |
|
| 3290 | - // $p_remove_path does not apply to 'list' mode. |
|
| 3291 | - // $p_path and $p_remove_path are commulative. |
|
| 3292 | - // Return Values : |
|
| 3293 | - // 1 on success,0 or less on error (see error code list) |
|
| 3294 | - // -------------------------------------------------------------------------------- |
|
| 3295 | - function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
|
| 3296 | - {
|
|
| 3276 | + } |
|
| 3277 | + // -------------------------------------------------------------------------------- |
|
| 3278 | + |
|
| 3279 | + // -------------------------------------------------------------------------------- |
|
| 3280 | + // Function : privExtractByRule() |
|
| 3281 | + // Description : |
|
| 3282 | + // Extract a file or directory depending of rules (by index, by name, ...) |
|
| 3283 | + // Parameters : |
|
| 3284 | + // $p_file_list : An array where will be placed the properties of each |
|
| 3285 | + // extracted file |
|
| 3286 | + // $p_path : Path to add while writing the extracted files |
|
| 3287 | + // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
| 3288 | + // extracted files. If the path does not match the file path, |
|
| 3289 | + // the file is extracted with its memorized path. |
|
| 3290 | + // $p_remove_path does not apply to 'list' mode. |
|
| 3291 | + // $p_path and $p_remove_path are commulative. |
|
| 3292 | + // Return Values : |
|
| 3293 | + // 1 on success,0 or less on error (see error code list) |
|
| 3294 | + // -------------------------------------------------------------------------------- |
|
| 3295 | + function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
|
| 3296 | + {
|
|
| 3297 | 3297 | $v_result=1; |
| 3298 | 3298 | |
| 3299 | 3299 | // ----- Magic quotes trick |
@@ -3301,44 +3301,44 @@ discard block |
||
| 3301 | 3301 | |
| 3302 | 3302 | // ----- Check the path |
| 3303 | 3303 | if ( ($p_path == "") |
| 3304 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3305 | - && (substr($p_path, 0, 3) != "../") |
|
| 3306 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3307 | - $p_path = "./".$p_path; |
|
| 3304 | + || ( (substr($p_path, 0, 1) != "/") |
|
| 3305 | + && (substr($p_path, 0, 3) != "../") |
|
| 3306 | + && (substr($p_path,1,2)!=":/"))) |
|
| 3307 | + $p_path = "./".$p_path; |
|
| 3308 | 3308 | |
| 3309 | 3309 | // ----- Reduce the path last (and duplicated) '/' |
| 3310 | 3310 | if (($p_path != "./") && ($p_path != "/")) |
| 3311 | 3311 | {
|
| 3312 | - // ----- Look for the path end '/' |
|
| 3313 | - while (substr($p_path, -1) == "/") |
|
| 3314 | - {
|
|
| 3312 | + // ----- Look for the path end '/' |
|
| 3313 | + while (substr($p_path, -1) == "/") |
|
| 3314 | + {
|
|
| 3315 | 3315 | $p_path = substr($p_path, 0, strlen($p_path)-1); |
| 3316 | - } |
|
| 3316 | + } |
|
| 3317 | 3317 | } |
| 3318 | 3318 | |
| 3319 | 3319 | // ----- Look for path to remove format (should end by /) |
| 3320 | 3320 | if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) |
| 3321 | 3321 | {
|
| 3322 | - $p_remove_path .= '/'; |
|
| 3322 | + $p_remove_path .= '/'; |
|
| 3323 | 3323 | } |
| 3324 | 3324 | $p_remove_path_size = strlen($p_remove_path); |
| 3325 | 3325 | |
| 3326 | 3326 | // ----- Open the zip file |
| 3327 | 3327 | if (($v_result = $this->privOpenFd('rb')) != 1)
|
| 3328 | 3328 | {
|
| 3329 | - $this->privSwapBackMagicQuotes(); |
|
| 3330 | - return $v_result; |
|
| 3329 | + $this->privSwapBackMagicQuotes(); |
|
| 3330 | + return $v_result; |
|
| 3331 | 3331 | } |
| 3332 | 3332 | |
| 3333 | 3333 | // ----- Read the central directory informations |
| 3334 | 3334 | $v_central_dir = array(); |
| 3335 | 3335 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 3336 | 3336 | {
|
| 3337 | - // ----- Close the zip file |
|
| 3338 | - $this->privCloseFd(); |
|
| 3339 | - $this->privSwapBackMagicQuotes(); |
|
| 3337 | + // ----- Close the zip file |
|
| 3338 | + $this->privCloseFd(); |
|
| 3339 | + $this->privSwapBackMagicQuotes(); |
|
| 3340 | 3340 | |
| 3341 | - return $v_result; |
|
| 3341 | + return $v_result; |
|
| 3342 | 3342 | } |
| 3343 | 3343 | |
| 3344 | 3344 | // ----- Start at beginning of Central Dir |
@@ -3349,10 +3349,10 @@ discard block |
||
| 3349 | 3349 | for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
| 3350 | 3350 | {
|
| 3351 | 3351 | |
| 3352 | - // ----- Read next Central dir entry |
|
| 3353 | - @rewind($this->zip_fd); |
|
| 3354 | - if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3355 | - {
|
|
| 3352 | + // ----- Read next Central dir entry |
|
| 3353 | + @rewind($this->zip_fd); |
|
| 3354 | + if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3355 | + {
|
|
| 3356 | 3356 | // ----- Close the zip file |
| 3357 | 3357 | $this->privCloseFd(); |
| 3358 | 3358 | $this->privSwapBackMagicQuotes(); |
@@ -3362,54 +3362,54 @@ discard block |
||
| 3362 | 3362 | |
| 3363 | 3363 | // ----- Return |
| 3364 | 3364 | return PclZip::errorCode(); |
| 3365 | - } |
|
| 3365 | + } |
|
| 3366 | 3366 | |
| 3367 | - // ----- Read the file header |
|
| 3368 | - $v_header = array(); |
|
| 3369 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3370 | - {
|
|
| 3367 | + // ----- Read the file header |
|
| 3368 | + $v_header = array(); |
|
| 3369 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3370 | + {
|
|
| 3371 | 3371 | // ----- Close the zip file |
| 3372 | 3372 | $this->privCloseFd(); |
| 3373 | 3373 | $this->privSwapBackMagicQuotes(); |
| 3374 | 3374 | |
| 3375 | 3375 | return $v_result; |
| 3376 | - } |
|
| 3376 | + } |
|
| 3377 | 3377 | |
| 3378 | - // ----- Store the index |
|
| 3379 | - $v_header['index'] = $i; |
|
| 3378 | + // ----- Store the index |
|
| 3379 | + $v_header['index'] = $i; |
|
| 3380 | 3380 | |
| 3381 | - // ----- Store the file position |
|
| 3382 | - $v_pos_entry = ftell($this->zip_fd); |
|
| 3381 | + // ----- Store the file position |
|
| 3382 | + $v_pos_entry = ftell($this->zip_fd); |
|
| 3383 | 3383 | |
| 3384 | - // ----- Look for the specific extract rules |
|
| 3385 | - $v_extract = false; |
|
| 3384 | + // ----- Look for the specific extract rules |
|
| 3385 | + $v_extract = false; |
|
| 3386 | 3386 | |
| 3387 | - // ----- Look for extract by name rule |
|
| 3388 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3387 | + // ----- Look for extract by name rule |
|
| 3388 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3389 | 3389 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
| 3390 | 3390 | |
| 3391 | - // ----- Look if the filename is in the list |
|
| 3392 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
|
|
| 3391 | + // ----- Look if the filename is in the list |
|
| 3392 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
|
|
| 3393 | 3393 | |
| 3394 | - // ----- Look for a directory |
|
| 3395 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
|
| 3394 | + // ----- Look for a directory |
|
| 3395 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
|
| 3396 | 3396 | |
| 3397 | - // ----- Look if the directory is in the filename path |
|
| 3398 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3397 | + // ----- Look if the directory is in the filename path |
|
| 3398 | + if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3399 | 3399 | && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 3400 | - $v_extract = true; |
|
| 3401 | - } |
|
| 3402 | - } |
|
| 3403 | - // ----- Look for a filename |
|
| 3404 | - elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
|
| 3405 | - $v_extract = true; |
|
| 3406 | - } |
|
| 3407 | - } |
|
| 3408 | - } |
|
| 3400 | + $v_extract = true; |
|
| 3401 | + } |
|
| 3402 | + } |
|
| 3403 | + // ----- Look for a filename |
|
| 3404 | + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
|
| 3405 | + $v_extract = true; |
|
| 3406 | + } |
|
| 3407 | + } |
|
| 3408 | + } |
|
| 3409 | 3409 | |
| 3410 | - // ----- Look for extract by ereg rule |
|
| 3411 | - // ereg() is deprecated with PHP 5.3 |
|
| 3412 | - /* |
|
| 3410 | + // ----- Look for extract by ereg rule |
|
| 3411 | + // ereg() is deprecated with PHP 5.3 |
|
| 3412 | + /* |
|
| 3413 | 3413 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 3414 | 3414 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
|
| 3415 | 3415 | |
@@ -3419,199 +3419,199 @@ discard block |
||
| 3419 | 3419 | } |
| 3420 | 3420 | */ |
| 3421 | 3421 | |
| 3422 | - // ----- Look for extract by preg rule |
|
| 3423 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3422 | + // ----- Look for extract by preg rule |
|
| 3423 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3424 | 3424 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
| 3425 | 3425 | |
| 3426 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
|
|
| 3427 | - $v_extract = true; |
|
| 3428 | - } |
|
| 3429 | - } |
|
| 3426 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
|
|
| 3427 | + $v_extract = true; |
|
| 3428 | + } |
|
| 3429 | + } |
|
| 3430 | 3430 | |
| 3431 | - // ----- Look for extract by index rule |
|
| 3432 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3431 | + // ----- Look for extract by index rule |
|
| 3432 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3433 | 3433 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
| 3434 | 3434 | |
| 3435 | - // ----- Look if the index is in the list |
|
| 3436 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
|
|
| 3435 | + // ----- Look if the index is in the list |
|
| 3436 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
|
|
| 3437 | 3437 | |
| 3438 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 3439 | - $v_extract = true; |
|
| 3440 | - } |
|
| 3441 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 3442 | - $j_start = $j+1; |
|
| 3443 | - } |
|
| 3438 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 3439 | + $v_extract = true; |
|
| 3440 | + } |
|
| 3441 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 3442 | + $j_start = $j+1; |
|
| 3443 | + } |
|
| 3444 | 3444 | |
| 3445 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 3446 | - break; |
|
| 3447 | - } |
|
| 3448 | - } |
|
| 3449 | - } |
|
| 3445 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 3446 | + break; |
|
| 3447 | + } |
|
| 3448 | + } |
|
| 3449 | + } |
|
| 3450 | 3450 | |
| 3451 | - // ----- Look for no rule, which means extract all the archive |
|
| 3452 | - else {
|
|
| 3453 | - $v_extract = true; |
|
| 3454 | - } |
|
| 3451 | + // ----- Look for no rule, which means extract all the archive |
|
| 3452 | + else {
|
|
| 3453 | + $v_extract = true; |
|
| 3454 | + } |
|
| 3455 | 3455 | |
| 3456 | - // ----- Check compression method |
|
| 3457 | - if ( ($v_extract) |
|
| 3458 | - && ( ($v_header['compression'] != 8) |
|
| 3459 | - && ($v_header['compression'] != 0))) {
|
|
| 3460 | - $v_header['status'] = 'unsupported_compression'; |
|
| 3456 | + // ----- Check compression method |
|
| 3457 | + if ( ($v_extract) |
|
| 3458 | + && ( ($v_header['compression'] != 8) |
|
| 3459 | + && ($v_header['compression'] != 0))) {
|
|
| 3460 | + $v_header['status'] = 'unsupported_compression'; |
|
| 3461 | 3461 | |
| 3462 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3463 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3464 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3462 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3463 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3464 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3465 | 3465 | |
| 3466 | - $this->privSwapBackMagicQuotes(); |
|
| 3466 | + $this->privSwapBackMagicQuotes(); |
|
| 3467 | 3467 | |
| 3468 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3469 | - "Filename '".$v_header['stored_filename']."' is " |
|
| 3470 | - ."compressed by an unsupported compression " |
|
| 3471 | - ."method (".$v_header['compression'].") ");
|
|
| 3468 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3469 | + "Filename '".$v_header['stored_filename']."' is " |
|
| 3470 | + ."compressed by an unsupported compression " |
|
| 3471 | + ."method (".$v_header['compression'].") ");
|
|
| 3472 | 3472 | |
| 3473 | - return PclZip::errorCode(); |
|
| 3474 | - } |
|
| 3475 | - } |
|
| 3473 | + return PclZip::errorCode(); |
|
| 3474 | + } |
|
| 3475 | + } |
|
| 3476 | 3476 | |
| 3477 | - // ----- Check encrypted files |
|
| 3478 | - if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
|
|
| 3479 | - $v_header['status'] = 'unsupported_encryption'; |
|
| 3477 | + // ----- Check encrypted files |
|
| 3478 | + if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
|
|
| 3479 | + $v_header['status'] = 'unsupported_encryption'; |
|
| 3480 | 3480 | |
| 3481 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3482 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3483 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3481 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3482 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3483 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3484 | 3484 | |
| 3485 | - $this->privSwapBackMagicQuotes(); |
|
| 3485 | + $this->privSwapBackMagicQuotes(); |
|
| 3486 | 3486 | |
| 3487 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3488 | - "Unsupported encryption for " |
|
| 3489 | - ." filename '".$v_header['stored_filename'] |
|
| 3490 | - ."'"); |
|
| 3487 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3488 | + "Unsupported encryption for " |
|
| 3489 | + ." filename '".$v_header['stored_filename'] |
|
| 3490 | + ."'"); |
|
| 3491 | 3491 | |
| 3492 | - return PclZip::errorCode(); |
|
| 3493 | - } |
|
| 3492 | + return PclZip::errorCode(); |
|
| 3493 | + } |
|
| 3494 | 3494 | } |
| 3495 | 3495 | |
| 3496 | - // ----- Look for real extraction |
|
| 3497 | - if (($v_extract) && ($v_header['status'] != 'ok')) {
|
|
| 3498 | - $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3499 | - $p_file_list[$v_nb_extracted++]); |
|
| 3500 | - if ($v_result != 1) {
|
|
| 3501 | - $this->privCloseFd(); |
|
| 3502 | - $this->privSwapBackMagicQuotes(); |
|
| 3503 | - return $v_result; |
|
| 3504 | - } |
|
| 3496 | + // ----- Look for real extraction |
|
| 3497 | + if (($v_extract) && ($v_header['status'] != 'ok')) {
|
|
| 3498 | + $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3499 | + $p_file_list[$v_nb_extracted++]); |
|
| 3500 | + if ($v_result != 1) {
|
|
| 3501 | + $this->privCloseFd(); |
|
| 3502 | + $this->privSwapBackMagicQuotes(); |
|
| 3503 | + return $v_result; |
|
| 3504 | + } |
|
| 3505 | 3505 | |
| 3506 | - $v_extract = false; |
|
| 3507 | - } |
|
| 3506 | + $v_extract = false; |
|
| 3507 | + } |
|
| 3508 | 3508 | |
| 3509 | - // ----- Look for real extraction |
|
| 3510 | - if ($v_extract) |
|
| 3511 | - {
|
|
| 3509 | + // ----- Look for real extraction |
|
| 3510 | + if ($v_extract) |
|
| 3511 | + {
|
|
| 3512 | 3512 | |
| 3513 | 3513 | // ----- Go to the file position |
| 3514 | 3514 | @rewind($this->zip_fd); |
| 3515 | 3515 | if (@fseek($this->zip_fd, $v_header['offset'])) |
| 3516 | 3516 | {
|
| 3517 | - // ----- Close the zip file |
|
| 3518 | - $this->privCloseFd(); |
|
| 3517 | + // ----- Close the zip file |
|
| 3518 | + $this->privCloseFd(); |
|
| 3519 | 3519 | |
| 3520 | - $this->privSwapBackMagicQuotes(); |
|
| 3520 | + $this->privSwapBackMagicQuotes(); |
|
| 3521 | 3521 | |
| 3522 | - // ----- Error log |
|
| 3523 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3522 | + // ----- Error log |
|
| 3523 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3524 | 3524 | |
| 3525 | - // ----- Return |
|
| 3526 | - return PclZip::errorCode(); |
|
| 3525 | + // ----- Return |
|
| 3526 | + return PclZip::errorCode(); |
|
| 3527 | 3527 | } |
| 3528 | 3528 | |
| 3529 | 3529 | // ----- Look for extraction as string |
| 3530 | 3530 | if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
|
| 3531 | 3531 | |
| 3532 | - $v_string = ''; |
|
| 3532 | + $v_string = ''; |
|
| 3533 | 3533 | |
| 3534 | - // ----- Extracting the file |
|
| 3535 | - $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3536 | - if ($v_result1 < 1) {
|
|
| 3534 | + // ----- Extracting the file |
|
| 3535 | + $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3536 | + if ($v_result1 < 1) {
|
|
| 3537 | 3537 | $this->privCloseFd(); |
| 3538 | 3538 | $this->privSwapBackMagicQuotes(); |
| 3539 | 3539 | return $v_result1; |
| 3540 | - } |
|
| 3540 | + } |
|
| 3541 | 3541 | |
| 3542 | - // ----- Get the only interesting attributes |
|
| 3543 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3544 | - {
|
|
| 3542 | + // ----- Get the only interesting attributes |
|
| 3543 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3544 | + {
|
|
| 3545 | 3545 | // ----- Close the zip file |
| 3546 | 3546 | $this->privCloseFd(); |
| 3547 | 3547 | $this->privSwapBackMagicQuotes(); |
| 3548 | 3548 | |
| 3549 | 3549 | return $v_result; |
| 3550 | - } |
|
| 3550 | + } |
|
| 3551 | 3551 | |
| 3552 | - // ----- Set the file content |
|
| 3553 | - $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3552 | + // ----- Set the file content |
|
| 3553 | + $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3554 | 3554 | |
| 3555 | - // ----- Next extracted file |
|
| 3556 | - $v_nb_extracted++; |
|
| 3555 | + // ----- Next extracted file |
|
| 3556 | + $v_nb_extracted++; |
|
| 3557 | 3557 | |
| 3558 | - // ----- Look for user callback abort |
|
| 3559 | - if ($v_result1 == 2) {
|
|
| 3560 | - break; |
|
| 3561 | - } |
|
| 3558 | + // ----- Look for user callback abort |
|
| 3559 | + if ($v_result1 == 2) {
|
|
| 3560 | + break; |
|
| 3561 | + } |
|
| 3562 | 3562 | } |
| 3563 | 3563 | // ----- Look for extraction in standard output |
| 3564 | 3564 | elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
| 3565 | - && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
|
|
| 3566 | - // ----- Extracting the file in standard output |
|
| 3567 | - $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3568 | - if ($v_result1 < 1) {
|
|
| 3565 | + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
|
|
| 3566 | + // ----- Extracting the file in standard output |
|
| 3567 | + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3568 | + if ($v_result1 < 1) {
|
|
| 3569 | 3569 | $this->privCloseFd(); |
| 3570 | 3570 | $this->privSwapBackMagicQuotes(); |
| 3571 | 3571 | return $v_result1; |
| 3572 | - } |
|
| 3572 | + } |
|
| 3573 | 3573 | |
| 3574 | - // ----- Get the only interesting attributes |
|
| 3575 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
|
|
| 3574 | + // ----- Get the only interesting attributes |
|
| 3575 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
|
|
| 3576 | 3576 | $this->privCloseFd(); |
| 3577 | 3577 | $this->privSwapBackMagicQuotes(); |
| 3578 | 3578 | return $v_result; |
| 3579 | - } |
|
| 3579 | + } |
|
| 3580 | 3580 | |
| 3581 | - // ----- Look for user callback abort |
|
| 3582 | - if ($v_result1 == 2) {
|
|
| 3583 | - break; |
|
| 3584 | - } |
|
| 3581 | + // ----- Look for user callback abort |
|
| 3582 | + if ($v_result1 == 2) {
|
|
| 3583 | + break; |
|
| 3584 | + } |
|
| 3585 | 3585 | } |
| 3586 | 3586 | // ----- Look for normal extraction |
| 3587 | 3587 | else {
|
| 3588 | - // ----- Extracting the file |
|
| 3589 | - $v_result1 = $this->privExtractFile($v_header, |
|
| 3590 | - $p_path, $p_remove_path, |
|
| 3591 | - $p_remove_all_path, |
|
| 3592 | - $p_options); |
|
| 3593 | - if ($v_result1 < 1) {
|
|
| 3588 | + // ----- Extracting the file |
|
| 3589 | + $v_result1 = $this->privExtractFile($v_header, |
|
| 3590 | + $p_path, $p_remove_path, |
|
| 3591 | + $p_remove_all_path, |
|
| 3592 | + $p_options); |
|
| 3593 | + if ($v_result1 < 1) {
|
|
| 3594 | 3594 | $this->privCloseFd(); |
| 3595 | 3595 | $this->privSwapBackMagicQuotes(); |
| 3596 | 3596 | return $v_result1; |
| 3597 | - } |
|
| 3597 | + } |
|
| 3598 | 3598 | |
| 3599 | - // ----- Get the only interesting attributes |
|
| 3600 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3601 | - {
|
|
| 3599 | + // ----- Get the only interesting attributes |
|
| 3600 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3601 | + {
|
|
| 3602 | 3602 | // ----- Close the zip file |
| 3603 | 3603 | $this->privCloseFd(); |
| 3604 | 3604 | $this->privSwapBackMagicQuotes(); |
| 3605 | 3605 | |
| 3606 | 3606 | return $v_result; |
| 3607 | - } |
|
| 3607 | + } |
|
| 3608 | 3608 | |
| 3609 | - // ----- Look for user callback abort |
|
| 3610 | - if ($v_result1 == 2) {
|
|
| 3611 | - break; |
|
| 3612 | - } |
|
| 3609 | + // ----- Look for user callback abort |
|
| 3610 | + if ($v_result1 == 2) {
|
|
| 3611 | + break; |
|
| 3612 | + } |
|
| 3613 | + } |
|
| 3613 | 3614 | } |
| 3614 | - } |
|
| 3615 | 3615 | } |
| 3616 | 3616 | |
| 3617 | 3617 | // ----- Close the zip file |
@@ -3620,27 +3620,27 @@ discard block |
||
| 3620 | 3620 | |
| 3621 | 3621 | // ----- Return |
| 3622 | 3622 | return $v_result; |
| 3623 | - } |
|
| 3624 | - // -------------------------------------------------------------------------------- |
|
| 3625 | - |
|
| 3626 | - // -------------------------------------------------------------------------------- |
|
| 3627 | - // Function : privExtractFile() |
|
| 3628 | - // Description : |
|
| 3629 | - // Parameters : |
|
| 3630 | - // Return Values : |
|
| 3631 | - // |
|
| 3632 | - // 1 : ... ? |
|
| 3633 | - // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback |
|
| 3634 | - // -------------------------------------------------------------------------------- |
|
| 3635 | - function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
|
| 3636 | - {
|
|
| 3623 | + } |
|
| 3624 | + // -------------------------------------------------------------------------------- |
|
| 3625 | + |
|
| 3626 | + // -------------------------------------------------------------------------------- |
|
| 3627 | + // Function : privExtractFile() |
|
| 3628 | + // Description : |
|
| 3629 | + // Parameters : |
|
| 3630 | + // Return Values : |
|
| 3631 | + // |
|
| 3632 | + // 1 : ... ? |
|
| 3633 | + // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback |
|
| 3634 | + // -------------------------------------------------------------------------------- |
|
| 3635 | + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
|
| 3636 | + {
|
|
| 3637 | 3637 | $v_result=1; |
| 3638 | 3638 | |
| 3639 | 3639 | // ----- Read the file header |
| 3640 | 3640 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
| 3641 | 3641 | {
|
| 3642 | - // ----- Return |
|
| 3643 | - return $v_result; |
|
| 3642 | + // ----- Return |
|
| 3643 | + return $v_result; |
|
| 3644 | 3644 | } |
| 3645 | 3645 | |
| 3646 | 3646 | |
@@ -3666,74 +3666,74 @@ discard block |
||
| 3666 | 3666 | // ----- Look for path to remove |
| 3667 | 3667 | else if ($p_remove_path != "") |
| 3668 | 3668 | {
|
| 3669 | - if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3670 | - {
|
|
| 3669 | + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3670 | + {
|
|
| 3671 | 3671 | |
| 3672 | 3672 | // ----- Change the file status |
| 3673 | 3673 | $p_entry['status'] = "filtered"; |
| 3674 | 3674 | |
| 3675 | 3675 | // ----- Return |
| 3676 | 3676 | return $v_result; |
| 3677 | - } |
|
| 3677 | + } |
|
| 3678 | 3678 | |
| 3679 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 3680 | - if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3681 | - {
|
|
| 3679 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 3680 | + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3681 | + {
|
|
| 3682 | 3682 | |
| 3683 | 3683 | // ----- Remove the path |
| 3684 | 3684 | $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); |
| 3685 | 3685 | |
| 3686 | - } |
|
| 3686 | + } |
|
| 3687 | 3687 | } |
| 3688 | 3688 | |
| 3689 | 3689 | // ----- Add the path |
| 3690 | 3690 | if ($p_path != '') {
|
| 3691 | - $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3691 | + $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3692 | 3692 | } |
| 3693 | 3693 | |
| 3694 | 3694 | // ----- Check a base_dir_restriction |
| 3695 | 3695 | if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
|
| 3696 | - $v_inclusion |
|
| 3697 | - = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3696 | + $v_inclusion |
|
| 3697 | + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3698 | 3698 | $p_entry['filename']); |
| 3699 | - if ($v_inclusion == 0) {
|
|
| 3699 | + if ($v_inclusion == 0) {
|
|
| 3700 | 3700 | |
| 3701 | 3701 | PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
| 3702 | - "Filename '".$p_entry['filename']."' is " |
|
| 3703 | - ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); |
|
| 3702 | + "Filename '".$p_entry['filename']."' is " |
|
| 3703 | + ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); |
|
| 3704 | 3704 | |
| 3705 | 3705 | return PclZip::errorCode(); |
| 3706 | - } |
|
| 3706 | + } |
|
| 3707 | 3707 | } |
| 3708 | 3708 | |
| 3709 | 3709 | // ----- Look for pre-extract callback |
| 3710 | 3710 | if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
| 3711 | 3711 | |
| 3712 | - // ----- Generate a local information |
|
| 3713 | - $v_local_header = array(); |
|
| 3714 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3712 | + // ----- Generate a local information |
|
| 3713 | + $v_local_header = array(); |
|
| 3714 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3715 | 3715 | |
| 3716 | - // ----- Call the callback |
|
| 3717 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3718 | - // header. |
|
| 3716 | + // ----- Call the callback |
|
| 3717 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3718 | + // header. |
|
| 3719 | 3719 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
| 3720 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3721 | - if ($v_result == 0) {
|
|
| 3720 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3721 | + if ($v_result == 0) {
|
|
| 3722 | 3722 | // ----- Change the file status |
| 3723 | 3723 | $p_entry['status'] = "skipped"; |
| 3724 | 3724 | $v_result = 1; |
| 3725 | - } |
|
| 3725 | + } |
|
| 3726 | 3726 | |
| 3727 | - // ----- Look for abort result |
|
| 3728 | - if ($v_result == 2) {
|
|
| 3727 | + // ----- Look for abort result |
|
| 3728 | + if ($v_result == 2) {
|
|
| 3729 | 3729 | // ----- This status is internal and will be changed in 'skipped' |
| 3730 | 3730 | $p_entry['status'] = "aborted"; |
| 3731 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3732 | - } |
|
| 3731 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3732 | + } |
|
| 3733 | 3733 | |
| 3734 | - // ----- Update the informations |
|
| 3735 | - // Only some fields can be modified |
|
| 3736 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 3734 | + // ----- Update the informations |
|
| 3735 | + // Only some fields can be modified |
|
| 3736 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 3737 | 3737 | } |
| 3738 | 3738 | |
| 3739 | 3739 | |
@@ -3744,9 +3744,9 @@ discard block |
||
| 3744 | 3744 | if (file_exists($p_entry['filename'])) |
| 3745 | 3745 | {
|
| 3746 | 3746 | |
| 3747 | - // ----- Look if file is a directory |
|
| 3748 | - if (is_dir($p_entry['filename'])) |
|
| 3749 | - {
|
|
| 3747 | + // ----- Look if file is a directory |
|
| 3748 | + if (is_dir($p_entry['filename'])) |
|
| 3749 | + {
|
|
| 3750 | 3750 | |
| 3751 | 3751 | // ----- Change the file status |
| 3752 | 3752 | $p_entry['status'] = "already_a_directory"; |
@@ -3755,18 +3755,18 @@ discard block |
||
| 3755 | 3755 | // For historical reason first PclZip implementation does not stop |
| 3756 | 3756 | // when this kind of error occurs. |
| 3757 | 3757 | if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
| 3758 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3758 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3759 | 3759 | |
| 3760 | 3760 | PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
| 3761 | - "Filename '".$p_entry['filename']."' is " |
|
| 3762 | - ."already used by an existing directory"); |
|
| 3761 | + "Filename '".$p_entry['filename']."' is " |
|
| 3762 | + ."already used by an existing directory"); |
|
| 3763 | 3763 | |
| 3764 | 3764 | return PclZip::errorCode(); |
| 3765 | - } |
|
| 3766 | - } |
|
| 3767 | - // ----- Look if file is write protected |
|
| 3768 | - else if (!is_writeable($p_entry['filename'])) |
|
| 3769 | - {
|
|
| 3765 | + } |
|
| 3766 | + } |
|
| 3767 | + // ----- Look if file is write protected |
|
| 3768 | + else if (!is_writeable($p_entry['filename'])) |
|
| 3769 | + {
|
|
| 3770 | 3770 | |
| 3771 | 3771 | // ----- Change the file status |
| 3772 | 3772 | $p_entry['status'] = "write_protected"; |
@@ -3775,90 +3775,90 @@ discard block |
||
| 3775 | 3775 | // For historical reason first PclZip implementation does not stop |
| 3776 | 3776 | // when this kind of error occurs. |
| 3777 | 3777 | if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
| 3778 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3778 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3779 | 3779 | |
| 3780 | 3780 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3781 | - "Filename '".$p_entry['filename']."' exists " |
|
| 3782 | - ."and is write protected"); |
|
| 3781 | + "Filename '".$p_entry['filename']."' exists " |
|
| 3782 | + ."and is write protected"); |
|
| 3783 | 3783 | |
| 3784 | 3784 | return PclZip::errorCode(); |
| 3785 | - } |
|
| 3786 | - } |
|
| 3785 | + } |
|
| 3786 | + } |
|
| 3787 | 3787 | |
| 3788 | - // ----- Look if the extracted file is older |
|
| 3789 | - else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3790 | - {
|
|
| 3788 | + // ----- Look if the extracted file is older |
|
| 3789 | + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3790 | + {
|
|
| 3791 | 3791 | // ----- Change the file status |
| 3792 | 3792 | if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
| 3793 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
|
|
| 3794 | - } |
|
| 3795 | - else {
|
|
| 3793 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
|
|
| 3794 | + } |
|
| 3795 | + else {
|
|
| 3796 | 3796 | $p_entry['status'] = "newer_exist"; |
| 3797 | 3797 | |
| 3798 | 3798 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3799 | 3799 | // For historical reason first PclZip implementation does not stop |
| 3800 | 3800 | // when this kind of error occurs. |
| 3801 | 3801 | if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
| 3802 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3802 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
|
| 3803 | 3803 | |
| 3804 | 3804 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3805 | - "Newer version of '".$p_entry['filename']."' exists " |
|
| 3806 | - ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3805 | + "Newer version of '".$p_entry['filename']."' exists " |
|
| 3806 | + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3807 | 3807 | |
| 3808 | 3808 | return PclZip::errorCode(); |
| 3809 | - } |
|
| 3810 | - } |
|
| 3811 | - } |
|
| 3812 | - else {
|
|
| 3813 | - } |
|
| 3809 | + } |
|
| 3810 | + } |
|
| 3811 | + } |
|
| 3812 | + else {
|
|
| 3813 | + } |
|
| 3814 | 3814 | } |
| 3815 | 3815 | |
| 3816 | 3816 | // ----- Check the directory availability and create it if necessary |
| 3817 | 3817 | else {
|
| 3818 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3818 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3819 | 3819 | $v_dir_to_check = $p_entry['filename']; |
| 3820 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3820 | + else if (!strstr($p_entry['filename'], "/")) |
|
| 3821 | 3821 | $v_dir_to_check = ""; |
| 3822 | - else |
|
| 3822 | + else |
|
| 3823 | 3823 | $v_dir_to_check = dirname($p_entry['filename']); |
| 3824 | 3824 | |
| 3825 | 3825 | if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
|
| 3826 | 3826 | |
| 3827 | - // ----- Change the file status |
|
| 3828 | - $p_entry['status'] = "path_creation_fail"; |
|
| 3827 | + // ----- Change the file status |
|
| 3828 | + $p_entry['status'] = "path_creation_fail"; |
|
| 3829 | 3829 | |
| 3830 | - // ----- Return |
|
| 3831 | - //return $v_result; |
|
| 3832 | - $v_result = 1; |
|
| 3830 | + // ----- Return |
|
| 3831 | + //return $v_result; |
|
| 3832 | + $v_result = 1; |
|
| 3833 | + } |
|
| 3833 | 3834 | } |
| 3834 | - } |
|
| 3835 | 3835 | } |
| 3836 | 3836 | |
| 3837 | 3837 | // ----- Look if extraction should be done |
| 3838 | 3838 | if ($p_entry['status'] == 'ok') {
|
| 3839 | 3839 | |
| 3840 | - // ----- Do the extraction (if not a folder) |
|
| 3841 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3842 | - {
|
|
| 3840 | + // ----- Do the extraction (if not a folder) |
|
| 3841 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3842 | + {
|
|
| 3843 | 3843 | // ----- Look for not compressed file |
| 3844 | 3844 | if ($p_entry['compression'] == 0) {
|
| 3845 | 3845 | |
| 3846 | - // ----- Opening destination file |
|
| 3847 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3848 | - {
|
|
| 3846 | + // ----- Opening destination file |
|
| 3847 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3848 | + {
|
|
| 3849 | 3849 | |
| 3850 | 3850 | // ----- Change the file status |
| 3851 | 3851 | $p_entry['status'] = "write_error"; |
| 3852 | 3852 | |
| 3853 | 3853 | // ----- Return |
| 3854 | 3854 | return $v_result; |
| 3855 | - } |
|
| 3855 | + } |
|
| 3856 | 3856 | |
| 3857 | 3857 | |
| 3858 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3859 | - $v_size = $p_entry['compressed_size']; |
|
| 3860 | - while ($v_size != 0) |
|
| 3861 | - {
|
|
| 3858 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3859 | + $v_size = $p_entry['compressed_size']; |
|
| 3860 | + while ($v_size != 0) |
|
| 3861 | + {
|
|
| 3862 | 3862 | $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
| 3863 | 3863 | $v_buffer = @fread($this->zip_fd, $v_read_size); |
| 3864 | 3864 | /* Try to speed up the code |
@@ -3867,38 +3867,38 @@ discard block |
||
| 3867 | 3867 | */ |
| 3868 | 3868 | @fwrite($v_dest_file, $v_buffer, $v_read_size); |
| 3869 | 3869 | $v_size -= $v_read_size; |
| 3870 | - } |
|
| 3870 | + } |
|
| 3871 | 3871 | |
| 3872 | - // ----- Closing the destination file |
|
| 3873 | - fclose($v_dest_file); |
|
| 3872 | + // ----- Closing the destination file |
|
| 3873 | + fclose($v_dest_file); |
|
| 3874 | 3874 | |
| 3875 | - // ----- Change the file mtime |
|
| 3876 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3875 | + // ----- Change the file mtime |
|
| 3876 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3877 | 3877 | |
| 3878 | 3878 | |
| 3879 | 3879 | } |
| 3880 | 3880 | else {
|
| 3881 | - // ----- TBC |
|
| 3882 | - // Need to be finished |
|
| 3883 | - if (($p_entry['flag'] & 1) == 1) {
|
|
| 3881 | + // ----- TBC |
|
| 3882 | + // Need to be finished |
|
| 3883 | + if (($p_entry['flag'] & 1) == 1) {
|
|
| 3884 | 3884 | PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
| 3885 | 3885 | return PclZip::errorCode(); |
| 3886 | - } |
|
| 3886 | + } |
|
| 3887 | 3887 | |
| 3888 | 3888 | |
| 3889 | - // ----- Look for using temporary file to unzip |
|
| 3890 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3889 | + // ----- Look for using temporary file to unzip |
|
| 3890 | + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3891 | 3891 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 3892 | 3892 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 3893 | 3893 | && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
|
| 3894 | 3894 | $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
| 3895 | 3895 | if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
| 3896 | - return $v_result; |
|
| 3896 | + return $v_result; |
|
| 3897 | + } |
|
| 3897 | 3898 | } |
| 3898 | - } |
|
| 3899 | 3899 | |
| 3900 | - // ----- Look for extract in memory |
|
| 3901 | - else {
|
|
| 3900 | + // ----- Look for extract in memory |
|
| 3901 | + else {
|
|
| 3902 | 3902 | |
| 3903 | 3903 | |
| 3904 | 3904 | // ----- Read the compressed file in a buffer (one shot) |
@@ -3909,20 +3909,20 @@ discard block |
||
| 3909 | 3909 | unset($v_buffer); |
| 3910 | 3910 | if ($v_file_content === FALSE) {
|
| 3911 | 3911 | |
| 3912 | - // ----- Change the file status |
|
| 3913 | - // TBC |
|
| 3914 | - $p_entry['status'] = "error"; |
|
| 3912 | + // ----- Change the file status |
|
| 3913 | + // TBC |
|
| 3914 | + $p_entry['status'] = "error"; |
|
| 3915 | 3915 | |
| 3916 | - return $v_result; |
|
| 3916 | + return $v_result; |
|
| 3917 | 3917 | } |
| 3918 | 3918 | |
| 3919 | 3919 | // ----- Opening destination file |
| 3920 | 3920 | if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
|
| 3921 | 3921 | |
| 3922 | - // ----- Change the file status |
|
| 3923 | - $p_entry['status'] = "write_error"; |
|
| 3922 | + // ----- Change the file status |
|
| 3923 | + $p_entry['status'] = "write_error"; |
|
| 3924 | 3924 | |
| 3925 | - return $v_result; |
|
| 3925 | + return $v_result; |
|
| 3926 | 3926 | } |
| 3927 | 3927 | |
| 3928 | 3928 | // ----- Write the uncompressed data |
@@ -3932,67 +3932,67 @@ discard block |
||
| 3932 | 3932 | // ----- Closing the destination file |
| 3933 | 3933 | @fclose($v_dest_file); |
| 3934 | 3934 | |
| 3935 | - } |
|
| 3935 | + } |
|
| 3936 | 3936 | |
| 3937 | - // ----- Change the file mtime |
|
| 3938 | - @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3937 | + // ----- Change the file mtime |
|
| 3938 | + @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3939 | 3939 | } |
| 3940 | 3940 | |
| 3941 | 3941 | // ----- Look for chmod option |
| 3942 | 3942 | if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
|
| 3943 | 3943 | |
| 3944 | - // ----- Change the mode of the file |
|
| 3945 | - @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3944 | + // ----- Change the mode of the file |
|
| 3945 | + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3946 | 3946 | } |
| 3947 | 3947 | |
| 3948 | - } |
|
| 3948 | + } |
|
| 3949 | 3949 | } |
| 3950 | 3950 | |
| 3951 | - // ----- Change abort status |
|
| 3952 | - if ($p_entry['status'] == "aborted") {
|
|
| 3951 | + // ----- Change abort status |
|
| 3952 | + if ($p_entry['status'] == "aborted") {
|
|
| 3953 | 3953 | $p_entry['status'] = "skipped"; |
| 3954 | - } |
|
| 3954 | + } |
|
| 3955 | 3955 | |
| 3956 | 3956 | // ----- Look for post-extract callback |
| 3957 | 3957 | elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
| 3958 | 3958 | |
| 3959 | - // ----- Generate a local information |
|
| 3960 | - $v_local_header = array(); |
|
| 3961 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3959 | + // ----- Generate a local information |
|
| 3960 | + $v_local_header = array(); |
|
| 3961 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3962 | 3962 | |
| 3963 | - // ----- Call the callback |
|
| 3964 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3965 | - // header. |
|
| 3963 | + // ----- Call the callback |
|
| 3964 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3965 | + // header. |
|
| 3966 | 3966 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
| 3967 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3967 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3968 | 3968 | |
| 3969 | - // ----- Look for abort result |
|
| 3970 | - if ($v_result == 2) {
|
|
| 3971 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3972 | - } |
|
| 3969 | + // ----- Look for abort result |
|
| 3970 | + if ($v_result == 2) {
|
|
| 3971 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3972 | + } |
|
| 3973 | 3973 | } |
| 3974 | 3974 | |
| 3975 | 3975 | // ----- Return |
| 3976 | 3976 | return $v_result; |
| 3977 | - } |
|
| 3978 | - // -------------------------------------------------------------------------------- |
|
| 3979 | - |
|
| 3980 | - // -------------------------------------------------------------------------------- |
|
| 3981 | - // Function : privExtractFileUsingTempFile() |
|
| 3982 | - // Description : |
|
| 3983 | - // Parameters : |
|
| 3984 | - // Return Values : |
|
| 3985 | - // -------------------------------------------------------------------------------- |
|
| 3986 | - function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
|
| 3987 | - {
|
|
| 3977 | + } |
|
| 3978 | + // -------------------------------------------------------------------------------- |
|
| 3979 | + |
|
| 3980 | + // -------------------------------------------------------------------------------- |
|
| 3981 | + // Function : privExtractFileUsingTempFile() |
|
| 3982 | + // Description : |
|
| 3983 | + // Parameters : |
|
| 3984 | + // Return Values : |
|
| 3985 | + // -------------------------------------------------------------------------------- |
|
| 3986 | + function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
|
| 3987 | + {
|
|
| 3988 | 3988 | $v_result=1; |
| 3989 | 3989 | |
| 3990 | 3990 | // ----- Creates a temporary file |
| 3991 | 3991 | $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
|
| 3992 | 3992 | if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
|
| 3993 | - fclose($v_file); |
|
| 3994 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3995 | - return PclZip::errorCode(); |
|
| 3993 | + fclose($v_file); |
|
| 3994 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3995 | + return PclZip::errorCode(); |
|
| 3996 | 3996 | } |
| 3997 | 3997 | |
| 3998 | 3998 | |
@@ -4004,11 +4004,11 @@ discard block |
||
| 4004 | 4004 | $v_size = $p_entry['compressed_size']; |
| 4005 | 4005 | while ($v_size != 0) |
| 4006 | 4006 | {
|
| 4007 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4008 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 4009 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 4010 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4011 | - $v_size -= $v_read_size; |
|
| 4007 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4008 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 4009 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 4010 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4011 | + $v_size -= $v_read_size; |
|
| 4012 | 4012 | } |
| 4013 | 4013 | |
| 4014 | 4014 | // ----- Write gz file format footer |
@@ -4020,27 +4020,27 @@ discard block |
||
| 4020 | 4020 | |
| 4021 | 4021 | // ----- Opening destination file |
| 4022 | 4022 | if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
|
| 4023 | - $p_entry['status'] = "write_error"; |
|
| 4024 | - return $v_result; |
|
| 4023 | + $p_entry['status'] = "write_error"; |
|
| 4024 | + return $v_result; |
|
| 4025 | 4025 | } |
| 4026 | 4026 | |
| 4027 | 4027 | // ----- Open the temporary gz file |
| 4028 | 4028 | if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
|
| 4029 | - @fclose($v_dest_file); |
|
| 4030 | - $p_entry['status'] = "read_error"; |
|
| 4031 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4032 | - return PclZip::errorCode(); |
|
| 4029 | + @fclose($v_dest_file); |
|
| 4030 | + $p_entry['status'] = "read_error"; |
|
| 4031 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4032 | + return PclZip::errorCode(); |
|
| 4033 | 4033 | } |
| 4034 | 4034 | |
| 4035 | 4035 | |
| 4036 | 4036 | // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
| 4037 | 4037 | $v_size = $p_entry['size']; |
| 4038 | 4038 | while ($v_size != 0) {
|
| 4039 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4040 | - $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4041 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 4042 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4043 | - $v_size -= $v_read_size; |
|
| 4039 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4040 | + $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4041 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
|
| 4042 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4043 | + $v_size -= $v_read_size; |
|
| 4044 | 4044 | } |
| 4045 | 4045 | @fclose($v_dest_file); |
| 4046 | 4046 | @gzclose($v_src_file); |
@@ -4050,22 +4050,22 @@ discard block |
||
| 4050 | 4050 | |
| 4051 | 4051 | // ----- Return |
| 4052 | 4052 | return $v_result; |
| 4053 | - } |
|
| 4054 | - // -------------------------------------------------------------------------------- |
|
| 4055 | - |
|
| 4056 | - // -------------------------------------------------------------------------------- |
|
| 4057 | - // Function : privExtractFileInOutput() |
|
| 4058 | - // Description : |
|
| 4059 | - // Parameters : |
|
| 4060 | - // Return Values : |
|
| 4061 | - // -------------------------------------------------------------------------------- |
|
| 4062 | - function privExtractFileInOutput(&$p_entry, &$p_options) |
|
| 4063 | - {
|
|
| 4053 | + } |
|
| 4054 | + // -------------------------------------------------------------------------------- |
|
| 4055 | + |
|
| 4056 | + // -------------------------------------------------------------------------------- |
|
| 4057 | + // Function : privExtractFileInOutput() |
|
| 4058 | + // Description : |
|
| 4059 | + // Parameters : |
|
| 4060 | + // Return Values : |
|
| 4061 | + // -------------------------------------------------------------------------------- |
|
| 4062 | + function privExtractFileInOutput(&$p_entry, &$p_options) |
|
| 4063 | + {
|
|
| 4064 | 4064 | $v_result=1; |
| 4065 | 4065 | |
| 4066 | 4066 | // ----- Read the file header |
| 4067 | 4067 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
|
| 4068 | - return $v_result; |
|
| 4068 | + return $v_result; |
|
| 4069 | 4069 | } |
| 4070 | 4070 | |
| 4071 | 4071 | |
@@ -4077,31 +4077,31 @@ discard block |
||
| 4077 | 4077 | // ----- Look for pre-extract callback |
| 4078 | 4078 | if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
| 4079 | 4079 | |
| 4080 | - // ----- Generate a local information |
|
| 4081 | - $v_local_header = array(); |
|
| 4082 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4080 | + // ----- Generate a local information |
|
| 4081 | + $v_local_header = array(); |
|
| 4082 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4083 | 4083 | |
| 4084 | - // ----- Call the callback |
|
| 4085 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4086 | - // header. |
|
| 4084 | + // ----- Call the callback |
|
| 4085 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4086 | + // header. |
|
| 4087 | 4087 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
| 4088 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4089 | - if ($v_result == 0) {
|
|
| 4088 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4089 | + if ($v_result == 0) {
|
|
| 4090 | 4090 | // ----- Change the file status |
| 4091 | 4091 | $p_entry['status'] = "skipped"; |
| 4092 | 4092 | $v_result = 1; |
| 4093 | - } |
|
| 4093 | + } |
|
| 4094 | 4094 | |
| 4095 | - // ----- Look for abort result |
|
| 4096 | - if ($v_result == 2) {
|
|
| 4095 | + // ----- Look for abort result |
|
| 4096 | + if ($v_result == 2) {
|
|
| 4097 | 4097 | // ----- This status is internal and will be changed in 'skipped' |
| 4098 | 4098 | $p_entry['status'] = "aborted"; |
| 4099 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4100 | - } |
|
| 4099 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4100 | + } |
|
| 4101 | 4101 | |
| 4102 | - // ----- Update the informations |
|
| 4103 | - // Only some fields can be modified |
|
| 4104 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4102 | + // ----- Update the informations |
|
| 4103 | + // Only some fields can be modified |
|
| 4104 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4105 | 4105 | } |
| 4106 | 4106 | |
| 4107 | 4107 | // ----- Trace |
@@ -4109,78 +4109,78 @@ discard block |
||
| 4109 | 4109 | // ----- Look if extraction should be done |
| 4110 | 4110 | if ($p_entry['status'] == 'ok') {
|
| 4111 | 4111 | |
| 4112 | - // ----- Do the extraction (if not a folder) |
|
| 4113 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4112 | + // ----- Do the extraction (if not a folder) |
|
| 4113 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4114 | 4114 | // ----- Look for not compressed file |
| 4115 | 4115 | if ($p_entry['compressed_size'] == $p_entry['size']) {
|
| 4116 | 4116 | |
| 4117 | - // ----- Read the file in a buffer (one shot) |
|
| 4118 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4117 | + // ----- Read the file in a buffer (one shot) |
|
| 4118 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4119 | 4119 | |
| 4120 | - // ----- Send the file to the output |
|
| 4121 | - echo $v_buffer; |
|
| 4122 | - unset($v_buffer); |
|
| 4120 | + // ----- Send the file to the output |
|
| 4121 | + echo $v_buffer; |
|
| 4122 | + unset($v_buffer); |
|
| 4123 | 4123 | } |
| 4124 | 4124 | else {
|
| 4125 | 4125 | |
| 4126 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 4127 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4126 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 4127 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4128 | 4128 | |
| 4129 | - // ----- Decompress the file |
|
| 4130 | - $v_file_content = gzinflate($v_buffer); |
|
| 4131 | - unset($v_buffer); |
|
| 4129 | + // ----- Decompress the file |
|
| 4130 | + $v_file_content = gzinflate($v_buffer); |
|
| 4131 | + unset($v_buffer); |
|
| 4132 | 4132 | |
| 4133 | - // ----- Send the file to the output |
|
| 4134 | - echo $v_file_content; |
|
| 4135 | - unset($v_file_content); |
|
| 4133 | + // ----- Send the file to the output |
|
| 4134 | + echo $v_file_content; |
|
| 4135 | + unset($v_file_content); |
|
| 4136 | + } |
|
| 4136 | 4137 | } |
| 4137 | - } |
|
| 4138 | 4138 | } |
| 4139 | 4139 | |
| 4140 | - // ----- Change abort status |
|
| 4141 | - if ($p_entry['status'] == "aborted") {
|
|
| 4142 | - $p_entry['status'] = "skipped"; |
|
| 4143 | - } |
|
| 4140 | + // ----- Change abort status |
|
| 4141 | + if ($p_entry['status'] == "aborted") {
|
|
| 4142 | + $p_entry['status'] = "skipped"; |
|
| 4143 | + } |
|
| 4144 | 4144 | |
| 4145 | 4145 | // ----- Look for post-extract callback |
| 4146 | 4146 | elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
| 4147 | 4147 | |
| 4148 | - // ----- Generate a local information |
|
| 4149 | - $v_local_header = array(); |
|
| 4150 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4148 | + // ----- Generate a local information |
|
| 4149 | + $v_local_header = array(); |
|
| 4150 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4151 | 4151 | |
| 4152 | - // ----- Call the callback |
|
| 4153 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4154 | - // header. |
|
| 4152 | + // ----- Call the callback |
|
| 4153 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4154 | + // header. |
|
| 4155 | 4155 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
| 4156 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4156 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4157 | 4157 | |
| 4158 | - // ----- Look for abort result |
|
| 4159 | - if ($v_result == 2) {
|
|
| 4160 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4161 | - } |
|
| 4158 | + // ----- Look for abort result |
|
| 4159 | + if ($v_result == 2) {
|
|
| 4160 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4161 | + } |
|
| 4162 | 4162 | } |
| 4163 | 4163 | |
| 4164 | 4164 | return $v_result; |
| 4165 | - } |
|
| 4166 | - // -------------------------------------------------------------------------------- |
|
| 4167 | - |
|
| 4168 | - // -------------------------------------------------------------------------------- |
|
| 4169 | - // Function : privExtractFileAsString() |
|
| 4170 | - // Description : |
|
| 4171 | - // Parameters : |
|
| 4172 | - // Return Values : |
|
| 4173 | - // -------------------------------------------------------------------------------- |
|
| 4174 | - function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
|
| 4175 | - {
|
|
| 4165 | + } |
|
| 4166 | + // -------------------------------------------------------------------------------- |
|
| 4167 | + |
|
| 4168 | + // -------------------------------------------------------------------------------- |
|
| 4169 | + // Function : privExtractFileAsString() |
|
| 4170 | + // Description : |
|
| 4171 | + // Parameters : |
|
| 4172 | + // Return Values : |
|
| 4173 | + // -------------------------------------------------------------------------------- |
|
| 4174 | + function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
|
| 4175 | + {
|
|
| 4176 | 4176 | $v_result=1; |
| 4177 | 4177 | |
| 4178 | 4178 | // ----- Read the file header |
| 4179 | 4179 | $v_header = array(); |
| 4180 | 4180 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
| 4181 | 4181 | {
|
| 4182 | - // ----- Return |
|
| 4183 | - return $v_result; |
|
| 4182 | + // ----- Return |
|
| 4183 | + return $v_result; |
|
| 4184 | 4184 | } |
| 4185 | 4185 | |
| 4186 | 4186 | |
@@ -4192,110 +4192,110 @@ discard block |
||
| 4192 | 4192 | // ----- Look for pre-extract callback |
| 4193 | 4193 | if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
| 4194 | 4194 | |
| 4195 | - // ----- Generate a local information |
|
| 4196 | - $v_local_header = array(); |
|
| 4197 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4195 | + // ----- Generate a local information |
|
| 4196 | + $v_local_header = array(); |
|
| 4197 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4198 | 4198 | |
| 4199 | - // ----- Call the callback |
|
| 4200 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4201 | - // header. |
|
| 4199 | + // ----- Call the callback |
|
| 4200 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4201 | + // header. |
|
| 4202 | 4202 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
| 4203 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4204 | - if ($v_result == 0) {
|
|
| 4203 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4204 | + if ($v_result == 0) {
|
|
| 4205 | 4205 | // ----- Change the file status |
| 4206 | 4206 | $p_entry['status'] = "skipped"; |
| 4207 | 4207 | $v_result = 1; |
| 4208 | - } |
|
| 4208 | + } |
|
| 4209 | 4209 | |
| 4210 | - // ----- Look for abort result |
|
| 4211 | - if ($v_result == 2) {
|
|
| 4210 | + // ----- Look for abort result |
|
| 4211 | + if ($v_result == 2) {
|
|
| 4212 | 4212 | // ----- This status is internal and will be changed in 'skipped' |
| 4213 | 4213 | $p_entry['status'] = "aborted"; |
| 4214 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4215 | - } |
|
| 4214 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4215 | + } |
|
| 4216 | 4216 | |
| 4217 | - // ----- Update the informations |
|
| 4218 | - // Only some fields can be modified |
|
| 4219 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4217 | + // ----- Update the informations |
|
| 4218 | + // Only some fields can be modified |
|
| 4219 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4220 | 4220 | } |
| 4221 | 4221 | |
| 4222 | 4222 | |
| 4223 | 4223 | // ----- Look if extraction should be done |
| 4224 | 4224 | if ($p_entry['status'] == 'ok') {
|
| 4225 | 4225 | |
| 4226 | - // ----- Do the extraction (if not a folder) |
|
| 4227 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4226 | + // ----- Do the extraction (if not a folder) |
|
| 4227 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
|
| 4228 | 4228 | // ----- Look for not compressed file |
| 4229 | - // if ($p_entry['compressed_size'] == $p_entry['size']) |
|
| 4229 | + // if ($p_entry['compressed_size'] == $p_entry['size']) |
|
| 4230 | 4230 | if ($p_entry['compression'] == 0) {
|
| 4231 | 4231 | |
| 4232 | - // ----- Reading the file |
|
| 4233 | - $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4232 | + // ----- Reading the file |
|
| 4233 | + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4234 | 4234 | } |
| 4235 | 4235 | else {
|
| 4236 | 4236 | |
| 4237 | - // ----- Reading the file |
|
| 4238 | - $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4237 | + // ----- Reading the file |
|
| 4238 | + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4239 | 4239 | |
| 4240 | - // ----- Decompress the file |
|
| 4241 | - if (($p_string = @gzinflate($v_data)) === FALSE) {
|
|
| 4242 | - // TBC |
|
| 4243 | - } |
|
| 4240 | + // ----- Decompress the file |
|
| 4241 | + if (($p_string = @gzinflate($v_data)) === FALSE) {
|
|
| 4242 | + // TBC |
|
| 4243 | + } |
|
| 4244 | 4244 | } |
| 4245 | 4245 | |
| 4246 | 4246 | // ----- Trace |
| 4247 | - } |
|
| 4248 | - else {
|
|
| 4249 | - // TBC : error : can not extract a folder in a string |
|
| 4250 | - } |
|
| 4247 | + } |
|
| 4248 | + else {
|
|
| 4249 | + // TBC : error : can not extract a folder in a string |
|
| 4250 | + } |
|
| 4251 | 4251 | |
| 4252 | 4252 | } |
| 4253 | 4253 | |
| 4254 | - // ----- Change abort status |
|
| 4255 | - if ($p_entry['status'] == "aborted") {
|
|
| 4254 | + // ----- Change abort status |
|
| 4255 | + if ($p_entry['status'] == "aborted") {
|
|
| 4256 | 4256 | $p_entry['status'] = "skipped"; |
| 4257 | - } |
|
| 4257 | + } |
|
| 4258 | 4258 | |
| 4259 | 4259 | // ----- Look for post-extract callback |
| 4260 | 4260 | elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
| 4261 | 4261 | |
| 4262 | - // ----- Generate a local information |
|
| 4263 | - $v_local_header = array(); |
|
| 4264 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4262 | + // ----- Generate a local information |
|
| 4263 | + $v_local_header = array(); |
|
| 4264 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4265 | 4265 | |
| 4266 | - // ----- Swap the content to header |
|
| 4267 | - $v_local_header['content'] = $p_string; |
|
| 4268 | - $p_string = ''; |
|
| 4266 | + // ----- Swap the content to header |
|
| 4267 | + $v_local_header['content'] = $p_string; |
|
| 4268 | + $p_string = ''; |
|
| 4269 | 4269 | |
| 4270 | - // ----- Call the callback |
|
| 4271 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4272 | - // header. |
|
| 4270 | + // ----- Call the callback |
|
| 4271 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4272 | + // header. |
|
| 4273 | 4273 | // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
| 4274 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4274 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4275 | 4275 | |
| 4276 | - // ----- Swap back the content to header |
|
| 4277 | - $p_string = $v_local_header['content']; |
|
| 4278 | - unset($v_local_header['content']); |
|
| 4276 | + // ----- Swap back the content to header |
|
| 4277 | + $p_string = $v_local_header['content']; |
|
| 4278 | + unset($v_local_header['content']); |
|
| 4279 | 4279 | |
| 4280 | - // ----- Look for abort result |
|
| 4281 | - if ($v_result == 2) {
|
|
| 4282 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4283 | - } |
|
| 4280 | + // ----- Look for abort result |
|
| 4281 | + if ($v_result == 2) {
|
|
| 4282 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4283 | + } |
|
| 4284 | 4284 | } |
| 4285 | 4285 | |
| 4286 | 4286 | // ----- Return |
| 4287 | 4287 | return $v_result; |
| 4288 | - } |
|
| 4289 | - // -------------------------------------------------------------------------------- |
|
| 4290 | - |
|
| 4291 | - // -------------------------------------------------------------------------------- |
|
| 4292 | - // Function : privReadFileHeader() |
|
| 4293 | - // Description : |
|
| 4294 | - // Parameters : |
|
| 4295 | - // Return Values : |
|
| 4296 | - // -------------------------------------------------------------------------------- |
|
| 4297 | - function privReadFileHeader(&$p_header) |
|
| 4298 | - {
|
|
| 4288 | + } |
|
| 4289 | + // -------------------------------------------------------------------------------- |
|
| 4290 | + |
|
| 4291 | + // -------------------------------------------------------------------------------- |
|
| 4292 | + // Function : privReadFileHeader() |
|
| 4293 | + // Description : |
|
| 4294 | + // Parameters : |
|
| 4295 | + // Return Values : |
|
| 4296 | + // -------------------------------------------------------------------------------- |
|
| 4297 | + function privReadFileHeader(&$p_header) |
|
| 4298 | + {
|
|
| 4299 | 4299 | $v_result=1; |
| 4300 | 4300 | |
| 4301 | 4301 | // ----- Read the 4 bytes signature |
@@ -4306,11 +4306,11 @@ discard block |
||
| 4306 | 4306 | if ($v_data['id'] != 0x04034b50) |
| 4307 | 4307 | {
|
| 4308 | 4308 | |
| 4309 | - // ----- Error log |
|
| 4310 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4309 | + // ----- Error log |
|
| 4310 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4311 | 4311 | |
| 4312 | - // ----- Return |
|
| 4313 | - return PclZip::errorCode(); |
|
| 4312 | + // ----- Return |
|
| 4313 | + return PclZip::errorCode(); |
|
| 4314 | 4314 | } |
| 4315 | 4315 | |
| 4316 | 4316 | // ----- Read the first 42 bytes of the header |
@@ -4319,14 +4319,14 @@ discard block |
||
| 4319 | 4319 | // ----- Look for invalid block size |
| 4320 | 4320 | if (strlen($v_binary_data) != 26) |
| 4321 | 4321 | {
|
| 4322 | - $p_header['filename'] = ""; |
|
| 4323 | - $p_header['status'] = "invalid_header"; |
|
| 4322 | + $p_header['filename'] = ""; |
|
| 4323 | + $p_header['status'] = "invalid_header"; |
|
| 4324 | 4324 | |
| 4325 | - // ----- Error log |
|
| 4326 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4325 | + // ----- Error log |
|
| 4326 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4327 | 4327 | |
| 4328 | - // ----- Return |
|
| 4329 | - return PclZip::errorCode(); |
|
| 4328 | + // ----- Return |
|
| 4329 | + return PclZip::errorCode(); |
|
| 4330 | 4330 | } |
| 4331 | 4331 | |
| 4332 | 4332 | // ----- Extract the values |
@@ -4337,10 +4337,10 @@ discard block |
||
| 4337 | 4337 | |
| 4338 | 4338 | // ----- Get extra_fields |
| 4339 | 4339 | if ($v_data['extra_len'] != 0) {
|
| 4340 | - $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4340 | + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4341 | 4341 | } |
| 4342 | 4342 | else {
|
| 4343 | - $p_header['extra'] = ''; |
|
| 4343 | + $p_header['extra'] = ''; |
|
| 4344 | 4344 | } |
| 4345 | 4345 | |
| 4346 | 4346 | // ----- Extract properties |
@@ -4357,23 +4357,23 @@ discard block |
||
| 4357 | 4357 | $p_header['mtime'] = $v_data['mtime']; |
| 4358 | 4358 | if ($p_header['mdate'] && $p_header['mtime']) |
| 4359 | 4359 | {
|
| 4360 | - // ----- Extract time |
|
| 4361 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4362 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4363 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4360 | + // ----- Extract time |
|
| 4361 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4362 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4363 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4364 | 4364 | |
| 4365 | - // ----- Extract date |
|
| 4366 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4367 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4368 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4365 | + // ----- Extract date |
|
| 4366 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4367 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4368 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4369 | 4369 | |
| 4370 | - // ----- Get UNIX date format |
|
| 4371 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4370 | + // ----- Get UNIX date format |
|
| 4371 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4372 | 4372 | |
| 4373 | 4373 | } |
| 4374 | 4374 | else |
| 4375 | 4375 | {
|
| 4376 | - $p_header['mtime'] = time(); |
|
| 4376 | + $p_header['mtime'] = time(); |
|
| 4377 | 4377 | } |
| 4378 | 4378 | |
| 4379 | 4379 | // TBC |
@@ -4388,17 +4388,17 @@ discard block |
||
| 4388 | 4388 | |
| 4389 | 4389 | // ----- Return |
| 4390 | 4390 | return $v_result; |
| 4391 | - } |
|
| 4392 | - // -------------------------------------------------------------------------------- |
|
| 4393 | - |
|
| 4394 | - // -------------------------------------------------------------------------------- |
|
| 4395 | - // Function : privReadCentralFileHeader() |
|
| 4396 | - // Description : |
|
| 4397 | - // Parameters : |
|
| 4398 | - // Return Values : |
|
| 4399 | - // -------------------------------------------------------------------------------- |
|
| 4400 | - function privReadCentralFileHeader(&$p_header) |
|
| 4401 | - {
|
|
| 4391 | + } |
|
| 4392 | + // -------------------------------------------------------------------------------- |
|
| 4393 | + |
|
| 4394 | + // -------------------------------------------------------------------------------- |
|
| 4395 | + // Function : privReadCentralFileHeader() |
|
| 4396 | + // Description : |
|
| 4397 | + // Parameters : |
|
| 4398 | + // Return Values : |
|
| 4399 | + // -------------------------------------------------------------------------------- |
|
| 4400 | + function privReadCentralFileHeader(&$p_header) |
|
| 4401 | + {
|
|
| 4402 | 4402 | $v_result=1; |
| 4403 | 4403 | |
| 4404 | 4404 | // ----- Read the 4 bytes signature |
@@ -4409,11 +4409,11 @@ discard block |
||
| 4409 | 4409 | if ($v_data['id'] != 0x02014b50) |
| 4410 | 4410 | {
|
| 4411 | 4411 | |
| 4412 | - // ----- Error log |
|
| 4413 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4412 | + // ----- Error log |
|
| 4413 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4414 | 4414 | |
| 4415 | - // ----- Return |
|
| 4416 | - return PclZip::errorCode(); |
|
| 4415 | + // ----- Return |
|
| 4416 | + return PclZip::errorCode(); |
|
| 4417 | 4417 | } |
| 4418 | 4418 | |
| 4419 | 4419 | // ----- Read the first 42 bytes of the header |
@@ -4422,14 +4422,14 @@ discard block |
||
| 4422 | 4422 | // ----- Look for invalid block size |
| 4423 | 4423 | if (strlen($v_binary_data) != 42) |
| 4424 | 4424 | {
|
| 4425 | - $p_header['filename'] = ""; |
|
| 4426 | - $p_header['status'] = "invalid_header"; |
|
| 4425 | + $p_header['filename'] = ""; |
|
| 4426 | + $p_header['status'] = "invalid_header"; |
|
| 4427 | 4427 | |
| 4428 | - // ----- Error log |
|
| 4429 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4428 | + // ----- Error log |
|
| 4429 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4430 | 4430 | |
| 4431 | - // ----- Return |
|
| 4432 | - return PclZip::errorCode(); |
|
| 4431 | + // ----- Return |
|
| 4432 | + return PclZip::errorCode(); |
|
| 4433 | 4433 | } |
| 4434 | 4434 | |
| 4435 | 4435 | // ----- Extract the values |
@@ -4437,28 +4437,28 @@ discard block |
||
| 4437 | 4437 | |
| 4438 | 4438 | // ----- Get filename |
| 4439 | 4439 | if ($p_header['filename_len'] != 0) |
| 4440 | - // |
|
| 4441 | - // -------------------------------------------------------------------------------- |
|
| 4442 | - // A patch about stored filenames with backslash directory separator (Windows style). |
|
| 4443 | - // Archives created by the utility IZArc 3.81 (possibly new versions too) need this patch. |
|
| 4444 | - //$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4445 | - $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len']));
|
|
| 4446 | - // -------------------------------------------------------------------------------- |
|
| 4447 | - // |
|
| 4440 | + // |
|
| 4441 | + // -------------------------------------------------------------------------------- |
|
| 4442 | + // A patch about stored filenames with backslash directory separator (Windows style). |
|
| 4443 | + // Archives created by the utility IZArc 3.81 (possibly new versions too) need this patch. |
|
| 4444 | + //$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4445 | + $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len']));
|
|
| 4446 | + // -------------------------------------------------------------------------------- |
|
| 4447 | + // |
|
| 4448 | 4448 | else |
| 4449 | - $p_header['filename'] = ''; |
|
| 4449 | + $p_header['filename'] = ''; |
|
| 4450 | 4450 | |
| 4451 | 4451 | // ----- Get extra |
| 4452 | 4452 | if ($p_header['extra_len'] != 0) |
| 4453 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4453 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4454 | 4454 | else |
| 4455 | - $p_header['extra'] = ''; |
|
| 4455 | + $p_header['extra'] = ''; |
|
| 4456 | 4456 | |
| 4457 | 4457 | // ----- Get comment |
| 4458 | 4458 | if ($p_header['comment_len'] != 0) |
| 4459 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4459 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4460 | 4460 | else |
| 4461 | - $p_header['comment'] = ''; |
|
| 4461 | + $p_header['comment'] = ''; |
|
| 4462 | 4462 | |
| 4463 | 4463 | // ----- Extract properties |
| 4464 | 4464 | |
@@ -4467,23 +4467,23 @@ discard block |
||
| 4467 | 4467 | // TBC : bug : this was ignoring time with 0/0/0 |
| 4468 | 4468 | if (1) |
| 4469 | 4469 | {
|
| 4470 | - // ----- Extract time |
|
| 4471 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4472 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4473 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4470 | + // ----- Extract time |
|
| 4471 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4472 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4473 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4474 | 4474 | |
| 4475 | - // ----- Extract date |
|
| 4476 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4477 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4478 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4475 | + // ----- Extract date |
|
| 4476 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4477 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4478 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4479 | 4479 | |
| 4480 | - // ----- Get UNIX date format |
|
| 4481 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4480 | + // ----- Get UNIX date format |
|
| 4481 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4482 | 4482 | |
| 4483 | 4483 | } |
| 4484 | 4484 | else |
| 4485 | 4485 | {
|
| 4486 | - $p_header['mtime'] = time(); |
|
| 4486 | + $p_header['mtime'] = time(); |
|
| 4487 | 4487 | } |
| 4488 | 4488 | |
| 4489 | 4489 | // ----- Set the stored filename |
@@ -4494,63 +4494,63 @@ discard block |
||
| 4494 | 4494 | |
| 4495 | 4495 | // ----- Look if it is a directory |
| 4496 | 4496 | if (substr($p_header['filename'], -1) == '/') {
|
| 4497 | - //$p_header['external'] = 0x41FF0010; |
|
| 4498 | - $p_header['external'] = 0x00000010; |
|
| 4497 | + //$p_header['external'] = 0x41FF0010; |
|
| 4498 | + $p_header['external'] = 0x00000010; |
|
| 4499 | 4499 | } |
| 4500 | 4500 | |
| 4501 | 4501 | |
| 4502 | 4502 | // ----- Return |
| 4503 | 4503 | return $v_result; |
| 4504 | - } |
|
| 4505 | - // -------------------------------------------------------------------------------- |
|
| 4506 | - |
|
| 4507 | - // -------------------------------------------------------------------------------- |
|
| 4508 | - // Function : privCheckFileHeaders() |
|
| 4509 | - // Description : |
|
| 4510 | - // Parameters : |
|
| 4511 | - // Return Values : |
|
| 4512 | - // 1 on success, |
|
| 4513 | - // 0 on error; |
|
| 4514 | - // -------------------------------------------------------------------------------- |
|
| 4515 | - function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
|
| 4516 | - {
|
|
| 4504 | + } |
|
| 4505 | + // -------------------------------------------------------------------------------- |
|
| 4506 | + |
|
| 4507 | + // -------------------------------------------------------------------------------- |
|
| 4508 | + // Function : privCheckFileHeaders() |
|
| 4509 | + // Description : |
|
| 4510 | + // Parameters : |
|
| 4511 | + // Return Values : |
|
| 4512 | + // 1 on success, |
|
| 4513 | + // 0 on error; |
|
| 4514 | + // -------------------------------------------------------------------------------- |
|
| 4515 | + function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
|
| 4516 | + {
|
|
| 4517 | 4517 | $v_result=1; |
| 4518 | 4518 | |
| 4519 | - // ----- Check the static values |
|
| 4520 | - // TBC |
|
| 4521 | - if ($p_local_header['filename'] != $p_central_header['filename']) {
|
|
| 4522 | - } |
|
| 4523 | - if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
|
|
| 4524 | - } |
|
| 4525 | - if ($p_local_header['flag'] != $p_central_header['flag']) {
|
|
| 4526 | - } |
|
| 4527 | - if ($p_local_header['compression'] != $p_central_header['compression']) {
|
|
| 4528 | - } |
|
| 4529 | - if ($p_local_header['mtime'] != $p_central_header['mtime']) {
|
|
| 4530 | - } |
|
| 4531 | - if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
|
|
| 4532 | - } |
|
| 4533 | - |
|
| 4534 | - // ----- Look for flag bit 3 |
|
| 4535 | - if (($p_local_header['flag'] & 8) == 8) {
|
|
| 4536 | - $p_local_header['size'] = $p_central_header['size']; |
|
| 4537 | - $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4538 | - $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4539 | - } |
|
| 4519 | + // ----- Check the static values |
|
| 4520 | + // TBC |
|
| 4521 | + if ($p_local_header['filename'] != $p_central_header['filename']) {
|
|
| 4522 | + } |
|
| 4523 | + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
|
|
| 4524 | + } |
|
| 4525 | + if ($p_local_header['flag'] != $p_central_header['flag']) {
|
|
| 4526 | + } |
|
| 4527 | + if ($p_local_header['compression'] != $p_central_header['compression']) {
|
|
| 4528 | + } |
|
| 4529 | + if ($p_local_header['mtime'] != $p_central_header['mtime']) {
|
|
| 4530 | + } |
|
| 4531 | + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
|
|
| 4532 | + } |
|
| 4533 | + |
|
| 4534 | + // ----- Look for flag bit 3 |
|
| 4535 | + if (($p_local_header['flag'] & 8) == 8) {
|
|
| 4536 | + $p_local_header['size'] = $p_central_header['size']; |
|
| 4537 | + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4538 | + $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4539 | + } |
|
| 4540 | 4540 | |
| 4541 | 4541 | // ----- Return |
| 4542 | 4542 | return $v_result; |
| 4543 | - } |
|
| 4544 | - // -------------------------------------------------------------------------------- |
|
| 4545 | - |
|
| 4546 | - // -------------------------------------------------------------------------------- |
|
| 4547 | - // Function : privReadEndCentralDir() |
|
| 4548 | - // Description : |
|
| 4549 | - // Parameters : |
|
| 4550 | - // Return Values : |
|
| 4551 | - // -------------------------------------------------------------------------------- |
|
| 4552 | - function privReadEndCentralDir(&$p_central_dir) |
|
| 4553 | - {
|
|
| 4543 | + } |
|
| 4544 | + // -------------------------------------------------------------------------------- |
|
| 4545 | + |
|
| 4546 | + // -------------------------------------------------------------------------------- |
|
| 4547 | + // Function : privReadEndCentralDir() |
|
| 4548 | + // Description : |
|
| 4549 | + // Parameters : |
|
| 4550 | + // Return Values : |
|
| 4551 | + // -------------------------------------------------------------------------------- |
|
| 4552 | + function privReadEndCentralDir(&$p_central_dir) |
|
| 4553 | + {
|
|
| 4554 | 4554 | $v_result=1; |
| 4555 | 4555 | |
| 4556 | 4556 | // ----- Go to the end of the zip file |
@@ -4558,59 +4558,59 @@ discard block |
||
| 4558 | 4558 | @fseek($this->zip_fd, $v_size); |
| 4559 | 4559 | if (@ftell($this->zip_fd) != $v_size) |
| 4560 | 4560 | {
|
| 4561 | - // ----- Error log |
|
| 4562 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4561 | + // ----- Error log |
|
| 4562 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4563 | 4563 | |
| 4564 | - // ----- Return |
|
| 4565 | - return PclZip::errorCode(); |
|
| 4564 | + // ----- Return |
|
| 4565 | + return PclZip::errorCode(); |
|
| 4566 | 4566 | } |
| 4567 | 4567 | |
| 4568 | 4568 | // ----- First try : look if this is an archive with no commentaries (most of the time) |
| 4569 | 4569 | // in this case the end of central dir is at 22 bytes of the file end |
| 4570 | 4570 | $v_found = 0; |
| 4571 | 4571 | if ($v_size > 26) {
|
| 4572 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4573 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4574 | - {
|
|
| 4572 | + @fseek($this->zip_fd, $v_size-22); |
|
| 4573 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4574 | + {
|
|
| 4575 | 4575 | // ----- Error log |
| 4576 | 4576 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
| 4577 | 4577 | |
| 4578 | 4578 | // ----- Return |
| 4579 | 4579 | return PclZip::errorCode(); |
| 4580 | - } |
|
| 4580 | + } |
|
| 4581 | 4581 | |
| 4582 | - // ----- Read for bytes |
|
| 4583 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4584 | - $v_data = @unpack('Vid', $v_binary_data);
|
|
| 4582 | + // ----- Read for bytes |
|
| 4583 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4584 | + $v_data = @unpack('Vid', $v_binary_data);
|
|
| 4585 | 4585 | |
| 4586 | - // ----- Check signature |
|
| 4587 | - if ($v_data['id'] == 0x06054b50) {
|
|
| 4586 | + // ----- Check signature |
|
| 4587 | + if ($v_data['id'] == 0x06054b50) {
|
|
| 4588 | 4588 | $v_found = 1; |
| 4589 | - } |
|
| 4589 | + } |
|
| 4590 | 4590 | |
| 4591 | - $v_pos = ftell($this->zip_fd); |
|
| 4591 | + $v_pos = ftell($this->zip_fd); |
|
| 4592 | 4592 | } |
| 4593 | 4593 | |
| 4594 | 4594 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 4595 | 4595 | if (!$v_found) {
|
| 4596 | - $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4597 | - if ($v_maximum_size > $v_size) |
|
| 4596 | + $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4597 | + if ($v_maximum_size > $v_size) |
|
| 4598 | 4598 | $v_maximum_size = $v_size; |
| 4599 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4600 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4601 | - {
|
|
| 4599 | + @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4600 | + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4601 | + {
|
|
| 4602 | 4602 | // ----- Error log |
| 4603 | 4603 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
| 4604 | 4604 | |
| 4605 | 4605 | // ----- Return |
| 4606 | 4606 | return PclZip::errorCode(); |
| 4607 | - } |
|
| 4607 | + } |
|
| 4608 | 4608 | |
| 4609 | - // ----- Read byte per byte in order to find the signature |
|
| 4610 | - $v_pos = ftell($this->zip_fd); |
|
| 4611 | - $v_bytes = 0x00000000; |
|
| 4612 | - while ($v_pos < $v_size) |
|
| 4613 | - {
|
|
| 4609 | + // ----- Read byte per byte in order to find the signature |
|
| 4610 | + $v_pos = ftell($this->zip_fd); |
|
| 4611 | + $v_bytes = 0x00000000; |
|
| 4612 | + while ($v_pos < $v_size) |
|
| 4613 | + {
|
|
| 4614 | 4614 | // ----- Read a byte |
| 4615 | 4615 | $v_byte = @fread($this->zip_fd, 1); |
| 4616 | 4616 | |
@@ -4623,23 +4623,23 @@ discard block |
||
| 4623 | 4623 | // ----- Compare the bytes |
| 4624 | 4624 | if ($v_bytes == 0x504b0506) |
| 4625 | 4625 | {
|
| 4626 | - $v_pos++; |
|
| 4627 | - break; |
|
| 4626 | + $v_pos++; |
|
| 4627 | + break; |
|
| 4628 | 4628 | } |
| 4629 | 4629 | |
| 4630 | 4630 | $v_pos++; |
| 4631 | - } |
|
| 4631 | + } |
|
| 4632 | 4632 | |
| 4633 | - // ----- Look if not found end of central dir |
|
| 4634 | - if ($v_pos == $v_size) |
|
| 4635 | - {
|
|
| 4633 | + // ----- Look if not found end of central dir |
|
| 4634 | + if ($v_pos == $v_size) |
|
| 4635 | + {
|
|
| 4636 | 4636 | |
| 4637 | 4637 | // ----- Error log |
| 4638 | 4638 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); |
| 4639 | 4639 | |
| 4640 | 4640 | // ----- Return |
| 4641 | 4641 | return PclZip::errorCode(); |
| 4642 | - } |
|
| 4642 | + } |
|
| 4643 | 4643 | } |
| 4644 | 4644 | |
| 4645 | 4645 | // ----- Read the first 18 bytes of the header |
@@ -4649,11 +4649,11 @@ discard block |
||
| 4649 | 4649 | if (strlen($v_binary_data) != 18) |
| 4650 | 4650 | {
|
| 4651 | 4651 | |
| 4652 | - // ----- Error log |
|
| 4653 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4652 | + // ----- Error log |
|
| 4653 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4654 | 4654 | |
| 4655 | - // ----- Return |
|
| 4656 | - return PclZip::errorCode(); |
|
| 4655 | + // ----- Return |
|
| 4656 | + return PclZip::errorCode(); |
|
| 4657 | 4657 | } |
| 4658 | 4658 | |
| 4659 | 4659 | // ----- Extract the values |
@@ -4662,27 +4662,27 @@ discard block |
||
| 4662 | 4662 | // ----- Check the global size |
| 4663 | 4663 | if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
|
| 4664 | 4664 | |
| 4665 | - // ----- Removed in release 2.2 see readme file |
|
| 4666 | - // The check of the file size is a little too strict. |
|
| 4667 | - // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. |
|
| 4668 | - // While decrypted, zip has training 0 bytes |
|
| 4669 | - if (0) {
|
|
| 4670 | - // ----- Error log |
|
| 4671 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4672 | - 'The central dir is not at the end of the archive.' |
|
| 4673 | - .' Some trailing bytes exists after the archive.'); |
|
| 4665 | + // ----- Removed in release 2.2 see readme file |
|
| 4666 | + // The check of the file size is a little too strict. |
|
| 4667 | + // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. |
|
| 4668 | + // While decrypted, zip has training 0 bytes |
|
| 4669 | + if (0) {
|
|
| 4670 | + // ----- Error log |
|
| 4671 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4672 | + 'The central dir is not at the end of the archive.' |
|
| 4673 | + .' Some trailing bytes exists after the archive.'); |
|
| 4674 | 4674 | |
| 4675 | - // ----- Return |
|
| 4676 | - return PclZip::errorCode(); |
|
| 4677 | - } |
|
| 4675 | + // ----- Return |
|
| 4676 | + return PclZip::errorCode(); |
|
| 4677 | + } |
|
| 4678 | 4678 | } |
| 4679 | 4679 | |
| 4680 | 4680 | // ----- Get comment |
| 4681 | 4681 | if ($v_data['comment_size'] != 0) {
|
| 4682 | - $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4682 | + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4683 | 4683 | } |
| 4684 | 4684 | else |
| 4685 | - $p_central_dir['comment'] = ''; |
|
| 4685 | + $p_central_dir['comment'] = ''; |
|
| 4686 | 4686 | |
| 4687 | 4687 | $p_central_dir['entries'] = $v_data['entries']; |
| 4688 | 4688 | $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
@@ -4697,33 +4697,33 @@ discard block |
||
| 4697 | 4697 | |
| 4698 | 4698 | // ----- Return |
| 4699 | 4699 | return $v_result; |
| 4700 | - } |
|
| 4701 | - // -------------------------------------------------------------------------------- |
|
| 4702 | - |
|
| 4703 | - // -------------------------------------------------------------------------------- |
|
| 4704 | - // Function : privDeleteByRule() |
|
| 4705 | - // Description : |
|
| 4706 | - // Parameters : |
|
| 4707 | - // Return Values : |
|
| 4708 | - // -------------------------------------------------------------------------------- |
|
| 4709 | - function privDeleteByRule(&$p_result_list, &$p_options) |
|
| 4710 | - {
|
|
| 4700 | + } |
|
| 4701 | + // -------------------------------------------------------------------------------- |
|
| 4702 | + |
|
| 4703 | + // -------------------------------------------------------------------------------- |
|
| 4704 | + // Function : privDeleteByRule() |
|
| 4705 | + // Description : |
|
| 4706 | + // Parameters : |
|
| 4707 | + // Return Values : |
|
| 4708 | + // -------------------------------------------------------------------------------- |
|
| 4709 | + function privDeleteByRule(&$p_result_list, &$p_options) |
|
| 4710 | + {
|
|
| 4711 | 4711 | $v_result=1; |
| 4712 | 4712 | $v_list_detail = array(); |
| 4713 | 4713 | |
| 4714 | 4714 | // ----- Open the zip file |
| 4715 | 4715 | if (($v_result=$this->privOpenFd('rb')) != 1)
|
| 4716 | 4716 | {
|
| 4717 | - // ----- Return |
|
| 4718 | - return $v_result; |
|
| 4717 | + // ----- Return |
|
| 4718 | + return $v_result; |
|
| 4719 | 4719 | } |
| 4720 | 4720 | |
| 4721 | 4721 | // ----- Read the central directory informations |
| 4722 | 4722 | $v_central_dir = array(); |
| 4723 | 4723 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 4724 | 4724 | {
|
| 4725 | - $this->privCloseFd(); |
|
| 4726 | - return $v_result; |
|
| 4725 | + $this->privCloseFd(); |
|
| 4726 | + return $v_result; |
|
| 4727 | 4727 | } |
| 4728 | 4728 | |
| 4729 | 4729 | // ----- Go to beginning of File |
@@ -4735,14 +4735,14 @@ discard block |
||
| 4735 | 4735 | @rewind($this->zip_fd); |
| 4736 | 4736 | if (@fseek($this->zip_fd, $v_pos_entry)) |
| 4737 | 4737 | {
|
| 4738 | - // ----- Close the zip file |
|
| 4739 | - $this->privCloseFd(); |
|
| 4738 | + // ----- Close the zip file |
|
| 4739 | + $this->privCloseFd(); |
|
| 4740 | 4740 | |
| 4741 | - // ----- Error log |
|
| 4742 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4741 | + // ----- Error log |
|
| 4742 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4743 | 4743 | |
| 4744 | - // ----- Return |
|
| 4745 | - return PclZip::errorCode(); |
|
| 4744 | + // ----- Return |
|
| 4745 | + return PclZip::errorCode(); |
|
| 4746 | 4746 | } |
| 4747 | 4747 | |
| 4748 | 4748 | // ----- Read each entry |
@@ -4751,53 +4751,53 @@ discard block |
||
| 4751 | 4751 | for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
| 4752 | 4752 | {
|
| 4753 | 4753 | |
| 4754 | - // ----- Read the file header |
|
| 4755 | - $v_header_list[$v_nb_extracted] = array(); |
|
| 4756 | - if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4757 | - {
|
|
| 4754 | + // ----- Read the file header |
|
| 4755 | + $v_header_list[$v_nb_extracted] = array(); |
|
| 4756 | + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4757 | + {
|
|
| 4758 | 4758 | // ----- Close the zip file |
| 4759 | 4759 | $this->privCloseFd(); |
| 4760 | 4760 | |
| 4761 | 4761 | return $v_result; |
| 4762 | - } |
|
| 4762 | + } |
|
| 4763 | 4763 | |
| 4764 | 4764 | |
| 4765 | - // ----- Store the index |
|
| 4766 | - $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4765 | + // ----- Store the index |
|
| 4766 | + $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4767 | 4767 | |
| 4768 | - // ----- Look for the specific extract rules |
|
| 4769 | - $v_found = false; |
|
| 4768 | + // ----- Look for the specific extract rules |
|
| 4769 | + $v_found = false; |
|
| 4770 | 4770 | |
| 4771 | - // ----- Look for extract by name rule |
|
| 4772 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4771 | + // ----- Look for extract by name rule |
|
| 4772 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4773 | 4773 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
| 4774 | 4774 | |
| 4775 | - // ----- Look if the filename is in the list |
|
| 4776 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
|
|
| 4775 | + // ----- Look if the filename is in the list |
|
| 4776 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
|
|
| 4777 | 4777 | |
| 4778 | - // ----- Look for a directory |
|
| 4779 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
|
| 4778 | + // ----- Look for a directory |
|
| 4779 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
|
| 4780 | 4780 | |
| 4781 | - // ----- Look if the directory is in the filename path |
|
| 4782 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4781 | + // ----- Look if the directory is in the filename path |
|
| 4782 | + if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4783 | 4783 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4784 | - $v_found = true; |
|
| 4785 | - } |
|
| 4786 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4784 | + $v_found = true; |
|
| 4785 | + } |
|
| 4786 | + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4787 | 4787 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
| 4788 | - $v_found = true; |
|
| 4789 | - } |
|
| 4790 | - } |
|
| 4791 | - // ----- Look for a filename |
|
| 4792 | - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
|
| 4793 | - $v_found = true; |
|
| 4794 | - } |
|
| 4795 | - } |
|
| 4796 | - } |
|
| 4788 | + $v_found = true; |
|
| 4789 | + } |
|
| 4790 | + } |
|
| 4791 | + // ----- Look for a filename |
|
| 4792 | + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
|
| 4793 | + $v_found = true; |
|
| 4794 | + } |
|
| 4795 | + } |
|
| 4796 | + } |
|
| 4797 | 4797 | |
| 4798 | - // ----- Look for extract by ereg rule |
|
| 4799 | - // ereg() is deprecated with PHP 5.3 |
|
| 4800 | - /* |
|
| 4798 | + // ----- Look for extract by ereg rule |
|
| 4799 | + // ereg() is deprecated with PHP 5.3 |
|
| 4800 | + /* |
|
| 4801 | 4801 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 4802 | 4802 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
|
| 4803 | 4803 | |
@@ -4807,47 +4807,47 @@ discard block |
||
| 4807 | 4807 | } |
| 4808 | 4808 | */ |
| 4809 | 4809 | |
| 4810 | - // ----- Look for extract by preg rule |
|
| 4811 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4810 | + // ----- Look for extract by preg rule |
|
| 4811 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4812 | 4812 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
| 4813 | 4813 | |
| 4814 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
|
| 4815 | - $v_found = true; |
|
| 4816 | - } |
|
| 4817 | - } |
|
| 4814 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
|
| 4815 | + $v_found = true; |
|
| 4816 | + } |
|
| 4817 | + } |
|
| 4818 | 4818 | |
| 4819 | - // ----- Look for extract by index rule |
|
| 4820 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4819 | + // ----- Look for extract by index rule |
|
| 4820 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4821 | 4821 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
| 4822 | 4822 | |
| 4823 | - // ----- Look if the index is in the list |
|
| 4824 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
|
|
| 4823 | + // ----- Look if the index is in the list |
|
| 4824 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
|
|
| 4825 | 4825 | |
| 4826 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 4827 | - $v_found = true; |
|
| 4828 | - } |
|
| 4829 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 4830 | - $j_start = $j+1; |
|
| 4831 | - } |
|
| 4826 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
|
| 4827 | + $v_found = true; |
|
| 4828 | + } |
|
| 4829 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
|
| 4830 | + $j_start = $j+1; |
|
| 4831 | + } |
|
| 4832 | 4832 | |
| 4833 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 4834 | - break; |
|
| 4835 | - } |
|
| 4836 | - } |
|
| 4837 | - } |
|
| 4838 | - else {
|
|
| 4839 | - $v_found = true; |
|
| 4840 | - } |
|
| 4833 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
|
| 4834 | + break; |
|
| 4835 | + } |
|
| 4836 | + } |
|
| 4837 | + } |
|
| 4838 | + else {
|
|
| 4839 | + $v_found = true; |
|
| 4840 | + } |
|
| 4841 | 4841 | |
| 4842 | - // ----- Look for deletion |
|
| 4843 | - if ($v_found) |
|
| 4844 | - {
|
|
| 4842 | + // ----- Look for deletion |
|
| 4843 | + if ($v_found) |
|
| 4844 | + {
|
|
| 4845 | 4845 | unset($v_header_list[$v_nb_extracted]); |
| 4846 | - } |
|
| 4847 | - else |
|
| 4848 | - {
|
|
| 4846 | + } |
|
| 4847 | + else |
|
| 4848 | + {
|
|
| 4849 | 4849 | $v_nb_extracted++; |
| 4850 | - } |
|
| 4850 | + } |
|
| 4851 | 4851 | } |
| 4852 | 4852 | |
| 4853 | 4853 | // ----- Look if something need to be deleted |
@@ -4899,7 +4899,7 @@ discard block |
||
| 4899 | 4899 | |
| 4900 | 4900 | // ----- Check that local file header is same as central file header |
| 4901 | 4901 | if ($this->privCheckFileHeaders($v_local_header, |
| 4902 | - $v_header_list[$i]) != 1) {
|
|
| 4902 | + $v_header_list[$i]) != 1) {
|
|
| 4903 | 4903 | // TBC |
| 4904 | 4904 | } |
| 4905 | 4905 | unset($v_local_header); |
@@ -4950,7 +4950,7 @@ discard block |
||
| 4950 | 4950 | // ----- Zip file comment |
| 4951 | 4951 | $v_comment = ''; |
| 4952 | 4952 | if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
| 4953 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4953 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4954 | 4954 | } |
| 4955 | 4955 | |
| 4956 | 4956 | // ----- Calculate the size of the central header |
@@ -4990,11 +4990,11 @@ discard block |
||
| 4990 | 4990 | $this->privCloseFd(); |
| 4991 | 4991 | |
| 4992 | 4992 | if (($v_result = $this->privOpenFd('wb')) != 1) {
|
| 4993 | - return $v_result; |
|
| 4993 | + return $v_result; |
|
| 4994 | 4994 | } |
| 4995 | 4995 | |
| 4996 | 4996 | if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
|
| 4997 | - return $v_result; |
|
| 4997 | + return $v_result; |
|
| 4998 | 4998 | } |
| 4999 | 4999 | |
| 5000 | 5000 | $this->privCloseFd(); |
@@ -5002,35 +5002,35 @@ discard block |
||
| 5002 | 5002 | |
| 5003 | 5003 | // ----- Return |
| 5004 | 5004 | return $v_result; |
| 5005 | - } |
|
| 5006 | - // -------------------------------------------------------------------------------- |
|
| 5007 | - |
|
| 5008 | - // -------------------------------------------------------------------------------- |
|
| 5009 | - // Function : privDirCheck() |
|
| 5010 | - // Description : |
|
| 5011 | - // Check if a directory exists, if not it creates it and all the parents directory |
|
| 5012 | - // which may be useful. |
|
| 5013 | - // Parameters : |
|
| 5014 | - // $p_dir : Directory path to check. |
|
| 5015 | - // Return Values : |
|
| 5016 | - // 1 : OK |
|
| 5017 | - // -1 : Unable to create directory |
|
| 5018 | - // -------------------------------------------------------------------------------- |
|
| 5019 | - function privDirCheck($p_dir, $p_is_dir=false) |
|
| 5020 | - {
|
|
| 5005 | + } |
|
| 5006 | + // -------------------------------------------------------------------------------- |
|
| 5007 | + |
|
| 5008 | + // -------------------------------------------------------------------------------- |
|
| 5009 | + // Function : privDirCheck() |
|
| 5010 | + // Description : |
|
| 5011 | + // Check if a directory exists, if not it creates it and all the parents directory |
|
| 5012 | + // which may be useful. |
|
| 5013 | + // Parameters : |
|
| 5014 | + // $p_dir : Directory path to check. |
|
| 5015 | + // Return Values : |
|
| 5016 | + // 1 : OK |
|
| 5017 | + // -1 : Unable to create directory |
|
| 5018 | + // -------------------------------------------------------------------------------- |
|
| 5019 | + function privDirCheck($p_dir, $p_is_dir=false) |
|
| 5020 | + {
|
|
| 5021 | 5021 | $v_result = 1; |
| 5022 | 5022 | |
| 5023 | 5023 | |
| 5024 | 5024 | // ----- Remove the final '/' |
| 5025 | 5025 | if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
| 5026 | 5026 | {
|
| 5027 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5027 | + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 5028 | 5028 | } |
| 5029 | 5029 | |
| 5030 | 5030 | // ----- Check the directory availability |
| 5031 | 5031 | if ((is_dir($p_dir)) || ($p_dir == "")) |
| 5032 | 5032 | {
|
| 5033 | - return 1; |
|
| 5033 | + return 1; |
|
| 5034 | 5034 | } |
| 5035 | 5035 | |
| 5036 | 5036 | // ----- Extract parent directory |
@@ -5039,77 +5039,77 @@ discard block |
||
| 5039 | 5039 | // ----- Just a check |
| 5040 | 5040 | if ($p_parent_dir != $p_dir) |
| 5041 | 5041 | {
|
| 5042 | - // ----- Look for parent directory |
|
| 5043 | - if ($p_parent_dir != "") |
|
| 5044 | - {
|
|
| 5042 | + // ----- Look for parent directory |
|
| 5043 | + if ($p_parent_dir != "") |
|
| 5044 | + {
|
|
| 5045 | 5045 | if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) |
| 5046 | 5046 | {
|
| 5047 | - return $v_result; |
|
| 5047 | + return $v_result; |
|
| 5048 | + } |
|
| 5048 | 5049 | } |
| 5049 | - } |
|
| 5050 | 5050 | } |
| 5051 | 5051 | |
| 5052 | 5052 | // ----- Create the directory |
| 5053 | 5053 | if (!@mkdir($p_dir, 0777)) |
| 5054 | 5054 | {
|
| 5055 | - // ----- Error log |
|
| 5056 | - PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5055 | + // ----- Error log |
|
| 5056 | + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5057 | 5057 | |
| 5058 | - // ----- Return |
|
| 5059 | - return PclZip::errorCode(); |
|
| 5058 | + // ----- Return |
|
| 5059 | + return PclZip::errorCode(); |
|
| 5060 | 5060 | } |
| 5061 | 5061 | |
| 5062 | 5062 | // ----- Return |
| 5063 | 5063 | return $v_result; |
| 5064 | - } |
|
| 5065 | - // -------------------------------------------------------------------------------- |
|
| 5066 | - |
|
| 5067 | - // -------------------------------------------------------------------------------- |
|
| 5068 | - // Function : privMerge() |
|
| 5069 | - // Description : |
|
| 5070 | - // If $p_archive_to_add does not exist, the function exit with a success result. |
|
| 5071 | - // Parameters : |
|
| 5072 | - // Return Values : |
|
| 5073 | - // -------------------------------------------------------------------------------- |
|
| 5074 | - function privMerge(&$p_archive_to_add) |
|
| 5075 | - {
|
|
| 5064 | + } |
|
| 5065 | + // -------------------------------------------------------------------------------- |
|
| 5066 | + |
|
| 5067 | + // -------------------------------------------------------------------------------- |
|
| 5068 | + // Function : privMerge() |
|
| 5069 | + // Description : |
|
| 5070 | + // If $p_archive_to_add does not exist, the function exit with a success result. |
|
| 5071 | + // Parameters : |
|
| 5072 | + // Return Values : |
|
| 5073 | + // -------------------------------------------------------------------------------- |
|
| 5074 | + function privMerge(&$p_archive_to_add) |
|
| 5075 | + {
|
|
| 5076 | 5076 | $v_result=1; |
| 5077 | 5077 | |
| 5078 | 5078 | // ----- Look if the archive_to_add exists |
| 5079 | 5079 | if (!is_file($p_archive_to_add->zipname)) |
| 5080 | 5080 | {
|
| 5081 | 5081 | |
| 5082 | - // ----- Nothing to merge, so merge is a success |
|
| 5083 | - $v_result = 1; |
|
| 5082 | + // ----- Nothing to merge, so merge is a success |
|
| 5083 | + $v_result = 1; |
|
| 5084 | 5084 | |
| 5085 | - // ----- Return |
|
| 5086 | - return $v_result; |
|
| 5085 | + // ----- Return |
|
| 5086 | + return $v_result; |
|
| 5087 | 5087 | } |
| 5088 | 5088 | |
| 5089 | 5089 | // ----- Look if the archive exists |
| 5090 | 5090 | if (!is_file($this->zipname)) |
| 5091 | 5091 | {
|
| 5092 | 5092 | |
| 5093 | - // ----- Do a duplicate |
|
| 5094 | - $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5093 | + // ----- Do a duplicate |
|
| 5094 | + $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5095 | 5095 | |
| 5096 | - // ----- Return |
|
| 5097 | - return $v_result; |
|
| 5096 | + // ----- Return |
|
| 5097 | + return $v_result; |
|
| 5098 | 5098 | } |
| 5099 | 5099 | |
| 5100 | 5100 | // ----- Open the zip file |
| 5101 | 5101 | if (($v_result=$this->privOpenFd('rb')) != 1)
|
| 5102 | 5102 | {
|
| 5103 | - // ----- Return |
|
| 5104 | - return $v_result; |
|
| 5103 | + // ----- Return |
|
| 5104 | + return $v_result; |
|
| 5105 | 5105 | } |
| 5106 | 5106 | |
| 5107 | 5107 | // ----- Read the central directory informations |
| 5108 | 5108 | $v_central_dir = array(); |
| 5109 | 5109 | if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
| 5110 | 5110 | {
|
| 5111 | - $this->privCloseFd(); |
|
| 5112 | - return $v_result; |
|
| 5111 | + $this->privCloseFd(); |
|
| 5112 | + return $v_result; |
|
| 5113 | 5113 | } |
| 5114 | 5114 | |
| 5115 | 5115 | // ----- Go to beginning of File |
@@ -5118,20 +5118,20 @@ discard block |
||
| 5118 | 5118 | // ----- Open the archive_to_add file |
| 5119 | 5119 | if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
|
| 5120 | 5120 | {
|
| 5121 | - $this->privCloseFd(); |
|
| 5121 | + $this->privCloseFd(); |
|
| 5122 | 5122 | |
| 5123 | - // ----- Return |
|
| 5124 | - return $v_result; |
|
| 5123 | + // ----- Return |
|
| 5124 | + return $v_result; |
|
| 5125 | 5125 | } |
| 5126 | 5126 | |
| 5127 | 5127 | // ----- Read the central directory informations |
| 5128 | 5128 | $v_central_dir_to_add = array(); |
| 5129 | 5129 | if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) |
| 5130 | 5130 | {
|
| 5131 | - $this->privCloseFd(); |
|
| 5132 | - $p_archive_to_add->privCloseFd(); |
|
| 5131 | + $this->privCloseFd(); |
|
| 5132 | + $p_archive_to_add->privCloseFd(); |
|
| 5133 | 5133 | |
| 5134 | - return $v_result; |
|
| 5134 | + return $v_result; |
|
| 5135 | 5135 | } |
| 5136 | 5136 | |
| 5137 | 5137 | // ----- Go to beginning of File |
@@ -5143,13 +5143,13 @@ discard block |
||
| 5143 | 5143 | // ----- Open the temporary file in write mode |
| 5144 | 5144 | if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
| 5145 | 5145 | {
|
| 5146 | - $this->privCloseFd(); |
|
| 5147 | - $p_archive_to_add->privCloseFd(); |
|
| 5146 | + $this->privCloseFd(); |
|
| 5147 | + $p_archive_to_add->privCloseFd(); |
|
| 5148 | 5148 | |
| 5149 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5149 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5150 | 5150 | |
| 5151 | - // ----- Return |
|
| 5152 | - return PclZip::errorCode(); |
|
| 5151 | + // ----- Return |
|
| 5152 | + return PclZip::errorCode(); |
|
| 5153 | 5153 | } |
| 5154 | 5154 | |
| 5155 | 5155 | // ----- Copy the files from the archive to the temporary file |
@@ -5157,20 +5157,20 @@ discard block |
||
| 5157 | 5157 | $v_size = $v_central_dir['offset']; |
| 5158 | 5158 | while ($v_size != 0) |
| 5159 | 5159 | {
|
| 5160 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5161 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5162 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5163 | - $v_size -= $v_read_size; |
|
| 5160 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5161 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5162 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5163 | + $v_size -= $v_read_size; |
|
| 5164 | 5164 | } |
| 5165 | 5165 | |
| 5166 | 5166 | // ----- Copy the files from the archive_to_add into the temporary file |
| 5167 | 5167 | $v_size = $v_central_dir_to_add['offset']; |
| 5168 | 5168 | while ($v_size != 0) |
| 5169 | 5169 | {
|
| 5170 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5171 | - $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5172 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5173 | - $v_size -= $v_read_size; |
|
| 5170 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5171 | + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5172 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5173 | + $v_size -= $v_read_size; |
|
| 5174 | 5174 | } |
| 5175 | 5175 | |
| 5176 | 5176 | // ----- Store the offset of the central dir |
@@ -5180,20 +5180,20 @@ discard block |
||
| 5180 | 5180 | $v_size = $v_central_dir['size']; |
| 5181 | 5181 | while ($v_size != 0) |
| 5182 | 5182 | {
|
| 5183 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5184 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5185 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5186 | - $v_size -= $v_read_size; |
|
| 5183 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5184 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5185 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5186 | + $v_size -= $v_read_size; |
|
| 5187 | 5187 | } |
| 5188 | 5188 | |
| 5189 | 5189 | // ----- Copy the block of file headers from the archive_to_add |
| 5190 | 5190 | $v_size = $v_central_dir_to_add['size']; |
| 5191 | 5191 | while ($v_size != 0) |
| 5192 | 5192 | {
|
| 5193 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5194 | - $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5195 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5196 | - $v_size -= $v_read_size; |
|
| 5193 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5194 | + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5195 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5196 | + $v_size -= $v_read_size; |
|
| 5197 | 5197 | } |
| 5198 | 5198 | |
| 5199 | 5199 | // ----- Merge the file comments |
@@ -5212,16 +5212,16 @@ discard block |
||
| 5212 | 5212 | // ----- Create the central dir footer |
| 5213 | 5213 | if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
| 5214 | 5214 | {
|
| 5215 | - $this->privCloseFd(); |
|
| 5216 | - $p_archive_to_add->privCloseFd(); |
|
| 5217 | - @fclose($v_zip_temp_fd); |
|
| 5218 | - $this->zip_fd = null; |
|
| 5215 | + $this->privCloseFd(); |
|
| 5216 | + $p_archive_to_add->privCloseFd(); |
|
| 5217 | + @fclose($v_zip_temp_fd); |
|
| 5218 | + $this->zip_fd = null; |
|
| 5219 | 5219 | |
| 5220 | - // ----- Reset the file list |
|
| 5221 | - unset($v_header_list); |
|
| 5220 | + // ----- Reset the file list |
|
| 5221 | + unset($v_header_list); |
|
| 5222 | 5222 | |
| 5223 | - // ----- Return |
|
| 5224 | - return $v_result; |
|
| 5223 | + // ----- Return |
|
| 5224 | + return $v_result; |
|
| 5225 | 5225 | } |
| 5226 | 5226 | |
| 5227 | 5227 | // ----- Swap back the file descriptor |
@@ -5247,46 +5247,46 @@ discard block |
||
| 5247 | 5247 | |
| 5248 | 5248 | // ----- Return |
| 5249 | 5249 | return $v_result; |
| 5250 | - } |
|
| 5251 | - // -------------------------------------------------------------------------------- |
|
| 5252 | - |
|
| 5253 | - // -------------------------------------------------------------------------------- |
|
| 5254 | - // Function : privDuplicate() |
|
| 5255 | - // Description : |
|
| 5256 | - // Parameters : |
|
| 5257 | - // Return Values : |
|
| 5258 | - // -------------------------------------------------------------------------------- |
|
| 5259 | - function privDuplicate($p_archive_filename) |
|
| 5260 | - {
|
|
| 5250 | + } |
|
| 5251 | + // -------------------------------------------------------------------------------- |
|
| 5252 | + |
|
| 5253 | + // -------------------------------------------------------------------------------- |
|
| 5254 | + // Function : privDuplicate() |
|
| 5255 | + // Description : |
|
| 5256 | + // Parameters : |
|
| 5257 | + // Return Values : |
|
| 5258 | + // -------------------------------------------------------------------------------- |
|
| 5259 | + function privDuplicate($p_archive_filename) |
|
| 5260 | + {
|
|
| 5261 | 5261 | $v_result=1; |
| 5262 | 5262 | |
| 5263 | 5263 | // ----- Look if the $p_archive_filename exists |
| 5264 | 5264 | if (!is_file($p_archive_filename)) |
| 5265 | 5265 | {
|
| 5266 | 5266 | |
| 5267 | - // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5268 | - $v_result = 1; |
|
| 5267 | + // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5268 | + $v_result = 1; |
|
| 5269 | 5269 | |
| 5270 | - // ----- Return |
|
| 5271 | - return $v_result; |
|
| 5270 | + // ----- Return |
|
| 5271 | + return $v_result; |
|
| 5272 | 5272 | } |
| 5273 | 5273 | |
| 5274 | 5274 | // ----- Open the zip file |
| 5275 | 5275 | if (($v_result=$this->privOpenFd('wb')) != 1)
|
| 5276 | 5276 | {
|
| 5277 | - // ----- Return |
|
| 5278 | - return $v_result; |
|
| 5277 | + // ----- Return |
|
| 5278 | + return $v_result; |
|
| 5279 | 5279 | } |
| 5280 | 5280 | |
| 5281 | 5281 | // ----- Open the temporary file in write mode |
| 5282 | 5282 | if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) |
| 5283 | 5283 | {
|
| 5284 | - $this->privCloseFd(); |
|
| 5284 | + $this->privCloseFd(); |
|
| 5285 | 5285 | |
| 5286 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5286 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5287 | 5287 | |
| 5288 | - // ----- Return |
|
| 5289 | - return PclZip::errorCode(); |
|
| 5288 | + // ----- Return |
|
| 5289 | + return PclZip::errorCode(); |
|
| 5290 | 5290 | } |
| 5291 | 5291 | |
| 5292 | 5292 | // ----- Copy the files from the archive to the temporary file |
@@ -5294,10 +5294,10 @@ discard block |
||
| 5294 | 5294 | $v_size = filesize($p_archive_filename); |
| 5295 | 5295 | while ($v_size != 0) |
| 5296 | 5296 | {
|
| 5297 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5298 | - $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5299 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5300 | - $v_size -= $v_read_size; |
|
| 5297 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5298 | + $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5299 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5300 | + $v_size -= $v_read_size; |
|
| 5301 | 5301 | } |
| 5302 | 5302 | |
| 5303 | 5303 | // ----- Close |
@@ -5308,211 +5308,211 @@ discard block |
||
| 5308 | 5308 | |
| 5309 | 5309 | // ----- Return |
| 5310 | 5310 | return $v_result; |
| 5311 | - } |
|
| 5312 | - // -------------------------------------------------------------------------------- |
|
| 5313 | - |
|
| 5314 | - // -------------------------------------------------------------------------------- |
|
| 5315 | - // Function : privErrorLog() |
|
| 5316 | - // Description : |
|
| 5317 | - // Parameters : |
|
| 5318 | - // -------------------------------------------------------------------------------- |
|
| 5319 | - function privErrorLog($p_error_code=0, $p_error_string='') |
|
| 5320 | - {
|
|
| 5311 | + } |
|
| 5312 | + // -------------------------------------------------------------------------------- |
|
| 5313 | + |
|
| 5314 | + // -------------------------------------------------------------------------------- |
|
| 5315 | + // Function : privErrorLog() |
|
| 5316 | + // Description : |
|
| 5317 | + // Parameters : |
|
| 5318 | + // -------------------------------------------------------------------------------- |
|
| 5319 | + function privErrorLog($p_error_code=0, $p_error_string='') |
|
| 5320 | + {
|
|
| 5321 | 5321 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 5322 | - PclError($p_error_code, $p_error_string); |
|
| 5322 | + PclError($p_error_code, $p_error_string); |
|
| 5323 | 5323 | } |
| 5324 | 5324 | else {
|
| 5325 | - $this->error_code = $p_error_code; |
|
| 5326 | - $this->error_string = $p_error_string; |
|
| 5327 | - } |
|
| 5328 | - } |
|
| 5329 | - // -------------------------------------------------------------------------------- |
|
| 5330 | - |
|
| 5331 | - // -------------------------------------------------------------------------------- |
|
| 5332 | - // Function : privErrorReset() |
|
| 5333 | - // Description : |
|
| 5334 | - // Parameters : |
|
| 5335 | - // -------------------------------------------------------------------------------- |
|
| 5336 | - function privErrorReset() |
|
| 5337 | - {
|
|
| 5325 | + $this->error_code = $p_error_code; |
|
| 5326 | + $this->error_string = $p_error_string; |
|
| 5327 | + } |
|
| 5328 | + } |
|
| 5329 | + // -------------------------------------------------------------------------------- |
|
| 5330 | + |
|
| 5331 | + // -------------------------------------------------------------------------------- |
|
| 5332 | + // Function : privErrorReset() |
|
| 5333 | + // Description : |
|
| 5334 | + // Parameters : |
|
| 5335 | + // -------------------------------------------------------------------------------- |
|
| 5336 | + function privErrorReset() |
|
| 5337 | + {
|
|
| 5338 | 5338 | if (PCLZIP_ERROR_EXTERNAL == 1) {
|
| 5339 | - PclErrorReset(); |
|
| 5339 | + PclErrorReset(); |
|
| 5340 | 5340 | } |
| 5341 | 5341 | else {
|
| 5342 | - $this->error_code = 0; |
|
| 5343 | - $this->error_string = ''; |
|
| 5344 | - } |
|
| 5345 | - } |
|
| 5346 | - // -------------------------------------------------------------------------------- |
|
| 5347 | - |
|
| 5348 | - // -------------------------------------------------------------------------------- |
|
| 5349 | - // Function : privDisableMagicQuotes() |
|
| 5350 | - // Description : |
|
| 5351 | - // Parameters : |
|
| 5352 | - // Return Values : |
|
| 5353 | - // -------------------------------------------------------------------------------- |
|
| 5354 | - function privDisableMagicQuotes() |
|
| 5355 | - {
|
|
| 5342 | + $this->error_code = 0; |
|
| 5343 | + $this->error_string = ''; |
|
| 5344 | + } |
|
| 5345 | + } |
|
| 5346 | + // -------------------------------------------------------------------------------- |
|
| 5347 | + |
|
| 5348 | + // -------------------------------------------------------------------------------- |
|
| 5349 | + // Function : privDisableMagicQuotes() |
|
| 5350 | + // Description : |
|
| 5351 | + // Parameters : |
|
| 5352 | + // Return Values : |
|
| 5353 | + // -------------------------------------------------------------------------------- |
|
| 5354 | + function privDisableMagicQuotes() |
|
| 5355 | + {
|
|
| 5356 | 5356 | $v_result=1; |
| 5357 | 5357 | |
| 5358 | 5358 | // ----- Look if function exists |
| 5359 | 5359 | if ( (!function_exists("get_magic_quotes_runtime"))
|
| 5360 | - || (!function_exists("set_magic_quotes_runtime"))) {
|
|
| 5361 | - return $v_result; |
|
| 5362 | - } |
|
| 5360 | + || (!function_exists("set_magic_quotes_runtime"))) {
|
|
| 5361 | + return $v_result; |
|
| 5362 | + } |
|
| 5363 | 5363 | |
| 5364 | 5364 | // ----- Look if already done |
| 5365 | 5365 | if ($this->magic_quotes_status != -1) {
|
| 5366 | - return $v_result; |
|
| 5367 | - } |
|
| 5366 | + return $v_result; |
|
| 5367 | + } |
|
| 5368 | 5368 | |
| 5369 | - // ----- Get and memorize the magic_quote value |
|
| 5370 | - $this->magic_quotes_status = @get_magic_quotes_runtime(); |
|
| 5369 | + // ----- Get and memorize the magic_quote value |
|
| 5370 | + $this->magic_quotes_status = @get_magic_quotes_runtime(); |
|
| 5371 | 5371 | |
| 5372 | - // ----- Disable magic_quotes |
|
| 5373 | - if ($this->magic_quotes_status == 1) {
|
|
| 5374 | - @set_magic_quotes_runtime(0); |
|
| 5375 | - } |
|
| 5372 | + // ----- Disable magic_quotes |
|
| 5373 | + if ($this->magic_quotes_status == 1) {
|
|
| 5374 | + @set_magic_quotes_runtime(0); |
|
| 5375 | + } |
|
| 5376 | 5376 | |
| 5377 | 5377 | // ----- Return |
| 5378 | 5378 | return $v_result; |
| 5379 | - } |
|
| 5380 | - // -------------------------------------------------------------------------------- |
|
| 5381 | - |
|
| 5382 | - // -------------------------------------------------------------------------------- |
|
| 5383 | - // Function : privSwapBackMagicQuotes() |
|
| 5384 | - // Description : |
|
| 5385 | - // Parameters : |
|
| 5386 | - // Return Values : |
|
| 5387 | - // -------------------------------------------------------------------------------- |
|
| 5388 | - function privSwapBackMagicQuotes() |
|
| 5389 | - {
|
|
| 5379 | + } |
|
| 5380 | + // -------------------------------------------------------------------------------- |
|
| 5381 | + |
|
| 5382 | + // -------------------------------------------------------------------------------- |
|
| 5383 | + // Function : privSwapBackMagicQuotes() |
|
| 5384 | + // Description : |
|
| 5385 | + // Parameters : |
|
| 5386 | + // Return Values : |
|
| 5387 | + // -------------------------------------------------------------------------------- |
|
| 5388 | + function privSwapBackMagicQuotes() |
|
| 5389 | + {
|
|
| 5390 | 5390 | $v_result=1; |
| 5391 | 5391 | |
| 5392 | 5392 | // ----- Look if function exists |
| 5393 | 5393 | if ( (!function_exists("get_magic_quotes_runtime"))
|
| 5394 | - || (!function_exists("set_magic_quotes_runtime"))) {
|
|
| 5395 | - return $v_result; |
|
| 5396 | - } |
|
| 5394 | + || (!function_exists("set_magic_quotes_runtime"))) {
|
|
| 5395 | + return $v_result; |
|
| 5396 | + } |
|
| 5397 | 5397 | |
| 5398 | 5398 | // ----- Look if something to do |
| 5399 | 5399 | if ($this->magic_quotes_status != -1) {
|
| 5400 | - return $v_result; |
|
| 5401 | - } |
|
| 5400 | + return $v_result; |
|
| 5401 | + } |
|
| 5402 | 5402 | |
| 5403 | - // ----- Swap back magic_quotes |
|
| 5404 | - if ($this->magic_quotes_status == 1) {
|
|
| 5405 | - @set_magic_quotes_runtime($this->magic_quotes_status); |
|
| 5406 | - } |
|
| 5403 | + // ----- Swap back magic_quotes |
|
| 5404 | + if ($this->magic_quotes_status == 1) {
|
|
| 5405 | + @set_magic_quotes_runtime($this->magic_quotes_status); |
|
| 5406 | + } |
|
| 5407 | 5407 | |
| 5408 | 5408 | // ----- Return |
| 5409 | 5409 | return $v_result; |
| 5410 | - } |
|
| 5411 | - // -------------------------------------------------------------------------------- |
|
| 5412 | - |
|
| 5413 | - } |
|
| 5414 | - // End of class |
|
| 5415 | - // -------------------------------------------------------------------------------- |
|
| 5416 | - |
|
| 5417 | - // -------------------------------------------------------------------------------- |
|
| 5418 | - // Function : PclZipUtilPathReduction() |
|
| 5419 | - // Description : |
|
| 5420 | - // Parameters : |
|
| 5421 | - // Return Values : |
|
| 5422 | - // -------------------------------------------------------------------------------- |
|
| 5423 | - function PclZipUtilPathReduction($p_dir) |
|
| 5424 | - {
|
|
| 5410 | + } |
|
| 5411 | + // -------------------------------------------------------------------------------- |
|
| 5412 | + |
|
| 5413 | + } |
|
| 5414 | + // End of class |
|
| 5415 | + // -------------------------------------------------------------------------------- |
|
| 5416 | + |
|
| 5417 | + // -------------------------------------------------------------------------------- |
|
| 5418 | + // Function : PclZipUtilPathReduction() |
|
| 5419 | + // Description : |
|
| 5420 | + // Parameters : |
|
| 5421 | + // Return Values : |
|
| 5422 | + // -------------------------------------------------------------------------------- |
|
| 5423 | + function PclZipUtilPathReduction($p_dir) |
|
| 5424 | + {
|
|
| 5425 | 5425 | $v_result = ""; |
| 5426 | 5426 | |
| 5427 | 5427 | // ----- Look for not empty path |
| 5428 | 5428 | if ($p_dir != "") {
|
| 5429 | - // ----- Explode path by directory names |
|
| 5430 | - $v_list = explode("/", $p_dir);
|
|
| 5429 | + // ----- Explode path by directory names |
|
| 5430 | + $v_list = explode("/", $p_dir);
|
|
| 5431 | 5431 | |
| 5432 | - // ----- Study directories from last to first |
|
| 5433 | - $v_skip = 0; |
|
| 5434 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) {
|
|
| 5432 | + // ----- Study directories from last to first |
|
| 5433 | + $v_skip = 0; |
|
| 5434 | + for ($i=sizeof($v_list)-1; $i>=0; $i--) {
|
|
| 5435 | 5435 | // ----- Look for current path |
| 5436 | 5436 | if ($v_list[$i] == ".") {
|
| 5437 | - // ----- Ignore this directory |
|
| 5438 | - // Should be the first $i=0, but no check is done |
|
| 5437 | + // ----- Ignore this directory |
|
| 5438 | + // Should be the first $i=0, but no check is done |
|
| 5439 | 5439 | } |
| 5440 | 5440 | else if ($v_list[$i] == "..") {
|
| 5441 | - $v_skip++; |
|
| 5441 | + $v_skip++; |
|
| 5442 | 5442 | } |
| 5443 | 5443 | else if ($v_list[$i] == "") {
|
| 5444 | - // ----- First '/' i.e. root slash |
|
| 5445 | - if ($i == 0) {
|
|
| 5444 | + // ----- First '/' i.e. root slash |
|
| 5445 | + if ($i == 0) {
|
|
| 5446 | 5446 | $v_result = "/".$v_result; |
| 5447 | - if ($v_skip > 0) {
|
|
| 5448 | - // ----- It is an invalid path, so the path is not modified |
|
| 5449 | - // TBC |
|
| 5450 | - $v_result = $p_dir; |
|
| 5447 | + if ($v_skip > 0) {
|
|
| 5448 | + // ----- It is an invalid path, so the path is not modified |
|
| 5449 | + // TBC |
|
| 5450 | + $v_result = $p_dir; |
|
| 5451 | 5451 | $v_skip = 0; |
| 5452 | - } |
|
| 5453 | - } |
|
| 5454 | - // ----- Last '/' i.e. indicates a directory |
|
| 5455 | - else if ($i == (sizeof($v_list)-1)) {
|
|
| 5452 | + } |
|
| 5453 | + } |
|
| 5454 | + // ----- Last '/' i.e. indicates a directory |
|
| 5455 | + else if ($i == (sizeof($v_list)-1)) {
|
|
| 5456 | 5456 | $v_result = $v_list[$i]; |
| 5457 | - } |
|
| 5458 | - // ----- Double '/' inside the path |
|
| 5459 | - else {
|
|
| 5457 | + } |
|
| 5458 | + // ----- Double '/' inside the path |
|
| 5459 | + else {
|
|
| 5460 | 5460 | // ----- Ignore only the double '//' in path, |
| 5461 | 5461 | // but not the first and last '/' |
| 5462 | - } |
|
| 5462 | + } |
|
| 5463 | 5463 | } |
| 5464 | 5464 | else {
|
| 5465 | - // ----- Look for item to skip |
|
| 5466 | - if ($v_skip > 0) {
|
|
| 5467 | - $v_skip--; |
|
| 5468 | - } |
|
| 5469 | - else {
|
|
| 5465 | + // ----- Look for item to skip |
|
| 5466 | + if ($v_skip > 0) {
|
|
| 5467 | + $v_skip--; |
|
| 5468 | + } |
|
| 5469 | + else {
|
|
| 5470 | 5470 | $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
| 5471 | - } |
|
| 5471 | + } |
|
| 5472 | + } |
|
| 5472 | 5473 | } |
| 5473 | - } |
|
| 5474 | 5474 | |
| 5475 | - // ----- Look for skip |
|
| 5476 | - if ($v_skip > 0) {
|
|
| 5475 | + // ----- Look for skip |
|
| 5476 | + if ($v_skip > 0) {
|
|
| 5477 | 5477 | while ($v_skip > 0) {
|
| 5478 | 5478 | $v_result = '../'.$v_result; |
| 5479 | 5479 | $v_skip--; |
| 5480 | 5480 | } |
| 5481 | - } |
|
| 5481 | + } |
|
| 5482 | 5482 | } |
| 5483 | 5483 | |
| 5484 | 5484 | // ----- Return |
| 5485 | 5485 | return $v_result; |
| 5486 | - } |
|
| 5487 | - // -------------------------------------------------------------------------------- |
|
| 5488 | - |
|
| 5489 | - // -------------------------------------------------------------------------------- |
|
| 5490 | - // Function : PclZipUtilPathInclusion() |
|
| 5491 | - // Description : |
|
| 5492 | - // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
| 5493 | - // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
| 5494 | - // $p_dir. |
|
| 5495 | - // The function indicates also if the path is exactly the same as the dir. |
|
| 5496 | - // This function supports path with duplicated '/' like '//', but does not |
|
| 5497 | - // support '.' or '..' statements. |
|
| 5498 | - // Parameters : |
|
| 5499 | - // Return Values : |
|
| 5500 | - // 0 if $p_path is not inside directory $p_dir |
|
| 5501 | - // 1 if $p_path is inside directory $p_dir |
|
| 5502 | - // 2 if $p_path is exactly the same as $p_dir |
|
| 5503 | - // -------------------------------------------------------------------------------- |
|
| 5504 | - function PclZipUtilPathInclusion($p_dir, $p_path) |
|
| 5505 | - {
|
|
| 5486 | + } |
|
| 5487 | + // -------------------------------------------------------------------------------- |
|
| 5488 | + |
|
| 5489 | + // -------------------------------------------------------------------------------- |
|
| 5490 | + // Function : PclZipUtilPathInclusion() |
|
| 5491 | + // Description : |
|
| 5492 | + // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
| 5493 | + // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
| 5494 | + // $p_dir. |
|
| 5495 | + // The function indicates also if the path is exactly the same as the dir. |
|
| 5496 | + // This function supports path with duplicated '/' like '//', but does not |
|
| 5497 | + // support '.' or '..' statements. |
|
| 5498 | + // Parameters : |
|
| 5499 | + // Return Values : |
|
| 5500 | + // 0 if $p_path is not inside directory $p_dir |
|
| 5501 | + // 1 if $p_path is inside directory $p_dir |
|
| 5502 | + // 2 if $p_path is exactly the same as $p_dir |
|
| 5503 | + // -------------------------------------------------------------------------------- |
|
| 5504 | + function PclZipUtilPathInclusion($p_dir, $p_path) |
|
| 5505 | + {
|
|
| 5506 | 5506 | $v_result = 1; |
| 5507 | 5507 | |
| 5508 | 5508 | // ----- Look for path beginning by ./ |
| 5509 | 5509 | if ( ($p_dir == '.') |
| 5510 | 5510 | || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
|
| 5511 | - $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5511 | + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5512 | 5512 | } |
| 5513 | 5513 | if ( ($p_path == '.') |
| 5514 | 5514 | || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
|
| 5515 | - $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5515 | + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5516 | 5516 | } |
| 5517 | 5517 | |
| 5518 | 5518 | // ----- Explode dir and path by directory separator |
@@ -5526,196 +5526,196 @@ discard block |
||
| 5526 | 5526 | $j = 0; |
| 5527 | 5527 | while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
|
| 5528 | 5528 | |
| 5529 | - // ----- Look for empty dir (path reduction) |
|
| 5530 | - if ($v_list_dir[$i] == '') {
|
|
| 5529 | + // ----- Look for empty dir (path reduction) |
|
| 5530 | + if ($v_list_dir[$i] == '') {
|
|
| 5531 | 5531 | $i++; |
| 5532 | 5532 | continue; |
| 5533 | - } |
|
| 5534 | - if ($v_list_path[$j] == '') {
|
|
| 5533 | + } |
|
| 5534 | + if ($v_list_path[$j] == '') {
|
|
| 5535 | 5535 | $j++; |
| 5536 | 5536 | continue; |
| 5537 | - } |
|
| 5537 | + } |
|
| 5538 | 5538 | |
| 5539 | - // ----- Compare the items |
|
| 5540 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
|
|
| 5539 | + // ----- Compare the items |
|
| 5540 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
|
|
| 5541 | 5541 | $v_result = 0; |
| 5542 | - } |
|
| 5542 | + } |
|
| 5543 | 5543 | |
| 5544 | - // ----- Next items |
|
| 5545 | - $i++; |
|
| 5546 | - $j++; |
|
| 5544 | + // ----- Next items |
|
| 5545 | + $i++; |
|
| 5546 | + $j++; |
|
| 5547 | 5547 | } |
| 5548 | 5548 | |
| 5549 | 5549 | // ----- Look if everything seems to be the same |
| 5550 | 5550 | if ($v_result) {
|
| 5551 | - // ----- Skip all the empty items |
|
| 5552 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5553 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5551 | + // ----- Skip all the empty items |
|
| 5552 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5553 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5554 | 5554 | |
| 5555 | - if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
|
|
| 5555 | + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
|
|
| 5556 | 5556 | // ----- There are exactly the same |
| 5557 | 5557 | $v_result = 2; |
| 5558 | - } |
|
| 5559 | - else if ($i < $v_list_dir_size) {
|
|
| 5558 | + } |
|
| 5559 | + else if ($i < $v_list_dir_size) {
|
|
| 5560 | 5560 | // ----- The path is shorter than the dir |
| 5561 | 5561 | $v_result = 0; |
| 5562 | - } |
|
| 5562 | + } |
|
| 5563 | 5563 | } |
| 5564 | 5564 | |
| 5565 | 5565 | // ----- Return |
| 5566 | 5566 | return $v_result; |
| 5567 | - } |
|
| 5568 | - // -------------------------------------------------------------------------------- |
|
| 5569 | - |
|
| 5570 | - // -------------------------------------------------------------------------------- |
|
| 5571 | - // Function : PclZipUtilCopyBlock() |
|
| 5572 | - // Description : |
|
| 5573 | - // Parameters : |
|
| 5574 | - // $p_mode : read/write compression mode |
|
| 5575 | - // 0 : src & dest normal |
|
| 5576 | - // 1 : src gzip, dest normal |
|
| 5577 | - // 2 : src normal, dest gzip |
|
| 5578 | - // 3 : src & dest gzip |
|
| 5579 | - // Return Values : |
|
| 5580 | - // -------------------------------------------------------------------------------- |
|
| 5581 | - function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 5582 | - {
|
|
| 5567 | + } |
|
| 5568 | + // -------------------------------------------------------------------------------- |
|
| 5569 | + |
|
| 5570 | + // -------------------------------------------------------------------------------- |
|
| 5571 | + // Function : PclZipUtilCopyBlock() |
|
| 5572 | + // Description : |
|
| 5573 | + // Parameters : |
|
| 5574 | + // $p_mode : read/write compression mode |
|
| 5575 | + // 0 : src & dest normal |
|
| 5576 | + // 1 : src gzip, dest normal |
|
| 5577 | + // 2 : src normal, dest gzip |
|
| 5578 | + // 3 : src & dest gzip |
|
| 5579 | + // Return Values : |
|
| 5580 | + // -------------------------------------------------------------------------------- |
|
| 5581 | + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 5582 | + {
|
|
| 5583 | 5583 | $v_result = 1; |
| 5584 | 5584 | |
| 5585 | 5585 | if ($p_mode==0) |
| 5586 | 5586 | {
|
| 5587 | - while ($p_size != 0) |
|
| 5588 | - {
|
|
| 5587 | + while ($p_size != 0) |
|
| 5588 | + {
|
|
| 5589 | 5589 | $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
| 5590 | 5590 | $v_buffer = @fread($p_src, $v_read_size); |
| 5591 | 5591 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5592 | 5592 | $p_size -= $v_read_size; |
| 5593 | - } |
|
| 5593 | + } |
|
| 5594 | 5594 | } |
| 5595 | 5595 | else if ($p_mode==1) |
| 5596 | 5596 | {
|
| 5597 | - while ($p_size != 0) |
|
| 5598 | - {
|
|
| 5597 | + while ($p_size != 0) |
|
| 5598 | + {
|
|
| 5599 | 5599 | $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
| 5600 | 5600 | $v_buffer = @gzread($p_src, $v_read_size); |
| 5601 | 5601 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5602 | 5602 | $p_size -= $v_read_size; |
| 5603 | - } |
|
| 5603 | + } |
|
| 5604 | 5604 | } |
| 5605 | 5605 | else if ($p_mode==2) |
| 5606 | 5606 | {
|
| 5607 | - while ($p_size != 0) |
|
| 5608 | - {
|
|
| 5607 | + while ($p_size != 0) |
|
| 5608 | + {
|
|
| 5609 | 5609 | $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
| 5610 | 5610 | $v_buffer = @fread($p_src, $v_read_size); |
| 5611 | 5611 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 5612 | 5612 | $p_size -= $v_read_size; |
| 5613 | - } |
|
| 5613 | + } |
|
| 5614 | 5614 | } |
| 5615 | 5615 | else if ($p_mode==3) |
| 5616 | 5616 | {
|
| 5617 | - while ($p_size != 0) |
|
| 5618 | - {
|
|
| 5617 | + while ($p_size != 0) |
|
| 5618 | + {
|
|
| 5619 | 5619 | $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
| 5620 | 5620 | $v_buffer = @gzread($p_src, $v_read_size); |
| 5621 | 5621 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 5622 | 5622 | $p_size -= $v_read_size; |
| 5623 | - } |
|
| 5623 | + } |
|
| 5624 | 5624 | } |
| 5625 | 5625 | |
| 5626 | 5626 | // ----- Return |
| 5627 | 5627 | return $v_result; |
| 5628 | - } |
|
| 5629 | - // -------------------------------------------------------------------------------- |
|
| 5630 | - |
|
| 5631 | - // -------------------------------------------------------------------------------- |
|
| 5632 | - // Function : PclZipUtilRename() |
|
| 5633 | - // Description : |
|
| 5634 | - // This function tries to do a simple rename() function. If it fails, it |
|
| 5635 | - // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
| 5636 | - // first one. |
|
| 5637 | - // Parameters : |
|
| 5638 | - // $p_src : Old filename |
|
| 5639 | - // $p_dest : New filename |
|
| 5640 | - // Return Values : |
|
| 5641 | - // 1 on success, 0 on failure. |
|
| 5642 | - // -------------------------------------------------------------------------------- |
|
| 5643 | - function PclZipUtilRename($p_src, $p_dest) |
|
| 5644 | - {
|
|
| 5628 | + } |
|
| 5629 | + // -------------------------------------------------------------------------------- |
|
| 5630 | + |
|
| 5631 | + // -------------------------------------------------------------------------------- |
|
| 5632 | + // Function : PclZipUtilRename() |
|
| 5633 | + // Description : |
|
| 5634 | + // This function tries to do a simple rename() function. If it fails, it |
|
| 5635 | + // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
| 5636 | + // first one. |
|
| 5637 | + // Parameters : |
|
| 5638 | + // $p_src : Old filename |
|
| 5639 | + // $p_dest : New filename |
|
| 5640 | + // Return Values : |
|
| 5641 | + // 1 on success, 0 on failure. |
|
| 5642 | + // -------------------------------------------------------------------------------- |
|
| 5643 | + function PclZipUtilRename($p_src, $p_dest) |
|
| 5644 | + {
|
|
| 5645 | 5645 | $v_result = 1; |
| 5646 | 5646 | |
| 5647 | 5647 | // ----- Try to rename the files |
| 5648 | 5648 | if (!@rename($p_src, $p_dest)) {
|
| 5649 | 5649 | |
| 5650 | - // ----- Try to copy & unlink the src |
|
| 5651 | - if (!@copy($p_src, $p_dest)) {
|
|
| 5650 | + // ----- Try to copy & unlink the src |
|
| 5651 | + if (!@copy($p_src, $p_dest)) {
|
|
| 5652 | 5652 | $v_result = 0; |
| 5653 | - } |
|
| 5654 | - else if (!@unlink($p_src)) {
|
|
| 5653 | + } |
|
| 5654 | + else if (!@unlink($p_src)) {
|
|
| 5655 | 5655 | $v_result = 0; |
| 5656 | - } |
|
| 5656 | + } |
|
| 5657 | 5657 | } |
| 5658 | 5658 | |
| 5659 | 5659 | // ----- Return |
| 5660 | 5660 | return $v_result; |
| 5661 | - } |
|
| 5662 | - // -------------------------------------------------------------------------------- |
|
| 5663 | - |
|
| 5664 | - // -------------------------------------------------------------------------------- |
|
| 5665 | - // Function : PclZipUtilOptionText() |
|
| 5666 | - // Description : |
|
| 5667 | - // Translate option value in text. Mainly for debug purpose. |
|
| 5668 | - // Parameters : |
|
| 5669 | - // $p_option : the option value. |
|
| 5670 | - // Return Values : |
|
| 5671 | - // The option text value. |
|
| 5672 | - // -------------------------------------------------------------------------------- |
|
| 5673 | - function PclZipUtilOptionText($p_option) |
|
| 5674 | - {
|
|
| 5661 | + } |
|
| 5662 | + // -------------------------------------------------------------------------------- |
|
| 5663 | + |
|
| 5664 | + // -------------------------------------------------------------------------------- |
|
| 5665 | + // Function : PclZipUtilOptionText() |
|
| 5666 | + // Description : |
|
| 5667 | + // Translate option value in text. Mainly for debug purpose. |
|
| 5668 | + // Parameters : |
|
| 5669 | + // $p_option : the option value. |
|
| 5670 | + // Return Values : |
|
| 5671 | + // The option text value. |
|
| 5672 | + // -------------------------------------------------------------------------------- |
|
| 5673 | + function PclZipUtilOptionText($p_option) |
|
| 5674 | + {
|
|
| 5675 | 5675 | |
| 5676 | 5676 | $v_list = get_defined_constants(); |
| 5677 | 5677 | for (reset($v_list); $v_key = key($v_list); next($v_list)) {
|
| 5678 | - $v_prefix = substr($v_key, 0, 10); |
|
| 5679 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5678 | + $v_prefix = substr($v_key, 0, 10); |
|
| 5679 | + if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5680 | 5680 | || ($v_prefix == 'PCLZIP_CB_') |
| 5681 | 5681 | || ($v_prefix == 'PCLZIP_ATT')) |
| 5682 | - && ($v_list[$v_key] == $p_option)) {
|
|
| 5682 | + && ($v_list[$v_key] == $p_option)) {
|
|
| 5683 | 5683 | return $v_key; |
| 5684 | - } |
|
| 5684 | + } |
|
| 5685 | 5685 | } |
| 5686 | 5686 | |
| 5687 | 5687 | $v_result = 'Unknown'; |
| 5688 | 5688 | |
| 5689 | 5689 | return $v_result; |
| 5690 | - } |
|
| 5691 | - // -------------------------------------------------------------------------------- |
|
| 5692 | - |
|
| 5693 | - // -------------------------------------------------------------------------------- |
|
| 5694 | - // Function : PclZipUtilTranslateWinPath() |
|
| 5695 | - // Description : |
|
| 5696 | - // Translate windows path by replacing '\' by '/' and optionally removing |
|
| 5697 | - // drive letter. |
|
| 5698 | - // Parameters : |
|
| 5699 | - // $p_path : path to translate. |
|
| 5700 | - // $p_remove_disk_letter : true | false |
|
| 5701 | - // Return Values : |
|
| 5702 | - // The path translated. |
|
| 5703 | - // -------------------------------------------------------------------------------- |
|
| 5704 | - function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 5705 | - {
|
|
| 5690 | + } |
|
| 5691 | + // -------------------------------------------------------------------------------- |
|
| 5692 | + |
|
| 5693 | + // -------------------------------------------------------------------------------- |
|
| 5694 | + // Function : PclZipUtilTranslateWinPath() |
|
| 5695 | + // Description : |
|
| 5696 | + // Translate windows path by replacing '\' by '/' and optionally removing |
|
| 5697 | + // drive letter. |
|
| 5698 | + // Parameters : |
|
| 5699 | + // $p_path : path to translate. |
|
| 5700 | + // $p_remove_disk_letter : true | false |
|
| 5701 | + // Return Values : |
|
| 5702 | + // The path translated. |
|
| 5703 | + // -------------------------------------------------------------------------------- |
|
| 5704 | + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 5705 | + {
|
|
| 5706 | 5706 | if (stristr(php_uname(), 'windows')) {
|
| 5707 | - // ----- Look for potential disk letter |
|
| 5708 | - if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
|
|
| 5709 | - $p_path = substr($p_path, $v_position+1); |
|
| 5710 | - } |
|
| 5711 | - // ----- Change potential windows directory separator |
|
| 5712 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
|
|
| 5713 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 5714 | - } |
|
| 5707 | + // ----- Look for potential disk letter |
|
| 5708 | + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
|
|
| 5709 | + $p_path = substr($p_path, $v_position+1); |
|
| 5710 | + } |
|
| 5711 | + // ----- Change potential windows directory separator |
|
| 5712 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
|
|
| 5713 | + $p_path = strtr($p_path, '\\', '/'); |
|
| 5714 | + } |
|
| 5715 | 5715 | } |
| 5716 | 5716 | return $p_path; |
| 5717 | - } |
|
| 5718 | - // -------------------------------------------------------------------------------- |
|
| 5717 | + } |
|
| 5718 | + // -------------------------------------------------------------------------------- |
|
| 5719 | 5719 | |
| 5720 | 5720 | |
| 5721 | 5721 | ?> |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @uses export/table_pdf.tpl |
| 76 | 76 | |
| 77 | - * @param $content |
|
| 77 | + * @param string $content |
|
| 78 | 78 | * @param bool|false $saveToFile |
| 79 | 79 | * @param bool|false $returnHtml |
| 80 | 80 | * |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param string pdf name |
| 193 | 193 | * @param string course code (if you are using html that are located in the document tool you must provide this) |
| 194 | 194 | * @param bool Whether to print the header, footer and watermark (true) or just the content (false) |
| 195 | - * @return bool |
|
| 195 | + * @return false|null |
|
| 196 | 196 | */ |
| 197 | 197 | public function html_to_pdf( |
| 198 | 198 | $html_file_array, |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF |
| 32 | 32 | * mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]]) |
| 33 | 33 | */ |
| 34 | - if (!in_array($orientation, array('P','L'))) { |
|
| 34 | + if (!in_array($orientation, array('P', 'L'))) { |
|
| 35 | 35 | $orientation = 'P'; |
| 36 | 36 | } |
| 37 | 37 | //$this->pdf = $pdf = new mPDF('UTF-8', $pageFormat, '', '', 30, 20, 27, 25, 16, 13, $orientation); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $visualTheme = api_get_visual_theme(); |
| 112 | 112 | $img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png'; |
| 113 | 113 | if (file_exists($img)) { |
| 114 | - $img = api_get_path(WEB_CSS_PATH) . 'themes/' . $visualTheme . '/images/pdf_logo_header.png'; |
|
| 114 | + $img = api_get_path(WEB_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png'; |
|
| 115 | 115 | $organization = "<img src='$img'>"; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Clean styles and javascript document |
| 232 | - $clean_search = array ( |
|
| 232 | + $clean_search = array( |
|
| 233 | 233 | '@<script[^>]*?>.*?</script>@si', |
| 234 | 234 | '@<style[^>]*?>.*?</style>@si' |
| 235 | 235 | ); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | // then print the title in the PDF |
| 251 | 251 | if (is_array($file) && isset($file['title'])) { |
| 252 | 252 | $html_title = $file['title']; |
| 253 | - $file = $file['path']; |
|
| 253 | + $file = $file['path']; |
|
| 254 | 254 | } else { |
| 255 | 255 | //we suppose we've only been sent a file path |
| 256 | 256 | $html_title = basename($file); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | //it's not a chapter but the file exists, print its title |
| 283 | 283 | if ($print_title) { |
| 284 | 284 | $this->pdf->WriteHTML( |
| 285 | - '<html><body><h3>' . $html_title . '</h3></body></html>', |
|
| 285 | + '<html><body><h3>'.$html_title.'</h3></body></html>', |
|
| 286 | 286 | 2 |
| 287 | 287 | ); |
| 288 | 288 | } |
@@ -292,12 +292,12 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | if (in_array($extension, array('html', 'htm'))) { |
| 294 | 294 | $filename = $file_info['basename']; |
| 295 | - $filename = str_replace('_',' ',$filename); |
|
| 295 | + $filename = str_replace('_', ' ', $filename); |
|
| 296 | 296 | |
| 297 | 297 | if ($extension == 'html') { |
| 298 | - $filename = basename($filename,'.html'); |
|
| 299 | - } elseif($extension == 'htm'){ |
|
| 300 | - $filename = basename($filename,'.htm'); |
|
| 298 | + $filename = basename($filename, '.html'); |
|
| 299 | + } elseif ($extension == 'htm') { |
|
| 300 | + $filename = basename($filename, '.htm'); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | $document_html = @file_get_contents($file); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $document_html = str_replace('href="./css/frames.css"', $absolute_css_path, $document_html); |
| 309 | 309 | |
| 310 | 310 | if (!empty($course_data['path'])) { |
| 311 | - $document_html= str_replace('../','', $document_html); |
|
| 311 | + $document_html = str_replace('../', '', $document_html); |
|
| 312 | 312 | $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/'; |
| 313 | 313 | |
| 314 | 314 | $doc = new DOMDocument(); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $new_path = $old_src; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $document_html= str_replace($old_src, $new_path, $document_html); |
|
| 343 | + $document_html = str_replace($old_src, $new_path, $document_html); |
|
| 344 | 344 | } |
| 345 | 345 | } else { |
| 346 | 346 | //Check if this is a complete URL |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | if (!empty($document_html)) { |
| 369 | 369 | $this->pdf->WriteHTML($document_html.$page_break, 2); |
| 370 | 370 | } |
| 371 | - } elseif (in_array($extension, array('jpg','jpeg','png','gif'))) { |
|
| 371 | + } elseif (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) { |
|
| 372 | 372 | //Images |
| 373 | 373 | $image = Display::img($file); |
| 374 | 374 | $this->pdf->WriteHTML('<html><body>'.$image.'</body></html>'.$page_break, 2); |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | //clean styles and javascript document |
| 420 | - $clean_search = array ( |
|
| 420 | + $clean_search = array( |
|
| 421 | 421 | '@<script[^>]*?>.*?</script>@si', |
| 422 | 422 | '@<style[^>]*?>.*?</style>@siU' |
| 423 | 423 | ); |
@@ -431,11 +431,11 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | //absolute path for frames.css //TODO: necessary? |
| 433 | 433 | $absolute_css_path = api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/frames.css'; |
| 434 | - $document_html = str_replace('href="./css/frames.css"','href="'.$absolute_css_path.'"', $document_html); |
|
| 434 | + $document_html = str_replace('href="./css/frames.css"', 'href="'.$absolute_css_path.'"', $document_html); |
|
| 435 | 435 | |
| 436 | - $document_html= str_replace('../../','',$document_html); |
|
| 437 | - $document_html= str_replace('../','',$document_html); |
|
| 438 | - $document_html= str_replace((empty($_configuration['url_append'])?'':$_configuration['url_append'].'/').'courses/'.$course_code.'/document/','',$document_html); |
|
| 436 | + $document_html = str_replace('../../', '', $document_html); |
|
| 437 | + $document_html = str_replace('../', '', $document_html); |
|
| 438 | + $document_html = str_replace((empty($_configuration['url_append']) ? '' : $_configuration['url_append'].'/').'courses/'.$course_code.'/document/', '', $document_html); |
|
| 439 | 439 | |
| 440 | 440 | if (!empty($course_data['path'])) { |
| 441 | 441 | $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/'; |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $old_src_fixed = str_replace('/courses/'.$course_data['path'].'/document/', '', $old_src); |
| 457 | 457 | $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed); |
| 458 | 458 | $new_path = $document_path.$old_src_fixed; |
| 459 | - $document_html= str_replace($old_src, $new_path, $document_html); |
|
| 459 | + $document_html = str_replace($old_src, $new_path, $document_html); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | //$document_html= str_replace('temp_template_path', 'src="/main/default_course_document/', $document_html);// restore src templates |
| 476 | 476 | |
| 477 | 477 | api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data. |
| 478 | - $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
| 478 | + $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
| 479 | 479 | // $_GET[] too, as it is done with file name. |
| 480 | 480 | // At the moment the title is retrieved from the html document itself. |
| 481 | 481 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | //$this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file |
| 498 | 498 | |
| 499 | 499 | if ($outputMode == 'F') { |
| 500 | - $output_file = api_get_path(SYS_ARCHIVE_PATH) . $output_file; |
|
| 500 | + $output_file = api_get_path(SYS_ARCHIVE_PATH).$output_file; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | if ($saveInFile) { |
@@ -530,14 +530,14 @@ discard block |
||
| 530 | 530 | $web_path = false; |
| 531 | 531 | if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') { |
| 532 | 532 | $course_info = api_get_course_info($course_code); |
| 533 | - $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 533 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 534 | 534 | if (file_exists($store_path)) { |
| 535 | - $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 535 | + $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 536 | 536 | } |
| 537 | 537 | } else { |
| 538 | - $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 538 | + $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 539 | 539 | if (file_exists($store_path)) |
| 540 | - $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 540 | + $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 541 | 541 | } |
| 542 | 542 | return $web_path; |
| 543 | 543 | } |
@@ -576,10 +576,10 @@ discard block |
||
| 576 | 576 | { |
| 577 | 577 | if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') { |
| 578 | 578 | $course_info = api_get_course_info($course_code); |
| 579 | - $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path |
|
| 579 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path |
|
| 580 | 580 | $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/pdf_watermark.png'; |
| 581 | 581 | } else { |
| 582 | - $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images'; // course path |
|
| 582 | + $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images'; // course path |
|
| 583 | 583 | $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
| 584 | 584 | } |
| 585 | 585 | $course_image = $store_path.'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
@@ -614,9 +614,9 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | public function set_footer() |
| 616 | 616 | { |
| 617 | - $this->pdf->defaultfooterfontsize = 12; // in pts |
|
| 618 | - $this->pdf->defaultfooterfontstyle = B; // blank, B, I, or BI |
|
| 619 | - $this->pdf->defaultfooterline = 1; // 1 to include line below header/above footer |
|
| 617 | + $this->pdf->defaultfooterfontsize = 12; // in pts |
|
| 618 | + $this->pdf->defaultfooterfontstyle = B; // blank, B, I, or BI |
|
| 619 | + $this->pdf->defaultfooterline = 1; // 1 to include line below header/above footer |
|
| 620 | 620 | $platform_name = api_get_setting('Institution'); |
| 621 | 621 | $left_content = $platform_name; |
| 622 | 622 | $center_content = ''; |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | */ |
| 683 | 683 | public function set_header($course_data) |
| 684 | 684 | { |
| 685 | - $this->pdf->defaultheaderfontsize = 10; // in pts |
|
| 686 | - $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
| 687 | - $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
| 685 | + $this->pdf->defaultheaderfontsize = 10; // in pts |
|
| 686 | + $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
| 687 | + $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
| 688 | 688 | |
| 689 | 689 | if (!empty($course_data['code'])) { |
| 690 | 690 | $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']); |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | if (!empty($teacher_list)) { |
| 694 | 694 | |
| 695 | 695 | foreach ($teacher_list as $teacher) { |
| 696 | - $teachers[]= $teacher['firstname'].' '.$teacher['lastname']; |
|
| 696 | + $teachers[] = $teacher['firstname'].' '.$teacher['lastname']; |
|
| 697 | 697 | } |
| 698 | 698 | if (count($teachers) > 1) { |
| 699 | 699 | $teachers = get_lang('Teachers').': '.implode(', ', $teachers); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | 'line' => 1, |
| 761 | 761 | ), |
| 762 | 762 | ); |
| 763 | - $this->pdf->SetHeader($header);// ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
| 763 | + $this->pdf->SetHeader($header); // ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | $this->pdf->directionality = api_get_text_direction(); |
| 806 | 806 | $this->pdf->useOnlyCoreFonts = true; |
| 807 | 807 | // Use different Odd/Even headers and footers and mirror margins |
| 808 | - $this->pdf->mirrorMargins = 1; |
|
| 808 | + $this->pdf->mirrorMargins = 1; |
|
| 809 | 809 | |
| 810 | 810 | // Add decoration only if not stated otherwise |
| 811 | 811 | if ($complete) { |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | $watermark_text = api_get_setting('pdf_export_watermark_text'); |
| 834 | 834 | } |
| 835 | 835 | if (!empty($watermark_text)) { |
| 836 | - $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1); |
|
| 836 | + $this->pdf->SetWatermarkText(strcode2utf($watermark_text), 0.1); |
|
| 837 | 837 | $this->pdf->showWatermarkText = true; |
| 838 | 838 | } |
| 839 | 839 | } |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | if (empty($this->custom_header)) { |
| 842 | 842 | self::set_header($course_data); |
| 843 | 843 | } else { |
| 844 | - $this->pdf->SetHTMLHeader($this->custom_header,'E'); |
|
| 845 | - $this->pdf->SetHTMLHeader($this->custom_header,'O'); |
|
| 844 | + $this->pdf->SetHTMLHeader($this->custom_header, 'E'); |
|
| 845 | + $this->pdf->SetHTMLHeader($this->custom_header, 'O'); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | if (empty($this->custom_footer)) { |
@@ -536,8 +536,9 @@ |
||
| 536 | 536 | } |
| 537 | 537 | } else { |
| 538 | 538 | $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
| 539 | - if (file_exists($store_path)) |
|
| 540 | - $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 539 | + if (file_exists($store_path)) { |
|
| 540 | + $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 541 | + } |
|
| 541 | 542 | } |
| 542 | 543 | return $web_path; |
| 543 | 544 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | * @author Patrick Cool |
| 17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
| 18 | 18 | * @package chamilo.link |
| 19 | - |
|
| 20 | 19 | */ |
| 21 | 20 | |
| 22 | 21 | // Including libraries |
@@ -264,6 +264,7 @@ discard block |
||
| 264 | 264 | * Set the encoding method |
| 265 | 265 | * |
| 266 | 266 | * @param string Encoding to use |
| 267 | + * @param string $encoding |
|
| 267 | 268 | * @access public |
| 268 | 269 | */ |
| 269 | 270 | function setOutputEncoding($encoding) |
@@ -924,6 +925,7 @@ discard block |
||
| 924 | 925 | * Check whether the current record read is a date |
| 925 | 926 | * |
| 926 | 927 | * @param todo |
| 928 | + * @param integer $spos |
|
| 927 | 929 | * @return boolean True if date, false otherwise |
| 928 | 930 | */ |
| 929 | 931 | function isDate($spos) |
@@ -982,6 +984,9 @@ discard block |
||
| 982 | 984 | return array($string, $raw); |
| 983 | 985 | } |
| 984 | 986 | |
| 987 | + /** |
|
| 988 | + * @param integer $spos |
|
| 989 | + */ |
|
| 985 | 990 | function createNumber($spos) |
| 986 | 991 | { |
| 987 | 992 | $rknumhigh = $this->_GetInt4d($this->data, $spos + 10); |
@@ -1000,6 +1005,10 @@ discard block |
||
| 1000 | 1005 | return $value; |
| 1001 | 1006 | } |
| 1002 | 1007 | |
| 1008 | + /** |
|
| 1009 | + * @param integer $row |
|
| 1010 | + * @param integer $col |
|
| 1011 | + */ |
|
| 1003 | 1012 | function addcell($row, $col, $string, $raw = '') |
| 1004 | 1013 | { |
| 1005 | 1014 | //echo "ADD cel $row-$col $string\n"; |
@@ -1014,6 +1023,9 @@ discard block |
||
| 1014 | 1023 | } |
| 1015 | 1024 | |
| 1016 | 1025 | |
| 1026 | + /** |
|
| 1027 | + * @param integer $rknum |
|
| 1028 | + */ |
|
| 1017 | 1029 | function _GetIEEE754($rknum) |
| 1018 | 1030 | { |
| 1019 | 1031 | if (($rknum & 0x02) != 0) { |
@@ -1051,6 +1063,10 @@ discard block |
||
| 1051 | 1063 | /* |
| 1052 | 1064 | * Function modified by jmontoya in order to fix a problem with encoding in excels |
| 1053 | 1065 | * */ |
| 1066 | + |
|
| 1067 | + /** |
|
| 1068 | + * @param string $string |
|
| 1069 | + */ |
|
| 1054 | 1070 | function _encodeUTF16($string, $check = false) { |
| 1055 | 1071 | //var_dump($this->_defaultEncoding.' '.$this->_encoderFunction.' '.$from); |
| 1056 | 1072 | if ($check) { |
@@ -1074,6 +1090,10 @@ discard block |
||
| 1074 | 1090 | */ |
| 1075 | 1091 | } |
| 1076 | 1092 | |
| 1093 | + /** |
|
| 1094 | + * @param string $data |
|
| 1095 | + * @param integer $pos |
|
| 1096 | + */ |
|
| 1077 | 1097 | function _GetInt4d($data, $pos) |
| 1078 | 1098 | { |
| 1079 | 1099 | $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); |
@@ -464,10 +464,10 @@ discard block |
||
| 464 | 464 | case SPREADSHEET_EXCEL_READER_TYPE_SST: |
| 465 | 465 | //echo "Type_SST\n"; |
| 466 | 466 | $spos = $pos + 4; |
| 467 | - $limitpos = $spos + $length; |
|
| 468 | - $uniqueStrings = $this->_GetInt4d($this->data, $spos+4); |
|
| 467 | + $limitpos = $spos + $length; |
|
| 468 | + $uniqueStrings = $this->_GetInt4d($this->data, $spos+4); |
|
| 469 | 469 | $spos += 8; |
| 470 | - for ($i = 0; $i < $uniqueStrings; $i++) { |
|
| 470 | + for ($i = 0; $i < $uniqueStrings; $i++) { |
|
| 471 | 471 | // Read in the number of characters |
| 472 | 472 | if ($spos == $limitpos) { |
| 473 | 473 | $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
@@ -496,9 +496,9 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | if ($extendedString) { |
| 499 | - // Read in cchExtRst |
|
| 500 | - $extendedRunLength = $this->_GetInt4d($this->data, $spos); |
|
| 501 | - $spos += 4; |
|
| 499 | + // Read in cchExtRst |
|
| 500 | + $extendedRunLength = $this->_GetInt4d($this->data, $spos); |
|
| 501 | + $spos += 4; |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | $len = ($asciiEncoding)? $numChars : $numChars*2; |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2)); |
| 513 | 513 | $spos = $limitpos; |
| 514 | 514 | |
| 515 | - while ($charsLeft > 0){ |
|
| 515 | + while ($charsLeft > 0){ |
|
| 516 | 516 | $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
| 517 | 517 | $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
| 518 | 518 | if ($opcode != 0x3c) { |
@@ -522,29 +522,29 @@ discard block |
||
| 522 | 522 | $limitpos = $spos + $conlength; |
| 523 | 523 | $option = ord($this->data[$spos]); |
| 524 | 524 | $spos += 1; |
| 525 | - if ($asciiEncoding && ($option == 0)) { |
|
| 525 | + if ($asciiEncoding && ($option == 0)) { |
|
| 526 | 526 | $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength); |
| 527 | 527 | $retstr .= substr($this->data, $spos, $len); |
| 528 | 528 | $charsLeft -= $len; |
| 529 | 529 | $asciiEncoding = true; |
| 530 | - }elseif (!$asciiEncoding && ($option != 0)){ |
|
| 530 | + }elseif (!$asciiEncoding && ($option != 0)){ |
|
| 531 | 531 | $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); |
| 532 | 532 | $retstr .= substr($this->data, $spos, $len); |
| 533 | 533 | $charsLeft -= $len/2; |
| 534 | 534 | $asciiEncoding = false; |
| 535 | - }elseif (!$asciiEncoding && ($option == 0)) { |
|
| 535 | + }elseif (!$asciiEncoding && ($option == 0)) { |
|
| 536 | 536 | // Bummer - the string starts off as Unicode, but after the |
| 537 | 537 | // continuation it is in straightforward ASCII encoding |
| 538 | 538 | $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength); |
| 539 | 539 | for ($j = 0; $j < $len; $j++) { |
| 540 | - $retstr .= $this->data[$spos + $j].chr(0); |
|
| 540 | + $retstr .= $this->data[$spos + $j].chr(0); |
|
| 541 | 541 | } |
| 542 | 542 | $charsLeft -= $len; |
| 543 | 543 | $asciiEncoding = false; |
| 544 | - }else{ |
|
| 544 | + }else{ |
|
| 545 | 545 | $newstr = ''; |
| 546 | 546 | for ($j = 0; $j < strlen($retstr); $j++) { |
| 547 | - $newstr = $retstr[$j].chr(0); |
|
| 547 | + $newstr = $retstr[$j].chr(0); |
|
| 548 | 548 | } |
| 549 | 549 | $retstr = $newstr; |
| 550 | 550 | $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); |
@@ -552,28 +552,28 @@ discard block |
||
| 552 | 552 | $charsLeft -= $len/2; |
| 553 | 553 | $asciiEncoding = false; |
| 554 | 554 | //echo "Izavrat\n"; |
| 555 | - } |
|
| 556 | - $spos += $len; |
|
| 555 | + } |
|
| 556 | + $spos += $len; |
|
| 557 | 557 | |
| 558 | - } |
|
| 558 | + } |
|
| 559 | 559 | } |
| 560 | 560 | //We check the string before send it check the _encodeUTF16 |
| 561 | 561 | //$retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr); |
| 562 | 562 | $retstr = ($asciiEncoding) ? $this->_encodeUTF16($retstr, true) : $this->_encodeUTF16($retstr); |
| 563 | 563 | // echo "Str $i = $retstr\n"; |
| 564 | 564 | if ($richString){ |
| 565 | - $spos += 4 * $formattingRuns; |
|
| 565 | + $spos += 4 * $formattingRuns; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | // For extended strings, skip over the extended string data |
| 569 | 569 | if ($extendedString) { |
| 570 | - $spos += $extendedRunLength; |
|
| 570 | + $spos += $extendedRunLength; |
|
| 571 | 571 | } |
| 572 | 572 | //if ($retstr == 'Derby'){ |
| 573 | 573 | // echo "bb\n"; |
| 574 | 574 | //} |
| 575 | 575 | $this->sst[]=$retstr; |
| 576 | - } |
|
| 576 | + } |
|
| 577 | 577 | /*$continueRecords = array(); |
| 578 | 578 | while ($this->getNextCode() == Type_CONTINUE) { |
| 579 | 579 | $continueRecords[] = &$this->nextRecord(); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | $this->shareStrings = new SSTRecord($r, $continueRecords); |
| 583 | 583 | //print_r($this->shareStrings->strings); |
| 584 | 584 | */ |
| 585 | - // echo 'SST read: '.($time_end-$time_start)."\n"; |
|
| 585 | + // echo 'SST read: '.($time_end-$time_start)."\n"; |
|
| 586 | 586 | break; |
| 587 | 587 | |
| 588 | 588 | case SPREADSHEET_EXCEL_READER_TYPE_FILEPASS: |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | $this->formatRecords[$indexCode] = $formatString; |
| 610 | - // echo "Type.FORMAT\n"; |
|
| 610 | + // echo "Type.FORMAT\n"; |
|
| 611 | 611 | break; |
| 612 | 612 | case SPREADSHEET_EXCEL_READER_TYPE_XF: |
| 613 | 613 | //global $dateFormats, $numberFormats; |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | $rec_name = substr($this->data, $pos+11, $rec_length); |
| 679 | 679 | } |
| 680 | 680 | $this->boundsheets[] = array('name'=>$rec_name, |
| 681 | - 'offset'=>$rec_offset); |
|
| 681 | + 'offset'=>$rec_offset); |
|
| 682 | 682 | |
| 683 | 683 | break; |
| 684 | 684 | |
@@ -820,14 +820,14 @@ discard block |
||
| 820 | 820 | } |
| 821 | 821 | $string = sprintf($this->curformat, $numValue * $this->multiplier); |
| 822 | 822 | } |
| 823 | - //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8; |
|
| 824 | - $tmppos += 6; |
|
| 825 | - $this->addcell($row, $colFirst + $i, $string, $raw); |
|
| 826 | - //echo "MULRK $row ".($colFirst + $i)." $string\n"; |
|
| 823 | + //$rec['rknumbers'][$i]['xfindex'] = ord($rec['data'][$pos]) | ord($rec['data'][$pos+1]) << 8; |
|
| 824 | + $tmppos += 6; |
|
| 825 | + $this->addcell($row, $colFirst + $i, $string, $raw); |
|
| 826 | + //echo "MULRK $row ".($colFirst + $i)." $string\n"; |
|
| 827 | 827 | } |
| 828 | - //MulRKRecord($r); |
|
| 828 | + //MulRKRecord($r); |
|
| 829 | 829 | // Get the individual cell records from the multiple record |
| 830 | - //$num = ; |
|
| 830 | + //$num = ; |
|
| 831 | 831 | |
| 832 | 832 | break; |
| 833 | 833 | case SPREADSHEET_EXCEL_READER_TYPE_NUMBER: |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent |
| 837 | 837 | if ($this->isDate($spos)) { |
| 838 | 838 | list($string, $raw) = $this->createDate($tmp['double']); |
| 839 | - // $this->addcell(DateRecord($r, 1)); |
|
| 839 | + // $this->addcell(DateRecord($r, 1)); |
|
| 840 | 840 | }else{ |
| 841 | 841 | //$raw = $tmp['']; |
| 842 | 842 | if (isset($this->_columnsFormat[$column + 1])){ |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | $raw = $this->createNumber($spos); |
| 846 | 846 | $string = sprintf($this->curformat, $raw * $this->multiplier); |
| 847 | 847 | |
| 848 | - // $this->addcell(NumberRecord($r)); |
|
| 848 | + // $this->addcell(NumberRecord($r)); |
|
| 849 | 849 | } |
| 850 | 850 | $this->addcell($row, $column, $string, $raw); |
| 851 | 851 | //echo "Number $row $column $string\n"; |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent |
| 869 | 869 | if ($this->isDate($spos)) { |
| 870 | 870 | list($string, $raw) = $this->createDate($tmp['double']); |
| 871 | - // $this->addcell(DateRecord($r, 1)); |
|
| 871 | + // $this->addcell(DateRecord($r, 1)); |
|
| 872 | 872 | }else{ |
| 873 | 873 | //$raw = $tmp['']; |
| 874 | 874 | if (isset($this->_columnsFormat[$column + 1])){ |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | $raw = $this->createNumber($spos); |
| 878 | 878 | $string = sprintf($this->curformat, $raw * $this->multiplier); |
| 879 | 879 | |
| 880 | - // $this->addcell(NumberRecord($r)); |
|
| 880 | + // $this->addcell(NumberRecord($r)); |
|
| 881 | 881 | } |
| 882 | 882 | $this->addcell($row, $column, $string, $raw); |
| 883 | 883 | //echo "Number $row $column $string\n"; |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
| 900 | 900 | $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8)); |
| 901 | 901 | |
| 902 | - // $this->addcell(LabelRecord($r)); |
|
| 902 | + // $this->addcell(LabelRecord($r)); |
|
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | 905 | case SPREADSHEET_EXCEL_READER_TYPE_EOF: |
@@ -914,9 +914,9 @@ discard block |
||
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | if (!isset($this->sheets[$this->sn]['numRows'])) |
| 917 | - $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow']; |
|
| 917 | + $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow']; |
|
| 918 | 918 | if (!isset($this->sheets[$this->sn]['numCols'])) |
| 919 | - $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol']; |
|
| 919 | + $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol']; |
|
| 920 | 920 | |
| 921 | 921 | } |
| 922 | 922 | |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | // The RK format calls for using only the most significant 30 bits of the |
| 1034 | 1034 | // 64 bit floating point value. The other 34 bits are assumed to be 0 |
| 1035 | 1035 | // So, we use the upper 30 bits of $rknum as follows... |
| 1036 | - $sign = ($rknum & 0x80000000) >> 31; |
|
| 1036 | + $sign = ($rknum & 0x80000000) >> 31; |
|
| 1037 | 1037 | $exp = ($rknum & 0x7ff00000) >> 20; |
| 1038 | 1038 | $mantissa = (0x100000 | ($rknum & 0x000ffffc)); |
| 1039 | 1039 | $value = $mantissa / pow( 2 , (20- ($exp - 1023))); |
@@ -25,50 +25,50 @@ discard block |
||
| 25 | 25 | * @see OLE, Spreadsheet_Excel_Writer |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | -define('SPREADSHEET_EXCEL_READER_BIFF8', 0x600); |
|
| 29 | -define('SPREADSHEET_EXCEL_READER_BIFF7', 0x500); |
|
| 30 | -define('SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS', 0x5); |
|
| 31 | -define('SPREADSHEET_EXCEL_READER_WORKSHEET', 0x10); |
|
| 32 | - |
|
| 33 | -define('SPREADSHEET_EXCEL_READER_TYPE_BOF', 0x809); |
|
| 34 | -define('SPREADSHEET_EXCEL_READER_TYPE_EOF', 0x0a); |
|
| 35 | -define('SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET', 0x85); |
|
| 36 | -define('SPREADSHEET_EXCEL_READER_TYPE_DIMENSION', 0x200); |
|
| 37 | -define('SPREADSHEET_EXCEL_READER_TYPE_ROW', 0x208); |
|
| 38 | -define('SPREADSHEET_EXCEL_READER_TYPE_DBCELL', 0xd7); |
|
| 39 | -define('SPREADSHEET_EXCEL_READER_TYPE_FILEPASS', 0x2f); |
|
| 40 | -define('SPREADSHEET_EXCEL_READER_TYPE_NOTE', 0x1c); |
|
| 41 | -define('SPREADSHEET_EXCEL_READER_TYPE_TXO', 0x1b6); |
|
| 42 | -define('SPREADSHEET_EXCEL_READER_TYPE_RK', 0x7e); |
|
| 43 | -define('SPREADSHEET_EXCEL_READER_TYPE_RK2', 0x27e); |
|
| 44 | -define('SPREADSHEET_EXCEL_READER_TYPE_MULRK', 0xbd); |
|
| 45 | -define('SPREADSHEET_EXCEL_READER_TYPE_MULBLANK', 0xbe); |
|
| 46 | -define('SPREADSHEET_EXCEL_READER_TYPE_INDEX', 0x20b); |
|
| 47 | -define('SPREADSHEET_EXCEL_READER_TYPE_SST', 0xfc); |
|
| 48 | -define('SPREADSHEET_EXCEL_READER_TYPE_EXTSST', 0xff); |
|
| 49 | -define('SPREADSHEET_EXCEL_READER_TYPE_CONTINUE', 0x3c); |
|
| 50 | -define('SPREADSHEET_EXCEL_READER_TYPE_LABEL', 0x204); |
|
| 51 | -define('SPREADSHEET_EXCEL_READER_TYPE_LABELSST', 0xfd); |
|
| 52 | -define('SPREADSHEET_EXCEL_READER_TYPE_NUMBER', 0x203); |
|
| 53 | -define('SPREADSHEET_EXCEL_READER_TYPE_NAME', 0x18); |
|
| 54 | -define('SPREADSHEET_EXCEL_READER_TYPE_ARRAY', 0x221); |
|
| 55 | -define('SPREADSHEET_EXCEL_READER_TYPE_STRING', 0x207); |
|
| 56 | -define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA', 0x406); |
|
| 57 | -define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA2', 0x6); |
|
| 58 | -define('SPREADSHEET_EXCEL_READER_TYPE_FORMAT', 0x41e); |
|
| 59 | -define('SPREADSHEET_EXCEL_READER_TYPE_XF', 0xe0); |
|
| 60 | -define('SPREADSHEET_EXCEL_READER_TYPE_BOOLERR', 0x205); |
|
| 61 | -define('SPREADSHEET_EXCEL_READER_TYPE_UNKNOWN', 0xffff); |
|
| 28 | +define('SPREADSHEET_EXCEL_READER_BIFF8', 0x600); |
|
| 29 | +define('SPREADSHEET_EXCEL_READER_BIFF7', 0x500); |
|
| 30 | +define('SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS', 0x5); |
|
| 31 | +define('SPREADSHEET_EXCEL_READER_WORKSHEET', 0x10); |
|
| 32 | + |
|
| 33 | +define('SPREADSHEET_EXCEL_READER_TYPE_BOF', 0x809); |
|
| 34 | +define('SPREADSHEET_EXCEL_READER_TYPE_EOF', 0x0a); |
|
| 35 | +define('SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET', 0x85); |
|
| 36 | +define('SPREADSHEET_EXCEL_READER_TYPE_DIMENSION', 0x200); |
|
| 37 | +define('SPREADSHEET_EXCEL_READER_TYPE_ROW', 0x208); |
|
| 38 | +define('SPREADSHEET_EXCEL_READER_TYPE_DBCELL', 0xd7); |
|
| 39 | +define('SPREADSHEET_EXCEL_READER_TYPE_FILEPASS', 0x2f); |
|
| 40 | +define('SPREADSHEET_EXCEL_READER_TYPE_NOTE', 0x1c); |
|
| 41 | +define('SPREADSHEET_EXCEL_READER_TYPE_TXO', 0x1b6); |
|
| 42 | +define('SPREADSHEET_EXCEL_READER_TYPE_RK', 0x7e); |
|
| 43 | +define('SPREADSHEET_EXCEL_READER_TYPE_RK2', 0x27e); |
|
| 44 | +define('SPREADSHEET_EXCEL_READER_TYPE_MULRK', 0xbd); |
|
| 45 | +define('SPREADSHEET_EXCEL_READER_TYPE_MULBLANK', 0xbe); |
|
| 46 | +define('SPREADSHEET_EXCEL_READER_TYPE_INDEX', 0x20b); |
|
| 47 | +define('SPREADSHEET_EXCEL_READER_TYPE_SST', 0xfc); |
|
| 48 | +define('SPREADSHEET_EXCEL_READER_TYPE_EXTSST', 0xff); |
|
| 49 | +define('SPREADSHEET_EXCEL_READER_TYPE_CONTINUE', 0x3c); |
|
| 50 | +define('SPREADSHEET_EXCEL_READER_TYPE_LABEL', 0x204); |
|
| 51 | +define('SPREADSHEET_EXCEL_READER_TYPE_LABELSST', 0xfd); |
|
| 52 | +define('SPREADSHEET_EXCEL_READER_TYPE_NUMBER', 0x203); |
|
| 53 | +define('SPREADSHEET_EXCEL_READER_TYPE_NAME', 0x18); |
|
| 54 | +define('SPREADSHEET_EXCEL_READER_TYPE_ARRAY', 0x221); |
|
| 55 | +define('SPREADSHEET_EXCEL_READER_TYPE_STRING', 0x207); |
|
| 56 | +define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA', 0x406); |
|
| 57 | +define('SPREADSHEET_EXCEL_READER_TYPE_FORMULA2', 0x6); |
|
| 58 | +define('SPREADSHEET_EXCEL_READER_TYPE_FORMAT', 0x41e); |
|
| 59 | +define('SPREADSHEET_EXCEL_READER_TYPE_XF', 0xe0); |
|
| 60 | +define('SPREADSHEET_EXCEL_READER_TYPE_BOOLERR', 0x205); |
|
| 61 | +define('SPREADSHEET_EXCEL_READER_TYPE_UNKNOWN', 0xffff); |
|
| 62 | 62 | define('SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR', 0x22); |
| 63 | -define('SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS', 0xE5); |
|
| 63 | +define('SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS', 0xE5); |
|
| 64 | 64 | |
| 65 | -define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS' , 25569); |
|
| 65 | +define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS', 25569); |
|
| 66 | 66 | define('SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904', 24107); |
| 67 | -define('SPREADSHEET_EXCEL_READER_MSINADAY', 86400); |
|
| 67 | +define('SPREADSHEET_EXCEL_READER_MSINADAY', 86400); |
|
| 68 | 68 | //define('SPREADSHEET_EXCEL_READER_MSINADAY', 24 * 60 * 60); |
| 69 | 69 | |
| 70 | 70 | //define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%.2f"); |
| 71 | -define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%s"); |
|
| 71 | +define('SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%s"); |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | /* |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @var array |
| 202 | 202 | * @access public |
| 203 | 203 | */ |
| 204 | - var $dateFormats = array ( |
|
| 204 | + var $dateFormats = array( |
|
| 205 | 205 | 0xe => "d/m/Y", |
| 206 | 206 | 0xf => "d-M-Y", |
| 207 | 207 | 0x10 => "d-M", |
@@ -222,26 +222,26 @@ discard block |
||
| 222 | 222 | * @access public |
| 223 | 223 | */ |
| 224 | 224 | var $numberFormats = array( |
| 225 | - 0x1 => "%1.0f", // "0" |
|
| 226 | - 0x2 => "%1.2f", // "0.00", |
|
| 227 | - 0x3 => "%1.0f", //"#,##0", |
|
| 228 | - 0x4 => "%1.2f", //"#,##0.00", |
|
| 229 | - 0x5 => "%1.0f", /*"$#,##0;($#,##0)",*/ |
|
| 230 | - 0x6 => '$%1.0f', /*"$#,##0;($#,##0)",*/ |
|
| 231 | - 0x7 => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 232 | - 0x8 => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 233 | - 0x9 => '%1.0f%%', // "0%" |
|
| 234 | - 0xa => '%1.2f%%', // "0.00%" |
|
| 235 | - 0xb => '%1.2f', // 0.00E00", |
|
| 236 | - 0x25 => '%1.0f', // "#,##0;(#,##0)", |
|
| 237 | - 0x26 => '%1.0f', //"#,##0;(#,##0)", |
|
| 238 | - 0x27 => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 239 | - 0x28 => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 240 | - 0x29 => '%1.0f', //"#,##0;(#,##0)", |
|
| 241 | - 0x2a => '$%1.0f', //"$#,##0;($#,##0)", |
|
| 242 | - 0x2b => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 243 | - 0x2c => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 244 | - 0x30 => '%1.0f'); //"##0.0E0"; |
|
| 225 | + 0x1 => "%1.0f", // "0" |
|
| 226 | + 0x2 => "%1.2f", // "0.00", |
|
| 227 | + 0x3 => "%1.0f", //"#,##0", |
|
| 228 | + 0x4 => "%1.2f", //"#,##0.00", |
|
| 229 | + 0x5 => "%1.0f", /*"$#,##0;($#,##0)",*/ |
|
| 230 | + 0x6 => '$%1.0f', /*"$#,##0;($#,##0)",*/ |
|
| 231 | + 0x7 => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 232 | + 0x8 => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 233 | + 0x9 => '%1.0f%%', // "0%" |
|
| 234 | + 0xa => '%1.2f%%', // "0.00%" |
|
| 235 | + 0xb => '%1.2f', // 0.00E00", |
|
| 236 | + 0x25 => '%1.0f', // "#,##0;(#,##0)", |
|
| 237 | + 0x26 => '%1.0f', //"#,##0;(#,##0)", |
|
| 238 | + 0x27 => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 239 | + 0x28 => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 240 | + 0x29 => '%1.0f', //"#,##0;(#,##0)", |
|
| 241 | + 0x2a => '$%1.0f', //"$#,##0;($#,##0)", |
|
| 242 | + 0x2b => '%1.2f', //"#,##0.00;(#,##0.00)", |
|
| 243 | + 0x2c => '$%1.2f', //"$#,##0.00;($#,##0.00)", |
|
| 244 | + 0x30 => '%1.0f'); //"##0.0E0"; |
|
| 245 | 245 | |
| 246 | 246 | // }}} |
| 247 | 247 | // {{{ Spreadsheet_Excel_Reader() |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | function Spreadsheet_Excel_Reader() |
| 255 | 255 | { |
| 256 | - $this->_ole =& new OLERead(); |
|
| 256 | + $this->_ole = & new OLERead(); |
|
| 257 | 257 | $this->setUTFEncoder('iconv'); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -290,8 +290,7 @@ discard block |
||
| 290 | 290 | $this->_encoderFunction = function_exists('iconv') ? 'iconv' : ''; |
| 291 | 291 | } elseif ($encoder == 'mb') { |
| 292 | 292 | $this->_encoderFunction = function_exists('mb_convert_encoding') ? |
| 293 | - 'mb_convert_encoding' : |
|
| 294 | - ''; |
|
| 293 | + 'mb_convert_encoding' : ''; |
|
| 295 | 294 | } |
| 296 | 295 | } |
| 297 | 296 | |
@@ -376,9 +375,9 @@ discard block |
||
| 376 | 375 | $res = $this->_ole->read($sFileName); |
| 377 | 376 | |
| 378 | 377 | // oops, something goes wrong (Darko Miljanovic) |
| 379 | - if($res === false) { |
|
| 378 | + if ($res === false) { |
|
| 380 | 379 | // check error code |
| 381 | - if($this->_ole->error == 1) { |
|
| 380 | + if ($this->_ole->error == 1) { |
|
| 382 | 381 | // bad file |
| 383 | 382 | //die('The filename ' . $sFileName . ' is not readable'); |
| 384 | 383 | Display::display_header(''); |
@@ -437,11 +436,11 @@ discard block |
||
| 437 | 436 | { |
| 438 | 437 | $pos = 0; |
| 439 | 438 | |
| 440 | - $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; |
|
| 441 | - $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; |
|
| 439 | + $code = ord($this->data[$pos]) | ord($this->data[$pos + 1]) << 8; |
|
| 440 | + $length = ord($this->data[$pos + 2]) | ord($this->data[$pos + 3]) << 8; |
|
| 442 | 441 | |
| 443 | - $version = ord($this->data[$pos + 4]) | ord($this->data[$pos + 5])<<8; |
|
| 444 | - $substreamType = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7])<<8; |
|
| 442 | + $version = ord($this->data[$pos + 4]) | ord($this->data[$pos + 5]) << 8; |
|
| 443 | + $substreamType = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7]) << 8; |
|
| 445 | 444 | //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n"; |
| 446 | 445 | |
| 447 | 446 | if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && |
@@ -449,15 +448,15 @@ discard block |
||
| 449 | 448 | return false; |
| 450 | 449 | } |
| 451 | 450 | |
| 452 | - if ($substreamType != SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS){ |
|
| 451 | + if ($substreamType != SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS) { |
|
| 453 | 452 | return false; |
| 454 | 453 | } |
| 455 | 454 | |
| 456 | 455 | //print_r($rec); |
| 457 | 456 | $pos += $length + 4; |
| 458 | 457 | |
| 459 | - $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; |
|
| 460 | - $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; |
|
| 458 | + $code = ord($this->data[$pos]) | ord($this->data[$pos + 1]) << 8; |
|
| 459 | + $length = ord($this->data[$pos + 2]) | ord($this->data[$pos + 3]) << 8; |
|
| 461 | 460 | |
| 462 | 461 | while ($code != SPREADSHEET_EXCEL_READER_TYPE_EOF) { |
| 463 | 462 | switch ($code) { |
@@ -465,33 +464,33 @@ discard block |
||
| 465 | 464 | //echo "Type_SST\n"; |
| 466 | 465 | $spos = $pos + 4; |
| 467 | 466 | $limitpos = $spos + $length; |
| 468 | - $uniqueStrings = $this->_GetInt4d($this->data, $spos+4); |
|
| 467 | + $uniqueStrings = $this->_GetInt4d($this->data, $spos + 4); |
|
| 469 | 468 | $spos += 8; |
| 470 | 469 | for ($i = 0; $i < $uniqueStrings; $i++) { |
| 471 | 470 | // Read in the number of characters |
| 472 | 471 | if ($spos == $limitpos) { |
| 473 | - $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 474 | - $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 472 | + $opcode = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 473 | + $conlength = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 475 | 474 | if ($opcode != 0x3c) { |
| 476 | 475 | return -1; |
| 477 | 476 | } |
| 478 | 477 | $spos += 4; |
| 479 | 478 | $limitpos = $spos + $conlength; |
| 480 | 479 | } |
| 481 | - $numChars = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8); |
|
| 480 | + $numChars = ord($this->data[$spos]) | (ord($this->data[$spos + 1]) << 8); |
|
| 482 | 481 | //echo "i = $i pos = $pos numChars = $numChars "; |
| 483 | 482 | $spos += 2; |
| 484 | 483 | $optionFlags = ord($this->data[$spos]); |
| 485 | 484 | $spos++; |
| 486 | - $asciiEncoding = (($optionFlags & 0x01) == 0) ; |
|
| 487 | - $extendedString = ( ($optionFlags & 0x04) != 0); |
|
| 485 | + $asciiEncoding = (($optionFlags & 0x01) == 0); |
|
| 486 | + $extendedString = (($optionFlags & 0x04) != 0); |
|
| 488 | 487 | |
| 489 | 488 | // See if string contains formatting information |
| 490 | - $richString = ( ($optionFlags & 0x08) != 0); |
|
| 489 | + $richString = (($optionFlags & 0x08) != 0); |
|
| 491 | 490 | |
| 492 | 491 | if ($richString) { |
| 493 | 492 | // Read in the crun |
| 494 | - $formattingRuns = ord($this->data[$spos]) | (ord($this->data[$spos+1]) << 8); |
|
| 493 | + $formattingRuns = ord($this->data[$spos]) | (ord($this->data[$spos + 1]) << 8); |
|
| 495 | 494 | $spos += 2; |
| 496 | 495 | } |
| 497 | 496 | |
@@ -501,20 +500,20 @@ discard block |
||
| 501 | 500 | $spos += 4; |
| 502 | 501 | } |
| 503 | 502 | |
| 504 | - $len = ($asciiEncoding)? $numChars : $numChars*2; |
|
| 503 | + $len = ($asciiEncoding) ? $numChars : $numChars * 2; |
|
| 505 | 504 | if ($spos + $len < $limitpos) { |
| 506 | 505 | $retstr = substr($this->data, $spos, $len); |
| 507 | 506 | $spos += $len; |
| 508 | - }else{ |
|
| 507 | + } else { |
|
| 509 | 508 | // found countinue |
| 510 | 509 | $retstr = substr($this->data, $spos, $limitpos - $spos); |
| 511 | 510 | $bytesRead = $limitpos - $spos; |
| 512 | 511 | $charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2)); |
| 513 | 512 | $spos = $limitpos; |
| 514 | 513 | |
| 515 | - while ($charsLeft > 0){ |
|
| 516 | - $opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 517 | - $conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 514 | + while ($charsLeft > 0) { |
|
| 515 | + $opcode = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 516 | + $conlength = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 518 | 517 | if ($opcode != 0x3c) { |
| 519 | 518 | return -1; |
| 520 | 519 | } |
@@ -527,10 +526,10 @@ discard block |
||
| 527 | 526 | $retstr .= substr($this->data, $spos, $len); |
| 528 | 527 | $charsLeft -= $len; |
| 529 | 528 | $asciiEncoding = true; |
| 530 | - }elseif (!$asciiEncoding && ($option != 0)){ |
|
| 529 | + }elseif (!$asciiEncoding && ($option != 0)) { |
|
| 531 | 530 | $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); |
| 532 | 531 | $retstr .= substr($this->data, $spos, $len); |
| 533 | - $charsLeft -= $len/2; |
|
| 532 | + $charsLeft -= $len / 2; |
|
| 534 | 533 | $asciiEncoding = false; |
| 535 | 534 | }elseif (!$asciiEncoding && ($option == 0)) { |
| 536 | 535 | // Bummer - the string starts off as Unicode, but after the |
@@ -541,7 +540,7 @@ discard block |
||
| 541 | 540 | } |
| 542 | 541 | $charsLeft -= $len; |
| 543 | 542 | $asciiEncoding = false; |
| 544 | - }else{ |
|
| 543 | + } else { |
|
| 545 | 544 | $newstr = ''; |
| 546 | 545 | for ($j = 0; $j < strlen($retstr); $j++) { |
| 547 | 546 | $newstr = $retstr[$j].chr(0); |
@@ -549,7 +548,7 @@ discard block |
||
| 549 | 548 | $retstr = $newstr; |
| 550 | 549 | $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); |
| 551 | 550 | $retstr .= substr($this->data, $spos, $len); |
| 552 | - $charsLeft -= $len/2; |
|
| 551 | + $charsLeft -= $len / 2; |
|
| 553 | 552 | $asciiEncoding = false; |
| 554 | 553 | //echo "Izavrat\n"; |
| 555 | 554 | } |
@@ -561,7 +560,7 @@ discard block |
||
| 561 | 560 | //$retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr); |
| 562 | 561 | $retstr = ($asciiEncoding) ? $this->_encodeUTF16($retstr, true) : $this->_encodeUTF16($retstr); |
| 563 | 562 | // echo "Str $i = $retstr\n"; |
| 564 | - if ($richString){ |
|
| 563 | + if ($richString) { |
|
| 565 | 564 | $spos += 4 * $formattingRuns; |
| 566 | 565 | } |
| 567 | 566 | |
@@ -572,7 +571,7 @@ discard block |
||
| 572 | 571 | //if ($retstr == 'Derby'){ |
| 573 | 572 | // echo "bb\n"; |
| 574 | 573 | //} |
| 575 | - $this->sst[]=$retstr; |
|
| 574 | + $this->sst[] = $retstr; |
|
| 576 | 575 | } |
| 577 | 576 | /*$continueRecords = array(); |
| 578 | 577 | while ($this->getNextCode() == Type_CONTINUE) { |
@@ -592,18 +591,18 @@ discard block |
||
| 592 | 591 | //echo "Type_NAME\n"; |
| 593 | 592 | break; |
| 594 | 593 | case SPREADSHEET_EXCEL_READER_TYPE_FORMAT: |
| 595 | - $indexCode = ord($this->data[$pos+4]) | ord($this->data[$pos+5]) << 8; |
|
| 594 | + $indexCode = ord($this->data[$pos + 4]) | ord($this->data[$pos + 5]) << 8; |
|
| 596 | 595 | |
| 597 | 596 | if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { |
| 598 | - $numchars = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8; |
|
| 599 | - if (ord($this->data[$pos+8]) == 0){ |
|
| 600 | - $formatString = substr($this->data, $pos+9, $numchars); |
|
| 597 | + $numchars = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7]) << 8; |
|
| 598 | + if (ord($this->data[$pos + 8]) == 0) { |
|
| 599 | + $formatString = substr($this->data, $pos + 9, $numchars); |
|
| 601 | 600 | } else { |
| 602 | - $formatString = substr($this->data, $pos+9, $numchars*2); |
|
| 601 | + $formatString = substr($this->data, $pos + 9, $numchars * 2); |
|
| 603 | 602 | } |
| 604 | 603 | } else { |
| 605 | - $numchars = ord($this->data[$pos+6]); |
|
| 606 | - $formatString = substr($this->data, $pos+7, $numchars*2); |
|
| 604 | + $numchars = ord($this->data[$pos + 6]); |
|
| 605 | + $formatString = substr($this->data, $pos + 7, $numchars * 2); |
|
| 607 | 606 | } |
| 608 | 607 | |
| 609 | 608 | $this->formatRecords[$indexCode] = $formatString; |
@@ -611,7 +610,7 @@ discard block |
||
| 611 | 610 | break; |
| 612 | 611 | case SPREADSHEET_EXCEL_READER_TYPE_XF: |
| 613 | 612 | //global $dateFormats, $numberFormats; |
| 614 | - $indexCode = ord($this->data[$pos+6]) | ord($this->data[$pos+7]) << 8; |
|
| 613 | + $indexCode = ord($this->data[$pos + 6]) | ord($this->data[$pos + 7]) << 8; |
|
| 615 | 614 | //echo "\nType.XF ".count($this->formatRecords['xfrecords'])." $indexCode "; |
| 616 | 615 | if (array_key_exists($indexCode, $this->dateFormats)) { |
| 617 | 616 | //echo "isdate ".$dateFormats[$indexCode]; |
@@ -625,9 +624,9 @@ discard block |
||
| 625 | 624 | 'type' => 'number', |
| 626 | 625 | 'format' => $this->numberFormats[$indexCode] |
| 627 | 626 | ); |
| 628 | - }else{ |
|
| 627 | + } else { |
|
| 629 | 628 | $isdate = FALSE; |
| 630 | - if ($indexCode > 0){ |
|
| 629 | + if ($indexCode > 0) { |
|
| 631 | 630 | if (isset($this->formatRecords[$indexCode])) |
| 632 | 631 | $formatstr = $this->formatRecords[$indexCode]; |
| 633 | 632 | //echo '.other.'; |
@@ -641,12 +640,12 @@ discard block |
||
| 641 | 640 | } |
| 642 | 641 | } |
| 643 | 642 | |
| 644 | - if ($isdate){ |
|
| 643 | + if ($isdate) { |
|
| 645 | 644 | $this->formatRecords['xfrecords'][] = array( |
| 646 | 645 | 'type' => 'date', |
| 647 | 646 | 'format' => $formatstr, |
| 648 | 647 | ); |
| 649 | - }else{ |
|
| 648 | + } else { |
|
| 650 | 649 | $this->formatRecords['xfrecords'][] = array( |
| 651 | 650 | 'type' => 'other', |
| 652 | 651 | 'format' => '', |
@@ -658,24 +657,24 @@ discard block |
||
| 658 | 657 | break; |
| 659 | 658 | case SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR: |
| 660 | 659 | //echo "Type.NINETEENFOUR\n"; |
| 661 | - $this->nineteenFour = (ord($this->data[$pos+4]) == 1); |
|
| 660 | + $this->nineteenFour = (ord($this->data[$pos + 4]) == 1); |
|
| 662 | 661 | break; |
| 663 | 662 | case SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET: |
| 664 | 663 | //echo "Type.BOUNDSHEET\n"; |
| 665 | - $rec_offset = $this->_GetInt4d($this->data, $pos+4); |
|
| 666 | - $rec_typeFlag = ord($this->data[$pos+8]); |
|
| 667 | - $rec_visibilityFlag = ord($this->data[$pos+9]); |
|
| 668 | - $rec_length = ord($this->data[$pos+10]); |
|
| 669 | - |
|
| 670 | - if ($version == SPREADSHEET_EXCEL_READER_BIFF8){ |
|
| 671 | - $chartype = ord($this->data[$pos+11]); |
|
| 672 | - if ($chartype == 0){ |
|
| 673 | - $rec_name = substr($this->data, $pos+12, $rec_length); |
|
| 664 | + $rec_offset = $this->_GetInt4d($this->data, $pos + 4); |
|
| 665 | + $rec_typeFlag = ord($this->data[$pos + 8]); |
|
| 666 | + $rec_visibilityFlag = ord($this->data[$pos + 9]); |
|
| 667 | + $rec_length = ord($this->data[$pos + 10]); |
|
| 668 | + |
|
| 669 | + if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { |
|
| 670 | + $chartype = ord($this->data[$pos + 11]); |
|
| 671 | + if ($chartype == 0) { |
|
| 672 | + $rec_name = substr($this->data, $pos + 12, $rec_length); |
|
| 674 | 673 | } else { |
| 675 | - $rec_name = $this->_encodeUTF16(substr($this->data, $pos+12, $rec_length*2)); |
|
| 674 | + $rec_name = $this->_encodeUTF16(substr($this->data, $pos + 12, $rec_length * 2)); |
|
| 676 | 675 | } |
| 677 | - }elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7){ |
|
| 678 | - $rec_name = substr($this->data, $pos+11, $rec_length); |
|
| 676 | + }elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7) { |
|
| 677 | + $rec_name = substr($this->data, $pos + 11, $rec_length); |
|
| 679 | 678 | } |
| 680 | 679 | $this->boundsheets[] = array('name'=>$rec_name, |
| 681 | 680 | 'offset'=>$rec_offset); |
@@ -686,14 +685,14 @@ discard block |
||
| 686 | 685 | |
| 687 | 686 | //echo "Code = ".base_convert($r['code'],10,16)."\n"; |
| 688 | 687 | $pos += $length + 4; |
| 689 | - $code = ord($this->data[$pos]) | ord($this->data[$pos+1])<<8; |
|
| 690 | - $length = ord($this->data[$pos+2]) | ord($this->data[$pos+3])<<8; |
|
| 688 | + $code = ord($this->data[$pos]) | ord($this->data[$pos + 1]) << 8; |
|
| 689 | + $length = ord($this->data[$pos + 2]) | ord($this->data[$pos + 3]) << 8; |
|
| 691 | 690 | |
| 692 | 691 | //$r = &$this->nextRecord(); |
| 693 | 692 | //echo "1 Code = ".base_convert($r['code'],10,16)."\n"; |
| 694 | 693 | } |
| 695 | 694 | |
| 696 | - foreach ($this->boundsheets as $key=>$val){ |
|
| 695 | + foreach ($this->boundsheets as $key=>$val) { |
|
| 697 | 696 | $this->sn = $key; |
| 698 | 697 | $this->_parsesheet($val['offset']); |
| 699 | 698 | } |
@@ -712,30 +711,30 @@ discard block |
||
| 712 | 711 | { |
| 713 | 712 | $cont = true; |
| 714 | 713 | // read BOF |
| 715 | - $code = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 716 | - $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 714 | + $code = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 715 | + $length = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 717 | 716 | |
| 718 | - $version = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5])<<8; |
|
| 719 | - $substreamType = ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8; |
|
| 717 | + $version = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5]) << 8; |
|
| 718 | + $substreamType = ord($this->data[$spos + 6]) | ord($this->data[$spos + 7]) << 8; |
|
| 720 | 719 | |
| 721 | 720 | if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && ($version != SPREADSHEET_EXCEL_READER_BIFF7)) { |
| 722 | 721 | return -1; |
| 723 | 722 | } |
| 724 | 723 | |
| 725 | - if ($substreamType != SPREADSHEET_EXCEL_READER_WORKSHEET){ |
|
| 724 | + if ($substreamType != SPREADSHEET_EXCEL_READER_WORKSHEET) { |
|
| 726 | 725 | return -2; |
| 727 | 726 | } |
| 728 | 727 | //echo "Start parse code=".base_convert($code,10,16)." version=".base_convert($version,10,16)." substreamType=".base_convert($substreamType,10,16).""."\n"; |
| 729 | 728 | $spos += $length + 4; |
| 730 | 729 | //var_dump($this->formatRecords); |
| 731 | 730 | //echo "code $code $length"; |
| 732 | - while($cont) { |
|
| 731 | + while ($cont) { |
|
| 733 | 732 | //echo "mem= ".memory_get_usage()."\n"; |
| 734 | 733 | // $r = &$this->file->nextRecord(); |
| 735 | 734 | $lowcode = ord($this->data[$spos]); |
| 736 | 735 | if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) break; |
| 737 | - $code = $lowcode | ord($this->data[$spos+1])<<8; |
|
| 738 | - $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 736 | + $code = $lowcode | ord($this->data[$spos + 1]) << 8; |
|
| 737 | + $length = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 739 | 738 | $spos += 4; |
| 740 | 739 | $this->sheets[$this->sn]['maxrow'] = $this->_rowoffset - 1; |
| 741 | 740 | $this->sheets[$this->sn]['maxcol'] = $this->_coloffset - 1; |
@@ -746,29 +745,29 @@ discard block |
||
| 746 | 745 | case SPREADSHEET_EXCEL_READER_TYPE_DIMENSION: |
| 747 | 746 | //echo 'Type_DIMENSION '; |
| 748 | 747 | if (!isset($this->numRows)) { |
| 749 | - if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)){ |
|
| 750 | - $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+2]) | ord($this->data[$spos+3]) << 8; |
|
| 751 | - $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+6]) | ord($this->data[$spos+7]) << 8; |
|
| 748 | + if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)) { |
|
| 749 | + $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 750 | + $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos + 6]) | ord($this->data[$spos + 7]) << 8; |
|
| 752 | 751 | } else { |
| 753 | - $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8; |
|
| 754 | - $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos+10]) | ord($this->data[$spos+11]) << 8; |
|
| 752 | + $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5]) << 8; |
|
| 753 | + $this->sheets[$this->sn]['numCols'] = ord($this->data[$spos + 10]) | ord($this->data[$spos + 11]) << 8; |
|
| 755 | 754 | } |
| 756 | 755 | } |
| 757 | 756 | //echo 'numRows '.$this->numRows.' '.$this->numCols."\n"; |
| 758 | 757 | break; |
| 759 | 758 | case SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS: |
| 760 | - $cellRanges = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 759 | + $cellRanges = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 761 | 760 | for ($i = 0; $i < $cellRanges; $i++) { |
| 762 | - $fr = ord($this->data[$spos + 8*$i + 2]) | ord($this->data[$spos + 8*$i + 3])<<8; |
|
| 763 | - $lr = ord($this->data[$spos + 8*$i + 4]) | ord($this->data[$spos + 8*$i + 5])<<8; |
|
| 764 | - $fc = ord($this->data[$spos + 8*$i + 6]) | ord($this->data[$spos + 8*$i + 7])<<8; |
|
| 765 | - $lc = ord($this->data[$spos + 8*$i + 8]) | ord($this->data[$spos + 8*$i + 9])<<8; |
|
| 761 | + $fr = ord($this->data[$spos + 8 * $i + 2]) | ord($this->data[$spos + 8 * $i + 3]) << 8; |
|
| 762 | + $lr = ord($this->data[$spos + 8 * $i + 4]) | ord($this->data[$spos + 8 * $i + 5]) << 8; |
|
| 763 | + $fc = ord($this->data[$spos + 8 * $i + 6]) | ord($this->data[$spos + 8 * $i + 7]) << 8; |
|
| 764 | + $lc = ord($this->data[$spos + 8 * $i + 8]) | ord($this->data[$spos + 8 * $i + 9]) << 8; |
|
| 766 | 765 | //$this->sheets[$this->sn]['mergedCells'][] = array($fr + 1, $fc + 1, $lr + 1, $lc + 1); |
| 767 | 766 | if ($lr - $fr > 0) { |
| 768 | - $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['rowspan'] = $lr - $fr + 1; |
|
| 767 | + $this->sheets[$this->sn]['cellsInfo'][$fr + 1][$fc + 1]['rowspan'] = $lr - $fr + 1; |
|
| 769 | 768 | } |
| 770 | 769 | if ($lc - $fc > 0) { |
| 771 | - $this->sheets[$this->sn]['cellsInfo'][$fr+1][$fc+1]['colspan'] = $lc - $fc + 1; |
|
| 770 | + $this->sheets[$this->sn]['cellsInfo'][$fr + 1][$fc + 1]['colspan'] = $lc - $fc + 1; |
|
| 772 | 771 | } |
| 773 | 772 | } |
| 774 | 773 | //echo "Merged Cells $cellRanges $lr $fr $lc $fc\n"; |
@@ -776,16 +775,16 @@ discard block |
||
| 776 | 775 | case SPREADSHEET_EXCEL_READER_TYPE_RK: |
| 777 | 776 | case SPREADSHEET_EXCEL_READER_TYPE_RK2: |
| 778 | 777 | //echo 'SPREADSHEET_EXCEL_READER_TYPE_RK'."\n"; |
| 779 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 780 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 778 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 779 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 781 | 780 | $rknum = $this->_GetInt4d($this->data, $spos + 6); |
| 782 | 781 | $numValue = $this->_GetIEEE754($rknum); |
| 783 | 782 | //echo $numValue." "; |
| 784 | 783 | if ($this->isDate($spos)) { |
| 785 | 784 | list($string, $raw) = $this->createDate($numValue); |
| 786 | - }else{ |
|
| 785 | + } else { |
|
| 787 | 786 | $raw = $numValue; |
| 788 | - if (isset($this->_columnsFormat[$column + 1])){ |
|
| 787 | + if (isset($this->_columnsFormat[$column + 1])) { |
|
| 789 | 788 | $this->curformat = $this->_columnsFormat[$column + 1]; |
| 790 | 789 | } |
| 791 | 790 | $string = sprintf($this->curformat, $numValue * $this->multiplier); |
@@ -795,27 +794,27 @@ discard block |
||
| 795 | 794 | //echo "Type_RK $row $column $string $raw {$this->curformat}\n"; |
| 796 | 795 | break; |
| 797 | 796 | case SPREADSHEET_EXCEL_READER_TYPE_LABELSST: |
| 798 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 799 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 800 | - $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5])<<8; |
|
| 801 | - $index = $this->_GetInt4d($this->data, $spos + 6); |
|
| 797 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 798 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 799 | + $xfindex = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5]) << 8; |
|
| 800 | + $index = $this->_GetInt4d($this->data, $spos + 6); |
|
| 802 | 801 | //var_dump($this->sst); |
| 803 | 802 | $this->addcell($row, $column, $this->sst[$index]); |
| 804 | 803 | //echo "LabelSST $row $column $string\n"; |
| 805 | 804 | break; |
| 806 | 805 | case SPREADSHEET_EXCEL_READER_TYPE_MULRK: |
| 807 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 808 | - $colFirst = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 809 | - $colLast = ord($this->data[$spos + $length - 2]) | ord($this->data[$spos + $length - 1])<<8; |
|
| 806 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 807 | + $colFirst = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 808 | + $colLast = ord($this->data[$spos + $length - 2]) | ord($this->data[$spos + $length - 1]) << 8; |
|
| 810 | 809 | $columns = $colLast - $colFirst + 1; |
| 811 | - $tmppos = $spos+4; |
|
| 810 | + $tmppos = $spos + 4; |
|
| 812 | 811 | for ($i = 0; $i < $columns; $i++) { |
| 813 | 812 | $numValue = $this->_GetIEEE754($this->_GetInt4d($this->data, $tmppos + 2)); |
| 814 | - if ($this->isDate($tmppos-4)) { |
|
| 813 | + if ($this->isDate($tmppos - 4)) { |
|
| 815 | 814 | list($string, $raw) = $this->createDate($numValue); |
| 816 | - }else{ |
|
| 815 | + } else { |
|
| 817 | 816 | $raw = $numValue; |
| 818 | - if (isset($this->_columnsFormat[$colFirst + $i + 1])){ |
|
| 817 | + if (isset($this->_columnsFormat[$colFirst + $i + 1])) { |
|
| 819 | 818 | $this->curformat = $this->_columnsFormat[$colFirst + $i + 1]; |
| 820 | 819 | } |
| 821 | 820 | $string = sprintf($this->curformat, $numValue * $this->multiplier); |
@@ -831,15 +830,15 @@ discard block |
||
| 831 | 830 | |
| 832 | 831 | break; |
| 833 | 832 | case SPREADSHEET_EXCEL_READER_TYPE_NUMBER: |
| 834 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 835 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 833 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 834 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 836 | 835 | $tmp = unpack("ddouble", substr($this->data, $spos + 6, 8)); // It machine machine dependent |
| 837 | 836 | if ($this->isDate($spos)) { |
| 838 | 837 | list($string, $raw) = $this->createDate($tmp['double']); |
| 839 | 838 | // $this->addcell(DateRecord($r, 1)); |
| 840 | - }else{ |
|
| 839 | + } else { |
|
| 841 | 840 | //$raw = $tmp['']; |
| 842 | - if (isset($this->_columnsFormat[$column + 1])){ |
|
| 841 | + if (isset($this->_columnsFormat[$column + 1])) { |
|
| 843 | 842 | $this->curformat = $this->_columnsFormat[$column + 1]; |
| 844 | 843 | } |
| 845 | 844 | $raw = $this->createNumber($spos); |
@@ -852,16 +851,16 @@ discard block |
||
| 852 | 851 | break; |
| 853 | 852 | case SPREADSHEET_EXCEL_READER_TYPE_FORMULA: |
| 854 | 853 | case SPREADSHEET_EXCEL_READER_TYPE_FORMULA2: |
| 855 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 856 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 857 | - if ((ord($this->data[$spos+6])==0) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { |
|
| 854 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 855 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 856 | + if ((ord($this->data[$spos + 6]) == 0) && (ord($this->data[$spos + 12]) == 255) && (ord($this->data[$spos + 13]) == 255)) { |
|
| 858 | 857 | //String formula. Result follows in a STRING record |
| 859 | 858 | //echo "FORMULA $row $column Formula with a string<br>\n"; |
| 860 | - } elseif ((ord($this->data[$spos+6])==1) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { |
|
| 859 | + } elseif ((ord($this->data[$spos + 6]) == 1) && (ord($this->data[$spos + 12]) == 255) && (ord($this->data[$spos + 13]) == 255)) { |
|
| 861 | 860 | //Boolean formula. Result is in +2; 0=false,1=true |
| 862 | - } elseif ((ord($this->data[$spos+6])==2) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { |
|
| 861 | + } elseif ((ord($this->data[$spos + 6]) == 2) && (ord($this->data[$spos + 12]) == 255) && (ord($this->data[$spos + 13]) == 255)) { |
|
| 863 | 862 | //Error formula. Error code is in +2; |
| 864 | - } elseif ((ord($this->data[$spos+6])==3) && (ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) { |
|
| 863 | + } elseif ((ord($this->data[$spos + 6]) == 3) && (ord($this->data[$spos + 12]) == 255) && (ord($this->data[$spos + 13]) == 255)) { |
|
| 865 | 864 | //Formula result is a null string. |
| 866 | 865 | } else { |
| 867 | 866 | // result is a number, so first 14 bytes are just like a _NUMBER record |
@@ -869,9 +868,9 @@ discard block |
||
| 869 | 868 | if ($this->isDate($spos)) { |
| 870 | 869 | list($string, $raw) = $this->createDate($tmp['double']); |
| 871 | 870 | // $this->addcell(DateRecord($r, 1)); |
| 872 | - }else{ |
|
| 871 | + } else { |
|
| 873 | 872 | //$raw = $tmp['']; |
| 874 | - if (isset($this->_columnsFormat[$column + 1])){ |
|
| 873 | + if (isset($this->_columnsFormat[$column + 1])) { |
|
| 875 | 874 | $this->curformat = $this->_columnsFormat[$column + 1]; |
| 876 | 875 | } |
| 877 | 876 | $raw = $this->createNumber($spos); |
@@ -884,9 +883,9 @@ discard block |
||
| 884 | 883 | } |
| 885 | 884 | break; |
| 886 | 885 | case SPREADSHEET_EXCEL_READER_TYPE_BOOLERR: |
| 887 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 888 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 889 | - $string = ord($this->data[$spos+6]); |
|
| 886 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 887 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 888 | + $string = ord($this->data[$spos + 6]); |
|
| 890 | 889 | $this->addcell($row, $column, $string); |
| 891 | 890 | //echo 'Type_BOOLERR '."\n"; |
| 892 | 891 | break; |
@@ -895,9 +894,9 @@ discard block |
||
| 895 | 894 | case SPREADSHEET_EXCEL_READER_TYPE_MULBLANK: |
| 896 | 895 | break; |
| 897 | 896 | case SPREADSHEET_EXCEL_READER_TYPE_LABEL: |
| 898 | - $row = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8; |
|
| 899 | - $column = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
|
| 900 | - $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7])<<8)); |
|
| 897 | + $row = ord($this->data[$spos]) | ord($this->data[$spos + 1]) << 8; |
|
| 898 | + $column = ord($this->data[$spos + 2]) | ord($this->data[$spos + 3]) << 8; |
|
| 899 | + $this->addcell($row, $column, substr($this->data, $spos + 8, ord($this->data[$spos + 6]) | ord($this->data[$spos + 7]) << 8)); |
|
| 901 | 900 | |
| 902 | 901 | // $this->addcell(LabelRecord($r)); |
| 903 | 902 | break; |
@@ -929,7 +928,7 @@ discard block |
||
| 929 | 928 | function isDate($spos) |
| 930 | 929 | { |
| 931 | 930 | //$xfindex = GetInt2d(, 4); |
| 932 | - $xfindex = ord($this->data[$spos+4]) | ord($this->data[$spos+5]) << 8; |
|
| 931 | + $xfindex = ord($this->data[$spos + 4]) | ord($this->data[$spos + 5]) << 8; |
|
| 933 | 932 | //echo 'check is date '.$xfindex.' '.$this->formatRecords['xfrecords'][$xfindex]['type']."\n"; |
| 934 | 933 | //var_dump($this->formatRecords['xfrecords'][$xfindex]); |
| 935 | 934 | if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'date') { |
@@ -940,10 +939,10 @@ discard block |
||
| 940 | 939 | if ($this->formatRecords['xfrecords'][$xfindex]['type'] == 'number') { |
| 941 | 940 | $this->curformat = $this->formatRecords['xfrecords'][$xfindex]['format']; |
| 942 | 941 | $this->rectype = 'number'; |
| 943 | - if (($xfindex == 0x9) || ($xfindex == 0xa)){ |
|
| 942 | + if (($xfindex == 0x9) || ($xfindex == 0xa)) { |
|
| 944 | 943 | $this->multiplier = 100; |
| 945 | 944 | } |
| 946 | - }else{ |
|
| 945 | + } else { |
|
| 947 | 946 | $this->curformat = $this->_defaultFormat; |
| 948 | 947 | $this->rectype = 'unknown'; |
| 949 | 948 | } |
@@ -968,15 +967,15 @@ discard block |
||
| 968 | 967 | { |
| 969 | 968 | if ($numValue > 1) { |
| 970 | 969 | $utcDays = $numValue - ($this->nineteenFour ? SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904 : SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS); |
| 971 | - $utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY); |
|
| 972 | - $string = date ($this->curformat, $utcValue); |
|
| 970 | + $utcValue = round(($utcDays + 1) * SPREADSHEET_EXCEL_READER_MSINADAY); |
|
| 971 | + $string = date($this->curformat, $utcValue); |
|
| 973 | 972 | $raw = $utcValue; |
| 974 | 973 | } else { |
| 975 | 974 | $raw = $numValue; |
| 976 | 975 | $hours = floor($numValue * 24); |
| 977 | 976 | $mins = floor($numValue * 24 * 60) - $hours * 60; |
| 978 | 977 | $secs = floor($numValue * SPREADSHEET_EXCEL_READER_MSINADAY) - $hours * 60 * 60 - $mins * 60; |
| 979 | - $string = date ($this->curformat, mktime($hours, $mins, $secs)); |
|
| 978 | + $string = date($this->curformat, mktime($hours, $mins, $secs)); |
|
| 980 | 979 | } |
| 981 | 980 | |
| 982 | 981 | return array($string, $raw); |
@@ -988,15 +987,15 @@ discard block |
||
| 988 | 987 | $rknumlow = $this->_GetInt4d($this->data, $spos + 6); |
| 989 | 988 | //for ($i=0; $i<8; $i++) { echo ord($this->data[$i+$spos+6]) . " "; } echo "<br>"; |
| 990 | 989 | $sign = ($rknumhigh & 0x80000000) >> 31; |
| 991 | - $exp = ($rknumhigh & 0x7ff00000) >> 20; |
|
| 990 | + $exp = ($rknumhigh & 0x7ff00000) >> 20; |
|
| 992 | 991 | $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); |
| 993 | 992 | $mantissalow1 = ($rknumlow & 0x80000000) >> 31; |
| 994 | 993 | $mantissalow2 = ($rknumlow & 0x7fffffff); |
| 995 | - $value = $mantissa / pow( 2 , (20- ($exp - 1023))); |
|
| 996 | - if ($mantissalow1 != 0) $value += 1 / pow (2 , (21 - ($exp - 1023))); |
|
| 997 | - $value += $mantissalow2 / pow (2 , (52 - ($exp - 1023))); |
|
| 994 | + $value = $mantissa / pow(2, (20 - ($exp - 1023))); |
|
| 995 | + if ($mantissalow1 != 0) $value += 1 / pow(2, (21 - ($exp - 1023))); |
|
| 996 | + $value += $mantissalow2 / pow(2, (52 - ($exp - 1023))); |
|
| 998 | 997 | //echo "Sign = $sign, Exp = $exp, mantissahighx = $mantissa, mantissalow1 = $mantissalow1, mantissalow2 = $mantissalow2<br>\n"; |
| 999 | - if ($sign) {$value = -1 * $value;} |
|
| 998 | + if ($sign) {$value = -1 * $value; } |
|
| 1000 | 999 | return $value; |
| 1001 | 1000 | } |
| 1002 | 1001 | |
@@ -1036,8 +1035,8 @@ discard block |
||
| 1036 | 1035 | $sign = ($rknum & 0x80000000) >> 31; |
| 1037 | 1036 | $exp = ($rknum & 0x7ff00000) >> 20; |
| 1038 | 1037 | $mantissa = (0x100000 | ($rknum & 0x000ffffc)); |
| 1039 | - $value = $mantissa / pow( 2 , (20- ($exp - 1023))); |
|
| 1040 | - if ($sign) {$value = -1 * $value;} |
|
| 1038 | + $value = $mantissa / pow(2, (20 - ($exp - 1023))); |
|
| 1039 | + if ($sign) {$value = -1 * $value; } |
|
| 1041 | 1040 | //end of changes by mmp |
| 1042 | 1041 | |
| 1043 | 1042 | } |
@@ -1058,7 +1057,7 @@ discard block |
||
| 1058 | 1057 | $string = api_convert_encoding($string, $this->_defaultEncoding, $from); |
| 1059 | 1058 | return $string; |
| 1060 | 1059 | } |
| 1061 | - $string = api_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE'); |
|
| 1060 | + $string = api_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE'); |
|
| 1062 | 1061 | return $string; |
| 1063 | 1062 | /* |
| 1064 | 1063 | * Default behaviour |
@@ -1076,10 +1075,10 @@ discard block |
||
| 1076 | 1075 | |
| 1077 | 1076 | function _GetInt4d($data, $pos) |
| 1078 | 1077 | { |
| 1079 | - $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); |
|
| 1080 | - if ($value>=4294967294) |
|
| 1078 | + $value = ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | (ord($data[$pos + 3]) << 24); |
|
| 1079 | + if ($value >= 4294967294) |
|
| 1081 | 1080 | { |
| 1082 | - $value=-2; |
|
| 1081 | + $value = -2; |
|
| 1083 | 1082 | } |
| 1084 | 1083 | return $value; |
| 1085 | 1084 | } |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | if ($spos + $len < $limitpos) { |
| 506 | 506 | $retstr = substr($this->data, $spos, $len); |
| 507 | 507 | $spos += $len; |
| 508 | - }else{ |
|
| 508 | + } else{ |
|
| 509 | 509 | // found countinue |
| 510 | 510 | $retstr = substr($this->data, $spos, $limitpos - $spos); |
| 511 | 511 | $bytesRead = $limitpos - $spos; |
@@ -527,12 +527,12 @@ discard block |
||
| 527 | 527 | $retstr .= substr($this->data, $spos, $len); |
| 528 | 528 | $charsLeft -= $len; |
| 529 | 529 | $asciiEncoding = true; |
| 530 | - }elseif (!$asciiEncoding && ($option != 0)){ |
|
| 530 | + } elseif (!$asciiEncoding && ($option != 0)){ |
|
| 531 | 531 | $len = min($charsLeft * 2, $limitpos - $spos); // min($charsLeft, $conlength); |
| 532 | 532 | $retstr .= substr($this->data, $spos, $len); |
| 533 | 533 | $charsLeft -= $len/2; |
| 534 | 534 | $asciiEncoding = false; |
| 535 | - }elseif (!$asciiEncoding && ($option == 0)) { |
|
| 535 | + } elseif (!$asciiEncoding && ($option == 0)) { |
|
| 536 | 536 | // Bummer - the string starts off as Unicode, but after the |
| 537 | 537 | // continuation it is in straightforward ASCII encoding |
| 538 | 538 | $len = min($charsLeft, $limitpos - $spos); // min($charsLeft, $conlength); |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | $charsLeft -= $len; |
| 543 | 543 | $asciiEncoding = false; |
| 544 | - }else{ |
|
| 544 | + } else{ |
|
| 545 | 545 | $newstr = ''; |
| 546 | 546 | for ($j = 0; $j < strlen($retstr); $j++) { |
| 547 | 547 | $newstr = $retstr[$j].chr(0); |
@@ -619,22 +619,24 @@ discard block |
||
| 619 | 619 | 'type' => 'date', |
| 620 | 620 | 'format' => $this->dateFormats[$indexCode] |
| 621 | 621 | ); |
| 622 | - }elseif (array_key_exists($indexCode, $this->numberFormats)) { |
|
| 622 | + } elseif (array_key_exists($indexCode, $this->numberFormats)) { |
|
| 623 | 623 | //echo "isnumber ".$this->numberFormats[$indexCode]; |
| 624 | 624 | $this->formatRecords['xfrecords'][] = array( |
| 625 | 625 | 'type' => 'number', |
| 626 | 626 | 'format' => $this->numberFormats[$indexCode] |
| 627 | 627 | ); |
| 628 | - }else{ |
|
| 628 | + } else{ |
|
| 629 | 629 | $isdate = FALSE; |
| 630 | 630 | if ($indexCode > 0){ |
| 631 | - if (isset($this->formatRecords[$indexCode])) |
|
| 632 | - $formatstr = $this->formatRecords[$indexCode]; |
|
| 631 | + if (isset($this->formatRecords[$indexCode])) { |
|
| 632 | + $formatstr = $this->formatRecords[$indexCode]; |
|
| 633 | + } |
|
| 633 | 634 | //echo '.other.'; |
| 634 | 635 | //echo "\ndate-time=$formatstr=\n"; |
| 635 | - if ($formatstr) |
|
| 636 | - if (preg_match("/[^hmsday\/\-:\s]/i", $formatstr) == 0) { // found day and time format |
|
| 636 | + if ($formatstr) { |
|
| 637 | + if (preg_match("/[^hmsday\/\-:\s]/i", $formatstr) == 0) { // found day and time format |
|
| 637 | 638 | $isdate = TRUE; |
| 639 | + } |
|
| 638 | 640 | $formatstr = str_replace('mm', 'i', $formatstr); |
| 639 | 641 | $formatstr = str_replace('h', 'H', $formatstr); |
| 640 | 642 | //echo "\ndate-time $formatstr \n"; |
@@ -646,7 +648,7 @@ discard block |
||
| 646 | 648 | 'type' => 'date', |
| 647 | 649 | 'format' => $formatstr, |
| 648 | 650 | ); |
| 649 | - }else{ |
|
| 651 | + } else{ |
|
| 650 | 652 | $this->formatRecords['xfrecords'][] = array( |
| 651 | 653 | 'type' => 'other', |
| 652 | 654 | 'format' => '', |
@@ -674,7 +676,7 @@ discard block |
||
| 674 | 676 | } else { |
| 675 | 677 | $rec_name = $this->_encodeUTF16(substr($this->data, $pos+12, $rec_length*2)); |
| 676 | 678 | } |
| 677 | - }elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7){ |
|
| 679 | + } elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7){ |
|
| 678 | 680 | $rec_name = substr($this->data, $pos+11, $rec_length); |
| 679 | 681 | } |
| 680 | 682 | $this->boundsheets[] = array('name'=>$rec_name, |
@@ -733,7 +735,9 @@ discard block |
||
| 733 | 735 | //echo "mem= ".memory_get_usage()."\n"; |
| 734 | 736 | // $r = &$this->file->nextRecord(); |
| 735 | 737 | $lowcode = ord($this->data[$spos]); |
| 736 | - if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) break; |
|
| 738 | + if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) { |
|
| 739 | + break; |
|
| 740 | + } |
|
| 737 | 741 | $code = $lowcode | ord($this->data[$spos+1])<<8; |
| 738 | 742 | $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; |
| 739 | 743 | $spos += 4; |
@@ -783,7 +787,7 @@ discard block |
||
| 783 | 787 | //echo $numValue." "; |
| 784 | 788 | if ($this->isDate($spos)) { |
| 785 | 789 | list($string, $raw) = $this->createDate($numValue); |
| 786 | - }else{ |
|
| 790 | + } else{ |
|
| 787 | 791 | $raw = $numValue; |
| 788 | 792 | if (isset($this->_columnsFormat[$column + 1])){ |
| 789 | 793 | $this->curformat = $this->_columnsFormat[$column + 1]; |
@@ -813,7 +817,7 @@ discard block |
||
| 813 | 817 | $numValue = $this->_GetIEEE754($this->_GetInt4d($this->data, $tmppos + 2)); |
| 814 | 818 | if ($this->isDate($tmppos-4)) { |
| 815 | 819 | list($string, $raw) = $this->createDate($numValue); |
| 816 | - }else{ |
|
| 820 | + } else{ |
|
| 817 | 821 | $raw = $numValue; |
| 818 | 822 | if (isset($this->_columnsFormat[$colFirst + $i + 1])){ |
| 819 | 823 | $this->curformat = $this->_columnsFormat[$colFirst + $i + 1]; |
@@ -837,7 +841,7 @@ discard block |
||
| 837 | 841 | if ($this->isDate($spos)) { |
| 838 | 842 | list($string, $raw) = $this->createDate($tmp['double']); |
| 839 | 843 | // $this->addcell(DateRecord($r, 1)); |
| 840 | - }else{ |
|
| 844 | + } else{ |
|
| 841 | 845 | //$raw = $tmp['']; |
| 842 | 846 | if (isset($this->_columnsFormat[$column + 1])){ |
| 843 | 847 | $this->curformat = $this->_columnsFormat[$column + 1]; |
@@ -869,7 +873,7 @@ discard block |
||
| 869 | 873 | if ($this->isDate($spos)) { |
| 870 | 874 | list($string, $raw) = $this->createDate($tmp['double']); |
| 871 | 875 | // $this->addcell(DateRecord($r, 1)); |
| 872 | - }else{ |
|
| 876 | + } else{ |
|
| 873 | 877 | //$raw = $tmp['']; |
| 874 | 878 | if (isset($this->_columnsFormat[$column + 1])){ |
| 875 | 879 | $this->curformat = $this->_columnsFormat[$column + 1]; |
@@ -913,10 +917,12 @@ discard block |
||
| 913 | 917 | $spos += $length; |
| 914 | 918 | } |
| 915 | 919 | |
| 916 | - if (!isset($this->sheets[$this->sn]['numRows'])) |
|
| 917 | - $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow']; |
|
| 918 | - if (!isset($this->sheets[$this->sn]['numCols'])) |
|
| 919 | - $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol']; |
|
| 920 | + if (!isset($this->sheets[$this->sn]['numRows'])) { |
|
| 921 | + $this->sheets[$this->sn]['numRows'] = $this->sheets[$this->sn]['maxrow']; |
|
| 922 | + } |
|
| 923 | + if (!isset($this->sheets[$this->sn]['numCols'])) { |
|
| 924 | + $this->sheets[$this->sn]['numCols'] = $this->sheets[$this->sn]['maxcol']; |
|
| 925 | + } |
|
| 920 | 926 | |
| 921 | 927 | } |
| 922 | 928 | |
@@ -943,7 +949,7 @@ discard block |
||
| 943 | 949 | if (($xfindex == 0x9) || ($xfindex == 0xa)){ |
| 944 | 950 | $this->multiplier = 100; |
| 945 | 951 | } |
| 946 | - }else{ |
|
| 952 | + } else{ |
|
| 947 | 953 | $this->curformat = $this->_defaultFormat; |
| 948 | 954 | $this->rectype = 'unknown'; |
| 949 | 955 | } |
@@ -993,7 +999,9 @@ discard block |
||
| 993 | 999 | $mantissalow1 = ($rknumlow & 0x80000000) >> 31; |
| 994 | 1000 | $mantissalow2 = ($rknumlow & 0x7fffffff); |
| 995 | 1001 | $value = $mantissa / pow( 2 , (20- ($exp - 1023))); |
| 996 | - if ($mantissalow1 != 0) $value += 1 / pow (2 , (21 - ($exp - 1023))); |
|
| 1002 | + if ($mantissalow1 != 0) { |
|
| 1003 | + $value += 1 / pow (2 , (21 - ($exp - 1023))); |
|
| 1004 | + } |
|
| 997 | 1005 | $value += $mantissalow2 / pow (2 , (52 - ($exp - 1023))); |
| 998 | 1006 | //echo "Sign = $sign, Exp = $exp, mantissahighx = $mantissa, mantissalow1 = $mantissalow1, mantissalow2 = $mantissalow2<br>\n"; |
| 999 | 1007 | if ($sign) {$value = -1 * $value;} |
@@ -1006,10 +1014,12 @@ discard block |
||
| 1006 | 1014 | $this->sheets[$this->sn]['maxrow'] = max($this->sheets[$this->sn]['maxrow'], $row + $this->_rowoffset); |
| 1007 | 1015 | $this->sheets[$this->sn]['maxcol'] = max($this->sheets[$this->sn]['maxcol'], $col + $this->_coloffset); |
| 1008 | 1016 | $this->sheets[$this->sn]['cells'][$row + $this->_rowoffset][$col + $this->_coloffset] = $string; |
| 1009 | - if ($raw) |
|
| 1010 | - $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['raw'] = $raw; |
|
| 1011 | - if (isset($this->rectype)) |
|
| 1012 | - $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['type'] = $this->rectype; |
|
| 1017 | + if ($raw) { |
|
| 1018 | + $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['raw'] = $raw; |
|
| 1019 | + } |
|
| 1020 | + if (isset($this->rectype)) { |
|
| 1021 | + $this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col + $this->_coloffset]['type'] = $this->rectype; |
|
| 1022 | + } |
|
| 1013 | 1023 | |
| 1014 | 1024 | } |
| 1015 | 1025 | |
@@ -116,6 +116,7 @@ |
||
| 116 | 116 | * @param string exception message |
| 117 | 117 | * @param int|Exception|PEAR_Error|array|null exception cause |
| 118 | 118 | * @param int|null exception code or null |
| 119 | + * @param string $message |
|
| 119 | 120 | */ |
| 120 | 121 | public function __construct($message, $p2 = null, $p3 = null) |
| 121 | 122 | { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $trace = $this->getTraceSafe(); |
| 236 | 236 | $cause = array('class' => get_class($this), |
| 237 | - 'message' => $this->message, |
|
| 238 | - 'file' => 'unknown', |
|
| 239 | - 'line' => 'unknown'); |
|
| 237 | + 'message' => $this->message, |
|
| 238 | + 'file' => 'unknown', |
|
| 239 | + 'line' => 'unknown'); |
|
| 240 | 240 | if (isset($trace[0])) { |
| 241 | 241 | if (isset($trace[0]['file'])) { |
| 242 | 242 | $cause['file'] = $trace[0]['file']; |
@@ -248,28 +248,28 @@ discard block |
||
| 248 | 248 | $this->cause->getCauseMessage($causes); |
| 249 | 249 | } elseif ($this->cause instanceof Exception) { |
| 250 | 250 | $causes[] = array('class' => get_class($this->cause), |
| 251 | - 'message' => $this->cause->getMessage(), |
|
| 252 | - 'file' => $this->cause->getFile(), |
|
| 253 | - 'line' => $this->cause->getLine()); |
|
| 251 | + 'message' => $this->cause->getMessage(), |
|
| 252 | + 'file' => $this->cause->getFile(), |
|
| 253 | + 'line' => $this->cause->getLine()); |
|
| 254 | 254 | } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { |
| 255 | 255 | $causes[] = array('class' => get_class($this->cause), |
| 256 | - 'message' => $this->cause->getMessage(), |
|
| 257 | - 'file' => 'unknown', |
|
| 258 | - 'line' => 'unknown'); |
|
| 256 | + 'message' => $this->cause->getMessage(), |
|
| 257 | + 'file' => 'unknown', |
|
| 258 | + 'line' => 'unknown'); |
|
| 259 | 259 | } elseif (is_array($this->cause)) { |
| 260 | 260 | foreach ($this->cause as $cause) { |
| 261 | 261 | if ($cause instanceof PEAR_Exception) { |
| 262 | 262 | $cause->getCauseMessage($causes); |
| 263 | 263 | } elseif ($cause instanceof Exception) { |
| 264 | 264 | $causes[] = array('class' => get_class($cause), |
| 265 | - 'message' => $cause->getMessage(), |
|
| 266 | - 'file' => $cause->getFile(), |
|
| 267 | - 'line' => $cause->getLine()); |
|
| 265 | + 'message' => $cause->getMessage(), |
|
| 266 | + 'file' => $cause->getFile(), |
|
| 267 | + 'line' => $cause->getLine()); |
|
| 268 | 268 | } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { |
| 269 | 269 | $causes[] = array('class' => get_class($cause), |
| 270 | - 'message' => $cause->getMessage(), |
|
| 271 | - 'file' => 'unknown', |
|
| 272 | - 'line' => 'unknown'); |
|
| 270 | + 'message' => $cause->getMessage(), |
|
| 271 | + 'file' => 'unknown', |
|
| 272 | + 'line' => 'unknown'); |
|
| 273 | 273 | } elseif (is_array($cause) && isset($cause['message'])) { |
| 274 | 274 | // PEAR_ErrorStack warning |
| 275 | 275 | $causes[] = array( |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | $html = '<table style="border: 1px" cellspacing="0">' . "\n"; |
| 328 | 328 | foreach ($causes as $i => $cause) { |
| 329 | 329 | $html .= '<tr><td colspan="3" style="background: #ff9999">' |
| 330 | - . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: ' |
|
| 331 | - . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> ' |
|
| 332 | - . 'on line <b>' . $cause['line'] . '</b>' |
|
| 333 | - . "</td></tr>\n"; |
|
| 330 | + . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: ' |
|
| 331 | + . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> ' |
|
| 332 | + . 'on line <b>' . $cause['line'] . '</b>' |
|
| 333 | + . "</td></tr>\n"; |
|
| 334 | 334 | } |
| 335 | 335 | $html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n" |
| 336 | - . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>' |
|
| 337 | - . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>' |
|
| 338 | - . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n"; |
|
| 336 | + . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>' |
|
| 337 | + . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>' |
|
| 338 | + . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n"; |
|
| 339 | 339 | |
| 340 | 340 | foreach ($trace as $k => $v) { |
| 341 | 341 | $html .= '<tr><td style="text-align: center;">' . $k . '</td>' |
| 342 | - . '<td>'; |
|
| 342 | + . '<td>'; |
|
| 343 | 343 | if (!empty($v['class'])) { |
| 344 | 344 | $html .= $v['class'] . $v['type']; |
| 345 | 345 | } |
@@ -361,15 +361,15 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | $html .= '(' . implode(', ',$args) . ')' |
| 364 | - . '</td>' |
|
| 365 | - . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') |
|
| 366 | - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') |
|
| 367 | - . '</td></tr>' . "\n"; |
|
| 364 | + . '</td>' |
|
| 365 | + . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') |
|
| 366 | + . ':' . (isset($v['line']) ? $v['line'] : 'unknown') |
|
| 367 | + . '</td></tr>' . "\n"; |
|
| 368 | 368 | } |
| 369 | 369 | $html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>' |
| 370 | - . '<td>{main}</td>' |
|
| 371 | - . '<td> </td></tr>' . "\n" |
|
| 372 | - . '</table>'; |
|
| 370 | + . '<td>{main}</td>' |
|
| 371 | + . '<td> </td></tr>' . "\n" |
|
| 372 | + . '</table>'; |
|
| 373 | 373 | return $html; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -380,8 +380,8 @@ discard block |
||
| 380 | 380 | $causeMsg = ''; |
| 381 | 381 | foreach ($causes as $i => $cause) { |
| 382 | 382 | $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' |
| 383 | - . $cause['message'] . ' in ' . $cause['file'] |
|
| 384 | - . ' on line ' . $cause['line'] . "\n"; |
|
| 383 | + . $cause['message'] . ' in ' . $cause['file'] |
|
| 384 | + . ' on line ' . $cause['line'] . "\n"; |
|
| 385 | 385 | } |
| 386 | 386 | return $causeMsg . $this->getTraceAsString(); |
| 387 | 387 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // using is_object allows both Exception and PEAR_Error |
| 127 | 127 | if (is_object($p2) && !($p2 instanceof Exception)) { |
| 128 | 128 | if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { |
| 129 | - throw new PEAR_Exception('exception cause must be Exception, ' . |
|
| 129 | + throw new PEAR_Exception('exception cause must be Exception, '. |
|
| 130 | 130 | 'array, or PEAR_Error'); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -276,11 +276,9 @@ discard block |
||
| 276 | 276 | 'class' => $cause['package'], |
| 277 | 277 | 'message' => $cause['message'], |
| 278 | 278 | 'file' => isset($cause['context']['file']) ? |
| 279 | - $cause['context']['file'] : |
|
| 280 | - 'unknown', |
|
| 279 | + $cause['context']['file'] : 'unknown', |
|
| 281 | 280 | 'line' => isset($cause['context']['line']) ? |
| 282 | - $cause['context']['line'] : |
|
| 283 | - 'unknown', |
|
| 281 | + $cause['context']['line'] : 'unknown', |
|
| 284 | 282 | ); |
| 285 | 283 | } |
| 286 | 284 | } |
@@ -293,7 +291,7 @@ discard block |
||
| 293 | 291 | $this->_trace = $this->getTrace(); |
| 294 | 292 | if (empty($this->_trace)) { |
| 295 | 293 | $backtrace = debug_backtrace(); |
| 296 | - $this->_trace = array($backtrace[count($backtrace)-1]); |
|
| 294 | + $this->_trace = array($backtrace[count($backtrace) - 1]); |
|
| 297 | 295 | } |
| 298 | 296 | } |
| 299 | 297 | return $this->_trace; |
@@ -324,24 +322,24 @@ discard block |
||
| 324 | 322 | $trace = $this->getTraceSafe(); |
| 325 | 323 | $causes = array(); |
| 326 | 324 | $this->getCauseMessage($causes); |
| 327 | - $html = '<table style="border: 1px" cellspacing="0">' . "\n"; |
|
| 325 | + $html = '<table style="border: 1px" cellspacing="0">'."\n"; |
|
| 328 | 326 | foreach ($causes as $i => $cause) { |
| 329 | 327 | $html .= '<tr><td colspan="3" style="background: #ff9999">' |
| 330 | - . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: ' |
|
| 331 | - . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> ' |
|
| 332 | - . 'on line <b>' . $cause['line'] . '</b>' |
|
| 328 | + . str_repeat('-', $i).' <b>'.$cause['class'].'</b>: ' |
|
| 329 | + . htmlspecialchars($cause['message']).' in <b>'.$cause['file'].'</b> ' |
|
| 330 | + . 'on line <b>'.$cause['line'].'</b>' |
|
| 333 | 331 | . "</td></tr>\n"; |
| 334 | 332 | } |
| 335 | - $html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n" |
|
| 333 | + $html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>'."\n" |
|
| 336 | 334 | . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>' |
| 337 | 335 | . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>' |
| 338 | - . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n"; |
|
| 336 | + . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>'."\n"; |
|
| 339 | 337 | |
| 340 | 338 | foreach ($trace as $k => $v) { |
| 341 | - $html .= '<tr><td style="text-align: center;">' . $k . '</td>' |
|
| 339 | + $html .= '<tr><td style="text-align: center;">'.$k.'</td>' |
|
| 342 | 340 | . '<td>'; |
| 343 | 341 | if (!empty($v['class'])) { |
| 344 | - $html .= $v['class'] . $v['type']; |
|
| 342 | + $html .= $v['class'].$v['type']; |
|
| 345 | 343 | } |
| 346 | 344 | $html .= $v['function']; |
| 347 | 345 | $args = array(); |
@@ -353,22 +351,22 @@ discard block |
||
| 353 | 351 | elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; |
| 354 | 352 | elseif (is_int($arg) || is_double($arg)) $args[] = $arg; |
| 355 | 353 | else { |
| 356 | - $arg = (string)$arg; |
|
| 354 | + $arg = (string) $arg; |
|
| 357 | 355 | $str = htmlspecialchars(substr($arg, 0, 16)); |
| 358 | 356 | if (strlen($arg) > 16) $str .= '…'; |
| 359 | - $args[] = "'" . $str . "'"; |
|
| 357 | + $args[] = "'".$str."'"; |
|
| 360 | 358 | } |
| 361 | 359 | } |
| 362 | 360 | } |
| 363 | - $html .= '(' . implode(', ',$args) . ')' |
|
| 361 | + $html .= '('.implode(', ', $args).')' |
|
| 364 | 362 | . '</td>' |
| 365 | - . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') |
|
| 366 | - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') |
|
| 367 | - . '</td></tr>' . "\n"; |
|
| 363 | + . '<td>'.(isset($v['file']) ? $v['file'] : 'unknown') |
|
| 364 | + . ':'.(isset($v['line']) ? $v['line'] : 'unknown') |
|
| 365 | + . '</td></tr>'."\n"; |
|
| 368 | 366 | } |
| 369 | - $html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>' |
|
| 367 | + $html .= '<tr><td style="text-align: center;">'.($k + 1).'</td>' |
|
| 370 | 368 | . '<td>{main}</td>' |
| 371 | - . '<td> </td></tr>' . "\n" |
|
| 369 | + . '<td> </td></tr>'."\n" |
|
| 372 | 370 | . '</table>'; |
| 373 | 371 | return $html; |
| 374 | 372 | } |
@@ -379,10 +377,10 @@ discard block |
||
| 379 | 377 | $this->getCauseMessage($causes); |
| 380 | 378 | $causeMsg = ''; |
| 381 | 379 | foreach ($causes as $i => $cause) { |
| 382 | - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' |
|
| 383 | - . $cause['message'] . ' in ' . $cause['file'] |
|
| 384 | - . ' on line ' . $cause['line'] . "\n"; |
|
| 380 | + $causeMsg .= str_repeat(' ', $i).$cause['class'].': ' |
|
| 381 | + . $cause['message'].' in '.$cause['file'] |
|
| 382 | + . ' on line '.$cause['line']."\n"; |
|
| 385 | 383 | } |
| 386 | - return $causeMsg . $this->getTraceAsString(); |
|
| 384 | + return $causeMsg.$this->getTraceAsString(); |
|
| 387 | 385 | } |
| 388 | 386 | } |
@@ -347,15 +347,22 @@ |
||
| 347 | 347 | $args = array(); |
| 348 | 348 | if (!empty($v['args'])) { |
| 349 | 349 | foreach ($v['args'] as $arg) { |
| 350 | - if (is_null($arg)) $args[] = 'null'; |
|
| 351 | - elseif (is_array($arg)) $args[] = 'Array'; |
|
| 352 | - elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')'; |
|
| 353 | - elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; |
|
| 354 | - elseif (is_int($arg) || is_double($arg)) $args[] = $arg; |
|
| 355 | - else { |
|
| 350 | + if (is_null($arg)) { |
|
| 351 | + $args[] = 'null'; |
|
| 352 | + } elseif (is_array($arg)) { |
|
| 353 | + $args[] = 'Array'; |
|
| 354 | + } elseif (is_object($arg)) { |
|
| 355 | + $args[] = 'Object('.get_class($arg).')'; |
|
| 356 | + } elseif (is_bool($arg)) { |
|
| 357 | + $args[] = $arg ? 'true' : 'false'; |
|
| 358 | + } elseif (is_int($arg) || is_double($arg)) { |
|
| 359 | + $args[] = $arg; |
|
| 360 | + } else { |
|
| 356 | 361 | $arg = (string)$arg; |
| 357 | 362 | $str = htmlspecialchars(substr($arg, 0, 16)); |
| 358 | - if (strlen($arg) > 16) $str .= '…'; |
|
| 363 | + if (strlen($arg) > 16) { |
|
| 364 | + $str .= '…'; |
|
| 365 | + } |
|
| 359 | 366 | $args[] = "'" . $str . "'"; |
| 360 | 367 | } |
| 361 | 368 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param array $attributes Array of attribute |
| 200 | 200 | * @since 1.0 |
| 201 | 201 | * @access private |
| 202 | - * @return bool |
|
| 202 | + * @return boolean|null |
|
| 203 | 203 | */ |
| 204 | 204 | function _getAttrKey($attr, $attributes) |
| 205 | 205 | { |
@@ -265,6 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string Attribute name |
| 267 | 267 | * @param string Attribute value (will be set to $name if omitted) |
| 268 | + * @param string $name |
|
| 268 | 269 | * @access public |
| 269 | 270 | */ |
| 270 | 271 | function setAttribute($name, $value = null) |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | if (is_array($attributes)) { |
| 142 | 142 | $charset = HTML_Common::charset(); |
| 143 | 143 | foreach ($attributes as $key => $value) { |
| 144 | - // Modified by Ivan Tcholakov, 16-MAR-2010 |
|
| 144 | + // Modified by Ivan Tcholakov, 16-MAR-2010 |
|
| 145 | 145 | $value = @htmlspecialchars($value, ENT_COMPAT, $charset); |
| 146 | 146 | $strAttr .= ' ' . $key . '= "' . $value. '"'; |
| 147 | 147 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | foreach ($attributes as $key => $value) { |
| 144 | 144 | // Modified by Ivan Tcholakov, 16-MAR-2010 |
| 145 | 145 | $value = @htmlspecialchars($value, ENT_COMPAT, $charset); |
| 146 | - $strAttr .= ' ' . $key . '= "' . $value. '"'; |
|
| 146 | + $strAttr .= ' '.$key.'= "'.$value.'"'; |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | return $strAttr; |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | return $ret; |
| 171 | 171 | |
| 172 | 172 | } elseif (is_string($attributes)) { |
| 173 | - $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . |
|
| 173 | + $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)". |
|
| 174 | 174 | "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/"; |
| 175 | 175 | if (preg_match_all($preg, $attributes, $regs)) { |
| 176 | - for ($counter=0; $counter<count($regs[1]); $counter++) { |
|
| 176 | + for ($counter = 0; $counter < count($regs[1]); $counter++) { |
|
| 177 | 177 | $name = $regs[1][$counter]; |
| 178 | 178 | $check = $regs[0][$counter]; |
| 179 | 179 | $value = $regs[7][$counter]; |
@@ -689,6 +689,8 @@ discard block |
||
| 689 | 689 | * @param HTML_QuickForm_element Element to insert |
| 690 | 690 | * @param string Name of the element before which the new |
| 691 | 691 | * one is inserted |
| 692 | + * @param HTML_QuickForm_element $element |
|
| 693 | + * @param string $nameAfter |
|
| 692 | 694 | * @return HTML_QuickForm_element reference to inserted element |
| 693 | 695 | * @throws HTML_QuickForm_Error |
| 694 | 696 | */ |
@@ -1290,7 +1292,7 @@ discard block |
||
| 1290 | 1292 | * Applies a data filter for the given field(s) |
| 1291 | 1293 | * |
| 1292 | 1294 | * @param mixed $element Form element name or array of such names |
| 1293 | - * @param mixed $filter Callback, either function name or array(&$object, 'method') |
|
| 1295 | + * @param string $filter Callback, either function name or array(&$object, 'method') |
|
| 1294 | 1296 | * @since 2.0 |
| 1295 | 1297 | * @access public |
| 1296 | 1298 | * @throws HTML_QuickForm_Error |
@@ -2042,6 +2044,7 @@ discard block |
||
| 2042 | 2044 | * |
| 2043 | 2045 | * @access public |
| 2044 | 2046 | * @param int error code |
| 2047 | + * @param integer $value |
|
| 2045 | 2048 | * @return string error message |
| 2046 | 2049 | * @static |
| 2047 | 2050 | */ |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @see HTML_QuickForm::errorMessage() |
| 44 | 44 | */ |
| 45 | -define('QUICKFORM_OK', 1); |
|
| 46 | -define('QUICKFORM_ERROR', -1); |
|
| 47 | -define('QUICKFORM_INVALID_RULE', -2); |
|
| 48 | -define('QUICKFORM_NONEXIST_ELEMENT', -3); |
|
| 49 | -define('QUICKFORM_INVALID_FILTER', -4); |
|
| 50 | -define('QUICKFORM_UNREGISTERED_ELEMENT', -5); |
|
| 51 | -define('QUICKFORM_INVALID_ELEMENT_NAME', -6); |
|
| 52 | -define('QUICKFORM_INVALID_PROCESS', -7); |
|
| 53 | -define('QUICKFORM_DEPRECATED', -8); |
|
| 54 | -define('QUICKFORM_INVALID_DATASOURCE', -9); |
|
| 45 | +define('QUICKFORM_OK', 1); |
|
| 46 | +define('QUICKFORM_ERROR', -1); |
|
| 47 | +define('QUICKFORM_INVALID_RULE', -2); |
|
| 48 | +define('QUICKFORM_NONEXIST_ELEMENT', -3); |
|
| 49 | +define('QUICKFORM_INVALID_FILTER', -4); |
|
| 50 | +define('QUICKFORM_UNREGISTERED_ELEMENT', -5); |
|
| 51 | +define('QUICKFORM_INVALID_ELEMENT_NAME', -6); |
|
| 52 | +define('QUICKFORM_INVALID_PROCESS', -7); |
|
| 53 | +define('QUICKFORM_DEPRECATED', -8); |
|
| 54 | +define('QUICKFORM_INVALID_DATASOURCE', -9); |
|
| 55 | 55 | /**#@-*/ |
| 56 | 56 | |
| 57 | 57 | // }}} |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field |
| 230 | 230 | * @access public |
| 231 | 231 | */ |
| 232 | - public function __construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) |
|
| 232 | + public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false) |
|
| 233 | 233 | { |
| 234 | 234 | parent::__construct($attributes); |
| 235 | 235 | $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | 'id' => $form_id |
| 247 | 247 | ) + $target; |
| 248 | 248 | $this->updateAttributes($attributes); |
| 249 | - if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) { |
|
| 249 | + if (!$trackSubmit || isset($_REQUEST['_qf__'.$formName])) { |
|
| 250 | 250 | if (1 == get_magic_quotes_gpc()) { |
| 251 | - $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST); |
|
| 251 | + $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST); |
|
| 252 | 252 | foreach ($_FILES as $keyFirst => $valFirst) { |
| 253 | 253 | foreach ($valFirst as $keySecond => $valSecond) { |
| 254 | 254 | if ('name' == $keySecond) { |
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } else { |
| 262 | - $this->_submitValues = 'get' == $method? $_GET: $_POST; |
|
| 262 | + $this->_submitValues = 'get' == $method ? $_GET : $_POST; |
|
| 263 | 263 | $this->_submitFiles = $_FILES; |
| 264 | 264 | } |
| 265 | 265 | $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; |
| 266 | 266 | } |
| 267 | 267 | if ($trackSubmit) { |
| 268 | - unset($this->_submitValues['_qf__' . $formName]); |
|
| 269 | - $this->addElement('hidden', '_qf__' . $formName, null); |
|
| 268 | + unset($this->_submitValues['_qf__'.$formName]); |
|
| 269 | + $this->addElement('hidden', '_qf__'.$formName, null); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) { |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | public static function registerRule($ruleName, $type, $data1, $data2 = null) |
| 347 | 347 | { |
| 348 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
| 348 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
| 349 | 349 | $registry->registerRule($ruleName, $type, $data1, $data2); |
| 350 | 350 | } // end func registerRule |
| 351 | 351 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * @access public |
| 361 | 361 | * @return boolean |
| 362 | 362 | */ |
| 363 | - function elementExists($element=null) |
|
| 363 | + function elementExists($element = null) |
|
| 364 | 364 | { |
| 365 | 365 | return isset($this->_elementIndex[$element]); |
| 366 | 366 | } // end func elementExists |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) |
| 386 | 386 | { |
| 387 | 387 | if (is_object($datasource)) { |
| 388 | - $this->_datasource =& $datasource; |
|
| 388 | + $this->_datasource = & $datasource; |
|
| 389 | 389 | if (is_callable(array($datasource, 'defaultValues'))) { |
| 390 | 390 | $this->setDefaults($datasource->defaultValues($this), $defaultsFilter); |
| 391 | 391 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | if (!$this->elementExists('MAX_FILE_SIZE')) { |
| 497 | 497 | $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize); |
| 498 | 498 | } else { |
| 499 | - $el =& $this->getElement('MAX_FILE_SIZE'); |
|
| 499 | + $el = & $this->getElement('MAX_FILE_SIZE'); |
|
| 500 | 500 | $el->updateAttributes(array('value' => $this->_maxFileSize)); |
| 501 | 501 | } |
| 502 | 502 | } // end func setMaxFileSize |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | $elementObject->onQuickFormEvent('updateValue', null, $this); |
| 635 | 635 | } else { |
| 636 | 636 | $args = func_get_args(); |
| 637 | - $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); |
|
| 637 | + $elementObject = & $this->_loadElement('addElement', $element, array_slice($args, 1)); |
|
| 638 | 638 | if (PEAR::isError($elementObject)) { |
| 639 | 639 | return $elementObject; |
| 640 | 640 | } |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | isset($this->_elementIndex[$elementName]) |
| 647 | 647 | ) { |
| 648 | 648 | if ($this->_elements[$this->_elementIndex[$elementName]]->getType() == $elementObject->getType()) { |
| 649 | - $this->_elements[] =& $elementObject; |
|
| 649 | + $this->_elements[] = & $elementObject; |
|
| 650 | 650 | $elKeys = array_keys($this->_elements); |
| 651 | 651 | $this->_duplicateIndex[$elementName][] = end($elKeys); |
| 652 | 652 | } else { |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | return $error; |
| 662 | 662 | } |
| 663 | 663 | } else { |
| 664 | - $this->_elements[] =& $elementObject; |
|
| 664 | + $this->_elements[] = & $elementObject; |
|
| 665 | 665 | $elKeys = array_keys($this->_elements); |
| 666 | 666 | $this->_elementIndex[$elementName] = end($elKeys); |
| 667 | 667 | } |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | function &insertElementBefore(&$element, $nameAfter) |
| 696 | 696 | { |
| 697 | 697 | if (!empty($this->_duplicateIndex[$nameAfter])) { |
| 698 | - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); |
|
| 698 | + $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "'.$nameAfter.'" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); |
|
| 699 | 699 | return $error; |
| 700 | 700 | } elseif (!$this->elementExists($nameAfter)) { |
| 701 | 701 | $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | for ($i = end($elKeys); $i >= $targetIdx; $i--) { |
| 718 | 718 | if (isset($this->_elements[$i])) { |
| 719 | 719 | $currentName = $this->_elements[$i]->getName(); |
| 720 | - $this->_elements[$i + 1] =& $this->_elements[$i]; |
|
| 720 | + $this->_elements[$i + 1] = & $this->_elements[$i]; |
|
| 721 | 721 | if ($this->_elementIndex[$currentName] == $i) { |
| 722 | 722 | $this->_elementIndex[$currentName] = $i + 1; |
| 723 | 723 | } else { |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | } |
| 729 | 729 | } |
| 730 | 730 | // Put the element in place finally |
| 731 | - $this->_elements[$targetIdx] =& $element; |
|
| 731 | + $this->_elements[$targetIdx] = & $element; |
|
| 732 | 732 | if (!$duplicate) { |
| 733 | 733 | $this->_elementIndex[$elementName] = $targetIdx; |
| 734 | 734 | } else { |
@@ -759,12 +759,12 @@ discard block |
||
| 759 | 759 | * @access public |
| 760 | 760 | * @throws HTML_QuickForm_Error |
| 761 | 761 | */ |
| 762 | - function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true) |
|
| 762 | + function &addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true) |
|
| 763 | 763 | { |
| 764 | 764 | static $anonGroups = 1; |
| 765 | 765 | |
| 766 | 766 | if (0 == strlen($name)) { |
| 767 | - $name = 'qf_group_' . $anonGroups++; |
|
| 767 | + $name = 'qf_group_'.$anonGroups++; |
|
| 768 | 768 | $appendName = false; |
| 769 | 769 | } |
| 770 | 770 | $group = & $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName); |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | if (is_array($value)) { |
| 822 | 822 | $value[] = $v; |
| 823 | 823 | } else { |
| 824 | - $value = (null === $value)? $v: array($value, $v); |
|
| 824 | + $value = (null === $value) ? $v : array($value, $v); |
|
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | } |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | { |
| 845 | 845 | $value = null; |
| 846 | 846 | if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) { |
| 847 | - $value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array(); |
|
| 847 | + $value = isset($this->_submitValues[$elementName]) ? $this->_submitValues[$elementName] : array(); |
|
| 848 | 848 | if (is_array($value) && isset($this->_submitFiles[$elementName])) { |
| 849 | 849 | foreach ($this->_submitFiles[$elementName] as $k => $v) { |
| 850 | 850 | $value = HTML_QuickForm::arrayMerge($value, $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k)); |
@@ -859,34 +859,34 @@ discard block |
||
| 859 | 859 | array('\\', '\''), array('\\\\', '\\\''), |
| 860 | 860 | substr($elementName, 0, $pos) |
| 861 | 861 | ); |
| 862 | - $idx = "['" . str_replace( |
|
| 862 | + $idx = "['".str_replace( |
|
| 863 | 863 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
| 864 | 864 | substr($elementName, $pos + 1, -1) |
| 865 | - ) . "']"; |
|
| 865 | + )."']"; |
|
| 866 | 866 | if (isset($this->_submitValues[$base])) { |
| 867 | 867 | $value = eval("return (isset(\$this->_submitValues['{$base}']{$idx})) ? \$this->_submitValues['{$base}']{$idx} : null;"); |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { |
| 871 | 871 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
| 872 | - $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . |
|
| 873 | - " return null;\n" . |
|
| 874 | - "} else {\n" . |
|
| 872 | + $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n". |
|
| 873 | + " return null;\n". |
|
| 874 | + "} else {\n". |
|
| 875 | 875 | " \$v = array();\n"; |
| 876 | 876 | foreach ($props as $prop) { |
| 877 | 877 | $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; |
| 878 | 878 | } |
| 879 | - $fileValue = eval($code . " return \$v;\n}\n"); |
|
| 879 | + $fileValue = eval($code." return \$v;\n}\n"); |
|
| 880 | 880 | if (null !== $fileValue) { |
| 881 | - $value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue); |
|
| 881 | + $value = null === $value ? $fileValue : HTML_QuickForm::arrayMerge($value, $fileValue); |
|
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | // This is only supposed to work for groups with appendName = false |
| 887 | 887 | if (null === $value && 'group' == $this->getElementType($elementName)) { |
| 888 | - $group =& $this->getElement($elementName); |
|
| 889 | - $elements =& $group->getElements(); |
|
| 888 | + $group = & $this->getElement($elementName); |
|
| 889 | + $elements = & $group->getElements(); |
|
| 890 | 890 | foreach (array_keys($elements) as $key) { |
| 891 | 891 | $name = $group->getElementName($key); |
| 892 | 892 | // prevent endless recursion in case of radios and such |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true); |
| 1050 | 1050 | return $error; |
| 1051 | 1051 | } |
| 1052 | - $el =& $this->_elements[$this->_elementIndex[$elementName]]; |
|
| 1052 | + $el = & $this->_elements[$this->_elementIndex[$elementName]]; |
|
| 1053 | 1053 | unset($this->_elements[$this->_elementIndex[$elementName]]); |
| 1054 | 1054 | if (empty($this->_duplicateIndex[$elementName])) { |
| 1055 | 1055 | unset($this->_elementIndex[$elementName]); |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | $this->_rules[$element] = array(); |
| 1149 | 1149 | } |
| 1150 | 1150 | if ($validation == 'client') { |
| 1151 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
| 1151 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | $this->_rules[$element][] = array( |
| 1154 | 1154 | 'type' => $type, |
@@ -1181,20 +1181,20 @@ discard block |
||
| 1181 | 1181 | * @access public |
| 1182 | 1182 | * @throws HTML_QuickForm_Error |
| 1183 | 1183 | */ |
| 1184 | - function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) |
|
| 1184 | + function addGroupRule($group, $arg1, $type = '', $format = null, $howmany = 0, $validation = 'server', $reset = false) |
|
| 1185 | 1185 | { |
| 1186 | 1186 | if (!$this->elementExists($group)) { |
| 1187 | 1187 | return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - $groupObj =& $this->getElement($group); |
|
| 1190 | + $groupObj = & $this->getElement($group); |
|
| 1191 | 1191 | if (is_array($arg1)) { |
| 1192 | 1192 | $required = 0; |
| 1193 | 1193 | foreach ($arg1 as $elementIndex => $rules) { |
| 1194 | 1194 | $elementName = $groupObj->getElementName($elementIndex); |
| 1195 | 1195 | foreach ($rules as $rule) { |
| 1196 | 1196 | $format = (isset($rule[2])) ? $rule[2] : null; |
| 1197 | - $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server'; |
|
| 1197 | + $validation = (isset($rule[3]) && 'client' == $rule[3]) ? 'client' : 'server'; |
|
| 1198 | 1198 | $reset = isset($rule[4]) && $rule[4]; |
| 1199 | 1199 | $type = $rule[1]; |
| 1200 | 1200 | if (false === ($newName = $this->isRuleRegistered($type, true))) { |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | $required++; |
| 1219 | 1219 | } |
| 1220 | 1220 | if ('client' == $validation) { |
| 1221 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
| 1221 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | } |
| 1224 | 1224 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | $this->_required[] = $group; |
| 1256 | 1256 | } |
| 1257 | 1257 | if ($validation == 'client') { |
| 1258 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
| 1258 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | 1261 | } // end func addGroupRule |
@@ -1312,10 +1312,10 @@ discard block |
||
| 1312 | 1312 | if (false === strpos($elName, '[')) { |
| 1313 | 1313 | $this->_submitValues[$elName] = $this->_recursiveFilter($filter, $value); |
| 1314 | 1314 | } else { |
| 1315 | - $idx = "['" . str_replace( |
|
| 1315 | + $idx = "['".str_replace( |
|
| 1316 | 1316 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
| 1317 | 1317 | $elName |
| 1318 | - ) . "']"; |
|
| 1318 | + )."']"; |
|
| 1319 | 1319 | eval("\$this->_submitValues{$idx} = \$this->_recursiveFilter(\$filter, \$value);"); |
| 1320 | 1320 | } |
| 1321 | 1321 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
| 1435 | 1435 | } |
| 1436 | 1436 | $ruleName = false; |
| 1437 | 1437 | if (is_object($name) && is_a($name, 'html_quickform_rule')) { |
| 1438 | - $ruleName = !empty($name->name)? $name->name: strtolower(get_class($name)); |
|
| 1438 | + $ruleName = !empty($name->name) ? $name->name : strtolower(get_class($name)); |
|
| 1439 | 1439 | } elseif (is_string($name) && class_exists($name)) { |
| 1440 | 1440 | $parent = strtolower($name); |
| 1441 | 1441 | do { |
@@ -1446,7 +1446,7 @@ discard block |
||
| 1446 | 1446 | } while ($parent = get_parent_class($parent)); |
| 1447 | 1447 | } |
| 1448 | 1448 | if ($ruleName) { |
| 1449 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1449 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1450 | 1450 | $registry->registerRule($ruleName, null, $name); |
| 1451 | 1451 | } |
| 1452 | 1452 | return $ruleName; |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | return false; |
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1573 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1574 | 1574 | |
| 1575 | 1575 | foreach ($this->_rules as $target => $rules) { |
| 1576 | 1576 | $submitValue = $this->getSubmitValue($target); |
@@ -1601,10 +1601,10 @@ discard block |
||
| 1601 | 1601 | array('\\', '\''), array('\\\\', '\\\''), |
| 1602 | 1602 | substr($target, 0, $pos) |
| 1603 | 1603 | ); |
| 1604 | - $idx = "['" . str_replace( |
|
| 1604 | + $idx = "['".str_replace( |
|
| 1605 | 1605 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
| 1606 | 1606 | substr($target, $pos + 1, -1) |
| 1607 | - ) . "']"; |
|
| 1607 | + )."']"; |
|
| 1608 | 1608 | eval("\$isUpload = isset(\$this->_submitFiles['{$base}']['name']{$idx});"); |
| 1609 | 1609 | } |
| 1610 | 1610 | if ($isUpload && (!isset($submitValue['error']) || UPLOAD_ERR_NO_FILE == $submitValue['error'])) { |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | $result = $registry->validate($rule['type'], $submitValue, $rule['format'], false); |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int)$result)) { |
|
| 1627 | + if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int) $result)) { |
|
| 1628 | 1628 | if (isset($rule['group'])) { |
| 1629 | 1629 | $this->_errors[$rule['group']] = $rule['message']; |
| 1630 | 1630 | } else { |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | * @access public |
| 1660 | 1660 | * @throws HTML_QuickForm_Error |
| 1661 | 1661 | */ |
| 1662 | - function freeze($elementList=null) |
|
| 1662 | + function freeze($elementList = null) |
|
| 1663 | 1663 | { |
| 1664 | 1664 | if (!isset($elementList)) { |
| 1665 | 1665 | $this->_freezeAll = true; |
@@ -1680,7 +1680,7 @@ discard block |
||
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | if (!empty($elementList)) { |
| 1683 | - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); |
|
| 1683 | + return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '".implode("', '", array_keys($elementList))."' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); |
|
| 1684 | 1684 | } |
| 1685 | 1685 | return true; |
| 1686 | 1686 | } // end func freeze |
@@ -1736,7 +1736,7 @@ discard block |
||
| 1736 | 1736 | function accept(&$renderer) { |
| 1737 | 1737 | $renderer->startForm($this); |
| 1738 | 1738 | foreach (array_keys($this->_elements) as $key) { |
| 1739 | - $element =& $this->_elements[$key]; |
|
| 1739 | + $element = & $this->_elements[$key]; |
|
| 1740 | 1740 | $elementName = $element->getName(); |
| 1741 | 1741 | $required = ($this->isElementRequired($elementName) && !$element->isFrozen()); |
| 1742 | 1742 | $error = $this->getElementError($elementName); |
@@ -1782,7 +1782,7 @@ discard block |
||
| 1782 | 1782 | if (!is_null($in_data)) { |
| 1783 | 1783 | $this->addElement('html', $in_data); |
| 1784 | 1784 | } |
| 1785 | - $renderer =& $this->defaultRenderer(); |
|
| 1785 | + $renderer = & $this->defaultRenderer(); |
|
| 1786 | 1786 | $this->accept($renderer); |
| 1787 | 1787 | |
| 1788 | 1788 | return $renderer->toHtml(); |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | return ''; |
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1807 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
| 1808 | 1808 | $test = array(); |
| 1809 | 1809 | $js_escape = array( |
| 1810 | 1810 | "\r" => '\r', |
@@ -1820,30 +1820,30 @@ discard block |
||
| 1820 | 1820 | if ('client' == $rule['validation']) { |
| 1821 | 1821 | unset($element); |
| 1822 | 1822 | |
| 1823 | - $dependent = isset($rule['dependent']) && is_array($rule['dependent']); |
|
| 1823 | + $dependent = isset($rule['dependent']) && is_array($rule['dependent']); |
|
| 1824 | 1824 | $rule['message'] = strtr($rule['message'], $js_escape); |
| 1825 | 1825 | |
| 1826 | 1826 | if (isset($rule['group'])) { |
| 1827 | - $group =& $this->getElement($rule['group']); |
|
| 1827 | + $group = & $this->getElement($rule['group']); |
|
| 1828 | 1828 | // No JavaScript validation for frozen elements |
| 1829 | 1829 | if ($group->isFrozen()) { |
| 1830 | 1830 | continue 2; |
| 1831 | 1831 | } |
| 1832 | - $elements =& $group->getElements(); |
|
| 1832 | + $elements = & $group->getElements(); |
|
| 1833 | 1833 | foreach (array_keys($elements) as $key) { |
| 1834 | 1834 | if ($elementName == $group->getElementName($key)) { |
| 1835 | - $element =& $elements[$key]; |
|
| 1835 | + $element = & $elements[$key]; |
|
| 1836 | 1836 | break; |
| 1837 | 1837 | } |
| 1838 | 1838 | } |
| 1839 | 1839 | } elseif ($dependent) { |
| 1840 | - $element = array(); |
|
| 1841 | - $element[] =& $this->getElement($elementName); |
|
| 1840 | + $element = array(); |
|
| 1841 | + $element[] = & $this->getElement($elementName); |
|
| 1842 | 1842 | foreach ($rule['dependent'] as $elName) { |
| 1843 | - $element[] =& $this->getElement($elName); |
|
| 1843 | + $element[] = & $this->getElement($elName); |
|
| 1844 | 1844 | } |
| 1845 | 1845 | } else { |
| 1846 | - $element =& $this->getElement($elementName); |
|
| 1846 | + $element = & $this->getElement($elementName); |
|
| 1847 | 1847 | } |
| 1848 | 1848 | // No JavaScript validation for frozen elements |
| 1849 | 1849 | if (is_object($element) && $element->isFrozen()) { |
@@ -1862,23 +1862,23 @@ discard block |
||
| 1862 | 1862 | } |
| 1863 | 1863 | if (count($test) > 0) { |
| 1864 | 1864 | return |
| 1865 | - "\n<script type=\"text/javascript\">\n" . |
|
| 1866 | - "//<![CDATA[\n" . |
|
| 1867 | - "function validate_" . $this->_attributes['id'] . "(frm) {\n" . |
|
| 1868 | - " var value = '';\n" . |
|
| 1869 | - " var errFlag = new Array();\n" . |
|
| 1870 | - " var _qfGroups = {};\n" . |
|
| 1871 | - " _qfMsg = '';\n\n" . |
|
| 1872 | - join("\n", $test) . |
|
| 1873 | - "\n if (_qfMsg != '') {\n" . |
|
| 1874 | - " _qfMsg = '" . strtr($this->_jsPrefix, $js_escape) . "' + _qfMsg;\n" . |
|
| 1875 | - " _qfMsg = _qfMsg + '\\n" . strtr($this->_jsPostfix, $js_escape) . "';\n" . |
|
| 1876 | - " alert(_qfMsg);\n" . |
|
| 1877 | - " return false;\n" . |
|
| 1878 | - " }\n" . |
|
| 1879 | - " return true;\n" . |
|
| 1880 | - "}\n" . |
|
| 1881 | - "//]]>\n" . |
|
| 1865 | + "\n<script type=\"text/javascript\">\n". |
|
| 1866 | + "//<![CDATA[\n". |
|
| 1867 | + "function validate_".$this->_attributes['id']."(frm) {\n". |
|
| 1868 | + " var value = '';\n". |
|
| 1869 | + " var errFlag = new Array();\n". |
|
| 1870 | + " var _qfGroups = {};\n". |
|
| 1871 | + " _qfMsg = '';\n\n". |
|
| 1872 | + join("\n", $test). |
|
| 1873 | + "\n if (_qfMsg != '') {\n". |
|
| 1874 | + " _qfMsg = '".strtr($this->_jsPrefix, $js_escape)."' + _qfMsg;\n". |
|
| 1875 | + " _qfMsg = _qfMsg + '\\n".strtr($this->_jsPostfix, $js_escape)."';\n". |
|
| 1876 | + " alert(_qfMsg);\n". |
|
| 1877 | + " return false;\n". |
|
| 1878 | + " }\n". |
|
| 1879 | + " return true;\n". |
|
| 1880 | + "}\n". |
|
| 1881 | + "//]]>\n". |
|
| 1882 | 1882 | "</script>"; |
| 1883 | 1883 | } |
| 1884 | 1884 | return ''; |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | */ |
| 1898 | 1898 | function getSubmitValues($mergeFiles = false) |
| 1899 | 1899 | { |
| 1900 | - return $mergeFiles? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles): $this->_submitValues; |
|
| 1900 | + return $mergeFiles ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues; |
|
| 1901 | 1901 | } // end func getSubmitValues |
| 1902 | 1902 | |
| 1903 | 1903 | // }}} |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | if (is_array($value)) { |
| 1952 | 1952 | $value[] = $v; |
| 1953 | 1953 | } else { |
| 1954 | - $value = (null === $value)? $v: array($value, $v); |
|
| 1954 | + $value = (null === $value) ? $v : array($value, $v); |
|
| 1955 | 1955 | } |
| 1956 | 1956 | } |
| 1957 | 1957 | } |
@@ -630,8 +630,8 @@ discard block |
||
| 630 | 630 | public function &addElement($element) |
| 631 | 631 | { |
| 632 | 632 | if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { |
| 633 | - $elementObject = &$element; |
|
| 634 | - $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
| 633 | + $elementObject = &$element; |
|
| 634 | + $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
| 635 | 635 | } else { |
| 636 | 636 | $args = func_get_args(); |
| 637 | 637 | $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); |
@@ -676,22 +676,22 @@ discard block |
||
| 676 | 676 | // }}} |
| 677 | 677 | // {{{ insertElementBefore() |
| 678 | 678 | |
| 679 | - /** |
|
| 680 | - * Inserts a new element right before the other element |
|
| 681 | - * |
|
| 682 | - * Warning: it is not possible to check whether the $element is already |
|
| 683 | - * added to the form, therefore if you want to move the existing form |
|
| 684 | - * element to a new position, you'll have to use removeElement(): |
|
| 685 | - * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
| 686 | - * |
|
| 687 | - * @access public |
|
| 688 | - * @since 3.2.4 |
|
| 689 | - * @param HTML_QuickForm_element Element to insert |
|
| 690 | - * @param string Name of the element before which the new |
|
| 691 | - * one is inserted |
|
| 692 | - * @return HTML_QuickForm_element reference to inserted element |
|
| 693 | - * @throws HTML_QuickForm_Error |
|
| 694 | - */ |
|
| 679 | + /** |
|
| 680 | + * Inserts a new element right before the other element |
|
| 681 | + * |
|
| 682 | + * Warning: it is not possible to check whether the $element is already |
|
| 683 | + * added to the form, therefore if you want to move the existing form |
|
| 684 | + * element to a new position, you'll have to use removeElement(): |
|
| 685 | + * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
| 686 | + * |
|
| 687 | + * @access public |
|
| 688 | + * @since 3.2.4 |
|
| 689 | + * @param HTML_QuickForm_element Element to insert |
|
| 690 | + * @param string Name of the element before which the new |
|
| 691 | + * one is inserted |
|
| 692 | + * @return HTML_QuickForm_element reference to inserted element |
|
| 693 | + * @throws HTML_QuickForm_Error |
|
| 694 | + */ |
|
| 695 | 695 | function &insertElementBefore(&$element, $nameAfter) |
| 696 | 696 | { |
| 697 | 697 | if (!empty($this->_duplicateIndex[$nameAfter])) { |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { |
| 871 | 871 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
| 872 | 872 | $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . |
| 873 | - " return null;\n" . |
|
| 874 | - "} else {\n" . |
|
| 875 | - " \$v = array();\n"; |
|
| 873 | + " return null;\n" . |
|
| 874 | + "} else {\n" . |
|
| 875 | + " \$v = array();\n"; |
|
| 876 | 876 | foreach ($props as $prop) { |
| 877 | 877 | $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; |
| 878 | 878 | } |
@@ -917,13 +917,13 @@ discard block |
||
| 917 | 917 | return $value; |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | - /** |
|
| 921 | - * A helper function to change the indexes in $_FILES array |
|
| 922 | - * |
|
| 923 | - * @param mixed Some value from the $_FILES array |
|
| 924 | - * @param string The key from the $_FILES array that should be appended |
|
| 925 | - * @return array |
|
| 926 | - */ |
|
| 920 | + /** |
|
| 921 | + * A helper function to change the indexes in $_FILES array |
|
| 922 | + * |
|
| 923 | + * @param mixed Some value from the $_FILES array |
|
| 924 | + * @param string The key from the $_FILES array that should be appended |
|
| 925 | + * @return array |
|
| 926 | + */ |
|
| 927 | 927 | function _reindexFiles($value, $key) |
| 928 | 928 | { |
| 929 | 929 | if (!is_array($value)) { |
@@ -976,27 +976,27 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | } // end func setElementError |
| 978 | 978 | |
| 979 | - // }}} |
|
| 980 | - // {{{ getElementType() |
|
| 981 | - |
|
| 982 | - /** |
|
| 983 | - * Returns the type of the given element |
|
| 984 | - * |
|
| 985 | - * @param string $element Name of form element |
|
| 986 | - * @since 1.1 |
|
| 987 | - * @access public |
|
| 988 | - * @return string Type of the element, false if the element is not found |
|
| 989 | - */ |
|
| 990 | - function getElementType($element) |
|
| 991 | - { |
|
| 992 | - if (isset($this->_elementIndex[$element])) { |
|
| 993 | - return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
| 994 | - } |
|
| 995 | - return false; |
|
| 996 | - } // end func getElementType |
|
| 997 | - |
|
| 998 | - // }}} |
|
| 999 | - // {{{ updateElementAttr() |
|
| 979 | + // }}} |
|
| 980 | + // {{{ getElementType() |
|
| 981 | + |
|
| 982 | + /** |
|
| 983 | + * Returns the type of the given element |
|
| 984 | + * |
|
| 985 | + * @param string $element Name of form element |
|
| 986 | + * @since 1.1 |
|
| 987 | + * @access public |
|
| 988 | + * @return string Type of the element, false if the element is not found |
|
| 989 | + */ |
|
| 990 | + function getElementType($element) |
|
| 991 | + { |
|
| 992 | + if (isset($this->_elementIndex[$element])) { |
|
| 993 | + return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
| 994 | + } |
|
| 995 | + return false; |
|
| 996 | + } // end func getElementType |
|
| 997 | + |
|
| 998 | + // }}} |
|
| 999 | + // {{{ updateElementAttr() |
|
| 1000 | 1000 | |
| 1001 | 1001 | /** |
| 1002 | 1002 | * Updates Attributes for one or more elements |
@@ -1263,18 +1263,18 @@ discard block |
||
| 1263 | 1263 | // }}} |
| 1264 | 1264 | // {{{ addFormRule() |
| 1265 | 1265 | |
| 1266 | - /** |
|
| 1267 | - * Adds a global validation rule |
|
| 1268 | - * |
|
| 1269 | - * This should be used when for a rule involving several fields or if |
|
| 1270 | - * you want to use some completely custom validation for your form. |
|
| 1271 | - * The rule function/method should return true in case of successful |
|
| 1272 | - * validation and array('element name' => 'error') when there were errors. |
|
| 1273 | - * |
|
| 1274 | - * @access public |
|
| 1275 | - * @param mixed Callback, either function name or array(&$object, 'method') |
|
| 1276 | - * @throws HTML_QuickForm_Error |
|
| 1277 | - */ |
|
| 1266 | + /** |
|
| 1267 | + * Adds a global validation rule |
|
| 1268 | + * |
|
| 1269 | + * This should be used when for a rule involving several fields or if |
|
| 1270 | + * you want to use some completely custom validation for your form. |
|
| 1271 | + * The rule function/method should return true in case of successful |
|
| 1272 | + * validation and array('element name' => 'error') when there were errors. |
|
| 1273 | + * |
|
| 1274 | + * @access public |
|
| 1275 | + * @param mixed Callback, either function name or array(&$object, 'method') |
|
| 1276 | + * @throws HTML_QuickForm_Error |
|
| 1277 | + */ |
|
| 1278 | 1278 | function addFormRule($rule) |
| 1279 | 1279 | { |
| 1280 | 1280 | if (!is_callable($rule)) { |
@@ -1351,18 +1351,18 @@ discard block |
||
| 1351 | 1351 | // }}} |
| 1352 | 1352 | // {{{ arrayMerge() |
| 1353 | 1353 | |
| 1354 | - /** |
|
| 1355 | - * Merges two arrays |
|
| 1356 | - * |
|
| 1357 | - * Merges two array like the PHP function array_merge but recursively. |
|
| 1358 | - * The main difference is that existing keys will not be renumbered |
|
| 1359 | - * if they are integers. |
|
| 1360 | - * |
|
| 1361 | - * @access public |
|
| 1362 | - * @param array $a original array |
|
| 1363 | - * @param array $b array which will be merged into first one |
|
| 1364 | - * @return array merged array |
|
| 1365 | - */ |
|
| 1354 | + /** |
|
| 1355 | + * Merges two arrays |
|
| 1356 | + * |
|
| 1357 | + * Merges two array like the PHP function array_merge but recursively. |
|
| 1358 | + * The main difference is that existing keys will not be renumbered |
|
| 1359 | + * if they are integers. |
|
| 1360 | + * |
|
| 1361 | + * @access public |
|
| 1362 | + * @param array $a original array |
|
| 1363 | + * @param array $b array which will be merged into first one |
|
| 1364 | + * @return array merged array |
|
| 1365 | + */ |
|
| 1366 | 1366 | static function arrayMerge($a, $b) |
| 1367 | 1367 | { |
| 1368 | 1368 | foreach ($b as $k => $v) { |
@@ -1493,10 +1493,10 @@ discard block |
||
| 1493 | 1493 | */ |
| 1494 | 1494 | function isElementFrozen($element) |
| 1495 | 1495 | { |
| 1496 | - if (isset($this->_elementIndex[$element])) { |
|
| 1497 | - return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
| 1498 | - } |
|
| 1499 | - return false; |
|
| 1496 | + if (isset($this->_elementIndex[$element])) { |
|
| 1497 | + return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
| 1498 | + } |
|
| 1499 | + return false; |
|
| 1500 | 1500 | } // end func isElementFrozen |
| 1501 | 1501 | |
| 1502 | 1502 | // }}} |
@@ -1685,7 +1685,7 @@ discard block |
||
| 1685 | 1685 | */ |
| 1686 | 1686 | function isFrozen() |
| 1687 | 1687 | { |
| 1688 | - return $this->_freezeAll; |
|
| 1688 | + return $this->_freezeAll; |
|
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | 1691 | /** |
@@ -1707,14 +1707,14 @@ discard block |
||
| 1707 | 1707 | return call_user_func($callback, $values); |
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | - /** |
|
| 1711 | - * Accepts a renderer |
|
| 1712 | - * |
|
| 1713 | - * @param object An HTML_QuickForm_Renderer object |
|
| 1714 | - * @since 3.0 |
|
| 1715 | - * @access public |
|
| 1716 | - * @return void |
|
| 1717 | - */ |
|
| 1710 | + /** |
|
| 1711 | + * Accepts a renderer |
|
| 1712 | + * |
|
| 1713 | + * @param object An HTML_QuickForm_Renderer object |
|
| 1714 | + * @since 3.0 |
|
| 1715 | + * @access public |
|
| 1716 | + * @return void |
|
| 1717 | + */ |
|
| 1718 | 1718 | function accept(&$renderer) { |
| 1719 | 1719 | $renderer->startForm($this); |
| 1720 | 1720 | foreach (array_keys($this->_elements) as $key) { |
@@ -1727,13 +1727,13 @@ discard block |
||
| 1727 | 1727 | $renderer->finishForm($this); |
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | - /** |
|
| 1731 | - * Returns a reference to default renderer object |
|
| 1732 | - * |
|
| 1733 | - * @access public |
|
| 1734 | - * @since 3.0 |
|
| 1735 | - * @return HTML_QuickForm_Renderer_Default |
|
| 1736 | - */ |
|
| 1730 | + /** |
|
| 1731 | + * Returns a reference to default renderer object |
|
| 1732 | + * |
|
| 1733 | + * @access public |
|
| 1734 | + * @since 3.0 |
|
| 1735 | + * @return HTML_QuickForm_Renderer_Default |
|
| 1736 | + */ |
|
| 1737 | 1737 | function &defaultRenderer() { |
| 1738 | 1738 | if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { |
| 1739 | 1739 | // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3 |
@@ -1889,7 +1889,7 @@ discard block |
||
| 1889 | 1889 | // |
| 1890 | 1890 | $this->accept($renderer); |
| 1891 | 1891 | return $renderer->toArray(); |
| 1892 | - } |
|
| 1892 | + } |
|
| 1893 | 1893 | |
| 1894 | 1894 | /** |
| 1895 | 1895 | * Returns a 'safe' element's value |
@@ -1961,15 +1961,15 @@ discard block |
||
| 1961 | 1961 | return $values; |
| 1962 | 1962 | } |
| 1963 | 1963 | |
| 1964 | - /** |
|
| 1965 | - * Tells whether the form was already submitted |
|
| 1966 | - * |
|
| 1967 | - * This is useful since the _submitFiles and _submitValues arrays |
|
| 1968 | - * may be completely empty after the trackSubmit value is removed. |
|
| 1969 | - * |
|
| 1970 | - * @access public |
|
| 1971 | - * @return bool |
|
| 1972 | - */ |
|
| 1964 | + /** |
|
| 1965 | + * Tells whether the form was already submitted |
|
| 1966 | + * |
|
| 1967 | + * This is useful since the _submitFiles and _submitValues arrays |
|
| 1968 | + * may be completely empty after the trackSubmit value is removed. |
|
| 1969 | + * |
|
| 1970 | + * @access public |
|
| 1971 | + * @return bool |
|
| 1972 | + */ |
|
| 1973 | 1973 | function isSubmitted() |
| 1974 | 1974 | { |
| 1975 | 1975 | return $this->_flagSubmitted; |
@@ -2056,21 +2056,21 @@ discard block |
||
| 2056 | 2056 | { |
| 2057 | 2057 | |
| 2058 | 2058 | /** |
| 2059 | - * Prefix for all error messages |
|
| 2060 | - * @var string |
|
| 2061 | - */ |
|
| 2059 | + * Prefix for all error messages |
|
| 2060 | + * @var string |
|
| 2061 | + */ |
|
| 2062 | 2062 | var $error_message_prefix = 'QuickForm Error: '; |
| 2063 | 2063 | |
| 2064 | 2064 | /** |
| 2065 | - * Creates a quickform error object, extending the PEAR_Error class |
|
| 2066 | - * |
|
| 2067 | - * @param int $code the error code |
|
| 2068 | - * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
| 2069 | - * @param int $level intensity of the error (PHP error code) |
|
| 2070 | - * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
| 2071 | - */ |
|
| 2065 | + * Creates a quickform error object, extending the PEAR_Error class |
|
| 2066 | + * |
|
| 2067 | + * @param int $code the error code |
|
| 2068 | + * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
| 2069 | + * @param int $level intensity of the error (PHP error code) |
|
| 2070 | + * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
| 2071 | + */ |
|
| 2072 | 2072 | function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, |
| 2073 | - $level = E_USER_NOTICE, $debuginfo = null) |
|
| 2073 | + $level = E_USER_NOTICE, $debuginfo = null) |
|
| 2074 | 2074 | { |
| 2075 | 2075 | if (is_int($code)) { |
| 2076 | 2076 | $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo); |