original_string: function lock($path) {
          $this->_path = $this->translate_uri($path);
          $this->header_unset();
          $this->create_basic_request('LOCK');
          $this->header_add('Timeout: Infinite');
          $this->header_add('Content-type: text/xml');
          // create the xml request ...
          $xml =  "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
          $xml .= "<D:lockinfo xmlns:D='DAV:'\r\n>";
          $xml .= "  <D:lockscope><D:exclusive/></D:lockscope>\r\n";
          $xml .= "  <D:locktype><D:write/></D:locktype>\r\n";
          $xml .= "  <D:owner>\r\n";
          $xml .= "    <D:href>".($this->_user)."</D:href>\r\n";
          $xml .= "  </D:owner>\r\n";
          $xml .= "</D:lockinfo>\r\n";
          $this->header_add('Content-length: ' . strlen($xml));
          $this->send_request();
          // send also xml
          fputs($this->sock, $xml);
          $this->get_respond();
          $response = $this->process_respond();
          // validate the response ... (only basic validation)
          // check http-version
          if ($response['status']['http-version'] == 'HTTP/1.1' ||
              $response['status']['http-version'] == 'HTTP/1.0') {
              /* seems to be http ... proceed
              rfc 2518 says:
              200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body.
              412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the
                       request in the lockinfo XML element.
              423 (Locked) - The resource is locked, so the method has been rejected.
               */
  
                  switch($response['status']['status-code']) {
                  case 200:
                      // collection was successfully locked... see xml response to get lock token...
                      if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) {
                          // ok let's get the content of the xml stuff
                          $this->_parser = xml_parser_create_ns();
                          $this->_parserid = (int) $this->_parser;
                          // forget old data...
                          unset($this->_lock[$this->_parserid]);
                          unset($this->_xmltree[$this->_parserid]);
                          xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0);
                          xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0);
                          xml_set_object($this->_parser, $this);
                          xml_set_element_handler($this->_parser, "_lock_startElement", "_endElement");
                          xml_set_character_data_handler($this->_parser, "_lock_cdata");
  
                          if (!xml_parse($this->_parser, $response['body'])) {
                              die(sprintf("XML error: %s at line %d",
                                  xml_error_string(xml_get_error_code($this->_parser)),
                                  xml_get_current_line_number($this->_parser)));
                          }
  
                          // Free resources
                          xml_parser_free($this->_parser);
                          // add status code to array
                          $this->_lock[$this->_parserid]['status'] = 200;
                          return $this->_lock[$this->_parserid];
  
                      } else {
                          print 'Missing Content-Type: text/xml header in response.<br>';
                      }
                      return false;
  
                  default:
                      // hmm. not what we expected. Just return what we got from webdav server
                      // someone else has to handle it.
                      $this->_lock['status'] = $response['status']['status-code'];
                      return $this->_lock;
                  }
              }
  
  
      }
code: function lock($path) {
          $this->_path = $this->translate_uri($path);
          $this->header_unset();
          $this->create_basic_request('LOCK');
          $this->header_add('Timeout: Infinite');
          $this->header_add('Content-type: text/xml');
          // create the xml request ...
          $xml =  "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
          $xml .= "<D:lockinfo xmlns:D='DAV:'\r\n>";
          $xml .= "  <D:lockscope><D:exclusive/></D:lockscope>\r\n";
          $xml .= "  <D:locktype><D:write/></D:locktype>\r\n";
          $xml .= "  <D:owner>\r\n";
          $xml .= "    <D:href>".($this->_user)."</D:href>\r\n";
          $xml .= "  </D:owner>\r\n";
          $xml .= "</D:lockinfo>\r\n";
          $this->header_add('Content-length: ' . strlen($xml));
          $this->send_request();
          // send also xml
          fputs($this->sock, $xml);
          $this->get_respond();
          $response = $this->process_respond();
          // validate the response ... (only basic validation)
          // check http-version
          if ($response['status']['http-version'] == 'HTTP/1.1' ||
              $response['status']['http-version'] == 'HTTP/1.0') {
              /* seems to be http ... proceed
              rfc 2518 says:
              200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body.
              412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the
                       request in the lockinfo XML element.
              423 (Locked) - The resource is locked, so the method has been rejected.
               */
  
                  switch($response['status']['status-code']) {
                  case 200:
                      // collection was successfully locked... see xml response to get lock token...
                      if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) {
                          // ok let's get the content of the xml stuff
                          $this->_parser = xml_parser_create_ns();
                          $this->_parserid = (int) $this->_parser;
                          // forget old data...
                          unset($this->_lock[$this->_parserid]);
                          unset($this->_xmltree[$this->_parserid]);
                          xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0);
                          xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0);
                          xml_set_object($this->_parser, $this);
                          xml_set_element_handler($this->_parser, "_lock_startElement", "_endElement");
                          xml_set_character_data_handler($this->_parser, "_lock_cdata");
  
                          if (!xml_parse($this->_parser, $response['body'])) {
                              die(sprintf("XML error: %s at line %d",
                                  xml_error_string(xml_get_error_code($this->_parser)),
                                  xml_get_current_line_number($this->_parser)));
                          }
  
                          // Free resources
                          xml_parser_free($this->_parser);
                          // add status code to array
                          $this->_lock[$this->_parserid]['status'] = 200;
                          return $this->_lock[$this->_parserid];
  
                      } else {
                          print 'Missing Content-Type: text/xml header in response.<br>';
                      }
                      return false;
  
                  default:
                      // hmm. not what we expected. Just return what we got from webdav server
                      // someone else has to handle it.
                      $this->_lock['status'] = $response['status']['status-code'];
                      return $this->_lock;
                  }
              }
  
  
      }
code_tokens: function lock ( $ path ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'LOCK' ) ; $ this -> header_add ( 'Timeout: Infinite' ) ; $ this -> header_add ( 'Content-type: text/xml' ) ; // create the xml request ... $ xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" ; $ xml .= "<D:lockinfo xmlns:D='DAV:'\r\n>" ; $ xml .= "  <D:lockscope><D:exclusive/></D:lockscope>\r\n" ; $ xml .= "  <D:locktype><D:write/></D:locktype>\r\n" ; $ xml .= "  <D:owner>\r\n" ; $ xml .= "    <D:href>" . ( $ this -> _user ) . "</D:href>\r\n" ; $ xml .= "  </D:owner>\r\n" ; $ xml .= "</D:lockinfo>\r\n" ; $ this -> header_add ( 'Content-length: ' . strlen ( $ xml ) ) ; $ this -> send_request ( ) ; // send also xml fputs ( $ this -> sock , $ xml ) ; $ this -> get_respond ( ) ; $ response = $ this -> process_respond ( ) ; // validate the response ... (only basic validation) // check http-version if ( $ response [ 'status' ] [ 'http-version' ] == 'HTTP/1.1' || $ response [ 'status' ] [ 'http-version' ] == 'HTTP/1.0' ) { /* seems to be http ... proceed
              rfc 2518 says:
              200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body.
              412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the
                       request in the lockinfo XML element.
              423 (Locked) - The resource is locked, so the method has been rejected.
               */ switch ( $ response [ 'status' ] [ 'status-code' ] ) { case 200 : // collection was successfully locked... see xml response to get lock token... if ( strcmp ( $ response [ 'header' ] [ 'Content-Type' ] , 'text/xml; charset="utf-8"' ) == 0 ) { // ok let's get the content of the xml stuff $ this -> _parser = xml_parser_create_ns ( ) ; $ this -> _parserid = ( int ) $ this -> _parser ; // forget old data... unset ( $ this -> _lock [ $ this -> _parserid ] ) ; unset ( $ this -> _xmltree [ $ this -> _parserid ] ) ; xml_parser_set_option ( $ this -> _parser , XML_OPTION_SKIP_WHITE , 0 ) ; xml_parser_set_option ( $ this -> _parser , XML_OPTION_CASE_FOLDING , 0 ) ; xml_set_object ( $ this -> _parser , $ this ) ; xml_set_element_handler ( $ this -> _parser , "_lock_startElement" , "_endElement" ) ; xml_set_character_data_handler ( $ this -> _parser , "_lock_cdata" ) ; if ( ! xml_parse ( $ this -> _parser , $ response [ 'body' ] ) ) { die ( sprintf ( "XML error: %s at line %d" , xml_error_string ( xml_get_error_code ( $ this -> _parser ) ) , xml_get_current_line_number ( $ this -> _parser ) ) ) ; } // Free resources xml_parser_free ( $ this -> _parser ) ; // add status code to array $ this -> _lock [ $ this -> _parserid ] [ 'status' ] = 200 ; return $ this -> _lock [ $ this -> _parserid ] ; } else { print 'Missing Content-Type: text/xml header in response.<br>' ; } return false ; default : // hmm. not what we expected. Just return what we got from webdav server // someone else has to handle it. $ this -> _lock [ 'status' ] = $ response [ 'status' ] [ 'status-code' ] ; return $ this -> _lock ; } } }
docstring: Public method lock
  
  Locks a file or collection.
  
  Lock uses this->_user as lock owner.
  
  @param string path
  @return int status code (look at rfc 2518). false on error.
docstring_tokens: Public method lock