From c3dc2c68f3bbaa9577c12fa6af55afe2ab3f2880 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 14:03:48 +0900 Subject: [PATCH 1/8] Import additional composer dependencies --- composer.json | 5 +- composer.lock | 291 +- vendor/composer/ClassLoader.php | 2 +- vendor/composer/autoload_classmap.php | 35 + vendor/composer/autoload_files.php | 1 + vendor/composer/autoload_namespaces.php | 2 + vendor/composer/autoload_psr4.php | 1 + vendor/composer/autoload_real.php | 4 + vendor/composer/include_paths.php | 10 + vendor/composer/installed.json | 499 +- vendor/matthiasmullie/minify/src/CSS.php | 13 +- .../path-converter/src/Converter.php | 21 +- vendor/pear/http_request2/HTTP/Request2.php | 1030 +++ .../http_request2/HTTP/Request2/Adapter.php | 137 + .../HTTP/Request2/Adapter/Curl.php | 567 ++ .../HTTP/Request2/Adapter/Mock.php | 166 + .../HTTP/Request2/Adapter/Socket.php | 1121 +++ .../http_request2/HTTP/Request2/CookieJar.php | 494 ++ .../http_request2/HTTP/Request2/Exception.php | 160 + .../HTTP/Request2/MultipartBody.php | 268 + .../HTTP/Request2/Observer/Log.php | 192 + .../http_request2/HTTP/Request2/Response.php | 631 ++ .../http_request2/HTTP/Request2/SOCKS5.php | 135 + .../HTTP/Request2/SocketWrapper.php | 297 + vendor/pear/http_request2/README.md | 80 + vendor/pear/http_request2/composer.json | 34 + .../pear/http_request2/data/generate-list.php | 96 + .../http_request2/data/public-suffix-list.php | 6701 +++++++++++++++++ vendor/pear/http_request2/docs/LICENSE | 31 + .../docs/examples/upload-rapidshare.php | 58 + vendor/pear/http_request2/package.xml | 646 ++ vendor/pear/http_request2/tests/AllTests.php | 54 + .../tests/NetworkConfig.php.dist | 58 + .../pear/http_request2/tests/ObserverTest.php | 95 + .../tests/Request2/Adapter/AllTests.php | 70 + .../Request2/Adapter/CommonNetworkTest.php | 387 + .../tests/Request2/Adapter/CurlTest.php | 120 + .../tests/Request2/Adapter/MockTest.php | 157 + .../tests/Request2/Adapter/SkippedTests.php | 56 + .../Request2/Adapter/SocketProxyTest.php | 55 + .../tests/Request2/Adapter/SocketTest.php | 159 + .../http_request2/tests/Request2/AllTests.php | 56 + .../tests/Request2/CookieJarTest.php | 370 + .../tests/Request2/MultipartBodyTest.php | 102 + .../tests/Request2/ResponseTest.php | 128 + .../pear/http_request2/tests/Request2Test.php | 391 + .../pear/http_request2/tests/TestHelper.php | 51 + .../pear/http_request2/tests/_files/bug_15305 | Bin 0 -> 16338 bytes .../pear/http_request2/tests/_files/bug_18169 | 9 + .../pear/http_request2/tests/_files/empty.gif | Bin 0 -> 43 bytes .../http_request2/tests/_files/plaintext.txt | 1 + .../tests/_files/response_cookies | 13 + .../tests/_files/response_deflate | Bin 0 -> 1654 bytes .../http_request2/tests/_files/response_gzip | Bin 0 -> 1672 bytes .../tests/_files/response_gzip_broken | Bin 0 -> 221 bytes .../tests/_files/response_headers | 12 + .../tests/_network/basicauth.php | 33 + .../http_request2/tests/_network/bug19934.php | 27 + .../http_request2/tests/_network/cookies.php | 24 + .../tests/_network/digestauth.php | 83 + .../tests/_network/getparameters.php | 24 + .../tests/_network/postparameters.php | 24 + .../tests/_network/rawpostdata.php | 22 + .../tests/_network/redirects.php | 47 + .../tests/_network/setcookie.php | 27 + .../http_request2/tests/_network/timeout.php | 23 + .../http_request2/tests/_network/uploads.php | 36 + vendor/pear/net_url2/.gitignore | 7 + vendor/pear/net_url2/.scrutinizer.yml | 38 + vendor/pear/net_url2/.travis.yml | 17 + vendor/pear/net_url2/Net/URL2.php | 1219 +++ vendor/pear/net_url2/README.md | 43 + vendor/pear/net_url2/composer.json | 47 + vendor/pear/net_url2/docs/6470.php | 56 + vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes | 27 + vendor/pear/net_url2/docs/example.php | 62 + vendor/pear/net_url2/package.xml | 469 ++ vendor/pear/net_url2/phpunit.xml.dist | 17 + vendor/pear/net_url2/tests/AllTests.php | 59 + vendor/pear/net_url2/tests/Net/URL2Test.php | 1088 +++ vendor/pear/pear_exception/.gitignore | 6 + vendor/pear/pear_exception/.travis.yml | 7 + vendor/pear/pear_exception/LICENSE | 27 + vendor/pear/pear_exception/PEAR/Exception.php | 456 ++ vendor/pear/pear_exception/composer.json | 43 + vendor/pear/pear_exception/package.xml | 120 + .../tests/PEAR/ExceptionTest.php | 78 + vendor/swiftmailer/swiftmailer/.gitattributes | 9 + vendor/swiftmailer/swiftmailer/.gitignore | 4 + vendor/swiftmailer/swiftmailer/.travis.yml | 25 + vendor/swiftmailer/swiftmailer/CHANGES | 206 + vendor/swiftmailer/swiftmailer/LICENSE | 19 + vendor/swiftmailer/swiftmailer/README | 16 + vendor/swiftmailer/swiftmailer/VERSION | 1 + vendor/swiftmailer/swiftmailer/composer.json | 31 + .../swiftmailer/swiftmailer/doc/headers.rst | 742 ++ .../swiftmailer/doc/help-resources.rst | 44 + .../swiftmailer/doc/including-the-files.rst | 46 + vendor/swiftmailer/swiftmailer/doc/index.rst | 16 + .../swiftmailer/doc/installing.rst | 89 + .../swiftmailer/doc/introduction.rst | 135 + .../swiftmailer/swiftmailer/doc/japanese.rst | 22 + .../swiftmailer/swiftmailer/doc/messages.rst | 1057 +++ .../swiftmailer/swiftmailer/doc/overview.rst | 161 + .../swiftmailer/swiftmailer/doc/plugins.rst | 385 + .../swiftmailer/swiftmailer/doc/sending.rst | 607 ++ .../swiftmailer/doc/uml/Encoders.graffle | Bin 0 -> 3503 bytes .../swiftmailer/doc/uml/Mime.graffle | Bin 0 -> 5575 bytes .../swiftmailer/doc/uml/Transports.graffle | Bin 0 -> 3061 bytes .../swiftmailer/lib/classes/Swift.php | 80 + .../lib/classes/Swift/Attachment.php | 71 + .../AbstractFilterableInputStream.php | 179 + .../Swift/ByteStream/ArrayByteStream.php | 184 + .../Swift/ByteStream/FileByteStream.php | 229 + .../ByteStream/TemporaryFileByteStream.php | 42 + .../lib/classes/Swift/CharacterReader.php | 67 + .../GenericFixedWidthReader.php | 97 + .../Swift/CharacterReader/UsAsciiReader.php | 84 + .../Swift/CharacterReader/Utf8Reader.php | 179 + .../classes/Swift/CharacterReaderFactory.php | 26 + .../SimpleCharacterReaderFactory.php | 124 + .../lib/classes/Swift/CharacterStream.php | 89 + .../CharacterStream/ArrayCharacterStream.php | 293 + .../CharacterStream/NgCharacterStream.php | 275 + .../lib/classes/Swift/ConfigurableSpool.php | 63 + .../lib/classes/Swift/DependencyContainer.php | 373 + .../lib/classes/Swift/DependencyException.php | 27 + .../lib/classes/Swift/EmbeddedFile.php | 69 + .../swiftmailer/lib/classes/Swift/Encoder.php | 28 + .../classes/Swift/Encoder/Base64Encoder.php | 58 + .../lib/classes/Swift/Encoder/QpEncoder.php | 289 + .../classes/Swift/Encoder/Rfc2231Encoder.php | 92 + .../lib/classes/Swift/Encoding.php | 64 + .../lib/classes/Swift/Events/CommandEvent.php | 65 + .../classes/Swift/Events/CommandListener.php | 24 + .../lib/classes/Swift/Events/Event.php | 38 + .../classes/Swift/Events/EventDispatcher.php | 83 + .../classes/Swift/Events/EventListener.php | 18 + .../lib/classes/Swift/Events/EventObject.php | 63 + .../classes/Swift/Events/ResponseEvent.php | 65 + .../classes/Swift/Events/ResponseListener.php | 24 + .../lib/classes/Swift/Events/SendEvent.php | 129 + .../lib/classes/Swift/Events/SendListener.php | 31 + .../Swift/Events/SimpleEventDispatcher.php | 156 + .../Swift/Events/TransportChangeEvent.php | 27 + .../Swift/Events/TransportChangeListener.php | 45 + .../Swift/Events/TransportExceptionEvent.php | 46 + .../Events/TransportExceptionListener.php | 24 + .../lib/classes/Swift/FailoverTransport.php | 45 + .../lib/classes/Swift/FileSpool.php | 208 + .../lib/classes/Swift/FileStream.php | 24 + .../lib/classes/Swift/Filterable.php | 32 + .../swiftmailer/lib/classes/Swift/Image.php | 61 + .../lib/classes/Swift/InputByteStream.php | 75 + .../lib/classes/Swift/IoException.php | 29 + .../lib/classes/Swift/KeyCache.php | 105 + .../classes/Swift/KeyCache/ArrayKeyCache.php | 206 + .../classes/Swift/KeyCache/DiskKeyCache.php | 324 + .../Swift/KeyCache/KeyCacheInputStream.php | 51 + .../classes/Swift/KeyCache/NullKeyCache.php | 115 + .../KeyCache/SimpleKeyCacheInputStream.php | 127 + .../classes/Swift/LoadBalancedTransport.php | 45 + .../lib/classes/Swift/MailTransport.php | 45 + .../swiftmailer/lib/classes/Swift/Mailer.php | 114 + .../Swift/Mailer/ArrayRecipientIterator.php | 55 + .../Swift/Mailer/RecipientIterator.php | 32 + .../lib/classes/Swift/MemorySpool.php | 84 + .../swiftmailer/lib/classes/Swift/Message.php | 291 + .../lib/classes/Swift/Mime/Attachment.php | 153 + .../classes/Swift/Mime/CharsetObserver.php | 24 + .../lib/classes/Swift/Mime/ContentEncoder.php | 34 + .../ContentEncoder/Base64ContentEncoder.php | 104 + .../ContentEncoder/NativeQpContentEncoder.php | 123 + .../ContentEncoder/PlainContentEncoder.php | 162 + .../Mime/ContentEncoder/QpContentEncoder.php | 123 + .../ContentEncoder/QpContentEncoderProxy.php | 97 + .../Mime/ContentEncoder/RawContentEncoder.php | 64 + .../lib/classes/Swift/Mime/EmbeddedFile.php | 45 + .../classes/Swift/Mime/EncodingObserver.php | 24 + .../lib/classes/Swift/Mime/Grammar.php | 176 + .../lib/classes/Swift/Mime/Header.php | 93 + .../lib/classes/Swift/Mime/HeaderEncoder.php | 24 + .../HeaderEncoder/Base64HeaderEncoder.php | 55 + .../Mime/HeaderEncoder/QpHeaderEncoder.php | 65 + .../lib/classes/Swift/Mime/HeaderFactory.php | 78 + .../lib/classes/Swift/Mime/HeaderSet.php | 169 + .../Swift/Mime/Headers/AbstractHeader.php | 503 ++ .../classes/Swift/Mime/Headers/DateHeader.php | 125 + .../Mime/Headers/IdentificationHeader.php | 180 + .../Swift/Mime/Headers/MailboxHeader.php | 354 + .../Swift/Mime/Headers/OpenDKIMHeader.php | 137 + .../Mime/Headers/ParameterizedHeader.php | 260 + .../classes/Swift/Mime/Headers/PathHeader.php | 143 + .../Swift/Mime/Headers/UnstructuredHeader.php | 112 + .../lib/classes/Swift/Mime/Message.php | 223 + .../lib/classes/Swift/Mime/MimeEntity.php | 117 + .../lib/classes/Swift/Mime/MimePart.php | 214 + .../Swift/Mime/ParameterizedHeader.php | 34 + .../Swift/Mime/SimpleHeaderFactory.php | 198 + .../classes/Swift/Mime/SimpleHeaderSet.php | 396 + .../lib/classes/Swift/Mime/SimpleMessage.php | 649 ++ .../classes/Swift/Mime/SimpleMimeEntity.php | 867 +++ .../lib/classes/Swift/MimePart.php | 59 + .../lib/classes/Swift/NullTransport.php | 39 + .../lib/classes/Swift/OutputByteStream.php | 46 + .../classes/Swift/Plugins/AntiFloodPlugin.php | 141 + .../Swift/Plugins/BandwidthMonitorPlugin.php | 164 + .../Swift/Plugins/Decorator/Replacements.php | 31 + .../classes/Swift/Plugins/DecoratorPlugin.php | 207 + .../Swift/Plugins/ImpersonatePlugin.php | 69 + .../lib/classes/Swift/Plugins/Logger.php | 36 + .../classes/Swift/Plugins/LoggerPlugin.php | 142 + .../Swift/Plugins/Loggers/ArrayLogger.php | 72 + .../Swift/Plugins/Loggers/EchoLogger.php | 58 + .../classes/Swift/Plugins/MessageLogger.php | 74 + .../Swift/Plugins/Pop/Pop3Connection.php | 31 + .../Swift/Plugins/Pop/Pop3Exception.php | 27 + .../Swift/Plugins/PopBeforeSmtpPlugin.php | 273 + .../Swift/Plugins/RedirectingPlugin.php | 213 + .../lib/classes/Swift/Plugins/Reporter.php | 32 + .../classes/Swift/Plugins/ReporterPlugin.php | 73 + .../Swift/Plugins/Reporters/HitReporter.php | 59 + .../Swift/Plugins/Reporters/HtmlReporter.php | 39 + .../lib/classes/Swift/Plugins/Sleeper.php | 24 + .../classes/Swift/Plugins/ThrottlerPlugin.php | 200 + .../lib/classes/Swift/Plugins/Timer.php | 24 + .../lib/classes/Swift/Preferences.php | 103 + .../Swift/ReplacementFilterFactory.php | 27 + .../classes/Swift/RfcComplianceException.php | 27 + .../lib/classes/Swift/SendmailTransport.php | 45 + .../lib/classes/Swift/SignedMessage.php | 23 + .../swiftmailer/lib/classes/Swift/Signer.php | 20 + .../lib/classes/Swift/Signers/BodySigner.php | 33 + .../lib/classes/Swift/Signers/DKIMSigner.php | 702 ++ .../classes/Swift/Signers/DomainKeySigner.php | 525 ++ .../classes/Swift/Signers/HeaderSigner.php | 65 + .../classes/Swift/Signers/OpenDKIMSigner.php | 189 + .../lib/classes/Swift/Signers/SMimeSigner.php | 437 ++ .../lib/classes/Swift/SmtpTransport.php | 58 + .../swiftmailer/lib/classes/Swift/Spool.php | 53 + .../lib/classes/Swift/SpoolTransport.php | 47 + .../lib/classes/Swift/StreamFilter.php | 35 + .../ByteArrayReplacementFilter.php | 169 + .../StreamFilters/StringReplacementFilter.php | 66 + .../StringReplacementFilterFactory.php | 45 + .../lib/classes/Swift/SwiftException.php | 29 + .../lib/classes/Swift/Transport.php | 54 + .../Swift/Transport/AbstractSmtpTransport.php | 490 ++ .../Esmtp/Auth/CramMd5Authenticator.php | 81 + .../Esmtp/Auth/LoginAuthenticator.php | 51 + .../Esmtp/Auth/NTLMAuthenticator.php | 726 ++ .../Esmtp/Auth/PlainAuthenticator.php | 50 + .../Esmtp/Auth/XOAuth2Authenticator.php | 70 + .../Swift/Transport/Esmtp/AuthHandler.php | 263 + .../Swift/Transport/Esmtp/Authenticator.php | 35 + .../classes/Swift/Transport/EsmtpHandler.php | 86 + .../Swift/Transport/EsmtpTransport.php | 386 + .../Swift/Transport/FailoverTransport.php | 85 + .../lib/classes/Swift/Transport/IoBuffer.php | 67 + .../Swift/Transport/LoadBalancedTransport.php | 166 + .../classes/Swift/Transport/MailInvoker.php | 32 + .../classes/Swift/Transport/MailTransport.php | 237 + .../classes/Swift/Transport/NullTransport.php | 93 + .../Swift/Transport/SendmailTransport.php | 159 + .../Swift/Transport/SimpleMailInvoker.php | 39 + .../lib/classes/Swift/Transport/SmtpAgent.php | 36 + .../Swift/Transport/SpoolTransport.php | 117 + .../classes/Swift/Transport/StreamBuffer.php | 321 + .../lib/classes/Swift/TransportException.php | 29 + .../lib/classes/Swift/Validate.php | 43 + .../lib/dependency_maps/cache_deps.php | 23 + .../lib/dependency_maps/message_deps.php | 9 + .../lib/dependency_maps/mime_deps.php | 123 + .../lib/dependency_maps/transport_deps.php | 76 + .../swiftmailer/lib/mime_types.php | 1007 +++ .../swiftmailer/lib/preferences.php | 25 + .../swiftmailer/lib/swift_init.php | 28 + .../swiftmailer/lib/swift_required.php | 30 + .../swiftmailer/lib/swift_required_pear.php | 30 + .../lib/swiftmailer_generate_mimes_config.php | 193 + .../swiftmailer/swiftmailer/phpunit.xml.dist | 37 + .../tests/IdenticalBinaryConstraint.php | 62 + .../swiftmailer/tests/StreamCollector.php | 11 + .../tests/SwiftMailerSmokeTestCase.php | 46 + .../swiftmailer/tests/SwiftMailerTestCase.php | 34 + .../_samples/charsets/iso-2022-jp/one.txt | 11 + .../_samples/charsets/iso-8859-1/one.txt | 19 + .../tests/_samples/charsets/utf-8/one.txt | 22 + .../tests/_samples/charsets/utf-8/three.txt | 45 + .../tests/_samples/charsets/utf-8/two.txt | 3 + .../tests/_samples/dkim/dkim.test.priv | 15 + .../tests/_samples/dkim/dkim.test.pub | 6 + .../swiftmailer/tests/_samples/files/data.txt | 1 + .../tests/_samples/files/swiftmailer.png | Bin 0 -> 3194 bytes .../tests/_samples/files/textfile.zip | Bin 0 -> 202 bytes .../swiftmailer/tests/_samples/smime/CA.srl | 1 + .../swiftmailer/tests/_samples/smime/ca.crt | 21 + .../swiftmailer/tests/_samples/smime/ca.key | 27 + .../tests/_samples/smime/create-cert.sh | 40 + .../tests/_samples/smime/encrypt.crt | 19 + .../tests/_samples/smime/encrypt.key | 27 + .../tests/_samples/smime/encrypt2.crt | 19 + .../tests/_samples/smime/encrypt2.key | 27 + .../tests/_samples/smime/intermediate.crt | 19 + .../tests/_samples/smime/intermediate.key | 27 + .../swiftmailer/tests/_samples/smime/sign.crt | 19 + .../swiftmailer/tests/_samples/smime/sign.key | 27 + .../tests/_samples/smime/sign2.crt | 19 + .../tests/_samples/smime/sign2.key | 27 + .../tests/acceptance.conf.php.default | 44 + .../Swift/AttachmentAcceptanceTest.php | 12 + .../FileByteStreamAcceptanceTest.php | 174 + ...leCharacterReaderFactoryAcceptanceTest.php | 179 + .../DependencyContainerAcceptanceTest.php | 20 + .../Swift/EmbeddedFileAcceptanceTest.php | 12 + .../Encoder/Base64EncoderAcceptanceTest.php | 45 + .../Swift/Encoder/QpEncoderAcceptanceTest.php | 50 + .../Encoder/Rfc2231EncoderAcceptanceTest.php | 50 + .../Swift/EncodingAcceptanceTest.php | 30 + .../KeyCache/ArrayKeyCacheAcceptanceTest.php | 173 + .../KeyCache/DiskKeyCacheAcceptanceTest.php | 183 + .../Swift/MessageAcceptanceTest.php | 57 + .../Swift/Mime/AttachmentAcceptanceTest.php | 125 + .../Base64ContentEncoderAcceptanceTest.php | 56 + .../NativeQpContentEncoderAcceptanceTest.php | 86 + .../PlainContentEncoderAcceptanceTest.php | 88 + .../QpContentEncoderAcceptanceTest.php | 157 + .../Swift/Mime/EmbeddedFileAcceptanceTest.php | 137 + .../Base64HeaderEncoderAcceptanceTest.php | 32 + .../Swift/Mime/MimePartAcceptanceTest.php | 129 + .../Mime/SimpleMessageAcceptanceTest.php | 1251 +++ .../Swift/MimePartAcceptanceTest.php | 15 + .../AbstractStreamBufferAcceptanceTest.php | 134 + .../BasicSocketAcceptanceTest.php | 34 + .../StreamBuffer/ProcessAcceptanceTest.php | 27 + .../StreamBuffer/SocketTimeoutTest.php | 65 + .../StreamBuffer/SslSocketAcceptanceTest.php | 41 + .../StreamBuffer/TlsSocketAcceptanceTest.php | 40 + .../swiftmailer/tests/bootstrap.php | 19 + .../tests/bug/Swift/Bug111Test.php | 42 + .../tests/bug/Swift/Bug118Test.php | 20 + .../tests/bug/Swift/Bug206Test.php | 38 + .../tests/bug/Swift/Bug274Test.php | 21 + .../swiftmailer/tests/bug/Swift/Bug34Test.php | 75 + .../swiftmailer/tests/bug/Swift/Bug35Test.php | 73 + .../swiftmailer/tests/bug/Swift/Bug38Test.php | 194 + .../tests/bug/Swift/Bug518Test.php | 38 + .../swiftmailer/tests/bug/Swift/Bug51Test.php | 121 + .../tests/bug/Swift/Bug534Test.php | 38 + .../swiftmailer/tests/bug/Swift/Bug71Test.php | 20 + .../swiftmailer/tests/bug/Swift/Bug76Test.php | 82 + .../tests/fixtures/EsmtpTransportFixture.php | 10 + .../tests/fixtures/MimeEntityFixture.php | 59 + .../swiftmailer/tests/smoke.conf.php.default | 63 + .../smoke/Swift/Smoke/AttachmentSmokeTest.php | 30 + .../smoke/Swift/Smoke/BasicSmokeTest.php | 23 + .../Smoke/HtmlWithAttachmentSmokeTest.php | 29 + .../Swift/Smoke/InternationalSmokeTest.php | 37 + .../Swift/ByteStream/ArrayByteStreamTest.php | 204 + .../GenericFixedWidthReaderTest.php | 43 + .../CharacterReader/UsAsciiReaderTest.php | 52 + .../Swift/CharacterReader/Utf8ReaderTest.php | 65 + .../ArrayCharacterStreamTest.php | 360 + .../unit/Swift/DependencyContainerTest.php | 174 + .../unit/Swift/Encoder/Base64EncoderTest.php | 173 + .../unit/Swift/Encoder/QpEncoderTest.php | 381 + .../unit/Swift/Encoder/Rfc2231EncoderTest.php | 141 + .../unit/Swift/Events/CommandEventTest.php | 36 + .../unit/Swift/Events/EventObjectTest.php | 34 + .../unit/Swift/Events/ResponseEventTest.php | 40 + .../tests/unit/Swift/Events/SendEventTest.php | 99 + .../Events/SimpleEventDispatcherTest.php | 135 + .../Swift/Events/TransportChangeEventTest.php | 32 + .../Events/TransportExceptionEventTest.php | 43 + .../unit/Swift/KeyCache/ArrayKeyCacheTest.php | 242 + .../SimpleKeyCacheInputStreamTest.php | 73 + .../Mailer/ArrayRecipientIteratorTest.php | 42 + .../tests/unit/Swift/MailerTest.php | 152 + .../tests/unit/Swift/MessageTest.php | 130 + .../Swift/Mime/AbstractMimeEntityTest.php | 1054 +++ .../tests/unit/Swift/Mime/AttachmentTest.php | 320 + .../Base64ContentEncoderTest.php | 323 + .../PlainContentEncoderTest.php | 173 + .../ContentEncoder/QpContentEncoderTest.php | 496 ++ .../unit/Swift/Mime/EmbeddedFileTest.php | 57 + .../HeaderEncoder/Base64HeaderEncoderTest.php | 13 + .../HeaderEncoder/QpHeaderEncoderTest.php | 223 + .../Swift/Mime/Headers/DateHeaderTest.php | 69 + .../Mime/Headers/IdentificationHeaderTest.php | 189 + .../Swift/Mime/Headers/MailboxHeaderTest.php | 327 + .../Mime/Headers/ParameterizedHeaderTest.php | 400 + .../Swift/Mime/Headers/PathHeaderTest.php | 77 + .../Mime/Headers/UnstructuredHeaderTest.php | 355 + .../tests/unit/Swift/Mime/MimePartTest.php | 233 + .../Swift/Mime/SimpleHeaderFactoryTest.php | 168 + .../unit/Swift/Mime/SimpleHeaderSetTest.php | 734 ++ .../unit/Swift/Mime/SimpleMessageTest.php | 829 ++ .../unit/Swift/Mime/SimpleMimeEntityTest.php | 11 + .../Swift/Plugins/AntiFloodPluginTest.php | 95 + .../Plugins/BandwidthMonitorPluginTest.php | 127 + .../Swift/Plugins/DecoratorPluginTest.php | 269 + .../unit/Swift/Plugins/LoggerPluginTest.php | 190 + .../Swift/Plugins/Loggers/ArrayLoggerTest.php | 65 + .../Swift/Plugins/Loggers/EchoLoggerTest.php | 24 + .../Swift/Plugins/PopBeforeSmtpPluginTest.php | 103 + .../Swift/Plugins/RedirectingPluginTest.php | 185 + .../unit/Swift/Plugins/ReporterPluginTest.php | 88 + .../Plugins/Reporters/HitReporterTest.php | 64 + .../Plugins/Reporters/HtmlReporterTest.php | 54 + .../Swift/Plugins/ThrottlerPluginTest.php | 104 + .../unit/Swift/Signers/DKIMSignerTest.php | 227 + .../unit/Swift/Signers/OpenDKIMSignerTest.php | 45 + .../unit/Swift/Signers/SMimeSignerTest.php | 554 ++ .../ByteArrayReplacementFilterTest.php | 131 + .../StringReplacementFilterFactoryTest.php | 38 + .../StringReplacementFilterTest.php | 55 + .../AbstractSmtpEventSupportTest.php | 560 ++ .../unit/Swift/Transport/AbstractSmtpTest.php | 1249 +++ .../Esmtp/Auth/CramMd5AuthenticatorTest.php | 66 + .../Esmtp/Auth/LoginAuthenticatorTest.php | 66 + .../Esmtp/Auth/NTLMAuthenticatorTest.php | 235 + .../Esmtp/Auth/PlainAuthenticatorTest.php | 69 + .../Swift/Transport/Esmtp/AuthHandlerTest.php | 167 + .../EsmtpTransport/ExtensionSupportTest.php | 530 ++ .../Swift/Transport/EsmtpTransportTest.php | 298 + .../Swift/Transport/FailoverTransportTest.php | 520 ++ .../Transport/LoadBalancedTransportTest.php | 751 ++ .../Swift/Transport/MailTransportTest.php | 311 + .../Swift/Transport/SendmailTransportTest.php | 152 + .../unit/Swift/Transport/StreamBufferTest.php | 45 + vendor/true/punycode/.gitignore | 3 + vendor/true/punycode/.travis.yml | 31 + vendor/true/punycode/CHANGELOG.md | 35 + vendor/true/punycode/LICENSE | 19 + vendor/true/punycode/README.md | 45 + vendor/true/punycode/composer.json | 26 + vendor/true/punycode/phpunit.xml.dist | 17 + vendor/true/punycode/src/Punycode.php | 334 + vendor/true/punycode/tests/PunycodeTest.php | 151 + 439 files changed, 67918 insertions(+), 138 deletions(-) create mode 100644 vendor/composer/include_paths.php create mode 100644 vendor/pear/http_request2/HTTP/Request2.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/CookieJar.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Exception.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/MultipartBody.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Observer/Log.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/Response.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/SOCKS5.php create mode 100644 vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php create mode 100644 vendor/pear/http_request2/README.md create mode 100644 vendor/pear/http_request2/composer.json create mode 100644 vendor/pear/http_request2/data/generate-list.php create mode 100644 vendor/pear/http_request2/data/public-suffix-list.php create mode 100644 vendor/pear/http_request2/docs/LICENSE create mode 100644 vendor/pear/http_request2/docs/examples/upload-rapidshare.php create mode 100644 vendor/pear/http_request2/package.xml create mode 100644 vendor/pear/http_request2/tests/AllTests.php create mode 100644 vendor/pear/http_request2/tests/NetworkConfig.php.dist create mode 100644 vendor/pear/http_request2/tests/ObserverTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/AllTests.php create mode 100644 vendor/pear/http_request2/tests/Request2/CookieJarTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php create mode 100644 vendor/pear/http_request2/tests/Request2/ResponseTest.php create mode 100644 vendor/pear/http_request2/tests/Request2Test.php create mode 100644 vendor/pear/http_request2/tests/TestHelper.php create mode 100644 vendor/pear/http_request2/tests/_files/bug_15305 create mode 100644 vendor/pear/http_request2/tests/_files/bug_18169 create mode 100644 vendor/pear/http_request2/tests/_files/empty.gif create mode 100644 vendor/pear/http_request2/tests/_files/plaintext.txt create mode 100644 vendor/pear/http_request2/tests/_files/response_cookies create mode 100644 vendor/pear/http_request2/tests/_files/response_deflate create mode 100644 vendor/pear/http_request2/tests/_files/response_gzip create mode 100644 vendor/pear/http_request2/tests/_files/response_gzip_broken create mode 100644 vendor/pear/http_request2/tests/_files/response_headers create mode 100644 vendor/pear/http_request2/tests/_network/basicauth.php create mode 100644 vendor/pear/http_request2/tests/_network/bug19934.php create mode 100644 vendor/pear/http_request2/tests/_network/cookies.php create mode 100644 vendor/pear/http_request2/tests/_network/digestauth.php create mode 100644 vendor/pear/http_request2/tests/_network/getparameters.php create mode 100644 vendor/pear/http_request2/tests/_network/postparameters.php create mode 100644 vendor/pear/http_request2/tests/_network/rawpostdata.php create mode 100644 vendor/pear/http_request2/tests/_network/redirects.php create mode 100644 vendor/pear/http_request2/tests/_network/setcookie.php create mode 100644 vendor/pear/http_request2/tests/_network/timeout.php create mode 100644 vendor/pear/http_request2/tests/_network/uploads.php create mode 100644 vendor/pear/net_url2/.gitignore create mode 100644 vendor/pear/net_url2/.scrutinizer.yml create mode 100644 vendor/pear/net_url2/.travis.yml create mode 100755 vendor/pear/net_url2/Net/URL2.php create mode 100644 vendor/pear/net_url2/README.md create mode 100644 vendor/pear/net_url2/composer.json create mode 100755 vendor/pear/net_url2/docs/6470.php create mode 100644 vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes create mode 100755 vendor/pear/net_url2/docs/example.php create mode 100644 vendor/pear/net_url2/package.xml create mode 100644 vendor/pear/net_url2/phpunit.xml.dist create mode 100644 vendor/pear/net_url2/tests/AllTests.php create mode 100644 vendor/pear/net_url2/tests/Net/URL2Test.php create mode 100644 vendor/pear/pear_exception/.gitignore create mode 100644 vendor/pear/pear_exception/.travis.yml create mode 100644 vendor/pear/pear_exception/LICENSE create mode 100644 vendor/pear/pear_exception/PEAR/Exception.php create mode 100644 vendor/pear/pear_exception/composer.json create mode 100644 vendor/pear/pear_exception/package.xml create mode 100644 vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php create mode 100644 vendor/swiftmailer/swiftmailer/.gitattributes create mode 100644 vendor/swiftmailer/swiftmailer/.gitignore create mode 100644 vendor/swiftmailer/swiftmailer/.travis.yml create mode 100644 vendor/swiftmailer/swiftmailer/CHANGES create mode 100644 vendor/swiftmailer/swiftmailer/LICENSE create mode 100644 vendor/swiftmailer/swiftmailer/README create mode 100644 vendor/swiftmailer/swiftmailer/VERSION create mode 100644 vendor/swiftmailer/swiftmailer/composer.json create mode 100644 vendor/swiftmailer/swiftmailer/doc/headers.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/help-resources.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/including-the-files.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/index.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/installing.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/introduction.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/japanese.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/messages.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/overview.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/plugins.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/sending.rst create mode 100644 vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle create mode 100644 vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle create mode 100644 vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Image.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/mime_types.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/preferences.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/swift_init.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/swift_required.php create mode 100644 vendor/swiftmailer/swiftmailer/lib/swift_required_pear.php create mode 100755 vendor/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php create mode 100644 vendor/swiftmailer/swiftmailer/phpunit.xml.dist create mode 100644 vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/StreamCollector.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/charsets/iso-2022-jp/one.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/charsets/iso-8859-1/one.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/one.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/three.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/two.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/dkim/dkim.test.priv create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/dkim/dkim.test.pub create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/files/data.txt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/files/swiftmailer.png create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/CA.srl create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/create-cert.sh create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/intermediate.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/intermediate.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign2.crt create mode 100644 vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign2.key create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance.conf.php.default create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/AttachmentAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Base64EncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bootstrap.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/fixtures/MimeEntityFixture.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default create mode 100644 vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/MessageTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/AntiFloodPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php create mode 100644 vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php create mode 100644 vendor/true/punycode/.gitignore create mode 100644 vendor/true/punycode/.travis.yml create mode 100644 vendor/true/punycode/CHANGELOG.md create mode 100644 vendor/true/punycode/LICENSE create mode 100644 vendor/true/punycode/README.md create mode 100644 vendor/true/punycode/composer.json create mode 100644 vendor/true/punycode/phpunit.xml.dist create mode 100644 vendor/true/punycode/src/Punycode.php create mode 100644 vendor/true/punycode/tests/PunycodeTest.php diff --git a/composer.json b/composer.json index 65cbf222e..0d67b09d1 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,11 @@ "ezyang/htmlpurifier": "4.7.*", "matthiasmullie/minify": "1.3.*", "michelf/php-markdown": "1.5.*", + "pear/http_request2": "2.2.*", "rmccue/requests": "1.6.*", - "sunra/php-simple-html-dom-parser": "1.5.*" + "sunra/php-simple-html-dom-parser": "1.5.*", + "swiftmailer/swiftmailer": "5.4.*", + "true/punycode": "2.*" }, "require-dev": { "php": ">=5.4.0", diff --git a/composer.lock b/composer.lock index 2f55bbc70..fb06f62f0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8649ea9e0951fe7dd685f9bb14e4a17d", - "content-hash": "0276b439721108d097fff978f7ee1c93", + "hash": "97c72bd2862f9d0a77824d769085e926", + "content-hash": "ffd2aaf7dc6705d78c09488d2c7ab024", "packages": [ { "name": "defuse/php-encryption", @@ -98,16 +98,16 @@ }, { "name": "matthiasmullie/minify", - "version": "1.3.30", + "version": "1.3.32", "source": { "type": "git", "url": "https://github.com/matthiasmullie/minify.git", - "reference": "0cd5108683e7376e795555ced56229c4c16597aa" + "reference": "140c714688908afcecde87338c8309233bdc2519" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/0cd5108683e7376e795555ced56229c4c16597aa", - "reference": "0cd5108683e7376e795555ced56229c4c16597aa", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/140c714688908afcecde87338c8309233bdc2519", + "reference": "140c714688908afcecde87338c8309233bdc2519", "shasum": "" }, "require": { @@ -151,20 +151,20 @@ "minifier", "minify" ], - "time": "2016-01-05 07:43:18" + "time": "2016-01-11 02:10:11" }, { "name": "matthiasmullie/path-converter", - "version": "1.0.6", + "version": "1.0.7", "source": { "type": "git", "url": "https://github.com/matthiasmullie/path-converter.git", - "reference": "9f83d0c398dbe70f45f5840d95ffad73d5efd35f" + "reference": "83609c1bb251b2540eba912615571a501a0a06a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/9f83d0c398dbe70f45f5840d95ffad73d5efd35f", - "reference": "9f83d0c398dbe70f45f5840d95ffad73d5efd35f", + "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/83609c1bb251b2540eba912615571a501a0a06a6", + "reference": "83609c1bb251b2540eba912615571a501a0a06a6", "shasum": "" }, "require": { @@ -201,7 +201,7 @@ "paths", "relative" ], - "time": "2016-01-05 07:45:30" + "time": "2016-01-07 00:41:13" }, { "name": "michelf/php-markdown", @@ -254,6 +254,174 @@ ], "time": "2015-03-01 12:03:08" }, + { + "name": "pear/http_request2", + "version": "v2.2.1", + "source": { + "type": "git", + "url": "https://github.com/pear/HTTP_Request2.git", + "reference": "d6c81670c504045248c1afdf896bb9a3288158de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", + "reference": "d6c81670c504045248c1afdf896bb9a3288158de", + "shasum": "" + }, + "require": { + "pear/net_url2": ">=2.0.0", + "pear/pear_exception": "*", + "php": ">=5.2.0" + }, + "suggest": { + "ext-fileinfo": "Adds support for looking up mime-types using finfo.", + "ext-zlib": "Allows handling gzip compressed responses.", + "lib-curl": "Allows using cURL as a request backend.", + "lib-openssl": "Allows handling SSL requests when not using cURL." + }, + "type": "library", + "autoload": { + "psr-0": { + "HTTP_Request2": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Alexey Borzov", + "email": "avb@php.net", + "role": "Developer HTML_Common2" + } + ], + "description": "Provides an easy way to perform HTTP requests.", + "homepage": "http://pear.php.net/package/HTTP_Request2", + "keywords": [ + "PEAR", + "curl", + "http", + "request" + ], + "time": "2014-01-16 17:27:21" + }, + { + "name": "pear/net_url2", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/pear/Net_URL2.git", + "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", + "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", + "shasum": "" + }, + "require": { + "php": ">=5.1.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "Net/URL2.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Coallier", + "email": "davidc@php.net" + }, + { + "name": "Tom Klingenberg", + "email": "tkli@php.net" + }, + { + "name": "Christian Schmidt", + "email": "chmidt@php.net" + } + ], + "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", + "homepage": "https://github.com/pear/Net_URL2", + "keywords": [ + "PEAR", + "net", + "networking", + "rfc3986", + "uri", + "url" + ], + "time": "2015-04-18 17:36:57" + }, + { + "name": "pear/pear_exception", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/pear/PEAR_Exception.git", + "reference": "8c18719fdae000b690e3912be401c76e406dd13b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b", + "reference": "8c18719fdae000b690e3912be401c76e406dd13b", + "shasum": "" + }, + "require": { + "php": ">=4.4.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "type": "class", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "PEAR": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "." + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Helgi Thormar", + "email": "dufuz@php.net" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net" + } + ], + "description": "The PEAR Exception base class.", + "homepage": "https://github.com/pear/PEAR_Exception", + "keywords": [ + "exception" + ], + "time": "2015-02-10 20:07:52" + }, { "name": "rmccue/requests", "version": "v1.6.1", @@ -345,6 +513,105 @@ "parser" ], "time": "2013-05-04 14:32:03" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.1", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1,<0.9.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2015-06-06 14:19:39" + }, + { + "name": "true/punycode", + "version": "v2.0.2", + "source": { + "type": "git", + "url": "https://github.com/true/php-punycode.git", + "reference": "74fa01d4de396c40e239794123b3874cb594a30c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/true/php-punycode/zipball/74fa01d4de396c40e239794123b3874cb594a30c", + "reference": "74fa01d4de396c40e239794123b3874cb594a30c", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.7", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "TrueBV\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Renan Gonçalves", + "email": "renan.saddam@gmail.com" + } + ], + "description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)", + "homepage": "https://github.com/true/php-punycode", + "keywords": [ + "idna", + "punycode" + ], + "time": "2016-01-07 17:12:58" } ], "packages-dev": null, diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 990cfdcfa..ff6ecfb82 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -147,7 +147,7 @@ class ClassLoader * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories + * @param array|string $paths The PSR-4 base directories * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 16cbeb808..40d51d0bd 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -235,6 +235,37 @@ return array( 'HTMLPurifier_VarParser_Flexible' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php', 'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php', 'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php', + 'HTTP_Request2' => $vendorDir . '/pear/http_request2/HTTP/Request2.php', + 'HTTP_Request2Test' => $vendorDir . '/pear/http_request2/tests/Request2Test.php', + 'HTTP_Request2_Adapter' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter.php', + 'HTTP_Request2_Adapter_CommonNetworkTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php', + 'HTTP_Request2_Adapter_Curl' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Curl.php', + 'HTTP_Request2_Adapter_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CurlTest.php', + 'HTTP_Request2_Adapter_Mock' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Mock.php', + 'HTTP_Request2_Adapter_MockTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/MockTest.php', + 'HTTP_Request2_Adapter_Skip_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', + 'HTTP_Request2_Adapter_Skip_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', + 'HTTP_Request2_Adapter_Skip_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', + 'HTTP_Request2_Adapter_Socket' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Socket.php', + 'HTTP_Request2_Adapter_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php', + 'HTTP_Request2_Adapter_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketTest.php', + 'HTTP_Request2_AllTests' => $vendorDir . '/pear/http_request2/tests/AllTests.php', + 'HTTP_Request2_ConnectionException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', + 'HTTP_Request2_CookieJar' => $vendorDir . '/pear/http_request2/HTTP/Request2/CookieJar.php', + 'HTTP_Request2_CookieJarTest' => $vendorDir . '/pear/http_request2/tests/Request2/CookieJarTest.php', + 'HTTP_Request2_Exception' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', + 'HTTP_Request2_LogicException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', + 'HTTP_Request2_MessageException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', + 'HTTP_Request2_MockObserver' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', + 'HTTP_Request2_MultipartBody' => $vendorDir . '/pear/http_request2/HTTP/Request2/MultipartBody.php', + 'HTTP_Request2_MultipartBodyTest' => $vendorDir . '/pear/http_request2/tests/Request2/MultipartBodyTest.php', + 'HTTP_Request2_NotImplementedException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', + 'HTTP_Request2_ObserverTest' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', + 'HTTP_Request2_Observer_Log' => $vendorDir . '/pear/http_request2/HTTP/Request2/Observer/Log.php', + 'HTTP_Request2_Response' => $vendorDir . '/pear/http_request2/HTTP/Request2/Response.php', + 'HTTP_Request2_ResponseTest' => $vendorDir . '/pear/http_request2/tests/Request2/ResponseTest.php', + 'HTTP_Request2_SOCKS5' => $vendorDir . '/pear/http_request2/HTTP/Request2/SOCKS5.php', + 'HTTP_Request2_SocketWrapper' => $vendorDir . '/pear/http_request2/HTTP/Request2/SocketWrapper.php', 'MatthiasMullie\\Minify\\CSS' => $vendorDir . '/matthiasmullie/minify/src/CSS.php', 'MatthiasMullie\\Minify\\Exception' => $vendorDir . '/matthiasmullie/minify/src/Exception.php', 'MatthiasMullie\\Minify\\JS' => $vendorDir . '/matthiasmullie/minify/src/JS.php', @@ -243,6 +274,9 @@ return array( 'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', 'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php', 'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php', + 'Net_URL2' => $vendorDir . '/pear/net_url2/Net/URL2.php', + 'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php', + 'PEAR_ExceptionTest' => $vendorDir . '/pear/pear_exception/tests/PEAR/ExceptionTest.php', 'Requests' => $vendorDir . '/rmccue/requests/library/Requests.php', 'Requests_Auth' => $vendorDir . '/rmccue/requests/library/Requests/Auth.php', 'Requests_Auth_Basic' => $vendorDir . '/rmccue/requests/library/Requests/Auth/Basic.php', @@ -297,4 +331,5 @@ return array( 'Requests_Utility_CaseInsensitiveDictionary' => $vendorDir . '/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php', 'Requests_Utility_FilteredIterator' => $vendorDir . '/rmccue/requests/library/Requests/Utility/FilteredIterator.php', 'Sunra\\PhpSimple\\HtmlDomParser' => $vendorDir . '/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/HtmlDomParser.php', + 'TrueBV\\Punycode' => $vendorDir . '/true/punycode/src/Punycode.php', ); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 460d3107e..995fea35b 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -8,4 +8,5 @@ $baseDir = dirname($vendorDir); return array( '8170285c807a9f24f165f37b15bc9a36' => $vendorDir . '/defuse/php-encryption/Crypto.php', '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 0ba8d72dc..44320b577 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -8,6 +8,8 @@ $baseDir = dirname($vendorDir); return array( 'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'), 'Requests' => array($vendorDir . '/rmccue/requests/library'), + 'PEAR' => array($vendorDir . '/pear/pear_exception'), 'Michelf' => array($vendorDir . '/michelf/php-markdown'), + 'HTTP_Request2' => array($vendorDir . '/pear/http_request2'), 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index b7014d645..fada27478 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'TrueBV\\' => array($vendorDir . '/true/punycode/src'), 'MatthiasMullie\\PathConverter\\' => array($vendorDir . '/matthiasmullie/path-converter/src'), 'MatthiasMullie\\Minify\\' => array($vendorDir . '/matthiasmullie/minify/src'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index d8899d992..4ad2a5c88 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -23,6 +23,10 @@ class ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de', 'loadClassLoader')); + $includePaths = require __DIR__ . '/include_paths.php'; + array_push($includePaths, get_include_path()); + set_include_path(join(PATH_SEPARATOR, $includePaths)); + $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); diff --git a/vendor/composer/include_paths.php b/vendor/composer/include_paths.php new file mode 100644 index 000000000..98c3d1374 --- /dev/null +++ b/vendor/composer/include_paths.php @@ -0,0 +1,10 @@ +=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8", - "satooshi/php-coveralls": "~1.0" - }, - "time": "2016-01-05 07:45:30", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "MatthiasMullie\\PathConverter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Matthias Mullie", - "email": "pathconverter@mullie.eu", - "homepage": "http://www.mullie.eu", - "role": "Developer" - } - ], - "description": "Relative path converter", - "homepage": "http://github.com/matthiasmullie/path-converter", - "keywords": [ - "converter", - "path", - "paths", - "relative" - ] - }, - { - "name": "matthiasmullie/minify", - "version": "1.3.30", - "version_normalized": "1.3.30.0", - "source": { - "type": "git", - "url": "https://github.com/matthiasmullie/minify.git", - "reference": "0cd5108683e7376e795555ced56229c4c16597aa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/0cd5108683e7376e795555ced56229c4c16597aa", - "reference": "0cd5108683e7376e795555ced56229c4c16597aa", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "matthiasmullie/path-converter": "~1.0", - "php": ">=5.3.0" - }, - "require-dev": { - "matthiasmullie/scrapbook": "~1.0", - "phpunit/phpunit": "~4.8", - "satooshi/php-coveralls": "~1.0" - }, - "time": "2016-01-05 07:43:18", - "bin": [ - "bin/minifycss", - "bin/minifyjs" - ], - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "MatthiasMullie\\Minify\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Matthias Mullie", - "email": "minify@mullie.eu", - "homepage": "http://www.mullie.eu", - "role": "Developer" - } - ], - "description": "CSS & JS minifier", - "homepage": "http://www.minifier.org", - "keywords": [ - "JS", - "css", - "javascript", - "minifier", - "minify" - ] - }, { "name": "rmccue/requests", "version": "v1.6.1", @@ -351,5 +240,393 @@ "iri", "sockets" ] + }, + { + "name": "matthiasmullie/path-converter", + "version": "1.0.7", + "version_normalized": "1.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/path-converter.git", + "reference": "83609c1bb251b2540eba912615571a501a0a06a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/83609c1bb251b2540eba912615571a501a0a06a6", + "reference": "83609c1bb251b2540eba912615571a501a0a06a6", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "~1.0" + }, + "time": "2016-01-07 00:41:13", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "MatthiasMullie\\PathConverter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "pathconverter@mullie.eu", + "homepage": "http://www.mullie.eu", + "role": "Developer" + } + ], + "description": "Relative path converter", + "homepage": "http://github.com/matthiasmullie/path-converter", + "keywords": [ + "converter", + "path", + "paths", + "relative" + ] + }, + { + "name": "matthiasmullie/minify", + "version": "1.3.32", + "version_normalized": "1.3.32.0", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/minify.git", + "reference": "140c714688908afcecde87338c8309233bdc2519" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/140c714688908afcecde87338c8309233bdc2519", + "reference": "140c714688908afcecde87338c8309233bdc2519", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "matthiasmullie/path-converter": "~1.0", + "php": ">=5.3.0" + }, + "require-dev": { + "matthiasmullie/scrapbook": "~1.0", + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "~1.0" + }, + "time": "2016-01-11 02:10:11", + "bin": [ + "bin/minifycss", + "bin/minifyjs" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "MatthiasMullie\\Minify\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "minify@mullie.eu", + "homepage": "http://www.mullie.eu", + "role": "Developer" + } + ], + "description": "CSS & JS minifier", + "homepage": "http://www.minifier.org", + "keywords": [ + "JS", + "css", + "javascript", + "minifier", + "minify" + ] + }, + { + "name": "pear/pear_exception", + "version": "v1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/pear/PEAR_Exception.git", + "reference": "8c18719fdae000b690e3912be401c76e406dd13b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b", + "reference": "8c18719fdae000b690e3912be401c76e406dd13b", + "shasum": "" + }, + "require": { + "php": ">=4.4.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "time": "2015-02-10 20:07:52", + "type": "class", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "PEAR": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "." + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Helgi Thormar", + "email": "dufuz@php.net" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net" + } + ], + "description": "The PEAR Exception base class.", + "homepage": "https://github.com/pear/PEAR_Exception", + "keywords": [ + "exception" + ] + }, + { + "name": "pear/net_url2", + "version": "v2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/pear/Net_URL2.git", + "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", + "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", + "shasum": "" + }, + "require": { + "php": ">=5.1.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.3.0" + }, + "time": "2015-04-18 17:36:57", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "Net/URL2.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Coallier", + "email": "davidc@php.net" + }, + { + "name": "Tom Klingenberg", + "email": "tkli@php.net" + }, + { + "name": "Christian Schmidt", + "email": "chmidt@php.net" + } + ], + "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", + "homepage": "https://github.com/pear/Net_URL2", + "keywords": [ + "PEAR", + "net", + "networking", + "rfc3986", + "uri", + "url" + ] + }, + { + "name": "pear/http_request2", + "version": "v2.2.1", + "version_normalized": "2.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/pear/HTTP_Request2.git", + "reference": "d6c81670c504045248c1afdf896bb9a3288158de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", + "reference": "d6c81670c504045248c1afdf896bb9a3288158de", + "shasum": "" + }, + "require": { + "pear/net_url2": ">=2.0.0", + "pear/pear_exception": "*", + "php": ">=5.2.0" + }, + "suggest": { + "ext-fileinfo": "Adds support for looking up mime-types using finfo.", + "ext-zlib": "Allows handling gzip compressed responses.", + "lib-curl": "Allows using cURL as a request backend.", + "lib-openssl": "Allows handling SSL requests when not using cURL." + }, + "time": "2014-01-16 17:27:21", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "HTTP_Request2": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Alexey Borzov", + "email": "avb@php.net", + "role": "Developer HTML_Common2" + } + ], + "description": "Provides an easy way to perform HTTP requests.", + "homepage": "http://pear.php.net/package/HTTP_Request2", + "keywords": [ + "PEAR", + "curl", + "http", + "request" + ] + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.1", + "version_normalized": "5.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1,<0.9.4" + }, + "time": "2015-06-06 14:19:39", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ] + }, + { + "name": "true/punycode", + "version": "v2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/true/php-punycode.git", + "reference": "74fa01d4de396c40e239794123b3874cb594a30c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/true/php-punycode/zipball/74fa01d4de396c40e239794123b3874cb594a30c", + "reference": "74fa01d4de396c40e239794123b3874cb594a30c", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.7", + "squizlabs/php_codesniffer": "~2.0" + }, + "time": "2016-01-07 17:12:58", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "TrueBV\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Renan Gonçalves", + "email": "renan.saddam@gmail.com" + } + ], + "description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)", + "homepage": "https://github.com/true/php-punycode", + "keywords": [ + "idna", + "punycode" + ] } ] diff --git a/vendor/matthiasmullie/minify/src/CSS.php b/vendor/matthiasmullie/minify/src/CSS.php index 86cc2bc59..3d2de11f5 100644 --- a/vendor/matthiasmullie/minify/src/CSS.php +++ b/vendor/matthiasmullie/minify/src/CSS.php @@ -314,6 +314,10 @@ class CSS extends Minify // restore the string we've extracted earlier $css = $this->restoreExtractedData($css); + $source = $source ?: ''; + $css = $this->combineImports($source, $css); + $css = $this->importFiles($source, $css); + /* * If we'll save to a new path, we'll have to fix the relative paths * to be relative no longer to the source file, but to the new path. @@ -321,15 +325,9 @@ class CSS extends Minify * conversion happens (because we still want it to go through most * of the move code...) */ - $source = $source ?: ''; $converter = new Converter($source, $path ?: $source); $css = $this->move($converter, $css); - // if no target path is given, relative paths were not converted, so - // they'll still be relative to the source file then - $css = $this->importFiles($path ?: $source, $css); - $css = $this->combineImports($path ?: $source, $css); - // combine css $content .= $css; } @@ -522,11 +520,12 @@ class CSS extends Minify * Strip comments from source code. * * @param string $content + * * @return string */ protected function stripEmptyTags($content) { - return preg_replace('/(^|\})[^\{]+\{\s*\}/', '\\1', $content); + return preg_replace('/(^|\})[^\{\}]+\{\s*\}/', '\\1', $content); } /** diff --git a/vendor/matthiasmullie/path-converter/src/Converter.php b/vendor/matthiasmullie/path-converter/src/Converter.php index ae3d158d2..fe9307b75 100644 --- a/vendor/matthiasmullie/path-converter/src/Converter.php +++ b/vendor/matthiasmullie/path-converter/src/Converter.php @@ -1,4 +1,5 @@ - * * @copyright Copyright (c) 2015, Matthias Mullie. All rights reserved. * @license MIT License */ @@ -38,6 +38,11 @@ class Converter if ($shared === '') { // when both paths have nothing in common, one of them is probably // absolute while the other is relative + $cwd = getcwd(); + $from = strpos($from, $cwd) === 0 ? $from : $cwd.'/'.$from; + $to = strpos($to, $cwd) === 0 ? $to : $cwd.'/'.$to; + + // or traveling the tree via `..` // attempt to resolve path, or assume it's fine if it doesn't exist $from = realpath($from) ?: $from; $to = realpath($to) ?: $to; @@ -56,7 +61,8 @@ class Converter /** * Normalize path. * - * @param string $path + * @param string $path + * * @return string */ protected function normalize($path) @@ -87,8 +93,9 @@ class Converter * share * /home/forkcms/frontend * - * @param string $path1 - * @param string $path2 + * @param string $path1 + * @param string $path2 + * * @return string */ protected function shared($path1, $path2) @@ -122,7 +129,8 @@ class Converter * ../../core/layout/images/img.gif relative to * /home/forkcms/frontend/cache/minified_css * - * @param string $path The relative path that needs to be converted. + * @param string $path The relative path that needs to be converted. + * * @return string The new relative path. */ public function convert($path) @@ -155,7 +163,8 @@ class Converter /** * Attempt to get the directory name from a path. * - * @param string $path + * @param string $path + * * @return string */ public function dirname($path) diff --git a/vendor/pear/http_request2/HTTP/Request2.php b/vendor/pear/http_request2/HTTP/Request2.php new file mode 100644 index 000000000..42156f1d6 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2.php @@ -0,0 +1,1030 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * A class representing an URL as per RFC 3986. + */ +require_once 'Net/URL2.php'; + +/** + * Exception class for HTTP_Request2 package + */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Class representing a HTTP request message + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc2616#section-5 + */ +class HTTP_Request2 implements SplSubject +{ + /**#@+ + * Constants for HTTP request methods + * + * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 + */ + const METHOD_OPTIONS = 'OPTIONS'; + const METHOD_GET = 'GET'; + const METHOD_HEAD = 'HEAD'; + const METHOD_POST = 'POST'; + const METHOD_PUT = 'PUT'; + const METHOD_DELETE = 'DELETE'; + const METHOD_TRACE = 'TRACE'; + const METHOD_CONNECT = 'CONNECT'; + /**#@-*/ + + /**#@+ + * Constants for HTTP authentication schemes + * + * @link http://tools.ietf.org/html/rfc2617 + */ + const AUTH_BASIC = 'basic'; + const AUTH_DIGEST = 'digest'; + /**#@-*/ + + /** + * Regular expression used to check for invalid symbols in RFC 2616 tokens + * @link http://pear.php.net/bugs/bug.php?id=15630 + */ + const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; + + /** + * Regular expression used to check for invalid symbols in cookie strings + * @link http://pear.php.net/bugs/bug.php?id=15630 + * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html + */ + const REGEXP_INVALID_COOKIE = '/[\s,;]/'; + + /** + * Fileinfo magic database resource + * @var resource + * @see detectMimeType() + */ + private static $_fileinfoDb; + + /** + * Observers attached to the request (instances of SplObserver) + * @var array + */ + protected $observers = array(); + + /** + * Request URL + * @var Net_URL2 + */ + protected $url; + + /** + * Request method + * @var string + */ + protected $method = self::METHOD_GET; + + /** + * Authentication data + * @var array + * @see getAuth() + */ + protected $auth; + + /** + * Request headers + * @var array + */ + protected $headers = array(); + + /** + * Configuration parameters + * @var array + * @see setConfig() + */ + protected $config = array( + 'adapter' => 'HTTP_Request2_Adapter_Socket', + 'connect_timeout' => 10, + 'timeout' => 0, + 'use_brackets' => true, + 'protocol_version' => '1.1', + 'buffer_size' => 16384, + 'store_body' => true, + 'local_ip' => null, + + 'proxy_host' => '', + 'proxy_port' => '', + 'proxy_user' => '', + 'proxy_password' => '', + 'proxy_auth_scheme' => self::AUTH_BASIC, + 'proxy_type' => 'http', + + 'ssl_verify_peer' => true, + 'ssl_verify_host' => true, + 'ssl_cafile' => null, + 'ssl_capath' => null, + 'ssl_local_cert' => null, + 'ssl_passphrase' => null, + + 'digest_compat_ie' => false, + + 'follow_redirects' => false, + 'max_redirects' => 5, + 'strict_redirects' => false + ); + + /** + * Last event in request / response handling, intended for observers + * @var array + * @see getLastEvent() + */ + protected $lastEvent = array( + 'name' => 'start', + 'data' => null + ); + + /** + * Request body + * @var string|resource + * @see setBody() + */ + protected $body = ''; + + /** + * Array of POST parameters + * @var array + */ + protected $postParams = array(); + + /** + * Array of file uploads (for multipart/form-data POST requests) + * @var array + */ + protected $uploads = array(); + + /** + * Adapter used to perform actual HTTP request + * @var HTTP_Request2_Adapter + */ + protected $adapter; + + /** + * Cookie jar to persist cookies between requests + * @var HTTP_Request2_CookieJar + */ + protected $cookieJar = null; + + /** + * Constructor. Can set request URL, method and configuration array. + * + * Also sets a default value for User-Agent header. + * + * @param string|Net_Url2 $url Request URL + * @param string $method Request method + * @param array $config Configuration for this Request instance + */ + public function __construct( + $url = null, $method = self::METHOD_GET, array $config = array() + ) { + $this->setConfig($config); + if (!empty($url)) { + $this->setUrl($url); + } + if (!empty($method)) { + $this->setMethod($method); + } + $this->setHeader( + 'user-agent', 'HTTP_Request2/@package_version@ ' . + '(http://pear.php.net/package/http_request2) PHP/' . phpversion() + ); + } + + /** + * Sets the URL for this request + * + * If the URL has userinfo part (username & password) these will be removed + * and converted to auth data. If the URL does not have a path component, + * that will be set to '/'. + * + * @param string|Net_URL2 $url Request URL + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function setUrl($url) + { + if (is_string($url)) { + $url = new Net_URL2( + $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) + ); + } + if (!$url instanceof Net_URL2) { + throw new HTTP_Request2_LogicException( + 'Parameter is not a valid HTTP URL', + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + // URL contains username / password? + if ($url->getUserinfo()) { + $username = $url->getUser(); + $password = $url->getPassword(); + $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); + $url->setUserinfo(''); + } + if ('' == $url->getPath()) { + $url->setPath('/'); + } + $this->url = $url; + + return $this; + } + + /** + * Returns the request URL + * + * @return Net_URL2 + */ + public function getUrl() + { + return $this->url; + } + + /** + * Sets the request method + * + * @param string $method one of the methods defined in RFC 2616 + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException if the method name is invalid + */ + public function setMethod($method) + { + // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 + if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { + throw new HTTP_Request2_LogicException( + "Invalid request method '{$method}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $this->method = $method; + + return $this; + } + + /** + * Returns the request method + * + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * Sets the configuration parameter(s) + * + * The following parameters are available: + *
    + *
  • 'adapter' - adapter to use (string)
  • + *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • + *
  • 'timeout' - Total number of seconds a request can take. + * Use 0 for no limit, should be greater than + * 'connect_timeout' if set (integer)
  • + *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • + *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • + *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • + *
  • 'store_body' - Whether to store response body in response object. + * Set to false if receiving a huge response and + * using an Observer to save it (boolean)
  • + *
  • 'local_ip' - Specifies the IP address that will be used for accessing + * the network (string)
  • + *
  • 'proxy_type' - Proxy type, 'http' or 'socks5' (string)
  • + *
  • 'proxy_host' - Proxy server host (string)
  • + *
  • 'proxy_port' - Proxy server port (integer)
  • + *
  • 'proxy_user' - Proxy auth username (string)
  • + *
  • 'proxy_password' - Proxy auth password (string)
  • + *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • + *
  • 'proxy' - Shorthand for proxy_* parameters, proxy given as URL, + * e.g. 'socks5://localhost:1080/' (string)
  • + *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • + *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL + * certificate matches host name (bool)
  • + *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer + * with (use with 'ssl_verify_peer') (string)
  • + *
  • 'ssl_capath' - Directory holding multiple Certificate + * Authority files (string)
  • + *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • + *
  • 'ssl_passphrase' - Passphrase with which local certificate + * was encoded (string)
  • + *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 + * in using URL without query string in digest + * authentication (boolean)
  • + *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • + *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • + *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and + * 302 (true, needed for compatibility with RFC 2616) + * or switch to GET (false, needed for compatibility with most + * browsers) (boolean)
  • + *
+ * + * @param string|array $nameOrConfig configuration parameter name or array + * ('parameter name' => 'parameter value') + * @param mixed $value parameter value if $nameOrConfig is not an array + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException If the parameter is unknown + */ + public function setConfig($nameOrConfig, $value = null) + { + if (is_array($nameOrConfig)) { + foreach ($nameOrConfig as $name => $value) { + $this->setConfig($name, $value); + } + + } elseif ('proxy' == $nameOrConfig) { + $url = new Net_URL2($value); + $this->setConfig(array( + 'proxy_type' => $url->getScheme(), + 'proxy_host' => $url->getHost(), + 'proxy_port' => $url->getPort(), + 'proxy_user' => rawurldecode($url->getUser()), + 'proxy_password' => rawurldecode($url->getPassword()) + )); + + } else { + if (!array_key_exists($nameOrConfig, $this->config)) { + throw new HTTP_Request2_LogicException( + "Unknown configuration parameter '{$nameOrConfig}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $this->config[$nameOrConfig] = $value; + } + + return $this; + } + + /** + * Returns the value(s) of the configuration parameter(s) + * + * @param string $name parameter name + * + * @return mixed value of $name parameter, array of all configuration + * parameters if $name is not given + * @throws HTTP_Request2_LogicException If the parameter is unknown + */ + public function getConfig($name = null) + { + if (null === $name) { + return $this->config; + } elseif (!array_key_exists($name, $this->config)) { + throw new HTTP_Request2_LogicException( + "Unknown configuration parameter '{$name}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + return $this->config[$name]; + } + + /** + * Sets the autentification data + * + * @param string $user user name + * @param string $password password + * @param string $scheme authentication scheme + * + * @return HTTP_Request2 + */ + public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) + { + if (empty($user)) { + $this->auth = null; + } else { + $this->auth = array( + 'user' => (string)$user, + 'password' => (string)$password, + 'scheme' => $scheme + ); + } + + return $this; + } + + /** + * Returns the authentication data + * + * The array has the keys 'user', 'password' and 'scheme', where 'scheme' + * is one of the HTTP_Request2::AUTH_* constants. + * + * @return array + */ + public function getAuth() + { + return $this->auth; + } + + /** + * Sets request header(s) + * + * The first parameter may be either a full header string 'header: value' or + * header name. In the former case $value parameter is ignored, in the latter + * the header's value will either be set to $value or the header will be + * removed if $value is null. The first parameter can also be an array of + * headers, in that case method will be called recursively. + * + * Note that headers are treated case insensitively as per RFC 2616. + * + * + * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' + * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' + * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' + * $req->setHeader('FOO'); // removes 'Foo' header from request + * + * + * @param string|array $name header name, header string ('Header: value') + * or an array of headers + * @param string|array|null $value header value if $name is not an array, + * header will be removed if value is null + * @param bool $replace whether to replace previous header with the + * same name or append to its value + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function setHeader($name, $value = null, $replace = true) + { + if (is_array($name)) { + foreach ($name as $k => $v) { + if (is_string($k)) { + $this->setHeader($k, $v, $replace); + } else { + $this->setHeader($v, null, $replace); + } + } + } else { + if (null === $value && strpos($name, ':')) { + list($name, $value) = array_map('trim', explode(':', $name, 2)); + } + // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 + if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { + throw new HTTP_Request2_LogicException( + "Invalid header name '{$name}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + // Header names are case insensitive anyway + $name = strtolower($name); + if (null === $value) { + unset($this->headers[$name]); + + } else { + if (is_array($value)) { + $value = implode(', ', array_map('trim', $value)); + } elseif (is_string($value)) { + $value = trim($value); + } + if (!isset($this->headers[$name]) || $replace) { + $this->headers[$name] = $value; + } else { + $this->headers[$name] .= ', ' . $value; + } + } + } + + return $this; + } + + /** + * Returns the request headers + * + * The array is of the form ('header name' => 'header value'), header names + * are lowercased + * + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Adds a cookie to the request + * + * If the request does not have a CookieJar object set, this method simply + * appends a cookie to "Cookie:" header. + * + * If a CookieJar object is available, the cookie is stored in that object. + * Data from request URL will be used for setting its 'domain' and 'path' + * parameters, 'expires' and 'secure' will be set to null and false, + * respectively. If you need further control, use CookieJar's methods. + * + * @param string $name cookie name + * @param string $value cookie value + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + * @see setCookieJar() + */ + public function addCookie($name, $value) + { + if (!empty($this->cookieJar)) { + $this->cookieJar->store( + array('name' => $name, 'value' => $value), $this->url + ); + + } else { + $cookie = $name . '=' . $value; + if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { + throw new HTTP_Request2_LogicException( + "Invalid cookie: '{$cookie}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; + $this->setHeader('cookie', $cookies . $cookie); + } + + return $this; + } + + /** + * Sets the request body + * + * If you provide file pointer rather than file name, it should support + * fstat() and rewind() operations. + * + * @param string|resource|HTTP_Request2_MultipartBody $body Either a + * string with the body or filename containing body or + * pointer to an open file or object with multipart body data + * @param bool $isFilename Whether + * first parameter is a filename + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function setBody($body, $isFilename = false) + { + if (!$isFilename && !is_resource($body)) { + if (!$body instanceof HTTP_Request2_MultipartBody) { + $this->body = (string)$body; + } else { + $this->body = $body; + } + } else { + $fileData = $this->fopenWrapper($body, empty($this->headers['content-type'])); + $this->body = $fileData['fp']; + if (empty($this->headers['content-type'])) { + $this->setHeader('content-type', $fileData['type']); + } + } + $this->postParams = $this->uploads = array(); + + return $this; + } + + /** + * Returns the request body + * + * @return string|resource|HTTP_Request2_MultipartBody + */ + public function getBody() + { + if (self::METHOD_POST == $this->method + && (!empty($this->postParams) || !empty($this->uploads)) + ) { + if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { + $body = http_build_query($this->postParams, '', '&'); + if (!$this->getConfig('use_brackets')) { + $body = preg_replace('/%5B\d+%5D=/', '=', $body); + } + // support RFC 3986 by not encoding '~' symbol (request #15368) + return str_replace('%7E', '~', $body); + + } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) { + require_once 'HTTP/Request2/MultipartBody.php'; + return new HTTP_Request2_MultipartBody( + $this->postParams, $this->uploads, $this->getConfig('use_brackets') + ); + } + } + return $this->body; + } + + /** + * Adds a file to form-based file upload + * + * Used to emulate file upload via a HTML form. The method also sets + * Content-Type of HTTP request to 'multipart/form-data'. + * + * If you just want to send the contents of a file as the body of HTTP + * request you should use setBody() method. + * + * If you provide file pointers rather than file names, they should support + * fstat() and rewind() operations. + * + * @param string $fieldName name of file-upload field + * @param string|resource|array $filename full name of local file, + * pointer to open file or an array of files + * @param string $sendFilename filename to send in the request + * @param string $contentType content-type of file being uploaded + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function addUpload( + $fieldName, $filename, $sendFilename = null, $contentType = null + ) { + if (!is_array($filename)) { + $fileData = $this->fopenWrapper($filename, empty($contentType)); + $this->uploads[$fieldName] = array( + 'fp' => $fileData['fp'], + 'filename' => !empty($sendFilename)? $sendFilename + :(is_string($filename)? basename($filename): 'anonymous.blob') , + 'size' => $fileData['size'], + 'type' => empty($contentType)? $fileData['type']: $contentType + ); + } else { + $fps = $names = $sizes = $types = array(); + foreach ($filename as $f) { + if (!is_array($f)) { + $f = array($f); + } + $fileData = $this->fopenWrapper($f[0], empty($f[2])); + $fps[] = $fileData['fp']; + $names[] = !empty($f[1])? $f[1] + :(is_string($f[0])? basename($f[0]): 'anonymous.blob'); + $sizes[] = $fileData['size']; + $types[] = empty($f[2])? $fileData['type']: $f[2]; + } + $this->uploads[$fieldName] = array( + 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types + ); + } + if (empty($this->headers['content-type']) + || 'application/x-www-form-urlencoded' == $this->headers['content-type'] + ) { + $this->setHeader('content-type', 'multipart/form-data'); + } + + return $this; + } + + /** + * Adds POST parameter(s) to the request. + * + * @param string|array $name parameter name or array ('name' => 'value') + * @param mixed $value parameter value (can be an array) + * + * @return HTTP_Request2 + */ + public function addPostParameter($name, $value = null) + { + if (!is_array($name)) { + $this->postParams[$name] = $value; + } else { + foreach ($name as $k => $v) { + $this->addPostParameter($k, $v); + } + } + if (empty($this->headers['content-type'])) { + $this->setHeader('content-type', 'application/x-www-form-urlencoded'); + } + + return $this; + } + + /** + * Attaches a new observer + * + * @param SplObserver $observer any object implementing SplObserver + */ + public function attach(SplObserver $observer) + { + foreach ($this->observers as $attached) { + if ($attached === $observer) { + return; + } + } + $this->observers[] = $observer; + } + + /** + * Detaches an existing observer + * + * @param SplObserver $observer any object implementing SplObserver + */ + public function detach(SplObserver $observer) + { + foreach ($this->observers as $key => $attached) { + if ($attached === $observer) { + unset($this->observers[$key]); + return; + } + } + } + + /** + * Notifies all observers + */ + public function notify() + { + foreach ($this->observers as $observer) { + $observer->update($this); + } + } + + /** + * Sets the last event + * + * Adapters should use this method to set the current state of the request + * and notify the observers. + * + * @param string $name event name + * @param mixed $data event data + */ + public function setLastEvent($name, $data = null) + { + $this->lastEvent = array( + 'name' => $name, + 'data' => $data + ); + $this->notify(); + } + + /** + * Returns the last event + * + * Observers should use this method to access the last change in request. + * The following event names are possible: + *
    + *
  • 'connect' - after connection to remote server, + * data is the destination (string)
  • + *
  • 'disconnect' - after disconnection from server
  • + *
  • 'sentHeaders' - after sending the request headers, + * data is the headers sent (string)
  • + *
  • 'sentBodyPart' - after sending a part of the request body, + * data is the length of that part (int)
  • + *
  • 'sentBody' - after sending the whole request body, + * data is request body length (int)
  • + *
  • 'receivedHeaders' - after receiving the response headers, + * data is HTTP_Request2_Response object
  • + *
  • 'receivedBodyPart' - after receiving a part of the response + * body, data is that part (string)
  • + *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still + * encoded by Content-Encoding
  • + *
  • 'receivedBody' - after receiving the complete response + * body, data is HTTP_Request2_Response object
  • + *
+ * Different adapters may not send all the event types. Mock adapter does + * not send any events to the observers. + * + * @return array The array has two keys: 'name' and 'data' + */ + public function getLastEvent() + { + return $this->lastEvent; + } + + /** + * Sets the adapter used to actually perform the request + * + * You can pass either an instance of a class implementing HTTP_Request2_Adapter + * or a class name. The method will only try to include a file if the class + * name starts with HTTP_Request2_Adapter_, it will also try to prepend this + * prefix to the class name if it doesn't contain any underscores, so that + * + * $request->setAdapter('curl'); + * + * will work. + * + * @param string|HTTP_Request2_Adapter $adapter Adapter to use + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function setAdapter($adapter) + { + if (is_string($adapter)) { + if (!class_exists($adapter, false)) { + if (false === strpos($adapter, '_')) { + $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); + } + if (!class_exists($adapter, false) + && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter) + ) { + include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; + } + if (!class_exists($adapter, false)) { + throw new HTTP_Request2_LogicException( + "Class {$adapter} not found", + HTTP_Request2_Exception::MISSING_VALUE + ); + } + } + $adapter = new $adapter; + } + if (!$adapter instanceof HTTP_Request2_Adapter) { + throw new HTTP_Request2_LogicException( + 'Parameter is not a HTTP request adapter', + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $this->adapter = $adapter; + + return $this; + } + + /** + * Sets the cookie jar + * + * A cookie jar is used to maintain cookies across HTTP requests and + * responses. Cookies from jar will be automatically added to the request + * headers based on request URL. + * + * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to + * create a new one, false to remove + * + * @return HTTP_Request2 + * @throws HTTP_Request2_LogicException + */ + public function setCookieJar($jar = true) + { + if (!class_exists('HTTP_Request2_CookieJar', false)) { + require_once 'HTTP/Request2/CookieJar.php'; + } + + if ($jar instanceof HTTP_Request2_CookieJar) { + $this->cookieJar = $jar; + } elseif (true === $jar) { + $this->cookieJar = new HTTP_Request2_CookieJar(); + } elseif (!$jar) { + $this->cookieJar = null; + } else { + throw new HTTP_Request2_LogicException( + 'Invalid parameter passed to setCookieJar()', + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + + return $this; + } + + /** + * Returns current CookieJar object or null if none + * + * @return HTTP_Request2_CookieJar|null + */ + public function getCookieJar() + { + return $this->cookieJar; + } + + /** + * Sends the request and returns the response + * + * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + */ + public function send() + { + // Sanity check for URL + if (!$this->url instanceof Net_URL2 + || !$this->url->isAbsolute() + || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) + ) { + throw new HTTP_Request2_LogicException( + 'HTTP_Request2 needs an absolute HTTP(S) request URL, ' + . ($this->url instanceof Net_URL2 + ? "'" . $this->url->__toString() . "'" : 'none') + . ' given', + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + if (empty($this->adapter)) { + $this->setAdapter($this->getConfig('adapter')); + } + // magic_quotes_runtime may break file uploads and chunked response + // processing; see bug #4543. Don't use ini_get() here; see bug #16440. + if ($magicQuotes = get_magic_quotes_runtime()) { + set_magic_quotes_runtime(false); + } + // force using single byte encoding if mbstring extension overloads + // strlen() and substr(); see bug #1781, bug #10605 + if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { + $oldEncoding = mb_internal_encoding(); + mb_internal_encoding('8bit'); + } + + try { + $response = $this->adapter->sendRequest($this); + } catch (Exception $e) { + } + // cleanup in either case (poor man's "finally" clause) + if ($magicQuotes) { + set_magic_quotes_runtime(true); + } + if (!empty($oldEncoding)) { + mb_internal_encoding($oldEncoding); + } + // rethrow the exception + if (!empty($e)) { + throw $e; + } + return $response; + } + + /** + * Wrapper around fopen()/fstat() used by setBody() and addUpload() + * + * @param string|resource $file file name or pointer to open file + * @param bool $detectType whether to try autodetecting MIME + * type of file, will only work if $file is a + * filename, not pointer + * + * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) + * @throws HTTP_Request2_LogicException + */ + protected function fopenWrapper($file, $detectType = false) + { + if (!is_string($file) && !is_resource($file)) { + throw new HTTP_Request2_LogicException( + "Filename or file pointer resource expected", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $fileData = array( + 'fp' => is_string($file)? null: $file, + 'type' => 'application/octet-stream', + 'size' => 0 + ); + if (is_string($file)) { + if (!($fileData['fp'] = @fopen($file, 'rb'))) { + $error = error_get_last(); + throw new HTTP_Request2_LogicException( + $error['message'], HTTP_Request2_Exception::READ_ERROR + ); + } + if ($detectType) { + $fileData['type'] = self::detectMimeType($file); + } + } + if (!($stat = fstat($fileData['fp']))) { + throw new HTTP_Request2_LogicException( + "fstat() call failed", HTTP_Request2_Exception::READ_ERROR + ); + } + $fileData['size'] = $stat['size']; + + return $fileData; + } + + /** + * Tries to detect MIME type of a file + * + * The method will try to use fileinfo extension if it is available, + * deprecated mime_content_type() function in the other case. If neither + * works, default 'application/octet-stream' MIME type is returned + * + * @param string $filename file name + * + * @return string file MIME type + */ + protected static function detectMimeType($filename) + { + // finfo extension from PECL available + if (function_exists('finfo_open')) { + if (!isset(self::$_fileinfoDb)) { + self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); + } + if (self::$_fileinfoDb) { + $info = finfo_file(self::$_fileinfoDb, $filename); + } + } + // (deprecated) mime_content_type function available + if (empty($info) && function_exists('mime_content_type')) { + return mime_content_type($filename); + } + return empty($info)? 'application/octet-stream': $info; + } +} +?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter.php b/vendor/pear/http_request2/HTTP/Request2/Adapter.php new file mode 100644 index 000000000..01c796a06 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Adapter.php @@ -0,0 +1,137 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Class representing a HTTP response + */ +require_once 'HTTP/Request2/Response.php'; + +/** + * Base class for HTTP_Request2 adapters + * + * HTTP_Request2 class itself only defines methods for aggregating the request + * data, all actual work of sending the request to the remote server and + * receiving its response is performed by adapters. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +abstract class HTTP_Request2_Adapter +{ + /** + * A list of methods that MUST NOT have a request body, per RFC 2616 + * @var array + */ + protected static $bodyDisallowed = array('TRACE'); + + /** + * Methods having defined semantics for request body + * + * Content-Length header (indicating that the body follows, section 4.3 of + * RFC 2616) will be sent for these methods even if no body was added + * + * @var array + * @link http://pear.php.net/bugs/bug.php?id=12900 + * @link http://pear.php.net/bugs/bug.php?id=14740 + */ + protected static $bodyRequired = array('POST', 'PUT'); + + /** + * Request being sent + * @var HTTP_Request2 + */ + protected $request; + + /** + * Request body + * @var string|resource|HTTP_Request2_MultipartBody + * @see HTTP_Request2::getBody() + */ + protected $requestBody; + + /** + * Length of the request body + * @var integer + */ + protected $contentLength; + + /** + * Sends request to the remote server and returns its response + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + abstract public function sendRequest(HTTP_Request2 $request); + + /** + * Calculates length of the request body, adds proper headers + * + * @param array &$headers associative array of request headers, this method + * will add proper 'Content-Length' and 'Content-Type' + * headers to this array (or remove them if not needed) + */ + protected function calculateRequestLength(&$headers) + { + $this->requestBody = $this->request->getBody(); + + if (is_string($this->requestBody)) { + $this->contentLength = strlen($this->requestBody); + } elseif (is_resource($this->requestBody)) { + $stat = fstat($this->requestBody); + $this->contentLength = $stat['size']; + rewind($this->requestBody); + } else { + $this->contentLength = $this->requestBody->getLength(); + $headers['content-type'] = 'multipart/form-data; boundary=' . + $this->requestBody->getBoundary(); + $this->requestBody->rewind(); + } + + if (in_array($this->request->getMethod(), self::$bodyDisallowed) + || 0 == $this->contentLength + ) { + // No body: send a Content-Length header nonetheless (request #12900), + // but do that only for methods that require a body (bug #14740) + if (in_array($this->request->getMethod(), self::$bodyRequired)) { + $headers['content-length'] = 0; + } else { + unset($headers['content-length']); + // if the method doesn't require a body and doesn't have a + // body, don't send a Content-Type header. (request #16799) + unset($headers['content-type']); + } + } else { + if (empty($headers['content-type'])) { + $headers['content-type'] = 'application/x-www-form-urlencoded'; + } + // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) + if (!isset($headers['transfer-encoding'])) { + $headers['content-length'] = $this->contentLength; + } + } + } +} +?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php new file mode 100644 index 000000000..777135921 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php @@ -0,0 +1,567 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Base class for HTTP_Request2 adapters + */ +require_once 'HTTP/Request2/Adapter.php'; + +/** + * Adapter for HTTP_Request2 wrapping around cURL extension + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter +{ + /** + * Mapping of header names to cURL options + * @var array + */ + protected static $headerMap = array( + 'accept-encoding' => CURLOPT_ENCODING, + 'cookie' => CURLOPT_COOKIE, + 'referer' => CURLOPT_REFERER, + 'user-agent' => CURLOPT_USERAGENT + ); + + /** + * Mapping of SSL context options to cURL options + * @var array + */ + protected static $sslContextMap = array( + 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, + 'ssl_cafile' => CURLOPT_CAINFO, + 'ssl_capath' => CURLOPT_CAPATH, + 'ssl_local_cert' => CURLOPT_SSLCERT, + 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD + ); + + /** + * Mapping of CURLE_* constants to Exception subclasses and error codes + * @var array + */ + protected static $errorMap = array( + CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', + HTTP_Request2_Exception::NON_HTTP_REDIRECT), + CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), + CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), + CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), + // error returned from write callback + CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', + HTTP_Request2_Exception::NON_HTTP_REDIRECT), + CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', + HTTP_Request2_Exception::TIMEOUT), + CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), + CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), + CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', + HTTP_Request2_Exception::MISCONFIGURATION), + CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', + HTTP_Request2_Exception::MISCONFIGURATION), + CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', + HTTP_Request2_Exception::NON_HTTP_REDIRECT), + CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', + HTTP_Request2_Exception::TOO_MANY_REDIRECTS), + CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), + CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), + CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', + HTTP_Request2_Exception::MISCONFIGURATION), + CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', + HTTP_Request2_Exception::MISCONFIGURATION), + CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), + CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), + CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', + HTTP_Request2_Exception::INVALID_ARGUMENT), + CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), + CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), + CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), + ); + + /** + * Response being received + * @var HTTP_Request2_Response + */ + protected $response; + + /** + * Whether 'sentHeaders' event was sent to observers + * @var boolean + */ + protected $eventSentHeaders = false; + + /** + * Whether 'receivedHeaders' event was sent to observers + * @var boolean + */ + protected $eventReceivedHeaders = false; + + /** + * Position within request body + * @var integer + * @see callbackReadBody() + */ + protected $position = 0; + + /** + * Information about last transfer, as returned by curl_getinfo() + * @var array + */ + protected $lastInfo; + + /** + * Creates a subclass of HTTP_Request2_Exception from curl error data + * + * @param resource $ch curl handle + * + * @return HTTP_Request2_Exception + */ + protected static function wrapCurlError($ch) + { + $nativeCode = curl_errno($ch); + $message = 'Curl error: ' . curl_error($ch); + if (!isset(self::$errorMap[$nativeCode])) { + return new HTTP_Request2_Exception($message, 0, $nativeCode); + } else { + $class = self::$errorMap[$nativeCode][0]; + $code = empty(self::$errorMap[$nativeCode][1]) + ? 0 : self::$errorMap[$nativeCode][1]; + return new $class($message, $code, $nativeCode); + } + } + + /** + * Sends request to the remote server and returns its response + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + if (!extension_loaded('curl')) { + throw new HTTP_Request2_LogicException( + 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION + ); + } + + $this->request = $request; + $this->response = null; + $this->position = 0; + $this->eventSentHeaders = false; + $this->eventReceivedHeaders = false; + + try { + if (false === curl_exec($ch = $this->createCurlHandle())) { + $e = self::wrapCurlError($ch); + } + } catch (Exception $e) { + } + if (isset($ch)) { + $this->lastInfo = curl_getinfo($ch); + curl_close($ch); + } + + $response = $this->response; + unset($this->request, $this->requestBody, $this->response); + + if (!empty($e)) { + throw $e; + } + + if ($jar = $request->getCookieJar()) { + $jar->addCookiesFromResponse($response, $request->getUrl()); + } + + if (0 < $this->lastInfo['size_download']) { + $request->setLastEvent('receivedBody', $response); + } + return $response; + } + + /** + * Returns information about last transfer + * + * @return array associative array as returned by curl_getinfo() + */ + public function getInfo() + { + return $this->lastInfo; + } + + /** + * Creates a new cURL handle and populates it with data from the request + * + * @return resource a cURL handle, as created by curl_init() + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_NotImplementedException + */ + protected function createCurlHandle() + { + $ch = curl_init(); + + curl_setopt_array($ch, array( + // setup write callbacks + CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), + CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), + // buffer size + CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), + // connection timeout + CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), + // save full outgoing headers, in case someone is interested + CURLINFO_HEADER_OUT => true, + // request url + CURLOPT_URL => $this->request->getUrl()->getUrl() + )); + + // set up redirects + if (!$this->request->getConfig('follow_redirects')) { + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); + } else { + if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) { + throw new HTTP_Request2_LogicException( + 'Redirect support in curl is unavailable due to open_basedir or safe_mode setting', + HTTP_Request2_Exception::MISCONFIGURATION + ); + } + curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); + // limit redirects to http(s), works in 5.2.10+ + if (defined('CURLOPT_REDIR_PROTOCOLS')) { + curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + } + // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571 + if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) { + curl_setopt($ch, CURLOPT_POSTREDIR, 3); + } + } + + // set local IP via CURLOPT_INTERFACE (request #19515) + if ($ip = $this->request->getConfig('local_ip')) { + curl_setopt($ch, CURLOPT_INTERFACE, $ip); + } + + // request timeout + if ($timeout = $this->request->getConfig('timeout')) { + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + } + + // set HTTP version + switch ($this->request->getConfig('protocol_version')) { + case '1.0': + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + break; + case '1.1': + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + } + + // set request method + switch ($this->request->getMethod()) { + case HTTP_Request2::METHOD_GET: + curl_setopt($ch, CURLOPT_HTTPGET, true); + break; + case HTTP_Request2::METHOD_POST: + curl_setopt($ch, CURLOPT_POST, true); + break; + case HTTP_Request2::METHOD_HEAD: + curl_setopt($ch, CURLOPT_NOBODY, true); + break; + case HTTP_Request2::METHOD_PUT: + curl_setopt($ch, CURLOPT_UPLOAD, true); + break; + default: + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); + } + + // set proxy, if needed + if ($host = $this->request->getConfig('proxy_host')) { + if (!($port = $this->request->getConfig('proxy_port'))) { + throw new HTTP_Request2_LogicException( + 'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE + ); + } + curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); + if ($user = $this->request->getConfig('proxy_user')) { + curl_setopt( + $ch, CURLOPT_PROXYUSERPWD, + $user . ':' . $this->request->getConfig('proxy_password') + ); + switch ($this->request->getConfig('proxy_auth_scheme')) { + case HTTP_Request2::AUTH_BASIC: + curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); + break; + case HTTP_Request2::AUTH_DIGEST: + curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); + } + } + if ($type = $this->request->getConfig('proxy_type')) { + switch ($type) { + case 'http': + curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + break; + case 'socks5': + curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + break; + default: + throw new HTTP_Request2_NotImplementedException( + "Proxy type '{$type}' is not supported" + ); + } + } + } + + // set authentication data + if ($auth = $this->request->getAuth()) { + curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); + switch ($auth['scheme']) { + case HTTP_Request2::AUTH_BASIC: + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + break; + case HTTP_Request2::AUTH_DIGEST: + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + } + } + + // set SSL options + foreach ($this->request->getConfig() as $name => $value) { + if ('ssl_verify_host' == $name && null !== $value) { + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); + } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { + curl_setopt($ch, self::$sslContextMap[$name], $value); + } + } + + $headers = $this->request->getHeaders(); + // make cURL automagically send proper header + if (!isset($headers['accept-encoding'])) { + $headers['accept-encoding'] = ''; + } + + if (($jar = $this->request->getCookieJar()) + && ($cookies = $jar->getMatching($this->request->getUrl(), true)) + ) { + $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; + } + + // set headers having special cURL keys + foreach (self::$headerMap as $name => $option) { + if (isset($headers[$name])) { + curl_setopt($ch, $option, $headers[$name]); + unset($headers[$name]); + } + } + + $this->calculateRequestLength($headers); + if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) { + $this->workaroundPhpBug47204($ch, $headers); + } + + // set headers not having special keys + $headersFmt = array(); + foreach ($headers as $name => $value) { + $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); + $headersFmt[] = $canonicalName . ': ' . $value; + } + curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); + + return $ch; + } + + /** + * Workaround for PHP bug #47204 that prevents rewinding request body + * + * The workaround consists of reading the entire request body into memory + * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large + * file uploads, use Socket adapter instead. + * + * @param resource $ch cURL handle + * @param array &$headers Request headers + */ + protected function workaroundPhpBug47204($ch, &$headers) + { + // no redirects, no digest auth -> probably no rewind needed + if (!$this->request->getConfig('follow_redirects') + && (!($auth = $this->request->getAuth()) + || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) + ) { + curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); + + } else { + // rewind may be needed, read the whole body into memory + if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { + $this->requestBody = $this->requestBody->__toString(); + + } elseif (is_resource($this->requestBody)) { + $fp = $this->requestBody; + $this->requestBody = ''; + while (!feof($fp)) { + $this->requestBody .= fread($fp, 16384); + } + } + // curl hangs up if content-length is present + unset($headers['content-length']); + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); + } + } + + /** + * Callback function called by cURL for reading the request body + * + * @param resource $ch cURL handle + * @param resource $fd file descriptor (not used) + * @param integer $length maximum length of data to return + * + * @return string part of the request body, up to $length bytes + */ + protected function callbackReadBody($ch, $fd, $length) + { + if (!$this->eventSentHeaders) { + $this->request->setLastEvent( + 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) + ); + $this->eventSentHeaders = true; + } + if (in_array($this->request->getMethod(), self::$bodyDisallowed) + || 0 == $this->contentLength || $this->position >= $this->contentLength + ) { + return ''; + } + if (is_string($this->requestBody)) { + $string = substr($this->requestBody, $this->position, $length); + } elseif (is_resource($this->requestBody)) { + $string = fread($this->requestBody, $length); + } else { + $string = $this->requestBody->read($length); + } + $this->request->setLastEvent('sentBodyPart', strlen($string)); + $this->position += strlen($string); + return $string; + } + + /** + * Callback function called by cURL for saving the response headers + * + * @param resource $ch cURL handle + * @param string $string response header (with trailing CRLF) + * + * @return integer number of bytes saved + * @see HTTP_Request2_Response::parseHeaderLine() + */ + protected function callbackWriteHeader($ch, $string) + { + // we may receive a second set of headers if doing e.g. digest auth + if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { + // don't bother with 100-Continue responses (bug #15785) + if (!$this->eventSentHeaders + || $this->response->getStatus() >= 200 + ) { + $this->request->setLastEvent( + 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) + ); + } + $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); + // if body wasn't read by a callback, send event with total body size + if ($upload > $this->position) { + $this->request->setLastEvent( + 'sentBodyPart', $upload - $this->position + ); + $this->position = $upload; + } + if ($upload && (!$this->eventSentHeaders + || $this->response->getStatus() >= 200) + ) { + $this->request->setLastEvent('sentBody', $upload); + } + $this->eventSentHeaders = true; + // we'll need a new response object + if ($this->eventReceivedHeaders) { + $this->eventReceivedHeaders = false; + $this->response = null; + } + } + if (empty($this->response)) { + $this->response = new HTTP_Request2_Response( + $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) + ); + } else { + $this->response->parseHeaderLine($string); + if ('' == trim($string)) { + // don't bother with 100-Continue responses (bug #15785) + if (200 <= $this->response->getStatus()) { + $this->request->setLastEvent('receivedHeaders', $this->response); + } + + if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) { + $redirectUrl = new Net_URL2($this->response->getHeader('location')); + + // for versions lower than 5.2.10, check the redirection URL protocol + if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() + && !in_array($redirectUrl->getScheme(), array('http', 'https')) + ) { + return -1; + } + + if ($jar = $this->request->getCookieJar()) { + $jar->addCookiesFromResponse($this->response, $this->request->getUrl()); + if (!$redirectUrl->isAbsolute()) { + $redirectUrl = $this->request->getUrl()->resolve($redirectUrl); + } + if ($cookies = $jar->getMatching($redirectUrl, true)) { + curl_setopt($ch, CURLOPT_COOKIE, $cookies); + } + } + } + $this->eventReceivedHeaders = true; + } + } + return strlen($string); + } + + /** + * Callback function called by cURL for saving the response body + * + * @param resource $ch cURL handle (not used) + * @param string $string part of the response body + * + * @return integer number of bytes saved + * @throws HTTP_Request2_MessageException + * @see HTTP_Request2_Response::appendBody() + */ + protected function callbackWriteBody($ch, $string) + { + // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if + // response doesn't start with proper HTTP status line (see bug #15716) + if (empty($this->response)) { + throw new HTTP_Request2_MessageException( + "Malformed response: {$string}", + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } + if ($this->request->getConfig('store_body')) { + $this->response->appendBody($string); + } + $this->request->setLastEvent('receivedBodyPart', $string); + return strlen($string); + } +} +?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php new file mode 100644 index 000000000..aeaf3eeb7 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php @@ -0,0 +1,166 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Base class for HTTP_Request2 adapters + */ +require_once 'HTTP/Request2/Adapter.php'; + +/** + * Mock adapter intended for testing + * + * Can be used to test applications depending on HTTP_Request2 package without + * actually performing any HTTP requests. This adapter will return responses + * previously added via addResponse() + * + * $mock = new HTTP_Request2_Adapter_Mock(); + * $mock->addResponse("HTTP/1.1 ... "); + * + * $request = new HTTP_Request2(); + * $request->setAdapter($mock); + * + * // This will return the response set above + * $response = $req->send(); + * + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter +{ + /** + * A queue of responses to be returned by sendRequest() + * @var array + */ + protected $responses = array(); + + /** + * Returns the next response from the queue built by addResponse() + * + * Only responses without explicit URLs or with URLs equal to request URL + * will be considered. If matching response is not found or the queue is + * empty then default empty response with status 400 will be returned, + * if an Exception object was added to the queue it will be thrown. + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + $requestUrl = (string)$request->getUrl(); + $response = null; + foreach ($this->responses as $k => $v) { + if (!$v[1] || $requestUrl == $v[1]) { + $response = $v[0]; + array_splice($this->responses, $k, 1); + break; + } + } + if (!$response) { + return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); + + } elseif ($response instanceof HTTP_Request2_Response) { + return $response; + + } else { + // rethrow the exception + $class = get_class($response); + $message = $response->getMessage(); + $code = $response->getCode(); + throw new $class($message, $code); + } + } + + /** + * Adds response to the queue + * + * @param mixed $response either a string, a pointer to an open file, + * an instance of HTTP_Request2_Response or Exception + * @param string $url A request URL this response should be valid for + * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) + * + * @throws HTTP_Request2_Exception + */ + public function addResponse($response, $url = null) + { + if (is_string($response)) { + $response = self::createResponseFromString($response); + } elseif (is_resource($response)) { + $response = self::createResponseFromFile($response); + } elseif (!$response instanceof HTTP_Request2_Response && + !$response instanceof Exception + ) { + throw new HTTP_Request2_Exception('Parameter is not a valid response'); + } + $this->responses[] = array($response, $url); + } + + /** + * Creates a new HTTP_Request2_Response object from a string + * + * @param string $str string containing HTTP response message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public static function createResponseFromString($str) + { + $parts = preg_split('!(\r?\n){2}!m', $str, 2); + $headerLines = explode("\n", $parts[0]); + $response = new HTTP_Request2_Response(array_shift($headerLines)); + foreach ($headerLines as $headerLine) { + $response->parseHeaderLine($headerLine); + } + $response->parseHeaderLine(''); + if (isset($parts[1])) { + $response->appendBody($parts[1]); + } + return $response; + } + + /** + * Creates a new HTTP_Request2_Response object from a file + * + * @param resource $fp file pointer returned by fopen() + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public static function createResponseFromFile($fp) + { + $response = new HTTP_Request2_Response(fgets($fp)); + do { + $headerLine = fgets($fp); + $response->parseHeaderLine($headerLine); + } while ('' != trim($headerLine)); + + while (!feof($fp)) { + $response->appendBody(fread($fp, 8192)); + } + return $response; + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php new file mode 100644 index 000000000..f18c4f5b3 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php @@ -0,0 +1,1121 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Base class for HTTP_Request2 adapters */ +require_once 'HTTP/Request2/Adapter.php'; + +/** Socket wrapper class */ +require_once 'HTTP/Request2/SocketWrapper.php'; + +/** + * Socket-based adapter for HTTP_Request2 + * + * This adapter uses only PHP sockets and will work on almost any PHP + * environment. Code is based on original HTTP_Request PEAR package. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter +{ + /** + * Regular expression for 'token' rule from RFC 2616 + */ + const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; + + /** + * Regular expression for 'quoted-string' rule from RFC 2616 + */ + const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"'; + + /** + * Connected sockets, needed for Keep-Alive support + * @var array + * @see connect() + */ + protected static $sockets = array(); + + /** + * Data for digest authentication scheme + * + * The keys for the array are URL prefixes. + * + * The values are associative arrays with data (realm, nonce, nonce-count, + * opaque...) needed for digest authentication. Stored here to prevent making + * duplicate requests to digest-protected resources after we have already + * received the challenge. + * + * @var array + */ + protected static $challenges = array(); + + /** + * Connected socket + * @var HTTP_Request2_SocketWrapper + * @see connect() + */ + protected $socket; + + /** + * Challenge used for server digest authentication + * @var array + */ + protected $serverChallenge; + + /** + * Challenge used for proxy digest authentication + * @var array + */ + protected $proxyChallenge; + + /** + * Remaining length of the current chunk, when reading chunked response + * @var integer + * @see readChunked() + */ + protected $chunkLength = 0; + + /** + * Remaining amount of redirections to follow + * + * Starts at 'max_redirects' configuration parameter and is reduced on each + * subsequent redirect. An Exception will be thrown once it reaches zero. + * + * @var integer + */ + protected $redirectCountdown = null; + + /** + * Whether to wait for "100 Continue" response before sending request body + * @var bool + */ + protected $expect100Continue = false; + + /** + * Sends request to the remote server and returns its response + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + $this->request = $request; + + try { + $keepAlive = $this->connect(); + $headers = $this->prepareHeaders(); + $this->socket->write($headers); + // provide request headers to the observer, see request #7633 + $this->request->setLastEvent('sentHeaders', $headers); + + if (!$this->expect100Continue) { + $this->writeBody(); + $response = $this->readResponse(); + + } else { + $response = $this->readResponse(); + if (!$response || 100 == $response->getStatus()) { + $this->expect100Continue = false; + // either got "100 Continue" or timed out -> send body + $this->writeBody(); + $response = $this->readResponse(); + } + } + + + if ($jar = $request->getCookieJar()) { + $jar->addCookiesFromResponse($response, $request->getUrl()); + } + + if (!$this->canKeepAlive($keepAlive, $response)) { + $this->disconnect(); + } + + if ($this->shouldUseProxyDigestAuth($response)) { + return $this->sendRequest($request); + } + if ($this->shouldUseServerDigestAuth($response)) { + return $this->sendRequest($request); + } + if ($authInfo = $response->getHeader('authentication-info')) { + $this->updateChallenge($this->serverChallenge, $authInfo); + } + if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { + $this->updateChallenge($this->proxyChallenge, $proxyInfo); + } + + } catch (Exception $e) { + $this->disconnect(); + } + + unset($this->request, $this->requestBody); + + if (!empty($e)) { + $this->redirectCountdown = null; + throw $e; + } + + if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { + $this->redirectCountdown = null; + return $response; + } else { + return $this->handleRedirect($request, $response); + } + } + + /** + * Connects to the remote server + * + * @return bool whether the connection can be persistent + * @throws HTTP_Request2_Exception + */ + protected function connect() + { + $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); + $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); + $headers = $this->request->getHeaders(); + $reqHost = $this->request->getUrl()->getHost(); + if (!($reqPort = $this->request->getUrl()->getPort())) { + $reqPort = $secure? 443: 80; + } + + $httpProxy = $socksProxy = false; + if (!($host = $this->request->getConfig('proxy_host'))) { + $host = $reqHost; + $port = $reqPort; + } else { + if (!($port = $this->request->getConfig('proxy_port'))) { + throw new HTTP_Request2_LogicException( + 'Proxy port not provided', + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if ('http' == ($type = $this->request->getConfig('proxy_type'))) { + $httpProxy = true; + } elseif ('socks5' == $type) { + $socksProxy = true; + } else { + throw new HTTP_Request2_NotImplementedException( + "Proxy type '{$type}' is not supported" + ); + } + } + + if ($tunnel && !$httpProxy) { + throw new HTTP_Request2_LogicException( + "Trying to perform CONNECT request without proxy", + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if ($secure && !in_array('ssl', stream_get_transports())) { + throw new HTTP_Request2_LogicException( + 'Need OpenSSL support for https:// requests', + HTTP_Request2_Exception::MISCONFIGURATION + ); + } + + // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive + // connection token to a proxy server... + if ($httpProxy && !$secure && !empty($headers['connection']) + && 'Keep-Alive' == $headers['connection'] + ) { + $this->request->setHeader('connection'); + } + + $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && + empty($headers['connection'])) || + (!empty($headers['connection']) && + 'Keep-Alive' == $headers['connection']); + + $options = array(); + if ($ip = $this->request->getConfig('local_ip')) { + $options['socket'] = array( + 'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0' + ); + } + if ($secure || $tunnel) { + $options['ssl'] = array(); + foreach ($this->request->getConfig() as $name => $value) { + if ('ssl_' == substr($name, 0, 4) && null !== $value) { + if ('ssl_verify_host' == $name) { + if ($value) { + $options['ssl']['CN_match'] = $reqHost; + } + } else { + $options['ssl'][substr($name, 4)] = $value; + } + } + } + ksort($options['ssl']); + } + + // Use global request timeout if given, see feature requests #5735, #8964 + if ($timeout = $this->request->getConfig('timeout')) { + $deadline = time() + $timeout; + } else { + $deadline = null; + } + + // Changing SSL context options after connection is established does *not* + // work, we need a new connection if options change + $remote = ((!$secure || $httpProxy || $socksProxy)? 'tcp://': 'ssl://') + . $host . ':' . $port; + $socketKey = $remote . ( + ($secure && $httpProxy || $socksProxy) + ? "->{$reqHost}:{$reqPort}" : '' + ) . (empty($options)? '': ':' . serialize($options)); + unset($this->socket); + + // We use persistent connections and have a connected socket? + // Ensure that the socket is still connected, see bug #16149 + if ($keepAlive && !empty(self::$sockets[$socketKey]) + && !self::$sockets[$socketKey]->eof() + ) { + $this->socket =& self::$sockets[$socketKey]; + + } else { + if ($socksProxy) { + require_once 'HTTP/Request2/SOCKS5.php'; + + $this->socket = new HTTP_Request2_SOCKS5( + $remote, $this->request->getConfig('connect_timeout'), + $options, $this->request->getConfig('proxy_user'), + $this->request->getConfig('proxy_password') + ); + // handle request timeouts ASAP + $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); + $this->socket->connect($reqHost, $reqPort); + if (!$secure) { + $conninfo = "tcp://{$reqHost}:{$reqPort} via {$remote}"; + } else { + $this->socket->enableCrypto(); + $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; + } + + } elseif ($secure && $httpProxy && !$tunnel) { + $this->establishTunnel(); + $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; + + } else { + $this->socket = new HTTP_Request2_SocketWrapper( + $remote, $this->request->getConfig('connect_timeout'), $options + ); + } + $this->request->setLastEvent('connect', empty($conninfo)? $remote: $conninfo); + self::$sockets[$socketKey] =& $this->socket; + } + $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); + return $keepAlive; + } + + /** + * Establishes a tunnel to a secure remote server via HTTP CONNECT request + * + * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP + * sees that we are connected to a proxy server (duh!) rather than the server + * that presents its certificate. + * + * @link http://tools.ietf.org/html/rfc2817#section-5.2 + * @throws HTTP_Request2_Exception + */ + protected function establishTunnel() + { + $donor = new self; + $connect = new HTTP_Request2( + $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, + array_merge($this->request->getConfig(), array('adapter' => $donor)) + ); + $response = $connect->send(); + // Need any successful (2XX) response + if (200 > $response->getStatus() || 300 <= $response->getStatus()) { + throw new HTTP_Request2_ConnectionException( + 'Failed to connect via HTTPS proxy. Proxy response: ' . + $response->getStatus() . ' ' . $response->getReasonPhrase() + ); + } + $this->socket = $donor->socket; + $this->socket->enableCrypto(); + } + + /** + * Checks whether current connection may be reused or should be closed + * + * @param boolean $requestKeepAlive whether connection could + * be persistent in the first place + * @param HTTP_Request2_Response $response response object to check + * + * @return boolean + */ + protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) + { + // Do not close socket on successful CONNECT request + if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() + && 200 <= $response->getStatus() && 300 > $response->getStatus() + ) { + return true; + } + + $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) + || null !== $response->getHeader('content-length') + // no body possible for such responses, see also request #17031 + || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() + || in_array($response->getStatus(), array(204, 304)); + $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || + (null === $response->getHeader('connection') && + '1.1' == $response->getVersion()); + return $requestKeepAlive && $lengthKnown && $persistent; + } + + /** + * Disconnects from the remote server + */ + protected function disconnect() + { + if (!empty($this->socket)) { + $this->socket = null; + $this->request->setLastEvent('disconnect'); + } + } + + /** + * Handles HTTP redirection + * + * This method will throw an Exception if redirect to a non-HTTP(S) location + * is attempted, also if number of redirects performed already is equal to + * 'max_redirects' configuration parameter. + * + * @param HTTP_Request2 $request Original request + * @param HTTP_Request2_Response $response Response containing redirect + * + * @return HTTP_Request2_Response Response from a new location + * @throws HTTP_Request2_Exception + */ + protected function handleRedirect( + HTTP_Request2 $request, HTTP_Request2_Response $response + ) { + if (is_null($this->redirectCountdown)) { + $this->redirectCountdown = $request->getConfig('max_redirects'); + } + if (0 == $this->redirectCountdown) { + $this->redirectCountdown = null; + // Copying cURL behaviour + throw new HTTP_Request2_MessageException( + 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', + HTTP_Request2_Exception::TOO_MANY_REDIRECTS + ); + } + $redirectUrl = new Net_URL2( + $response->getHeader('location'), + array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) + ); + // refuse non-HTTP redirect + if ($redirectUrl->isAbsolute() + && !in_array($redirectUrl->getScheme(), array('http', 'https')) + ) { + $this->redirectCountdown = null; + throw new HTTP_Request2_MessageException( + 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), + HTTP_Request2_Exception::NON_HTTP_REDIRECT + ); + } + // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), + // but in practice it is often not + if (!$redirectUrl->isAbsolute()) { + $redirectUrl = $request->getUrl()->resolve($redirectUrl); + } + $redirect = clone $request; + $redirect->setUrl($redirectUrl); + if (303 == $response->getStatus() + || (!$request->getConfig('strict_redirects') + && in_array($response->getStatus(), array(301, 302))) + ) { + $redirect->setMethod(HTTP_Request2::METHOD_GET); + $redirect->setBody(''); + } + + if (0 < $this->redirectCountdown) { + $this->redirectCountdown--; + } + return $this->sendRequest($redirect); + } + + /** + * Checks whether another request should be performed with server digest auth + * + * Several conditions should be satisfied for it to return true: + * - response status should be 401 + * - auth credentials should be set in the request object + * - response should contain WWW-Authenticate header with digest challenge + * - there is either no challenge stored for this URL or new challenge + * contains stale=true parameter (in other case we probably just failed + * due to invalid username / password) + * + * The method stores challenge values in $challenges static property + * + * @param HTTP_Request2_Response $response response to check + * + * @return boolean whether another request should be performed + * @throws HTTP_Request2_Exception in case of unsupported challenge parameters + */ + protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) + { + // no sense repeating a request if we don't have credentials + if (401 != $response->getStatus() || !$this->request->getAuth()) { + return false; + } + if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { + return false; + } + + $url = $this->request->getUrl(); + $scheme = $url->getScheme(); + $host = $scheme . '://' . $url->getHost(); + if ($port = $url->getPort()) { + if ((0 == strcasecmp($scheme, 'http') && 80 != $port) + || (0 == strcasecmp($scheme, 'https') && 443 != $port) + ) { + $host .= ':' . $port; + } + } + + if (!empty($challenge['domain'])) { + $prefixes = array(); + foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { + // don't bother with different servers + if ('/' == substr($prefix, 0, 1)) { + $prefixes[] = $host . $prefix; + } + } + } + if (empty($prefixes)) { + $prefixes = array($host . '/'); + } + + $ret = true; + foreach ($prefixes as $prefix) { + if (!empty(self::$challenges[$prefix]) + && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) + ) { + // probably credentials are invalid + $ret = false; + } + self::$challenges[$prefix] =& $challenge; + } + return $ret; + } + + /** + * Checks whether another request should be performed with proxy digest auth + * + * Several conditions should be satisfied for it to return true: + * - response status should be 407 + * - proxy auth credentials should be set in the request object + * - response should contain Proxy-Authenticate header with digest challenge + * - there is either no challenge stored for this proxy or new challenge + * contains stale=true parameter (in other case we probably just failed + * due to invalid username / password) + * + * The method stores challenge values in $challenges static property + * + * @param HTTP_Request2_Response $response response to check + * + * @return boolean whether another request should be performed + * @throws HTTP_Request2_Exception in case of unsupported challenge parameters + */ + protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) + { + if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { + return false; + } + if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { + return false; + } + + $key = 'proxy://' . $this->request->getConfig('proxy_host') . + ':' . $this->request->getConfig('proxy_port'); + + if (!empty(self::$challenges[$key]) + && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) + ) { + $ret = false; + } else { + $ret = true; + } + self::$challenges[$key] = $challenge; + return $ret; + } + + /** + * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value + * + * There is a problem with implementation of RFC 2617: several of the parameters + * are defined as quoted-string there and thus may contain backslash escaped + * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as + * just value of quoted-string X without surrounding quotes, it doesn't speak + * about removing backslash escaping. + * + * Now realm parameter is user-defined and human-readable, strange things + * happen when it contains quotes: + * - Apache allows quotes in realm, but apparently uses realm value without + * backslashes for digest computation + * - Squid allows (manually escaped) quotes there, but it is impossible to + * authorize with either escaped or unescaped quotes used in digest, + * probably it can't parse the response (?) + * - Both IE and Firefox display realm value with backslashes in + * the password popup and apparently use the same value for digest + * + * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in + * quoted-string handling, unfortunately that means failure to authorize + * sometimes + * + * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header + * + * @return mixed associative array with challenge parameters, false if + * no challenge is present in header value + * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters + */ + protected function parseDigestChallenge($headerValue) + { + $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . + self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; + $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; + if (!preg_match($challenge, $headerValue, $matches)) { + return false; + } + + preg_match_all('!' . $authParam . '!', $matches[0], $params); + $paramsAry = array(); + $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', + 'algorithm', 'qop'); + for ($i = 0; $i < count($params[0]); $i++) { + // section 3.2.1: Any unrecognized directive MUST be ignored. + if (in_array($params[1][$i], $knownParams)) { + if ('"' == substr($params[2][$i], 0, 1)) { + $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); + } else { + $paramsAry[$params[1][$i]] = $params[2][$i]; + } + } + } + // we only support qop=auth + if (!empty($paramsAry['qop']) + && !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) + ) { + throw new HTTP_Request2_NotImplementedException( + "Only 'auth' qop is currently supported in digest authentication, " . + "server requested '{$paramsAry['qop']}'" + ); + } + // we only support algorithm=MD5 + if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { + throw new HTTP_Request2_NotImplementedException( + "Only 'MD5' algorithm is currently supported in digest authentication, " . + "server requested '{$paramsAry['algorithm']}'" + ); + } + + return $paramsAry; + } + + /** + * Parses [Proxy-]Authentication-Info header value and updates challenge + * + * @param array &$challenge challenge to update + * @param string $headerValue value of [Proxy-]Authentication-Info header + * + * @todo validate server rspauth response + */ + protected function updateChallenge(&$challenge, $headerValue) + { + $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . + self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; + $paramsAry = array(); + + preg_match_all($authParam, $headerValue, $params); + for ($i = 0; $i < count($params[0]); $i++) { + if ('"' == substr($params[2][$i], 0, 1)) { + $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); + } else { + $paramsAry[$params[1][$i]] = $params[2][$i]; + } + } + // for now, just update the nonce value + if (!empty($paramsAry['nextnonce'])) { + $challenge['nonce'] = $paramsAry['nextnonce']; + $challenge['nc'] = 1; + } + } + + /** + * Creates a value for [Proxy-]Authorization header when using digest authentication + * + * @param string $user user name + * @param string $password password + * @param string $url request URL + * @param array &$challenge digest challenge parameters + * + * @return string value of [Proxy-]Authorization request header + * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 + */ + protected function createDigestResponse($user, $password, $url, &$challenge) + { + if (false !== ($q = strpos($url, '?')) + && $this->request->getConfig('digest_compat_ie') + ) { + $url = substr($url, 0, $q); + } + + $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); + $a2 = md5($this->request->getMethod() . ':' . $url); + + if (empty($challenge['qop'])) { + $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); + } else { + $challenge['cnonce'] = 'Req2.' . rand(); + if (empty($challenge['nc'])) { + $challenge['nc'] = 1; + } + $nc = sprintf('%08x', $challenge['nc']++); + $digest = md5( + $a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . + $challenge['cnonce'] . ':auth:' . $a2 + ); + } + return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . + 'realm="' . $challenge['realm'] . '", ' . + 'nonce="' . $challenge['nonce'] . '", ' . + 'uri="' . $url . '", ' . + 'response="' . $digest . '"' . + (!empty($challenge['opaque'])? + ', opaque="' . $challenge['opaque'] . '"': + '') . + (!empty($challenge['qop'])? + ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': + ''); + } + + /** + * Adds 'Authorization' header (if needed) to request headers array + * + * @param array &$headers request headers + * @param string $requestHost request host (needed for digest authentication) + * @param string $requestUrl request URL (needed for digest authentication) + * + * @throws HTTP_Request2_NotImplementedException + */ + protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) + { + if (!($auth = $this->request->getAuth())) { + return; + } + switch ($auth['scheme']) { + case HTTP_Request2::AUTH_BASIC: + $headers['authorization'] = 'Basic ' . base64_encode( + $auth['user'] . ':' . $auth['password'] + ); + break; + + case HTTP_Request2::AUTH_DIGEST: + unset($this->serverChallenge); + $fullUrl = ('/' == $requestUrl[0])? + $this->request->getUrl()->getScheme() . '://' . + $requestHost . $requestUrl: + $requestUrl; + foreach (array_keys(self::$challenges) as $key) { + if ($key == substr($fullUrl, 0, strlen($key))) { + $headers['authorization'] = $this->createDigestResponse( + $auth['user'], $auth['password'], + $requestUrl, self::$challenges[$key] + ); + $this->serverChallenge =& self::$challenges[$key]; + break; + } + } + break; + + default: + throw new HTTP_Request2_NotImplementedException( + "Unknown HTTP authentication scheme '{$auth['scheme']}'" + ); + } + } + + /** + * Adds 'Proxy-Authorization' header (if needed) to request headers array + * + * @param array &$headers request headers + * @param string $requestUrl request URL (needed for digest authentication) + * + * @throws HTTP_Request2_NotImplementedException + */ + protected function addProxyAuthorizationHeader(&$headers, $requestUrl) + { + if (!$this->request->getConfig('proxy_host') + || !($user = $this->request->getConfig('proxy_user')) + || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) + && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) + ) { + return; + } + + $password = $this->request->getConfig('proxy_password'); + switch ($this->request->getConfig('proxy_auth_scheme')) { + case HTTP_Request2::AUTH_BASIC: + $headers['proxy-authorization'] = 'Basic ' . base64_encode( + $user . ':' . $password + ); + break; + + case HTTP_Request2::AUTH_DIGEST: + unset($this->proxyChallenge); + $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . + ':' . $this->request->getConfig('proxy_port'); + if (!empty(self::$challenges[$proxyUrl])) { + $headers['proxy-authorization'] = $this->createDigestResponse( + $user, $password, + $requestUrl, self::$challenges[$proxyUrl] + ); + $this->proxyChallenge =& self::$challenges[$proxyUrl]; + } + break; + + default: + throw new HTTP_Request2_NotImplementedException( + "Unknown HTTP authentication scheme '" . + $this->request->getConfig('proxy_auth_scheme') . "'" + ); + } + } + + + /** + * Creates the string with the Request-Line and request headers + * + * @return string + * @throws HTTP_Request2_Exception + */ + protected function prepareHeaders() + { + $headers = $this->request->getHeaders(); + $url = $this->request->getUrl(); + $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); + $host = $url->getHost(); + + $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; + if (($port = $url->getPort()) && $port != $defaultPort || $connect) { + $host .= ':' . (empty($port)? $defaultPort: $port); + } + // Do not overwrite explicitly set 'Host' header, see bug #16146 + if (!isset($headers['host'])) { + $headers['host'] = $host; + } + + if ($connect) { + $requestUrl = $host; + + } else { + if (!$this->request->getConfig('proxy_host') + || 'http' != $this->request->getConfig('proxy_type') + || 0 == strcasecmp($url->getScheme(), 'https') + ) { + $requestUrl = ''; + } else { + $requestUrl = $url->getScheme() . '://' . $host; + } + $path = $url->getPath(); + $query = $url->getQuery(); + $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); + } + + if ('1.1' == $this->request->getConfig('protocol_version') + && extension_loaded('zlib') && !isset($headers['accept-encoding']) + ) { + $headers['accept-encoding'] = 'gzip, deflate'; + } + if (($jar = $this->request->getCookieJar()) + && ($cookies = $jar->getMatching($this->request->getUrl(), true)) + ) { + $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; + } + + $this->addAuthorizationHeader($headers, $host, $requestUrl); + $this->addProxyAuthorizationHeader($headers, $requestUrl); + $this->calculateRequestLength($headers); + if ('1.1' == $this->request->getConfig('protocol_version')) { + $this->updateExpectHeader($headers); + } else { + $this->expect100Continue = false; + } + + $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . + $this->request->getConfig('protocol_version') . "\r\n"; + foreach ($headers as $name => $value) { + $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); + $headersStr .= $canonicalName . ': ' . $value . "\r\n"; + } + return $headersStr . "\r\n"; + } + + /** + * Adds or removes 'Expect: 100-continue' header from request headers + * + * Also sets the $expect100Continue property. Parsing of existing header + * is somewhat needed due to its complex structure and due to the + * requirement in section 8.2.3 of RFC 2616: + * > A client MUST NOT send an Expect request-header field (section + * > 14.20) with the "100-continue" expectation if it does not intend + * > to send a request body. + * + * @param array &$headers Array of headers prepared for the request + * + * @throws HTTP_Request2_LogicException + * @link http://pear.php.net/bugs/bug.php?id=19233 + * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 + */ + protected function updateExpectHeader(&$headers) + { + $this->expect100Continue = false; + $expectations = array(); + if (isset($headers['expect'])) { + if ('' === $headers['expect']) { + // empty 'Expect' header is technically invalid, so just get rid of it + unset($headers['expect']); + return; + } + // build regexp to parse the value of existing Expect header + $expectParam = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:' + . self::REGEXP_TOKEN . '|' + . self::REGEXP_QUOTED_STRING . '))?\s*'; + $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:' + . self::REGEXP_TOKEN . '|' + . self::REGEXP_QUOTED_STRING . ')\s*(?:' + . $expectParam . ')*)?'; + $expectItem = '!(100-continue|' . $expectExtension . ')!A'; + + $pos = 0; + $length = strlen($headers['expect']); + + while ($pos < $length) { + $pos += strspn($headers['expect'], " \t", $pos); + if (',' === substr($headers['expect'], $pos, 1)) { + $pos++; + continue; + + } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) { + throw new HTTP_Request2_LogicException( + "Cannot parse value '{$headers['expect']}' of Expect header", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + + } else { + $pos += strlen($m[0]); + if (strcasecmp('100-continue', $m[0])) { + $expectations[] = $m[0]; + } + } + } + } + + if (1024 < $this->contentLength) { + $expectations[] = '100-continue'; + $this->expect100Continue = true; + } + + if (empty($expectations)) { + unset($headers['expect']); + } else { + $headers['expect'] = implode(',', $expectations); + } + } + + /** + * Sends the request body + * + * @throws HTTP_Request2_MessageException + */ + protected function writeBody() + { + if (in_array($this->request->getMethod(), self::$bodyDisallowed) + || 0 == $this->contentLength + ) { + return; + } + + $position = 0; + $bufferSize = $this->request->getConfig('buffer_size'); + $headers = $this->request->getHeaders(); + $chunked = isset($headers['transfer-encoding']); + while ($position < $this->contentLength) { + if (is_string($this->requestBody)) { + $str = substr($this->requestBody, $position, $bufferSize); + } elseif (is_resource($this->requestBody)) { + $str = fread($this->requestBody, $bufferSize); + } else { + $str = $this->requestBody->read($bufferSize); + } + if (!$chunked) { + $this->socket->write($str); + } else { + $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n"); + } + // Provide the length of written string to the observer, request #7630 + $this->request->setLastEvent('sentBodyPart', strlen($str)); + $position += strlen($str); + } + + // write zero-length chunk + if ($chunked) { + $this->socket->write("0\r\n\r\n"); + } + $this->request->setLastEvent('sentBody', $this->contentLength); + } + + /** + * Reads the remote server's response + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + protected function readResponse() + { + $bufferSize = $this->request->getConfig('buffer_size'); + // http://tools.ietf.org/html/rfc2616#section-8.2.3 + // ...the client SHOULD NOT wait for an indefinite period before sending the request body + $timeout = $this->expect100Continue ? 1 : null; + + do { + try { + $response = new HTTP_Request2_Response( + $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl() + ); + do { + $headerLine = $this->socket->readLine($bufferSize); + $response->parseHeaderLine($headerLine); + } while ('' != $headerLine); + + } catch (HTTP_Request2_MessageException $e) { + if (HTTP_Request2_Exception::TIMEOUT === $e->getCode() + && $this->expect100Continue + ) { + return null; + } + throw $e; + } + if ($this->expect100Continue && 100 == $response->getStatus()) { + return $response; + } + } while (in_array($response->getStatus(), array(100, 101))); + + $this->request->setLastEvent('receivedHeaders', $response); + + // No body possible in such responses + if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() + || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() + && 200 <= $response->getStatus() && 300 > $response->getStatus()) + || in_array($response->getStatus(), array(204, 304)) + ) { + return $response; + } + + $chunked = 'chunked' == $response->getHeader('transfer-encoding'); + $length = $response->getHeader('content-length'); + $hasBody = false; + if ($chunked || null === $length || 0 < intval($length)) { + // RFC 2616, section 4.4: + // 3. ... If a message is received with both a + // Transfer-Encoding header field and a Content-Length header field, + // the latter MUST be ignored. + $toRead = ($chunked || null === $length)? null: $length; + $this->chunkLength = 0; + + while (!$this->socket->eof() && (is_null($toRead) || 0 < $toRead)) { + if ($chunked) { + $data = $this->readChunked($bufferSize); + } elseif (is_null($toRead)) { + $data = $this->socket->read($bufferSize); + } else { + $data = $this->socket->read(min($toRead, $bufferSize)); + $toRead -= strlen($data); + } + if ('' == $data && (!$this->chunkLength || $this->socket->eof())) { + break; + } + + $hasBody = true; + if ($this->request->getConfig('store_body')) { + $response->appendBody($data); + } + if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { + $this->request->setLastEvent('receivedEncodedBodyPart', $data); + } else { + $this->request->setLastEvent('receivedBodyPart', $data); + } + } + } + + if ($hasBody) { + $this->request->setLastEvent('receivedBody', $response); + } + return $response; + } + + /** + * Reads a part of response body encoded with chunked Transfer-Encoding + * + * @param int $bufferSize buffer size to use for reading + * + * @return string + * @throws HTTP_Request2_MessageException + */ + protected function readChunked($bufferSize) + { + // at start of the next chunk? + if (0 == $this->chunkLength) { + $line = $this->socket->readLine($bufferSize); + if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { + throw new HTTP_Request2_MessageException( + "Cannot decode chunked response, invalid chunk length '{$line}'", + HTTP_Request2_Exception::DECODE_ERROR + ); + } else { + $this->chunkLength = hexdec($matches[1]); + // Chunk with zero length indicates the end + if (0 == $this->chunkLength) { + $this->socket->readLine($bufferSize); + return ''; + } + } + } + $data = $this->socket->read(min($this->chunkLength, $bufferSize)); + $this->chunkLength -= strlen($data); + if (0 == $this->chunkLength) { + $this->socket->readLine($bufferSize); // Trailing CRLF + } + return $data; + } +} + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/CookieJar.php b/vendor/pear/http_request2/HTTP/Request2/CookieJar.php new file mode 100644 index 000000000..ed6352ebe --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/CookieJar.php @@ -0,0 +1,494 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Class representing a HTTP request message */ +require_once 'HTTP/Request2.php'; + +/** + * Stores cookies and passes them between HTTP requests + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_CookieJar implements Serializable +{ + /** + * Array of stored cookies + * + * The array is indexed by domain, path and cookie name + * .example.com + * / + * some_cookie => cookie data + * /subdir + * other_cookie => cookie data + * .example.org + * ... + * + * @var array + */ + protected $cookies = array(); + + /** + * Whether session cookies should be serialized when serializing the jar + * @var bool + */ + protected $serializeSession = false; + + /** + * Whether Public Suffix List should be used for domain matching + * @var bool + */ + protected $useList = true; + + /** + * Array with Public Suffix List data + * @var array + * @link http://publicsuffix.org/ + */ + protected static $psl = array(); + + /** + * Class constructor, sets various options + * + * @param bool $serializeSessionCookies Controls serializing session cookies, + * see {@link serializeSessionCookies()} + * @param bool $usePublicSuffixList Controls using Public Suffix List, + * see {@link usePublicSuffixList()} + */ + public function __construct( + $serializeSessionCookies = false, $usePublicSuffixList = true + ) { + $this->serializeSessionCookies($serializeSessionCookies); + $this->usePublicSuffixList($usePublicSuffixList); + } + + /** + * Returns current time formatted in ISO-8601 at UTC timezone + * + * @return string + */ + protected function now() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + return $dt->format(DateTime::ISO8601); + } + + /** + * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields + * + * The checks are as follows: + * - cookie array should contain 'name' and 'value' fields; + * - name and value should not contain disallowed symbols; + * - 'expires' should be either empty parseable by DateTime; + * - 'domain' and 'path' should be either not empty or an URL where + * cookie was set should be provided. + * - if $setter is provided, then document at that URL should be allowed + * to set a cookie for that 'domain'. If $setter is not provided, + * then no domain checks will be made. + * + * 'expires' field will be converted to ISO8601 format from COOKIE format, + * 'domain' and 'path' will be set from setter URL if empty. + * + * @param array $cookie cookie data, as returned by + * {@link HTTP_Request2_Response::getCookies()} + * @param Net_URL2 $setter URL of the document that sent Set-Cookie header + * + * @return array Updated cookie array + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_MessageException + */ + protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) + { + if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { + throw new HTTP_Request2_LogicException( + "Cookie array should contain 'name' and 'value' fields", + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) { + throw new HTTP_Request2_LogicException( + "Invalid cookie name: '{$cookie['name']}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) { + throw new HTTP_Request2_LogicException( + "Invalid cookie value: '{$cookie['value']}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); + + // Need ISO-8601 date @ UTC timezone + if (!empty($cookie['expires']) + && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires']) + ) { + try { + $dt = new DateTime($cookie['expires']); + $dt->setTimezone(new DateTimeZone('UTC')); + $cookie['expires'] = $dt->format(DateTime::ISO8601); + } catch (Exception $e) { + throw new HTTP_Request2_LogicException($e->getMessage()); + } + } + + if (empty($cookie['domain']) || empty($cookie['path'])) { + if (!$setter) { + throw new HTTP_Request2_LogicException( + 'Cookie misses domain and/or path component, cookie setter URL needed', + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if (empty($cookie['domain'])) { + if ($host = $setter->getHost()) { + $cookie['domain'] = $host; + } else { + throw new HTTP_Request2_LogicException( + 'Setter URL does not contain host part, can\'t set cookie domain', + HTTP_Request2_Exception::MISSING_VALUE + ); + } + } + if (empty($cookie['path'])) { + $path = $setter->getPath(); + $cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); + } + } + + if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) { + throw new HTTP_Request2_MessageException( + "Domain " . $setter->getHost() . " cannot set cookies for " + . $cookie['domain'] + ); + } + + return $cookie; + } + + /** + * Stores a cookie in the jar + * + * @param array $cookie cookie data, as returned by + * {@link HTTP_Request2_Response::getCookies()} + * @param Net_URL2 $setter URL of the document that sent Set-Cookie header + * + * @throws HTTP_Request2_Exception + */ + public function store(array $cookie, Net_URL2 $setter = null) + { + $cookie = $this->checkAndUpdateFields($cookie, $setter); + + if (strlen($cookie['value']) + && (is_null($cookie['expires']) || $cookie['expires'] > $this->now()) + ) { + if (!isset($this->cookies[$cookie['domain']])) { + $this->cookies[$cookie['domain']] = array(); + } + if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { + $this->cookies[$cookie['domain']][$cookie['path']] = array(); + } + $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; + + } elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) { + unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]); + } + } + + /** + * Adds cookies set in HTTP response to the jar + * + * @param HTTP_Request2_Response $response HTTP response message + * @param Net_URL2 $setter original request URL, needed for + * setting default domain/path + */ + public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter) + { + foreach ($response->getCookies() as $cookie) { + $this->store($cookie, $setter); + } + } + + /** + * Returns all cookies matching a given request URL + * + * The following checks are made: + * - cookie domain should match request host + * - cookie path should be a prefix for request path + * - 'secure' cookies will only be sent for HTTPS requests + * + * @param Net_URL2 $url Request url + * @param bool $asString Whether to return cookies as string for "Cookie: " header + * + * @return array|string Matching cookies + */ + public function getMatching(Net_URL2 $url, $asString = false) + { + $host = $url->getHost(); + $path = $url->getPath(); + $secure = 0 == strcasecmp($url->getScheme(), 'https'); + + $matched = $ret = array(); + foreach (array_keys($this->cookies) as $domain) { + if ($this->domainMatch($host, $domain)) { + foreach (array_keys($this->cookies[$domain]) as $cPath) { + if (0 === strpos($path, $cPath)) { + foreach ($this->cookies[$domain][$cPath] as $name => $cookie) { + if (!$cookie['secure'] || $secure) { + $matched[$name][strlen($cookie['path'])] = $cookie; + } + } + } + } + } + } + foreach ($matched as $cookies) { + krsort($cookies); + $ret = array_merge($ret, $cookies); + } + if (!$asString) { + return $ret; + } else { + $str = ''; + foreach ($ret as $c) { + $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value']; + } + return $str; + } + } + + /** + * Returns all cookies stored in a jar + * + * @return array + */ + public function getAll() + { + $cookies = array(); + foreach (array_keys($this->cookies) as $domain) { + foreach (array_keys($this->cookies[$domain]) as $path) { + foreach ($this->cookies[$domain][$path] as $name => $cookie) { + $cookies[] = $cookie; + } + } + } + return $cookies; + } + + /** + * Sets whether session cookies should be serialized when serializing the jar + * + * @param boolean $serialize serialize? + */ + public function serializeSessionCookies($serialize) + { + $this->serializeSession = (bool)$serialize; + } + + /** + * Sets whether Public Suffix List should be used for restricting cookie-setting + * + * Without PSL {@link domainMatch()} will only prevent setting cookies for + * top-level domains like '.com' or '.org'. However, it will not prevent + * setting a cookie for '.co.uk' even though only third-level registrations + * are possible in .uk domain. + * + * With the List it is possible to find the highest level at which a domain + * may be registered for a particular top-level domain and consequently + * prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by + * Firefox, Chrome and Opera browsers to restrict cookie setting. + * + * Note that PSL is licensed differently to HTTP_Request2 package (refer to + * the license information in public-suffix-list.php), so you can disable + * its use if this is an issue for you. + * + * @param boolean $useList use the list? + * + * @link http://publicsuffix.org/learn/ + */ + public function usePublicSuffixList($useList) + { + $this->useList = (bool)$useList; + } + + /** + * Returns string representation of object + * + * @return string + * + * @see Serializable::serialize() + */ + public function serialize() + { + $cookies = $this->getAll(); + if (!$this->serializeSession) { + for ($i = count($cookies) - 1; $i >= 0; $i--) { + if (empty($cookies[$i]['expires'])) { + unset($cookies[$i]); + } + } + } + return serialize(array( + 'cookies' => $cookies, + 'serializeSession' => $this->serializeSession, + 'useList' => $this->useList + )); + } + + /** + * Constructs the object from serialized string + * + * @param string $serialized string representation + * + * @see Serializable::unserialize() + */ + public function unserialize($serialized) + { + $data = unserialize($serialized); + $now = $this->now(); + $this->serializeSessionCookies($data['serializeSession']); + $this->usePublicSuffixList($data['useList']); + foreach ($data['cookies'] as $cookie) { + if (!empty($cookie['expires']) && $cookie['expires'] <= $now) { + continue; + } + if (!isset($this->cookies[$cookie['domain']])) { + $this->cookies[$cookie['domain']] = array(); + } + if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { + $this->cookies[$cookie['domain']][$cookie['path']] = array(); + } + $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; + } + } + + /** + * Checks whether a cookie domain matches a request host. + * + * The method is used by {@link store()} to check for whether a document + * at given URL can set a cookie with a given domain attribute and by + * {@link getMatching()} to find cookies matching the request URL. + * + * @param string $requestHost request host + * @param string $cookieDomain cookie domain + * + * @return bool match success + */ + public function domainMatch($requestHost, $cookieDomain) + { + if ($requestHost == $cookieDomain) { + return true; + } + // IP address, we require exact match + if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) { + return false; + } + if ('.' != $cookieDomain[0]) { + $cookieDomain = '.' . $cookieDomain; + } + // prevents setting cookies for '.com' and similar domains + if (!$this->useList && substr_count($cookieDomain, '.') < 2 + || $this->useList && !self::getRegisteredDomain($cookieDomain) + ) { + return false; + } + return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain; + } + + /** + * Removes subdomains to get the registered domain (the first after top-level) + * + * The method will check Public Suffix List to find out where top-level + * domain ends and registered domain starts. It will remove domain parts + * to the left of registered one. + * + * @param string $domain domain name + * + * @return string|bool registered domain, will return false if $domain is + * either invalid or a TLD itself + */ + public static function getRegisteredDomain($domain) + { + $domainParts = explode('.', ltrim($domain, '.')); + + // load the list if needed + if (empty(self::$psl)) { + $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2'; + if (0 === strpos($path, '@' . 'data_dir@')) { + $path = realpath( + dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' + ); + } + self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php'; + } + + if (!($result = self::checkDomainsList($domainParts, self::$psl))) { + // known TLD, invalid domain name + return false; + } + + // unknown TLD + if (!strpos($result, '.')) { + // fallback to checking that domain "has at least two dots" + if (2 > ($count = count($domainParts))) { + return false; + } + return $domainParts[$count - 2] . '.' . $domainParts[$count - 1]; + } + return $result; + } + + /** + * Recursive helper method for {@link getRegisteredDomain()} + * + * @param array $domainParts remaining domain parts + * @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check + * + * @return string|null concatenated domain parts, null in case of error + */ + protected static function checkDomainsList(array $domainParts, $listNode) + { + $sub = array_pop($domainParts); + $result = null; + + if (!is_array($listNode) || is_null($sub) + || array_key_exists('!' . $sub, $listNode) + ) { + return $sub; + + } elseif (array_key_exists($sub, $listNode)) { + $result = self::checkDomainsList($domainParts, $listNode[$sub]); + + } elseif (array_key_exists('*', $listNode)) { + $result = self::checkDomainsList($domainParts, $listNode['*']); + + } else { + return $sub; + } + + return (strlen($result) > 0) ? ($result . '.' . $sub) : null; + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Exception.php b/vendor/pear/http_request2/HTTP/Request2/Exception.php new file mode 100644 index 000000000..d331372bf --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Exception.php @@ -0,0 +1,160 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Base class for exceptions in PEAR + */ +require_once 'PEAR/Exception.php'; + +/** + * Base exception class for HTTP_Request2 package + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 + */ +class HTTP_Request2_Exception extends PEAR_Exception +{ + /** An invalid argument was passed to a method */ + const INVALID_ARGUMENT = 1; + /** Some required value was not available */ + const MISSING_VALUE = 2; + /** Request cannot be processed due to errors in PHP configuration */ + const MISCONFIGURATION = 3; + /** Error reading the local file */ + const READ_ERROR = 4; + + /** Server returned a response that does not conform to HTTP protocol */ + const MALFORMED_RESPONSE = 10; + /** Failure decoding Content-Encoding or Transfer-Encoding of response */ + const DECODE_ERROR = 20; + /** Operation timed out */ + const TIMEOUT = 30; + /** Number of redirects exceeded 'max_redirects' configuration parameter */ + const TOO_MANY_REDIRECTS = 40; + /** Redirect to a protocol other than http(s):// */ + const NON_HTTP_REDIRECT = 50; + + /** + * Native error code + * @var int + */ + private $_nativeCode; + + /** + * Constructor, can set package error code and native error code + * + * @param string $message exception message + * @param int $code package error code, one of class constants + * @param int $nativeCode error code from underlying PHP extension + */ + public function __construct($message = null, $code = null, $nativeCode = null) + { + parent::__construct($message, $code); + $this->_nativeCode = $nativeCode; + } + + /** + * Returns error code produced by underlying PHP extension + * + * For Socket Adapter this may contain error number returned by + * stream_socket_client(), for Curl Adapter this will contain error number + * returned by curl_errno() + * + * @return integer + */ + public function getNativeCode() + { + return $this->_nativeCode; + } +} + +/** + * Exception thrown in case of missing features + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception +{ +} + +/** + * Exception that represents error in the program logic + * + * This exception usually implies a programmer's error, like passing invalid + * data to methods or trying to use PHP extensions that weren't installed or + * enabled. Usually exceptions of this kind will be thrown before request even + * starts. + * + * The exception will usually contain a package error code. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_LogicException extends HTTP_Request2_Exception +{ +} + +/** + * Exception thrown when connection to a web or proxy server fails + * + * The exception will not contain a package error code, but will contain + * native error code, as returned by stream_socket_client() or curl_errno(). + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception +{ +} + +/** + * Exception thrown when sending or receiving HTTP message fails + * + * The exception may contain both package error code and native error code. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_MessageException extends HTTP_Request2_Exception +{ +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php b/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php new file mode 100644 index 000000000..54d23ec1a --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php @@ -0,0 +1,268 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Exception class for HTTP_Request2 package */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Class for building multipart/form-data request body + * + * The class helps to reduce memory consumption by streaming large file uploads + * from disk, it also allows monitoring of upload progress (see request #7630) + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc1867 + */ +class HTTP_Request2_MultipartBody +{ + /** + * MIME boundary + * @var string + */ + private $_boundary; + + /** + * Form parameters added via {@link HTTP_Request2::addPostParameter()} + * @var array + */ + private $_params = array(); + + /** + * File uploads added via {@link HTTP_Request2::addUpload()} + * @var array + */ + private $_uploads = array(); + + /** + * Header for parts with parameters + * @var string + */ + private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; + + /** + * Header for parts with uploads + * @var string + */ + private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; + + /** + * Current position in parameter and upload arrays + * + * First number is index of "current" part, second number is position within + * "current" part + * + * @var array + */ + private $_pos = array(0, 0); + + + /** + * Constructor. Sets the arrays with POST data. + * + * @param array $params values of form fields set via + * {@link HTTP_Request2::addPostParameter()} + * @param array $uploads file uploads set via + * {@link HTTP_Request2::addUpload()} + * @param bool $useBrackets whether to append brackets to array variable names + */ + public function __construct(array $params, array $uploads, $useBrackets = true) + { + $this->_params = self::_flattenArray('', $params, $useBrackets); + foreach ($uploads as $fieldName => $f) { + if (!is_array($f['fp'])) { + $this->_uploads[] = $f + array('name' => $fieldName); + } else { + for ($i = 0; $i < count($f['fp']); $i++) { + $upload = array( + 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) + ); + foreach (array('fp', 'filename', 'size', 'type') as $key) { + $upload[$key] = $f[$key][$i]; + } + $this->_uploads[] = $upload; + } + } + } + } + + /** + * Returns the length of the body to use in Content-Length header + * + * @return integer + */ + public function getLength() + { + $boundaryLength = strlen($this->getBoundary()); + $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; + $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; + $length = $boundaryLength + 6; + foreach ($this->_params as $p) { + $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; + } + foreach ($this->_uploads as $u) { + $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + + strlen($u['filename']) + $u['size'] + 2; + } + return $length; + } + + /** + * Returns the boundary to use in Content-Type header + * + * @return string + */ + public function getBoundary() + { + if (empty($this->_boundary)) { + $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); + } + return $this->_boundary; + } + + /** + * Returns next chunk of request body + * + * @param integer $length Number of bytes to read + * + * @return string Up to $length bytes of data, empty string if at end + * @throws HTTP_Request2_LogicException + */ + public function read($length) + { + $ret = ''; + $boundary = $this->getBoundary(); + $paramCount = count($this->_params); + $uploadCount = count($this->_uploads); + while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { + $oldLength = $length; + if ($this->_pos[0] < $paramCount) { + $param = sprintf( + $this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0] + ) . $this->_params[$this->_pos[0]][1] . "\r\n"; + $ret .= substr($param, $this->_pos[1], $length); + $length -= min(strlen($param) - $this->_pos[1], $length); + + } elseif ($this->_pos[0] < $paramCount + $uploadCount) { + $pos = $this->_pos[0] - $paramCount; + $header = sprintf( + $this->_headerUpload, $boundary, $this->_uploads[$pos]['name'], + $this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type'] + ); + if ($this->_pos[1] < strlen($header)) { + $ret .= substr($header, $this->_pos[1], $length); + $length -= min(strlen($header) - $this->_pos[1], $length); + } + $filePos = max(0, $this->_pos[1] - strlen($header)); + if ($filePos < $this->_uploads[$pos]['size']) { + while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) { + if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) { + throw new HTTP_Request2_LogicException( + 'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR + ); + } + $ret .= $chunk; + $length -= strlen($chunk); + } + } + if ($length > 0) { + $start = $this->_pos[1] + ($oldLength - $length) - + strlen($header) - $this->_uploads[$pos]['size']; + $ret .= substr("\r\n", $start, $length); + $length -= min(2 - $start, $length); + } + + } else { + $closing = '--' . $boundary . "--\r\n"; + $ret .= substr($closing, $this->_pos[1], $length); + $length -= min(strlen($closing) - $this->_pos[1], $length); + } + if ($length > 0) { + $this->_pos = array($this->_pos[0] + 1, 0); + } else { + $this->_pos[1] += $oldLength; + } + } + return $ret; + } + + /** + * Sets the current position to the start of the body + * + * This allows reusing the same body in another request + */ + public function rewind() + { + $this->_pos = array(0, 0); + foreach ($this->_uploads as $u) { + rewind($u['fp']); + } + } + + /** + * Returns the body as string + * + * Note that it reads all file uploads into memory so it is a good idea not + * to use this method with large file uploads and rely on read() instead. + * + * @return string + */ + public function __toString() + { + $this->rewind(); + return $this->read($this->getLength()); + } + + + /** + * Helper function to change the (probably multidimensional) associative array + * into the simple one. + * + * @param string $name name for item + * @param mixed $values item's values + * @param bool $useBrackets whether to append [] to array variables' names + * + * @return array array with the following items: array('item name', 'item value'); + */ + private static function _flattenArray($name, $values, $useBrackets) + { + if (!is_array($values)) { + return array(array($name, $values)); + } else { + $ret = array(); + foreach ($values as $k => $v) { + if (empty($name)) { + $newName = $k; + } elseif ($useBrackets) { + $newName = $name . '[' . $k . ']'; + } else { + $newName = $name; + } + $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); + } + return $ret; + } + } +} +?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php b/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php new file mode 100644 index 000000000..2ba9f59df --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php @@ -0,0 +1,192 @@ + + * @author Alexey Borzov + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Exception class for HTTP_Request2 package + */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * A debug observer useful for debugging / testing. + * + * This observer logs to a log target data corresponding to the various request + * and response events, it logs by default to php://output but can be configured + * to log to a file or via the PEAR Log package. + * + * A simple example: + * + * require_once 'HTTP/Request2.php'; + * require_once 'HTTP/Request2/Observer/Log.php'; + * + * $request = new HTTP_Request2('http://www.example.com'); + * $observer = new HTTP_Request2_Observer_Log(); + * $request->attach($observer); + * $request->send(); + * + * + * A more complex example with PEAR Log: + * + * require_once 'HTTP/Request2.php'; + * require_once 'HTTP/Request2/Observer/Log.php'; + * require_once 'Log.php'; + * + * $request = new HTTP_Request2('http://www.example.com'); + * // we want to log with PEAR log + * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); + * + * // we only want to log received headers + * $observer->events = array('receivedHeaders'); + * + * $request->attach($observer); + * $request->send(); + * + * + * @category HTTP + * @package HTTP_Request2 + * @author David Jean Louis + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Observer_Log implements SplObserver +{ + // properties {{{ + + /** + * The log target, it can be a a resource or a PEAR Log instance. + * + * @var resource|Log $target + */ + protected $target = null; + + /** + * The events to log. + * + * @var array $events + */ + public $events = array( + 'connect', + 'sentHeaders', + 'sentBody', + 'receivedHeaders', + 'receivedBody', + 'disconnect', + ); + + // }}} + // __construct() {{{ + + /** + * Constructor. + * + * @param mixed $target Can be a file path (default: php://output), a resource, + * or an instance of the PEAR Log class. + * @param array $events Array of events to listen to (default: all events) + * + * @return void + */ + public function __construct($target = 'php://output', array $events = array()) + { + if (!empty($events)) { + $this->events = $events; + } + if (is_resource($target) || $target instanceof Log) { + $this->target = $target; + } elseif (false === ($this->target = @fopen($target, 'ab'))) { + throw new HTTP_Request2_Exception("Unable to open '{$target}'"); + } + } + + // }}} + // update() {{{ + + /** + * Called when the request notifies us of an event. + * + * @param HTTP_Request2 $subject The HTTP_Request2 instance + * + * @return void + */ + public function update(SplSubject $subject) + { + $event = $subject->getLastEvent(); + if (!in_array($event['name'], $this->events)) { + return; + } + + switch ($event['name']) { + case 'connect': + $this->log('* Connected to ' . $event['data']); + break; + case 'sentHeaders': + $headers = explode("\r\n", $event['data']); + array_pop($headers); + foreach ($headers as $header) { + $this->log('> ' . $header); + } + break; + case 'sentBody': + $this->log('> ' . $event['data'] . ' byte(s) sent'); + break; + case 'receivedHeaders': + $this->log(sprintf( + '< HTTP/%s %s %s', $event['data']->getVersion(), + $event['data']->getStatus(), $event['data']->getReasonPhrase() + )); + $headers = $event['data']->getHeader(); + foreach ($headers as $key => $val) { + $this->log('< ' . $key . ': ' . $val); + } + $this->log('< '); + break; + case 'receivedBody': + $this->log($event['data']->getBody()); + break; + case 'disconnect': + $this->log('* Disconnected'); + break; + } + } + + // }}} + // log() {{{ + + /** + * Logs the given message to the configured target. + * + * @param string $message Message to display + * + * @return void + */ + protected function log($message) + { + if ($this->target instanceof Log) { + $this->target->debug($message); + } elseif (is_resource($this->target)) { + fwrite($this->target, $message . "\r\n"); + } + } + + // }}} +} + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Response.php b/vendor/pear/http_request2/HTTP/Request2/Response.php new file mode 100644 index 000000000..56ee6c689 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/Response.php @@ -0,0 +1,631 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Exception class for HTTP_Request2 package + */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Class representing a HTTP response + * + * The class is designed to be used in "streaming" scenario, building the + * response as it is being received: + * + * $statusLine = read_status_line(); + * $response = new HTTP_Request2_Response($statusLine); + * do { + * $headerLine = read_header_line(); + * $response->parseHeaderLine($headerLine); + * } while ($headerLine != ''); + * + * while ($chunk = read_body()) { + * $response->appendBody($chunk); + * } + * + * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); + * + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc2616#section-6 + */ +class HTTP_Request2_Response +{ + /** + * HTTP protocol version (e.g. 1.0, 1.1) + * @var string + */ + protected $version; + + /** + * Status code + * @var integer + * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 + */ + protected $code; + + /** + * Reason phrase + * @var string + * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 + */ + protected $reasonPhrase; + + /** + * Effective URL (may be different from original request URL in case of redirects) + * @var string + */ + protected $effectiveUrl; + + /** + * Associative array of response headers + * @var array + */ + protected $headers = array(); + + /** + * Cookies set in the response + * @var array + */ + protected $cookies = array(); + + /** + * Name of last header processed by parseHederLine() + * + * Used to handle the headers that span multiple lines + * + * @var string + */ + protected $lastHeader = null; + + /** + * Response body + * @var string + */ + protected $body = ''; + + /** + * Whether the body is still encoded by Content-Encoding + * + * cURL provides the decoded body to the callback; if we are reading from + * socket the body is still gzipped / deflated + * + * @var bool + */ + protected $bodyEncoded; + + /** + * Associative array of HTTP status code / reason phrase. + * + * @var array + * @link http://tools.ietf.org/html/rfc2616#section-10 + */ + protected static $phrases = array( + + // 1xx: Informational - Request received, continuing process + 100 => 'Continue', + 101 => 'Switching Protocols', + + // 2xx: Success - The action was successfully received, understood and + // accepted + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + // 3xx: Redirection - Further action must be taken in order to complete + // the request + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', // 1.1 + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + // 4xx: Client Error - The request contains bad syntax or cannot be + // fulfilled + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + // 5xx: Server Error - The server failed to fulfill an apparently + // valid request + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', + 509 => 'Bandwidth Limit Exceeded', + + ); + + /** + * Returns the default reason phrase for the given code or all reason phrases + * + * @param int $code Response code + * + * @return string|array|null Default reason phrase for $code if $code is given + * (null if no phrase is available), array of all + * reason phrases if $code is null + * @link http://pear.php.net/bugs/18716 + */ + public static function getDefaultReasonPhrase($code = null) + { + if (null === $code) { + return self::$phrases; + } else { + return isset(self::$phrases[$code]) ? self::$phrases[$code] : null; + } + } + + /** + * Constructor, parses the response status line + * + * @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK") + * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding + * @param string $effectiveUrl Effective URL of the response + * + * @throws HTTP_Request2_MessageException if status line is invalid according to spec + */ + public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) + { + if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { + throw new HTTP_Request2_MessageException( + "Malformed response: {$statusLine}", + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } + $this->version = $m[1]; + $this->code = intval($m[2]); + $this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code); + $this->bodyEncoded = (bool)$bodyEncoded; + $this->effectiveUrl = (string)$effectiveUrl; + } + + /** + * Parses the line from HTTP response filling $headers array + * + * The method should be called after reading the line from socket or receiving + * it into cURL callback. Passing an empty string here indicates the end of + * response headers and triggers additional processing, so be sure to pass an + * empty string in the end. + * + * @param string $headerLine Line from HTTP response + */ + public function parseHeaderLine($headerLine) + { + $headerLine = trim($headerLine, "\r\n"); + + if ('' == $headerLine) { + // empty string signals the end of headers, process the received ones + if (!empty($this->headers['set-cookie'])) { + $cookies = is_array($this->headers['set-cookie'])? + $this->headers['set-cookie']: + array($this->headers['set-cookie']); + foreach ($cookies as $cookieString) { + $this->parseCookie($cookieString); + } + unset($this->headers['set-cookie']); + } + foreach (array_keys($this->headers) as $k) { + if (is_array($this->headers[$k])) { + $this->headers[$k] = implode(', ', $this->headers[$k]); + } + } + + } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { + // string of the form header-name: header value + $name = strtolower($m[1]); + $value = trim($m[2]); + if (empty($this->headers[$name])) { + $this->headers[$name] = $value; + } else { + if (!is_array($this->headers[$name])) { + $this->headers[$name] = array($this->headers[$name]); + } + $this->headers[$name][] = $value; + } + $this->lastHeader = $name; + + } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { + // continuation of a previous header + if (!is_array($this->headers[$this->lastHeader])) { + $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); + } else { + $key = count($this->headers[$this->lastHeader]) - 1; + $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); + } + } + } + + /** + * Parses a Set-Cookie header to fill $cookies array + * + * @param string $cookieString value of Set-Cookie header + * + * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html + */ + protected function parseCookie($cookieString) + { + $cookie = array( + 'expires' => null, + 'domain' => null, + 'path' => null, + 'secure' => false + ); + + if (!strpos($cookieString, ';')) { + // Only a name=value pair + $pos = strpos($cookieString, '='); + $cookie['name'] = trim(substr($cookieString, 0, $pos)); + $cookie['value'] = trim(substr($cookieString, $pos + 1)); + + } else { + // Some optional parameters are supplied + $elements = explode(';', $cookieString); + $pos = strpos($elements[0], '='); + $cookie['name'] = trim(substr($elements[0], 0, $pos)); + $cookie['value'] = trim(substr($elements[0], $pos + 1)); + + for ($i = 1; $i < count($elements); $i++) { + if (false === strpos($elements[$i], '=')) { + $elName = trim($elements[$i]); + $elValue = null; + } else { + list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); + } + $elName = strtolower($elName); + if ('secure' == $elName) { + $cookie['secure'] = true; + } elseif ('expires' == $elName) { + $cookie['expires'] = str_replace('"', '', $elValue); + } elseif ('path' == $elName || 'domain' == $elName) { + $cookie[$elName] = urldecode($elValue); + } else { + $cookie[$elName] = $elValue; + } + } + } + $this->cookies[] = $cookie; + } + + /** + * Appends a string to the response body + * + * @param string $bodyChunk part of response body + */ + public function appendBody($bodyChunk) + { + $this->body .= $bodyChunk; + } + + /** + * Returns the effective URL of the response + * + * This may be different from the request URL if redirects were followed. + * + * @return string + * @link http://pear.php.net/bugs/bug.php?id=18412 + */ + public function getEffectiveUrl() + { + return $this->effectiveUrl; + } + + /** + * Returns the status code + * + * @return integer + */ + public function getStatus() + { + return $this->code; + } + + /** + * Returns the reason phrase + * + * @return string + */ + public function getReasonPhrase() + { + return $this->reasonPhrase; + } + + /** + * Whether response is a redirect that can be automatically handled by HTTP_Request2 + * + * @return bool + */ + public function isRedirect() + { + return in_array($this->code, array(300, 301, 302, 303, 307)) + && isset($this->headers['location']); + } + + /** + * Returns either the named header or all response headers + * + * @param string $headerName Name of header to return + * + * @return string|array Value of $headerName header (null if header is + * not present), array of all response headers if + * $headerName is null + */ + public function getHeader($headerName = null) + { + if (null === $headerName) { + return $this->headers; + } else { + $headerName = strtolower($headerName); + return isset($this->headers[$headerName])? $this->headers[$headerName]: null; + } + } + + /** + * Returns cookies set in response + * + * @return array + */ + public function getCookies() + { + return $this->cookies; + } + + /** + * Returns the body of the response + * + * @return string + * @throws HTTP_Request2_Exception if body cannot be decoded + */ + public function getBody() + { + if (0 == strlen($this->body) || !$this->bodyEncoded + || !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) + ) { + return $this->body; + + } else { + if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { + $oldEncoding = mb_internal_encoding(); + mb_internal_encoding('8bit'); + } + + try { + switch (strtolower($this->getHeader('content-encoding'))) { + case 'gzip': + $decoded = self::decodeGzip($this->body); + break; + case 'deflate': + $decoded = self::decodeDeflate($this->body); + } + } catch (Exception $e) { + } + + if (!empty($oldEncoding)) { + mb_internal_encoding($oldEncoding); + } + if (!empty($e)) { + throw $e; + } + return $decoded; + } + } + + /** + * Get the HTTP version of the response + * + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Decodes the message-body encoded by gzip + * + * The real decoding work is done by gzinflate() built-in function, this + * method only parses the header and checks data for compliance with + * RFC 1952 + * + * @param string $data gzip-encoded data + * + * @return string decoded data + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_MessageException + * @link http://tools.ietf.org/html/rfc1952 + */ + public static function decodeGzip($data) + { + $length = strlen($data); + // If it doesn't look like gzip-encoded data, don't bother + if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { + return $data; + } + if (!function_exists('gzinflate')) { + throw new HTTP_Request2_LogicException( + 'Unable to decode body: gzip extension not available', + HTTP_Request2_Exception::MISCONFIGURATION + ); + } + $method = ord(substr($data, 2, 1)); + if (8 != $method) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: unknown compression method', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $flags = ord(substr($data, 3, 1)); + if ($flags & 224) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: reserved bits are set', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + + // header is 10 bytes minimum. may be longer, though. + $headerLength = 10; + // extra fields, need to skip 'em + if ($flags & 4) { + if ($length - $headerLength - 2 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $extraLength = unpack('v', substr($data, 10, 2)); + if ($length - $headerLength - 2 - $extraLength[1] < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $headerLength += $extraLength[1] + 2; + } + // file name, need to skip that + if ($flags & 8) { + if ($length - $headerLength - 1 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $filenameLength = strpos(substr($data, $headerLength), chr(0)); + if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $headerLength += $filenameLength + 1; + } + // comment, need to skip that also + if ($flags & 16) { + if ($length - $headerLength - 1 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $commentLength = strpos(substr($data, $headerLength), chr(0)); + if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $headerLength += $commentLength + 1; + } + // have a CRC for header. let's check + if ($flags & 2) { + if ($length - $headerLength - 2 < 8) { + throw new HTTP_Request2_MessageException( + 'Error parsing gzip header: data too short', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); + $crcStored = unpack('v', substr($data, $headerLength, 2)); + if ($crcReal != $crcStored[1]) { + throw new HTTP_Request2_MessageException( + 'Header CRC check failed', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + $headerLength += 2; + } + // unpacked data CRC and size at the end of encoded data + $tmp = unpack('V2', substr($data, -8)); + $dataCrc = $tmp[1]; + $dataSize = $tmp[2]; + + // finally, call the gzinflate() function + // don't pass $dataSize to gzinflate, see bugs #13135, #14370 + $unpacked = gzinflate(substr($data, $headerLength, -8)); + if (false === $unpacked) { + throw new HTTP_Request2_MessageException( + 'gzinflate() call failed', + HTTP_Request2_Exception::DECODE_ERROR + ); + } elseif ($dataSize != strlen($unpacked)) { + throw new HTTP_Request2_MessageException( + 'Data size check failed', + HTTP_Request2_Exception::DECODE_ERROR + ); + } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { + throw new HTTP_Request2_Exception( + 'Data CRC check failed', + HTTP_Request2_Exception::DECODE_ERROR + ); + } + return $unpacked; + } + + /** + * Decodes the message-body encoded by deflate + * + * @param string $data deflate-encoded data + * + * @return string decoded data + * @throws HTTP_Request2_LogicException + */ + public static function decodeDeflate($data) + { + if (!function_exists('gzuncompress')) { + throw new HTTP_Request2_LogicException( + 'Unable to decode body: gzip extension not available', + HTTP_Request2_Exception::MISCONFIGURATION + ); + } + // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, + // while many applications send raw deflate stream from RFC 1951. + // We should check for presence of zlib header and use gzuncompress() or + // gzinflate() as needed. See bug #15305 + $header = unpack('n', substr($data, 0, 2)); + return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php b/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php new file mode 100644 index 000000000..a801c17e8 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php @@ -0,0 +1,135 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Socket wrapper class used by Socket Adapter */ +require_once 'HTTP/Request2/SocketWrapper.php'; + +/** + * SOCKS5 proxy connection class (used by Socket Adapter) + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://pear.php.net/bugs/bug.php?id=19332 + * @link http://tools.ietf.org/html/rfc1928 + */ +class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper +{ + /** + * Constructor, tries to connect and authenticate to a SOCKS5 proxy + * + * @param string $address Proxy address, e.g. 'tcp://localhost:1080' + * @param int $timeout Connection timeout (seconds) + * @param array $contextOptions Stream context options + * @param string $username Proxy user name + * @param string $password Proxy password + * + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_ConnectionException + * @throws HTTP_Request2_MessageException + */ + public function __construct( + $address, $timeout = 10, array $contextOptions = array(), + $username = null, $password = null + ) { + parent::__construct($address, $timeout, $contextOptions); + + if (strlen($username)) { + $request = pack('C4', 5, 2, 0, 2); + } else { + $request = pack('C3', 5, 1, 0); + } + $this->write($request); + $response = unpack('Cversion/Cmethod', $this->read(3)); + if (5 != $response['version']) { + throw new HTTP_Request2_MessageException( + 'Invalid version received from SOCKS5 proxy: ' . $response['version'], + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } + switch ($response['method']) { + case 2: + $this->performAuthentication($username, $password); + case 0: + break; + default: + throw new HTTP_Request2_ConnectionException( + "Connection rejected by proxy due to unsupported auth method" + ); + } + } + + /** + * Performs username/password authentication for SOCKS5 + * + * @param string $username Proxy user name + * @param string $password Proxy password + * + * @throws HTTP_Request2_ConnectionException + * @throws HTTP_Request2_MessageException + * @link http://tools.ietf.org/html/rfc1929 + */ + protected function performAuthentication($username, $password) + { + $request = pack('C2', 1, strlen($username)) . $username + . pack('C', strlen($password)) . $password; + + $this->write($request); + $response = unpack('Cvn/Cstatus', $this->read(3)); + if (1 != $response['vn'] || 0 != $response['status']) { + throw new HTTP_Request2_ConnectionException( + 'Connection rejected by proxy due to invalid username and/or password' + ); + } + } + + /** + * Connects to a remote host via proxy + * + * @param string $remoteHost Remote host + * @param int $remotePort Remote port + * + * @throws HTTP_Request2_ConnectionException + * @throws HTTP_Request2_MessageException + */ + public function connect($remoteHost, $remotePort) + { + $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) + . $remoteHost . pack('n', $remotePort); + + $this->write($request); + $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); + if (5 != $response['version'] || 0 != $response['reserved']) { + throw new HTTP_Request2_MessageException( + 'Invalid response received from SOCKS5 proxy', + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } elseif (0 != $response['reply']) { + throw new HTTP_Request2_ConnectionException( + "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", + 0, $response['reply'] + ); + } + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php b/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php new file mode 100644 index 000000000..41497ba96 --- /dev/null +++ b/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php @@ -0,0 +1,297 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Exception classes for HTTP_Request2 package */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Socket wrapper class used by Socket Adapter + * + * Needed to properly handle connection errors, global timeout support and + * similar things. Loosely based on Net_Socket used by older HTTP_Request. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://pear.php.net/bugs/bug.php?id=19332 + * @link http://tools.ietf.org/html/rfc1928 + */ +class HTTP_Request2_SocketWrapper +{ + /** + * PHP warning messages raised during stream_socket_client() call + * @var array + */ + protected $connectionWarnings = array(); + + /** + * Connected socket + * @var resource + */ + protected $socket; + + /** + * Sum of start time and global timeout, exception will be thrown if request continues past this time + * @var integer + */ + protected $deadline; + + /** + * Global timeout value, mostly for exception messages + * @var integer + */ + protected $timeout; + + /** + * Class constructor, tries to establish connection + * + * @param string $address Address for stream_socket_client() call, + * e.g. 'tcp://localhost:80' + * @param int $timeout Connection timeout (seconds) + * @param array $contextOptions Context options + * + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_ConnectionException + */ + public function __construct($address, $timeout, array $contextOptions = array()) + { + if (!empty($contextOptions) + && !isset($contextOptions['socket']) && !isset($contextOptions['ssl']) + ) { + // Backwards compatibility with 2.1.0 and 2.1.1 releases + $contextOptions = array('ssl' => $contextOptions); + } + $context = stream_context_create(); + foreach ($contextOptions as $wrapper => $options) { + foreach ($options as $name => $value) { + if (!stream_context_set_option($context, $wrapper, $name, $value)) { + throw new HTTP_Request2_LogicException( + "Error setting '{$wrapper}' wrapper context option '{$name}'" + ); + } + } + } + set_error_handler(array($this, 'connectionWarningsHandler')); + $this->socket = stream_socket_client( + $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context + ); + restore_error_handler(); + // if we fail to bind to a specified local address (see request #19515), + // connection still succeeds, albeit with a warning. Throw an Exception + // with the warning text in this case as that connection is unlikely + // to be what user wants and as Curl throws an error in similar case. + if ($this->connectionWarnings) { + if ($this->socket) { + fclose($this->socket); + } + $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings); + throw new HTTP_Request2_ConnectionException( + "Unable to connect to {$address}. Error: {$error}", 0, $errno + ); + } + } + + /** + * Destructor, disconnects socket + */ + public function __destruct() + { + fclose($this->socket); + } + + /** + * Wrapper around fread(), handles global request timeout + * + * @param int $length Reads up to this number of bytes + * + * @return string Data read from socket + * @throws HTTP_Request2_MessageException In case of timeout + */ + public function read($length) + { + if ($this->deadline) { + stream_set_timeout($this->socket, max($this->deadline - time(), 1)); + } + $data = fread($this->socket, $length); + $this->checkTimeout(); + return $data; + } + + /** + * Reads until either the end of the socket or a newline, whichever comes first + * + * Strips the trailing newline from the returned data, handles global + * request timeout. Method idea borrowed from Net_Socket PEAR package. + * + * @param int $bufferSize buffer size to use for reading + * @param int $localTimeout timeout value to use just for this call + * (used when waiting for "100 Continue" response) + * + * @return string Available data up to the newline (not including newline) + * @throws HTTP_Request2_MessageException In case of timeout + */ + public function readLine($bufferSize, $localTimeout = null) + { + $line = ''; + while (!feof($this->socket)) { + if (null !== $localTimeout) { + stream_set_timeout($this->socket, $localTimeout); + } elseif ($this->deadline) { + stream_set_timeout($this->socket, max($this->deadline - time(), 1)); + } + + $line .= @fgets($this->socket, $bufferSize); + + if (null === $localTimeout) { + $this->checkTimeout(); + + } else { + $info = stream_get_meta_data($this->socket); + // reset socket timeout if we don't have request timeout specified, + // prevents further calls failing with a bogus Exception + if (!$this->deadline) { + $default = (int)@ini_get('default_socket_timeout'); + stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX); + } + if ($info['timed_out']) { + throw new HTTP_Request2_MessageException( + "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT + ); + } + } + if (substr($line, -1) == "\n") { + return rtrim($line, "\r\n"); + } + } + return $line; + } + + /** + * Wrapper around fwrite(), handles global request timeout + * + * @param string $data String to be written + * + * @return int + * @throws HTTP_Request2_MessageException + */ + public function write($data) + { + if ($this->deadline) { + stream_set_timeout($this->socket, max($this->deadline - time(), 1)); + } + $written = fwrite($this->socket, $data); + $this->checkTimeout(); + // http://www.php.net/manual/en/function.fwrite.php#96951 + if ($written < strlen($data)) { + throw new HTTP_Request2_MessageException('Error writing request'); + } + return $written; + } + + /** + * Tests for end-of-file on a socket + * + * @return bool + */ + public function eof() + { + return feof($this->socket); + } + + /** + * Sets request deadline + * + * @param int $deadline Exception will be thrown if request continues + * past this time + * @param int $timeout Original request timeout value, to use in + * Exception message + */ + public function setDeadline($deadline, $timeout) + { + $this->deadline = $deadline; + $this->timeout = $timeout; + } + + /** + * Turns on encryption on a socket + * + * @throws HTTP_Request2_ConnectionException + */ + public function enableCrypto() + { + $modes = array( + STREAM_CRYPTO_METHOD_TLS_CLIENT, + STREAM_CRYPTO_METHOD_SSLv3_CLIENT, + STREAM_CRYPTO_METHOD_SSLv23_CLIENT, + STREAM_CRYPTO_METHOD_SSLv2_CLIENT + ); + + foreach ($modes as $mode) { + if (stream_socket_enable_crypto($this->socket, true, $mode)) { + return; + } + } + throw new HTTP_Request2_ConnectionException( + 'Failed to enable secure connection when connecting through proxy' + ); + } + + /** + * Throws an Exception if stream timed out + * + * @throws HTTP_Request2_MessageException + */ + protected function checkTimeout() + { + $info = stream_get_meta_data($this->socket); + if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { + $reason = $this->deadline + ? "after {$this->timeout} second(s)" + : 'due to default_socket_timeout php.ini setting'; + throw new HTTP_Request2_MessageException( + "Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT + ); + } + } + + /** + * Error handler to use during stream_socket_client() call + * + * One stream_socket_client() call may produce *multiple* PHP warnings + * (especially OpenSSL-related), we keep them in an array to later use for + * the message of HTTP_Request2_ConnectionException + * + * @param int $errno error level + * @param string $errstr error message + * + * @return bool + */ + protected function connectionWarningsHandler($errno, $errstr) + { + if ($errno & E_WARNING) { + array_unshift($this->connectionWarnings, $errstr); + } + return true; + } +} +?> diff --git a/vendor/pear/http_request2/README.md b/vendor/pear/http_request2/README.md new file mode 100644 index 000000000..eef00606b --- /dev/null +++ b/vendor/pear/http_request2/README.md @@ -0,0 +1,80 @@ + +# HTTP_Request2 + +Provides an easy way to perform HTTP requests, uses pluggable adapters + +* Socket: pure PHP implementation of HTTP protocol (does *not* use http stream wrapper), based on older [PEAR HTTP_Request] package +* Curl: wrapper around PHP's cURL extension +* Mock: used for testing packages depending on HTTP_Request2, returns predefined responses without network interaction + +Both Socket and Curl adapters support POST requests with data and file uploads, basic and digest +authentication, cookies, managing cookies across requests, HTTP and SOCKS5 proxies, gzip and +deflate encodings, redirects, monitoring the request progress with Observers... + +This package is [PEAR HTTP_Request2] and has been migrated from [PEAR SVN] + +Please report all issues via the [PEAR bug tracker]. + +Pull requests are welcome. + +[PEAR HTTP_Request]: http://pear.php.net/package/HTTP_Request/ +[PEAR HTTP_Request2]: http://pear.php.net/package/HTTP_Request2/ +[PEAR SVN]: https://svn.php.net/repository/pear/packages/HTTP_Request2 +[PEAR bug tracker]: http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2 + +## Basic usage + +```PHP +require_once 'HTTP/Request2.php'; + +$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET); +try { + $response = $request->send(); + if (200 == $response->getStatus()) { + echo $response->getBody(); + } else { + echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . + $response->getReasonPhrase(); + } +} catch (HTTP_Request2_Exception $e) { + echo 'Error: ' . $e->getMessage(); +} +``` + +## Documentation + +...is available on PEAR website + + * Numerous [configuration options](http://pear.php.net/manual/en/package.http.http-request2.config.php) + * How to populate [the request object](http://pear.php.net/manual/en/package.http.http-request2.request.php) + * Description of [available adapters](http://pear.php.net/manual/en/package.http.http-request2.adapters.php) + * Processing of [HTTP response](http://pear.php.net/manual/en/package.http.http-request2.response.php) + * Monitoring the progress of request with [observers](http://pear.php.net/manual/en/package.http.http-request2.observers.php) + * Possible [exceptions](http://pear.php.net/manual/en/package.http.http-request2.exceptions.php) + +[Generated API documentation](http://pear.php.net/package/HTTP_Request2/docs/latest/) for the current release is also there. + +## Testing, Packaging and Installing (Pear) + +To test, run either + + $ phpunit tests/ + +or + + $ pear run-tests -r + +You may need to set up the NetworkConfig.php file if you want to perform tests that interact with a web server. +Its template is NetworkConfig.php.dist file, consult it for the details. + +To build, simply + + $ pear package + +To install from scratch + + $ pear install package.xml + +To upgrade + + $ pear upgrade -f package.xml diff --git a/vendor/pear/http_request2/composer.json b/vendor/pear/http_request2/composer.json new file mode 100644 index 000000000..92c6ca0fc --- /dev/null +++ b/vendor/pear/http_request2/composer.json @@ -0,0 +1,34 @@ +{ + "name" : "pear/http_request2", + "description" : "Provides an easy way to perform HTTP requests.", + "type" : "library", + "keywords" : [ "http", "request", "pear", "curl" ], + "homepage" : "http://pear.php.net/package/HTTP_Request2", + "license" : "BSD-3-Clause", + "authors" : [ + { + "name" : "Alexey Borzov", + "email" : "avb@php.net" + } + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2", + "source": "https://github.com/pear/HTTP_Request2" + }, + "require" : { + "php" : ">=5.2.0", + "pear/net_url2" : ">=2.0.0", + "pear/pear_exception" : "*" + }, + "suggest" : { + "ext-fileinfo" : "Adds support for looking up mime-types using finfo.", + "ext-zlib" : "Allows handling gzip compressed responses.", + "lib-curl" : "Allows using cURL as a request backend.", + "lib-openssl" : "Allows handling SSL requests when not using cURL." + }, + "autoload": { + "psr-0": { + "HTTP_Request2" : "" + } + } +} diff --git a/vendor/pear/http_request2/data/generate-list.php b/vendor/pear/http_request2/data/generate-list.php new file mode 100644 index 000000000..895247f4e --- /dev/null +++ b/vendor/pear/http_request2/data/generate-list.php @@ -0,0 +1,96 @@ + "); + } + + if (0 == ($count = count($valueTree))) { + fwrite($fp, 'true'); + } else { + fwrite($fp, "array(\n"); + for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { + writeNode($fp, $valueTree[$keys[$i]], $keys[$i], $indent + 1); + if ($i + 1 != $count) { + fwrite($fp, ",\n"); + } else { + fwrite($fp, "\n"); + } + } + fwrite($fp, str_repeat(' ', $indent) . ")"); + } +} + + +try { + $request = new HTTP_Request2(LIST_URL); + $response = $request->send(); + if (200 != $response->getStatus()) { + throw new Exception("List download URL returned status: " . + $response->getStatus() . ' ' . $response->getReasonPhrase()); + } + $list = $response->getBody(); + if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { + throw new Exception("List download URL does not contain expected phrase"); + } + if (!($fp = @fopen(OUTPUT_FILE, 'wt'))) { + throw new Exception("Unable to open " . OUTPUT_FILE); + } + +} catch (Exception $e) { + die($e->getMessage()); +} + +$tldTree = array(); +$license = true; + +fwrite($fp, ""); +fclose($fp); +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/data/public-suffix-list.php b/vendor/pear/http_request2/data/public-suffix-list.php new file mode 100644 index 000000000..af9273301 --- /dev/null +++ b/vendor/pear/http_request2/data/public-suffix-list.php @@ -0,0 +1,6701 @@ + array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'mil' => true, + 'org' => true + ), + 'ad' => array( + 'nom' => true + ), + 'ae' => array( + 'co' => true, + 'net' => true, + 'org' => true, + 'sch' => true, + 'ac' => true, + 'gov' => true, + 'mil' => true + ), + 'aero' => array( + 'accident-investigation' => true, + 'accident-prevention' => true, + 'aerobatic' => true, + 'aeroclub' => true, + 'aerodrome' => true, + 'agents' => true, + 'aircraft' => true, + 'airline' => true, + 'airport' => true, + 'air-surveillance' => true, + 'airtraffic' => true, + 'air-traffic-control' => true, + 'ambulance' => true, + 'amusement' => true, + 'association' => true, + 'author' => true, + 'ballooning' => true, + 'broker' => true, + 'caa' => true, + 'cargo' => true, + 'catering' => true, + 'certification' => true, + 'championship' => true, + 'charter' => true, + 'civilaviation' => true, + 'club' => true, + 'conference' => true, + 'consultant' => true, + 'consulting' => true, + 'control' => true, + 'council' => true, + 'crew' => true, + 'design' => true, + 'dgca' => true, + 'educator' => true, + 'emergency' => true, + 'engine' => true, + 'engineer' => true, + 'entertainment' => true, + 'equipment' => true, + 'exchange' => true, + 'express' => true, + 'federation' => true, + 'flight' => true, + 'freight' => true, + 'fuel' => true, + 'gliding' => true, + 'government' => true, + 'groundhandling' => true, + 'group' => true, + 'hanggliding' => true, + 'homebuilt' => true, + 'insurance' => true, + 'journal' => true, + 'journalist' => true, + 'leasing' => true, + 'logistics' => true, + 'magazine' => true, + 'maintenance' => true, + 'marketplace' => true, + 'media' => true, + 'microlight' => true, + 'modelling' => true, + 'navigation' => true, + 'parachuting' => true, + 'paragliding' => true, + 'passenger-association' => true, + 'pilot' => true, + 'press' => true, + 'production' => true, + 'recreation' => true, + 'repbody' => true, + 'res' => true, + 'research' => true, + 'rotorcraft' => true, + 'safety' => true, + 'scientist' => true, + 'services' => true, + 'show' => true, + 'skydiving' => true, + 'software' => true, + 'student' => true, + 'taxi' => true, + 'trader' => true, + 'trading' => true, + 'trainer' => true, + 'union' => true, + 'workinggroup' => true, + 'works' => true + ), + 'af' => array( + 'gov' => true, + 'com' => true, + 'org' => true, + 'net' => true, + 'edu' => true + ), + 'ag' => array( + 'com' => true, + 'org' => true, + 'net' => true, + 'co' => true, + 'nom' => true + ), + 'ai' => array( + 'off' => true, + 'com' => true, + 'net' => true, + 'org' => true + ), + 'al' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'net' => true, + 'org' => true + ), + 'am' => true, + 'an' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true + ), + 'ao' => array( + 'ed' => true, + 'gv' => true, + 'og' => true, + 'co' => true, + 'pb' => true, + 'it' => true + ), + 'aq' => true, + 'ar' => array( + 'com' => array( + 'blogspot' => true + ), + 'edu' => true, + 'gob' => true, + 'int' => true, + 'mil' => true, + 'net' => true, + 'org' => true, + 'tur' => true + ), + 'arpa' => array( + 'e164' => true, + 'in-addr' => true, + 'ip6' => true, + 'iris' => true, + 'uri' => true, + 'urn' => true + ), + 'as' => array( + 'gov' => true + ), + 'asia' => true, + 'at' => array( + 'ac' => true, + 'co' => array( + 'blogspot' => true + ), + 'gv' => true, + 'or' => true, + 'biz' => true, + 'info' => true, + 'priv' => true + ), + 'au' => array( + 'com' => array( + 'blogspot' => true + ), + 'net' => true, + 'org' => true, + 'edu' => array( + 'act' => true, + 'nsw' => true, + 'nt' => true, + 'qld' => true, + 'sa' => true, + 'tas' => true, + 'vic' => true, + 'wa' => true + ), + 'gov' => array( + 'act' => true, + 'qld' => true, + 'sa' => true, + 'tas' => true, + 'vic' => true, + 'wa' => true + ), + 'asn' => true, + 'id' => true, + 'csiro' => true, + 'info' => true, + 'conf' => true, + 'oz' => true, + 'act' => true, + 'nsw' => true, + 'nt' => true, + 'qld' => true, + 'sa' => true, + 'tas' => true, + 'vic' => true, + 'wa' => true + ), + 'aw' => array( + 'com' => true + ), + 'ax' => true, + 'az' => array( + 'com' => true, + 'net' => true, + 'int' => true, + 'gov' => true, + 'org' => true, + 'edu' => true, + 'info' => true, + 'pp' => true, + 'mil' => true, + 'name' => true, + 'pro' => true, + 'biz' => true + ), + 'ba' => array( + 'org' => true, + 'net' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'unsa' => true, + 'unbi' => true, + 'co' => true, + 'com' => true, + 'rs' => true + ), + 'bb' => array( + 'biz' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'info' => true, + 'net' => true, + 'org' => true, + 'store' => true + ), + 'bd' => array( + '*' => true + ), + 'be' => array( + 'ac' => true, + 'blogspot' => true + ), + 'bf' => array( + 'gov' => true + ), + 'bg' => array( + 'a' => true, + 'b' => true, + 'c' => true, + 'd' => true, + 'e' => true, + 'f' => true, + 'g' => true, + 'h' => true, + 'i' => true, + 'j' => true, + 'k' => true, + 'l' => true, + 'm' => true, + 'n' => true, + 'o' => true, + 'p' => true, + 'q' => true, + 'r' => true, + 's' => true, + 't' => true, + 'u' => true, + 'v' => true, + 'w' => true, + 'x' => true, + 'y' => true, + 'z' => true, + '0' => true, + '1' => true, + '2' => true, + '3' => true, + '4' => true, + '5' => true, + '6' => true, + '7' => true, + '8' => true, + '9' => true + ), + 'bh' => array( + 'com' => true, + 'edu' => true, + 'net' => true, + 'org' => true, + 'gov' => true + ), + 'bi' => array( + 'co' => true, + 'com' => true, + 'edu' => true, + 'or' => true, + 'org' => true + ), + 'biz' => array( + 'dyndns' => true, + 'for-better' => true, + 'for-more' => true, + 'for-some' => true, + 'for-the' => true, + 'selfip' => true, + 'webhop' => true + ), + 'bj' => array( + 'asso' => true, + 'barreau' => true, + 'gouv' => true, + 'blogspot' => true + ), + 'bm' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'org' => true + ), + 'bn' => array( + '*' => true + ), + 'bo' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'gob' => true, + 'int' => true, + 'org' => true, + 'net' => true, + 'mil' => true, + 'tv' => true + ), + 'br' => array( + 'adm' => true, + 'adv' => true, + 'agr' => true, + 'am' => true, + 'arq' => true, + 'art' => true, + 'ato' => true, + 'b' => true, + 'bio' => true, + 'blog' => true, + 'bmd' => true, + 'cim' => true, + 'cng' => true, + 'cnt' => true, + 'com' => array( + 'blogspot' => true + ), + 'coop' => true, + 'ecn' => true, + 'eco' => true, + 'edu' => true, + 'emp' => true, + 'eng' => true, + 'esp' => true, + 'etc' => true, + 'eti' => true, + 'far' => true, + 'flog' => true, + 'fm' => true, + 'fnd' => true, + 'fot' => true, + 'fst' => true, + 'g12' => true, + 'ggf' => true, + 'gov' => true, + 'imb' => true, + 'ind' => true, + 'inf' => true, + 'jor' => true, + 'jus' => true, + 'leg' => true, + 'lel' => true, + 'mat' => true, + 'med' => true, + 'mil' => true, + 'mus' => true, + 'net' => true, + 'nom' => true, + 'not' => true, + 'ntr' => true, + 'odo' => true, + 'org' => true, + 'ppg' => true, + 'pro' => true, + 'psc' => true, + 'psi' => true, + 'qsl' => true, + 'radio' => true, + 'rec' => true, + 'slg' => true, + 'srv' => true, + 'taxi' => true, + 'teo' => true, + 'tmp' => true, + 'trd' => true, + 'tur' => true, + 'tv' => true, + 'vet' => true, + 'vlog' => true, + 'wiki' => true, + 'zlg' => true + ), + 'bs' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'bt' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'org' => true + ), + 'bv' => true, + 'bw' => array( + 'co' => true, + 'org' => true + ), + 'by' => array( + 'gov' => true, + 'mil' => true, + 'com' => true, + 'of' => true + ), + 'bz' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'ca' => array( + 'ab' => true, + 'bc' => true, + 'mb' => true, + 'nb' => true, + 'nf' => true, + 'nl' => true, + 'ns' => true, + 'nt' => true, + 'nu' => true, + 'on' => true, + 'pe' => true, + 'qc' => true, + 'sk' => true, + 'yk' => true, + 'gc' => true, + 'co' => true, + 'blogspot' => true + ), + 'cat' => true, + 'cc' => array( + 'ftpaccess' => true, + 'game-server' => true, + 'myphotos' => true, + 'scrapping' => true + ), + 'cd' => array( + 'gov' => true + ), + 'cf' => array( + 'blogspot' => true + ), + 'cg' => true, + 'ch' => array( + 'blogspot' => true + ), + 'ci' => array( + 'org' => true, + 'or' => true, + 'com' => true, + 'co' => true, + 'edu' => true, + 'ed' => true, + 'ac' => true, + 'net' => true, + 'go' => true, + 'asso' => true, + 'aéroport' => true, + 'int' => true, + 'presse' => true, + 'md' => true, + 'gouv' => true + ), + 'ck' => array( + '*' => true, + '!www' => true + ), + 'cl' => array( + 'gov' => true, + 'gob' => true, + 'co' => true, + 'mil' => true + ), + 'cm' => array( + 'gov' => true + ), + 'cn' => array( + 'ac' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'org' => true, + 'mil' => true, + '公司' => true, + '网络' => true, + '網絡' => true, + 'ah' => true, + 'bj' => true, + 'cq' => true, + 'fj' => true, + 'gd' => true, + 'gs' => true, + 'gz' => true, + 'gx' => true, + 'ha' => true, + 'hb' => true, + 'he' => true, + 'hi' => true, + 'hl' => true, + 'hn' => true, + 'jl' => true, + 'js' => true, + 'jx' => true, + 'ln' => true, + 'nm' => true, + 'nx' => true, + 'qh' => true, + 'sc' => true, + 'sd' => true, + 'sh' => true, + 'sn' => true, + 'sx' => true, + 'tj' => true, + 'xj' => true, + 'xz' => true, + 'yn' => true, + 'zj' => true, + 'hk' => true, + 'mo' => true, + 'tw' => true + ), + 'co' => array( + 'arts' => true, + 'com' => true, + 'edu' => true, + 'firm' => true, + 'gov' => true, + 'info' => true, + 'int' => true, + 'mil' => true, + 'net' => true, + 'nom' => true, + 'org' => true, + 'rec' => true, + 'web' => true + ), + 'com' => array( + 'amazonaws' => array( + 'compute' => array( + 'ap-northeast-1' => true, + 'ap-southeast-1' => true, + 'ap-southeast-2' => true, + 'eu-west-1' => true, + 'sa-east-1' => true, + 'us-gov-west-1' => true, + 'us-west-1' => true, + 'us-west-2' => true + ), + 'us-east-1' => true, + 'compute-1' => array( + 'z-1' => true, + 'z-2' => true + ), + 'elb' => true, + 's3' => true, + 's3-us-west-2' => true, + 's3-us-west-1' => true, + 's3-eu-west-1' => true, + 's3-ap-southeast-1' => true, + 's3-ap-southeast-2' => true, + 's3-ap-northeast-1' => true, + 's3-sa-east-1' => true, + 's3-us-gov-west-1' => true, + 's3-fips-us-gov-west-1' => true, + 's3-website-us-east-1' => true, + 's3-website-us-west-2' => true, + 's3-website-us-west-1' => true, + 's3-website-eu-west-1' => true, + 's3-website-ap-southeast-1' => true, + 's3-website-ap-southeast-2' => true, + 's3-website-ap-northeast-1' => true, + 's3-website-sa-east-1' => true, + 's3-website-us-gov-west-1' => true + ), + 'elasticbeanstalk' => true, + 'betainabox' => true, + 'ar' => true, + 'br' => true, + 'cn' => true, + 'de' => true, + 'eu' => true, + 'gb' => true, + 'gr' => true, + 'hu' => true, + 'jpn' => true, + 'kr' => true, + 'no' => true, + 'qc' => true, + 'ru' => true, + 'sa' => true, + 'se' => true, + 'uk' => true, + 'us' => true, + 'uy' => true, + 'za' => true, + 'cloudcontrolled' => true, + 'cloudcontrolapp' => true, + 'dreamhosters' => true, + 'dyndns-at-home' => true, + 'dyndns-at-work' => true, + 'dyndns-blog' => true, + 'dyndns-free' => true, + 'dyndns-home' => true, + 'dyndns-ip' => true, + 'dyndns-mail' => true, + 'dyndns-office' => true, + 'dyndns-pics' => true, + 'dyndns-remote' => true, + 'dyndns-server' => true, + 'dyndns-web' => true, + 'dyndns-wiki' => true, + 'dyndns-work' => true, + 'blogdns' => true, + 'cechire' => true, + 'dnsalias' => true, + 'dnsdojo' => true, + 'doesntexist' => true, + 'dontexist' => true, + 'doomdns' => true, + 'dyn-o-saur' => true, + 'dynalias' => true, + 'est-a-la-maison' => true, + 'est-a-la-masion' => true, + 'est-le-patron' => true, + 'est-mon-blogueur' => true, + 'from-ak' => true, + 'from-al' => true, + 'from-ar' => true, + 'from-ca' => true, + 'from-ct' => true, + 'from-dc' => true, + 'from-de' => true, + 'from-fl' => true, + 'from-ga' => true, + 'from-hi' => true, + 'from-ia' => true, + 'from-id' => true, + 'from-il' => true, + 'from-in' => true, + 'from-ks' => true, + 'from-ky' => true, + 'from-ma' => true, + 'from-md' => true, + 'from-mi' => true, + 'from-mn' => true, + 'from-mo' => true, + 'from-ms' => true, + 'from-mt' => true, + 'from-nc' => true, + 'from-nd' => true, + 'from-ne' => true, + 'from-nh' => true, + 'from-nj' => true, + 'from-nm' => true, + 'from-nv' => true, + 'from-oh' => true, + 'from-ok' => true, + 'from-or' => true, + 'from-pa' => true, + 'from-pr' => true, + 'from-ri' => true, + 'from-sc' => true, + 'from-sd' => true, + 'from-tn' => true, + 'from-tx' => true, + 'from-ut' => true, + 'from-va' => true, + 'from-vt' => true, + 'from-wa' => true, + 'from-wi' => true, + 'from-wv' => true, + 'from-wy' => true, + 'getmyip' => true, + 'gotdns' => true, + 'hobby-site' => true, + 'homelinux' => true, + 'homeunix' => true, + 'iamallama' => true, + 'is-a-anarchist' => true, + 'is-a-blogger' => true, + 'is-a-bookkeeper' => true, + 'is-a-bulls-fan' => true, + 'is-a-caterer' => true, + 'is-a-chef' => true, + 'is-a-conservative' => true, + 'is-a-cpa' => true, + 'is-a-cubicle-slave' => true, + 'is-a-democrat' => true, + 'is-a-designer' => true, + 'is-a-doctor' => true, + 'is-a-financialadvisor' => true, + 'is-a-geek' => true, + 'is-a-green' => true, + 'is-a-guru' => true, + 'is-a-hard-worker' => true, + 'is-a-hunter' => true, + 'is-a-landscaper' => true, + 'is-a-lawyer' => true, + 'is-a-liberal' => true, + 'is-a-libertarian' => true, + 'is-a-llama' => true, + 'is-a-musician' => true, + 'is-a-nascarfan' => true, + 'is-a-nurse' => true, + 'is-a-painter' => true, + 'is-a-personaltrainer' => true, + 'is-a-photographer' => true, + 'is-a-player' => true, + 'is-a-republican' => true, + 'is-a-rockstar' => true, + 'is-a-socialist' => true, + 'is-a-student' => true, + 'is-a-teacher' => true, + 'is-a-techie' => true, + 'is-a-therapist' => true, + 'is-an-accountant' => true, + 'is-an-actor' => true, + 'is-an-actress' => true, + 'is-an-anarchist' => true, + 'is-an-artist' => true, + 'is-an-engineer' => true, + 'is-an-entertainer' => true, + 'is-certified' => true, + 'is-gone' => true, + 'is-into-anime' => true, + 'is-into-cars' => true, + 'is-into-cartoons' => true, + 'is-into-games' => true, + 'is-leet' => true, + 'is-not-certified' => true, + 'is-slick' => true, + 'is-uberleet' => true, + 'is-with-theband' => true, + 'isa-geek' => true, + 'isa-hockeynut' => true, + 'issmarterthanyou' => true, + 'likes-pie' => true, + 'likescandy' => true, + 'neat-url' => true, + 'saves-the-whales' => true, + 'selfip' => true, + 'sells-for-less' => true, + 'sells-for-u' => true, + 'servebbs' => true, + 'simple-url' => true, + 'space-to-rent' => true, + 'teaches-yoga' => true, + 'writesthisblog' => true, + 'ro' => true, + 'appspot' => true, + 'blogspot' => true, + 'codespot' => true, + 'googleapis' => true, + 'googlecode' => true, + 'herokuapp' => true, + 'herokussl' => true, + 'operaunite' => true, + 'rhcloud' => true + ), + 'coop' => true, + 'cr' => array( + 'ac' => true, + 'co' => true, + 'ed' => true, + 'fi' => true, + 'go' => true, + 'or' => true, + 'sa' => true + ), + 'cu' => array( + 'com' => true, + 'edu' => true, + 'org' => true, + 'net' => true, + 'gov' => true, + 'inf' => true + ), + 'cv' => array( + 'blogspot' => true + ), + 'cw' => array( + 'com' => true, + 'edu' => true, + 'net' => true, + 'org' => true + ), + 'cx' => array( + 'gov' => true, + 'ath' => true + ), + 'cy' => array( + '*' => true + ), + 'cz' => array( + 'blogspot' => true + ), + 'de' => array( + 'com' => true, + 'fuettertdasnetz' => true, + 'isteingeek' => true, + 'istmein' => true, + 'lebtimnetz' => true, + 'leitungsen' => true, + 'traeumtgerade' => true, + 'blogspot' => true + ), + 'dj' => true, + 'dk' => array( + 'blogspot' => true + ), + 'dm' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'do' => array( + 'art' => true, + 'com' => true, + 'edu' => true, + 'gob' => true, + 'gov' => true, + 'mil' => true, + 'net' => true, + 'org' => true, + 'sld' => true, + 'web' => true + ), + 'dz' => array( + 'com' => true, + 'org' => true, + 'net' => true, + 'gov' => true, + 'edu' => true, + 'asso' => true, + 'pol' => true, + 'art' => true + ), + 'ec' => array( + 'com' => true, + 'info' => true, + 'net' => true, + 'fin' => true, + 'k12' => true, + 'med' => true, + 'pro' => true, + 'org' => true, + 'edu' => true, + 'gov' => true, + 'gob' => true, + 'mil' => true + ), + 'edu' => true, + 'ee' => array( + 'edu' => true, + 'gov' => true, + 'riik' => true, + 'lib' => true, + 'med' => true, + 'com' => true, + 'pri' => true, + 'aip' => true, + 'org' => true, + 'fie' => true + ), + 'eg' => array( + 'com' => true, + 'edu' => true, + 'eun' => true, + 'gov' => true, + 'mil' => true, + 'name' => true, + 'net' => true, + 'org' => true, + 'sci' => true + ), + 'er' => array( + '*' => true + ), + 'es' => array( + 'com' => array( + 'blogspot' => true + ), + 'nom' => true, + 'org' => true, + 'gob' => true, + 'edu' => true + ), + 'et' => array( + '*' => true + ), + 'eu' => true, + 'fi' => array( + 'aland' => true, + 'blogspot' => true, + 'iki' => true + ), + 'fj' => array( + '*' => true + ), + 'fk' => array( + '*' => true + ), + 'fm' => true, + 'fo' => true, + 'fr' => array( + 'com' => true, + 'asso' => true, + 'nom' => true, + 'prd' => true, + 'presse' => true, + 'tm' => true, + 'aeroport' => true, + 'assedic' => true, + 'avocat' => true, + 'avoues' => true, + 'cci' => true, + 'chambagri' => true, + 'chirurgiens-dentistes' => true, + 'experts-comptables' => true, + 'geometre-expert' => true, + 'gouv' => true, + 'greta' => true, + 'huissier-justice' => true, + 'medecin' => true, + 'notaires' => true, + 'pharmacien' => true, + 'port' => true, + 'veterinaire' => true, + 'blogspot' => true + ), + 'ga' => true, + 'gb' => true, + 'gd' => true, + 'ge' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'mil' => true, + 'net' => true, + 'pvt' => true + ), + 'gf' => true, + 'gg' => array( + 'co' => true, + 'net' => true, + 'org' => true + ), + 'gh' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'mil' => true + ), + 'gi' => array( + 'com' => true, + 'ltd' => true, + 'gov' => true, + 'mod' => true, + 'edu' => true, + 'org' => true + ), + 'gl' => true, + 'gm' => true, + 'gn' => array( + 'ac' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'net' => true + ), + 'gov' => true, + 'gp' => array( + 'com' => true, + 'net' => true, + 'mobi' => true, + 'edu' => true, + 'org' => true, + 'asso' => true + ), + 'gq' => true, + 'gr' => array( + 'com' => true, + 'edu' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'blogspot' => true + ), + 'gs' => true, + 'gt' => array( + 'com' => true, + 'edu' => true, + 'gob' => true, + 'ind' => true, + 'mil' => true, + 'net' => true, + 'org' => true + ), + 'gu' => array( + '*' => true + ), + 'gw' => true, + 'gy' => array( + 'co' => true, + 'com' => true, + 'net' => true + ), + 'hk' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'idv' => true, + 'net' => true, + 'org' => true, + '公司' => true, + '教育' => true, + '敎育' => true, + '政府' => true, + '個人' => true, + '个人' => true, + '箇人' => true, + '網络' => true, + '网络' => true, + '组織' => true, + '網絡' => true, + '网絡' => true, + '组织' => true, + '組織' => true, + '組织' => true, + 'blogspot' => true + ), + 'hm' => true, + 'hn' => array( + 'com' => true, + 'edu' => true, + 'org' => true, + 'net' => true, + 'mil' => true, + 'gob' => true + ), + 'hr' => array( + 'iz' => true, + 'from' => true, + 'name' => true, + 'com' => true + ), + 'ht' => array( + 'com' => true, + 'shop' => true, + 'firm' => true, + 'info' => true, + 'adult' => true, + 'net' => true, + 'pro' => true, + 'org' => true, + 'med' => true, + 'art' => true, + 'coop' => true, + 'pol' => true, + 'asso' => true, + 'edu' => true, + 'rel' => true, + 'gouv' => true, + 'perso' => true + ), + 'hu' => array( + 'co' => true, + 'info' => true, + 'org' => true, + 'priv' => true, + 'sport' => true, + 'tm' => true, + '2000' => true, + 'agrar' => true, + 'bolt' => true, + 'casino' => true, + 'city' => true, + 'erotica' => true, + 'erotika' => true, + 'film' => true, + 'forum' => true, + 'games' => true, + 'hotel' => true, + 'ingatlan' => true, + 'jogasz' => true, + 'konyvelo' => true, + 'lakas' => true, + 'media' => true, + 'news' => true, + 'reklam' => true, + 'sex' => true, + 'shop' => true, + 'suli' => true, + 'szex' => true, + 'tozsde' => true, + 'utazas' => true, + 'video' => true, + 'blogspot' => true + ), + 'id' => array( + 'ac' => true, + 'biz' => true, + 'co' => true, + 'go' => true, + 'mil' => true, + 'my' => true, + 'net' => true, + 'or' => true, + 'sch' => true, + 'web' => true + ), + 'ie' => array( + 'gov' => true, + 'blogspot' => true + ), + 'il' => array( + '*' => true, + 'co' => array( + 'blogspot' => true + ) + ), + 'im' => array( + 'ac' => true, + 'co' => array( + 'ltd' => true, + 'plc' => true + ), + 'com' => true, + 'net' => true, + 'org' => true, + 'tt' => true, + 'tv' => true + ), + 'in' => array( + 'co' => true, + 'firm' => true, + 'net' => true, + 'org' => true, + 'gen' => true, + 'ind' => true, + 'nic' => true, + 'ac' => true, + 'edu' => true, + 'res' => true, + 'gov' => true, + 'mil' => true, + 'blogspot' => true + ), + 'info' => array( + 'dyndns' => true, + 'barrel-of-knowledge' => true, + 'barrell-of-knowledge' => true, + 'for-our' => true, + 'groks-the' => true, + 'groks-this' => true, + 'here-for-more' => true, + 'knowsitall' => true, + 'selfip' => true, + 'webhop' => true + ), + 'int' => array( + 'eu' => true + ), + 'io' => array( + 'com' => true, + 'github' => true + ), + 'iq' => array( + 'gov' => true, + 'edu' => true, + 'mil' => true, + 'com' => true, + 'org' => true, + 'net' => true + ), + 'ir' => array( + 'ac' => true, + 'co' => true, + 'gov' => true, + 'id' => true, + 'net' => true, + 'org' => true, + 'sch' => true, + 'ایران' => true, + 'ايران' => true + ), + 'is' => array( + 'net' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'int' => true, + 'cupcake' => true + ), + 'it' => array( + 'gov' => true, + 'edu' => true, + 'agrigento' => true, + 'ag' => true, + 'alessandria' => true, + 'al' => true, + 'ancona' => true, + 'an' => true, + 'aosta' => true, + 'aoste' => true, + 'ao' => true, + 'arezzo' => true, + 'ar' => true, + 'ascoli-piceno' => true, + 'ascolipiceno' => true, + 'ap' => true, + 'asti' => true, + 'at' => true, + 'avellino' => true, + 'av' => true, + 'bari' => true, + 'ba' => true, + 'andria-barletta-trani' => true, + 'andriabarlettatrani' => true, + 'trani-barletta-andria' => true, + 'tranibarlettaandria' => true, + 'barletta-trani-andria' => true, + 'barlettatraniandria' => true, + 'andria-trani-barletta' => true, + 'andriatranibarletta' => true, + 'trani-andria-barletta' => true, + 'traniandriabarletta' => true, + 'bt' => true, + 'belluno' => true, + 'bl' => true, + 'benevento' => true, + 'bn' => true, + 'bergamo' => true, + 'bg' => true, + 'biella' => true, + 'bi' => true, + 'bologna' => true, + 'bo' => true, + 'bolzano' => true, + 'bozen' => true, + 'balsan' => true, + 'alto-adige' => true, + 'altoadige' => true, + 'suedtirol' => true, + 'bz' => true, + 'brescia' => true, + 'bs' => true, + 'brindisi' => true, + 'br' => true, + 'cagliari' => true, + 'ca' => true, + 'caltanissetta' => true, + 'cl' => true, + 'campobasso' => true, + 'cb' => true, + 'carboniaiglesias' => true, + 'carbonia-iglesias' => true, + 'iglesias-carbonia' => true, + 'iglesiascarbonia' => true, + 'ci' => true, + 'caserta' => true, + 'ce' => true, + 'catania' => true, + 'ct' => true, + 'catanzaro' => true, + 'cz' => true, + 'chieti' => true, + 'ch' => true, + 'como' => true, + 'co' => true, + 'cosenza' => true, + 'cs' => true, + 'cremona' => true, + 'cr' => true, + 'crotone' => true, + 'kr' => true, + 'cuneo' => true, + 'cn' => true, + 'dell-ogliastra' => true, + 'dellogliastra' => true, + 'ogliastra' => true, + 'og' => true, + 'enna' => true, + 'en' => true, + 'ferrara' => true, + 'fe' => true, + 'fermo' => true, + 'fm' => true, + 'firenze' => true, + 'florence' => true, + 'fi' => true, + 'foggia' => true, + 'fg' => true, + 'forli-cesena' => true, + 'forlicesena' => true, + 'cesena-forli' => true, + 'cesenaforli' => true, + 'fc' => true, + 'frosinone' => true, + 'fr' => true, + 'genova' => true, + 'genoa' => true, + 'ge' => true, + 'gorizia' => true, + 'go' => true, + 'grosseto' => true, + 'gr' => true, + 'imperia' => true, + 'im' => true, + 'isernia' => true, + 'is' => true, + 'laquila' => true, + 'aquila' => true, + 'aq' => true, + 'la-spezia' => true, + 'laspezia' => true, + 'sp' => true, + 'latina' => true, + 'lt' => true, + 'lecce' => true, + 'le' => true, + 'lecco' => true, + 'lc' => true, + 'livorno' => true, + 'li' => true, + 'lodi' => true, + 'lo' => true, + 'lucca' => true, + 'lu' => true, + 'macerata' => true, + 'mc' => true, + 'mantova' => true, + 'mn' => true, + 'massa-carrara' => true, + 'massacarrara' => true, + 'carrara-massa' => true, + 'carraramassa' => true, + 'ms' => true, + 'matera' => true, + 'mt' => true, + 'medio-campidano' => true, + 'mediocampidano' => true, + 'campidano-medio' => true, + 'campidanomedio' => true, + 'vs' => true, + 'messina' => true, + 'me' => true, + 'milano' => true, + 'milan' => true, + 'mi' => true, + 'modena' => true, + 'mo' => true, + 'monza' => true, + 'monza-brianza' => true, + 'monzabrianza' => true, + 'monzaebrianza' => true, + 'monzaedellabrianza' => true, + 'monza-e-della-brianza' => true, + 'mb' => true, + 'napoli' => true, + 'naples' => true, + 'na' => true, + 'novara' => true, + 'no' => true, + 'nuoro' => true, + 'nu' => true, + 'oristano' => true, + 'or' => true, + 'padova' => true, + 'padua' => true, + 'pd' => true, + 'palermo' => true, + 'pa' => true, + 'parma' => true, + 'pr' => true, + 'pavia' => true, + 'pv' => true, + 'perugia' => true, + 'pg' => true, + 'pescara' => true, + 'pe' => true, + 'pesaro-urbino' => true, + 'pesarourbino' => true, + 'urbino-pesaro' => true, + 'urbinopesaro' => true, + 'pu' => true, + 'piacenza' => true, + 'pc' => true, + 'pisa' => true, + 'pi' => true, + 'pistoia' => true, + 'pt' => true, + 'pordenone' => true, + 'pn' => true, + 'potenza' => true, + 'pz' => true, + 'prato' => true, + 'po' => true, + 'ragusa' => true, + 'rg' => true, + 'ravenna' => true, + 'ra' => true, + 'reggio-calabria' => true, + 'reggiocalabria' => true, + 'rc' => true, + 'reggio-emilia' => true, + 'reggioemilia' => true, + 're' => true, + 'rieti' => true, + 'ri' => true, + 'rimini' => true, + 'rn' => true, + 'roma' => true, + 'rome' => true, + 'rm' => true, + 'rovigo' => true, + 'ro' => true, + 'salerno' => true, + 'sa' => true, + 'sassari' => true, + 'ss' => true, + 'savona' => true, + 'sv' => true, + 'siena' => true, + 'si' => true, + 'siracusa' => true, + 'sr' => true, + 'sondrio' => true, + 'so' => true, + 'taranto' => true, + 'ta' => true, + 'tempio-olbia' => true, + 'tempioolbia' => true, + 'olbia-tempio' => true, + 'olbiatempio' => true, + 'ot' => true, + 'teramo' => true, + 'te' => true, + 'terni' => true, + 'tr' => true, + 'torino' => true, + 'turin' => true, + 'to' => true, + 'trapani' => true, + 'tp' => true, + 'trento' => true, + 'trentino' => true, + 'tn' => true, + 'treviso' => true, + 'tv' => true, + 'trieste' => true, + 'ts' => true, + 'udine' => true, + 'ud' => true, + 'varese' => true, + 'va' => true, + 'venezia' => true, + 'venice' => true, + 've' => true, + 'verbania' => true, + 'vb' => true, + 'vercelli' => true, + 'vc' => true, + 'verona' => true, + 'vr' => true, + 'vibo-valentia' => true, + 'vibovalentia' => true, + 'vv' => true, + 'vicenza' => true, + 'vi' => true, + 'viterbo' => true, + 'vt' => true, + 'blogspot' => true + ), + 'je' => array( + 'co' => true, + 'net' => true, + 'org' => true + ), + 'jm' => array( + '*' => true + ), + 'jo' => array( + 'com' => true, + 'org' => true, + 'net' => true, + 'edu' => true, + 'sch' => true, + 'gov' => true, + 'mil' => true, + 'name' => true + ), + 'jobs' => true, + 'jp' => array( + 'ac' => true, + 'ad' => true, + 'co' => true, + 'ed' => true, + 'go' => true, + 'gr' => true, + 'lg' => true, + 'ne' => true, + 'or' => true, + 'aichi' => array( + 'aisai' => true, + 'ama' => true, + 'anjo' => true, + 'asuke' => true, + 'chiryu' => true, + 'chita' => true, + 'fuso' => true, + 'gamagori' => true, + 'handa' => true, + 'hazu' => true, + 'hekinan' => true, + 'higashiura' => true, + 'ichinomiya' => true, + 'inazawa' => true, + 'inuyama' => true, + 'isshiki' => true, + 'iwakura' => true, + 'kanie' => true, + 'kariya' => true, + 'kasugai' => true, + 'kira' => true, + 'kiyosu' => true, + 'komaki' => true, + 'konan' => true, + 'kota' => true, + 'mihama' => true, + 'miyoshi' => true, + 'nagakute' => true, + 'nishio' => true, + 'nisshin' => true, + 'obu' => true, + 'oguchi' => true, + 'oharu' => true, + 'okazaki' => true, + 'owariasahi' => true, + 'seto' => true, + 'shikatsu' => true, + 'shinshiro' => true, + 'shitara' => true, + 'tahara' => true, + 'takahama' => true, + 'tobishima' => true, + 'toei' => true, + 'togo' => true, + 'tokai' => true, + 'tokoname' => true, + 'toyoake' => true, + 'toyohashi' => true, + 'toyokawa' => true, + 'toyone' => true, + 'toyota' => true, + 'tsushima' => true, + 'yatomi' => true + ), + 'akita' => array( + 'akita' => true, + 'daisen' => true, + 'fujisato' => true, + 'gojome' => true, + 'hachirogata' => true, + 'happou' => true, + 'higashinaruse' => true, + 'honjo' => true, + 'honjyo' => true, + 'ikawa' => true, + 'kamikoani' => true, + 'kamioka' => true, + 'katagami' => true, + 'kazuno' => true, + 'kitaakita' => true, + 'kosaka' => true, + 'kyowa' => true, + 'misato' => true, + 'mitane' => true, + 'moriyoshi' => true, + 'nikaho' => true, + 'noshiro' => true, + 'odate' => true, + 'oga' => true, + 'ogata' => true, + 'semboku' => true, + 'yokote' => true, + 'yurihonjo' => true + ), + 'aomori' => array( + 'aomori' => true, + 'gonohe' => true, + 'hachinohe' => true, + 'hashikami' => true, + 'hiranai' => true, + 'hirosaki' => true, + 'itayanagi' => true, + 'kuroishi' => true, + 'misawa' => true, + 'mutsu' => true, + 'nakadomari' => true, + 'noheji' => true, + 'oirase' => true, + 'owani' => true, + 'rokunohe' => true, + 'sannohe' => true, + 'shichinohe' => true, + 'shingo' => true, + 'takko' => true, + 'towada' => true, + 'tsugaru' => true, + 'tsuruta' => true + ), + 'chiba' => array( + 'abiko' => true, + 'asahi' => true, + 'chonan' => true, + 'chosei' => true, + 'choshi' => true, + 'chuo' => true, + 'funabashi' => true, + 'futtsu' => true, + 'hanamigawa' => true, + 'ichihara' => true, + 'ichikawa' => true, + 'ichinomiya' => true, + 'inzai' => true, + 'isumi' => true, + 'kamagaya' => true, + 'kamogawa' => true, + 'kashiwa' => true, + 'katori' => true, + 'katsuura' => true, + 'kimitsu' => true, + 'kisarazu' => true, + 'kozaki' => true, + 'kujukuri' => true, + 'kyonan' => true, + 'matsudo' => true, + 'midori' => true, + 'mihama' => true, + 'minamiboso' => true, + 'mobara' => true, + 'mutsuzawa' => true, + 'nagara' => true, + 'nagareyama' => true, + 'narashino' => true, + 'narita' => true, + 'noda' => true, + 'oamishirasato' => true, + 'omigawa' => true, + 'onjuku' => true, + 'otaki' => true, + 'sakae' => true, + 'sakura' => true, + 'shimofusa' => true, + 'shirako' => true, + 'shiroi' => true, + 'shisui' => true, + 'sodegaura' => true, + 'sosa' => true, + 'tako' => true, + 'tateyama' => true, + 'togane' => true, + 'tohnosho' => true, + 'tomisato' => true, + 'urayasu' => true, + 'yachimata' => true, + 'yachiyo' => true, + 'yokaichiba' => true, + 'yokoshibahikari' => true, + 'yotsukaido' => true + ), + 'ehime' => array( + 'ainan' => true, + 'honai' => true, + 'ikata' => true, + 'imabari' => true, + 'iyo' => true, + 'kamijima' => true, + 'kihoku' => true, + 'kumakogen' => true, + 'masaki' => true, + 'matsuno' => true, + 'matsuyama' => true, + 'namikata' => true, + 'niihama' => true, + 'ozu' => true, + 'saijo' => true, + 'seiyo' => true, + 'shikokuchuo' => true, + 'tobe' => true, + 'toon' => true, + 'uchiko' => true, + 'uwajima' => true, + 'yawatahama' => true + ), + 'fukui' => array( + 'echizen' => true, + 'eiheiji' => true, + 'fukui' => true, + 'ikeda' => true, + 'katsuyama' => true, + 'mihama' => true, + 'minamiechizen' => true, + 'obama' => true, + 'ohi' => true, + 'ono' => true, + 'sabae' => true, + 'sakai' => true, + 'takahama' => true, + 'tsuruga' => true, + 'wakasa' => true + ), + 'fukuoka' => array( + 'ashiya' => true, + 'buzen' => true, + 'chikugo' => true, + 'chikuho' => true, + 'chikujo' => true, + 'chikushino' => true, + 'chikuzen' => true, + 'chuo' => true, + 'dazaifu' => true, + 'fukuchi' => true, + 'hakata' => true, + 'higashi' => true, + 'hirokawa' => true, + 'hisayama' => true, + 'iizuka' => true, + 'inatsuki' => true, + 'kaho' => true, + 'kasuga' => true, + 'kasuya' => true, + 'kawara' => true, + 'keisen' => true, + 'koga' => true, + 'kurate' => true, + 'kurogi' => true, + 'kurume' => true, + 'minami' => true, + 'miyako' => true, + 'miyama' => true, + 'miyawaka' => true, + 'mizumaki' => true, + 'munakata' => true, + 'nakagawa' => true, + 'nakama' => true, + 'nishi' => true, + 'nogata' => true, + 'ogori' => true, + 'okagaki' => true, + 'okawa' => true, + 'oki' => true, + 'omuta' => true, + 'onga' => true, + 'onojo' => true, + 'oto' => true, + 'saigawa' => true, + 'sasaguri' => true, + 'shingu' => true, + 'shinyoshitomi' => true, + 'shonai' => true, + 'soeda' => true, + 'sue' => true, + 'tachiarai' => true, + 'tagawa' => true, + 'takata' => true, + 'toho' => true, + 'toyotsu' => true, + 'tsuiki' => true, + 'ukiha' => true, + 'umi' => true, + 'usui' => true, + 'yamada' => true, + 'yame' => true, + 'yanagawa' => true, + 'yukuhashi' => true + ), + 'fukushima' => array( + 'aizubange' => true, + 'aizumisato' => true, + 'aizuwakamatsu' => true, + 'asakawa' => true, + 'bandai' => true, + 'date' => true, + 'fukushima' => true, + 'furudono' => true, + 'futaba' => true, + 'hanawa' => true, + 'higashi' => true, + 'hirata' => true, + 'hirono' => true, + 'iitate' => true, + 'inawashiro' => true, + 'ishikawa' => true, + 'iwaki' => true, + 'izumizaki' => true, + 'kagamiishi' => true, + 'kaneyama' => true, + 'kawamata' => true, + 'kitakata' => true, + 'kitashiobara' => true, + 'koori' => true, + 'koriyama' => true, + 'kunimi' => true, + 'miharu' => true, + 'mishima' => true, + 'namie' => true, + 'nango' => true, + 'nishiaizu' => true, + 'nishigo' => true, + 'okuma' => true, + 'omotego' => true, + 'ono' => true, + 'otama' => true, + 'samegawa' => true, + 'shimogo' => true, + 'shirakawa' => true, + 'showa' => true, + 'soma' => true, + 'sukagawa' => true, + 'taishin' => true, + 'tamakawa' => true, + 'tanagura' => true, + 'tenei' => true, + 'yabuki' => true, + 'yamato' => true, + 'yamatsuri' => true, + 'yanaizu' => true, + 'yugawa' => true + ), + 'gifu' => array( + 'anpachi' => true, + 'ena' => true, + 'gifu' => true, + 'ginan' => true, + 'godo' => true, + 'gujo' => true, + 'hashima' => true, + 'hichiso' => true, + 'hida' => true, + 'higashishirakawa' => true, + 'ibigawa' => true, + 'ikeda' => true, + 'kakamigahara' => true, + 'kani' => true, + 'kasahara' => true, + 'kasamatsu' => true, + 'kawaue' => true, + 'kitagata' => true, + 'mino' => true, + 'minokamo' => true, + 'mitake' => true, + 'mizunami' => true, + 'motosu' => true, + 'nakatsugawa' => true, + 'ogaki' => true, + 'sakahogi' => true, + 'seki' => true, + 'sekigahara' => true, + 'shirakawa' => true, + 'tajimi' => true, + 'takayama' => true, + 'tarui' => true, + 'toki' => true, + 'tomika' => true, + 'wanouchi' => true, + 'yamagata' => true, + 'yaotsu' => true, + 'yoro' => true + ), + 'gunma' => array( + 'annaka' => true, + 'chiyoda' => true, + 'fujioka' => true, + 'higashiagatsuma' => true, + 'isesaki' => true, + 'itakura' => true, + 'kanna' => true, + 'kanra' => true, + 'katashina' => true, + 'kawaba' => true, + 'kiryu' => true, + 'kusatsu' => true, + 'maebashi' => true, + 'meiwa' => true, + 'midori' => true, + 'minakami' => true, + 'naganohara' => true, + 'nakanojo' => true, + 'nanmoku' => true, + 'numata' => true, + 'oizumi' => true, + 'ora' => true, + 'ota' => true, + 'shibukawa' => true, + 'shimonita' => true, + 'shinto' => true, + 'showa' => true, + 'takasaki' => true, + 'takayama' => true, + 'tamamura' => true, + 'tatebayashi' => true, + 'tomioka' => true, + 'tsukiyono' => true, + 'tsumagoi' => true, + 'ueno' => true, + 'yoshioka' => true + ), + 'hiroshima' => array( + 'asaminami' => true, + 'daiwa' => true, + 'etajima' => true, + 'fuchu' => true, + 'fukuyama' => true, + 'hatsukaichi' => true, + 'higashihiroshima' => true, + 'hongo' => true, + 'jinsekikogen' => true, + 'kaita' => true, + 'kui' => true, + 'kumano' => true, + 'kure' => true, + 'mihara' => true, + 'miyoshi' => true, + 'naka' => true, + 'onomichi' => true, + 'osakikamijima' => true, + 'otake' => true, + 'saka' => true, + 'sera' => true, + 'seranishi' => true, + 'shinichi' => true, + 'shobara' => true, + 'takehara' => true + ), + 'hokkaido' => array( + 'abashiri' => true, + 'abira' => true, + 'aibetsu' => true, + 'akabira' => true, + 'akkeshi' => true, + 'asahikawa' => true, + 'ashibetsu' => true, + 'ashoro' => true, + 'assabu' => true, + 'atsuma' => true, + 'bibai' => true, + 'biei' => true, + 'bifuka' => true, + 'bihoro' => true, + 'biratori' => true, + 'chippubetsu' => true, + 'chitose' => true, + 'date' => true, + 'ebetsu' => true, + 'embetsu' => true, + 'eniwa' => true, + 'erimo' => true, + 'esan' => true, + 'esashi' => true, + 'fukagawa' => true, + 'fukushima' => true, + 'furano' => true, + 'furubira' => true, + 'haboro' => true, + 'hakodate' => true, + 'hamatonbetsu' => true, + 'hidaka' => true, + 'higashikagura' => true, + 'higashikawa' => true, + 'hiroo' => true, + 'hokuryu' => true, + 'hokuto' => true, + 'honbetsu' => true, + 'horokanai' => true, + 'horonobe' => true, + 'ikeda' => true, + 'imakane' => true, + 'ishikari' => true, + 'iwamizawa' => true, + 'iwanai' => true, + 'kamifurano' => true, + 'kamikawa' => true, + 'kamishihoro' => true, + 'kamisunagawa' => true, + 'kamoenai' => true, + 'kayabe' => true, + 'kembuchi' => true, + 'kikonai' => true, + 'kimobetsu' => true, + 'kitahiroshima' => true, + 'kitami' => true, + 'kiyosato' => true, + 'koshimizu' => true, + 'kunneppu' => true, + 'kuriyama' => true, + 'kuromatsunai' => true, + 'kushiro' => true, + 'kutchan' => true, + 'kyowa' => true, + 'mashike' => true, + 'matsumae' => true, + 'mikasa' => true, + 'minamifurano' => true, + 'mombetsu' => true, + 'moseushi' => true, + 'mukawa' => true, + 'muroran' => true, + 'naie' => true, + 'nakagawa' => true, + 'nakasatsunai' => true, + 'nakatombetsu' => true, + 'nanae' => true, + 'nanporo' => true, + 'nayoro' => true, + 'nemuro' => true, + 'niikappu' => true, + 'niki' => true, + 'nishiokoppe' => true, + 'noboribetsu' => true, + 'numata' => true, + 'obihiro' => true, + 'obira' => true, + 'oketo' => true, + 'okoppe' => true, + 'otaru' => true, + 'otobe' => true, + 'otofuke' => true, + 'otoineppu' => true, + 'oumu' => true, + 'ozora' => true, + 'pippu' => true, + 'rankoshi' => true, + 'rebun' => true, + 'rikubetsu' => true, + 'rishiri' => true, + 'rishirifuji' => true, + 'saroma' => true, + 'sarufutsu' => true, + 'shakotan' => true, + 'shari' => true, + 'shibecha' => true, + 'shibetsu' => true, + 'shikabe' => true, + 'shikaoi' => true, + 'shimamaki' => true, + 'shimizu' => true, + 'shimokawa' => true, + 'shinshinotsu' => true, + 'shintoku' => true, + 'shiranuka' => true, + 'shiraoi' => true, + 'shiriuchi' => true, + 'sobetsu' => true, + 'sunagawa' => true, + 'taiki' => true, + 'takasu' => true, + 'takikawa' => true, + 'takinoue' => true, + 'teshikaga' => true, + 'tobetsu' => true, + 'tohma' => true, + 'tomakomai' => true, + 'tomari' => true, + 'toya' => true, + 'toyako' => true, + 'toyotomi' => true, + 'toyoura' => true, + 'tsubetsu' => true, + 'tsukigata' => true, + 'urakawa' => true, + 'urausu' => true, + 'uryu' => true, + 'utashinai' => true, + 'wakkanai' => true, + 'wassamu' => true, + 'yakumo' => true, + 'yoichi' => true + ), + 'hyogo' => array( + 'aioi' => true, + 'akashi' => true, + 'ako' => true, + 'amagasaki' => true, + 'aogaki' => true, + 'asago' => true, + 'ashiya' => true, + 'awaji' => true, + 'fukusaki' => true, + 'goshiki' => true, + 'harima' => true, + 'himeji' => true, + 'ichikawa' => true, + 'inagawa' => true, + 'itami' => true, + 'kakogawa' => true, + 'kamigori' => true, + 'kamikawa' => true, + 'kasai' => true, + 'kasuga' => true, + 'kawanishi' => true, + 'miki' => true, + 'minamiawaji' => true, + 'nishinomiya' => true, + 'nishiwaki' => true, + 'ono' => true, + 'sanda' => true, + 'sannan' => true, + 'sasayama' => true, + 'sayo' => true, + 'shingu' => true, + 'shinonsen' => true, + 'shiso' => true, + 'sumoto' => true, + 'taishi' => true, + 'taka' => true, + 'takarazuka' => true, + 'takasago' => true, + 'takino' => true, + 'tamba' => true, + 'tatsuno' => true, + 'toyooka' => true, + 'yabu' => true, + 'yashiro' => true, + 'yoka' => true, + 'yokawa' => true + ), + 'ibaraki' => array( + 'ami' => true, + 'asahi' => true, + 'bando' => true, + 'chikusei' => true, + 'daigo' => true, + 'fujishiro' => true, + 'hitachi' => true, + 'hitachinaka' => true, + 'hitachiomiya' => true, + 'hitachiota' => true, + 'ibaraki' => true, + 'ina' => true, + 'inashiki' => true, + 'itako' => true, + 'iwama' => true, + 'joso' => true, + 'kamisu' => true, + 'kasama' => true, + 'kashima' => true, + 'kasumigaura' => true, + 'koga' => true, + 'miho' => true, + 'mito' => true, + 'moriya' => true, + 'naka' => true, + 'namegata' => true, + 'oarai' => true, + 'ogawa' => true, + 'omitama' => true, + 'ryugasaki' => true, + 'sakai' => true, + 'sakuragawa' => true, + 'shimodate' => true, + 'shimotsuma' => true, + 'shirosato' => true, + 'sowa' => true, + 'suifu' => true, + 'takahagi' => true, + 'tamatsukuri' => true, + 'tokai' => true, + 'tomobe' => true, + 'tone' => true, + 'toride' => true, + 'tsuchiura' => true, + 'tsukuba' => true, + 'uchihara' => true, + 'ushiku' => true, + 'yachiyo' => true, + 'yamagata' => true, + 'yawara' => true, + 'yuki' => true + ), + 'ishikawa' => array( + 'anamizu' => true, + 'hakui' => true, + 'hakusan' => true, + 'kaga' => true, + 'kahoku' => true, + 'kanazawa' => true, + 'kawakita' => true, + 'komatsu' => true, + 'nakanoto' => true, + 'nanao' => true, + 'nomi' => true, + 'nonoichi' => true, + 'noto' => true, + 'shika' => true, + 'suzu' => true, + 'tsubata' => true, + 'tsurugi' => true, + 'uchinada' => true, + 'wajima' => true + ), + 'iwate' => array( + 'fudai' => true, + 'fujisawa' => true, + 'hanamaki' => true, + 'hiraizumi' => true, + 'hirono' => true, + 'ichinohe' => true, + 'ichinoseki' => true, + 'iwaizumi' => true, + 'iwate' => true, + 'joboji' => true, + 'kamaishi' => true, + 'kanegasaki' => true, + 'karumai' => true, + 'kawai' => true, + 'kitakami' => true, + 'kuji' => true, + 'kunohe' => true, + 'kuzumaki' => true, + 'miyako' => true, + 'mizusawa' => true, + 'morioka' => true, + 'ninohe' => true, + 'noda' => true, + 'ofunato' => true, + 'oshu' => true, + 'otsuchi' => true, + 'rikuzentakata' => true, + 'shiwa' => true, + 'shizukuishi' => true, + 'sumita' => true, + 'takizawa' => true, + 'tanohata' => true, + 'tono' => true, + 'yahaba' => true, + 'yamada' => true + ), + 'kagawa' => array( + 'ayagawa' => true, + 'higashikagawa' => true, + 'kanonji' => true, + 'kotohira' => true, + 'manno' => true, + 'marugame' => true, + 'mitoyo' => true, + 'naoshima' => true, + 'sanuki' => true, + 'tadotsu' => true, + 'takamatsu' => true, + 'tonosho' => true, + 'uchinomi' => true, + 'utazu' => true, + 'zentsuji' => true + ), + 'kagoshima' => array( + 'akune' => true, + 'amami' => true, + 'hioki' => true, + 'isa' => true, + 'isen' => true, + 'izumi' => true, + 'kagoshima' => true, + 'kanoya' => true, + 'kawanabe' => true, + 'kinko' => true, + 'kouyama' => true, + 'makurazaki' => true, + 'matsumoto' => true, + 'minamitane' => true, + 'nakatane' => true, + 'nishinoomote' => true, + 'satsumasendai' => true, + 'soo' => true, + 'tarumizu' => true, + 'yusui' => true + ), + 'kanagawa' => array( + 'aikawa' => true, + 'atsugi' => true, + 'ayase' => true, + 'chigasaki' => true, + 'ebina' => true, + 'fujisawa' => true, + 'hadano' => true, + 'hakone' => true, + 'hiratsuka' => true, + 'isehara' => true, + 'kaisei' => true, + 'kamakura' => true, + 'kiyokawa' => true, + 'matsuda' => true, + 'minamiashigara' => true, + 'miura' => true, + 'nakai' => true, + 'ninomiya' => true, + 'odawara' => true, + 'oi' => true, + 'oiso' => true, + 'sagamihara' => true, + 'samukawa' => true, + 'tsukui' => true, + 'yamakita' => true, + 'yamato' => true, + 'yokosuka' => true, + 'yugawara' => true, + 'zama' => true, + 'zushi' => true + ), + 'kochi' => array( + 'aki' => true, + 'geisei' => true, + 'hidaka' => true, + 'higashitsuno' => true, + 'ino' => true, + 'kagami' => true, + 'kami' => true, + 'kitagawa' => true, + 'kochi' => true, + 'mihara' => true, + 'motoyama' => true, + 'muroto' => true, + 'nahari' => true, + 'nakamura' => true, + 'nankoku' => true, + 'nishitosa' => true, + 'niyodogawa' => true, + 'ochi' => true, + 'okawa' => true, + 'otoyo' => true, + 'otsuki' => true, + 'sakawa' => true, + 'sukumo' => true, + 'susaki' => true, + 'tosa' => true, + 'tosashimizu' => true, + 'toyo' => true, + 'tsuno' => true, + 'umaji' => true, + 'yasuda' => true, + 'yusuhara' => true + ), + 'kumamoto' => array( + 'amakusa' => true, + 'arao' => true, + 'aso' => true, + 'choyo' => true, + 'gyokuto' => true, + 'hitoyoshi' => true, + 'kamiamakusa' => true, + 'kashima' => true, + 'kikuchi' => true, + 'kosa' => true, + 'kumamoto' => true, + 'mashiki' => true, + 'mifune' => true, + 'minamata' => true, + 'minamioguni' => true, + 'nagasu' => true, + 'nishihara' => true, + 'oguni' => true, + 'ozu' => true, + 'sumoto' => true, + 'takamori' => true, + 'uki' => true, + 'uto' => true, + 'yamaga' => true, + 'yamato' => true, + 'yatsushiro' => true + ), + 'kyoto' => array( + 'ayabe' => true, + 'fukuchiyama' => true, + 'higashiyama' => true, + 'ide' => true, + 'ine' => true, + 'joyo' => true, + 'kameoka' => true, + 'kamo' => true, + 'kita' => true, + 'kizu' => true, + 'kumiyama' => true, + 'kyotamba' => true, + 'kyotanabe' => true, + 'kyotango' => true, + 'maizuru' => true, + 'minami' => true, + 'minamiyamashiro' => true, + 'miyazu' => true, + 'muko' => true, + 'nagaokakyo' => true, + 'nakagyo' => true, + 'nantan' => true, + 'oyamazaki' => true, + 'sakyo' => true, + 'seika' => true, + 'tanabe' => true, + 'uji' => true, + 'ujitawara' => true, + 'wazuka' => true, + 'yamashina' => true, + 'yawata' => true + ), + 'mie' => array( + 'asahi' => true, + 'inabe' => true, + 'ise' => true, + 'kameyama' => true, + 'kawagoe' => true, + 'kiho' => true, + 'kisosaki' => true, + 'kiwa' => true, + 'komono' => true, + 'kumano' => true, + 'kuwana' => true, + 'matsusaka' => true, + 'meiwa' => true, + 'mihama' => true, + 'minamiise' => true, + 'misugi' => true, + 'miyama' => true, + 'nabari' => true, + 'shima' => true, + 'suzuka' => true, + 'tado' => true, + 'taiki' => true, + 'taki' => true, + 'tamaki' => true, + 'toba' => true, + 'tsu' => true, + 'udono' => true, + 'ureshino' => true, + 'watarai' => true, + 'yokkaichi' => true + ), + 'miyagi' => array( + 'furukawa' => true, + 'higashimatsushima' => true, + 'ishinomaki' => true, + 'iwanuma' => true, + 'kakuda' => true, + 'kami' => true, + 'kawasaki' => true, + 'kesennuma' => true, + 'marumori' => true, + 'matsushima' => true, + 'minamisanriku' => true, + 'misato' => true, + 'murata' => true, + 'natori' => true, + 'ogawara' => true, + 'ohira' => true, + 'onagawa' => true, + 'osaki' => true, + 'rifu' => true, + 'semine' => true, + 'shibata' => true, + 'shichikashuku' => true, + 'shikama' => true, + 'shiogama' => true, + 'shiroishi' => true, + 'tagajo' => true, + 'taiwa' => true, + 'tome' => true, + 'tomiya' => true, + 'wakuya' => true, + 'watari' => true, + 'yamamoto' => true, + 'zao' => true + ), + 'miyazaki' => array( + 'aya' => true, + 'ebino' => true, + 'gokase' => true, + 'hyuga' => true, + 'kadogawa' => true, + 'kawaminami' => true, + 'kijo' => true, + 'kitagawa' => true, + 'kitakata' => true, + 'kitaura' => true, + 'kobayashi' => true, + 'kunitomi' => true, + 'kushima' => true, + 'mimata' => true, + 'miyakonojo' => true, + 'miyazaki' => true, + 'morotsuka' => true, + 'nichinan' => true, + 'nishimera' => true, + 'nobeoka' => true, + 'saito' => true, + 'shiiba' => true, + 'shintomi' => true, + 'takaharu' => true, + 'takanabe' => true, + 'takazaki' => true, + 'tsuno' => true + ), + 'nagano' => array( + 'achi' => true, + 'agematsu' => true, + 'anan' => true, + 'aoki' => true, + 'asahi' => true, + 'azumino' => true, + 'chikuhoku' => true, + 'chikuma' => true, + 'chino' => true, + 'fujimi' => true, + 'hakuba' => true, + 'hara' => true, + 'hiraya' => true, + 'iida' => true, + 'iijima' => true, + 'iiyama' => true, + 'iizuna' => true, + 'ikeda' => true, + 'ikusaka' => true, + 'ina' => true, + 'karuizawa' => true, + 'kawakami' => true, + 'kiso' => true, + 'kisofukushima' => true, + 'kitaaiki' => true, + 'komagane' => true, + 'komoro' => true, + 'matsukawa' => true, + 'matsumoto' => true, + 'miasa' => true, + 'minamiaiki' => true, + 'minamimaki' => true, + 'minamiminowa' => true, + 'minowa' => true, + 'miyada' => true, + 'miyota' => true, + 'mochizuki' => true, + 'nagano' => true, + 'nagawa' => true, + 'nagiso' => true, + 'nakagawa' => true, + 'nakano' => true, + 'nozawaonsen' => true, + 'obuse' => true, + 'ogawa' => true, + 'okaya' => true, + 'omachi' => true, + 'omi' => true, + 'ookuwa' => true, + 'ooshika' => true, + 'otaki' => true, + 'otari' => true, + 'sakae' => true, + 'sakaki' => true, + 'saku' => true, + 'sakuho' => true, + 'shimosuwa' => true, + 'shinanomachi' => true, + 'shiojiri' => true, + 'suwa' => true, + 'suzaka' => true, + 'takagi' => true, + 'takamori' => true, + 'takayama' => true, + 'tateshina' => true, + 'tatsuno' => true, + 'togakushi' => true, + 'togura' => true, + 'tomi' => true, + 'ueda' => true, + 'wada' => true, + 'yamagata' => true, + 'yamanouchi' => true, + 'yasaka' => true, + 'yasuoka' => true + ), + 'nagasaki' => array( + 'chijiwa' => true, + 'futsu' => true, + 'goto' => true, + 'hasami' => true, + 'hirado' => true, + 'iki' => true, + 'isahaya' => true, + 'kawatana' => true, + 'kuchinotsu' => true, + 'matsuura' => true, + 'nagasaki' => true, + 'obama' => true, + 'omura' => true, + 'oseto' => true, + 'saikai' => true, + 'sasebo' => true, + 'seihi' => true, + 'shimabara' => true, + 'shinkamigoto' => true, + 'togitsu' => true, + 'tsushima' => true, + 'unzen' => true + ), + 'nara' => array( + 'ando' => true, + 'gose' => true, + 'heguri' => true, + 'higashiyoshino' => true, + 'ikaruga' => true, + 'ikoma' => true, + 'kamikitayama' => true, + 'kanmaki' => true, + 'kashiba' => true, + 'kashihara' => true, + 'katsuragi' => true, + 'kawai' => true, + 'kawakami' => true, + 'kawanishi' => true, + 'koryo' => true, + 'kurotaki' => true, + 'mitsue' => true, + 'miyake' => true, + 'nara' => true, + 'nosegawa' => true, + 'oji' => true, + 'ouda' => true, + 'oyodo' => true, + 'sakurai' => true, + 'sango' => true, + 'shimoichi' => true, + 'shimokitayama' => true, + 'shinjo' => true, + 'soni' => true, + 'takatori' => true, + 'tawaramoto' => true, + 'tenkawa' => true, + 'tenri' => true, + 'uda' => true, + 'yamatokoriyama' => true, + 'yamatotakada' => true, + 'yamazoe' => true, + 'yoshino' => true + ), + 'niigata' => array( + 'aga' => true, + 'agano' => true, + 'gosen' => true, + 'itoigawa' => true, + 'izumozaki' => true, + 'joetsu' => true, + 'kamo' => true, + 'kariwa' => true, + 'kashiwazaki' => true, + 'minamiuonuma' => true, + 'mitsuke' => true, + 'muika' => true, + 'murakami' => true, + 'myoko' => true, + 'nagaoka' => true, + 'niigata' => true, + 'ojiya' => true, + 'omi' => true, + 'sado' => true, + 'sanjo' => true, + 'seiro' => true, + 'seirou' => true, + 'sekikawa' => true, + 'shibata' => true, + 'tagami' => true, + 'tainai' => true, + 'tochio' => true, + 'tokamachi' => true, + 'tsubame' => true, + 'tsunan' => true, + 'uonuma' => true, + 'yahiko' => true, + 'yoita' => true, + 'yuzawa' => true + ), + 'oita' => array( + 'beppu' => true, + 'bungoono' => true, + 'bungotakada' => true, + 'hasama' => true, + 'hiji' => true, + 'himeshima' => true, + 'hita' => true, + 'kamitsue' => true, + 'kokonoe' => true, + 'kuju' => true, + 'kunisaki' => true, + 'kusu' => true, + 'oita' => true, + 'saiki' => true, + 'taketa' => true, + 'tsukumi' => true, + 'usa' => true, + 'usuki' => true, + 'yufu' => true + ), + 'okayama' => array( + 'akaiwa' => true, + 'asakuchi' => true, + 'bizen' => true, + 'hayashima' => true, + 'ibara' => true, + 'kagamino' => true, + 'kasaoka' => true, + 'kibichuo' => true, + 'kumenan' => true, + 'kurashiki' => true, + 'maniwa' => true, + 'misaki' => true, + 'nagi' => true, + 'niimi' => true, + 'nishiawakura' => true, + 'okayama' => true, + 'satosho' => true, + 'setouchi' => true, + 'shinjo' => true, + 'shoo' => true, + 'soja' => true, + 'takahashi' => true, + 'tamano' => true, + 'tsuyama' => true, + 'wake' => true, + 'yakage' => true + ), + 'okinawa' => array( + 'aguni' => true, + 'ginowan' => true, + 'ginoza' => true, + 'gushikami' => true, + 'haebaru' => true, + 'higashi' => true, + 'hirara' => true, + 'iheya' => true, + 'ishigaki' => true, + 'ishikawa' => true, + 'itoman' => true, + 'izena' => true, + 'kadena' => true, + 'kin' => true, + 'kitadaito' => true, + 'kitanakagusuku' => true, + 'kumejima' => true, + 'kunigami' => true, + 'minamidaito' => true, + 'motobu' => true, + 'nago' => true, + 'naha' => true, + 'nakagusuku' => true, + 'nakijin' => true, + 'nanjo' => true, + 'nishihara' => true, + 'ogimi' => true, + 'okinawa' => true, + 'onna' => true, + 'shimoji' => true, + 'taketomi' => true, + 'tarama' => true, + 'tokashiki' => true, + 'tomigusuku' => true, + 'tonaki' => true, + 'urasoe' => true, + 'uruma' => true, + 'yaese' => true, + 'yomitan' => true, + 'yonabaru' => true, + 'yonaguni' => true, + 'zamami' => true + ), + 'osaka' => array( + 'abeno' => true, + 'chihayaakasaka' => true, + 'chuo' => true, + 'daito' => true, + 'fujiidera' => true, + 'habikino' => true, + 'hannan' => true, + 'higashiosaka' => true, + 'higashisumiyoshi' => true, + 'higashiyodogawa' => true, + 'hirakata' => true, + 'ibaraki' => true, + 'ikeda' => true, + 'izumi' => true, + 'izumiotsu' => true, + 'izumisano' => true, + 'kadoma' => true, + 'kaizuka' => true, + 'kanan' => true, + 'kashiwara' => true, + 'katano' => true, + 'kawachinagano' => true, + 'kishiwada' => true, + 'kita' => true, + 'kumatori' => true, + 'matsubara' => true, + 'minato' => true, + 'minoh' => true, + 'misaki' => true, + 'moriguchi' => true, + 'neyagawa' => true, + 'nishi' => true, + 'nose' => true, + 'osakasayama' => true, + 'sakai' => true, + 'sayama' => true, + 'sennan' => true, + 'settsu' => true, + 'shijonawate' => true, + 'shimamoto' => true, + 'suita' => true, + 'tadaoka' => true, + 'taishi' => true, + 'tajiri' => true, + 'takaishi' => true, + 'takatsuki' => true, + 'tondabayashi' => true, + 'toyonaka' => true, + 'toyono' => true, + 'yao' => true + ), + 'saga' => array( + 'ariake' => true, + 'arita' => true, + 'fukudomi' => true, + 'genkai' => true, + 'hamatama' => true, + 'hizen' => true, + 'imari' => true, + 'kamimine' => true, + 'kanzaki' => true, + 'karatsu' => true, + 'kashima' => true, + 'kitagata' => true, + 'kitahata' => true, + 'kiyama' => true, + 'kouhoku' => true, + 'kyuragi' => true, + 'nishiarita' => true, + 'ogi' => true, + 'omachi' => true, + 'ouchi' => true, + 'saga' => true, + 'shiroishi' => true, + 'taku' => true, + 'tara' => true, + 'tosu' => true, + 'yoshinogari' => true + ), + 'saitama' => array( + 'arakawa' => true, + 'asaka' => true, + 'chichibu' => true, + 'fujimi' => true, + 'fujimino' => true, + 'fukaya' => true, + 'hanno' => true, + 'hanyu' => true, + 'hasuda' => true, + 'hatogaya' => true, + 'hatoyama' => true, + 'hidaka' => true, + 'higashichichibu' => true, + 'higashimatsuyama' => true, + 'honjo' => true, + 'ina' => true, + 'iruma' => true, + 'iwatsuki' => true, + 'kamiizumi' => true, + 'kamikawa' => true, + 'kamisato' => true, + 'kasukabe' => true, + 'kawagoe' => true, + 'kawaguchi' => true, + 'kawajima' => true, + 'kazo' => true, + 'kitamoto' => true, + 'koshigaya' => true, + 'kounosu' => true, + 'kuki' => true, + 'kumagaya' => true, + 'matsubushi' => true, + 'minano' => true, + 'misato' => true, + 'miyashiro' => true, + 'miyoshi' => true, + 'moroyama' => true, + 'nagatoro' => true, + 'namegawa' => true, + 'niiza' => true, + 'ogano' => true, + 'ogawa' => true, + 'ogose' => true, + 'okegawa' => true, + 'omiya' => true, + 'otaki' => true, + 'ranzan' => true, + 'ryokami' => true, + 'saitama' => true, + 'sakado' => true, + 'satte' => true, + 'sayama' => true, + 'shiki' => true, + 'shiraoka' => true, + 'soka' => true, + 'sugito' => true, + 'toda' => true, + 'tokigawa' => true, + 'tokorozawa' => true, + 'tsurugashima' => true, + 'urawa' => true, + 'warabi' => true, + 'yashio' => true, + 'yokoze' => true, + 'yono' => true, + 'yorii' => true, + 'yoshida' => true, + 'yoshikawa' => true, + 'yoshimi' => true + ), + 'shiga' => array( + 'aisho' => true, + 'gamo' => true, + 'higashiomi' => true, + 'hikone' => true, + 'koka' => true, + 'konan' => true, + 'kosei' => true, + 'koto' => true, + 'kusatsu' => true, + 'maibara' => true, + 'moriyama' => true, + 'nagahama' => true, + 'nishiazai' => true, + 'notogawa' => true, + 'omihachiman' => true, + 'otsu' => true, + 'ritto' => true, + 'ryuoh' => true, + 'takashima' => true, + 'takatsuki' => true, + 'torahime' => true, + 'toyosato' => true, + 'yasu' => true + ), + 'shimane' => array( + 'akagi' => true, + 'ama' => true, + 'gotsu' => true, + 'hamada' => true, + 'higashiizumo' => true, + 'hikawa' => true, + 'hikimi' => true, + 'izumo' => true, + 'kakinoki' => true, + 'masuda' => true, + 'matsue' => true, + 'misato' => true, + 'nishinoshima' => true, + 'ohda' => true, + 'okinoshima' => true, + 'okuizumo' => true, + 'shimane' => true, + 'tamayu' => true, + 'tsuwano' => true, + 'unnan' => true, + 'yakumo' => true, + 'yasugi' => true, + 'yatsuka' => true + ), + 'shizuoka' => array( + 'arai' => true, + 'atami' => true, + 'fuji' => true, + 'fujieda' => true, + 'fujikawa' => true, + 'fujinomiya' => true, + 'fukuroi' => true, + 'gotemba' => true, + 'haibara' => true, + 'hamamatsu' => true, + 'higashiizu' => true, + 'ito' => true, + 'iwata' => true, + 'izu' => true, + 'izunokuni' => true, + 'kakegawa' => true, + 'kannami' => true, + 'kawanehon' => true, + 'kawazu' => true, + 'kikugawa' => true, + 'kosai' => true, + 'makinohara' => true, + 'matsuzaki' => true, + 'minamiizu' => true, + 'mishima' => true, + 'morimachi' => true, + 'nishiizu' => true, + 'numazu' => true, + 'omaezaki' => true, + 'shimada' => true, + 'shimizu' => true, + 'shimoda' => true, + 'shizuoka' => true, + 'susono' => true, + 'yaizu' => true, + 'yoshida' => true + ), + 'tochigi' => array( + 'ashikaga' => true, + 'bato' => true, + 'haga' => true, + 'ichikai' => true, + 'iwafune' => true, + 'kaminokawa' => true, + 'kanuma' => true, + 'karasuyama' => true, + 'kuroiso' => true, + 'mashiko' => true, + 'mibu' => true, + 'moka' => true, + 'motegi' => true, + 'nasu' => true, + 'nasushiobara' => true, + 'nikko' => true, + 'nishikata' => true, + 'nogi' => true, + 'ohira' => true, + 'ohtawara' => true, + 'oyama' => true, + 'sakura' => true, + 'sano' => true, + 'shimotsuke' => true, + 'shioya' => true, + 'takanezawa' => true, + 'tochigi' => true, + 'tsuga' => true, + 'ujiie' => true, + 'utsunomiya' => true, + 'yaita' => true + ), + 'tokushima' => array( + 'aizumi' => true, + 'anan' => true, + 'ichiba' => true, + 'itano' => true, + 'kainan' => true, + 'komatsushima' => true, + 'matsushige' => true, + 'mima' => true, + 'minami' => true, + 'miyoshi' => true, + 'mugi' => true, + 'nakagawa' => true, + 'naruto' => true, + 'sanagochi' => true, + 'shishikui' => true, + 'tokushima' => true, + 'wajiki' => true + ), + 'tokyo' => array( + 'adachi' => true, + 'akiruno' => true, + 'akishima' => true, + 'aogashima' => true, + 'arakawa' => true, + 'bunkyo' => true, + 'chiyoda' => true, + 'chofu' => true, + 'chuo' => true, + 'edogawa' => true, + 'fuchu' => true, + 'fussa' => true, + 'hachijo' => true, + 'hachioji' => true, + 'hamura' => true, + 'higashikurume' => true, + 'higashimurayama' => true, + 'higashiyamato' => true, + 'hino' => true, + 'hinode' => true, + 'hinohara' => true, + 'inagi' => true, + 'itabashi' => true, + 'katsushika' => true, + 'kita' => true, + 'kiyose' => true, + 'kodaira' => true, + 'koganei' => true, + 'kokubunji' => true, + 'komae' => true, + 'koto' => true, + 'kouzushima' => true, + 'kunitachi' => true, + 'machida' => true, + 'meguro' => true, + 'minato' => true, + 'mitaka' => true, + 'mizuho' => true, + 'musashimurayama' => true, + 'musashino' => true, + 'nakano' => true, + 'nerima' => true, + 'ogasawara' => true, + 'okutama' => true, + 'ome' => true, + 'oshima' => true, + 'ota' => true, + 'setagaya' => true, + 'shibuya' => true, + 'shinagawa' => true, + 'shinjuku' => true, + 'suginami' => true, + 'sumida' => true, + 'tachikawa' => true, + 'taito' => true, + 'tama' => true, + 'toshima' => true + ), + 'tottori' => array( + 'chizu' => true, + 'hino' => true, + 'kawahara' => true, + 'koge' => true, + 'kotoura' => true, + 'misasa' => true, + 'nanbu' => true, + 'nichinan' => true, + 'sakaiminato' => true, + 'tottori' => true, + 'wakasa' => true, + 'yazu' => true, + 'yonago' => true + ), + 'toyama' => array( + 'asahi' => true, + 'fuchu' => true, + 'fukumitsu' => true, + 'funahashi' => true, + 'himi' => true, + 'imizu' => true, + 'inami' => true, + 'johana' => true, + 'kamiichi' => true, + 'kurobe' => true, + 'nakaniikawa' => true, + 'namerikawa' => true, + 'nanto' => true, + 'nyuzen' => true, + 'oyabe' => true, + 'taira' => true, + 'takaoka' => true, + 'tateyama' => true, + 'toga' => true, + 'tonami' => true, + 'toyama' => true, + 'unazuki' => true, + 'uozu' => true, + 'yamada' => true + ), + 'wakayama' => array( + 'arida' => true, + 'aridagawa' => true, + 'gobo' => true, + 'hashimoto' => true, + 'hidaka' => true, + 'hirogawa' => true, + 'inami' => true, + 'iwade' => true, + 'kainan' => true, + 'kamitonda' => true, + 'katsuragi' => true, + 'kimino' => true, + 'kinokawa' => true, + 'kitayama' => true, + 'koya' => true, + 'koza' => true, + 'kozagawa' => true, + 'kudoyama' => true, + 'kushimoto' => true, + 'mihama' => true, + 'misato' => true, + 'nachikatsuura' => true, + 'shingu' => true, + 'shirahama' => true, + 'taiji' => true, + 'tanabe' => true, + 'wakayama' => true, + 'yuasa' => true, + 'yura' => true + ), + 'yamagata' => array( + 'asahi' => true, + 'funagata' => true, + 'higashine' => true, + 'iide' => true, + 'kahoku' => true, + 'kaminoyama' => true, + 'kaneyama' => true, + 'kawanishi' => true, + 'mamurogawa' => true, + 'mikawa' => true, + 'murayama' => true, + 'nagai' => true, + 'nakayama' => true, + 'nanyo' => true, + 'nishikawa' => true, + 'obanazawa' => true, + 'oe' => true, + 'oguni' => true, + 'ohkura' => true, + 'oishida' => true, + 'sagae' => true, + 'sakata' => true, + 'sakegawa' => true, + 'shinjo' => true, + 'shirataka' => true, + 'shonai' => true, + 'takahata' => true, + 'tendo' => true, + 'tozawa' => true, + 'tsuruoka' => true, + 'yamagata' => true, + 'yamanobe' => true, + 'yonezawa' => true, + 'yuza' => true + ), + 'yamaguchi' => array( + 'abu' => true, + 'hagi' => true, + 'hikari' => true, + 'hofu' => true, + 'iwakuni' => true, + 'kudamatsu' => true, + 'mitou' => true, + 'nagato' => true, + 'oshima' => true, + 'shimonoseki' => true, + 'shunan' => true, + 'tabuse' => true, + 'tokuyama' => true, + 'toyota' => true, + 'ube' => true, + 'yuu' => true + ), + 'yamanashi' => array( + 'chuo' => true, + 'doshi' => true, + 'fuefuki' => true, + 'fujikawa' => true, + 'fujikawaguchiko' => true, + 'fujiyoshida' => true, + 'hayakawa' => true, + 'hokuto' => true, + 'ichikawamisato' => true, + 'kai' => true, + 'kofu' => true, + 'koshu' => true, + 'kosuge' => true, + 'minami-alps' => true, + 'minobu' => true, + 'nakamichi' => true, + 'nanbu' => true, + 'narusawa' => true, + 'nirasaki' => true, + 'nishikatsura' => true, + 'oshino' => true, + 'otsuki' => true, + 'showa' => true, + 'tabayama' => true, + 'tsuru' => true, + 'uenohara' => true, + 'yamanakako' => true, + 'yamanashi' => true + ), + 'kawasaki' => array( + '*' => true, + '!city' => true + ), + 'kitakyushu' => array( + '*' => true, + '!city' => true + ), + 'kobe' => array( + '*' => true, + '!city' => true + ), + 'nagoya' => array( + '*' => true, + '!city' => true + ), + 'sapporo' => array( + '*' => true, + '!city' => true + ), + 'sendai' => array( + '*' => true, + '!city' => true + ), + 'yokohama' => array( + '*' => true, + '!city' => true + ), + 'blogspot' => true + ), + 'ke' => array( + '*' => true + ), + 'kg' => array( + 'org' => true, + 'net' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true + ), + 'kh' => array( + '*' => true + ), + 'ki' => array( + 'edu' => true, + 'biz' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'info' => true, + 'com' => true + ), + 'km' => array( + 'org' => true, + 'nom' => true, + 'gov' => true, + 'prd' => true, + 'tm' => true, + 'edu' => true, + 'mil' => true, + 'ass' => true, + 'com' => true, + 'coop' => true, + 'asso' => true, + 'presse' => true, + 'medecin' => true, + 'notaires' => true, + 'pharmaciens' => true, + 'veterinaire' => true, + 'gouv' => true + ), + 'kn' => array( + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'kp' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'rep' => true, + 'tra' => true + ), + 'kr' => array( + 'ac' => true, + 'co' => true, + 'es' => true, + 'go' => true, + 'hs' => true, + 'kg' => true, + 'mil' => true, + 'ms' => true, + 'ne' => true, + 'or' => true, + 'pe' => true, + 're' => true, + 'sc' => true, + 'busan' => true, + 'chungbuk' => true, + 'chungnam' => true, + 'daegu' => true, + 'daejeon' => true, + 'gangwon' => true, + 'gwangju' => true, + 'gyeongbuk' => true, + 'gyeonggi' => true, + 'gyeongnam' => true, + 'incheon' => true, + 'jeju' => true, + 'jeonbuk' => true, + 'jeonnam' => true, + 'seoul' => true, + 'ulsan' => true, + 'blogspot' => true + ), + 'kw' => array( + '*' => true + ), + 'ky' => array( + 'edu' => true, + 'gov' => true, + 'com' => true, + 'org' => true, + 'net' => true + ), + 'kz' => array( + 'org' => true, + 'edu' => true, + 'net' => true, + 'gov' => true, + 'mil' => true, + 'com' => true + ), + 'la' => array( + 'int' => true, + 'net' => true, + 'info' => true, + 'edu' => true, + 'gov' => true, + 'per' => true, + 'com' => true, + 'org' => true, + 'c' => true + ), + 'lb' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'org' => true + ), + 'lc' => array( + 'com' => true, + 'net' => true, + 'co' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'li' => true, + 'lk' => array( + 'gov' => true, + 'sch' => true, + 'net' => true, + 'int' => true, + 'com' => true, + 'org' => true, + 'edu' => true, + 'ngo' => true, + 'soc' => true, + 'web' => true, + 'ltd' => true, + 'assn' => true, + 'grp' => true, + 'hotel' => true + ), + 'lr' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'net' => true + ), + 'ls' => array( + 'co' => true, + 'org' => true + ), + 'lt' => array( + 'gov' => true + ), + 'lu' => true, + 'lv' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'org' => true, + 'mil' => true, + 'id' => true, + 'net' => true, + 'asn' => true, + 'conf' => true + ), + 'ly' => array( + 'com' => true, + 'net' => true, + 'gov' => true, + 'plc' => true, + 'edu' => true, + 'sch' => true, + 'med' => true, + 'org' => true, + 'id' => true + ), + 'ma' => array( + 'co' => true, + 'net' => true, + 'gov' => true, + 'org' => true, + 'ac' => true, + 'press' => true + ), + 'mc' => array( + 'tm' => true, + 'asso' => true + ), + 'md' => true, + 'me' => array( + 'co' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'ac' => true, + 'gov' => true, + 'its' => true, + 'priv' => true + ), + 'mg' => array( + 'org' => true, + 'nom' => true, + 'gov' => true, + 'prd' => true, + 'tm' => true, + 'edu' => true, + 'mil' => true, + 'com' => true + ), + 'mh' => true, + 'mil' => true, + 'mk' => array( + 'com' => true, + 'org' => true, + 'net' => true, + 'edu' => true, + 'gov' => true, + 'inf' => true, + 'name' => true + ), + 'ml' => array( + 'com' => true, + 'edu' => true, + 'gouv' => true, + 'gov' => true, + 'net' => true, + 'org' => true, + 'presse' => true + ), + 'mm' => array( + '*' => true + ), + 'mn' => array( + 'gov' => true, + 'edu' => true, + 'org' => true, + 'nyc' => true + ), + 'mo' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true + ), + 'mobi' => true, + 'mp' => true, + 'mq' => true, + 'mr' => array( + 'gov' => true, + 'blogspot' => true + ), + 'ms' => true, + 'mt' => array( + 'com' => true, + 'edu' => true, + 'net' => true, + 'org' => true + ), + 'mu' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'ac' => true, + 'co' => true, + 'or' => true + ), + 'museum' => array( + 'academy' => true, + 'agriculture' => true, + 'air' => true, + 'airguard' => true, + 'alabama' => true, + 'alaska' => true, + 'amber' => true, + 'ambulance' => true, + 'american' => true, + 'americana' => true, + 'americanantiques' => true, + 'americanart' => true, + 'amsterdam' => true, + 'and' => true, + 'annefrank' => true, + 'anthro' => true, + 'anthropology' => true, + 'antiques' => true, + 'aquarium' => true, + 'arboretum' => true, + 'archaeological' => true, + 'archaeology' => true, + 'architecture' => true, + 'art' => true, + 'artanddesign' => true, + 'artcenter' => true, + 'artdeco' => true, + 'arteducation' => true, + 'artgallery' => true, + 'arts' => true, + 'artsandcrafts' => true, + 'asmatart' => true, + 'assassination' => true, + 'assisi' => true, + 'association' => true, + 'astronomy' => true, + 'atlanta' => true, + 'austin' => true, + 'australia' => true, + 'automotive' => true, + 'aviation' => true, + 'axis' => true, + 'badajoz' => true, + 'baghdad' => true, + 'bahn' => true, + 'bale' => true, + 'baltimore' => true, + 'barcelona' => true, + 'baseball' => true, + 'basel' => true, + 'baths' => true, + 'bauern' => true, + 'beauxarts' => true, + 'beeldengeluid' => true, + 'bellevue' => true, + 'bergbau' => true, + 'berkeley' => true, + 'berlin' => true, + 'bern' => true, + 'bible' => true, + 'bilbao' => true, + 'bill' => true, + 'birdart' => true, + 'birthplace' => true, + 'bonn' => true, + 'boston' => true, + 'botanical' => true, + 'botanicalgarden' => true, + 'botanicgarden' => true, + 'botany' => true, + 'brandywinevalley' => true, + 'brasil' => true, + 'bristol' => true, + 'british' => true, + 'britishcolumbia' => true, + 'broadcast' => true, + 'brunel' => true, + 'brussel' => true, + 'brussels' => true, + 'bruxelles' => true, + 'building' => true, + 'burghof' => true, + 'bus' => true, + 'bushey' => true, + 'cadaques' => true, + 'california' => true, + 'cambridge' => true, + 'can' => true, + 'canada' => true, + 'capebreton' => true, + 'carrier' => true, + 'cartoonart' => true, + 'casadelamoneda' => true, + 'castle' => true, + 'castres' => true, + 'celtic' => true, + 'center' => true, + 'chattanooga' => true, + 'cheltenham' => true, + 'chesapeakebay' => true, + 'chicago' => true, + 'children' => true, + 'childrens' => true, + 'childrensgarden' => true, + 'chiropractic' => true, + 'chocolate' => true, + 'christiansburg' => true, + 'cincinnati' => true, + 'cinema' => true, + 'circus' => true, + 'civilisation' => true, + 'civilization' => true, + 'civilwar' => true, + 'clinton' => true, + 'clock' => true, + 'coal' => true, + 'coastaldefence' => true, + 'cody' => true, + 'coldwar' => true, + 'collection' => true, + 'colonialwilliamsburg' => true, + 'coloradoplateau' => true, + 'columbia' => true, + 'columbus' => true, + 'communication' => true, + 'communications' => true, + 'community' => true, + 'computer' => true, + 'computerhistory' => true, + 'comunicações' => true, + 'contemporary' => true, + 'contemporaryart' => true, + 'convent' => true, + 'copenhagen' => true, + 'corporation' => true, + 'correios-e-telecomunicações' => true, + 'corvette' => true, + 'costume' => true, + 'countryestate' => true, + 'county' => true, + 'crafts' => true, + 'cranbrook' => true, + 'creation' => true, + 'cultural' => true, + 'culturalcenter' => true, + 'culture' => true, + 'cyber' => true, + 'cymru' => true, + 'dali' => true, + 'dallas' => true, + 'database' => true, + 'ddr' => true, + 'decorativearts' => true, + 'delaware' => true, + 'delmenhorst' => true, + 'denmark' => true, + 'depot' => true, + 'design' => true, + 'detroit' => true, + 'dinosaur' => true, + 'discovery' => true, + 'dolls' => true, + 'donostia' => true, + 'durham' => true, + 'eastafrica' => true, + 'eastcoast' => true, + 'education' => true, + 'educational' => true, + 'egyptian' => true, + 'eisenbahn' => true, + 'elburg' => true, + 'elvendrell' => true, + 'embroidery' => true, + 'encyclopedic' => true, + 'england' => true, + 'entomology' => true, + 'environment' => true, + 'environmentalconservation' => true, + 'epilepsy' => true, + 'essex' => true, + 'estate' => true, + 'ethnology' => true, + 'exeter' => true, + 'exhibition' => true, + 'family' => true, + 'farm' => true, + 'farmequipment' => true, + 'farmers' => true, + 'farmstead' => true, + 'field' => true, + 'figueres' => true, + 'filatelia' => true, + 'film' => true, + 'fineart' => true, + 'finearts' => true, + 'finland' => true, + 'flanders' => true, + 'florida' => true, + 'force' => true, + 'fortmissoula' => true, + 'fortworth' => true, + 'foundation' => true, + 'francaise' => true, + 'frankfurt' => true, + 'franziskaner' => true, + 'freemasonry' => true, + 'freiburg' => true, + 'fribourg' => true, + 'frog' => true, + 'fundacio' => true, + 'furniture' => true, + 'gallery' => true, + 'garden' => true, + 'gateway' => true, + 'geelvinck' => true, + 'gemological' => true, + 'geology' => true, + 'georgia' => true, + 'giessen' => true, + 'glas' => true, + 'glass' => true, + 'gorge' => true, + 'grandrapids' => true, + 'graz' => true, + 'guernsey' => true, + 'halloffame' => true, + 'hamburg' => true, + 'handson' => true, + 'harvestcelebration' => true, + 'hawaii' => true, + 'health' => true, + 'heimatunduhren' => true, + 'hellas' => true, + 'helsinki' => true, + 'hembygdsforbund' => true, + 'heritage' => true, + 'histoire' => true, + 'historical' => true, + 'historicalsociety' => true, + 'historichouses' => true, + 'historisch' => true, + 'historisches' => true, + 'history' => true, + 'historyofscience' => true, + 'horology' => true, + 'house' => true, + 'humanities' => true, + 'illustration' => true, + 'imageandsound' => true, + 'indian' => true, + 'indiana' => true, + 'indianapolis' => true, + 'indianmarket' => true, + 'intelligence' => true, + 'interactive' => true, + 'iraq' => true, + 'iron' => true, + 'isleofman' => true, + 'jamison' => true, + 'jefferson' => true, + 'jerusalem' => true, + 'jewelry' => true, + 'jewish' => true, + 'jewishart' => true, + 'jfk' => true, + 'journalism' => true, + 'judaica' => true, + 'judygarland' => true, + 'juedisches' => true, + 'juif' => true, + 'karate' => true, + 'karikatur' => true, + 'kids' => true, + 'koebenhavn' => true, + 'koeln' => true, + 'kunst' => true, + 'kunstsammlung' => true, + 'kunstunddesign' => true, + 'labor' => true, + 'labour' => true, + 'lajolla' => true, + 'lancashire' => true, + 'landes' => true, + 'lans' => true, + 'läns' => true, + 'larsson' => true, + 'lewismiller' => true, + 'lincoln' => true, + 'linz' => true, + 'living' => true, + 'livinghistory' => true, + 'localhistory' => true, + 'london' => true, + 'losangeles' => true, + 'louvre' => true, + 'loyalist' => true, + 'lucerne' => true, + 'luxembourg' => true, + 'luzern' => true, + 'mad' => true, + 'madrid' => true, + 'mallorca' => true, + 'manchester' => true, + 'mansion' => true, + 'mansions' => true, + 'manx' => true, + 'marburg' => true, + 'maritime' => true, + 'maritimo' => true, + 'maryland' => true, + 'marylhurst' => true, + 'media' => true, + 'medical' => true, + 'medizinhistorisches' => true, + 'meeres' => true, + 'memorial' => true, + 'mesaverde' => true, + 'michigan' => true, + 'midatlantic' => true, + 'military' => true, + 'mill' => true, + 'miners' => true, + 'mining' => true, + 'minnesota' => true, + 'missile' => true, + 'missoula' => true, + 'modern' => true, + 'moma' => true, + 'money' => true, + 'monmouth' => true, + 'monticello' => true, + 'montreal' => true, + 'moscow' => true, + 'motorcycle' => true, + 'muenchen' => true, + 'muenster' => true, + 'mulhouse' => true, + 'muncie' => true, + 'museet' => true, + 'museumcenter' => true, + 'museumvereniging' => true, + 'music' => true, + 'national' => true, + 'nationalfirearms' => true, + 'nationalheritage' => true, + 'nativeamerican' => true, + 'naturalhistory' => true, + 'naturalhistorymuseum' => true, + 'naturalsciences' => true, + 'nature' => true, + 'naturhistorisches' => true, + 'natuurwetenschappen' => true, + 'naumburg' => true, + 'naval' => true, + 'nebraska' => true, + 'neues' => true, + 'newhampshire' => true, + 'newjersey' => true, + 'newmexico' => true, + 'newport' => true, + 'newspaper' => true, + 'newyork' => true, + 'niepce' => true, + 'norfolk' => true, + 'north' => true, + 'nrw' => true, + 'nuernberg' => true, + 'nuremberg' => true, + 'nyc' => true, + 'nyny' => true, + 'oceanographic' => true, + 'oceanographique' => true, + 'omaha' => true, + 'online' => true, + 'ontario' => true, + 'openair' => true, + 'oregon' => true, + 'oregontrail' => true, + 'otago' => true, + 'oxford' => true, + 'pacific' => true, + 'paderborn' => true, + 'palace' => true, + 'paleo' => true, + 'palmsprings' => true, + 'panama' => true, + 'paris' => true, + 'pasadena' => true, + 'pharmacy' => true, + 'philadelphia' => true, + 'philadelphiaarea' => true, + 'philately' => true, + 'phoenix' => true, + 'photography' => true, + 'pilots' => true, + 'pittsburgh' => true, + 'planetarium' => true, + 'plantation' => true, + 'plants' => true, + 'plaza' => true, + 'portal' => true, + 'portland' => true, + 'portlligat' => true, + 'posts-and-telecommunications' => true, + 'preservation' => true, + 'presidio' => true, + 'press' => true, + 'project' => true, + 'public' => true, + 'pubol' => true, + 'quebec' => true, + 'railroad' => true, + 'railway' => true, + 'research' => true, + 'resistance' => true, + 'riodejaneiro' => true, + 'rochester' => true, + 'rockart' => true, + 'roma' => true, + 'russia' => true, + 'saintlouis' => true, + 'salem' => true, + 'salvadordali' => true, + 'salzburg' => true, + 'sandiego' => true, + 'sanfrancisco' => true, + 'santabarbara' => true, + 'santacruz' => true, + 'santafe' => true, + 'saskatchewan' => true, + 'satx' => true, + 'savannahga' => true, + 'schlesisches' => true, + 'schoenbrunn' => true, + 'schokoladen' => true, + 'school' => true, + 'schweiz' => true, + 'science' => true, + 'scienceandhistory' => true, + 'scienceandindustry' => true, + 'sciencecenter' => true, + 'sciencecenters' => true, + 'science-fiction' => true, + 'sciencehistory' => true, + 'sciences' => true, + 'sciencesnaturelles' => true, + 'scotland' => true, + 'seaport' => true, + 'settlement' => true, + 'settlers' => true, + 'shell' => true, + 'sherbrooke' => true, + 'sibenik' => true, + 'silk' => true, + 'ski' => true, + 'skole' => true, + 'society' => true, + 'sologne' => true, + 'soundandvision' => true, + 'southcarolina' => true, + 'southwest' => true, + 'space' => true, + 'spy' => true, + 'square' => true, + 'stadt' => true, + 'stalbans' => true, + 'starnberg' => true, + 'state' => true, + 'stateofdelaware' => true, + 'station' => true, + 'steam' => true, + 'steiermark' => true, + 'stjohn' => true, + 'stockholm' => true, + 'stpetersburg' => true, + 'stuttgart' => true, + 'suisse' => true, + 'surgeonshall' => true, + 'surrey' => true, + 'svizzera' => true, + 'sweden' => true, + 'sydney' => true, + 'tank' => true, + 'tcm' => true, + 'technology' => true, + 'telekommunikation' => true, + 'television' => true, + 'texas' => true, + 'textile' => true, + 'theater' => true, + 'time' => true, + 'timekeeping' => true, + 'topology' => true, + 'torino' => true, + 'touch' => true, + 'town' => true, + 'transport' => true, + 'tree' => true, + 'trolley' => true, + 'trust' => true, + 'trustee' => true, + 'uhren' => true, + 'ulm' => true, + 'undersea' => true, + 'university' => true, + 'usa' => true, + 'usantiques' => true, + 'usarts' => true, + 'uscountryestate' => true, + 'usculture' => true, + 'usdecorativearts' => true, + 'usgarden' => true, + 'ushistory' => true, + 'ushuaia' => true, + 'uslivinghistory' => true, + 'utah' => true, + 'uvic' => true, + 'valley' => true, + 'vantaa' => true, + 'versailles' => true, + 'viking' => true, + 'village' => true, + 'virginia' => true, + 'virtual' => true, + 'virtuel' => true, + 'vlaanderen' => true, + 'volkenkunde' => true, + 'wales' => true, + 'wallonie' => true, + 'war' => true, + 'washingtondc' => true, + 'watchandclock' => true, + 'watch-and-clock' => true, + 'western' => true, + 'westfalen' => true, + 'whaling' => true, + 'wildlife' => true, + 'williamsburg' => true, + 'windmill' => true, + 'workshop' => true, + 'york' => true, + 'yorkshire' => true, + 'yosemite' => true, + 'youth' => true, + 'zoological' => true, + 'zoology' => true, + 'ירושלים' => true, + 'иком' => true + ), + 'mv' => array( + 'aero' => true, + 'biz' => true, + 'com' => true, + 'coop' => true, + 'edu' => true, + 'gov' => true, + 'info' => true, + 'int' => true, + 'mil' => true, + 'museum' => true, + 'name' => true, + 'net' => true, + 'org' => true, + 'pro' => true + ), + 'mw' => array( + 'ac' => true, + 'biz' => true, + 'co' => true, + 'com' => true, + 'coop' => true, + 'edu' => true, + 'gov' => true, + 'int' => true, + 'museum' => true, + 'net' => true, + 'org' => true + ), + 'mx' => array( + 'com' => true, + 'org' => true, + 'gob' => true, + 'edu' => true, + 'net' => true, + 'blogspot' => true + ), + 'my' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'edu' => true, + 'mil' => true, + 'name' => true + ), + 'mz' => array( + '*' => true, + '!teledata' => true + ), + 'na' => array( + 'info' => true, + 'pro' => true, + 'name' => true, + 'school' => true, + 'or' => true, + 'dr' => true, + 'us' => true, + 'mx' => true, + 'ca' => true, + 'in' => true, + 'cc' => true, + 'tv' => true, + 'ws' => true, + 'mobi' => true, + 'co' => true, + 'com' => true, + 'org' => true + ), + 'name' => array( + 'her' => array( + 'forgot' => true + ), + 'his' => array( + 'forgot' => true + ) + ), + 'nc' => array( + 'asso' => true + ), + 'ne' => true, + 'net' => array( + 'cloudfront' => true, + 'gb' => true, + 'hu' => true, + 'jp' => true, + 'se' => true, + 'uk' => true, + 'at-band-camp' => true, + 'blogdns' => true, + 'broke-it' => true, + 'buyshouses' => true, + 'dnsalias' => true, + 'dnsdojo' => true, + 'does-it' => true, + 'dontexist' => true, + 'dynalias' => true, + 'dynathome' => true, + 'endofinternet' => true, + 'from-az' => true, + 'from-co' => true, + 'from-la' => true, + 'from-ny' => true, + 'gets-it' => true, + 'ham-radio-op' => true, + 'homeftp' => true, + 'homeip' => true, + 'homelinux' => true, + 'homeunix' => true, + 'in-the-band' => true, + 'is-a-chef' => true, + 'is-a-geek' => true, + 'isa-geek' => true, + 'kicks-ass' => true, + 'office-on-the' => true, + 'podzone' => true, + 'scrapper-site' => true, + 'selfip' => true, + 'sells-it' => true, + 'servebbs' => true, + 'serveftp' => true, + 'thruhere' => true, + 'webhop' => true, + 'fastly' => array( + 'ssl' => array( + 'a' => true, + 'b' => true, + 'global' => true + ), + 'prod' => array( + 'a' => true, + 'global' => true + ) + ), + 'za' => true + ), + 'nf' => array( + 'com' => true, + 'net' => true, + 'per' => true, + 'rec' => true, + 'web' => true, + 'arts' => true, + 'firm' => true, + 'info' => true, + 'other' => true, + 'store' => true + ), + 'ng' => array( + 'com' => true, + 'edu' => true, + 'name' => true, + 'net' => true, + 'org' => true, + 'sch' => true, + 'gov' => true, + 'mil' => true, + 'mobi' => true + ), + 'ni' => array( + '*' => true + ), + 'nl' => array( + 'bv' => true, + 'co' => true, + 'blogspot' => true + ), + 'no' => array( + 'fhs' => true, + 'vgs' => true, + 'fylkesbibl' => true, + 'folkebibl' => true, + 'museum' => true, + 'idrett' => true, + 'priv' => true, + 'mil' => true, + 'stat' => true, + 'dep' => true, + 'kommune' => true, + 'herad' => true, + 'aa' => array( + 'gs' => true + ), + 'ah' => array( + 'gs' => true + ), + 'bu' => array( + 'gs' => true + ), + 'fm' => array( + 'gs' => true + ), + 'hl' => array( + 'gs' => true + ), + 'hm' => array( + 'gs' => true + ), + 'jan-mayen' => array( + 'gs' => true + ), + 'mr' => array( + 'gs' => true + ), + 'nl' => array( + 'gs' => true + ), + 'nt' => array( + 'gs' => true + ), + 'of' => array( + 'gs' => true + ), + 'ol' => array( + 'gs' => true + ), + 'oslo' => array( + 'gs' => true + ), + 'rl' => array( + 'gs' => true + ), + 'sf' => array( + 'gs' => true + ), + 'st' => array( + 'gs' => true + ), + 'svalbard' => array( + 'gs' => true + ), + 'tm' => array( + 'gs' => true + ), + 'tr' => array( + 'gs' => true + ), + 'va' => array( + 'gs' => true + ), + 'vf' => array( + 'gs' => true + ), + 'akrehamn' => true, + 'åkrehamn' => true, + 'algard' => true, + 'ålgård' => true, + 'arna' => true, + 'brumunddal' => true, + 'bryne' => true, + 'bronnoysund' => true, + 'brønnøysund' => true, + 'drobak' => true, + 'drøbak' => true, + 'egersund' => true, + 'fetsund' => true, + 'floro' => true, + 'florø' => true, + 'fredrikstad' => true, + 'hokksund' => true, + 'honefoss' => true, + 'hønefoss' => true, + 'jessheim' => true, + 'jorpeland' => true, + 'jørpeland' => true, + 'kirkenes' => true, + 'kopervik' => true, + 'krokstadelva' => true, + 'langevag' => true, + 'langevåg' => true, + 'leirvik' => true, + 'mjondalen' => true, + 'mjøndalen' => true, + 'mo-i-rana' => true, + 'mosjoen' => true, + 'mosjøen' => true, + 'nesoddtangen' => true, + 'orkanger' => true, + 'osoyro' => true, + 'osøyro' => true, + 'raholt' => true, + 'råholt' => true, + 'sandnessjoen' => true, + 'sandnessjøen' => true, + 'skedsmokorset' => true, + 'slattum' => true, + 'spjelkavik' => true, + 'stathelle' => true, + 'stavern' => true, + 'stjordalshalsen' => true, + 'stjørdalshalsen' => true, + 'tananger' => true, + 'tranby' => true, + 'vossevangen' => true, + 'afjord' => true, + 'åfjord' => true, + 'agdenes' => true, + 'al' => true, + 'ål' => true, + 'alesund' => true, + 'ålesund' => true, + 'alstahaug' => true, + 'alta' => true, + 'áltá' => true, + 'alaheadju' => true, + 'álaheadju' => true, + 'alvdal' => true, + 'amli' => true, + 'åmli' => true, + 'amot' => true, + 'åmot' => true, + 'andebu' => true, + 'andoy' => true, + 'andøy' => true, + 'andasuolo' => true, + 'ardal' => true, + 'årdal' => true, + 'aremark' => true, + 'arendal' => true, + 'ås' => true, + 'aseral' => true, + 'åseral' => true, + 'asker' => true, + 'askim' => true, + 'askvoll' => true, + 'askoy' => true, + 'askøy' => true, + 'asnes' => true, + 'åsnes' => true, + 'audnedaln' => true, + 'aukra' => true, + 'aure' => true, + 'aurland' => true, + 'aurskog-holand' => true, + 'aurskog-høland' => true, + 'austevoll' => true, + 'austrheim' => true, + 'averoy' => true, + 'averøy' => true, + 'balestrand' => true, + 'ballangen' => true, + 'balat' => true, + 'bálát' => true, + 'balsfjord' => true, + 'bahccavuotna' => true, + 'báhccavuotna' => true, + 'bamble' => true, + 'bardu' => true, + 'beardu' => true, + 'beiarn' => true, + 'bajddar' => true, + 'bájddar' => true, + 'baidar' => true, + 'báidár' => true, + 'berg' => true, + 'bergen' => true, + 'berlevag' => true, + 'berlevåg' => true, + 'bearalvahki' => true, + 'bearalváhki' => true, + 'bindal' => true, + 'birkenes' => true, + 'bjarkoy' => true, + 'bjarkøy' => true, + 'bjerkreim' => true, + 'bjugn' => true, + 'bodo' => true, + 'bodø' => true, + 'badaddja' => true, + 'bådåddjå' => true, + 'budejju' => true, + 'bokn' => true, + 'bremanger' => true, + 'bronnoy' => true, + 'brønnøy' => true, + 'bygland' => true, + 'bykle' => true, + 'barum' => true, + 'bærum' => true, + 'telemark' => array( + 'bo' => true, + 'bø' => true + ), + 'nordland' => array( + 'bo' => true, + 'bø' => true, + 'heroy' => true, + 'herøy' => true + ), + 'bievat' => true, + 'bievát' => true, + 'bomlo' => true, + 'bømlo' => true, + 'batsfjord' => true, + 'båtsfjord' => true, + 'bahcavuotna' => true, + 'báhcavuotna' => true, + 'dovre' => true, + 'drammen' => true, + 'drangedal' => true, + 'dyroy' => true, + 'dyrøy' => true, + 'donna' => true, + 'dønna' => true, + 'eid' => true, + 'eidfjord' => true, + 'eidsberg' => true, + 'eidskog' => true, + 'eidsvoll' => true, + 'eigersund' => true, + 'elverum' => true, + 'enebakk' => true, + 'engerdal' => true, + 'etne' => true, + 'etnedal' => true, + 'evenes' => true, + 'evenassi' => true, + 'evenášši' => true, + 'evje-og-hornnes' => true, + 'farsund' => true, + 'fauske' => true, + 'fuossko' => true, + 'fuoisku' => true, + 'fedje' => true, + 'fet' => true, + 'finnoy' => true, + 'finnøy' => true, + 'fitjar' => true, + 'fjaler' => true, + 'fjell' => true, + 'flakstad' => true, + 'flatanger' => true, + 'flekkefjord' => true, + 'flesberg' => true, + 'flora' => true, + 'fla' => true, + 'flå' => true, + 'folldal' => true, + 'forsand' => true, + 'fosnes' => true, + 'frei' => true, + 'frogn' => true, + 'froland' => true, + 'frosta' => true, + 'frana' => true, + 'fræna' => true, + 'froya' => true, + 'frøya' => true, + 'fusa' => true, + 'fyresdal' => true, + 'forde' => true, + 'førde' => true, + 'gamvik' => true, + 'gangaviika' => true, + 'gáŋgaviika' => true, + 'gaular' => true, + 'gausdal' => true, + 'gildeskal' => true, + 'gildeskål' => true, + 'giske' => true, + 'gjemnes' => true, + 'gjerdrum' => true, + 'gjerstad' => true, + 'gjesdal' => true, + 'gjovik' => true, + 'gjøvik' => true, + 'gloppen' => true, + 'gol' => true, + 'gran' => true, + 'grane' => true, + 'granvin' => true, + 'gratangen' => true, + 'grimstad' => true, + 'grong' => true, + 'kraanghke' => true, + 'kråanghke' => true, + 'grue' => true, + 'gulen' => true, + 'hadsel' => true, + 'halden' => true, + 'halsa' => true, + 'hamar' => true, + 'hamaroy' => true, + 'habmer' => true, + 'hábmer' => true, + 'hapmir' => true, + 'hápmir' => true, + 'hammerfest' => true, + 'hammarfeasta' => true, + 'hámmárfeasta' => true, + 'haram' => true, + 'hareid' => true, + 'harstad' => true, + 'hasvik' => true, + 'aknoluokta' => true, + 'ákŋoluokta' => true, + 'hattfjelldal' => true, + 'aarborte' => true, + 'haugesund' => true, + 'hemne' => true, + 'hemnes' => true, + 'hemsedal' => true, + 'more-og-romsdal' => array( + 'heroy' => true, + 'sande' => true + ), + 'møre-og-romsdal' => array( + 'herøy' => true, + 'sande' => true + ), + 'hitra' => true, + 'hjartdal' => true, + 'hjelmeland' => true, + 'hobol' => true, + 'hobøl' => true, + 'hof' => true, + 'hol' => true, + 'hole' => true, + 'holmestrand' => true, + 'holtalen' => true, + 'holtålen' => true, + 'hornindal' => true, + 'horten' => true, + 'hurdal' => true, + 'hurum' => true, + 'hvaler' => true, + 'hyllestad' => true, + 'hagebostad' => true, + 'hægebostad' => true, + 'hoyanger' => true, + 'høyanger' => true, + 'hoylandet' => true, + 'høylandet' => true, + 'ha' => true, + 'hå' => true, + 'ibestad' => true, + 'inderoy' => true, + 'inderøy' => true, + 'iveland' => true, + 'jevnaker' => true, + 'jondal' => true, + 'jolster' => true, + 'jølster' => true, + 'karasjok' => true, + 'karasjohka' => true, + 'kárášjohka' => true, + 'karlsoy' => true, + 'galsa' => true, + 'gálsá' => true, + 'karmoy' => true, + 'karmøy' => true, + 'kautokeino' => true, + 'guovdageaidnu' => true, + 'klepp' => true, + 'klabu' => true, + 'klæbu' => true, + 'kongsberg' => true, + 'kongsvinger' => true, + 'kragero' => true, + 'kragerø' => true, + 'kristiansand' => true, + 'kristiansund' => true, + 'krodsherad' => true, + 'krødsherad' => true, + 'kvalsund' => true, + 'rahkkeravju' => true, + 'ráhkkerávju' => true, + 'kvam' => true, + 'kvinesdal' => true, + 'kvinnherad' => true, + 'kviteseid' => true, + 'kvitsoy' => true, + 'kvitsøy' => true, + 'kvafjord' => true, + 'kvæfjord' => true, + 'giehtavuoatna' => true, + 'kvanangen' => true, + 'kvænangen' => true, + 'navuotna' => true, + 'návuotna' => true, + 'kafjord' => true, + 'kåfjord' => true, + 'gaivuotna' => true, + 'gáivuotna' => true, + 'larvik' => true, + 'lavangen' => true, + 'lavagis' => true, + 'loabat' => true, + 'loabát' => true, + 'lebesby' => true, + 'davvesiida' => true, + 'leikanger' => true, + 'leirfjord' => true, + 'leka' => true, + 'leksvik' => true, + 'lenvik' => true, + 'leangaviika' => true, + 'leaŋgaviika' => true, + 'lesja' => true, + 'levanger' => true, + 'lier' => true, + 'lierne' => true, + 'lillehammer' => true, + 'lillesand' => true, + 'lindesnes' => true, + 'lindas' => true, + 'lindås' => true, + 'lom' => true, + 'loppa' => true, + 'lahppi' => true, + 'láhppi' => true, + 'lund' => true, + 'lunner' => true, + 'luroy' => true, + 'lurøy' => true, + 'luster' => true, + 'lyngdal' => true, + 'lyngen' => true, + 'ivgu' => true, + 'lardal' => true, + 'lerdal' => true, + 'lærdal' => true, + 'lodingen' => true, + 'lødingen' => true, + 'lorenskog' => true, + 'lørenskog' => true, + 'loten' => true, + 'løten' => true, + 'malvik' => true, + 'masoy' => true, + 'måsøy' => true, + 'muosat' => true, + 'muosát' => true, + 'mandal' => true, + 'marker' => true, + 'marnardal' => true, + 'masfjorden' => true, + 'meland' => true, + 'meldal' => true, + 'melhus' => true, + 'meloy' => true, + 'meløy' => true, + 'meraker' => true, + 'meråker' => true, + 'moareke' => true, + 'moåreke' => true, + 'midsund' => true, + 'midtre-gauldal' => true, + 'modalen' => true, + 'modum' => true, + 'molde' => true, + 'moskenes' => true, + 'moss' => true, + 'mosvik' => true, + 'malselv' => true, + 'målselv' => true, + 'malatvuopmi' => true, + 'málatvuopmi' => true, + 'namdalseid' => true, + 'aejrie' => true, + 'namsos' => true, + 'namsskogan' => true, + 'naamesjevuemie' => true, + 'nååmesjevuemie' => true, + 'laakesvuemie' => true, + 'nannestad' => true, + 'narvik' => true, + 'narviika' => true, + 'naustdal' => true, + 'nedre-eiker' => true, + 'akershus' => array( + 'nes' => true + ), + 'buskerud' => array( + 'nes' => true + ), + 'nesna' => true, + 'nesodden' => true, + 'nesseby' => true, + 'unjarga' => true, + 'unjárga' => true, + 'nesset' => true, + 'nissedal' => true, + 'nittedal' => true, + 'nord-aurdal' => true, + 'nord-fron' => true, + 'nord-odal' => true, + 'norddal' => true, + 'nordkapp' => true, + 'davvenjarga' => true, + 'davvenjárga' => true, + 'nordre-land' => true, + 'nordreisa' => true, + 'raisa' => true, + 'ráisa' => true, + 'nore-og-uvdal' => true, + 'notodden' => true, + 'naroy' => true, + 'nærøy' => true, + 'notteroy' => true, + 'nøtterøy' => true, + 'odda' => true, + 'oksnes' => true, + 'øksnes' => true, + 'oppdal' => true, + 'oppegard' => true, + 'oppegård' => true, + 'orkdal' => true, + 'orland' => true, + 'ørland' => true, + 'orskog' => true, + 'ørskog' => true, + 'orsta' => true, + 'ørsta' => true, + 'hedmark' => array( + 'os' => true, + 'valer' => true, + 'våler' => true + ), + 'hordaland' => array( + 'os' => true + ), + 'osen' => true, + 'osteroy' => true, + 'osterøy' => true, + 'ostre-toten' => true, + 'østre-toten' => true, + 'overhalla' => true, + 'ovre-eiker' => true, + 'øvre-eiker' => true, + 'oyer' => true, + 'øyer' => true, + 'oygarden' => true, + 'øygarden' => true, + 'oystre-slidre' => true, + 'øystre-slidre' => true, + 'porsanger' => true, + 'porsangu' => true, + 'porsáŋgu' => true, + 'porsgrunn' => true, + 'radoy' => true, + 'radøy' => true, + 'rakkestad' => true, + 'rana' => true, + 'ruovat' => true, + 'randaberg' => true, + 'rauma' => true, + 'rendalen' => true, + 'rennebu' => true, + 'rennesoy' => true, + 'rennesøy' => true, + 'rindal' => true, + 'ringebu' => true, + 'ringerike' => true, + 'ringsaker' => true, + 'rissa' => true, + 'risor' => true, + 'risør' => true, + 'roan' => true, + 'rollag' => true, + 'rygge' => true, + 'ralingen' => true, + 'rælingen' => true, + 'rodoy' => true, + 'rødøy' => true, + 'romskog' => true, + 'rømskog' => true, + 'roros' => true, + 'røros' => true, + 'rost' => true, + 'røst' => true, + 'royken' => true, + 'røyken' => true, + 'royrvik' => true, + 'røyrvik' => true, + 'rade' => true, + 'råde' => true, + 'salangen' => true, + 'siellak' => true, + 'saltdal' => true, + 'salat' => true, + 'sálát' => true, + 'sálat' => true, + 'samnanger' => true, + 'vestfold' => array( + 'sande' => true + ), + 'sandefjord' => true, + 'sandnes' => true, + 'sandoy' => true, + 'sandøy' => true, + 'sarpsborg' => true, + 'sauda' => true, + 'sauherad' => true, + 'sel' => true, + 'selbu' => true, + 'selje' => true, + 'seljord' => true, + 'sigdal' => true, + 'siljan' => true, + 'sirdal' => true, + 'skaun' => true, + 'skedsmo' => true, + 'ski' => true, + 'skien' => true, + 'skiptvet' => true, + 'skjervoy' => true, + 'skjervøy' => true, + 'skierva' => true, + 'skiervá' => true, + 'skjak' => true, + 'skjåk' => true, + 'skodje' => true, + 'skanland' => true, + 'skånland' => true, + 'skanit' => true, + 'skánit' => true, + 'smola' => true, + 'smøla' => true, + 'snillfjord' => true, + 'snasa' => true, + 'snåsa' => true, + 'snoasa' => true, + 'snaase' => true, + 'snåase' => true, + 'sogndal' => true, + 'sokndal' => true, + 'sola' => true, + 'solund' => true, + 'songdalen' => true, + 'sortland' => true, + 'spydeberg' => true, + 'stange' => true, + 'stavanger' => true, + 'steigen' => true, + 'steinkjer' => true, + 'stjordal' => true, + 'stjørdal' => true, + 'stokke' => true, + 'stor-elvdal' => true, + 'stord' => true, + 'stordal' => true, + 'storfjord' => true, + 'omasvuotna' => true, + 'strand' => true, + 'stranda' => true, + 'stryn' => true, + 'sula' => true, + 'suldal' => true, + 'sund' => true, + 'sunndal' => true, + 'surnadal' => true, + 'sveio' => true, + 'svelvik' => true, + 'sykkylven' => true, + 'sogne' => true, + 'søgne' => true, + 'somna' => true, + 'sømna' => true, + 'sondre-land' => true, + 'søndre-land' => true, + 'sor-aurdal' => true, + 'sør-aurdal' => true, + 'sor-fron' => true, + 'sør-fron' => true, + 'sor-odal' => true, + 'sør-odal' => true, + 'sor-varanger' => true, + 'sør-varanger' => true, + 'matta-varjjat' => true, + 'mátta-várjjat' => true, + 'sorfold' => true, + 'sørfold' => true, + 'sorreisa' => true, + 'sørreisa' => true, + 'sorum' => true, + 'sørum' => true, + 'tana' => true, + 'deatnu' => true, + 'time' => true, + 'tingvoll' => true, + 'tinn' => true, + 'tjeldsund' => true, + 'dielddanuorri' => true, + 'tjome' => true, + 'tjøme' => true, + 'tokke' => true, + 'tolga' => true, + 'torsken' => true, + 'tranoy' => true, + 'tranøy' => true, + 'tromso' => true, + 'tromsø' => true, + 'tromsa' => true, + 'romsa' => true, + 'trondheim' => true, + 'troandin' => true, + 'trysil' => true, + 'trana' => true, + 'træna' => true, + 'trogstad' => true, + 'trøgstad' => true, + 'tvedestrand' => true, + 'tydal' => true, + 'tynset' => true, + 'tysfjord' => true, + 'divtasvuodna' => true, + 'divttasvuotna' => true, + 'tysnes' => true, + 'tysvar' => true, + 'tysvær' => true, + 'tonsberg' => true, + 'tønsberg' => true, + 'ullensaker' => true, + 'ullensvang' => true, + 'ulvik' => true, + 'utsira' => true, + 'vadso' => true, + 'vadsø' => true, + 'cahcesuolo' => true, + 'čáhcesuolo' => true, + 'vaksdal' => true, + 'valle' => true, + 'vang' => true, + 'vanylven' => true, + 'vardo' => true, + 'vardø' => true, + 'varggat' => true, + 'várggát' => true, + 'vefsn' => true, + 'vaapste' => true, + 'vega' => true, + 'vegarshei' => true, + 'vegårshei' => true, + 'vennesla' => true, + 'verdal' => true, + 'verran' => true, + 'vestby' => true, + 'vestnes' => true, + 'vestre-slidre' => true, + 'vestre-toten' => true, + 'vestvagoy' => true, + 'vestvågøy' => true, + 'vevelstad' => true, + 'vik' => true, + 'vikna' => true, + 'vindafjord' => true, + 'volda' => true, + 'voss' => true, + 'varoy' => true, + 'værøy' => true, + 'vagan' => true, + 'vågan' => true, + 'voagat' => true, + 'vagsoy' => true, + 'vågsøy' => true, + 'vaga' => true, + 'vågå' => true, + 'ostfold' => array( + 'valer' => true + ), + 'østfold' => array( + 'våler' => true + ), + 'co' => true, + 'blogspot' => true + ), + 'np' => array( + '*' => true + ), + 'nr' => array( + 'biz' => true, + 'info' => true, + 'gov' => true, + 'edu' => true, + 'org' => true, + 'net' => true, + 'com' => true + ), + 'nu' => array( + 'merseine' => true, + 'mine' => true, + 'shacknet' => true + ), + 'nz' => array( + '*' => true, + 'co' => array( + 'blogspot' => true + ) + ), + 'om' => array( + 'co' => true, + 'com' => true, + 'edu' => true, + 'gov' => true, + 'med' => true, + 'museum' => true, + 'net' => true, + 'org' => true, + 'pro' => true + ), + 'org' => array( + 'ae' => true, + 'us' => true, + 'dyndns' => array( + 'go' => true, + 'home' => true + ), + 'blogdns' => true, + 'blogsite' => true, + 'boldlygoingnowhere' => true, + 'dnsalias' => true, + 'dnsdojo' => true, + 'doesntexist' => true, + 'dontexist' => true, + 'doomdns' => true, + 'dvrdns' => true, + 'dynalias' => true, + 'endofinternet' => true, + 'endoftheinternet' => true, + 'from-me' => true, + 'game-host' => true, + 'gotdns' => true, + 'hobby-site' => true, + 'homedns' => true, + 'homeftp' => true, + 'homelinux' => true, + 'homeunix' => true, + 'is-a-bruinsfan' => true, + 'is-a-candidate' => true, + 'is-a-celticsfan' => true, + 'is-a-chef' => true, + 'is-a-geek' => true, + 'is-a-knight' => true, + 'is-a-linux-user' => true, + 'is-a-patsfan' => true, + 'is-a-soxfan' => true, + 'is-found' => true, + 'is-lost' => true, + 'is-saved' => true, + 'is-very-bad' => true, + 'is-very-evil' => true, + 'is-very-good' => true, + 'is-very-nice' => true, + 'is-very-sweet' => true, + 'isa-geek' => true, + 'kicks-ass' => true, + 'misconfused' => true, + 'podzone' => true, + 'readmyblog' => true, + 'selfip' => true, + 'sellsyourhome' => true, + 'servebbs' => true, + 'serveftp' => true, + 'servegame' => true, + 'stuff-4-sale' => true, + 'webhop' => true, + 'za' => true + ), + 'pa' => array( + 'ac' => true, + 'gob' => true, + 'com' => true, + 'org' => true, + 'sld' => true, + 'edu' => true, + 'net' => true, + 'ing' => true, + 'abo' => true, + 'med' => true, + 'nom' => true + ), + 'pe' => array( + 'edu' => true, + 'gob' => true, + 'nom' => true, + 'mil' => true, + 'org' => true, + 'com' => true, + 'net' => true + ), + 'pf' => array( + 'com' => true, + 'org' => true, + 'edu' => true + ), + 'pg' => array( + '*' => true + ), + 'ph' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'edu' => true, + 'ngo' => true, + 'mil' => true, + 'i' => true + ), + 'pk' => array( + 'com' => true, + 'net' => true, + 'edu' => true, + 'org' => true, + 'fam' => true, + 'biz' => true, + 'web' => true, + 'gov' => true, + 'gob' => true, + 'gok' => true, + 'gon' => true, + 'gop' => true, + 'gos' => true, + 'info' => true + ), + 'pl' => array( + 'aid' => true, + 'agro' => true, + 'atm' => true, + 'auto' => true, + 'biz' => true, + 'com' => true, + 'edu' => true, + 'gmina' => true, + 'gsm' => true, + 'info' => true, + 'mail' => true, + 'miasta' => true, + 'media' => true, + 'mil' => true, + 'net' => true, + 'nieruchomosci' => true, + 'nom' => true, + 'org' => true, + 'pc' => true, + 'powiat' => true, + 'priv' => true, + 'realestate' => true, + 'rel' => true, + 'sex' => true, + 'shop' => true, + 'sklep' => true, + 'sos' => true, + 'szkola' => true, + 'targi' => true, + 'tm' => true, + 'tourism' => true, + 'travel' => true, + 'turystyka' => true, + '6bone' => true, + 'art' => true, + 'mbone' => true, + 'gov' => array( + 'uw' => true, + 'um' => true, + 'ug' => true, + 'upow' => true, + 'starostwo' => true, + 'so' => true, + 'sr' => true, + 'po' => true, + 'pa' => true + ), + 'ngo' => true, + 'irc' => true, + 'usenet' => true, + 'augustow' => true, + 'babia-gora' => true, + 'bedzin' => true, + 'beskidy' => true, + 'bialowieza' => true, + 'bialystok' => true, + 'bielawa' => true, + 'bieszczady' => true, + 'boleslawiec' => true, + 'bydgoszcz' => true, + 'bytom' => true, + 'cieszyn' => true, + 'czeladz' => true, + 'czest' => true, + 'dlugoleka' => true, + 'elblag' => true, + 'elk' => true, + 'glogow' => true, + 'gniezno' => true, + 'gorlice' => true, + 'grajewo' => true, + 'ilawa' => true, + 'jaworzno' => true, + 'jelenia-gora' => true, + 'jgora' => true, + 'kalisz' => true, + 'kazimierz-dolny' => true, + 'karpacz' => true, + 'kartuzy' => true, + 'kaszuby' => true, + 'katowice' => true, + 'kepno' => true, + 'ketrzyn' => true, + 'klodzko' => true, + 'kobierzyce' => true, + 'kolobrzeg' => true, + 'konin' => true, + 'konskowola' => true, + 'kutno' => true, + 'lapy' => true, + 'lebork' => true, + 'legnica' => true, + 'lezajsk' => true, + 'limanowa' => true, + 'lomza' => true, + 'lowicz' => true, + 'lubin' => true, + 'lukow' => true, + 'malbork' => true, + 'malopolska' => true, + 'mazowsze' => true, + 'mazury' => true, + 'mielec' => true, + 'mielno' => true, + 'mragowo' => true, + 'naklo' => true, + 'nowaruda' => true, + 'nysa' => true, + 'olawa' => true, + 'olecko' => true, + 'olkusz' => true, + 'olsztyn' => true, + 'opoczno' => true, + 'opole' => true, + 'ostroda' => true, + 'ostroleka' => true, + 'ostrowiec' => true, + 'ostrowwlkp' => true, + 'pila' => true, + 'pisz' => true, + 'podhale' => true, + 'podlasie' => true, + 'polkowice' => true, + 'pomorze' => true, + 'pomorskie' => true, + 'prochowice' => true, + 'pruszkow' => true, + 'przeworsk' => true, + 'pulawy' => true, + 'radom' => true, + 'rawa-maz' => true, + 'rybnik' => true, + 'rzeszow' => true, + 'sanok' => true, + 'sejny' => true, + 'siedlce' => true, + 'slask' => true, + 'slupsk' => true, + 'sosnowiec' => true, + 'stalowa-wola' => true, + 'skoczow' => true, + 'starachowice' => true, + 'stargard' => true, + 'suwalki' => true, + 'swidnica' => true, + 'swiebodzin' => true, + 'swinoujscie' => true, + 'szczecin' => true, + 'szczytno' => true, + 'tarnobrzeg' => true, + 'tgory' => true, + 'turek' => true, + 'tychy' => true, + 'ustka' => true, + 'walbrzych' => true, + 'warmia' => true, + 'warszawa' => true, + 'waw' => true, + 'wegrow' => true, + 'wielun' => true, + 'wlocl' => true, + 'wloclawek' => true, + 'wodzislaw' => true, + 'wolomin' => true, + 'wroclaw' => true, + 'zachpomor' => true, + 'zagan' => true, + 'zarow' => true, + 'zgora' => true, + 'zgorzelec' => true, + 'gda' => true, + 'gdansk' => true, + 'gdynia' => true, + 'med' => true, + 'sopot' => true, + 'gliwice' => true, + 'krakow' => true, + 'poznan' => true, + 'wroc' => true, + 'zakopane' => true, + 'co' => true + ), + 'pm' => true, + 'pn' => array( + 'gov' => true, + 'co' => true, + 'org' => true, + 'edu' => true, + 'net' => true + ), + 'post' => true, + 'pr' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'edu' => true, + 'isla' => true, + 'pro' => true, + 'biz' => true, + 'info' => true, + 'name' => true, + 'est' => true, + 'prof' => true, + 'ac' => true + ), + 'pro' => array( + 'aca' => true, + 'bar' => true, + 'cpa' => true, + 'jur' => true, + 'law' => true, + 'med' => true, + 'eng' => true + ), + 'ps' => array( + 'edu' => true, + 'gov' => true, + 'sec' => true, + 'plo' => true, + 'com' => true, + 'org' => true, + 'net' => true + ), + 'pt' => array( + 'net' => true, + 'gov' => true, + 'org' => true, + 'edu' => true, + 'int' => true, + 'publ' => true, + 'com' => true, + 'nome' => true, + 'blogspot' => true + ), + 'pw' => array( + 'co' => true, + 'ne' => true, + 'or' => true, + 'ed' => true, + 'go' => true, + 'belau' => true + ), + 'py' => array( + 'com' => true, + 'coop' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'net' => true, + 'org' => true + ), + 'qa' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'name' => true, + 'net' => true, + 'org' => true, + 'sch' => true + ), + 're' => array( + 'com' => true, + 'asso' => true, + 'nom' => true, + 'blogspot' => true + ), + 'ro' => array( + 'com' => true, + 'org' => true, + 'tm' => true, + 'nt' => true, + 'nom' => true, + 'info' => true, + 'rec' => true, + 'arts' => true, + 'firm' => true, + 'store' => true, + 'www' => true, + 'blogspot' => true + ), + 'rs' => array( + 'co' => true, + 'org' => true, + 'edu' => true, + 'ac' => true, + 'gov' => true, + 'in' => true + ), + 'ru' => array( + 'ac' => true, + 'com' => true, + 'edu' => true, + 'int' => true, + 'net' => true, + 'org' => true, + 'pp' => true, + 'adygeya' => true, + 'altai' => true, + 'amur' => true, + 'arkhangelsk' => true, + 'astrakhan' => true, + 'bashkiria' => true, + 'belgorod' => true, + 'bir' => true, + 'bryansk' => true, + 'buryatia' => true, + 'cbg' => true, + 'chel' => true, + 'chelyabinsk' => true, + 'chita' => true, + 'chukotka' => true, + 'chuvashia' => true, + 'dagestan' => true, + 'dudinka' => true, + 'e-burg' => true, + 'grozny' => true, + 'irkutsk' => true, + 'ivanovo' => true, + 'izhevsk' => true, + 'jar' => true, + 'joshkar-ola' => true, + 'kalmykia' => true, + 'kaluga' => true, + 'kamchatka' => true, + 'karelia' => true, + 'kazan' => true, + 'kchr' => true, + 'kemerovo' => true, + 'khabarovsk' => true, + 'khakassia' => true, + 'khv' => true, + 'kirov' => true, + 'koenig' => true, + 'komi' => true, + 'kostroma' => true, + 'krasnoyarsk' => true, + 'kuban' => true, + 'kurgan' => true, + 'kursk' => true, + 'lipetsk' => true, + 'magadan' => true, + 'mari' => true, + 'mari-el' => true, + 'marine' => true, + 'mordovia' => true, + 'mosreg' => true, + 'msk' => true, + 'murmansk' => true, + 'nalchik' => true, + 'nnov' => true, + 'nov' => true, + 'novosibirsk' => true, + 'nsk' => true, + 'omsk' => true, + 'orenburg' => true, + 'oryol' => true, + 'palana' => true, + 'penza' => true, + 'perm' => true, + 'pskov' => true, + 'ptz' => true, + 'rnd' => true, + 'ryazan' => true, + 'sakhalin' => true, + 'samara' => true, + 'saratov' => true, + 'simbirsk' => true, + 'smolensk' => true, + 'spb' => true, + 'stavropol' => true, + 'stv' => true, + 'surgut' => true, + 'tambov' => true, + 'tatarstan' => true, + 'tom' => true, + 'tomsk' => true, + 'tsaritsyn' => true, + 'tsk' => true, + 'tula' => true, + 'tuva' => true, + 'tver' => true, + 'tyumen' => true, + 'udm' => true, + 'udmurtia' => true, + 'ulan-ude' => true, + 'vladikavkaz' => true, + 'vladimir' => true, + 'vladivostok' => true, + 'volgograd' => true, + 'vologda' => true, + 'voronezh' => true, + 'vrn' => true, + 'vyatka' => true, + 'yakutia' => true, + 'yamal' => true, + 'yaroslavl' => true, + 'yekaterinburg' => true, + 'yuzhno-sakhalinsk' => true, + 'amursk' => true, + 'baikal' => true, + 'cmw' => true, + 'fareast' => true, + 'jamal' => true, + 'kms' => true, + 'k-uralsk' => true, + 'kustanai' => true, + 'kuzbass' => true, + 'magnitka' => true, + 'mytis' => true, + 'nakhodka' => true, + 'nkz' => true, + 'norilsk' => true, + 'oskol' => true, + 'pyatigorsk' => true, + 'rubtsovsk' => true, + 'snz' => true, + 'syzran' => true, + 'vdonsk' => true, + 'zgrad' => true, + 'gov' => true, + 'mil' => true, + 'test' => true + ), + 'rw' => array( + 'gov' => true, + 'net' => true, + 'edu' => true, + 'ac' => true, + 'com' => true, + 'co' => true, + 'int' => true, + 'mil' => true, + 'gouv' => true + ), + 'sa' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'med' => true, + 'pub' => true, + 'edu' => true, + 'sch' => true + ), + 'sb' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'org' => true + ), + 'sc' => array( + 'com' => true, + 'gov' => true, + 'net' => true, + 'org' => true, + 'edu' => true + ), + 'sd' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'med' => true, + 'tv' => true, + 'gov' => true, + 'info' => true + ), + 'se' => array( + 'a' => true, + 'ac' => true, + 'b' => true, + 'bd' => true, + 'brand' => true, + 'c' => true, + 'd' => true, + 'e' => true, + 'f' => true, + 'fh' => true, + 'fhsk' => true, + 'fhv' => true, + 'g' => true, + 'h' => true, + 'i' => true, + 'k' => true, + 'komforb' => true, + 'kommunalforbund' => true, + 'komvux' => true, + 'l' => true, + 'lanbib' => true, + 'm' => true, + 'n' => true, + 'naturbruksgymn' => true, + 'o' => true, + 'org' => true, + 'p' => true, + 'parti' => true, + 'pp' => true, + 'press' => true, + 'r' => true, + 's' => true, + 'sshn' => true, + 't' => true, + 'tm' => true, + 'u' => true, + 'w' => true, + 'x' => true, + 'y' => true, + 'z' => true, + 'blogspot' => true + ), + 'sg' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'edu' => true, + 'per' => true, + 'blogspot' => true + ), + 'sh' => array( + 'com' => true, + 'net' => true, + 'gov' => true, + 'org' => true, + 'mil' => true + ), + 'si' => true, + 'sj' => true, + 'sk' => array( + 'blogspot' => true + ), + 'sl' => array( + 'com' => true, + 'net' => true, + 'edu' => true, + 'gov' => true, + 'org' => true + ), + 'sm' => true, + 'sn' => array( + 'art' => true, + 'com' => true, + 'edu' => true, + 'gouv' => true, + 'org' => true, + 'perso' => true, + 'univ' => true + ), + 'so' => array( + 'com' => true, + 'net' => true, + 'org' => true + ), + 'sr' => true, + 'st' => array( + 'co' => true, + 'com' => true, + 'consulado' => true, + 'edu' => true, + 'embaixada' => true, + 'gov' => true, + 'mil' => true, + 'net' => true, + 'org' => true, + 'principe' => true, + 'saotome' => true, + 'store' => true + ), + 'su' => true, + 'sv' => array( + 'com' => true, + 'edu' => true, + 'gob' => true, + 'org' => true, + 'red' => true + ), + 'sx' => array( + 'gov' => true + ), + 'sy' => array( + 'edu' => true, + 'gov' => true, + 'net' => true, + 'mil' => true, + 'com' => true, + 'org' => true + ), + 'sz' => array( + 'co' => true, + 'ac' => true, + 'org' => true + ), + 'tc' => true, + 'td' => array( + 'blogspot' => true + ), + 'tel' => true, + 'tf' => true, + 'tg' => true, + 'th' => array( + 'ac' => true, + 'co' => true, + 'go' => true, + 'in' => true, + 'mi' => true, + 'net' => true, + 'or' => true + ), + 'tj' => array( + 'ac' => true, + 'biz' => true, + 'co' => true, + 'com' => true, + 'edu' => true, + 'go' => true, + 'gov' => true, + 'int' => true, + 'mil' => true, + 'name' => true, + 'net' => true, + 'nic' => true, + 'org' => true, + 'test' => true, + 'web' => true + ), + 'tk' => true, + 'tl' => array( + 'gov' => true + ), + 'tm' => array( + 'com' => true, + 'co' => true, + 'org' => true, + 'net' => true, + 'nom' => true, + 'gov' => true, + 'mil' => true, + 'edu' => true + ), + 'tn' => array( + 'com' => true, + 'ens' => true, + 'fin' => true, + 'gov' => true, + 'ind' => true, + 'intl' => true, + 'nat' => true, + 'net' => true, + 'org' => true, + 'info' => true, + 'perso' => true, + 'tourism' => true, + 'edunet' => true, + 'rnrt' => true, + 'rns' => true, + 'rnu' => true, + 'mincom' => true, + 'agrinet' => true, + 'defense' => true, + 'turen' => true + ), + 'to' => array( + 'com' => true, + 'gov' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'mil' => true + ), + 'tp' => true, + 'tr' => array( + '*' => true, + '!nic' => true, + 'nc' => array( + 'gov' => true + ) + ), + 'travel' => true, + 'tt' => array( + 'co' => true, + 'com' => true, + 'org' => true, + 'net' => true, + 'biz' => true, + 'info' => true, + 'pro' => true, + 'int' => true, + 'coop' => true, + 'jobs' => true, + 'mobi' => true, + 'travel' => true, + 'museum' => true, + 'aero' => true, + 'name' => true, + 'gov' => true, + 'edu' => true + ), + 'tv' => array( + 'dyndns' => true, + 'better-than' => true, + 'on-the-web' => true, + 'worse-than' => true + ), + 'tw' => array( + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'com' => true, + 'net' => true, + 'org' => true, + 'idv' => true, + 'game' => true, + 'ebiz' => true, + 'club' => true, + '網路' => true, + '組織' => true, + '商業' => true, + 'blogspot' => true + ), + 'tz' => array( + 'ac' => true, + 'co' => true, + 'go' => true, + 'hotel' => true, + 'info' => true, + 'me' => true, + 'mil' => true, + 'mobi' => true, + 'ne' => true, + 'or' => true, + 'sc' => true, + 'tv' => true + ), + 'ua' => array( + 'com' => true, + 'edu' => true, + 'gov' => true, + 'in' => true, + 'net' => true, + 'org' => true, + 'cherkassy' => true, + 'cherkasy' => true, + 'chernigov' => true, + 'chernihiv' => true, + 'chernivtsi' => true, + 'chernovtsy' => true, + 'ck' => true, + 'cn' => true, + 'cr' => true, + 'crimea' => true, + 'cv' => true, + 'dn' => true, + 'dnepropetrovsk' => true, + 'dnipropetrovsk' => true, + 'dominic' => true, + 'donetsk' => true, + 'dp' => true, + 'if' => true, + 'ivano-frankivsk' => true, + 'kh' => true, + 'kharkiv' => true, + 'kharkov' => true, + 'kherson' => true, + 'khmelnitskiy' => true, + 'khmelnytskyi' => true, + 'kiev' => true, + 'kirovograd' => true, + 'km' => true, + 'kr' => true, + 'krym' => true, + 'ks' => true, + 'kv' => true, + 'kyiv' => true, + 'lg' => true, + 'lt' => true, + 'lugansk' => true, + 'lutsk' => true, + 'lv' => true, + 'lviv' => true, + 'mk' => true, + 'mykolaiv' => true, + 'nikolaev' => true, + 'od' => true, + 'odesa' => true, + 'odessa' => true, + 'pl' => true, + 'poltava' => true, + 'rivne' => true, + 'rovno' => true, + 'rv' => true, + 'sb' => true, + 'sebastopol' => true, + 'sevastopol' => true, + 'sm' => true, + 'sumy' => true, + 'te' => true, + 'ternopil' => true, + 'uz' => true, + 'uzhgorod' => true, + 'vinnica' => true, + 'vinnytsia' => true, + 'vn' => true, + 'volyn' => true, + 'yalta' => true, + 'zaporizhzhe' => true, + 'zaporizhzhia' => true, + 'zhitomir' => true, + 'zhytomyr' => true, + 'zp' => true, + 'zt' => true, + 'co' => true, + 'pp' => true + ), + 'ug' => array( + 'co' => true, + 'or' => true, + 'ac' => true, + 'sc' => true, + 'go' => true, + 'ne' => true, + 'com' => true, + 'org' => true + ), + 'uk' => array( + '*' => true, + 'sch' => array( + '*' => true + ), + '!bl' => true, + '!british-library' => true, + '!jet' => true, + '!mod' => true, + '!national-library-scotland' => true, + '!nel' => true, + '!nic' => true, + '!nls' => true, + '!parliament' => true, + 'co' => array( + 'blogspot' => true + ) + ), + 'us' => array( + 'dni' => true, + 'fed' => true, + 'isa' => true, + 'kids' => true, + 'nsn' => true, + 'ak' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'al' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ar' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'as' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'az' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ca' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'co' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ct' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'dc' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'de' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'fl' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ga' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'gu' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'hi' => array( + 'cc' => true, + 'lib' => true + ), + 'ia' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'id' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'il' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'in' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ks' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ky' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'la' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ma' => array( + 'k12' => array( + 'pvt' => true, + 'chtr' => true, + 'paroch' => true + ), + 'cc' => true, + 'lib' => true + ), + 'md' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'me' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'mi' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'mn' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'mo' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ms' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'mt' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nc' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nd' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ne' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nh' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nj' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nm' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'nv' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ny' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'oh' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ok' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'or' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'pa' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'pr' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ri' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'sc' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'sd' => array( + 'cc' => true, + 'lib' => true + ), + 'tn' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'tx' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'ut' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'vi' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'vt' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'va' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'wa' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'wi' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'wv' => array( + 'cc' => true + ), + 'wy' => array( + 'k12' => true, + 'cc' => true, + 'lib' => true + ), + 'is-by' => true, + 'land-4-sale' => true, + 'stuff-4-sale' => true + ), + 'uy' => array( + 'com' => true, + 'edu' => true, + 'gub' => true, + 'mil' => true, + 'net' => true, + 'org' => true + ), + 'uz' => array( + 'co' => true, + 'com' => true, + 'net' => true, + 'org' => true + ), + 'va' => true, + 'vc' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'mil' => true, + 'edu' => true + ), + 've' => array( + 'co' => true, + 'com' => true, + 'e12' => true, + 'edu' => true, + 'gov' => true, + 'info' => true, + 'mil' => true, + 'net' => true, + 'org' => true, + 'web' => true + ), + 'vg' => true, + 'vi' => array( + 'co' => true, + 'com' => true, + 'k12' => true, + 'net' => true, + 'org' => true + ), + 'vn' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'edu' => true, + 'gov' => true, + 'int' => true, + 'ac' => true, + 'biz' => true, + 'info' => true, + 'name' => true, + 'pro' => true, + 'health' => true + ), + 'vu' => true, + 'wf' => true, + 'ws' => array( + 'com' => true, + 'net' => true, + 'org' => true, + 'gov' => true, + 'edu' => true, + 'dyndns' => true, + 'mypets' => true + ), + 'yt' => true, + 'امارات' => true, + 'বাংলা' => true, + '中国' => true, + '中國' => true, + 'الجزائر' => true, + 'مصر' => true, + 'გე' => true, + '香港' => true, + 'भारत' => true, + 'بھارت' => true, + 'భారత్' => true, + 'ભારત' => true, + 'ਭਾਰਤ' => true, + 'ভারত' => true, + 'இந்தியா' => true, + 'ایران' => true, + 'ايران' => true, + 'الاردن' => true, + '한국' => true, + 'қаз' => true, + 'ලංකා' => true, + 'இலங்கை' => true, + 'المغرب' => true, + 'мон' => true, + 'مليسيا' => true, + 'عمان' => true, + 'فلسطين' => true, + 'срб' => true, + 'рф' => true, + 'قطر' => true, + 'السعودية' => true, + 'السعودیة' => true, + 'السعودیۃ' => true, + 'السعوديه' => true, + 'سورية' => true, + 'سوريا' => true, + '新加坡' => true, + 'சிங்கப்பூர்' => true, + 'ไทย' => true, + 'تونس' => true, + '台灣' => true, + '台湾' => true, + '臺灣' => true, + 'укр' => true, + 'اليمن' => true, + 'xxx' => true, + 'ye' => array( + '*' => true + ), + 'za' => array( + '*' => true + ), + 'zm' => array( + '*' => true + ), + 'zw' => array( + '*' => true + ), + 'онлайн' => true, + 'сайт' => true, + 'شبكة' => true, + '游戏' => true, + '企业' => true, + 'camera' => true, + 'clothing' => true, + 'lighting' => true, + 'singles' => true, + 'ventures' => true, + 'voyage' => true, + 'guru' => true, + 'holdings' => true, + 'equipment' => true, + 'bike' => true, + 'estate' => true, + 'tattoo' => true, + '在线' => true, + '中文网' => true, + 'land' => true, + 'plumbing' => true, + 'contractors' => true, + 'sexy' => true, + 'menu' => true, + '世界' => true, + 'uno' => true, + 'gallery' => true, + 'technology' => true, + '集团' => true, + 'reviews' => true, + 'guide' => true, + '我爱你' => true, + 'graphics' => true, + 'construction' => true, + 'onl' => true, + 'みんな' => true, + 'diamonds' => true, + 'kiwi' => true, + 'enterprises' => true, + 'today' => true, + 'futbol' => true, + 'photography' => true, + 'tips' => true, + 'directory' => true, + 'kitchen' => true, + '移动' => true, + 'kim' => true, + '삼성' => true, + 'monash' => true, + 'wed' => true, + 'pink' => true, + 'ruhr' => true, + 'buzz' => true, + 'careers' => true, + 'shoes' => true, + 'موقع' => true, + 'career' => true, + 'otsuka' => true, + '中信' => true, + 'gift' => true, + 'recipes' => true, + 'coffee' => true, + 'luxury' => true, + 'domains' => true, + 'photos' => true, + 'limo' => true, + 'viajes' => true, + 'wang' => true, + 'democrat' => true, + 'mango' => true, + 'cab' => true, + 'support' => true, + 'dance' => true, + 'nagoya' => true, + 'computer' => true, + 'wien' => true, + 'berlin' => true, + 'codes' => true, + 'email' => true, + 'بازار' => true, + 'repair' => true, + 'holiday' => true, + 'center' => true, + 'systems' => true, + 'wiki' => true, + 'ceo' => true, + 'international' => true, + 'solar' => true, + 'company' => true, + 'education' => true, + 'training' => true, + 'academy' => true, + 'marketing' => true, + 'florist' => true, + 'solutions' => true, + 'build' => true, + 'institute' => true, + 'builders' => true, + 'red' => true, + 'blue' => true, + 'ninja' => true, + 'business' => true, + 'gal' => true, + 'social' => true, + 'house' => true, + 'camp' => true, + 'immobilien' => true, + 'moda' => true, + 'glass' => true, + 'management' => true, + 'kaufen' => true, + 'farm' => true, + '公益' => true, + '政务' => true, + 'club' => true, + 'voting' => true, + 'TOKYO' => true, + 'moe' => true +); +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/docs/LICENSE b/vendor/pear/http_request2/docs/LICENSE new file mode 100644 index 000000000..fe4ae1a47 --- /dev/null +++ b/vendor/pear/http_request2/docs/LICENSE @@ -0,0 +1,31 @@ +HTTP_Request2 + +Copyright (c) 2008-2014, Alexey Borzov +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Alexey Borzov nor the names of his contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/http_request2/docs/examples/upload-rapidshare.php b/vendor/pear/http_request2/docs/examples/upload-rapidshare.php new file mode 100644 index 000000000..8773d1597 --- /dev/null +++ b/vendor/pear/http_request2/docs/examples/upload-rapidshare.php @@ -0,0 +1,58 @@ +send()->getBody(); + if (!preg_match('/^(\\d+)$/', $server)) { + throw new Exception("Invalid upload server: {$server}"); + } + + // Calculate file hash, we'll use it later to check upload + if (false === ($hash = @md5_file($filename))) { + throw new Exception("Cannot calculate MD5 hash of '{$filename}'"); + } + + // Second step: upload a file to the available server + $uploader = new HTTP_Request2( + "http://rs{$server}l3.rapidshare.com/cgi-bin/upload.cgi", + HTTP_Request2::METHOD_POST + ); + // Adding the file + $uploader->addUpload('filecontent', $filename); + // This will tell server to return program-friendly output + $uploader->addPostParameter('rsapi_v1', '1'); + + $response = $uploader->send()->getBody(); + if (!preg_match_all('/^(File[^=]+)=(.+)$/m', $response, $m, PREG_SET_ORDER)) { + throw new Exception("Invalid response: {$response}"); + } + $rspAry = array(); + foreach ($m as $item) { + $rspAry[$item[1]] = $item[2]; + } + // Check that uploaded file has the same hash + if (empty($rspAry['File1.4'])) { + throw new Exception("MD5 hash data not found in response"); + } elseif ($hash != strtolower($rspAry['File1.4'])) { + throw new Exception("Upload failed, local MD5 is {$hash}, uploaded MD5 is {$rspAry['File1.4']}"); + } + echo "Upload succeeded\nDownload link: {$rspAry['File1.1']}\nDelete link: {$rspAry['File1.2']}\n"; + +} catch (Exception $e) { + echo "Error: " . $e->getMessage(); +} +?> diff --git a/vendor/pear/http_request2/package.xml b/vendor/pear/http_request2/package.xml new file mode 100644 index 000000000..b648a16f8 --- /dev/null +++ b/vendor/pear/http_request2/package.xml @@ -0,0 +1,646 @@ + + + + HTTP_Request2 + pear.php.net + HTTP_Request + Provides an easy way to perform HTTP requests. + +PHP5 rewrite of HTTP_Request package (with parts of HTTP_Client). Provides +cleaner API and pluggable Adapters: + * Socket adapter, based on old HTTP_Request code, + * Curl adapter, wraps around PHP's cURL extension, + * Mock adapter, to use for testing packages dependent on HTTP_Request2. +Supports POST requests with data and file uploads, basic and digest +authentication, cookies, managing cookies across requests, proxies, gzip and +deflate encodings, redirects, monitoring the request progress with Observers... + + + Alexey Borzov + avb + avb@php.net + yes + + 2014-01-16 + + 2.2.1 + 2.2.0 + + + stable + stable + + BSD 3-Clause License + + * Fixed a bogus timeout Exception in Socket adapter after waiting for + "100 Continue" response: the same one second timeout was used + for further socket operations if explicit 'timeout' parameter was not set. + Thanks to Andrea Brancatelli (abrancatelli as schema31 dot it) for the report. + * Bundled a separate LICENSE file (request #20175). Updated phrasing and links + to mention 3-Clause BSD license the package actually uses. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.9.2 + + + Net_URL2 + pear.php.net + 2.0.0 + + + PEAR + pear.php.net + 1.9.2 + + + + + curl + + + fileinfo + + + zlib + + + openssl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2014-01-12 + + 2.2.0 + 2.2.0 + + + stable + stable + + BSD License + +New features + * Socket adapter will send "Expect: 100-continue" header and wait for + "100 Continue" response by default before sending large request body + (request #19233). This can be disabled by setting an empty "Expect" + header, the same way as done with Curl adapter (see bug #15937) + * It is possible to specify a local IP address to bind to using 'local_ip' + configuration parameter (request #19515) + +Other changes and fixes + * An infinite loop was possible when using a stream wrapper instead of + a regular file with MultipartBody (bug #19934) + * Socket adapter will properly send chunked request body if + "Transfer-Encoding: chunked" header is set for the request (bug #20125) + * Updated Public Suffix List to the latest version and updated its download script + * Unit tests fixes + + + + 2012-04-08 + + 2.1.1 + 2.1.0 + + + stable + stable + + BSD License + +Fixes for SOCKS5 proxies support in Socket adapter + + + + 2012-04-07 + + 2.1.0 + 2.1.0 + + + stable + stable + + BSD License + +New features: + * Mock adapter can return responses based on request URL (request #19276) + * Support for SOCKS5 proxies, added 'proxy_type' configuration parameter + (request #19332) + * Proxy configuration may be given as an URL, e.g. + $request->setConfig('proxy', 'socks5://localhost:1080'); + +Other changes and fixes: + * Coding standards fixes (request #14990) + * Unit tests now run from SVN checkout and under PHPUnit 3.6.x + * Explicit dependency on PEAR (until PEAR_Exception is a separate package) + * Get rid of track_errors, use a more robust solution (bug #19337) + * Additional class_exists() check in setAdapter() (request #19344) + * Public suffix list updated to current version + + + + 2011-10-20 + + 2.0.0 + 2.0.0 + + + stable + stable + + BSD License + +2.0.0RC2 repackaged as stable and depending on stable Net_URL2. No code changes. + + + + 2011-10-01 + + 2.0.0RC2 + 2.0.0 + + + beta + stable + + BSD License + + * Added an accessor method for HTTP_Request2_Response::$phrases (request #18716) + * HTTP_Request2::send() throws an exception if URL is not provided + rather than dies with a fatal error (bug #18755) + * Public Suffix List updated to current version + + + + 2011-05-06 + + 2.0.0RC1 + 2.0.0 + + + beta + stable + + BSD License + +SSL options for Curl Adapter are always set, this prevents errors when +redirecting from HTTP to HTTPS (bug #18443) + + + + + 2.0.0beta3 + 2.0.0 + + + beta + beta + + 2011-04-03 + BSD License + + * Added getEffectiveUrl() method to Response object, it returns the URL + response was received from, possibly after redirects (request #18412) + * Curl Adapter didn't send body for PUT requests sometimes (bug #18421) + + + + + 2.0.0beta2 + 2.0.0 + + + beta + beta + + 2011-03-25 + BSD License + + * Unit tests can now be run under recent PHPUnit versions (3.5+) + * Public Suffix List updated to current version + * PHP warning produced by stream_socket_client() in Socket adapter is now + added to Exception message (bug #18331) + + + + + 2.0.0beta1 + 2.0.0 + + + beta + beta + + 2011-02-27 + BSD License + +Additions and changes: + * Implemented cookie jar that allows to store and pass cookies across HTTP + requests (see request #18225) + * Added several specialized subclasses of HTTP_Request2_Exception, they are + now thrown instead of the parent. Also added error codes and possibility + to get native error code (as returned by stream_socket_client() and + curl_errno()) (request #16762) + * An additional 'sentBody' event is now sent to Observers (request #16828) + * setBody() and addUpload() can now accept file pointers (request #16863) + +Bugfixes: + * Incorrect check in Socket Adapter prevented Keep-alive from working in + some cases (bug #17031) + + + + + 0.6.0 + 0.6.0 + + + alpha + alpha + + 2011-02-14 + BSD License + +Additions and changes: + * Added test suite that interacts with a webserver. Please refer to + tests/NetworkConfig.php.dist for instructions. + * Packaging changes: docs/ and tests/ contents are installed without + redundant subdirectories. + * Added a $replace parameter to HTTP_Request2::setHeader() that controls + whether new header value will overwrite previous one or be appended + to it (request #17507) + +Bugfixes: + * Fixed a typo in Curl Adapter that prevented 'strict_redirects' from working + * Curl Adapter will throw an exception if CURLOPT_FOLLOWLOCATION can not be + enabled due to PHP setup (bug #17450) + * Allow parameters in manually set Content-Type headers (bug #17460) + * Properly reset redirect limit if multiple requests are performed with the + same instance of Socket Adapter (bug #17826) + * Response::getBody() no longer tries to decode empty strings (bug #18169) + + + + + 0.5.2 + 0.5.0 + + + alpha + alpha + + 2010-04-21 + BSD License + + * magic_quotes_runtime PHP setting could be incorrectly enabled after + performing the request (bug #16440) + * Unit tests fixes (bugs #17079, #17106, #17326) + * Observer_Log now appends to the log file rather than rewrites it (thanks to + troelskn at gmail dot com for reporting) + + + + + 0.5.1 + 0.5.0 + + + alpha + alpha + + 2009-11-21 + BSD License + + * Content-Type request header is no longer removed for POST and PUT requests + with empty request body (request #16799). + * CURLOPT_NOBODY option is now set when doing HEAD requests with Curl adapter. + + + + + 0.5.0 + 0.5.0 + + + alpha + alpha + + 2009-11-18 + BSD License + + * Redirect support added, new configuration parameters 'follow_redirects', + 'max_redirects' and 'strict_redirects' available + + * Implemented workaround for PHP bug #47204, Curl Adapter can now handle + Digest authentication and redirects when doing POST requests, unfortunately + this requires loading the entire request body into memory. + * Config parameter 'use_brackets' is propagated to created instances of Net_URL2 + * Prevent memory leaks due to circular references (request #16646) + * Fixed a misleading error message when timing out due to default_socket_timeout + * HTTP_Request2::setBody() can now accept an instance of HTTP_Request2_MultipartBody + without trying to convert it to string + * Calling HTTP_Request2::setBody() now clears post parameters and uploads + + + + + 0.4.1 + 0.4.0 + + + alpha + alpha + + 2009-09-14 + BSD License + + * Decoding of gzipped responses failed if mbstring.func_overload was enabled + (bug #16555) + * Changed boundary generation in multipart bodies to work correctly with + rapidshare.com, added first usage example: file uploading to rapidshare.com + * Added forgotten optional dependency on OpenSSL PHP extension + + + + + 0.4.0 + 0.4.0 + + + alpha + alpha + + 2009-05-03 + BSD License + + * Added 'store_body' config parameter, if set to false it will prevent storing + the response body in Response object (request #15881) + * HTTP_Request2::setHeader() method now works as documented, setHeader('name') + will remove the 'name' header, while setHeader('name', '') will set 'name' + header to empty value (bug #15937) + * Custom 'Host' header will not be overwritten by generated one (bug #16146) + * When trying to reuse the connected socket in Socket adapter, make sure that + it is still connected (bug #16149) + + + + + 0.3.0 + 0.3.0 + + + alpha + alpha + + 2009-01-28 + BSD License + + API changes: + * Removed HTTP_Request2::getConfigValue() method + + Feature additions: + * Added digest authentication (RFC 2617) support to Socket adapter. Thanks + to Tom Snyder (tomsn at inetoffice dot com) who sent me a prototype + implementation for HTTP_Request a couple of years ago. + * Added HTTPS proxy support to Socket adapter, this works through CONNECT + request described in RFC 2817. + * Mock adapter can now throw an Exception instead of returning a response + if Exception object is added via its addResponse() method (request #15629) + + Other changes and fixes: + * Support RFC 3986 by not encoding '~' in POST body (request #15368) + * Prevent an error with particular versions of PHP and Curl (bug #15617) + * Regular expressions used in HTTP_Request2 are now class constants + (request #15630) + * Curl adapter now throws an exception in case of malformed (non-HTTP) + response rather than dies with a fatal error (bug #15716) + * Curl handle wasn't closed in Curl adapter in case of error (bug #15721) + * Curl adapter sent an extra 'sentHeaders' event and returned bogus + response status when server returned 100-Continue response (bug #15785) + + + + + 0.2.0 + 0.2.0 + + + alpha + alpha + + 2009-01-07 + BSD License + + API changes: + * HTTP_Request2::getConfigValue() is deprecated and will be removed in next + release. Use HTTP_Request2::getConfig(). + * Changed HTTP_Request2::setConfig() to accept a pair of parameter name and + parameter value in addition to array('parameter name' => 'value') + * Added HTTP_Request2::getConfig() method that can return a single + configuration parameter or the whole configuration array + +Other additions and changes: + * Added a debug Observer that can log request progress to a file or an + instance of PEAR::Log (thanks to David Jean Louis, request #15424) + * Added a new 'timeout' parameter that limits total number of seconds + a request can take (see requests #5735 and #8964) + * Added various SSL protocol options: 'ssl_verify_peer', 'ssl_verify_host', + 'ssl_cafile', 'ssl_capath', 'ssl_local_cert', 'ssl_passphrase'. Note that + 'ssl_verify_host' option behaves differently in Socket and Curl Adapters: + http://bugs.php.net/bug.php?id=47030 + +Fixes: + * Fixed 'data error' when processing response encoded by 'deflate' + encoding (bug #15305) + * Curl Adapter now passes full request headers in 'sentHeaders' event + + + + + 0.1.0 + 0.1.0 + + + alpha + alpha + + 2008-11-17 + BSD License + +Initial release. The features supported are mostly the same as those of +HTTP_Request, with the following additional feature requests implemented: + * cURL extension support (request #5463) + * It is now possible to monitor the file upload progress with Observers + (request #7630) + * Added 'sentHeaders' notification providing the request headers to the + Observers (request #7633) + * Added support for 'deflate' encoding (request #11246) + + + + \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/AllTests.php b/vendor/pear/http_request2/tests/AllTests.php new file mode 100644 index 000000000..a311ca2f9 --- /dev/null +++ b/vendor/pear/http_request2/tests/AllTests.php @@ -0,0 +1,54 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'HTTP_Request2_AllTests::main'); +} + +require_once dirname(__FILE__) . '/Request2Test.php'; +require_once dirname(__FILE__) . '/ObserverTest.php'; +require_once dirname(__FILE__) . '/Request2/AllTests.php'; + +class HTTP_Request2_AllTests +{ + public static function main() + { + if (!function_exists('phpunit_autoload')) { + require_once 'PHPUnit/TextUI/TestRunner.php'; + } + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package'); + + $suite->addTest(Request2_AllTests::suite()); + $suite->addTestSuite('HTTP_Request2Test'); + $suite->addTestSuite('HTTP_Request2_ObserverTest'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'HTTP_Request2_AllTests::main') { + HTTP_Request2_AllTests::main(); +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/NetworkConfig.php.dist b/vendor/pear/http_request2/tests/NetworkConfig.php.dist new file mode 100644 index 000000000..c50609bb7 --- /dev/null +++ b/vendor/pear/http_request2/tests/NetworkConfig.php.dist @@ -0,0 +1,58 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * This file contains configuration needed for running HTTP_Request2 tests + * that interact with the network. Do not edit this file, copy it to + * NetworkConfig.php and edit the copy instead. + */ + +/** + * Base URL for HTTP_Request2 Adapters tests + * + * To enable the tests that actually perform network interaction, you should + * copy the contents of _network directory to a directory under your web + * server's document root or create a symbolic link to _network directory + * there. Set this constant to point to the URL of that directory. + */ +define('HTTP_REQUEST2_TESTS_BASE_URL', null); + +/** + * URL that is protected by server digest authentication + * + * This is needed for testing of 100 Continue handling, we can't implement + * digest in PHP since it will kick in a bit later + */ +define('HTTP_REQUEST2_TESTS_DIGEST_URL', null); + +/**#@+ + * Proxy setup for Socket Adapter tests + * + * Set these constants to run additional tests for Socket Adapter using a HTTP + * proxy. If proxy host is not set then the tests will not be run. + */ +define('HTTP_REQUEST2_TESTS_PROXY_HOST', null); +define('HTTP_REQUEST2_TESTS_PROXY_PORT', 8080); +define('HTTP_REQUEST2_TESTS_PROXY_USER', ''); +define('HTTP_REQUEST2_TESTS_PROXY_PASSWORD', ''); +define('HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME', 'basic'); +define('HTTP_REQUEST2_TESTS_PROXY_TYPE', 'http'); +/**#@-*/ +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/ObserverTest.php b/vendor/pear/http_request2/tests/ObserverTest.php new file mode 100644 index 000000000..9361e8f66 --- /dev/null +++ b/vendor/pear/http_request2/tests/ObserverTest.php @@ -0,0 +1,95 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(__FILE__) . '/TestHelper.php'; + +/** + * Class representing a HTTP request + */ +require_once 'HTTP/Request2.php'; + +/** + * Mock observer + */ +class HTTP_Request2_MockObserver implements SplObserver +{ + public $calls = 0; + + public $event; + + public function update (SplSubject $subject) + { + $this->calls++; + $this->event = $subject->getLastEvent(); + } +} + +/** + * Unit test for subject-observer pattern implementation in HTTP_Request2 + */ +class HTTP_Request2_ObserverTest extends PHPUnit_Framework_TestCase +{ + public function testSetLastEvent() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $request->attach($observer); + + $request->setLastEvent('foo', 'bar'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals(array('name' => 'foo', 'data' => 'bar'), $observer->event); + + $request->setLastEvent('baz'); + $this->assertEquals(2, $observer->calls); + $this->assertEquals(array('name' => 'baz', 'data' => null), $observer->event); + } + + public function testAttachOnlyOnce() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $observer2 = new HTTP_Request2_MockObserver(); + $request->attach($observer); + $request->attach($observer2); + $request->attach($observer); + + $request->setLastEvent('event', 'data'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals(1, $observer2->calls); + } + + public function testDetach() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $observer2 = new HTTP_Request2_MockObserver(); + + $request->attach($observer); + $request->detach($observer2); // should not be a error + $request->setLastEvent('first'); + + $request->detach($observer); + $request->setLastEvent('second'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php new file mode 100644 index 000000000..491d9c7f9 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php @@ -0,0 +1,70 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Request2_Adapter_AllTests::main'); +} + +require_once dirname(__FILE__) . '/MockTest.php'; +require_once dirname(__FILE__) . '/SkippedTests.php'; +require_once dirname(__FILE__) . '/SocketTest.php'; +require_once dirname(__FILE__) . '/SocketProxyTest.php'; +require_once dirname(__FILE__) . '/CurlTest.php'; + +class Request2_Adapter_AllTests +{ + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2 - Adapter'); + + $suite->addTestSuite('HTTP_Request2_Adapter_MockTest'); + if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL) { + $suite->addTestSuite('HTTP_Request2_Adapter_SocketTest'); + } else { + $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketTest'); + } + if (defined('HTTP_REQUEST2_TESTS_PROXY_HOST') && HTTP_REQUEST2_TESTS_PROXY_HOST + && defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL + ) { + $suite->addTestSuite('HTTP_Request2_Adapter_SocketProxyTest'); + } else { + $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketProxyTest'); + } + if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL + && extension_loaded('curl') + ) { + $suite->addTestSuite('HTTP_Request2_Adapter_CurlTest'); + } else { + $suite->addTestSuite('HTTP_Request2_Adapter_Skip_CurlTest'); + } + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'Request2_Adapter_AllTests::main') { + Request2_Adapter_AllTests::main(); +} +?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php new file mode 100644 index 000000000..2e20a8156 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php @@ -0,0 +1,387 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; + +/** Class representing a HTTP request */ +require_once 'HTTP/Request2.php'; +/** Class for building multipart/form-data request body */ +require_once 'HTTP/Request2/MultipartBody.php'; + +class SlowpokeBody extends HTTP_Request2_MultipartBody +{ + protected $doSleep; + + public function rewind() + { + $this->doSleep = true; + parent::rewind(); + } + + public function read($length) + { + if ($this->doSleep) { + sleep(3); + $this->doSleep = false; + } + return parent::read($length); + } +} + +class HeaderObserver implements SplObserver +{ + public $headers; + + public function update(SplSubject $subject) + { + $event = $subject->getLastEvent(); + + // force a timeout when writing request body + if ('sentHeaders' == $event['name']) { + $this->headers = $event['data']; + } + } +} + +/** + * Tests for HTTP_Request2 package that require a working webserver + * + * The class contains some common tests that should be run for all Adapters, + * it is extended by their unit tests. + * + * You need to properly set up this test suite, refer to NetworkConfig.php.dist + */ +abstract class HTTP_Request2_Adapter_CommonNetworkTest extends PHPUnit_Framework_TestCase +{ + /** + * HTTP Request object + * @var HTTP_Request2 + */ + protected $request; + + /** + * Base URL for remote test files + * @var string + */ + protected $baseUrl; + + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = array(); + + protected function setUp() + { + if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') || !HTTP_REQUEST2_TESTS_BASE_URL) { + $this->markTestSkipped('Base URL is not configured'); + + } else { + $this->baseUrl = rtrim(HTTP_REQUEST2_TESTS_BASE_URL, '/') . '/'; + $name = strtolower(preg_replace('/^test/i', '', $this->getName())) . '.php'; + + $this->request = new HTTP_Request2( + $this->baseUrl . $name, HTTP_Request2::METHOD_GET, $this->config + ); + } + } + + /** + * Tests possibility to send GET parameters + * + * NB: Currently there are problems with Net_URL2::setQueryVariables(), thus + * array structure is simple: http://pear.php.net/bugs/bug.php?id=18267 + */ + public function testGetParameters() + { + $data = array( + 'bar' => array( + 'key' => 'value' + ), + 'foo' => 'some value', + 'numbered' => array('first', 'second') + ); + + $this->request->getUrl()->setQueryVariables($data); + $response = $this->request->send(); + $this->assertEquals(serialize($data), $response->getBody()); + } + + public function testPostParameters() + { + $data = array( + 'bar' => array( + 'key' => 'some other value' + ), + 'baz' => array( + 'key1' => array( + 'key2' => 'yet another value' + ) + ), + 'foo' => 'some value', + 'indexed' => array('first', 'second') + ); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->addPostParameter($data); + + $response = $this->request->send(); + $this->assertEquals(serialize($data), $response->getBody()); + } + + public function testUploads() + { + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->addUpload('foo', dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', 'picture.gif', 'image/gif') + ->addUpload('bar', array( + array(dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', null, 'image/gif'), + array(dirname(dirname(dirname(__FILE__))) . '/_files/plaintext.txt', 'secret.txt', 'text/x-whatever') + )); + + $response = $this->request->send(); + $this->assertContains("foo picture.gif image/gif 43", $response->getBody()); + $this->assertContains("bar[0] empty.gif image/gif 43", $response->getBody()); + $this->assertContains("bar[1] secret.txt text/x-whatever 15", $response->getBody()); + } + + public function testRawPostData() + { + $data = 'Nothing to see here, move along'; + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setBody($data); + $response = $this->request->send(); + $this->assertEquals($data, $response->getBody()); + } + + public function testCookies() + { + $cookies = array( + 'CUSTOMER' => 'WILE_E_COYOTE', + 'PART_NUMBER' => 'ROCKET_LAUNCHER_0001' + ); + + foreach ($cookies as $k => $v) { + $this->request->addCookie($k, $v); + } + $response = $this->request->send(); + $this->assertEquals(serialize($cookies), $response->getBody()); + } + + public function testTimeout() + { + $this->request->setConfig('timeout', 2); + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); + } + } + + public function testTimeoutInRequest() + { + $this->request->setConfig('timeout', 2) + ->setUrl($this->baseUrl . 'postparameters.php') + ->setBody(new SlowpokeBody(array('foo' => 'some value'), array())); + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_MessageException was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); + } + } + + public function testBasicAuth() + { + $this->request->getUrl()->setQueryVariables(array( + 'user' => 'luser', + 'pass' => 'qwerty' + )); + $wrong = clone $this->request; + + $this->request->setAuth('luser', 'qwerty'); + $response = $this->request->send(); + $this->assertEquals(200, $response->getStatus()); + + $wrong->setAuth('luser', 'password'); + $response = $wrong->send(); + $this->assertEquals(401, $response->getStatus()); + } + + public function testDigestAuth() + { + $this->request->getUrl()->setQueryVariables(array( + 'user' => 'luser', + 'pass' => 'qwerty' + )); + $wrong = clone $this->request; + + $this->request->setAuth('luser', 'qwerty', HTTP_Request2::AUTH_DIGEST); + $response = $this->request->send(); + $this->assertEquals(200, $response->getStatus()); + + $wrong->setAuth('luser', 'password', HTTP_Request2::AUTH_DIGEST); + $response = $wrong->send(); + $this->assertEquals(401, $response->getStatus()); + } + + public function testRedirectsDefault() + { + $this->request->setUrl($this->baseUrl . 'redirects.php') + ->setConfig(array('follow_redirects' => true, 'strict_redirects' => false)) + ->setMethod(HTTP_Request2::METHOD_POST) + ->addPostParameter('foo', 'foo value'); + + $response = $this->request->send(); + $this->assertContains('Method=GET', $response->getBody()); + $this->assertNotContains('foo', $response->getBody()); + $this->assertEquals($this->baseUrl . 'redirects.php?redirects=0', $response->getEffectiveUrl()); + } + + public function testRedirectsStrict() + { + $this->request->setUrl($this->baseUrl . 'redirects.php') + ->setConfig(array('follow_redirects' => true, 'strict_redirects' => true)) + ->setMethod(HTTP_Request2::METHOD_POST) + ->addPostParameter('foo', 'foo value'); + + $response = $this->request->send(); + $this->assertContains('Method=POST', $response->getBody()); + $this->assertContains('foo', $response->getBody()); + } + + public function testRedirectsLimit() + { + $this->request->setUrl($this->baseUrl . 'redirects.php?redirects=4') + ->setConfig(array('follow_redirects' => true, 'max_redirects' => 2)); + + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::TOO_MANY_REDIRECTS, $e->getCode()); + } + } + + public function testRedirectsRelative() + { + $this->request->setUrl($this->baseUrl . 'redirects.php?special=relative') + ->setConfig(array('follow_redirects' => true)); + + $response = $this->request->send(); + $this->assertContains('did relative', $response->getBody()); + } + + public function testRedirectsNonHTTP() + { + $this->request->setUrl($this->baseUrl . 'redirects.php?special=ftp') + ->setConfig(array('follow_redirects' => true)); + + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::NON_HTTP_REDIRECT, $e->getCode()); + } + } + + public function testCookieJar() + { + $this->request->setUrl($this->baseUrl . 'setcookie.php?name=cookie_name&value=cookie_value'); + $req2 = clone $this->request; + + $this->request->setCookieJar()->send(); + $jar = $this->request->getCookieJar(); + $jar->store( + array('name' => 'foo', 'value' => 'bar'), + $this->request->getUrl() + ); + + $response = $req2->setUrl($this->baseUrl . 'cookies.php')->setCookieJar($jar)->send(); + $this->assertEquals( + serialize(array('cookie_name' => 'cookie_value', 'foo' => 'bar')), + $response->getBody() + ); + } + + public function testCookieJarAndRedirect() + { + $this->request->setUrl($this->baseUrl . 'redirects.php?special=cookie') + ->setConfig('follow_redirects', true) + ->setCookieJar(); + + $response = $this->request->send(); + $this->assertEquals(serialize(array('cookie_on_redirect' => 'success')), $response->getBody()); + } + + /** + * @link http://pear.php.net/bugs/bug.php?id=20125 + */ + public function testChunkedRequest() + { + $data = array( + 'long' => str_repeat('a', 1000), + 'very_long' => str_repeat('b', 2000) + ); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'postparameters.php') + ->setConfig('buffer_size', 512) + ->setHeader('Transfer-Encoding', 'chunked') + ->addPostParameter($data); + + $response = $this->request->send(); + $this->assertEquals(serialize($data), $response->getBody()); + } + + /** + * @link http://pear.php.net/bugs/bug.php?id=19233 + * @link http://pear.php.net/bugs/bug.php?id=15937 + */ + public function testPreventExpectHeader() + { + $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); + $observer = new HeaderObserver(); + $body = new HTTP_Request2_MultipartBody( + array(), + array( + 'upload' => array( + 'fp' => $fp, + 'filename' => 'bug_15305', + 'type' => 'application/octet-stream', + 'size' => 16338 + ) + ) + ); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'uploads.php') + ->setHeader('Expect', '') + ->setBody($body) + ->attach($observer); + + $response = $this->request->send(); + $this->assertNotContains('Expect:', $observer->headers); + $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php new file mode 100644 index 000000000..28722e739 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php @@ -0,0 +1,120 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once dirname(__FILE__) . '/CommonNetworkTest.php'; + +/** Adapter for HTTP_Request2 wrapping around cURL extension */ + +/** + * Unit test for Curl Adapter of HTTP_Request2 + */ +class HTTP_Request2_Adapter_CurlTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = array( + 'adapter' => 'HTTP_Request2_Adapter_Curl' + ); + + /** + * Checks whether redirect support in cURL is disabled by safe_mode or open_basedir + * @return bool + */ + protected function isRedirectSupportDisabled() + { + return ini_get('safe_mode') || ini_get('open_basedir'); + } + + public function testRedirectsDefault() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsDefault(); + } + } + + public function testRedirectsStrict() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsStrict(); + } + } + + public function testRedirectsLimit() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsLimit(); + } + } + + public function testRedirectsRelative() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsRelative(); + } + } + + public function testRedirectsNonHTTP() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsNonHTTP(); + } + } + + public function testCookieJarAndRedirect() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testCookieJarAndRedirect(); + } + } + + public function testBug17450() + { + if (!$this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Neither safe_mode nor open_basedir is enabled'); + } + + $this->request->setUrl($this->baseUrl . 'redirects.php') + ->setConfig(array('follow_redirects' => true)); + + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + + } catch (HTTP_Request2_LogicException $e) { + $this->assertEquals(HTTP_Request2_Exception::MISCONFIGURATION, $e->getCode()); + } + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php new file mode 100644 index 000000000..3a27e0c25 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php @@ -0,0 +1,157 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; + +/** + * Class representing a HTTP request + */ +require_once 'HTTP/Request2.php'; + +/** + * Mock adapter intended for testing + */ +require_once 'HTTP/Request2/Adapter/Mock.php'; + +/** + * Unit test for HTTP_Request2_Response class + */ +class HTTP_Request2_Adapter_MockTest extends PHPUnit_Framework_TestCase +{ + public function testDefaultResponse() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, + array('adapter' => 'mock')); + $response = $req->send(); + $this->assertEquals(400, $response->getStatus()); + $this->assertEquals(0, count($response->getHeader())); + $this->assertEquals('', $response->getBody()); + } + + public function testResponseFromString() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a string" + ); + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + + $response = $req->send(); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals(1, count($response->getHeader())); + $this->assertEquals('This is a string', $response->getBody()); + } + + public function testResponseFromFile() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse(fopen(dirname(dirname(dirname(__FILE__))) . + '/_files/response_headers', 'rb')); + + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + + $response = $req->send(); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals(7, count($response->getHeader())); + $this->assertEquals('Nothing to see here, move along.', $response->getBody()); + } + + public function testResponsesQueue() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 301 Over there\r\n" . + "Location: http://www.example.com/newpage.html\r\n" . + "\r\n" . + "The document is over there" + ); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a string" + ); + + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + $this->assertEquals(301, $req->send()->getStatus()); + $this->assertEquals(200, $req->send()->getStatus()); + $this->assertEquals(400, $req->send()->getStatus()); + } + + /** + * Returning URL-specific responses + * @link http://pear.php.net/bugs/bug.php?id=19276 + */ + public function testRequest19276() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a response from example.org", + 'http://example.org/' + ); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a response from example.com", + 'http://example.com/' + ); + + $req1 = new HTTP_Request2('http://localhost/'); + $req1->setAdapter($mock); + $this->assertEquals(400, $req1->send()->getStatus()); + + $req2 = new HTTP_Request2('http://example.com/'); + $req2->setAdapter($mock); + $this->assertContains('example.com', $req2->send()->getBody()); + + $req3 = new HTTP_Request2('http://example.org'); + $req3->setAdapter($mock); + $this->assertContains('example.org', $req3->send()->getBody()); + } + + public function testResponseException() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + new HTTP_Request2_Exception('Shit happens') + ); + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + try { + $req->send(); + } catch (Exception $e) { + $this->assertEquals('Shit happens', $e->getMessage()); + return; + } + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } +} +?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php new file mode 100644 index 000000000..a998f67dd --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php @@ -0,0 +1,56 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; + +/** + * Shows a skipped test if networked tests are not configured + */ +class HTTP_Request2_Adapter_Skip_SocketTest extends PHPUnit_Framework_TestCase +{ + public function testSocketAdapter() + { + $this->markTestSkipped('Socket Adapter tests need base URL configured.'); + } +} + +/** + * Shows a skipped test if proxy is not configured + */ +class HTTP_Request2_Adapter_Skip_SocketProxyTest extends PHPUnit_Framework_TestCase +{ + public function testSocketAdapterWithProxy() + { + $this->markTestSkipped('Socket Adapter proxy tests need base URL and proxy configured'); + } +} + +/** + * Shows a skipped test if networked tests are not configured or cURL extension is unavailable + */ +class HTTP_Request2_Adapter_Skip_CurlTest extends PHPUnit_Framework_TestCase +{ + public function testCurlAdapter() + { + $this->markTestSkipped('Curl Adapter tests need base URL configured and curl extension available'); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php new file mode 100644 index 000000000..78c4d4f3a --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php @@ -0,0 +1,55 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once dirname(__FILE__) . '/CommonNetworkTest.php'; + +/** + * Unit test for Socket Adapter of HTTP_Request2 working through proxy + */ +class HTTP_Request2_Adapter_SocketProxyTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = array( + 'adapter' => 'HTTP_Request2_Adapter_Socket' + ); + + protected function setUp() + { + if (!defined('HTTP_REQUEST2_TESTS_PROXY_HOST') || !HTTP_REQUEST2_TESTS_PROXY_HOST) { + $this->markTestSkipped('Proxy is not configured'); + + } else { + $this->config += array( + 'proxy_host' => HTTP_REQUEST2_TESTS_PROXY_HOST, + 'proxy_port' => HTTP_REQUEST2_TESTS_PROXY_PORT, + 'proxy_user' => HTTP_REQUEST2_TESTS_PROXY_USER, + 'proxy_password' => HTTP_REQUEST2_TESTS_PROXY_PASSWORD, + 'proxy_auth_scheme' => HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME, + 'proxy_type' => HTTP_REQUEST2_TESTS_PROXY_TYPE + ); + parent::setUp(); + } + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php new file mode 100644 index 000000000..1400238ce --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php @@ -0,0 +1,159 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once dirname(__FILE__) . '/CommonNetworkTest.php'; + +/** Socket-based adapter for HTTP_Request2 */ +require_once 'HTTP/Request2/Adapter/Socket.php'; + +/** + * Unit test for Socket Adapter of HTTP_Request2 + */ +class HTTP_Request2_Adapter_SocketTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = array( + 'adapter' => 'HTTP_Request2_Adapter_Socket' + ); + + public function testBug17826() + { + $adapter = new HTTP_Request2_Adapter_Socket(); + + $request1 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); + $request1->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) + ->setAdapter($adapter) + ->send(); + + $request2 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); + $request2->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) + ->setAdapter($adapter) + ->send(); + } + + + /** + * Infinite loop with stream wrapper passed as upload + * + * Dunno how the original reporter managed to pass a file pointer + * that doesn't support fstat() to MultipartBody, maybe he didn't use + * addUpload(). So we don't use it, either. + * + * @link http://pear.php.net/bugs/bug.php?id=19934 + */ + public function testBug19934() + { + if (!in_array('http', stream_get_wrappers())) { + $this->markTestSkipped("This test requires an HTTP fopen wrapper enabled"); + } + + $fp = fopen($this->baseUrl . '/bug19934.php', 'rb'); + $body = new HTTP_Request2_MultipartBody( + array(), + array( + 'upload' => array( + 'fp' => $fp, + 'filename' => 'foo.txt', + 'type' => 'text/plain', + 'size' => 20000 + ) + ) + ); + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'uploads.php') + ->setBody($body); + + set_error_handler(array($this, 'rewindWarningsHandler')); + $response = $this->request->send(); + restore_error_handler(); + + $this->assertContains("upload foo.txt text/plain 20000", $response->getBody()); + } + + public function rewindWarningsHandler($errno, $errstr) + { + if (($errno & E_WARNING) && false !== strpos($errstr, 'rewind')) { + return true; + } + return false; + } + + /** + * Do not send request body twice to URLs protected by digest auth + * + * @link http://pear.php.net/bugs/bug.php?id=19233 + */ + public function test100ContinueHandling() + { + if (!defined('HTTP_REQUEST2_TESTS_DIGEST_URL') || !HTTP_REQUEST2_TESTS_DIGEST_URL) { + $this->markTestSkipped('This test requires an URL protected by server digest auth'); + } + + $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); + $body = $this->getMock( + 'HTTP_Request2_MultipartBody', array('read'), array( + array(), + array( + 'upload' => array( + 'fp' => $fp, + 'filename' => 'bug_15305', + 'type' => 'application/octet-stream', + 'size' => 16338 + ) + ) + ) + ); + $body->expects($this->never())->method('read'); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl(HTTP_REQUEST2_TESTS_DIGEST_URL) + ->setBody($body); + + $this->assertEquals(401, $this->request->send()->getStatus()); + } + + public function test100ContinueTimeoutBug() + { + $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); + $body = new HTTP_Request2_MultipartBody( + array(), + array( + 'upload' => array( + 'fp' => $fp, + 'filename' => 'bug_15305', + 'type' => 'application/octet-stream', + 'size' => 16338 + ) + ) + ); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'uploads.php?slowpoke') + ->setBody($body); + + $response = $this->request->send(); + $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/AllTests.php b/vendor/pear/http_request2/tests/Request2/AllTests.php new file mode 100644 index 000000000..1b8bc6bb9 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/AllTests.php @@ -0,0 +1,56 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Request2_AllTests::main'); +} + +require_once dirname(__FILE__) . '/CookieJarTest.php'; +require_once dirname(__FILE__) . '/MultipartBodyTest.php'; +require_once dirname(__FILE__) . '/ResponseTest.php'; +require_once dirname(__FILE__) . '/Adapter/AllTests.php'; + +class Request2_AllTests +{ + public static function main() + { + if (!function_exists('phpunit_autoload')) { + require_once 'PHPUnit/TextUI/TestRunner.php'; + } + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2'); + + $suite->addTestSuite('HTTP_Request2_CookieJarTest'); + $suite->addTestSuite('HTTP_Request2_MultipartBodyTest'); + $suite->addTestSuite('HTTP_Request2_ResponseTest'); + $suite->addTest(Request2_Adapter_AllTests::suite()); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'Request2_AllTests::main') { + Request2_AllTests::main(); +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/CookieJarTest.php b/vendor/pear/http_request2/tests/Request2/CookieJarTest.php new file mode 100644 index 000000000..5f1de4290 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/CookieJarTest.php @@ -0,0 +1,370 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; +/** Stores cookies and passes them between HTTP requests */ +require_once 'HTTP/Request2/CookieJar.php'; + +/** + * Unit test for HTTP_Request2_CookieJar class + */ +class HTTP_Request2_CookieJarTest extends PHPUnit_Framework_TestCase +{ + /** + * Cookie jar instance being tested + * @var HTTP_Request2_CookieJar + */ + protected $jar; + + protected function setUp() + { + $this->jar = new HTTP_Request2_CookieJar(); + } + + /** + * Test that we can't store junk "cookies" in jar + * + * @dataProvider invalidCookieProvider + * @expectedException HTTP_Request2_LogicException + */ + public function testStoreInvalid($cookie) + { + $this->jar->store($cookie); + } + + /** + * + * @dataProvider noPSLDomainsProvider + */ + public function testDomainMatchNoPSL($requestHost, $cookieDomain, $expected) + { + $this->jar->usePublicSuffixList(false); + $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); + } + + /** + * + * @dataProvider PSLDomainsProvider + */ + public function testDomainMatchPSL($requestHost, $cookieDomain, $expected) + { + $this->jar->usePublicSuffixList(true); + $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); + } + + public function testConvertExpiresToISO8601() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('+1 day'); + + $this->jar->store(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => $dt->format(DateTime::COOKIE), + 'secure' => false + )); + $cookies = $this->jar->getAll(); + $this->assertEquals($cookies[0]['expires'], $dt->format(DateTime::ISO8601)); + } + + public function testProblem2038() + { + $this->jar->store(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => 'Sun, 01 Jan 2040 03:04:05 GMT', + 'secure' => false + )); + $cookies = $this->jar->getAll(); + $this->assertEquals(array(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => '2040-01-01T03:04:05+0000', + 'secure' => false + )), $cookies); + } + + public function testStoreExpired() + { + $base = array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'secure' => false + ); + + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('-1 day'); + $yesterday = $dt->format(DateTime::COOKIE); + + $dt->modify('+2 days'); + $tomorrow = $dt->format(DateTime::COOKIE); + + $this->jar->store($base + array('expires' => $yesterday)); + $this->assertEquals(0, count($this->jar->getAll())); + + $this->jar->store($base + array('expires' => $tomorrow)); + $this->assertEquals(1, count($this->jar->getAll())); + $this->jar->store($base + array('expires' => $yesterday)); + $this->assertEquals(0, count($this->jar->getAll())); + } + + /** + * + * @dataProvider cookieAndSetterProvider + */ + public function testGetDomainAndPathFromSetter($cookie, $setter, $expected) + { + $this->jar->store($cookie, $setter); + $expected = array_merge($cookie, $expected); + $cookies = $this->jar->getAll(); + $this->assertEquals($expected, $cookies[0]); + } + + /** + * + * @dataProvider cookieMatchProvider + */ + public function testGetMatchingCookies($url, $expectedCount) + { + $cookies = array( + array('domain' => '.example.com', 'path' => '/', 'secure' => false), + array('domain' => '.example.com', 'path' => '/', 'secure' => true), + array('domain' => '.example.com', 'path' => '/path', 'secure' => false), + array('domain' => '.example.com', 'path' => '/other', 'secure' => false), + array('domain' => 'example.com', 'path' => '/', 'secure' => false), + array('domain' => 'www.example.com', 'path' => '/', 'secure' => false), + array('domain' => 'specific.example.com', 'path' => '/path', 'secure' => false), + array('domain' => 'nowww.example.com', 'path' => '/', 'secure' => false), + ); + + for ($i = 0; $i < count($cookies); $i++) { + $this->jar->store($cookies[$i] + array('expires' => null, 'name' => "cookie{$i}", 'value' => "cookie_{$i}_value")); + } + + $this->assertEquals($expectedCount, count($this->jar->getMatching(new Net_URL2($url)))); + } + + public function testLongestPathFirst() + { + $cookie = array( + 'name' => 'foo', + 'domain' => '.example.com', + ); + foreach (array('/', '/specific/path/', '/specific/') as $path) { + $this->jar->store($cookie + array('path' => $path, 'value' => str_replace('/', '_', $path))); + } + $this->assertEquals( + 'foo=_specific_path_; foo=_specific_; foo=_', + $this->jar->getMatching(new Net_URL2('http://example.com/specific/path/file.php'), true) + ); + } + + public function testSerializable() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('+1 day'); + $cookie = array('domain' => '.example.com', 'path' => '/', 'secure' => false, 'value' => 'foo'); + + $this->jar->store($cookie + array('name' => 'session', 'expires' => null)); + $this->jar->store($cookie + array('name' => 'long', 'expires' => $dt->format(DateTime::COOKIE))); + + $newJar = unserialize(serialize($this->jar)); + $cookies = $newJar->getAll(); + $this->assertEquals(1, count($cookies)); + $this->assertEquals('long', $cookies[0]['name']); + + $this->jar->serializeSessionCookies(true); + $newJar = unserialize(serialize($this->jar)); + $this->assertEquals($this->jar->getAll(), $newJar->getAll()); + } + + public function testRemoveExpiredOnUnserialize() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('+2 seconds'); + + $this->jar->store(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => $dt->format(DateTime::COOKIE), + )); + + $serialized = serialize($this->jar); + sleep(2); + $newJar = unserialize($serialized); + $this->assertEquals(array(), $newJar->getAll()); + } + + public static function invalidCookieProvider() + { + return array( + array(array()), + array(array('name' => 'foo')), + array(array( + 'name' => 'a name', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + )), + array(array( + 'name' => 'foo', + 'value' => 'a value', + 'domain' => '.example.com', + 'path' => '/', + )), + array(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => null, + )), + array(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => null, + 'path' => '/', + )), + array(array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => 'invalid date', + )), + ); + } + + public static function noPSLdomainsProvider() + { + return array( + array('localhost', 'localhost', true), + array('www.example.com', 'www.example.com', true), + array('127.0.0.1', '127.0.0.1', true), + array('127.0.0.1', '.0.0.1', false), + array('www.example.com', '.example.com', true), + array('deep.within.example.com', '.example.com', true), + array('example.com', '.com', false), + array('anotherexample.com', 'example.com', false), + array('whatever.msk.ru', '.msk.ru', true), + array('whatever.co.uk', '.co.uk', true), + array('whatever.uk', '.whatever.uk', true), + array('whatever.tokyo.jp', '.whatever.tokyo.jp', true), + array('metro.tokyo.jp', '.metro.tokyo.jp', true), + array('foo.bar', '.foo.bar', true) + ); + } + + public static function PSLdomainsProvider() + { + return array( + array('localhost', 'localhost', true), + array('www.example.com', 'www.example.com', true), + array('127.0.0.1', '127.0.0.1', true), + array('127.0.0.1', '.0.0.1', false), + array('www.example.com', '.example.com', true), + array('deep.within.example.com', '.example.com', true), + array('example.com', '.com', false), + array('anotherexample.com', 'example.com', false), + array('whatever.msk.ru', '.msk.ru', false), + array('whatever.co.uk', '.co.uk', false), + array('whatever.uk', '.whatever.uk', false), + array('whatever.tr', '.whatever.tr', false), + array('nic.tr', '.nic.tr', true), + array('foo.bar', '.foo.bar', true) + ); + } + + public static function cookieAndSetterProvider() + { + return array( + array( + array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => null, + 'path' => null, + 'expires' => null, + 'secure' => false + ), + new Net_Url2('http://example.com/directory/file.php'), + array( + 'domain' => 'example.com', + 'path' => '/directory/' + ) + ), + array( + array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => null, + 'expires' => null, + 'secure' => false + ), + new Net_Url2('http://example.com/path/to/file.php'), + array( + 'path' => '/path/to/' + ) + ), + array( + array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => null, + 'path' => '/', + 'expires' => null, + 'secure' => false + ), + new Net_Url2('http://example.com/another/file.php'), + array( + 'domain' => 'example.com' + ) + ) + ); + } + + public static function cookieMatchProvider() + { + return array( + array('http://www.example.com/path/file.php', 4), + array('https://www.example.com/path/file.php', 5), + array('http://example.com/path/file.php', 3), + array('http://specific.example.com/path/file.php', 4), + array('http://specific.example.com/other/file.php', 3), + array('http://another.example.com/another', 2) + ); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php b/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php new file mode 100644 index 000000000..8543b9e56 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php @@ -0,0 +1,102 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; + +/** + * Class representing a HTTP request + */ +require_once 'HTTP/Request2.php'; + +/** + * Unit test for HTTP_Request2_MultipartBody class + */ +class HTTP_Request2_MultipartBodyTest extends PHPUnit_Framework_TestCase +{ + public function testUploadSimple() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addPostParameter('foo', 'I am a parameter') + ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') + ->getBody(); + + $this->assertTrue($body instanceof HTTP_Request2_MultipartBody); + $asString = $body->__toString(); + $boundary = $body->getBoundary(); + $this->assertEquals($body->getLength(), strlen($asString)); + $this->assertContains('This is a test.', $asString); + $this->assertContains('I am a parameter', $asString); + $this->assertRegexp("!--{$boundary}--\r\n$!", $asString); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testRequest16863() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $fp = fopen(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'rb'); + $body = $req->addUpload('upload', $fp) + ->getBody(); + + $asString = $body->__toString(); + $this->assertContains('name="upload"; filename="anonymous.blob"', $asString); + $this->assertContains('This is a test.', $asString); + + $req->addUpload('bad_upload', fopen('php://input', 'rb')); + } + + public function testStreaming() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addPostParameter('foo', 'I am a parameter') + ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') + ->getBody(); + $asString = ''; + while ($part = $body->read(10)) { + $asString .= $part; + } + $this->assertEquals($body->getLength(), strlen($asString)); + $this->assertContains('This is a test.', $asString); + $this->assertContains('I am a parameter', $asString); + } + + public function testUploadArray() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addUpload('upload', array( + array(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'bio.txt', 'text/plain'), + array(fopen(dirname(dirname(__FILE__)) . '/_files/empty.gif', 'rb'), 'photo.gif', 'image/gif') + )) + ->getBody(); + $asString = $body->__toString(); + $this->assertContains(file_get_contents(dirname(dirname(__FILE__)) . '/_files/empty.gif'), $asString); + $this->assertContains('name="upload[0]"; filename="bio.txt"', $asString); + $this->assertContains('name="upload[1]"; filename="photo.gif"', $asString); + + $body2 = $req->setConfig(array('use_brackets' => false))->getBody(); + $asString = $body2->__toString(); + $this->assertContains('name="upload"; filename="bio.txt"', $asString); + $this->assertContains('name="upload"; filename="photo.gif"', $asString); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/ResponseTest.php b/vendor/pear/http_request2/tests/Request2/ResponseTest.php new file mode 100644 index 000000000..c757d7327 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2/ResponseTest.php @@ -0,0 +1,128 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; + +/** + * Class representing a HTTP response + */ +require_once 'HTTP/Request2/Response.php'; + +/** + * Unit test for HTTP_Request2_Response class + */ +class HTTP_Request2_ResponseTest extends PHPUnit_Framework_TestCase +{ + /** + * + * @expectedException HTTP_Request2_MessageException + */ + public function testParseStatusLine() + { + $response = new HTTP_Request2_Response('HTTP/1.1 200 OK'); + $this->assertEquals('1.1', $response->getVersion()); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals('OK', $response->getReasonPhrase()); + + $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!'); + $this->assertEquals('1.2', $response2->getVersion()); + $this->assertEquals(222, $response2->getStatus()); + $this->assertEquals('Nishtyak!', $response2->getReasonPhrase()); + + $response3 = new HTTP_Request2_Response('Invalid status line'); + } + + public function testParseHeaders() + { + $response = $this->readResponseFromFile('response_headers'); + $this->assertEquals(7, count($response->getHeader())); + $this->assertEquals('PHP/6.2.2', $response->getHeader('X-POWERED-BY')); + $this->assertEquals('text/html; charset=windows-1251', $response->getHeader('cOnTeNt-TyPe')); + $this->assertEquals('accept-charset, user-agent', $response->getHeader('vary')); + } + + public function testParseCookies() + { + $response = $this->readResponseFromFile('response_cookies'); + $cookies = $response->getCookies(); + $this->assertEquals(4, count($cookies)); + $expected = array( + array('name' => 'foo', 'value' => 'bar', 'expires' => null, + 'domain' => null, 'path' => null, 'secure' => false), + array('name' => 'PHPSESSID', 'value' => '1234567890abcdef1234567890abcdef', + 'expires' => null, 'domain' => null, 'path' => '/', 'secure' => true), + array('name' => 'A', 'value' => 'B=C', 'expires' => null, + 'domain' => null, 'path' => null, 'secure' => false), + array('name' => 'baz', 'value' => '%20a%20value', 'expires' => 'Sun, 03 Jan 2010 03:04:05 GMT', + 'domain' => 'pear.php.net', 'path' => null, 'secure' => false), + ); + foreach ($cookies as $k => $cookie) { + $this->assertEquals($expected[$k], $cookie); + } + } + + /** + * + * @expectedException HTTP_Request2_MessageException + */ + public function testGzipEncoding() + { + $response = $this->readResponseFromFile('response_gzip'); + $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); + + $response = $this->readResponseFromFile('response_gzip_broken'); + $body = $response->getBody(); + } + + public function testDeflateEncoding() + { + $response = $this->readResponseFromFile('response_deflate'); + $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); + } + + public function testBug15305() + { + $response = $this->readResponseFromFile('bug_15305'); + $this->assertEquals('c8c5088fc8a7652afef380f086c010a6', md5($response->getBody())); + } + + public function testBug18169() + { + $response = $this->readResponseFromFile('bug_18169'); + $this->assertEquals('', $response->getBody()); + } + + protected function readResponseFromFile($filename) + { + $fp = fopen(dirname(dirname(__FILE__)) . '/_files/' . $filename, 'rb'); + $response = new HTTP_Request2_Response(fgets($fp)); + do { + $headerLine = fgets($fp); + $response->parseHeaderLine($headerLine); + } while ('' != trim($headerLine)); + + while (!feof($fp)) { + $response->appendBody(fread($fp, 1024)); + } + return $response; + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2Test.php b/vendor/pear/http_request2/tests/Request2Test.php new file mode 100644 index 000000000..70516d647 --- /dev/null +++ b/vendor/pear/http_request2/tests/Request2Test.php @@ -0,0 +1,391 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Sets up includes */ +require_once dirname(__FILE__) . '/TestHelper.php'; + +/** + * Class representing a HTTP request + */ +require_once 'HTTP/Request2.php'; + +/** + * Unit test for HTTP_Request2 class + */ +class HTTP_Request2Test extends PHPUnit_Framework_TestCase +{ + public function testConstructorSetsDefaults() + { + $url = new Net_URL2('http://www.example.com/foo'); + $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST, array('connect_timeout' => 666)); + + $this->assertSame($url, $req->getUrl()); + $this->assertEquals(HTTP_Request2::METHOD_POST, $req->getMethod()); + $this->assertEquals(666, $req->getConfig('connect_timeout')); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testSetUrl() + { + $urlString = 'http://www.example.com/foo/bar.php'; + $url = new Net_URL2($urlString); + + $req1 = new HTTP_Request2(); + $req1->setUrl($url); + $this->assertSame($url, $req1->getUrl()); + + $req2 = new HTTP_Request2(); + $req2->setUrl($urlString); + $this->assertInstanceOf('Net_URL2', $req2->getUrl()); + $this->assertEquals($urlString, $req2->getUrl()->getUrl()); + + $req3 = new HTTP_Request2(); + $req3->setUrl(array('This will cause an error')); + } + + public function testConvertUserinfoToAuth() + { + $req = new HTTP_Request2(); + $req->setUrl('http://foo:b%40r@www.example.com/'); + + $this->assertEquals('', (string)$req->getUrl()->getUserinfo()); + $this->assertEquals( + array('user' => 'foo', 'password' => 'b@r', 'scheme' => HTTP_Request2::AUTH_BASIC), + $req->getAuth() + ); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testSetMethod() + { + $req = new HTTP_Request2(); + $req->setMethod(HTTP_Request2::METHOD_PUT); + $this->assertEquals(HTTP_Request2::METHOD_PUT, $req->getMethod()); + + $req->setMethod('Invalid method'); + } + + public function testSetAndGetConfig() + { + $req = new HTTP_Request2(); + $this->assertArrayHasKey('connect_timeout', $req->getConfig()); + + $req->setConfig(array('connect_timeout' => 123)); + $this->assertEquals(123, $req->getConfig('connect_timeout')); + try { + $req->setConfig(array('foo' => 'unknown parameter')); + $this->fail('Expected HTTP_Request2_LogicException was not thrown'); + } catch (HTTP_Request2_LogicException $e) {} + + try { + $req->getConfig('bar'); + $this->fail('Expected HTTP_Request2_LogicException was not thrown'); + } catch (HTTP_Request2_LogicException $e) {} + } + + public function testSetProxyAsUrl() + { + $req = new HTTP_Request2(); + $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/'); + + $this->assertEquals('socks5', $req->getConfig('proxy_type')); + $this->assertEquals('localhost', $req->getConfig('proxy_host')); + $this->assertEquals(1080, $req->getConfig('proxy_port')); + $this->assertEquals('foo', $req->getConfig('proxy_user')); + $this->assertEquals('bar%baz', $req->getConfig('proxy_password')); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testHeaders() + { + $req = new HTTP_Request2(); + $autoHeaders = $req->getHeaders(); + + $req->setHeader('Foo', 'Bar'); + $req->setHeader('Foo-Bar: value'); + $req->setHeader(array('Another-Header' => 'another value', 'Yet-Another: other_value')); + $this->assertEquals( + array('foo-bar' => 'value', 'another-header' => 'another value', + 'yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, + $req->getHeaders() + ); + + $req->setHeader('FOO-BAR'); + $req->setHeader(array('aNOTHER-hEADER')); + $this->assertEquals( + array('yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, + $req->getHeaders() + ); + + $req->setHeader('Invalid header', 'value'); + } + + public function testBug15937() + { + $req = new HTTP_Request2(); + $autoHeaders = $req->getHeaders(); + + $req->setHeader('Expect: '); + $req->setHeader('Foo', ''); + $this->assertEquals( + array('expect' => '', 'foo' => '') + $autoHeaders, + $req->getHeaders() + ); + } + + public function testRequest17507() + { + $req = new HTTP_Request2(); + + $req->setHeader('accept-charset', 'iso-8859-1'); + $req->setHeader('accept-charset', array('windows-1251', 'utf-8'), false); + + $req->setHeader(array('accept' => 'text/html')); + $req->setHeader(array('accept' => 'image/gif'), null, false); + + $headers = $req->getHeaders(); + + $this->assertEquals('iso-8859-1, windows-1251, utf-8', $headers['accept-charset']); + $this->assertEquals('text/html, image/gif', $headers['accept']); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testCookies() + { + $req = new HTTP_Request2(); + $req->addCookie('name', 'value'); + $req->addCookie('foo', 'bar'); + $headers = $req->getHeaders(); + $this->assertEquals('name=value; foo=bar', $headers['cookie']); + + $req->addCookie('invalid cookie', 'value'); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testPlainBody() + { + $req = new HTTP_Request2(); + $req->setBody('A string'); + $this->assertEquals('A string', $req->getBody()); + + $req->setBody(dirname(__FILE__) . '/_files/plaintext.txt', true); + $headers = $req->getHeaders(); + $this->assertRegexp( + '!^(text/plain|application/octet-stream)!', + $headers['content-type'] + ); + $this->assertEquals('This is a test.', fread($req->getBody(), 1024)); + + $req->setBody('missing file', true); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testRequest16863() + { + $req = new HTTP_Request2(); + $req->setBody(fopen(dirname(__FILE__) . '/_files/plaintext.txt', 'rb')); + $headers = $req->getHeaders(); + $this->assertEquals('application/octet-stream', $headers['content-type']); + + $req->setBody(fopen('php://input', 'rb')); + } + + public function testUrlencodedBody() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $req->addPostParameter('foo', 'bar'); + $req->addPostParameter(array('baz' => 'quux')); + $req->addPostParameter('foobar', array('one', 'two')); + $this->assertEquals( + 'foo=bar&baz=quux&foobar%5B0%5D=one&foobar%5B1%5D=two', + $req->getBody() + ); + + $req->setConfig(array('use_brackets' => false)); + $this->assertEquals( + 'foo=bar&baz=quux&foobar=one&foobar=two', + $req->getBody() + ); + } + + public function testRequest15368() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $req->addPostParameter('foo', 'te~st'); + $this->assertContains('~', $req->getBody()); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + * @expectedExceptionMessage missing file + */ + public function testUpload() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $req->addUpload('upload', dirname(__FILE__) . '/_files/plaintext.txt'); + + $headers = $req->getHeaders(); + $this->assertEquals('multipart/form-data', $headers['content-type']); + + $req->addUpload('upload_2', 'missing file'); + } + + public function testPropagateUseBracketsToNetURL2() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, + array('use_brackets' => false)); + $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); + $this->assertEquals('http://www.example.com/?foo=bar&foo=baz', $req->getUrl()->__toString()); + + $req->setConfig('use_brackets', true)->setUrl('http://php.example.com/'); + $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); + $this->assertEquals('http://php.example.com/?foo[0]=bar&foo[1]=baz', $req->getUrl()->__toString()); + } + + public function testSetBodyRemovesPostParameters() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); + $req->addPostParameter('foo', 'bar'); + $req->setBody(''); + $this->assertEquals('', $req->getBody()); + } + + public function testPostParametersPrecedeSetBodyForPost() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); + $req->setBody('Request body'); + $req->addPostParameter('foo', 'bar'); + + $this->assertEquals('foo=bar', $req->getBody()); + + $req->setMethod(HTTP_Request2::METHOD_PUT); + $this->assertEquals('Request body', $req->getBody()); + } + + public function testSetMultipartBody() + { + require_once 'HTTP/Request2/MultipartBody.php'; + + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); + $body = new HTTP_Request2_MultipartBody(array('foo' => 'bar'), array()); + $req->setBody($body); + $this->assertSame($body, $req->getBody()); + } + + public function testBug17460() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); + $req->addPostParameter('foo', 'bar') + ->setHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8'); + + $this->assertEquals('foo=bar', $req->getBody()); + } + + /** + * + * @expectedException HTTP_Request2_LogicException + */ + public function testCookieJar() + { + $req = new HTTP_Request2(); + $this->assertNull($req->getCookieJar()); + + $req->setCookieJar(); + $jar = $req->getCookieJar(); + $this->assertInstanceOf('HTTP_Request2_CookieJar', $jar); + + $req2 = new HTTP_Request2(); + $req2->setCookieJar($jar); + $this->assertSame($jar, $req2->getCookieJar()); + + $req2->setCookieJar(null); + $this->assertNull($req2->getCookieJar()); + + $req2->setCookieJar('foo'); + } + + public function testAddCookieToJar() + { + $req = new HTTP_Request2(); + $req->setCookieJar(); + + try { + $req->addCookie('foo', 'bar'); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } catch (HTTP_Request2_LogicException $e) { } + + $req->setUrl('http://example.com/path/file.php'); + $req->addCookie('foo', 'bar'); + + $this->assertArrayNotHasKey('cookie', $req->getHeaders()); + $cookies = $req->getCookieJar()->getAll(); + $this->assertEquals( + array( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => 'example.com', + 'path' => '/path/', + 'expires' => null, + 'secure' => false + ), + $cookies[0] + ); + } + + /** + * @expectedException HTTP_Request2_LogicException + * @expectedExceptionMessage none + */ + public function testDisallowEmptyUrls() + { + $req = new HTTP_Request2(); + $req->send(); + } + + /** + * @expectedException HTTP_Request2_LogicException + * @expectedExceptionMessage '/foo/bar.php' + */ + public function testDisallowRelativeUrls() + { + $req = new HTTP_Request2('/foo/bar.php'); + $req->send(); + } +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/TestHelper.php b/vendor/pear/http_request2/tests/TestHelper.php new file mode 100644 index 000000000..512f6a9e6 --- /dev/null +++ b/vendor/pear/http_request2/tests/TestHelper.php @@ -0,0 +1,51 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** Include PHPUnit dependencies based on version */ +require_once 'PHPUnit/Runner/Version.php'; + +// If running from SVN checkout, update include_path +if ('@' . 'package_version@' == '@package_version@') { + $classPath = realpath(dirname(dirname(__FILE__))); + $includePath = array_map('realpath', explode(PATH_SEPARATOR, get_include_path())); + if (0 !== ($key = array_search($classPath, $includePath))) { + if (false !== $key) { + unset($includePath[$key]); + } + set_include_path($classPath . PATH_SEPARATOR . implode(PATH_SEPARATOR, $includePath)); + } +} + +$phpunitVersion = PHPUnit_Runner_Version::id(); +if ($phpunitVersion == '@' . 'package_version@' || !version_compare($phpunitVersion, '3.8', '<=')) { + echo "This version of PHPUnit is not supported."; + exit(1); +} elseif (version_compare($phpunitVersion, '3.5.0', '>=')) { + require_once 'PHPUnit/Autoload.php'; +} else { + require_once 'PHPUnit/Framework.php'; +} + +if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') + && is_readable(dirname(__FILE__) . '/NetworkConfig.php') +) { + require_once dirname(__FILE__) . '/NetworkConfig.php'; +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_files/bug_15305 b/vendor/pear/http_request2/tests/_files/bug_15305 new file mode 100644 index 0000000000000000000000000000000000000000..bbf6c70006b8062fd656063ee9cbbff16edf7f04 GIT binary patch literal 16338 zcmV;@KP|vWR8&weF)lG6GB7Y8PiqYdL}7GgIv`YaWh@{tHXur2ZXhx+FgYMHFgi6e zIx;dKM@>`>3R7irc4cxpAWdmwa&L2QW^^q{NmDO2E-(!WP&05kAVW|+B0^PDAVXDB zAVW`1Zy-iVP9RBEL~kHZPD~(ARZ<{ONLe6LK}~NUR7Fg0A`J>tIv`X_GEh`ZQbkTe zFfk1ZSS?U*cV%*AWGzB@Iv_z)P%chIR1FGPEkSc|Ze?^WR%LQ?X>V>iATlm6E;TSW zGB*thP;y~sZDBefZf`APVPj}z4GKeHV`yb9LvL<$a&K%pAZ~9hV_{=xWeo~LZ*FvD zZgeeFd2nSqAarGTbT4RhZEQOrV`yP=b7gcrb#!JeI1LIzZ*FvDZgee0Zewp`X>Mma zAY^4`Y+-a|4GKeVZggdCbS+F}ZfA68Iv_DMIXO5D3JnVFz3Fz_NVX>WDv`|2lvLsX zfHP%EmxE*}k7cVYIbC^NZm$3kBw>L75&$JDoxZCd;{LfW&}*Ha{R(~FY!2?-VE8_ z&TlSXFukm?>o|0*xKcTNSzv`p90#3B<^KM@d|xg5;ka`1y7Gyj=u|DaEJdWagjbqH1-5X5w_em;16^;o+X^TF65Kw1HWe`k-f>V8zs{VyZeiei zvGC&3%|jpx%u;vVLM%ST6{>l}tO*Yz5qD?tsMIR3${HYlE4}HJ2L3eQv17V_!Mxjs2o$YrlWG~$h;JIyE)f~p{M*;sfi4rhXm z{BX7UH1f)pKTS%9Y~T8g>CB}ckA8gmxx>%F7C?UpkSI2vg3VS))*sWaDE{~qKnrz= zxM9St#j(-9X>2^Eu?YX}@Xux1!4pPg_o{2hVY&KKssE(v*>;6mGY0 zeg5k8&EU-qyBNHJN|}UWlu7<1Na0n+u5WU;V&U1Hu2n|-&Vh_UhWrAHA?e+MGv#AZ z`Bb9ka{=}E6z^WY>c6_V&WYvASFeUwOPEB0ht?zo$AiFiER4SIRs2AB>a8szD|7;S zdI&9r!cOd>^b6-su8}6D2v$U8p)x2dHs?(5xa!i@FRZ| z??o)|!RtMtcqp2~o44wFajr}Ncf+D*YJf4UU04IJBP%GTC+0+jO8;5w8VpwE6LSfgXzi%DS z_U|Jm=@N+$qa`91&8!K%J@?}&cTf<3E=3dxZ!E&HB!i^qF>oe&J*%kOXNn%l$Vg58 zk>7Fkv~XPc%d_v^4Tim&-n+k4E+en|`3kJi`F!n+Jz-yXoxL;eMq;n{Q`Ff@h9$l= z%EYfxDdjLT1aDPzy&{cJuZ&mSMySZ1iI(x6*?0qQ?c|c%O zF5`BjXK-D|40-rav3URt3RL#B7N{=RO89f;UPaTyJk5Qfy*ti?}>W`Y)(G~`-Q*%{d3`vAL8$qLa{I|92B$a z@A&(Jqfo@N&|~J8qqC&l97f!>FGW1@?Kx6r(NcJEiPyaFku%!=j=wYCAJ9+NN+DCJ z^}wS!RHyhc?d`o}>!RptMP3{gt)g8VcbyZb96?#c`-O7hp!4p1anc>9-ABWdQt9Bc zB#(GD`SHhn-W|Ua=-uI=IKXRu@R_hPsmJuw{ru$!1jE%ARr1J^cSj@nr~C1QNJyA> z=!aUc4hX!>9FJK9lDgoJ*yx@8zS}L#JX?$$NJ8O2KC$rg*IQ6$=zW*YijTk|BCZX6RkwCEy1=`IcXG$Cv zK^&S2)1{)iENVl6$3haBm?mGKYkpD9Q0K%PF!gFq*mnkQ)3F+1g!Z$MP{SZ38bzlI zWdZiLeM?q^7Wn+7Xb~ARe##B&PuIC26~&K5UqN#ev;ZPA7V)VoBoh6H8$NysbG2VM zKkW?*2k*4^ME67zr(F}5^uXSq9zePvq|;1aIA6XHaaB>bOX4!w|5$X;Bvs)gee|OS z);&0)@%T(ny6@cgk{c|bW07?e2}a;cWo-_QtTIW+svW`$-$NbyA&OBEQ3lLf*OQM$ z82VwCu3Vqn-CI12LaQr|f-)Qp;n{#p(%}UcLRq89Yid#w3`&IBg9iEice;U*2?%!K z063j zg3($~@R0mOsHkD{;4@E5!_hs)QS6VNnLqw$gK!}JyV2p{`}YS2M=7EB7g2sL;#Ve6 zpZ5p&7Xioyv?VoUrA_g}!vhOKjUoWiv+W^<|MU*rxuC0oQDOjStkO4y155Ec&r=aN z9(+#qa#HELyvaaA1Ma#e{GXi~;b4d_2QVM|1$biRUi9EukeOv2!l5QW#jHp|5U3AL z@xsub4iYZQvqXZb^+lBe4d!nJtnsKgRt;D*Fk|onj3-pV0eWv@gh1p`%1??MpXqT& z6eHnwZ1O*%4wT*ki2#y-!LE#t2=)jK!39XhT1gv5PDvfC^u8_Il1w>*a!Oh*qluzj zrX~)Kxa27KLxL9J8|cB&>Z8@zt2eepsHtd+#CUi)DAdvkuHeAoH++!%x>>i*!`xg91tw$Dlb; z(1J`H%&RFb!Y?likDIRO4f-gr5phDOM6^rerRoz?Q4_@iyxPlgSSV(ACt{qaaez!1 z69vJ_X>$dMxRTN`UV-om?tG+C;B#ut%J&F@#Qxs)(1Vc@FYLjG-76eFtLz;nR^qs@ zAO)Z-1|#vQb2br7Kk)rqC-3d3fik7ln)}IS;gCp6u5$F3F8%Dk`|n5Z|8fAo*&)9f z9=05~41Y@k&TJz8@kgHMkz@UYzti7$3I%BFRiv)hAT^e*uAp&Dq?fQM7P^JvSlZ=8 zV=A;s^&XjEccpvHxfVXO{?cmHWUxb{ECsM|Bt8XBD55TClsq%bvH#{~ppe@?I3Rlt zS1GGu`-mUCTm@SefxXF!1c+L51%xaxI>_Ef!kUG!V1Ttiu`Vxv^c`=%fFWEIAjN@m zwxgJE@zGDwL8bEkJvbp@gJ)6v;KCW3GmjNTh2#InnNo1hW}&;EMsO;qgrV6KRHCMg zNXrD`;OMJi_;(0R>j@NKN*EqL`>s@a=Zx6JDX{;8k#@v~)=G2lAmGmEeW{c+?Z#-G zHUEtE8y^}wBhdIW5U77xC3p^jc@B!Zu?RiL&$={J7)1+7r=A=640`MGdO2~H&oZD^ zg`=eJ(Gwm8pO*4oPipf@_%O;8X~q*FGfj^)9s5B&Np*c|+ZPeLh}lgz6DRDERxhH9 zmyE_B(~|b>3{4&BB)=0T{y+5P;{Q5FV2_t%Weo zLufR3(}0UCA^0Je5MG58qisRL&x5erP2H#`AVT=t1md-@x6}{w_04M4s2WLq_@lD^ z+X-BkEfDVW5QIIdk)JOi1db;mTuIK^2q4G<7-=(66&3m}jN=vvw|NNg1`1!^ ze>qyRofS2~XZrR7vs@m*L4cEGJ9m<0{i){^*ke4m#@i&$leU}u9ymL*VE=RAbqa5; z+4C74>HIiZ$fvoJ0^V^!4+)V-OB z$mS14_7nGJJbYkUqsR-$6Bv4+!E<#ZoYZfiDDxmxa*{EQZg?gmgl(>Ip;4T z=!C-YDF))-|CjG7JX|LaD`|EK6pY?l_AMO0zP_G=sm$Efj-_0+z;!u3Y9xH5CDf+! zXv_7-bH-cYs2s&0G^9!LW?YWLdQ6fTw#g!lz~v9XFJCyNt@{A=fjd8f=01Kl^1~_P zQq6S>-{ZmR0FgMY4h}JY`b=V4IKFlrThLVBJ&OV%>{LQh;(wp@$rh9#jc9E|(rM2M z84S2BNH7SLe=o-&hq`=Coyt7}j%awbn-lmmgwg`dR`H-_7w{m&@_3wqee!Gto#q9S zezG|HGz&7ML|WdMKK!RU4qu{M(3E3CH0aG@zceB8V6@m1e2ByFXL*EFe-=j* z&mQn(S?(3JGJ$n{i@Q=>PwP`nhbP;;fxD4(olzXp{pOWMz=h-3OCDXS#>atXrS4F(NRt1A`T(FMR z6H8;VWXVGjL4~T2<>c(u>r1j%=eqJ5e(e^H-wJb4jMl@;7CS5ej4U5~hqffR4E&Wc zhXfwCyMRy8mCHTg4X?#I19~A#Jqc~OI^r?7KU1M6f%On7FG3}uT7*jBbRK9n#A^-U zln2oq{u*$XC@=??GlVJcL1-qUaJpm(!7_yUIP_-$vD&1%(lnXztmVA%ont{B+zS** zB4>pMfm*Ou>&G@vrUIL)S^mP9qSXY)$f3D`hH`9@ZYW6s-Dn9O=~ajTkWlS+Km>Z8 zYDKDtw>eL)kgUG>6$Eg8!$q@>w)rQOH0>6QI&1;AED=Sw;sH7n?NubO6sCd&3tb2lvI zz2rrX_j2ZT0}DFS`M6Khg=ctLnSipDlgOWimLT7s=IfgF&LiKv|7K`KRd-} z)rOi;J+0RaLu=`$+76v~P#Ni!9?0k0(0@d517SJbokxA#4JOd(Y1p?@|C+5zb8uR3 zwrbUOtu@3b>DAL_yJw)!r+R&`L-*j74;?t|u^-MI#d$CDuQzvg$r>+;Evf4KQ-l}H z^5Qxk?;6@I(Jl_*;ky~-7USif6S5n}x)pI$xse68@)SoLv?=ta7-_q^WkH#VFsolU z9;gRN`0@Y>f#eL&7N3+2NHca9!){$~=#8qx ztj|49g!HUdt=4r`I36Nq@x}?>SLlN8fjgIm_$$YYkh2AfE9?-&`o5hsb(${QMeAEh zC71iosq~y~w^yL-cdmj=hQo<_tRXm%Zk)Mqu#56OLHEpwJ?O682L=yA--5+MyeO|- zf1If?qD*Bdg81AIeHm1!L3=w9URR|)d!ufN*0IW)pW&uuMgOS5q1DucV2Btt#mn&! z$3f<$DN#5%7R-k%`~h$2IRX+{>@kA6&IqL*T#jwG1B3-P{oV<>h9uBk z@;8iw?*A*VvS>#|5Xmqqokl_W_BPkiCM5{~((Bz>Vd~#Ga~6geT*?Q3&@j#-C(ED% zG~I6PTavsq=V|xVkZq+>2wA{b@i-gH!trZ7W2f?A-zT!OoqZQ^5HV5tzpAr@R01jKy&F6gp4Jw+l3oS_QNNi?GgFp1X`QRQ-be_0 z7Q)$I9Jk!00Znx~qV+-McL_kE5f$wutQ2#~$ieBFCx#c|s3xL(Z|n+fA%9QxY?%*E z>MRCQOum~Jja)?YNlA&(y2*fG;>SJ-LnPL{QFN4-6Yf&RVuf#4^p0a!j8Bl zX%&o?>4t}Trq|v6Q2S&q><{58us0_ z;s#3A+Vw`WR>`+M@Le$lx7^XjGMC>+GbbkMT{`g0BR}RT-A2T&k1A8*D<#9mq6`B^ z3f9tRkSRD)iEzy#pb&Hm-$(d^daJ_r*jlhkOd;m?TLiRvT4~lGoPC7by+N-zY#NP5 zb6D3}wc(&%9kdrDwAxrJp>JsYEEtHr_2m_VU?#RE=7?INduJLkPw$Am?5NdBjhenaQ9g|1N)fZrtj zu*CV*70#!3$)iW?7MsF*E{+AN=och`mfCvb((=7IBZn`2tSH;uX4<}8 z+KfS^+U)h}jn-+i+0d%3W~+5-^lHuFS${A%)B6k3X6PWZEU2eT@7HiXxt3?D_}tk0b>xD?SW(dQAfN7SZ_ero&@a>G7dzIuJiUcFSgHL_Rh z>;#HFY9LmFPWWVMUKZRK!BE7G<%-Z$cEJit>C$Nu*@mIFjk*du#I|xIN6e;MsQo1{eTugK3aG%g-kC*!)p*;OwA;>rP!xoNP9ye z$y%hK(~NdoYtOOL5qq-2aSuKVR2Gzg2Zxvi-0^m|_)CkE=-v}C#DLb4QPWWcrXH?^ zsGKAic87>^22kw6OS~$!r7vixdK3Ir zuc$rBILU>5OO#9x4ao#KNkijBP&o-=FO=4=CTT*qHjjC?s?`h~{ig=?DP>u zfQhky9m%Df)K2OEBb8ji;P1R-cV25@&FL0)`5Ck+t7if3JPQR!6dj{(|Wu^aL(USGA~RHT4G~} z?z}6HB%R>Ts||VURdjt(MU%2yCdKk%i0lD5VkDZ`-oUjAb2nALY9i)}b_J!ap++P= z&A1EKj2>3t2PcSM_GS*B{h| zwT50t*uNO$uXTgq?XYMnTo8axz+%4I=S9v>&y6v5w$IdR)5>!Z!^u@Q%VGW32Iv1E z;wI*&nH=>s@_jp^urKiM!TA#>Vy0Bqi@A(HSzHP%TOZS3@a)SWK+x$BCvOU!(~d%vD(qP zCJ|C=)YQ%^NlJ>+3dc82fDj(4PlV8V;Guh^JrD~AB8J7JAmvfwMJ^PWVroQyhSscV z4M~h@OA_On-gg)+OoSgkHbGcMne?owOxf#43igeb#UEn|jkQ z>b1sj(ANjmMq|*^n~PI~YqjN>;|iwI#E84E`INoJctIeQoW5{8JK_)Qg-_Feq(iR+ z3B$jHd@909@9K|Io4ZqH0i_PxdkYuKvDwR4H_QZs-LhHm-Ch!WY!T44jaBP7dF*PPL8H7b(OxhAi89Fn5EzUL3W2_}!U zM4w2R_c`MFkh8ZKx-2KOq0yxkIqJ5OrFKfD6UGypKSZj(MoX`1h2wtuRH~m4u`bPv zT*u-by0nN3DD{Lj`u@GM;KpVHzg9WTmw({0@&F%(UL z7BTgn){+5?D!6nYCRJlpZQFY8Rl&|ON2KnSH##hlPpw5)Pb=GYI*{nf_HvsWB0M|; z*D?jPNNvHDmD|g38PbAb4CczV2h>}$?IEJsGP&=8R=wu-J-|80kU@-s3dzQVN88SJ zF2D($uUaJ9qBrZdPHf)@@tmUhEqfmpH9S{}l;}&CBp{cx{I4@^>l#$;Mn9XE2u?O& zaIEEnWLHZX<33fzZ%HC9HMp>951xkVk&I<-AhREx9}MlPjGuGJGl;dDh9A}{gQ0PD zc4`d!{aQ^oprd+yLp#%I+F5V-xPDh{v#T;w?IwP(i6QpcX&LIw4xRB#{It+*r|OOV z{()FC(d-c^}0XV=7;MOB+9dj}B=mzVF6dwlem+tF2KnmKMvm zmksz@o4E^pUkmuy7C(ILPo0msj>;VNB`slK0Qd8O{r4T~kL69!?i!xT zphGrh*Ll55#@l{;%|<^YL7SFxs@`!O9ih0aT~ z7ni3lrwHmWxz%K6wcN)ncb_CnxEJlt4@UFl;Nlv8&^;a=+D_!(d%`|6A27Pn;YhAv zUg-42#f_X(vLh94=4wM^YXbD4d563qJlb8}ofMsJsUKINCKu1p{z5muEC9o^O z%$0ueXQdvxNTW;yk_&^A008e4Qh$Ejyg0>-n9M~e!(D6U%A+q8W;;1ly;fzY_0MWr zyKfjhy?u73*Xu0=8r617Yo9Hxs$J_+J(piNU~=M)_K}*>r;?5nyOtXhD+9`@{9!4@ z-FlxmP=n-!pxv$^Lr?;@hcayBm?gXXO5@ z6QQ^7MrRDo@*isr=SvW&G|ZdX7W1lEp7{w596v81yE6Dg`6i zoXU-9#3x3qwbZ^ei^nk5at{f`w2)2^g20|6F^Y6Uxm*a6HIm0GW1hA8czLnTuQTVj z4~U>EBR=(K(Fgj@hoC>sZ}I~vbleKPKxjoT@W=TLB!Zh8afgmIdun#E7= z-7&Y}i%vNXL6N6mxuy4;kE z;}c7t0D5$P9=kVx`v@1yX0+jh)|BMb*@iwZ4Rm697SY*eA`(YE7%P`?cX|{q%8D_R8c_ z-eE6ko+y+%9HQ8n&RnPk({Ww4|6GI|T|XBgWeol^^1Z76k03?}u;1BkKmo8;uW6OL zpeq}wR+UHpeR{XcDKQ)H1+g2|X5siv`DMAosv4z)6}F*sE7aQY=lnMg12=)){uaFT zR#i=JOT6iBSG-AJ?uEEbA?q;6v^;_Mot}5t0CBe@IfF5VO=jn~j*9Fe_R@ zwPvji%@IJ$Giw${%(CpFw%7^M zXKGo(H)u3!bM5}m%a^e7ul~laT=W2}CD46vP zlJ6^*NwylbT7|&EeV*CT$r)HrMdh;Tv*%rK(T6K15J~H@*jBx;+TzqT=PklewJQH2 z9!gi>KUyu|Iy8Y(dJUcr{ZceT;DJ!vF4eV?JRKqBX!KuJp>3$LN)g^OdGItbj~kPF zv|+EVsc)z~5ywTU7>!ot8a{p;?Uninb)wQef{D_r(MWg^QR_;c{8;iwC0Y)cLy;D+ zX2qB)M)Ru_gHcfiEd7~h(XowRPsDn=+Nh|AGwPIjd-PFD#O%)I*;*DB;EaCNg;*S?npyC9WhGC2pW-qnLX-!}z3)YG+84&F=enh9Fu)w!Cu(yblWFs9d;!c`Kt3bo zW6E7_KiM{`RacswnIqC62nebCdNoh4b~>@)&)4y$>yJ0=t%>~rq_S?K%E>73x^xK5 z4~FJ=_6$zZ11`s*e;-e9!DIY@F>U;Tw4;?>bbrgJ4E5Ssy*KFB&U&@lsnI_j_M5%o zuzJ=qPIvHnd+hloy8=Ht++ufPLTiLzXW@+`X%ZJ+1AQ=uJr^E1!0Zyd8Afd2hu{gh z(@HL55g~23lBT0i?()?P#N?j;rz|Y{b4X6-0739oNv6utk_IY6TZgvlr;RR{UTZfH zR>8i~HV{Tk3Iz>XquhQjh;ztY2JH#M@Q-_evqLdjB~71eiLL(f9NBj1Z~ zbw8o*TOrt(dJdhYo`*9!nnqLCD5$iCzK7`PKmN!6 zPx+<*+~WKO3WOqdLK)qI7<_RpS;iV`HSE(!aqovPj5N~RgjH3z&K&&3It7zs;}43$ARYE*<}p| zI!RV$b@|1bKH4JYj#R|ft;%OTbtMK$sd_Rq_*c3Fs>|yxvQleSUtB*-P2b(L0;2{M zlOUm1VC0UW{B^!Q0&S-asC5_g1ZEO8SmH$Kp+A1v#oB2;>hCO);`#H3qEsDV;WK!XtNsQ$@ zdUD`0q8v*d*F5!QK^l98(U9REKQxo4FWmuDzV z-$aN*x=eBAVF;EmO>iPE{d<+Lj3@GNmv|zJs@E4Z&y>CfC(HY+Ogc`p5blJ9fm4-U zkkUx%K(Ofcu__3I(8IJ6MqE8m)hdKNu2fIx^A6OZ6jW-aVjC8g_7ve6btQf8%mPLo zCJJ6h+)`+O|XkR`jnkLT` zA@y>tx}K0JQ2hSi!?B?0wY0BSPh#3?wOp%xJxS~3cAF^LHk##HowyVa_UVV{sh*~M z*{H80XC=`D6{%|RcY|rqCgl?V>QAoRhPfL_Nx4*PYuI)P8t12Ol4=VxHa6?j2vBP6A+*eN~XLzY2 z>a?4RUauL|T7B&qb;-MwsMqILH-A$^r4_nWwX@^K52SlU=ew|Eri9zoZrO+?JfOO zd!@Frh)l^{Q+WC`cKAg#U)MG_Usp#gY!)4no~^KJqyL&Ts&8pj-EVA^_N6|lQN*(f z@cM%+lXu%2?FFPmpYYwF6(sZoiRu<4)LM&;NF-ZZ*K+GF%OHVe?&%XI^1)dfXYv=@ zShtw%E3EJngWvP$24})Y>59jwHHj!FHwIl9u zJ$6`hwSrnTL2ZkPuIEkkb#GWWej~RG{Wlmn;9>eSRg@&Sq~RH)JAs~tN-aTUi&3uU zjj}|A=3-eyXH>($6<%}1)xu@3>6o69B3K;4;yn$MdV8OUs@ z9Azn4==)Pj4A9?iP*sftxh)2`o;Sd2kh=oQlqk)Vx(2Ynw6K~y8Q1seNTM}LY+1KR zXLc5@_hTFB?n(40r%_gX%}uH*+d=h27as`S$ytu4x%f%71sDJN&1-o_EU5&a;j4ILH9*pZNa?{Mc_WDuSEV}oZ;Z5>CYj8M~uNss|u;hr2MQqijf zBf*n9-cunWwD_&~1yXr_MXMFT3-k>cJfDjy)yUzyJfM#aT8g_b6L$0E7mMh#fK`KOof1!T+9i ze*o7IR!GI5Yhw!3izk%Qkm9QnfOI6AA7;V-N`(o1qw?i!YN~l{$~vIW@Shiw`RWsg zN}a3Eo24L7{{yLn<7bNgX$~6%)1Ot;v*mZtQpTotaLlTk-qi}nwN393!`C;xgB#J< z^sZSrZf<(lDjc^qy=xba5pu47r-LnZZT_~RNS2JtX?|Pg(!i{vF1Y2N)XlxyPF-l0 zYys$_q>TcaX;}jQPts;@7fE~Of65l1JxbcC+$6dL{-31H-Y#)1#dcksUL>D+J@dW!2HnLSA?=n1BBuq}2qoo&>K2bSHP`p# zS8dA5W@{z!P@ZwOCOu0o(nNicj1ZQa71ig-sO>cCN=;3s)191}?O6ahD>?P;nM)R2 z*b(~)F79>W`1;JGT{)CVw<$Q19)%hD_Yv)VU7Imjq=)g6_JRn-~D_(X5Zy8qI zv`bdgsFiBEFiK|CYL!~H-EQ%^W?Po>o9Tk*}tyFDmc8NCV1DiG~Xw}-N*)WARQi1uLyz(~YW_Mau5h2BVHH7I^6(C7k0dWv$ zr{z#*6+<4u-#QyM`t53KFw|@H)|t^7v|5e9U~xkmnwe)_5L6_om$#skoY#hMh3v00 z?y-R%Aq-B|EZ&GuJYp|=Z#?noOm~c{O!k9+>9z1|_8TQTXeHFppN(l{EeWFtE6=wq zh01XZ4Hxlg?VoJ1!WPG84%~Q7C$6}xCw=QgB0()l$bXV-nPhY2rHiSaKxrKjUXo#)(j zMflK}-gahDCmMB#1MUQ^c8!O0h}d1!QQcodnMlzrN0=KB;#FkA&d_cQwQP&*&?BE@ zdbHC`vtfuf2M;w(vs7!;&}m)Q!40Oawd$g7*(w{ijipBQy4kjBqGXyiy;N(O;F_9f zmMmQ~o0e!aY`qFz(d$icsa-7@BMt0pS4SvTw@dA+R?{`xY*jf&F%6v9(0RMm99eCk zq!CML?Gm?|t&yl}x)>>x*0GeXx7rQ8Uai;LMy+t%gHcr{cDsB$gRzEkG?NAQUr#j1 zhyiXeN^QFZRyTDJt!>vzx>+;OZ=s2iIzW9J(OS)s-fU>CQd=8A4o8+&YU_qsYB%g= z+ithpqbd>2Fio(ZIV#mHP_)(@nI%4Im?g7W*9{HA31LJryHRh{8m3;-+f4!5js!-u zUMmTRHaF_}sMg#c!=g=5(z+%rsdAun3Tzf;fe-G?> z;@|IWMMRz~PdF?s`E2N|TC1&B?gCo;3ck_Wv`0%``BPDL3_!KZ01aH{@yNjY_Ax&9Xj)&$nA~*CV8Q~8=wm=K@JaTF0A6*id0vxFWhx++x!EN#!B{K`YE^5u zs`XZd)-hY$&F%NyAnSGGy@$V_FU$lXN zONIn6Q>Jk}aKjEflOLH4arhHP=n28+KQtbPY~(&lxS2ZZiSh)7`>#R}1dRTM&8<5S zY&2AKt_i9<8cObPvJZn(H{hX(Cex#RXku=z`d5Hr1j6|_ zFfZkHHSU(43x6E)VB%P%D@wqXr1g&C(p&m0W0)S9gYqcJWD%CU+S=R*L?!;oX1wL` zXgpwNN&LOF_R4D6#Na^dxenZI`p894g1^`*1@H(<*<)I*S3x9flcQZpx0e$8b(3pa zk=oe>j8qPrz9B%`Lu(X{uc+F&s`2w>Grl$aPwPQkfuRMWo?OY)Zayl73XL3It`%&Zsz*{#7GWKq%A+Z^gPi({ zCu~prd;0D{1cWZ>6}zFkJc#Y;Vr43lyTOE;BGnj|loa`o|M5TP5Vxv{>=Z2-uqxVZ zRu{XdiZM{hs7^_(NRG_nvM^{0yrDBKWQ$uVI5(QQ1^+LK-S7jtLtllb=zNH)(hPQ( z7Fgaqy1G4ev6OIbh(ub+s{J$ z`ORw~p1;PRpTX0dAB4C8*xEdf<5`tnjGz-7jW(og({u#X{Z$ByM+wrWk@tS`aPPRZ zLY2M}i(o#r=;RbFku}fYe()eCU;tG*VE_Byqq z?*_x(P4C@bD*L0EC$-)_Kltp7==T!DIln3^VJ@5S(e?}9t8DQxfyY0YDA(D{EfhaT zqmEu2nfM`%cSD*W>J;R3#P5_W{QZ&#QQ^zMQ3Ce{`1Jix=MLOd1zhT0sWHm(hz3=3 z&0I%;o~QnE`3%)4cb~+Tq*ZaR(PHzYDPoK=jb_>l7`#a0Z|T6?@@>&6To#J6(CrlX zNB*gDjuMJJi%_KUY#j0nyB5I)MF%v`wWiN0g5Q+wVWX>!;M8q zAmbsnUw_^|D5{xLjKhqg)FK@^>cWG916?i@C#Dla@$gwZ=}>!Dv}J)dP6+$L1LwN@ z0k7q3Vn@rVAlQ;inFmd=O2XmdXHsmPcb^@*lgz3V1NbFDY;+3OT@(nZ;8doFFR9Rd6&m6164G<84Vo!ULJC>yFY zf${(fo(ES|P+M9l*u&4-mqIc6X4r|-D=WD+J(fPPgl;=gK=hn&4=N6HVe+vBP8f|k zS}~xhTB$FJ6gPrHpg{0nG4Np$E{jItOHqVztHRyCsKS#Fm~Qn6HlGkd5Rwk4DHPd(*GnD9W;4>V=`?{X{dTEzlJXx6 zV1^>g2{PPrpVl$M$|R`hdJ_9tQB=9tE5N24c;mvC_r+WB&?&shsYsH8S3zoDQ-KG2 zkDN}yhuqAjslLaUOIp!GP)0qR8?4C;7D7FoTbl_6HhGwti=5Sw`*X^x3J2{IJ^WnR zr28-VU0ODw7U@Ge29Pwd8qqFQ>7x)l6Pm?DS*4~Eb9Qh9_hnxEV1D^ddtX)w)7THX z1+9>_{#x8!1OONRs}l?$!UOu2rr7spt}CH^w-1-~;`Hy)Vf|hCy{1* zjOBE|ED~Xlz6^12kieAZ(>d0SW8J!Q6@DM`ARr$29D`X09lcZ4ejmeWs+Zs`=|*W3 zcJwL;^X1Dy`KRlB0w$H&Pf;;tl|{&fVpfK-GN8C3>XO?;7yJ4_rSkqgyhG&z9@A+f z@0<~HV|H=Mns~F_W1KsQ2cH#wDVM6{uOD;EUzeEmV^nd()bXT|_+XSjf(x`&)N`o4 UqXW}M?@J}%n;dIGhvOgrAChp`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EcWoB$)bY%?+LvLy2Ixyzc-Rn7vppbKBJUqHP$M zs+QDRO?gGuv~{N4n?+u!dPfhYF0D`7yjhW{-Cxr-UTK#3L!K#4;8SjCt?M#x8oi`- zZ8rH556wz7_(vm0QJ8IBJyK?>WzKu7r)o{5Zr*#)@b!SsF6 zU$CHNmxKeBCTmMwHEQ3hOSHjYrKVCfy3SQ$kD9waVX@nP%A_OscHjoBQl+K~jN3&= z2xw`cc?y8akgk@d#zdeJGMA>&)DdoMpBQy9k@SGoj-oXW&6a!GPY5>TJTEm5Mb(Xm z<#RBgYg2bwo-X>dF0`_&CKzW8J@RSzZM|9#D&2qrbNFFEvmVX2fRt*t=as3VK#(Ks z<7Ho;BRUb(daV`f&f4X*)5rf;DqR*=`Wz?Gy=h(g91X`Q(cNL#VWLlzGWDPK&}%UM z+*XxIAbP;F>-~>| zbCYoZ*X;t+xxz?qa_)XVV3pqPjmw?I!$=jKt@VOqT6tdh?|_8LRtLA+<}ffw|A_Wr zY>)E@tSt&Mr+sYImJ4?R`4?60%wr8`+}U3#i%hJ1hZXPJ3XLa4YgOZzwFP?DC+m`Q zi1%Q97T&Q{#a8XCo36ZS9d_q@O`nlB;Y^kGBn|r3=N=r|iZf>@TNz^yIcy8|r?|Tm zU*zSKszO)Wh1GwxIM)Xi&M|kpkBl)1&G{E1G-N8>TLEBJ=K(C+(M7s%4xl>Y-kku# z=%b`s6pqQ6@L8=fy32DSIAZ;$ZNS$3(^svVDLT8{LOyHshTZB53qLqtmtSRnR%VN1 z`p9ngzI%C*a=qSrF!fo{F12+e_s7V`C~94xCmWR)jt9?XxBu5w)2!cLUT(MBL4PC;Xf_pLN~s8@^yyQOAo$rc z3c?Y2L3mH%<17|Qf{js3aypwxJR)fvgsBvXPcj@%<|7&2_;fW-DU4E@$f-;bmPWqE zwVrOH=$fV?9**(f;7U$pdhbeJ%QQqax<;{pyjc*ZayXv^G0o=jEJ_41osmq2lR!?z z2$m#6)FdzgiDVp1CVP6`6MD=bO=uW}X)FOYiW9mLfE!#*L{}4xM=}<})F)4d`$uqu zc7QtZDVd3(h-Jb7vMYNRpyu3h=5_&9_joe3zH2JUYYIlU$T9NzV9Y@x`=N1~ z4adFU82s;amrT#TxiD4>FK`~PF-41yI4(|Xw?}&@6|4nzR>CAa{yyU7(()w+9=Ome zRXpsi@Mv~i=hWLWRk`nacT0d@ZE{7TgaMFxa%u2z;ehYee8Xi^>TXizOTXOT$oLH$ z=d;cl%yxetv08u4OgLR8&weF)lG6GB7Y8PfHC7L}7GgIv_@JX)GWxF(67|ZXhx+F)$!7GCD9b zIxsXKM@>`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EfdTDSC3PW#hZe?S1X>V>iAY*KAb7c(*4GJHN z2nc&(dPe{QGhZ+_>yFXk@L}ZnzWNCEx{IMBvK_QJMJkE z1zSu>LM2FP)L-AXAoUez(nC`nVuo1kzV~+Vh?g(_`;R<&@=I5mX5$%6@=RA&`?S%u z%}qsb2d`dxL$lu1`Qxgg=h+K-{qEg6dP#3yz54mE@1{2GdO$%@kPEa_Ypd&xUJktP z02!FQSTA$i)cK-q7?`S-)LKn>Mb@-+rrn!GUa5LV52h}yPusj%k*VEZ(>7jdmia@T zDNf*1ZfULSGH)8aq;+jJ`4SJ!N;UXLBS%q~ZC*W6W~yb*d#tBwO{H$$d(iOpfX*>l zG7oz&nOP#TwGD)56hLxHwJ;lA>ecM}P?-jz`v?G_0_ix*v81DQjt4cfLgl5d2Oc-` z%~K#Kcp}9f2uLnlfcsytpk|kZ1C}OhOIXZs!C5HRbh{syFOvD+keWW zBlvdU2CY)1rVEVQMMnr|X`y)vfXa}rmZru;pb|2drqR?9Zfu_zbup3jfYpwoH4n{} zd)iM3Hsm}nH4jDAjfdrPFraHwcUhh;`m`>zvaBW;XAM2_Y4~luS`RASfC6*)VL-DU z&9{J*YPaW=siHuTBkbd4U!Nm75!8CE73 zVc21!Pn0tCpZ3seF#g&ISKEcvf3-N*2NljSce{^_F$vB27a}xdD&1QFU{>b= zEZfmVx^E7kI^*7*0K({_q*@e?$(it3tueaGb0Rom{ikif*8S60t(z%2yWB!PYxIWQ z>I(}$IA51vWq(#?i(~r8Zuh=>d69Cx-g_|hSK{}QRCDCvp0XB*gx)OjJTunq* z6O2bP7Q@shPlo$PaD;Y%I`Ju)iJ{~N@lk+R5a0Wp7)cZH`y4@7q){*pZa~v}{%v`< zEyH;%97br8%&(GErt?(LO%#n1&g>;3zLi6f{6do`anj8b;iEI<^oiitjlo%iucU)7@C$eazZAu>y$TB@k_x zo`#_wG)(D8l0tDakvAe73SNyk%biTb3onRe!U3`?dl#VQ+;Qf10af>SGPS;ID#>dK zMz_c@^7>%RK_dI1aheUsz2F%9?{t?;&%U`ZRtqn19IQszs)+~3If4IJmQ&Kk^ie;=`0f6YujAUnq&oQV_sf$I~A>M^grW=^W{P80o& S;6Y|eWcmj?o~>Y#3;+OD2L>Ae literal 0 HcmV?d00001 diff --git a/vendor/pear/http_request2/tests/_files/response_gzip_broken b/vendor/pear/http_request2/tests/_files/response_gzip_broken new file mode 100644 index 0000000000000000000000000000000000000000..0df0d1522f8a377ac905b20db95eb29dc1428493 GIT binary patch literal 221 zcmYL?%}N6?6h;efN+8eRT~;ueWJaY%T=?6flnywGJBjI~4V0T9bJ1yi1fR$Eb8zGK zJBRblo2D+Twon=a%SS10J)?vB9FM_Rcbtr`thu`Dz*ZY1pI;h@^)!g&w=VkE=MxZ~{ literal 0 HcmV?d00001 diff --git a/vendor/pear/http_request2/tests/_files/response_headers b/vendor/pear/http_request2/tests/_files/response_headers new file mode 100644 index 000000000..f60787bd5 --- /dev/null +++ b/vendor/pear/http_request2/tests/_files/response_headers @@ -0,0 +1,12 @@ +HTTP/1.1 200 OK +Date: Fri, 01 Jan 2010 02:03:04 GMT +Vary: accept-charset +Server: Apache/3.0.1 (Unix) +X-Powered-By: PHP/6.2.2 +Vary: user-agent +Content-Type: text/html; + charset=windows-1251 +Content-Length: 32 +Connection: close + +Nothing to see here, move along. \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/basicauth.php b/vendor/pear/http_request2/tests/_network/basicauth.php new file mode 100644 index 000000000..740df638c --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/basicauth.php @@ -0,0 +1,33 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +$user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null; +$pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null; +$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; +$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; + +if (!$user || !$pass || $user != $wantedUser || $pass != $wantedPass) { + header('WWW-Authenticate: Basic realm="HTTP_Request2 tests"', true, 401); + echo "Login required"; +} else { + echo "Username={$user};Password={$pass}"; +} + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/bug19934.php b/vendor/pear/http_request2/tests/_network/bug19934.php new file mode 100644 index 000000000..059387107 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/bug19934.php @@ -0,0 +1,27 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +for ($i = 0; $i < 20; $i++) { + for ($j = 0; $j < 10; $j++) { + echo str_repeat((string)$j, 98) . "\r\n"; + } + flush(); + usleep(50000); +} \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/cookies.php b/vendor/pear/http_request2/tests/_network/cookies.php new file mode 100644 index 000000000..821b1b19f --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/cookies.php @@ -0,0 +1,24 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +ksort($_COOKIE); +echo serialize($_COOKIE); + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/digestauth.php b/vendor/pear/http_request2/tests/_network/digestauth.php new file mode 100644 index 000000000..30c4e0d81 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/digestauth.php @@ -0,0 +1,83 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +/** + * Mostly borrowed from PHP manual and Socket Adapter implementation + * + * @link http://php.net/manual/en/features.http-auth.php + */ + +/** + * Parses the Digest auth header + * + * @param string $txt + */ +function http_digest_parse($txt) +{ + $token = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; + $quoted = '"(?:\\\\.|[^\\\\"])*"'; + + // protect against missing data + $needed_parts = array_flip(array('nonce', 'nc', 'cnonce', 'qop', 'username', 'uri', 'response')); + $data = array(); + + preg_match_all("!({$token})\\s*=\\s*({$token}|{$quoted})!", $txt, $matches); + for ($i = 0; $i < count($matches[0]); $i++) { + // ignore unneeded parameters + if (isset($needed_parts[$matches[1][$i]])) { + unset($needed_parts[$matches[1][$i]]); + if ('"' == substr($matches[2][$i], 0, 1)) { + $data[$matches[1][$i]] = substr($matches[2][$i], 1, -1); + } else { + $data[$matches[1][$i]] = $matches[2][$i]; + } + } + } + + return !empty($needed_parts) ? false : $data; +} + +$realm = 'HTTP_Request2 tests'; +$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; +$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; +$validAuth = false; + +if (!empty($_SERVER['PHP_AUTH_DIGEST']) + && ($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) + && $wantedUser == $data['username'] +) { + // generate the valid response + $a1 = md5($data['username'] . ':' . $realm . ':' . $wantedPass); + $a2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); + $response = md5($a1. ':' . $data['nonce'] . ':' . $data['nc'] . ':' + . $data['cnonce'] . ':' . $data['qop'] . ':' . $a2); + + // check valid response against existing one + $validAuth = ($data['response'] == $response); +} + +if (!$validAuth || empty($_SERVER['PHP_AUTH_DIGEST'])) { + header('WWW-Authenticate: Digest realm="' . $realm . + '",qop="auth",nonce="' . uniqid() . '"', true, 401); + echo "Login required"; +} else { + echo "Username={$user}"; +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/getparameters.php b/vendor/pear/http_request2/tests/_network/getparameters.php new file mode 100644 index 000000000..7c92f7036 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/getparameters.php @@ -0,0 +1,24 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +ksort($_GET); +echo serialize($_GET); + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/postparameters.php b/vendor/pear/http_request2/tests/_network/postparameters.php new file mode 100644 index 000000000..ce67cbc4c --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/postparameters.php @@ -0,0 +1,24 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +ksort($_POST); +echo serialize($_POST); + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/rawpostdata.php b/vendor/pear/http_request2/tests/_network/rawpostdata.php new file mode 100644 index 000000000..8a39c2f57 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/rawpostdata.php @@ -0,0 +1,22 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +readfile('php://input'); +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/redirects.php b/vendor/pear/http_request2/tests/_network/redirects.php new file mode 100644 index 000000000..4af8c0841 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/redirects.php @@ -0,0 +1,47 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +$redirects = isset($_GET['redirects'])? $_GET['redirects']: 1; +$https = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS'])); +$special = isset($_GET['special'])? $_GET['special']: null; + +if ('ftp' == $special) { + header('Location: ftp://localhost/pub/exploit.exe', true, 301); + +} elseif ('relative' == $special) { + header('Location: ./getparameters.php?msg=did%20relative%20redirect', true, 302); + +} elseif ('cookie' == $special) { + setcookie('cookie_on_redirect', 'success'); + header('Location: ./cookies.php', true, 302); + +} elseif ($redirects > 0) { + $url = ($https? 'https': 'http') . '://' . $_SERVER['SERVER_NAME'] + . (($https && 443 == $_SERVER['SERVER_PORT'] || !$https && 80 == $_SERVER['SERVER_PORT']) + ? '' : ':' . $_SERVER['SERVER_PORT']) + . $_SERVER['PHP_SELF'] . '?redirects=' . (--$redirects); + header('Location: ' . $url, true, 302); + +} else { + echo "Method=" . $_SERVER['REQUEST_METHOD'] . ';'; + var_dump($_POST); + var_dump($_GET); +} +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/setcookie.php b/vendor/pear/http_request2/tests/_network/setcookie.php new file mode 100644 index 000000000..0af79dfb6 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/setcookie.php @@ -0,0 +1,27 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +$name = empty($_GET['name'])? 'foo': $_GET['name']; +$value = empty($_GET['value'])? 'bar': $_GET['value']; + +setcookie($name, $value); + +echo "Cookie set!"; +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/timeout.php b/vendor/pear/http_request2/tests/_network/timeout.php new file mode 100644 index 000000000..03bba7415 --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/timeout.php @@ -0,0 +1,23 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +sleep(5); + +?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/uploads.php b/vendor/pear/http_request2/tests/_network/uploads.php new file mode 100644 index 000000000..28c0f299c --- /dev/null +++ b/vendor/pear/http_request2/tests/_network/uploads.php @@ -0,0 +1,36 @@ + + * @copyright 2008-2014 Alexey Borzov + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @link http://pear.php.net/package/HTTP_Request2 + */ + +if (isset($_GET['slowpoke'])) { + sleep(3); +} + +if (!empty($_FILES)) { + foreach ($_FILES as $name => $file) { + if (is_array($file['name'])) { + foreach($file['name'] as $k => $v) { + echo "{$name}[{$k}] {$v} {$file['type'][$k]} {$file['size'][$k]}\n"; + } + } else { + echo "{$name} {$file['name']} {$file['type']} {$file['size']}\n"; + } + } +} +?> \ No newline at end of file diff --git a/vendor/pear/net_url2/.gitignore b/vendor/pear/net_url2/.gitignore new file mode 100644 index 000000000..0e7f38ac3 --- /dev/null +++ b/vendor/pear/net_url2/.gitignore @@ -0,0 +1,7 @@ +# pear related +/Net_URL2-*.tgz + +# composer related +vendor/ +/composer.lock +/composer.phar diff --git a/vendor/pear/net_url2/.scrutinizer.yml b/vendor/pear/net_url2/.scrutinizer.yml new file mode 100644 index 000000000..bfdb37388 --- /dev/null +++ b/vendor/pear/net_url2/.scrutinizer.yml @@ -0,0 +1,38 @@ +filter: + excluded_paths: + - 'docs/*' +tools: + php_code_coverage: + enabled: true + test_command: phpunit + php_cpd: + excluded_dirs: + - tests + filter: + excluded_paths: [] + php_pdepend: + excluded_dirs: + - tests + php_hhvm: + filter: + excluded_paths: [] + php_mess_detector: + filter: + excluded_paths: [] + php_analyzer: + enabled: true + filter: + excluded_paths: ['docs/*'] + php_code_sniffer: + enabled: true + filter: + excluded_paths: ['docs/*'] + config: + tab_width: 4 + encoding: utf8 + ruleset: ~ + standard: PEAR + php_loc: + excluded_dirs: + - tests + - docs diff --git a/vendor/pear/net_url2/.travis.yml b/vendor/pear/net_url2/.travis.yml new file mode 100644 index 000000000..a3e7bdc49 --- /dev/null +++ b/vendor/pear/net_url2/.travis.yml @@ -0,0 +1,17 @@ +language: php + +php: + - 5.2 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + - hhvm-nightly + +matrix: + allow_failures: + - php: hhvm-nightly + +script: phpunit --coverage-text tests/Net diff --git a/vendor/pear/net_url2/Net/URL2.php b/vendor/pear/net_url2/Net/URL2.php new file mode 100755 index 000000000..dba48ce04 --- /dev/null +++ b/vendor/pear/net_url2/Net/URL2.php @@ -0,0 +1,1219 @@ + + * @copyright 2007-2009 Peytz & Co. A/S + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @version CVS: $Id$ + * @link https://tools.ietf.org/html/rfc3986 + */ + +/** + * Represents a URL as per RFC 3986. + * + * @category Networking + * @package Net_URL2 + * @author Christian Schmidt + * @copyright 2007-2009 Peytz & Co. A/S + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @version Release: @package_version@ + * @link https://pear.php.net/package/Net_URL2 + */ +class Net_URL2 +{ + /** + * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default + * is true. + */ + const OPTION_STRICT = 'strict'; + + /** + * Represent arrays in query using PHP's [] notation. Default is true. + */ + const OPTION_USE_BRACKETS = 'use_brackets'; + + /** + * Drop zero-based integer sequences in query using PHP's [] notation. Default + * is true. + */ + const OPTION_DROP_SEQUENCE = 'drop_sequence'; + + /** + * URL-encode query variable keys. Default is true. + */ + const OPTION_ENCODE_KEYS = 'encode_keys'; + + /** + * Query variable separators when parsing the query string. Every character + * is considered a separator. Default is "&". + */ + const OPTION_SEPARATOR_INPUT = 'input_separator'; + + /** + * Query variable separator used when generating the query string. Default + * is "&". + */ + const OPTION_SEPARATOR_OUTPUT = 'output_separator'; + + /** + * Default options corresponds to how PHP handles $_GET. + */ + private $_options = array( + self::OPTION_STRICT => true, + self::OPTION_USE_BRACKETS => true, + self::OPTION_DROP_SEQUENCE => true, + self::OPTION_ENCODE_KEYS => true, + self::OPTION_SEPARATOR_INPUT => '&', + self::OPTION_SEPARATOR_OUTPUT => '&', + ); + + /** + * @var string|bool + */ + private $_scheme = false; + + /** + * @var string|bool + */ + private $_userinfo = false; + + /** + * @var string|bool + */ + private $_host = false; + + /** + * @var string|bool + */ + private $_port = false; + + /** + * @var string + */ + private $_path = ''; + + /** + * @var string|bool + */ + private $_query = false; + + /** + * @var string|bool + */ + private $_fragment = false; + + /** + * Constructor. + * + * @param string $url an absolute or relative URL + * @param array $options an array of OPTION_xxx constants + * + * @uses self::parseUrl() + */ + public function __construct($url, array $options = array()) + { + foreach ($options as $optionName => $value) { + if (array_key_exists($optionName, $this->_options)) { + $this->_options[$optionName] = $value; + } + } + + $this->parseUrl($url); + } + + /** + * Magic Setter. + * + * This method will magically set the value of a private variable ($var) + * with the value passed as the args + * + * @param string $var The private variable to set. + * @param mixed $arg An argument of any type. + * + * @return void + */ + public function __set($var, $arg) + { + $method = 'set' . $var; + if (method_exists($this, $method)) { + $this->$method($arg); + } + } + + /** + * Magic Getter. + * + * This is the magic get method to retrieve the private variable + * that was set by either __set() or it's setter... + * + * @param string $var The property name to retrieve. + * + * @return mixed $this->$var Either a boolean false if the + * property is not set or the value + * of the private property. + */ + public function __get($var) + { + $method = 'get' . $var; + if (method_exists($this, $method)) { + return $this->$method(); + } + + return false; + } + + /** + * Returns the scheme, e.g. "http" or "urn", or false if there is no + * scheme specified, i.e. if this is a relative URL. + * + * @return string|bool + */ + public function getScheme() + { + return $this->_scheme; + } + + /** + * Sets the scheme, e.g. "http" or "urn". Specify false if there is no + * scheme specified, i.e. if this is a relative URL. + * + * @param string|bool $scheme e.g. "http" or "urn", or false if there is no + * scheme specified, i.e. if this is a relative + * URL + * + * @return $this + * @see getScheme + */ + public function setScheme($scheme) + { + $this->_scheme = $scheme; + return $this; + } + + /** + * Returns the user part of the userinfo part (the part preceding the first + * ":"), or false if there is no userinfo part. + * + * @return string|bool + */ + public function getUser() + { + return $this->_userinfo !== false + ? preg_replace('(:.*$)', '', $this->_userinfo) + : false; + } + + /** + * Returns the password part of the userinfo part (the part after the first + * ":"), or false if there is no userinfo part (i.e. the URL does not + * contain "@" in front of the hostname) or the userinfo part does not + * contain ":". + * + * @return string|bool + */ + public function getPassword() + { + return $this->_userinfo !== false + ? substr(strstr($this->_userinfo, ':'), 1) + : false; + } + + /** + * Returns the userinfo part, or false if there is none, i.e. if the + * authority part does not contain "@". + * + * @return string|bool + */ + public function getUserinfo() + { + return $this->_userinfo; + } + + /** + * Sets the userinfo part. If two arguments are passed, they are combined + * in the userinfo part as username ":" password. + * + * @param string|bool $userinfo userinfo or username + * @param string|bool $password optional password, or false + * + * @return $this + */ + public function setUserinfo($userinfo, $password = false) + { + if ($password !== false) { + $userinfo .= ':' . $password; + } + + if ($userinfo !== false) { + $userinfo = $this->_encodeData($userinfo); + } + + $this->_userinfo = $userinfo; + return $this; + } + + /** + * Returns the host part, or false if there is no authority part, e.g. + * relative URLs. + * + * @return string|bool a hostname, an IP address, or false + */ + public function getHost() + { + return $this->_host; + } + + /** + * Sets the host part. Specify false if there is no authority part, e.g. + * relative URLs. + * + * @param string|bool $host a hostname, an IP address, or false + * + * @return $this + */ + public function setHost($host) + { + $this->_host = $host; + return $this; + } + + /** + * Returns the port number, or false if there is no port number specified, + * i.e. if the default port is to be used. + * + * @return string|bool + */ + public function getPort() + { + return $this->_port; + } + + /** + * Sets the port number. Specify false if there is no port number specified, + * i.e. if the default port is to be used. + * + * @param string|bool $port a port number, or false + * + * @return $this + */ + public function setPort($port) + { + $this->_port = $port; + return $this; + } + + /** + * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or + * false if there is no authority. + * + * @return string|bool + */ + public function getAuthority() + { + if (false === $this->_host) { + return false; + } + + $authority = ''; + + if (strlen($this->_userinfo)) { + $authority .= $this->_userinfo . '@'; + } + + $authority .= $this->_host; + + if ($this->_port !== false) { + $authority .= ':' . $this->_port; + } + + return $authority; + } + + /** + * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify + * false if there is no authority. + * + * @param string|bool $authority a hostname or an IP address, possibly + * with userinfo prefixed and port number + * appended, e.g. "foo:bar@example.org:81". + * + * @return $this + */ + public function setAuthority($authority) + { + $this->_userinfo = false; + $this->_host = false; + $this->_port = false; + + if ('' === $authority) { + $this->_host = $authority; + return $this; + } + + if (!preg_match('(^(([^\@]*)\@)?(.+?)(:(\d*))?$)', $authority, $matches)) { + return $this; + } + + if ($matches[1]) { + $this->_userinfo = $this->_encodeData($matches[2]); + } + + $this->_host = $matches[3]; + + if (isset($matches[5]) && strlen($matches[5])) { + $this->_port = $matches[5]; + } + return $this; + } + + /** + * Returns the path part (possibly an empty string). + * + * @return string + */ + public function getPath() + { + return $this->_path; + } + + /** + * Sets the path part (possibly an empty string). + * + * @param string $path a path + * + * @return $this + */ + public function setPath($path) + { + $this->_path = $path; + return $this; + } + + /** + * Returns the query string (excluding the leading "?"), or false if "?" + * is not present in the URL. + * + * @return string|bool + * @see getQueryVariables + */ + public function getQuery() + { + return $this->_query; + } + + /** + * Sets the query string (excluding the leading "?"). Specify false if "?" + * is not present in the URL. + * + * @param string|bool $query a query string, e.g. "foo=1&bar=2" + * + * @return $this + * @see setQueryVariables + */ + public function setQuery($query) + { + $this->_query = $query; + return $this; + } + + /** + * Returns the fragment name, or false if "#" is not present in the URL. + * + * @return string|bool + */ + public function getFragment() + { + return $this->_fragment; + } + + /** + * Sets the fragment name. Specify false if "#" is not present in the URL. + * + * @param string|bool $fragment a fragment excluding the leading "#", or + * false + * + * @return $this + */ + public function setFragment($fragment) + { + $this->_fragment = $fragment; + return $this; + } + + /** + * Returns the query string like an array as the variables would appear in + * $_GET in a PHP script. If the URL does not contain a "?", an empty array + * is returned. + * + * @return array + */ + public function getQueryVariables() + { + $separator = $this->getOption(self::OPTION_SEPARATOR_INPUT); + $encodeKeys = $this->getOption(self::OPTION_ENCODE_KEYS); + $useBrackets = $this->getOption(self::OPTION_USE_BRACKETS); + + $return = array(); + + for ($part = strtok($this->_query, $separator); + strlen($part); + $part = strtok($separator) + ) { + list($key, $value) = explode('=', $part, 2) + array(1 => ''); + + if ($encodeKeys) { + $key = rawurldecode($key); + } + $value = rawurldecode($value); + + if ($useBrackets) { + $return = $this->_queryArrayByKey($key, $value, $return); + } else { + if (isset($return[$key])) { + $return[$key] = (array) $return[$key]; + $return[$key][] = $value; + } else { + $return[$key] = $value; + } + } + } + + return $return; + } + + /** + * Parse a single query key=value pair into an existing php array + * + * @param string $key query-key + * @param string $value query-value + * @param array $array of existing query variables (if any) + * + * @return mixed + */ + private function _queryArrayByKey($key, $value, array $array = array()) + { + if (!strlen($key)) { + return $array; + } + + $offset = $this->_queryKeyBracketOffset($key); + if ($offset === false) { + $name = $key; + } else { + $name = substr($key, 0, $offset); + } + + if (!strlen($name)) { + return $array; + } + + if (!$offset) { + // named value + $array[$name] = $value; + } else { + // array + $brackets = substr($key, $offset); + if (!isset($array[$name])) { + $array[$name] = null; + } + $array[$name] = $this->_queryArrayByBrackets( + $brackets, $value, $array[$name] + ); + } + + return $array; + } + + /** + * Parse a key-buffer to place value in array + * + * @param string $buffer to consume all keys from + * @param string $value to be set/add + * @param array $array to traverse and set/add value in + * + * @throws Exception + * @return array + */ + private function _queryArrayByBrackets($buffer, $value, array $array = null) + { + $entry = &$array; + + for ($iteration = 0; strlen($buffer); $iteration++) { + $open = $this->_queryKeyBracketOffset($buffer); + if ($open !== 0) { + // Opening bracket [ must exist at offset 0, if not, there is + // no bracket to parse and the value dropped. + // if this happens in the first iteration, this is flawed, see + // as well the second exception below. + if ($iteration) { + break; + } + // @codeCoverageIgnoreStart + throw new Exception( + 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . + 'Opening bracket [ must exist at offset 0' + ); + // @codeCoverageIgnoreEnd + } + + $close = strpos($buffer, ']', 1); + if (!$close) { + // this error condition should never be reached as this is a + // private method and bracket pairs are checked beforehand. + // See as well the first exception for the opening bracket. + // @codeCoverageIgnoreStart + throw new Exception( + 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . + 'Closing bracket ] must exist, not found' + ); + // @codeCoverageIgnoreEnd + } + + $index = substr($buffer, 1, $close - 1); + if (strlen($index)) { + $entry = &$entry[$index]; + } else { + if (!is_array($entry)) { + $entry = array(); + } + $entry[] = &$new; + $entry = &$new; + unset($new); + } + $buffer = substr($buffer, $close + 1); + } + + $entry = $value; + + return $array; + } + + /** + * Query-key has brackets ("...[]") + * + * @param string $key query-key + * + * @return bool|int offset of opening bracket, false if no brackets + */ + private function _queryKeyBracketOffset($key) + { + if (false !== $open = strpos($key, '[') + and false === strpos($key, ']', $open + 1) + ) { + $open = false; + } + + return $open; + } + + /** + * Sets the query string to the specified variable in the query string. + * + * @param array $array (name => value) array + * + * @return $this + */ + public function setQueryVariables(array $array) + { + if (!$array) { + $this->_query = false; + } else { + $this->_query = $this->buildQuery( + $array, + $this->getOption(self::OPTION_SEPARATOR_OUTPUT) + ); + } + return $this; + } + + /** + * Sets the specified variable in the query string. + * + * @param string $name variable name + * @param mixed $value variable value + * + * @return $this + */ + public function setQueryVariable($name, $value) + { + $array = $this->getQueryVariables(); + $array[$name] = $value; + $this->setQueryVariables($array); + return $this; + } + + /** + * Removes the specified variable from the query string. + * + * @param string $name a query string variable, e.g. "foo" in "?foo=1" + * + * @return void + */ + public function unsetQueryVariable($name) + { + $array = $this->getQueryVariables(); + unset($array[$name]); + $this->setQueryVariables($array); + } + + /** + * Returns a string representation of this URL. + * + * @return string + */ + public function getURL() + { + // See RFC 3986, section 5.3 + $url = ''; + + if ($this->_scheme !== false) { + $url .= $this->_scheme . ':'; + } + + $authority = $this->getAuthority(); + if ($authority === false && strtolower($this->_scheme) === 'file') { + $authority = ''; + } + + $url .= $this->_buildAuthorityAndPath($authority, $this->_path); + + if ($this->_query !== false) { + $url .= '?' . $this->_query; + } + + if ($this->_fragment !== false) { + $url .= '#' . $this->_fragment; + } + + return $url; + } + + /** + * Put authority and path together, wrapping authority + * into proper separators/terminators. + * + * @param string|bool $authority authority + * @param string $path path + * + * @return string + */ + private function _buildAuthorityAndPath($authority, $path) + { + if ($authority === false) { + return $path; + } + + $terminator = ($path !== '' && $path[0] !== '/') ? '/' : ''; + + return '//' . $authority . $terminator . $path; + } + + /** + * Returns a string representation of this URL. + * + * @return string + * @link https://php.net/language.oop5.magic#object.tostring + */ + public function __toString() + { + return $this->getURL(); + } + + /** + * Returns a normalized string representation of this URL. This is useful + * for comparison of URLs. + * + * @return string + */ + public function getNormalizedURL() + { + $url = clone $this; + $url->normalize(); + return $url->getUrl(); + } + + /** + * Normalizes the URL + * + * See RFC 3986, Section 6. Normalization and Comparison + * + * @link https://tools.ietf.org/html/rfc3986#section-6 + * + * @return void + */ + public function normalize() + { + // See RFC 3986, section 6 + + // Scheme is case-insensitive + if ($this->_scheme) { + $this->_scheme = strtolower($this->_scheme); + } + + // Hostname is case-insensitive + if ($this->_host) { + $this->_host = strtolower($this->_host); + } + + // Remove default port number for known schemes (RFC 3986, section 6.2.3) + if ('' === $this->_port + || $this->_port + && $this->_scheme + && $this->_port == getservbyname($this->_scheme, 'tcp') + ) { + $this->_port = false; + } + + // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) + // Normalize percentage-encoded unreserved characters (section 6.2.2.2) + $fields = array(&$this->_userinfo, &$this->_host, &$this->_path, + &$this->_query, &$this->_fragment); + foreach ($fields as &$field) { + if ($field !== false) { + $field = $this->_normalize("$field"); + } + } + unset($field); + + // Path segment normalization (RFC 3986, section 6.2.2.3) + $this->_path = self::removeDotSegments($this->_path); + + // Scheme based normalization (RFC 3986, section 6.2.3) + if (false !== $this->_host && '' === $this->_path) { + $this->_path = '/'; + } + + // path should start with '/' if there is authority (section 3.3.) + if (strlen($this->getAuthority()) + && strlen($this->_path) + && $this->_path[0] !== '/' + ) { + $this->_path = '/' . $this->_path; + } + } + + /** + * Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) + * Normalize percentage-encoded unreserved characters (section 6.2.2.2) + * + * @param string|array $mixed string or array of strings to normalize + * + * @return string|array + * @see normalize + * @see _normalizeCallback() + */ + private function _normalize($mixed) + { + return preg_replace_callback( + '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), + $mixed + ); + } + + /** + * Callback for _normalize() of %XX percentage-encodings + * + * @param array $matches as by preg_replace_callback + * + * @return string + * @see normalize + * @see _normalize + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private function _normalizeCallback($matches) + { + return self::urlencode(urldecode($matches[0])); + } + + /** + * Returns whether this instance represents an absolute URL. + * + * @return bool + */ + public function isAbsolute() + { + return (bool) $this->_scheme; + } + + /** + * Returns an Net_URL2 instance representing an absolute URL relative to + * this URL. + * + * @param Net_URL2|string $reference relative URL + * + * @throws Exception + * @return $this + */ + public function resolve($reference) + { + if (!$reference instanceof Net_URL2) { + $reference = new self($reference); + } + if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { + throw new Exception( + 'Base-URL must be absolute if reference is not fragment-only' + ); + } + + // A non-strict parser may ignore a scheme in the reference if it is + // identical to the base URI's scheme. + if (!$this->getOption(self::OPTION_STRICT) + && $reference->_scheme == $this->_scheme + ) { + $reference->_scheme = false; + } + + $target = new self(''); + if ($reference->_scheme !== false) { + $target->_scheme = $reference->_scheme; + $target->setAuthority($reference->getAuthority()); + $target->_path = self::removeDotSegments($reference->_path); + $target->_query = $reference->_query; + } else { + $authority = $reference->getAuthority(); + if ($authority !== false) { + $target->setAuthority($authority); + $target->_path = self::removeDotSegments($reference->_path); + $target->_query = $reference->_query; + } else { + if ($reference->_path == '') { + $target->_path = $this->_path; + if ($reference->_query !== false) { + $target->_query = $reference->_query; + } else { + $target->_query = $this->_query; + } + } else { + if (substr($reference->_path, 0, 1) == '/') { + $target->_path = self::removeDotSegments($reference->_path); + } else { + // Merge paths (RFC 3986, section 5.2.3) + if ($this->_host !== false && $this->_path == '') { + $target->_path = '/' . $reference->_path; + } else { + $i = strrpos($this->_path, '/'); + if ($i !== false) { + $target->_path = substr($this->_path, 0, $i + 1); + } + $target->_path .= $reference->_path; + } + $target->_path = self::removeDotSegments($target->_path); + } + $target->_query = $reference->_query; + } + $target->setAuthority($this->getAuthority()); + } + $target->_scheme = $this->_scheme; + } + + $target->_fragment = $reference->_fragment; + + return $target; + } + + /** + * URL is fragment-only + * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @return bool + */ + private function _isFragmentOnly() + { + return ( + $this->_fragment !== false + && $this->_query === false + && $this->_path === '' + && $this->_port === false + && $this->_host === false + && $this->_userinfo === false + && $this->_scheme === false + ); + } + + /** + * Removes dots as described in RFC 3986, section 5.2.4, e.g. + * "/foo/../bar/baz" => "/bar/baz" + * + * @param string $path a path + * + * @return string a path + */ + public static function removeDotSegments($path) + { + $path = (string) $path; + $output = ''; + + // Make sure not to be trapped in an infinite loop due to a bug in this + // method + $loopLimit = 256; + $j = 0; + while ('' !== $path && $j++ < $loopLimit) { + if (substr($path, 0, 2) === './') { + // Step 2.A + $path = substr($path, 2); + } elseif (substr($path, 0, 3) === '../') { + // Step 2.A + $path = substr($path, 3); + } elseif (substr($path, 0, 3) === '/./' || $path === '/.') { + // Step 2.B + $path = '/' . substr($path, 3); + } elseif (substr($path, 0, 4) === '/../' || $path === '/..') { + // Step 2.C + $path = '/' . substr($path, 4); + $i = strrpos($output, '/'); + $output = $i === false ? '' : substr($output, 0, $i); + } elseif ($path === '.' || $path === '..') { + // Step 2.D + $path = ''; + } else { + // Step 2.E + $i = strpos($path, '/', $path[0] === '/'); + if ($i === false) { + $output .= $path; + $path = ''; + break; + } + $output .= substr($path, 0, $i); + $path = substr($path, $i); + } + } + + if ($path !== '') { + $message = sprintf( + 'Unable to remove dot segments; hit loop limit %d (left: %s)', + $j, var_export($path, true) + ); + trigger_error($message, E_USER_WARNING); + } + + return $output; + } + + /** + * Percent-encodes all non-alphanumeric characters except these: _ . - ~ + * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP + * 5.2.x and earlier. + * + * @param string $string string to encode + * + * @return string + */ + public static function urlencode($string) + { + $encoded = rawurlencode($string); + + // This is only necessary in PHP < 5.3. + $encoded = str_replace('%7E', '~', $encoded); + return $encoded; + } + + /** + * Returns a Net_URL2 instance representing the canonical URL of the + * currently executing PHP script. + * + * @throws Exception + * @return string + */ + public static function getCanonical() + { + if (!isset($_SERVER['REQUEST_METHOD'])) { + // ALERT - no current URL + throw new Exception('Script was not called through a webserver'); + } + + // Begin with a relative URL + $url = new self($_SERVER['PHP_SELF']); + $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; + $url->_host = $_SERVER['SERVER_NAME']; + $port = $_SERVER['SERVER_PORT']; + if ($url->_scheme == 'http' && $port != 80 + || $url->_scheme == 'https' && $port != 443 + ) { + $url->_port = $port; + } + return $url; + } + + /** + * Returns the URL used to retrieve the current request. + * + * @return string + */ + public static function getRequestedURL() + { + return self::getRequested()->getUrl(); + } + + /** + * Returns a Net_URL2 instance representing the URL used to retrieve the + * current request. + * + * @throws Exception + * @return $this + */ + public static function getRequested() + { + if (!isset($_SERVER['REQUEST_METHOD'])) { + // ALERT - no current URL + throw new Exception('Script was not called through a webserver'); + } + + // Begin with a relative URL + $url = new self($_SERVER['REQUEST_URI']); + $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; + // Set host and possibly port + $url->setAuthority($_SERVER['HTTP_HOST']); + return $url; + } + + /** + * Returns the value of the specified option. + * + * @param string $optionName The name of the option to retrieve + * + * @return mixed + */ + public function getOption($optionName) + { + return isset($this->_options[$optionName]) + ? $this->_options[$optionName] : false; + } + + /** + * A simple version of http_build_query in userland. The encoded string is + * percentage encoded according to RFC 3986. + * + * @param array $data An array, which has to be converted into + * QUERY_STRING. Anything is possible. + * @param string $separator Separator {@link self::OPTION_SEPARATOR_OUTPUT} + * @param string $key For stacked values (arrays in an array). + * + * @return string + */ + protected function buildQuery(array $data, $separator, $key = null) + { + $query = array(); + $drop_names = ( + $this->_options[self::OPTION_DROP_SEQUENCE] === true + && array_keys($data) === array_keys(array_values($data)) + ); + foreach ($data as $name => $value) { + if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { + $name = rawurlencode($name); + } + if ($key !== null) { + if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { + $drop_names && $name = ''; + $name = $key . '[' . $name . ']'; + } else { + $name = $key; + } + } + if (is_array($value)) { + $query[] = $this->buildQuery($value, $separator, $name); + } else { + $query[] = $name . '=' . rawurlencode($value); + } + } + return implode($separator, $query); + } + + /** + * This method uses a regex to parse the url into the designated parts. + * + * @param string $url URL + * + * @return void + * @uses self::$_scheme, self::setAuthority(), self::$_path, self::$_query, + * self::$_fragment + * @see __construct + */ + protected function parseUrl($url) + { + // The regular expression is copied verbatim from RFC 3986, appendix B. + // The expression does not validate the URL but matches any string. + preg_match( + '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', + $url, $matches + ); + + // "path" is always present (possibly as an empty string); the rest + // are optional. + $this->_scheme = !empty($matches[1]) ? $matches[2] : false; + $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); + $this->_path = $this->_encodeData($matches[5]); + $this->_query = !empty($matches[6]) + ? $this->_encodeData($matches[7]) + : false + ; + $this->_fragment = !empty($matches[8]) ? $matches[9] : false; + } + + /** + * Encode characters that might have been forgotten to encode when passing + * in an URL. Applied onto Userinfo, Path and Query. + * + * @param string $url URL + * + * @return string + * @see parseUrl + * @see setAuthority + * @link https://pear.php.net/bugs/bug.php?id=20425 + */ + private function _encodeData($url) + { + return preg_replace_callback( + '([\x-\x20\x22\x3C\x3E\x7F-\xFF]+)', + array($this, '_encodeCallback'), $url + ); + } + + /** + * callback for encoding character data + * + * @param array $matches Matches + * + * @return string + * @see _encodeData + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private function _encodeCallback(array $matches) + { + return rawurlencode($matches[0]); + } +} diff --git a/vendor/pear/net_url2/README.md b/vendor/pear/net_url2/README.md new file mode 100644 index 000000000..bc98d3aec --- /dev/null +++ b/vendor/pear/net_url2/README.md @@ -0,0 +1,43 @@ +[![Net_URL2 on Packagist](https://poser.pugx.org/pear/net_url2/v/stable.png)][pear/net_url2] +[![Build Status](https://travis-ci.org/pear/Net_URL2.png)][Travis CI] +[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/quality-score.png?s=23b0d3f0ed58ee865317c500ee2cbe94517438ec)](https://scrutinizer-ci.com/g/pear/Net_URL2/) +[![Code Coverage](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/coverage.png?s=44d3682d7cdef471570d80dd8a7290a1e23fdfee)](https://scrutinizer-ci.com/g/pear/Net_URL2/) + +# Net_URL2 + +Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), +URL generation, and resolving of relative URLs. + +This package is [Pear Net_URL2] and has been migrated from [Pear SVN] + +Please report all new issues via the [PEAR bug tracker]. + +On Packagist as [pear/net_url2]. + +[Pear Net_URL2]: https://pear.php.net/package/Net_URL2 +[Pear SVN]: https://svn.php.net/repository/pear/packages/Net_URL2 +[PEAR bug tracker]: https://pear.php.net/bugs/search.php?cmd=display&package_name%5B%5D=Net_URL2 +[pear/net_url2]: https://packagist.org/packages/pear/net_url2 +[Travis CI]: https://travis-ci.org/pear/Net_URL2 + +## Testing, Packaging and Installing (Pear) + +To test, run either + + $ phpunit tests/ + + or + + $ pear run-tests -r + +To build, simply + + $ pear package + +To install from scratch + + $ pear install package.xml + +To upgrade + + $ pear upgrade -f package.xml diff --git a/vendor/pear/net_url2/composer.json b/vendor/pear/net_url2/composer.json new file mode 100644 index 000000000..b33698e5d --- /dev/null +++ b/vendor/pear/net_url2/composer.json @@ -0,0 +1,47 @@ +{ + "name": "pear/net_url2", + "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", + "type": "library", + "keywords": [ + "pear", + "net", + "url", + "uri", + "networking", + "rfc3986" + ], + "homepage": "https://github.com/pear/Net_URL2", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Tom Klingenberg", + "email": "tkli@php.net" + }, + { + "name": "David Coallier", + "email": "davidc@php.net" + }, + { + "name": "Christian Schmidt", + "email": "chmidt@php.net" + } + ], + "support": { + "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", + "source": "https://github.com/pear/Net_URL2" + }, + "require": { + "php": ">=5.1.4" + }, + "autoload": { + "classmap": ["Net/URL2.php"] + }, + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "require-dev": { + "phpunit/phpunit": ">=3.3.0" + } +} diff --git a/vendor/pear/net_url2/docs/6470.php b/vendor/pear/net_url2/docs/6470.php new file mode 100755 index 000000000..8ef0ff046 --- /dev/null +++ b/vendor/pear/net_url2/docs/6470.php @@ -0,0 +1,56 @@ + + * + * @category Networking + * @package Net_URL2 + * @author Some Pear Developers + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @link https://tools.ietf.org/html/rfc3986 + */ + +/** +* This example will decode the url given and display its +* constituent parts. +*/ + error_reporting(E_ALL | E_STRICT); + + require_once 'Net/URL2.php'; + + $url = new Net_URL2('https://www.example.com/foo/bar/index.php?foo=bar'); + +?> + + + +
+Protocol...: protocol; ?>
+
+Username...: user; ?>
+
+Password...: pass; ?>
+
+Server.....: host; ?>
+
+Port.......: port; ?>
+
+File/path..: path; ?>
+
+Querystring: querystring); ?>
+
+Anchor.....: anchor;?>
+
+Full URL...: getUrl(); ?>
+
+Resolve path (/.././/foo/bar/joe/./././../jabba): resolve('/.././/foo/bar/joe/./././../jabba'); ?>
+
+ + + diff --git a/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes b/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes new file mode 100644 index 000000000..b45ca8e94 --- /dev/null +++ b/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes @@ -0,0 +1,27 @@ +Copyright (c) 2002-2003, Richard Heyes +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3) Neither the name of the Richard Heyes nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/net_url2/docs/example.php b/vendor/pear/net_url2/docs/example.php new file mode 100755 index 000000000..351be68b8 --- /dev/null +++ b/vendor/pear/net_url2/docs/example.php @@ -0,0 +1,62 @@ + + * + * @category Networking + * @package Net_URL2 + * @author Some Pear Developers + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @link https://tools.ietf.org/html/rfc3986 + */ + +/** +* This example will decode the url given and display its +* constituent parts. +*/ + +error_reporting(E_ALL | E_STRICT); + +require 'Net/URL2.php'; + +$url = new Net_URL2( + 'https://example.com/pls/portal30/PORTAL30.wwpob_page.changetabs?' + .'p_back_url=http%3A%2F%2Fexample.com%2Fservlet%2Fpage%3F_pageid%3D360' + .'%2C366%2C368%2C382%26_dad%3Dportal30%26_schema%3DPORTAL30&foo=bar' +); + +?> + + + +
+Protocol...: protocol; ?>
+
+Username...: user; ?>
+
+Password...: pass; ?>
+
+Server.....: host; ?>
+
+Port.......: port; ?>
+
+File/path..: path; ?>
+
+Querystring: querystring); ?>
+
+Anchor.....: anchor;?>
+
+Full URL...: getUrl(); ?>
+
+
+Resolve path (.././/foo/bar/joe/./././../jabba): resolve('.././/foo/bar/joe/./././../jabba'); ?>
+
+ + + diff --git a/vendor/pear/net_url2/package.xml b/vendor/pear/net_url2/package.xml new file mode 100644 index 000000000..7f0b42ae4 --- /dev/null +++ b/vendor/pear/net_url2/package.xml @@ -0,0 +1,469 @@ + + + Net_URL2 + pear.php.net + Net_URL + Class for parsing and handling URL. + + Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of + relative URLs. + + + Tom Klingenberg + tkli + tkli@php.net + yes + + + David Coallier + davidc + davidc@php.net + no + + + Christian Schmidt + schmidt + schmidt@php.net + no + + + 2015-04-18 + + + 2.2.0 + 2.1.0 + + + stable + stable + + BSD-3-Clause + + * Changed composer autoloader to classmap, fixes include path pollution + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.1.4 + + + 1.4.0b1 + + + + + + + 2015-04-18 + + + 2.2.0 + 2.1.0 + + + stable + stable + + BSD-3-Clause + + * Changed composer autoloader to classmap, fixes include path pollution + + + + 2014-12-27 + + + 2.1.1 + 2.1.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20473: Normalize query and fragment broken + + + + 2014-10-21 + + + 2.1.0 + 2.1.0 + + + stable + stable + + BSD-3-Clause + + * New: OPTION_DROP_SEQUENCE + + + + 2014-10-21 + + + 2.0.12 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Removed: OPTION_DROP_SEQUENCE + + + + + 2014-10-18 + + + 2.0.11 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * New: OPTION_DROP_SEQUENCE + + + + + 2014-10-09 + + + 2.0.10 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Imp: composer for pear + * Fix: Documentation problem + + + + + 2014-10-08 + + + 2.0.9 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20418: Incorrect normalization of URI with missing authority + * Upd: Test for RFC 3986 Section 1.1.2 Examples + * Upd: Travis CI - PHP 5.6 added + + + + + 2014-10-07 + + + 2.0.8 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20420: Inconsistent setAuthority and getAuthority + * Fixed #20423: URI with IPv6 or IPvFuture not parsed + * Imp: Test for RFC 3986 Section 1.1.2 Examples + + + + + 2014-09-07 + + + 2.0.7 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20385: Incorrect normalization of userinfo + * Fixed #20399: Setting userinfo to FALSE not transparent + + + + + 2014-07-21 + + + 2.0.6 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20304: file:// URI gets crippled + + + + + 2014-01-01 + + + 2.0.5 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #17036: Brackets broken for query variables + * Fixed diverse coding style violations and misc. minor issues + * Increased code coverage + + + + + 2013-12-31 + + + 2.0.4 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20161: URLs with "0" as host fail to normalize with empty path + * A flaw in NetURL2::removeDotSegments() introduced in 2.0.1 has been fixed + * New: NetURL2::removeDotSegments() emits a warning on loop limit reach + * Url-segment maximum count raised from 100 to 256 (loop limit) + + + + + 2013-12-30 + + + 2.0.3 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #20156: setAuthority() flaw with "0" as host + * Fixed #20157: normalize() flaw with "0" as path + * Fixed #20158: Fragment-only references are not resolved to non-absolute base URI + * Fixed #20159: Authority not terminated by slash + * Fixed diverse coding style violations and misc. minor issues + * Increased code coverage + * Added support for Scrutinizer CI + + + + + 2013-12-27 + + + 2.0.2 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed #19684: Redirects containing spaces do not work + * Fixed diverse coding style violations and misc. minor issues + * Improved source package distribution + * Added support for Travis CI + + + + + 2013-12-24 + + + 2.0.1 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed Bug #20013: getNormalizedURL() adds leading "@" chars in the Authority + * Fixed Bug #20016: Wrong data in 6d4f4dd "Package.xml preparation." + * Fixed Bug #19176: resolve() does not merge the path if the base path is empty + * Fixed Bug #19315: removeDotSegments("0") not working + + + + + 2011-10-20 + + + 2.0.0 + 2.0.0 + + + stable + stable + + BSD-3-Clause + + * Fixed the version of the release. Follow the convention for Package2. + * Fixed Bug #18917: URL2.php moved to ./Net/Net (davidc) + + + + + + 1.0.0 + 1.0.0 + + + stable + stable + + 2011-10-20 + BSD-3-Clause + + * Fixed Bug #17036: Problem with parsed query string + * Fixed Bug #17087: setOption() function is gone + * Fixed #17166: Fluent Interface + * Fixed #17167: Refactor __construct + * Fixed Bug #18267: setQueryVariables() fails to encode array values + * Fixed Bug #14399: Fixed multiple bugs in Net_URL2 (Missing setOption value, unused properties, etc.) + + + + + + 0.3.1 + 0.3.0 + + + beta + beta + + 2011-02-22 + BSD-3-Clause + + * BC break: Removed setOption() to avoid undefined behaviour (bug #16674) + * Fixed Bug #16854: Invalid package.xml making it impossible to install with Pyrus + * Fixed Bug #16651: Port may be an empty string + * Fixed Bug #16653: Don't make OPTION_SEPARATOR_(IN|OUT)PUT default to arg_separator.(in|out)put + + + + + 0.3.0 + 0.3.0 + + + beta + beta + + 2009-09-05 + BSD-3-Clause + + * Fixed #14399 (Errors in URL parsing (items #1 and #3)) + * Fixed #14735 (Encode query string values) + * Fixed #15546 (Add adding __toString()) + * Fixed #15367 (Use RFC 3986-compliant version of rawurlencode() in PHP < 5.2) + * Fixed #14289 (Add __get() and __set()) + + + + + 0.2.0 + 0.2.0 + + + beta + beta + + 2008-06-18 + BSD-3-Clause + + * Major rewrite to comply with RFC3986 (bug #11574). + * Much better support for resolving relative URLs. + * WARNING: Method and property names has changed to reflect the terminology used in the RFC - THIS RELEASE IS + NOT BACKWARDS COMPATIBLE WITH VERSION 0.1.0. + + + + + 0.1.0 + 0.1.0 + + + beta + beta + + 2007-05-08 + BSD-3-Clause + Convert to PHP5 only. PHP4 users should continue with version 1.0.15 + + + diff --git a/vendor/pear/net_url2/phpunit.xml.dist b/vendor/pear/net_url2/phpunit.xml.dist new file mode 100644 index 000000000..2fee31891 --- /dev/null +++ b/vendor/pear/net_url2/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + tests + + + + + Net/URL2.php + + + diff --git a/vendor/pear/net_url2/tests/AllTests.php b/vendor/pear/net_url2/tests/AllTests.php new file mode 100644 index 000000000..65492fe36 --- /dev/null +++ b/vendor/pear/net_url2/tests/AllTests.php @@ -0,0 +1,59 @@ + + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @link https://tools.ietf.org/html/rfc3986 + */ + +require_once 'PHPUnit/Autoload.php'; + +chdir(dirname(__FILE__) . '/../'); + +require_once 'Net/URL2Test.php'; +require_once 'Net/URL2.php'; + +/** + * Test class for Net_URL2. + * + * @category Networking + * @package Net_URL2 + * @author Some Pear Developers + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @version Release: @package_version@ + * @link https://pear.php.net/package/Net_URL2 + */ +class Net_URL2_AllTests +{ + /** + * main() + * + * @return void + */ + public static function main() + { + + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + /** + * suite() + * + * @return PHPUnit_Framework_TestSuite + */ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('Net_URL2 tests'); + /** Add testsuites, if there is. */ + $suite->addTestSuite('Net_URL2Test'); + + return $suite; + } +} + +Net_URL2_AllTests::main(); diff --git a/vendor/pear/net_url2/tests/Net/URL2Test.php b/vendor/pear/net_url2/tests/Net/URL2Test.php new file mode 100644 index 000000000..a17d0c5f6 --- /dev/null +++ b/vendor/pear/net_url2/tests/Net/URL2Test.php @@ -0,0 +1,1088 @@ + + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @link https://tools.ietf.org/html/rfc3986 + */ + +/** + * Test class for Net_URL2. + * + * @category Networking + * @package Net_URL2 + * @author Some Pear Developers + * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause + * @version Release: @package_version@ + * @link https://pear.php.net/package/Net_URL2 + */ +class Net_URL2Test extends PHPUnit_Framework_TestCase +{ + /** + * Tests setting a zero-length string and false as authority + * Also: Regression test for Bug #20420 + * + * @covers Net_URL2::setAuthority + * @return void + * @link https://pear.php.net/bugs/bug.php?id=20420 + */ + public function testSetEmptyAuthority() + { + $url = new Net_URL2('http://www.example.com/'); + $url->setAuthority(''); + $this->assertSame('', $url->getAuthority()); + $this->assertSame('', $url->getHost()); + $this->assertSame(false, $url->getPort()); + $this->assertSame(false, $url->getUserinfo()); + $this->assertSame(false, $url->getUser()); + + $url->setAuthority(false); + $this->assertSame(false, $url->getAuthority()); + } + + /** + * Tests setting an empty userinfo part + * Also: Regression test for Bug #20013 and Bug #20399 + * + * @covers Net_URL2::setUserinfo + * @covers Net_URL2::getUserinfo + * @covers Net_URL2::getURL + * @return void + * @link https://pear.php.net/bugs/bug.php?id=20013 + * @link https://pear.php.net/bugs/bug.php?id=20399 + */ + public function testSetEmptyUserinfo() + { + $url = new Net_URL2('http://@www.example.com/'); + $this->assertSame('http://www.example.com/', $url->getURL()); + + $url = new Net_URL2('http://www.example.com/'); + $this->assertSame('http://www.example.com/', $url->getURL()); + $url->setUserinfo(''); + $this->assertSame('http://www.example.com/', $url->getURL()); + $this->assertSame('', $url->getUserinfo()); + $url->setUserinfo(false); + $this->assertSame('http://www.example.com/', $url->getURL()); + $this->assertFalse($url->getUserinfo()); + } + + /** + * Tests an URL with no userinfo and normalization + * + * Also: Regression test for Bug #20385 + * + * @covers Net_URL2::getUserinfo + * @covers Net_URL2::normalize + * @covers Net_URL2::getNormalizedURL + * @return void + * @link https://pear.php.net/bugs/bug.php?id=20385 + */ + public function testNoUserinfoAndNormalize() + { + $testUrl = 'http://www.example.com/'; + + $url = new Net_URL2($testUrl); + $this->assertFalse($url->getUserinfo()); + + $url->normalize(); + $this->assertFalse($url->getUserinfo()); + + $this->assertEquals($testUrl, $url->getURL()); + $this->assertEquals($testUrl, $url->getNormalizedURL()); + } + + /** + * Tests setQueryVariable(). + * + * @return void + */ + public function testSetQueryVariable() + { + + $url = new Net_URL2('http://www.example.com/'); + $url->setQueryVariable('pear', 'fun'); + $this->assertEquals($url->getURL(), 'http://www.example.com/?pear=fun'); + } + + /** + * Tests setQueryVariables(). + * + * @return void + */ + public function testSetQueryVariables() + { + + $url = new Net_URL2('http://www.example.com/'); + $url->setQueryVariables(array('pear' => 'fun')); + $this->assertEquals('http://www.example.com/?pear=fun', $url->getURL()); + $url->setQueryVariables(array('pear' => 'fun for sure')); + $this->assertEquals( + 'http://www.example.com/?pear=fun%20for%20sure', $url->getURL() + ); + } + + /** + * Tests unsetQueryVariable() + * + * @return void + */ + public function testUnsetQueryVariable() + { + $url = new Net_URL2( + 'http://www.example.com/?name=david&pear=fun&fish=slippery' + ); + + $removes = array( + 'pear' => 'http://www.example.com/?name=david&fish=slippery', + 'name' => 'http://www.example.com/?fish=slippery', + 'fish' => 'http://www.example.com/', + ); + + foreach ($removes as $name => $expected) { + $url->unsetQueryVariable($name); + $this->assertEquals($expected, $url); + } + } + + /** + * Tests setQuery(). + * + * @return void + */ + public function testSetQuery() + { + + $url = new Net_URL2('http://www.example.com/'); + $url->setQuery('flapdoodle&dilly%20all%20day'); + $this->assertEquals( + $url->getURL(), 'http://www.example.com/?flapdoodle&dilly%20all%20day' + ); + } + + /** + * Tests getQuery(). + * + * @return void + */ + public function testGetQuery() + { + + $url = new Net_URL2('http://www.example.com/?foo'); + $this->assertEquals($url->getQuery(), 'foo'); + $url = new Net_URL2('http://www.example.com/?pear=fun&fruit=fruity'); + $this->assertEquals($url->getQuery(), 'pear=fun&fruit=fruity'); + } + + /** + * Tests setScheme(). + * + * @return void + */ + public function testSetScheme() + { + + $url = new Net_URL2('http://www.example.com/'); + $url->setScheme('ftp'); + $this->assertEquals($url->getURL(), 'ftp://www.example.com/'); + $url->setScheme('gopher'); + $this->assertEquals($url->getURL(), 'gopher://www.example.com/'); + } + + /** + * Tests setting the fragment. + * + * @return void + */ + public function testSetFragment() + { + + $url = new Net_URL2('http://www.example.com/'); + $url->setFragment('pear'); + $this->assertEquals('http://www.example.com/#pear', $url->getURL()); + } + + /** + * A dataProvider for paths that are solved to a base URI. + * + * @see testResolveUrls + * @return array + */ + public function provideResolveUrls() + { + return array( + array( + // Examples from RFC 3986, section 5.4. + // relative base-URI, (URL => absolute URL), [(options)] + 'http://a/b/c/d;p?q', + array( + 'g:h' => 'g:h', + 'g' => 'http://a/b/c/g', + './g' => 'http://a/b/c/g', + 'g/' => 'http://a/b/c/g/', + '/g' => 'http://a/g', + '//g' => 'http://g', + '?y' => 'http://a/b/c/d;p?y', + 'g?y' => 'http://a/b/c/g?y', + '#s' => 'http://a/b/c/d;p?q#s', + 'g#s' => 'http://a/b/c/g#s', + 'g?y#s' => 'http://a/b/c/g?y#s', + ';x' => 'http://a/b/c/;x', + 'g;x' => 'http://a/b/c/g;x', + 'g;x?y#s' => 'http://a/b/c/g;x?y#s', + '' => 'http://a/b/c/d;p?q', + '.' => 'http://a/b/c/', + './' => 'http://a/b/c/', + '..' => 'http://a/b/', + '../' => 'http://a/b/', + '../g' => 'http://a/b/g', + '../..' => 'http://a/', + '../../' => 'http://a/', + '../../g' => 'http://a/g', + '../../../g' => 'http://a/g', + '../../../../g' => 'http://a/g', + '/./g' => 'http://a/g', + '/../g' => 'http://a/g', + 'g.' => 'http://a/b/c/g.', + '.g' => 'http://a/b/c/.g', + 'g..' => 'http://a/b/c/g..', + '..g' => 'http://a/b/c/..g', + './../g' => 'http://a/b/g', + './g/.' => 'http://a/b/c/g/', + 'g/./h' => 'http://a/b/c/g/h', + 'g/../h' => 'http://a/b/c/h', + 'g;x=1/./y' => 'http://a/b/c/g;x=1/y', + 'g;x=1/../y' => 'http://a/b/c/y', + 'g?y/./x' => 'http://a/b/c/g?y/./x', + 'g?y/../x' => 'http://a/b/c/g?y/../x', + 'g#s/./x' => 'http://a/b/c/g#s/./x', + 'g#s/../x' => 'http://a/b/c/g#s/../x', + 'http:g' => 'http:g', + ), + ), + array( + 'http://a/b/c/d;p?q', + array('http:g' => 'http://a/b/c/g'), + array('::OPTION_STRICT' => false) + ), + ); + } + + /** + * Test the resolve() function to resolve URLs to each other. + * + * @param string $baseURL base-URI + * @param array $relativeAbsolutePairs url-pairs, relative => resolved + * @param array $options Net_URL2 options + * + * @dataProvider provideResolveUrls + * @covers Net_URL2::resolve + * @return void + */ + public function testResolveUrls($baseURL, array $relativeAbsolutePairs, + array $options = array() + ) { + $options = $this->_translateOptionData($options); + $base = new Net_URL2($baseURL, $options); + $count = count($relativeAbsolutePairs); + $this->assertGreaterThan(0, $count, 'relative-absolute-pairs data is empty'); + foreach ($relativeAbsolutePairs as $relativeURL => $absoluteURL) { + $this->assertSame($absoluteURL, (string) $base->resolve($relativeURL)); + } + } + + /** + * Helper method to turn options with strings as the constant names + * (to allow to externalize the fixtures) into a concrete options + * array that uses the values from the Net_URL2 class constants. + * + * @param array $options options + * + * @return array + */ + private function _translateOptionData(array $options) + { + // translate string option-names to class constant starting with a colon. + foreach ($options as $name => $value) { + if ($name[0] === ':') { + unset($options[$name]); + $options[constant("Net_URL2$name")] = $value; + } + } + return $options; + } + + /** + * Test the resolve() function throwing an exception with invalid data. + * + * @covers Net_URL2::resolve + * @return void + */ + public function testResolveException() + { + // resolving a relative to a relative URL throws an exception + $base = new Net_URL2('news.html?category=arts'); + $this->addToAssertionCount(1); + try { + $base->resolve('../arts.html#section-2.4'); + } catch (Exception $e) { + $expected = 'Base-URL must be absolute if reference is not fragment-onl'; + $this->assertStringStartsWith($expected, $e->getMessage()); + return; + } + $this->fail('Expected exception not thrown.'); + } + + /** + * Assert that there is a last error message and it contains needle. + * + * @param string $needle needle + * + * @return void + */ + private function _assertLastErrorContains($needle) + { + $error = error_get_last(); + $this->assertArrayHasKey('message', $error, 'there was an error previously'); + $pos = strpos($error['message'], $needle); + + $this->assertTrue( + false !== $pos, + sprintf( + 'Last error message "%s" contains "%s"', $error['message'], $needle + ) + ); + } + + /** + * Test UrlEncoding + * + * @return void + * @link https://pear.php.net/bugs/bug.php?id=18267 + */ + public function testUrlEncoding() + { + $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); + $url = new Net_URL2('http://localhost/bug.php', $options); + $url->setQueryVariables( + array( + 'indexed' => array( + 'first value', 'second value', array('foo', 'bar'), + ) + ) + ); + $this->assertEquals( + 'http://localhost/bug.php?indexed[0]=first%20value&indexed[1]' . + '=second%20value&indexed[2][0]=foo&indexed[2][1]=bar', + strval($url) + ); + } + + /** + * A test to verify that keys in QUERY_STRING are encoded by default. + * + * @return void + * @see Net_URL2::OPTION_ENCODE_KEYS + * @see Net_URL2::buildQuery() + */ + public function testEncodeKeys() + { + $url = new Net_URL2('http://example.org'); + $url->setQueryVariables(array('helgi rulez' => 'till too')); + $this->assertEquals( + 'http://example.org?helgi%20rulez=till%20too', + strval($url) + ); + } + + /** + * A test to verify that keys in QUERY_STRING are not encoded when we supply + * 'false' via {@link Net_URL2::__construct()}. + * + * @return void + * @see Net_URL2::OPTION_ENCODE_KEYS + * @see Net_URL2::buildQuery() + */ + public function testDontEncodeKeys() + { + $url = new Net_URL2( + 'http://example.org', + array(Net_URL2::OPTION_ENCODE_KEYS => false) + ); + $url->setQueryVariables(array('till rulez' => 'helgi too')); + $this->assertEquals( + 'http://example.org?till rulez=helgi%20too', + strval($url) + ); + } + + /** + * Brackets for array query variables + * + * Also text to not encode zero based integer sequence into brackets + * + * @return void + * + * @link https://pear.php.net/bugs/bug.php?id=20427 + */ + public function testUseBrackets() + { + $url = new Net_URL2('http://example.org/'); + $url->setQueryVariables(array('foo' => array('bar', 'baz'))); + $expected = 'http://example.org/?foo[]=bar&foo[]=baz'; + $this->assertEquals($expected, $url->getURL()); + + $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); + $url = new Net_URL2('http://example.org/', $options); + $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); + $expected = 'http://example.org/?foo[0]=bar&foo[1]=foobar'; + $this->assertEquals($expected, $url->getURL()); + } + + /** + * Do not use brackets for query variables passed as array + * + * @return void + */ + public function testDontUseBrackets() + { + $url = new Net_URL2( + 'http://example.org/', + array(Net_URL2::OPTION_USE_BRACKETS => false) + ); + $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); + $this->assertEquals( + 'http://example.org/?foo=bar&foo=foobar', + strval($url) + ); + } + + /** + * A dataProvider for example URIs from RFC 3986 Section 1.1.2 + * + * @return array + * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 + * @see testExampleUri + */ + public function provideExampleUri() + { + return array( + array('ftp://ftp.is.co.za/rfc/rfc1808.txt'), + array('http://www.ietf.org/rfc/rfc2396.txt'), + array('ldap://[2001:db8::7]/c=GB?objectClass?one'), + array('mailto:John.Doe@example.com'), + array('news:comp.infosystems.www.servers.unix'), + array('tel:+1-816-555-1212'), + array('telnet://192.0.2.16:80/'), + array('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'), + ); + } + + /** + * test that Net_URL2 works with the example URIs from RFC 3986 Section 1.1.2 + * + * @param string $uri example URI + * + * @return void + * @dataProvider provideExampleUri + * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 + * @see testComponentRecompositionAndNormalization + */ + public function testExampleUri($uri) + { + $url = new Net_URL2($uri); + $this->assertSame($uri, $url->__toString()); + $url->normalize(); + $this->assertSame($uri, $url->__toString()); + } + + /** + * A dataProvider for pairs of paths with dot segments and + * their form when removed. + * + * @see testRemoveDotSegments + * @return array + */ + public function providePath() + { + // The numbers behind are in reference to sections + // in RFC 3986 5.2.4. Remove Dot Segments + return array( + array('../', ''), // 2. A. + array('./', ''), // 2. A. + array('/./', '/'), // 2. B. + array('/.', '/'), // 2. B. + array('/../', '/'), // 2. C. + array('/..', '/'), // 2. C. + array('..', ''), // 2. D. + array('.', ''), // 2. D. + array('a', 'a'), // 2. E. + array('/a', '/a'), // 2. E. + array('/a/b/c/./../../g', '/a/g'), // 3. + array('mid/content=5/../6', 'mid/6'), // 3. + array('../foo/bar.php', 'foo/bar.php'), + array('/foo/../bar/boo.php', '/bar/boo.php'), + array('/boo/..//foo//bar.php', '//foo//bar.php'), + array('/./foo/././bar.php', '/foo/bar.php'), + array('./.', ''), + ); + } + + /** + * Test removal of dot segments + * + * @param string $path Path + * @param string $assertion Assertion + * + * @dataProvider providePath + * @covers Net_URL2::removeDotSegments + * @return void + */ + public function testRemoveDotSegments($path, $assertion) + { + $this->assertEquals($assertion, Net_URL2::removeDotSegments($path)); + } + + /** + * Test removeDotSegments() loop limit warning + * + * @covers Net_URL2::removeDotSegments + * @return void + */ + public function testRemoveDotSegmentsLoopLimit() + { + $loopLimit = 256; + $segments = str_repeat('a/', $loopLimit); + + @Net_URL2::removeDotSegments($segments . 'b/'); + + $this->_assertLastErrorContains(sprintf(' loop limit %d ', $loopLimit + 1)); + $this->_assertLastErrorContains(" (left: '/b/')"); + } + + /** + * A dataProvider for query strings and their array representation + * + * @see testGetQueryVariables + * @return array + */ + public function provideQueryStrings() + { + // If the second (expected) value is set or not null, parse_str() differs. + // Notes on PHP differences with each entry/block + return array( + // Net_URL2::getQueryVariables() non-bracket mode + array('test=1&t%65st=%41&extra=', + array('test' => array('1', 'A'), 'extra' => ''), + array('::OPTION_USE_BRACKETS' => false)), + array(''), + array('='), + array('key'), + array('key='), + array('=value'), + array('k=v'), + // no space as var-name in PHP (array()): + array(' ', array(' ' => '' )), + array(' =v', array(' ' => 'v')), + array('key=value'), + // PHP replaces ".", " " and "[" in name replaced by "_": + array('key.=value' , array('key.' => 'value')), + array('key =value' , array('key ' => 'value')), + array('key[=value' , array('key[' => 'value')), + array("key\0=value", array("key\0" => 'value')), + array('key]=value'), + array('key[]=value'), + array('[]=value'), + array(']=value'), + array(']]=value'), + // PHP drops variables that are an open bracket only + array('[=value', array('[' => 'value')), + // PHP drops spaces in brackets: + array('key[ ]=value', array('key' => array(' ' => 'value'))), + // PHP replaces space " " in name by "_" + array('key []=1' , array('key ' => array('1' ))) , + // PHP does not support "\0" in var-names: + array("key[\0]=value" , array('key' => array("\0" => 'value' ))), + array("key[a\0]=value" , array('key' => array("a\0" => 'value' ))), + array("key[a\0b]=value" , array('key' => array("a\0b" => 'value'))), + array('var[]=1&var[0][]=2'), + array('key[] []=1'), + array('key[] [] []=1'), + array('key[] [] []'), + array('key[] [] []=[] []'), + array('[] [] []=[] []'), + ); + } + + /** + * Test parsing of query variables + * + * @param string $query string + * @param mixed $expected null to test against parse_str() behavior + * @param array $options Net_URL2 options + * + * @dataProvider provideQueryStrings + * @covers Net_URL2::getQueryVariables + * @covers Net_URL2::_queryArrayByKey + * @covers Net_URL2::_queryArrayByBrackets + * @covers Net_URL2::_queryKeyBracketOffset + * @return void + */ + public function testGetQueryVariables($query, $expected = null, + array $options = array() + ) { + $options = $this->_translateOptionData($options); + + $url = new Net_URL2('', $options); + + if ($expected === null) { + // parse_str() is in PHP before copy on write, therefore + // it uses pass-by-reference for $expected to return + // the array + parse_str($query, $expected); + } + + // Xdebug: If breakpoints are ignored, see Xdebug Issue 0000924 + $url->setQuery($query); + $actual = $url->getQueryVariables(); + + // Do two assertions, because the first one shows a more nice diff in case + // it fails and the second one is actually strict which is what has to be + // tested. + $this->assertEquals($expected, $actual); + $this->assertSame($expected, $actual); + } + + /** + * data provider of host and port + * + * @return array + * @see testHostAndPort + */ + public function provideHostAndPort() + { + return array( + array('[::1]', '[::1]', false), + array('[::1]:', '[::1]', false), + array('[::1]:128', '[::1]', '128'), + array('127.0.0.1', '127.0.0.1', false), + array('127.0.0.1:', '127.0.0.1', false), + array('127.0.0.1:128', '127.0.0.1', '128'), + array('localhost', 'localhost', false), + array('localhost:', 'localhost', false), + array('localhost:128', 'localhost', '128'), + ); + } + + /** + * test that an authority containing host and port maps to expected host and port + * + * This is also a regression test to test that using ip-literals works along- + * side ipv4 and reg-name hosts incl. port numbers + * + * It was reported as Bug #20423 on 2014-10-06 18:25 UTC that + * http://[::1]// URI drops the host + * + * @param string $authority string + * @param string $expectedHost string + * @param string|bool $expectedPort string or FALSE + * + * @return void + * @dataProvider provideHostAndPort + * @covers Net_URL2::setAuthority() + * @link https://pear.php.net/bugs/bug.php?id=20423 + * @link http://tools.ietf.org/html/rfc3986#section-3.2.2 + * @link http://tools.ietf.org/html/rfc3986#section-3.2 + * @link http://tools.ietf.org/html/rfc3986#section-3.2.3 + */ + public function testHostAndPort($authority, $expectedHost, $expectedPort) + { + $uri = "http://{$authority}"; + $url = new Net_URL2($uri); + $this->assertSame($expectedHost, $url->getHost()); + $this->assertSame($expectedPort, $url->getPort()); + } + + /** + * This is a regression test to test that Net_URL2::getQueryVariables() does + * not have a problem with nested array values in form of stacked brackets and + * was reported as Bug #17036 on 2010-01-26 15:48 UTC that there would be + * a problem with parsed query string. + * + * @link https://pear.php.net/bugs/bug.php?id=17036 + * @covers Net_URL2::getQueryVariables + * @return void + */ + public function test17036() + { + $queryString = 'start=10&test[0][first][1.1][20]=coucou'; + $url = new Net_URL2('?' . $queryString); + $vars = $url->getQueryVariables(); + + $expected = array(); + $expected['start'] = '10'; + $expected['test'][0]['first']['1.1'][20] = 'coucou'; + + $this->assertEquals($expected, $vars); // give nice diff in case of failuer + $this->assertSame($expected, $vars); // strictly assert the premise + } + + /** + * This is a regression test to test that resolve() does + * merge the path if the base path is empty as the opposite + * was reported as Bug #19176 on 2011-12-31 02:07 UTC + * + * @return void + */ + public function test19176() + { + $foo = new Net_URL2('http://www.example.com'); + $test = $foo->resolve('test.html')->getURL(); + $this->assertEquals('http://www.example.com/test.html', $test); + } + + /** + * This is a regression test that removeDotSegments('0') is + * working as it was reported as not-working in Bug #19315 + * on 2012-03-04 04:18 UTC. + * + * @return void + */ + public function test19315() + { + $actual = Net_URL2::removeDotSegments('0'); + $this->assertSame('0', $actual); + + $nonStringObject = (object)array(); + try { + Net_URL2::removeDotSegments($nonStringObject); + } catch (PHPUnit_Framework_Error $error) { + $this->addToAssertionCount(1); + } + + if (!isset($error)) { + $this->fail('Failed to verify that error was given.'); + } + unset($error); + } + + /** + * This is a regression test to test that recovering from + * a wrongly encoded URL is possible. + * + * It was requested as Request #19684 on 2011-12-31 02:07 UTC + * that redirects containing spaces should work. + * + * @return void + */ + public function test19684() + { + // Location: URL obtained Thu, 25 Apr 2013 20:51:31 GMT + $urlWithSpace = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS N' + . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' + . '48+219853269+219853286'; + + $urlCorrect = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS%20N' + . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' + . '48+219853269+219853286'; + + $url = new Net_URL2($urlWithSpace); + + $this->assertTrue($url->isAbsolute()); + + $urlPart = parse_url($urlCorrect, PHP_URL_PATH); + $this->assertSame($urlPart, $url->getPath()); + + $urlPart = parse_url($urlCorrect, PHP_URL_QUERY); + $this->assertSame($urlPart, $url->getQuery()); + + $this->assertSame($urlCorrect, (string)$url); + + $input = 'http://example.com/get + + to my nose/'; + $expected = 'http://example.com/get%20+%20+%20to%20my%20nose/'; + $actual = new Net_URL2($input); + $this->assertEquals($expected, $actual); + $actual->normalize(); + } + + /** + * data provider of list of equivalent URLs. + * + * @see testNormalize + * @see testConstructSelf + * @return array + */ + public function provideEquivalentUrlLists() + { + return array( + // String equivalence: + array('http://example.com/', 'http://example.com/'), + + // Originally first dataset: + array('http://www.example.com/%9a', 'http://www.example.com/%9A'), + + // Example from RFC 3986 6.2.2.: + array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'), + + // Example from RFC 3986 6.2.2.1.: + array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/'), + + // Example from RFC 3986 6.2.3.: + array( + 'http://example.com', 'http://example.com/', + 'http://example.com:/', 'http://example.com:80/' + ), + + // Bug #20161: URLs with "0" as host fail to normalize with empty path + array('http://0/', 'http://0'), + + // Bug #20473: Normalize query and fragment broken + array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar'), + ); + } + + /** + * This is a coverage test to invoke the normalize() + * method. + * + * @return void + * + * @dataProvider provideEquivalentUrlLists + */ + public function testNormalize() + { + $urls = func_get_args(); + + $this->assertGreaterThanOrEqual(2, count($urls)); + + $last = null; + + foreach ($urls as $index => $url) { + $url = new Net_Url2($url); + $url->normalize(); + if ($index) { + $this->assertSame((string)$last, (string)$url); + } + $last = $url; + } + } + + /** + * This is a coverage test to invoke __get and __set + * + * @covers Net_URL2::__get + * @covers Net_URL2::__set + * @return void + */ + public function testMagicSetGet() + { + $url = new Net_URL2(''); + + $property = 'authority'; + $url->$property = $value = 'value'; + $this->assertEquals($value, $url->$property); + + $property = 'unsetProperty'; + $url->$property = $value; + $this->assertEquals(false, $url->$property); + } + + /** + * data provider of uri and normal URIs + * + * @return array + * @see testComponentRecompositionAndNormalization + */ + public function provideComposedAndNormalized() + { + return array( + array(''), + array('http:g'), + array('user@host'), + array('mailto:user@host'), + ); + } + + /** + * Tests Net_URL2 RFC 3986 5.3. Component Recomposition in the light + * of normalization + * + * This is also a regression test to test that a missing authority works well + * with normalization + * + * It was reported as Bug #20418 on 2014-10-02 22:10 UTC that there is an + * Incorrect normalization of URI with missing authority + * + * @param string $uri URI + * + * @return void + * @covers Net_URL2::getUrl() + * @covers Net_URL2::normalize() + * @dataProvider provideComposedAndNormalized + * @link https://pear.php.net/bugs/bug.php?id=20418 + * @see testExampleUri + */ + public function testComponentRecompositionAndNormalization($uri) + { + $url = new Net_URL2($uri); + $this->assertSame($uri, $url->getURL()); + $url->normalize(); + $this->assertSame($uri, $url->getURL()); + } + + /** + * Tests Net_URL2 ctors URL parameter works with objects implementing + * __toString(). + * + * @dataProvider provideEquivalentUrlLists + * @coversNothing + * @return void + */ + public function testConstructSelf() + { + $urls = func_get_args(); + foreach ($urls as $url) { + $urlA = new Net_URL2($url); + $urlB = new Net_URL2($urlA); + $this->assertSame((string)$urlA, (string)$urlB); + } + } + + /** + * This is a feature test to see that the userinfo's data is getting + * encoded as outlined in #19684. + * + * @covers Net_URL2::setAuthority + * @covers Net_URL2::setUserinfo + * @return void + */ + public function testEncodeDataUserinfoAuthority() + { + $url = new Net_URL2('http://john doe:secret@example.com/'); + $this->assertSame('http://john%20doe:secret@example.com/', (string)$url); + + $url->setUserinfo('john doe'); + $this->assertSame('http://john%20doe@example.com/', (string)$url); + + $url->setUserinfo('john doe', 'pa wd'); + $this->assertSame('http://john%20doe:pa%20wd@example.com/', (string)$url); + } + + /** + * This is a regression test to test that using the + * host-name "0" does work with getAuthority() + * + * It was reported as Bug #20156 on 2013-12-27 22:56 UTC + * that setAuthority() with "0" as host would not work + * + * @covers Net_URL2::setAuthority + * @covers Net_URL2::getAuthority + * @covers Net_URL2::setHost + * @return void + */ + public function test20156() + { + $url = new Net_URL2('http://user:pass@example.com:127/'); + $host = '0'; + $url->setHost($host); + $this->assertSame('user:pass@0:127', $url->getAuthority()); + + $url->setHost(false); + $this->assertSame(false, $url->getAuthority()); + + $url->setAuthority($host); + $this->assertSame($host, $url->getAuthority()); + } + + /** + * This is a regression test to test that setting "0" as path + * does not break normalize(). + * + * It was reported as Bug #20157 on 2013-12-27 23:42 UTC that + * normalize() with "0" as path would not work. + * + * @covers Net_URL2::normalize + * @return void + */ + public function test20157() + { + $subject = 'http://example.com'; + $url = new Net_URL2($subject); + $url->setPath('0'); + $url->normalize(); + $this->assertSame("$subject/0", (string)$url); + } + + /** + * This is a regression test to ensure that fragment-only references can be + * resolved to a non-absolute Base-URI. + * + * It was reported as Bug #20158 2013-12-28 14:49 UTC that fragment-only + * references would not be resolved to non-absolute base URI + * + * @covers Net_URL2::resolve + * @covers Net_URL2::_isFragmentOnly + * @return void + */ + public function test20158() + { + $base = new Net_URL2('myfile.html'); + $resolved = $base->resolve('#world'); + $this->assertSame('myfile.html#world', (string)$resolved); + } + + /** + * This is a regression test to ensure that authority and path are properly + * combined when the path does not start with a slash which is the separator + * character between authority and path. + * + * It was reported as Bug #20159 2013-12-28 17:18 UTC that authority + * would not be terminated by slash + * + * @covers Net_URL2::getUrl + * @return void + */ + public function test20159() + { + $url = new Net_URL2('index.html'); + $url->setHost('example.com'); + $this->assertSame('//example.com/index.html', (string)$url); + } + + /** + * This is a regression test to test that using the file:// URI scheme with + * an empty (default) hostname has the empty authority preserved when the + * full URL is build. + * + * It was reported as Bug #20304 on 2014-06-21 00:06 UTC + * that file:// URI are crippled. + * + * Tests with a default authority for the "file" URI scheme + * + * @covers Net_URL2::getURL + * @return void + * @link https://pear.php.net/bugs/bug.php?id=20304 + */ + public function test20304() + { + $file = 'file:///path/to/file'; + $url = new Net_URL2($file); + $this->assertSame($file, (string) $url); + + $file = 'file://localhost/path/to/file'; + $url = new Net_URL2($file); + $this->assertSame($file, (string) $url); + + $file = 'file://user@/path/to/file'; + $url = new Net_URL2($file); + $this->assertSame($file, (string) $url); + + $file = 'FILE:///path/to/file'; + $url = new Net_URL2($file); + $this->assertSame($file, (string) $url); + } +} diff --git a/vendor/pear/pear_exception/.gitignore b/vendor/pear/pear_exception/.gitignore new file mode 100644 index 000000000..479265b07 --- /dev/null +++ b/vendor/pear/pear_exception/.gitignore @@ -0,0 +1,6 @@ +PEAR_Exception*.tgz + +# composer related +composer.lock +composer.phar +vendor diff --git a/vendor/pear/pear_exception/.travis.yml b/vendor/pear/pear_exception/.travis.yml new file mode 100644 index 000000000..18875d993 --- /dev/null +++ b/vendor/pear/pear_exception/.travis.yml @@ -0,0 +1,7 @@ +language: php +php: + - 5.6 + - 5.5 + - 5.4 +script: + - cd tests && phpunit --coverage-text . diff --git a/vendor/pear/pear_exception/LICENSE b/vendor/pear/pear_exception/LICENSE new file mode 100644 index 000000000..a00a2421f --- /dev/null +++ b/vendor/pear/pear_exception/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 1997-2009, + Stig Bakken , + Gregory Beaver , + Helgi Þormar Þorbjörnsson , + Tomas V.V.Cox , + Martin Jansen . +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/pear_exception/PEAR/Exception.php b/vendor/pear/pear_exception/PEAR/Exception.php new file mode 100644 index 000000000..5abf4f84a --- /dev/null +++ b/vendor/pear/pear_exception/PEAR/Exception.php @@ -0,0 +1,456 @@ + + * @author Hans Lellelid + * @author Bertrand Mansion + * @author Greg Beaver + * @copyright 1997-2009 The Authors + * @license http://opensource.org/licenses/bsd-license.php New BSD License + * @link http://pear.php.net/package/PEAR_Exception + * @since File available since Release 1.0.0 + */ + + +/** + * Base PEAR_Exception Class + * + * 1) Features: + * + * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) + * - Definable triggers, shot when exceptions occur + * - Pretty and informative error messages + * - Added more context info available (like class, method or cause) + * - cause can be a PEAR_Exception or an array of mixed + * PEAR_Exceptions/PEAR_ErrorStack warnings + * - callbacks for specific exception classes and their children + * + * 2) Ideas: + * + * - Maybe a way to define a 'template' for the output + * + * 3) Inherited properties from PHP Exception Class: + * + * protected $message + * protected $code + * protected $line + * protected $file + * private $trace + * + * 4) Inherited methods from PHP Exception Class: + * + * __clone + * __construct + * getMessage + * getCode + * getFile + * getLine + * getTraceSafe + * getTraceSafeAsString + * __toString + * + * 5) Usage example + * + * + * require_once 'PEAR/Exception.php'; + * + * class Test { + * function foo() { + * throw new PEAR_Exception('Error Message', ERROR_CODE); + * } + * } + * + * function myLogger($pear_exception) { + * echo $pear_exception->getMessage(); + * } + * // each time a exception is thrown the 'myLogger' will be called + * // (its use is completely optional) + * PEAR_Exception::addObserver('myLogger'); + * $test = new Test; + * try { + * $test->foo(); + * } catch (PEAR_Exception $e) { + * print $e; + * } + * + * + * @category PEAR + * @package PEAR_Exception + * @author Tomas V.V.Cox + * @author Hans Lellelid + * @author Bertrand Mansion + * @author Greg Beaver + * @copyright 1997-2009 The Authors + * @license http://opensource.org/licenses/bsd-license.php New BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PEAR_Exception + * @since Class available since Release 1.0.0 + */ +class PEAR_Exception extends Exception +{ + const OBSERVER_PRINT = -2; + const OBSERVER_TRIGGER = -4; + const OBSERVER_DIE = -8; + protected $cause; + private static $_observers = array(); + private static $_uniqueid = 0; + private $_trace; + + /** + * Supported signatures: + * - PEAR_Exception(string $message); + * - PEAR_Exception(string $message, int $code); + * - PEAR_Exception(string $message, Exception $cause); + * - PEAR_Exception(string $message, Exception $cause, int $code); + * - PEAR_Exception(string $message, PEAR_Error $cause); + * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); + * - PEAR_Exception(string $message, array $causes); + * - PEAR_Exception(string $message, array $causes, int $code); + * + * @param string $message exception message + * @param int|Exception|PEAR_Error|array|null $p2 exception cause + * @param int|null $p3 exception code or null + */ + public function __construct($message, $p2 = null, $p3 = null) + { + if (is_int($p2)) { + $code = $p2; + $this->cause = null; + } elseif (is_object($p2) || is_array($p2)) { + // using is_object allows both Exception and PEAR_Error + if (is_object($p2) && !($p2 instanceof Exception)) { + if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { + throw new PEAR_Exception( + 'exception cause must be Exception, ' . + 'array, or PEAR_Error' + ); + } + } + $code = $p3; + if (is_array($p2) && isset($p2['message'])) { + // fix potential problem of passing in a single warning + $p2 = array($p2); + } + $this->cause = $p2; + } else { + $code = null; + $this->cause = null; + } + parent::__construct($message, $code); + $this->signal(); + } + + /** + * Add an exception observer + * + * @param mixed $callback - A valid php callback, see php func is_callable() + * - A PEAR_Exception::OBSERVER_* constant + * - An array(const PEAR_Exception::OBSERVER_*, + * mixed $options) + * @param string $label The name of the observer. Use this if you want + * to remove it later with removeObserver() + * + * @return void + */ + public static function addObserver($callback, $label = 'default') + { + self::$_observers[$label] = $callback; + } + + /** + * Remove an exception observer + * + * @param string $label Name of the observer + * + * @return void + */ + public static function removeObserver($label = 'default') + { + unset(self::$_observers[$label]); + } + + /** + * Generate a unique ID for an observer + * + * @return int unique identifier for an observer + */ + public static function getUniqueId() + { + return self::$_uniqueid++; + } + + /** + * Send a signal to all observers + * + * @return void + */ + protected function signal() + { + foreach (self::$_observers as $func) { + if (is_callable($func)) { + call_user_func($func, $this); + continue; + } + settype($func, 'array'); + switch ($func[0]) { + case self::OBSERVER_PRINT : + $f = (isset($func[1])) ? $func[1] : '%s'; + printf($f, $this->getMessage()); + break; + case self::OBSERVER_TRIGGER : + $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; + trigger_error($this->getMessage(), $f); + break; + case self::OBSERVER_DIE : + $f = (isset($func[1])) ? $func[1] : '%s'; + die(printf($f, $this->getMessage())); + break; + default: + trigger_error('invalid observer type', E_USER_WARNING); + } + } + } + + /** + * Return specific error information that can be used for more detailed + * error messages or translation. + * + * This method may be overridden in child exception classes in order + * to add functionality not present in PEAR_Exception and is a placeholder + * to define API + * + * The returned array must be an associative array of parameter => value like so: + *
+     * array('name' => $name, 'context' => array(...))
+     * 
+ * + * @return array + */ + public function getErrorData() + { + return array(); + } + + /** + * Returns the exception that caused this exception to be thrown + * + * @return Exception|array The context of the exception + */ + public function getCause() + { + return $this->cause; + } + + /** + * Function must be public to call on caused exceptions + * + * @param array $causes Array that gets filled. + * + * @return void + */ + public function getCauseMessage(&$causes) + { + $trace = $this->getTraceSafe(); + $cause = array('class' => get_class($this), + 'message' => $this->message, + 'file' => 'unknown', + 'line' => 'unknown'); + if (isset($trace[0])) { + if (isset($trace[0]['file'])) { + $cause['file'] = $trace[0]['file']; + $cause['line'] = $trace[0]['line']; + } + } + $causes[] = $cause; + if ($this->cause instanceof PEAR_Exception) { + $this->cause->getCauseMessage($causes); + } elseif ($this->cause instanceof Exception) { + $causes[] = array('class' => get_class($this->cause), + 'message' => $this->cause->getMessage(), + 'file' => $this->cause->getFile(), + 'line' => $this->cause->getLine()); + } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { + $causes[] = array('class' => get_class($this->cause), + 'message' => $this->cause->getMessage(), + 'file' => 'unknown', + 'line' => 'unknown'); + } elseif (is_array($this->cause)) { + foreach ($this->cause as $cause) { + if ($cause instanceof PEAR_Exception) { + $cause->getCauseMessage($causes); + } elseif ($cause instanceof Exception) { + $causes[] = array('class' => get_class($cause), + 'message' => $cause->getMessage(), + 'file' => $cause->getFile(), + 'line' => $cause->getLine()); + } elseif (class_exists('PEAR_Error') + && $cause instanceof PEAR_Error + ) { + $causes[] = array('class' => get_class($cause), + 'message' => $cause->getMessage(), + 'file' => 'unknown', + 'line' => 'unknown'); + } elseif (is_array($cause) && isset($cause['message'])) { + // PEAR_ErrorStack warning + $causes[] = array( + 'class' => $cause['package'], + 'message' => $cause['message'], + 'file' => isset($cause['context']['file']) ? + $cause['context']['file'] : + 'unknown', + 'line' => isset($cause['context']['line']) ? + $cause['context']['line'] : + 'unknown', + ); + } + } + } + } + + /** + * Build a backtrace and return it + * + * @return array Backtrace + */ + public function getTraceSafe() + { + if (!isset($this->_trace)) { + $this->_trace = $this->getTrace(); + if (empty($this->_trace)) { + $backtrace = debug_backtrace(); + $this->_trace = array($backtrace[count($backtrace)-1]); + } + } + return $this->_trace; + } + + /** + * Gets the first class of the backtrace + * + * @return string Class name + */ + public function getErrorClass() + { + $trace = $this->getTraceSafe(); + return $trace[0]['class']; + } + + /** + * Gets the first method of the backtrace + * + * @return string Method/function name + */ + public function getErrorMethod() + { + $trace = $this->getTraceSafe(); + return $trace[0]['function']; + } + + /** + * Converts the exception to a string (HTML or plain text) + * + * @return string String representation + * + * @see toHtml() + * @see toText() + */ + public function __toString() + { + if (isset($_SERVER['REQUEST_URI'])) { + return $this->toHtml(); + } + return $this->toText(); + } + + /** + * Generates a HTML representation of the exception + * + * @return string HTML code + */ + public function toHtml() + { + $trace = $this->getTraceSafe(); + $causes = array(); + $this->getCauseMessage($causes); + $html = '' . "\n"; + foreach ($causes as $i => $cause) { + $html .= '\n"; + } + $html .= '' . "\n" + . '' + . '' + . '' . "\n"; + + foreach ($trace as $k => $v) { + $html .= '' + . '' + . '' . "\n"; + } + $html .= '' + . '' + . '' . "\n" + . '
' + . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' + . htmlspecialchars($cause['message']) + . ' in ' . $cause['file'] . ' ' + . 'on line ' . $cause['line'] . '' + . "
Exception trace
#FunctionLocation
' . $k . ''; + if (!empty($v['class'])) { + $html .= $v['class'] . $v['type']; + } + $html .= $v['function']; + $args = array(); + if (!empty($v['args'])) { + foreach ($v['args'] as $arg) { + if (is_null($arg)) { + $args[] = 'null'; + } else if (is_array($arg)) { + $args[] = 'Array'; + } else if (is_object($arg)) { + $args[] = 'Object('.get_class($arg).')'; + } else if (is_bool($arg)) { + $args[] = $arg ? 'true' : 'false'; + } else if (is_int($arg) || is_double($arg)) { + $args[] = $arg; + } else { + $arg = (string)$arg; + $str = htmlspecialchars(substr($arg, 0, 16)); + if (strlen($arg) > 16) { + $str .= '…'; + } + $args[] = "'" . $str . "'"; + } + } + } + $html .= '(' . implode(', ', $args) . ')' + . '' . (isset($v['file']) ? $v['file'] : 'unknown') + . ':' . (isset($v['line']) ? $v['line'] : 'unknown') + . '
' . ($k+1) . '{main} 
'; + return $html; + } + + /** + * Generates text representation of the exception and stack trace + * + * @return string + */ + public function toText() + { + $causes = array(); + $this->getCauseMessage($causes); + $causeMsg = ''; + foreach ($causes as $i => $cause) { + $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' + . $cause['message'] . ' in ' . $cause['file'] + . ' on line ' . $cause['line'] . "\n"; + } + return $causeMsg . $this->getTraceAsString(); + } +} +?> diff --git a/vendor/pear/pear_exception/composer.json b/vendor/pear/pear_exception/composer.json new file mode 100644 index 000000000..ce33ed1c8 --- /dev/null +++ b/vendor/pear/pear_exception/composer.json @@ -0,0 +1,43 @@ +{ + "name": "pear/pear_exception", + "description": "The PEAR Exception base class.", + "type": "class", + "keywords": [ + "exception" + ], + "homepage": "https://github.com/pear/PEAR_Exception", + "license": "BSD-2-Clause", + "authors": [ + { + "name": "Helgi Thormar", + "email": "dufuz@php.net" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net" + } + ], + "require": { + "php": ">=4.4.0" + }, + "autoload": { + "psr-0": { + "PEAR": "" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "include-path": [ + "." + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", + "source": "https://github.com/pear/PEAR_Exception" + }, + "require-dev": { + "phpunit/phpunit": "*" + } +} diff --git a/vendor/pear/pear_exception/package.xml b/vendor/pear/pear_exception/package.xml new file mode 100644 index 000000000..98290c6a8 --- /dev/null +++ b/vendor/pear/pear_exception/package.xml @@ -0,0 +1,120 @@ + + + PEAR_Exception + pear.php.net + The PEAR Exception base class + PEAR_Exception PHP5 error handling mechanism + + + Christian Weiske + cweiske + cweiske@php.net + yes + + + Helgi Thormar + dufuz + dufuz@php.net + no + + + Greg Beaver + cellog + cellog@php.net + no + + + 2015-02-10 + + + 1.0.0 + 1.0.0 + + + stable + stable + + New BSD License + + This package was split out from the PEAR package. + If you use PEAR_Exception in your package and use nothing from the PEAR package + then it's better to depend on just PEAR_Exception. + + + + + + + + + + + + + + + + + + 5.4.0 + + + 1.9.5 + + + + + + + + + + 1.0.0 + 1.0.0 + + + stable + stable + + 2015-02-10 + New BSD License + Release stable version + + + + + 1.0.0beta2 + 1.0.0 + + + beta + stable + + 2014-02-21 + New BSD License + Bump up PEAR dependency. + + + + + 1.0.0beta1 + 1.0.0 + + + beta + stable + + 2012-05-10 + New BSD License + +This packge was split out from the PEAR package. If you use PEAR_Exception in your package +and use nothing from the PEAR package then it's better to depend on just PEAR_Exception. + + + + diff --git a/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php b/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php new file mode 100644 index 000000000..61d2df4f1 --- /dev/null +++ b/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php @@ -0,0 +1,78 @@ +assertNull($e->getCause()); + } + + public function testGetCauseException() + { + $cause = new Exception('foo bar'); + $e = new PEAR_Exception('I caught an exception', $cause); + $this->assertNotNull($e->getCause()); + $this->assertInstanceOf('Exception', $e->getCause()); + $this->assertEquals($cause, $e->getCause()); + } + + public function testGetCauseMessage() + { + $cause = new Exception('foo bar'); + $e = new PEAR_Exception('I caught an exception', $cause); + + $e->getCauseMessage($causes); + $this->assertEquals('I caught an exception', $causes[0]['message']); + $this->assertEquals('foo bar', $causes[1]['message']); + } + + public function testGetTraceSafe() + { + $e = new PEAR_Exception('oops'); + $this->assertInternalType('array', $e->getTraceSafe()); + } + + public function testGetErrorClass() + { + $e = new PEAR_Exception('oops'); + $this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass()); + } + + public function testGetErrorMethod() + { + $e = new PEAR_Exception('oops'); + $this->assertEquals('testGetErrorMethod', $e->getErrorMethod()); + } + + public function test__toString() + { + $e = new PEAR_Exception('oops'); + $this->assertInternalType('string', (string) $e); + $this->assertContains('oops', (string) $e); + } + + public function testToHtml() + { + $e = new PEAR_Exception('oops'); + $html = $e->toHtml(); + $this->assertInternalType('string', $html); + $this->assertContains('oops', $html); + } +} +?> diff --git a/vendor/swiftmailer/swiftmailer/.gitattributes b/vendor/swiftmailer/swiftmailer/.gitattributes new file mode 100644 index 000000000..33b8efdb8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.gitattributes @@ -0,0 +1,9 @@ +*.crt -crlf +*.key -crlf +*.srl -crlf +*.pub -crlf +*.priv -crlf +*.txt -crlf + +# ignore /notes in the git-generated distributed .zip archive +/notes export-ignore diff --git a/vendor/swiftmailer/swiftmailer/.gitignore b/vendor/swiftmailer/swiftmailer/.gitignore new file mode 100644 index 000000000..9a23ffe6d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.gitignore @@ -0,0 +1,4 @@ +/tests/acceptance.conf.php +/tests/smoke.conf.php +/build/* +/vendor/ diff --git a/vendor/swiftmailer/swiftmailer/.travis.yml b/vendor/swiftmailer/swiftmailer/.travis.yml new file mode 100644 index 000000000..cadee014c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.travis.yml @@ -0,0 +1,25 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm-nightly + +before_script: + - cp tests/acceptance.conf.php.default tests/acceptance.conf.php + - cp tests/smoke.conf.php.default tests/smoke.conf.php + - composer self-update + - composer update --no-interaction --prefer-source + - gem install mailcatcher + - mailcatcher --smtp-port 4456 + +script: + - phpunit --verbose + +matrix: + allow_failures: + - php: 5.6 + - php: hhvm-nightly + fast_finish: true diff --git a/vendor/swiftmailer/swiftmailer/CHANGES b/vendor/swiftmailer/swiftmailer/CHANGES new file mode 100644 index 000000000..7330acdcf --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/CHANGES @@ -0,0 +1,206 @@ +Changelog +========= + +5.4.1 (2015-06-06) +------------------ + + * made Swiftmailer exceptions confirm to PHP base exception constructor signature + * fixed MAIL FROM & RCPT TO headers to be RFC compliant + +5.4.0 (2015-03-14) +------------------ + + * added the possibility to add extra certs to PKCS#7 signature + * fix base64 encoding with streams + * added a new RESULT_SPOOLED status for SpoolTransport + * fixed getBody() on attachments when called more than once + * removed dots from generated filenames in filespool + +5.3.1 (2014-12-05) +------------------ + + * fixed cloning of messages with attachments + +5.3.0 (2014-10-04) +------------------ + + * fixed cloning when using signers + * reverted removal of Swift_Encoding + * drop support for PHP 5.2.x + +5.2.2 (2014-09-20) +------------------ + + * fixed Japanese support + * fixed the memory spool when the message changes when in the pool + * added support for cloning messages + * fixed PHP warning in the redirect plugin + * changed the way to and cc-ed email are sent to only use one transaction + +5.2.1 (2014-06-13) +------------------ + + * SECURITY FIX: fixed CLI escaping when using sendmail as a transport + + Prior to 5.2.1, the sendmail transport (Swift_Transport_SendmailTransport) + was vulnerable to an arbitrary shell execution if the "From" header came + from a non-trusted source and no "Return-Path" is configured. + + * fixed parameter in DKIMSigner + * fixed compatibility with PHP < 5.4 + +5.2.0 (2014-05-08) +------------------ + + * fixed Swift_ByteStream_FileByteStream::read() to match to the specification + * fixed from-charset and to-charset arguments in mbstring_convert_encoding() usages + * fixed infinite loop in StreamBuffer + * fixed NullTransport to return the number of ignored emails instead of 0 + * Use phpunit and mockery for unit testing (realityking) + +5.1.0 (2014-03-18) +------------------ + + * fixed data writing to stream when sending large messages + * added support for libopendkim (https://github.com/xdecock/php-opendkim) + * merged SignedMessage and Message + * added Gmail XOAuth2 authentication + * updated the list of known mime types + * added NTLM authentication + +5.0.3 (2013-12-03) +------------------ + + * fixed double-dot bug + * fixed DKIM signer + +5.0.2 (2013-08-30) +------------------ + + * handled correct exception type while reading IoBuffer output + +5.0.1 (2013-06-17) +------------------ + + * changed the spool to only start the transport when a mail has to be sent + * fixed compatibility with PHP 5.2 + * fixed LICENSE file + +5.0.0 (2013-04-30) +------------------ + + * changed the license from LGPL to MIT + +4.3.1 (2013-04-11) +------------------ + + * removed usage of the native QP encoder when the charset is not UTF-8 + * fixed usage of uniqid to avoid collisions + * made a performance improvement when tokenizing large headers + * fixed usage of the PHP native QP encoder on PHP 5.4.7+ + +4.3.0 (2013-01-08) +------------------ + + * made the temporary directory configurable via the TMPDIR env variable + * added S/MIME signer and encryption support + +4.2.2 (2012-10-25) +------------------ + + * added the possibility to throttle messages per second in ThrottlerPlugin (mostly for Amazon SES) + * switched mime.qpcontentencoder to automatically use the PHP native encoder on PHP 5.4.7+ + * allowed specifying a whitelist with regular expressions in RedirectingPlugin + +4.2.1 (2012-07-13) +------------------ + + * changed the coding standards to PSR-1/2 + * fixed issue with autoloading + * added NativeQpContentEncoder to enhance performance (for PHP 5.3+) + +4.2.0 (2012-06-29) +------------------ + + * added documentation about how to use the Japanese support introduced in 4.1.8 + * added a way to override the default configuration in a lazy way + * changed the PEAR init script to lazy-load the initialization + * fixed a bug when calling Swift_Preferences before anything else (regression introduced in 4.1.8) + +4.1.8 (2012-06-17) +------------------ + + * added Japanese iso-2022-jp support + * changed the init script to lazy-load the initialization + * fixed docblocks (@id) which caused some problems with libraries parsing the dobclocks + * fixed Swift_Mime_Headers_IdentificationHeader::setId() when passed an array of ids + * fixed encoding of email addresses in headers + * added replacements setter to the Decorator plugin + +4.1.7 (2012-04-26) +------------------ + + * fixed QpEncoder safeMapShareId property + +4.1.6 (2012-03-23) +------------------ + + * reduced the size of serialized Messages + +4.1.5 (2012-01-04) +------------------ + + * enforced Swift_Spool::queueMessage() to return a Boolean + * made an optimization to the memory spool: start the transport only when required + * prevented stream_socket_client() from generating an error and throw a Swift_TransportException instead + * fixed a PHP warning when calling to mail() when safe_mode is off + * many doc tweaks + +4.1.4 (2011-12-16) +------------------ + + * added a memory spool (Swift_MemorySpool) + * fixed too many opened files when sending emails with attachments + +4.1.3 (2011-10-27) +------------------ + + * added STARTTLS support + * added missing @return tags on fluent methods + * added a MessageLogger plugin that logs all sent messages + * added composer.json + +4.1.2 (2011-09-13) +------------------ + + * fixed wrong detection of magic_quotes_runtime + * fixed fatal errors when no To or Subject header has been set + * fixed charset on parameter header continuations + * added documentation about how to install Swiftmailer from the PEAR channel + * fixed various typos and markup problem in the documentation + * fixed warning when cache directory does not exist + * fixed "slashes are escaped" bug + * changed require_once() to require() in autoload + +4.1.1 (2011-07-04) +------------------ + + * added missing file in PEAR package + +4.1.0 (2011-06-30) +------------------ + + * documentation has been converted to ReST + +4.1.0 RC1 (2011-06-17) +---------------------- + +New features: + + * changed the Decorator Plugin to allow replacements in all headers + * added Swift_Mime_Grammar and Swift_Validate to validate an email address + * modified the autoloader to lazy-initialize Swiftmailer + * removed Swift_Mailer::batchSend() + * added NullTransport + * added new plugins: RedirectingPlugin and ImpersonatePlugin + * added a way to send messages asynchronously (Spool) diff --git a/vendor/swiftmailer/swiftmailer/LICENSE b/vendor/swiftmailer/swiftmailer/LICENSE new file mode 100644 index 000000000..674bb2a6e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/swiftmailer/swiftmailer/README b/vendor/swiftmailer/swiftmailer/README new file mode 100644 index 000000000..eb5f8bcfa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/README @@ -0,0 +1,16 @@ +Swift Mailer +------------ + +Swift Mailer is a component based mailing solution for PHP 5. +It is released under the MIT license. + +Homepage: http://swiftmailer.org +Documentation: http://swiftmailer.org/docs +Mailing List: http://groups.google.com/group/swiftmailer +Bugs: https://github.com/swiftmailer/swiftmailer/issues +Repository: https://github.com/swiftmailer/swiftmailer + +Swift Mailer is highly object-oriented by design and lends itself +to use in complex web application with a great deal of flexibility. + +For full details on usage, see the documentation. diff --git a/vendor/swiftmailer/swiftmailer/VERSION b/vendor/swiftmailer/swiftmailer/VERSION new file mode 100644 index 000000000..e61a6dffa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/VERSION @@ -0,0 +1 @@ +Swift-5.4.1 diff --git a/vendor/swiftmailer/swiftmailer/composer.json b/vendor/swiftmailer/swiftmailer/composer.json new file mode 100644 index 000000000..a7b5e4476 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/composer.json @@ -0,0 +1,31 @@ +{ + "name": "swiftmailer/swiftmailer", + "type": "library", + "description": "Swiftmailer, free feature-rich PHP mailer", + "keywords": ["mail","mailer","email"], + "homepage": "http://swiftmailer.org", + "license": "MIT", + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1,<0.9.4" + }, + "autoload": { + "files": ["lib/swift_required.php"] + }, + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/doc/headers.rst b/vendor/swiftmailer/swiftmailer/doc/headers.rst new file mode 100644 index 000000000..6aec23ff3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/headers.rst @@ -0,0 +1,742 @@ +Message Headers +=============== + +Sometimes you'll want to add your own headers to a message or modify/remove +headers that are already present. You work with the message's HeaderSet to do +this. + +Header Basics +------------- + +All MIME entities in Swift Mailer -- including the message itself -- +store their headers in a single object called a HeaderSet. This HeaderSet is +retrieved with the ``getHeaders()`` method. + +As mentioned in the previous chapter, everything that forms a part of a message +in Swift Mailer is a MIME entity that is represented by an instance of +``Swift_Mime_MimeEntity``. This includes -- most notably -- the message object +itself, attachments, MIME parts and embedded images. Each of these MIME entities +consists of a body and a set of headers that describe the body. + +For all of the "standard" headers in these MIME entities, such as the +``Content-Type``, there are named methods for working with them, such as +``setContentType()`` and ``getContentType()``. This is because headers are a +moderately complex area of the library. Each header has a slightly different +required structure that it must meet in order to comply with the standards that +govern email (and that are checked by spam blockers etc). + +You fetch the HeaderSet from a MIME entity like so: + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + // Fetch the HeaderSet from a Message object + $headers = $message->getHeaders(); + + $attachment = Swift_Attachment::fromPath('document.pdf'); + + // Fetch the HeaderSet from an attachment object + $headers = $attachment->getHeaders(); + +The job of the HeaderSet is to contain and manage instances of Header objects. +Depending upon the MIME entity the HeaderSet came from, the contents of the +HeaderSet will be different, since an attachment for example has a different +set of headers to those in a message. + +You can find out what the HeaderSet contains with a quick loop, dumping out +the names of the headers: + +.. code-block:: php + + foreach ($headers->getAll() as $header) { + printf("%s
\n", $header->getFieldName()); + } + + /* + Content-Transfer-Encoding + Content-Type + MIME-Version + Date + Message-ID + From + Subject + To + */ + +You can also dump out the rendered HeaderSet by calling its ``toString()`` +method: + +.. code-block:: php + + echo $headers->toString(); + + /* + Message-ID: <1234869991.499a9ee7f1d5e@swift.generated> + Date: Tue, 17 Feb 2009 22:26:31 +1100 + Subject: Awesome subject! + From: sender@example.org + To: recipient@example.org + MIME-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + */ + +Where the complexity comes in is when you want to modify an existing header. +This complexity comes from the fact that each header can be of a slightly +different type (such as a Date header, or a header that contains email +addresses, or a header that has key-value parameters on it!). Each header in the +HeaderSet is an instance of ``Swift_Mime_Header``. They all have common +functionality, but knowing exactly what type of header you're working with will +allow you a little more control. + +You can determine the type of header by comparing the return value of its +``getFieldType()`` method with the constants ``TYPE_TEXT``, +``TYPE_PARAMETERIZED``, ``TYPE_DATE``, ``TYPE_MAILBOX``, ``TYPE_ID`` and +``TYPE_PATH`` which are defined in ``Swift_Mime_Header``. + + +.. code-block:: php + + foreach ($headers->getAll() as $header) { + switch ($header->getFieldType()) { + case Swift_Mime_Header::TYPE_TEXT: $type = 'text'; + break; + case Swift_Mime_Header::TYPE_PARAMETERIZED: $type = 'parameterized'; + break; + case Swift_Mime_Header::TYPE_MAILBOX: $type = 'mailbox'; + break; + case Swift_Mime_Header::TYPE_DATE: $type = 'date'; + break; + case Swift_Mime_Header::TYPE_ID: $type = 'ID'; + break; + case Swift_Mime_Header::TYPE_PATH: $type = 'path'; + break; + } + printf("%s: is a %s header
\n", $header->getFieldName(), $type); + } + + /* + Content-Transfer-Encoding: is a text header + Content-Type: is a parameterized header + MIME-Version: is a text header + Date: is a date header + Message-ID: is a ID header + From: is a mailbox header + Subject: is a text header + To: is a mailbox header + */ + +Headers can be removed from the set, modified within the set, or added to the +set. + +The following sections show you how to work with the HeaderSet and explain the +details of each implementation of ``Swift_Mime_Header`` that may +exist within the HeaderSet. + +Header Types +------------ + +Because all headers are modeled on different data (dates, addresses, text!) +there are different types of Header in Swift Mailer. Swift Mailer attempts to +categorize all possible MIME headers into more general groups, defined by a +small number of classes. + +Text Headers +~~~~~~~~~~~~ + +Text headers are the simplest type of Header. They contain textual information +with no special information included within it -- for example the Subject +header in a message. + +There's nothing particularly interesting about a text header, though it is +probably the one you'd opt to use if you need to add a custom header to a +message. It represents text just like you'd think it does. If the text +contains characters that are not permitted in a message header (such as new +lines, or non-ascii characters) then the header takes care of encoding the +text so that it can be used. + +No header -- including text headers -- in Swift Mailer is vulnerable to +header-injection attacks. Swift Mailer breaks any attempt at header injection by +encoding the dangerous data into a non-dangerous form. + +It's easy to add a new text header to a HeaderSet. You do this by calling the +HeaderSet's ``addTextHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addTextHeader('Your-Header-Name', 'the header value'); + +Changing the value of an existing text header is done by calling it's +``setValue()`` method. + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('new subject'); + +When output via ``toString()``, a text header produces something like the +following: + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('amazing subject line'); + + echo $subject->toString(); + + /* + + Subject: amazing subject line + + */ + +If the header contains any characters that are outside of the US-ASCII range +however, they will be encoded. This is nothing to be concerned about since +mail clients will decode them back. + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('contains – dash'); + + echo $subject->toString(); + + /* + + Subject: contains =?utf-8?Q?=E2=80=93?= dash + + */ + +Parameterized Headers +~~~~~~~~~~~~~~~~~~~~~ + +Parameterized headers are text headers that contain key-value parameters +following the textual content. The Content-Type header of a message is a +parameterized header since it contains charset information after the content +type. + +The parameterized header type is a special type of text header. It extends the +text header by allowing additional information to follow it. All of the methods +from text headers are available in addition to the methods described here. + +Adding a parameterized header to a HeaderSet is done by using the +``addParameterizedHeader()`` method which takes a text value like +``addTextHeader()`` but it also accepts an associative array of +key-value parameters. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addParameterizedHeader( + 'Header-Name', 'header value', + array('foo' => 'bar') + ); + +To change the text value of the header, call it's ``setValue()`` method just as +you do with text headers. + +To change the parameters in the header, call the header's ``setParameters()`` +method or the ``setParameter()`` method (note the pluralization). + +.. code-block:: php + + $type = $message->getHeaders()->get('Content-Type'); + + // setParameters() takes an associative array + $type->setParameters(array( + 'name' => 'file.txt', + 'charset' => 'iso-8859-1' + )); + + // setParameter() takes two args for $key and $value + $type->setParameter('charset', 'iso-8859-1'); + +When output via ``toString()``, a parameterized header produces something like +the following: + +.. code-block:: php + + $type = $message->getHeaders()->get('Content-Type'); + + $type->setValue('text/html'); + $type->setParameter('charset', 'utf-8'); + + echo $type->toString(); + + /* + + Content-Type: text/html; charset=utf-8 + + */ + +If the header contains any characters that are outside of the US-ASCII range +however, they will be encoded, just like they are for text headers. This is +nothing to be concerned about since mail clients will decode them back. +Likewise, if the parameters contain any non-ascii characters they will be +encoded so that they can be transmitted safely. + +.. code-block:: php + + $attachment = Swift_Attachment::newInstance(); + + $disp = $attachment->getHeaders()->get('Content-Disposition'); + + $disp->setValue('attachment'); + $disp->setParameter('filename', 'report–may.pdf'); + + echo $disp->toString(); + + /* + + Content-Disposition: attachment; filename*=utf-8''report%E2%80%93may.pdf + + */ + +Date Headers +~~~~~~~~~~~~ + +Date headers contains an RFC 2822 formatted date (i.e. what PHP's ``date('r')`` +returns). They are used anywhere a date or time is needed to be presented as a +message header. + +The data on which a date header is modeled is simply a UNIX timestamp such as +that returned by ``time()`` or ``strtotime()``. The timestamp is used to create +a correctly structured RFC 2822 formatted date such as +``Tue, 17 Feb 2009 22:26:31 +1100``. + +The obvious place this header type is used is in the ``Date:`` header of the +message itself. + +It's easy to add a new date header to a HeaderSet. You do this by calling +the HeaderSet's ``addDateHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addDateHeader('Your-Header-Name', strtotime('3 days ago')); + +Changing the value of an existing date header is done by calling it's +``setTimestamp()`` method. + +.. code-block:: php + + $date = $message->getHeaders()->get('Date'); + + $date->setTimestamp(time()); + +When output via ``toString()``, a date header produces something like the +following: + +.. code-block:: php + + $date = $message->getHeaders()->get('Date'); + + echo $date->toString(); + + /* + + Date: Wed, 18 Feb 2009 13:35:02 +1100 + + */ + +Mailbox (e-mail address) Headers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Mailbox headers contain one or more email addresses, possibly with +personalized names attached to them. The data on which they are modeled is +represented by an associative array of email addresses and names. + +Mailbox headers are probably the most complex header type to understand in +Swift Mailer because they accept their input as an array which can take various +forms, as described in the previous chapter. + +All of the headers that contain e-mail addresses in a message -- with the +exception of ``Return-Path:`` which has a stricter syntax -- use this header +type. That is, ``To:``, ``From:`` etc. + +You add a new mailbox header to a HeaderSet by calling the HeaderSet's +``addMailboxHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addMailboxHeader('Your-Header-Name', array( + 'person1@example.org' => 'Person Name One', + 'person2@example.org', + 'person3@example.org', + 'person4@example.org' => 'Another named person' + )); + +Changing the value of an existing mailbox header is done by calling it's +``setNameAddresses()`` method. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setNameAddresses(array( + 'joe@example.org' => 'Joe Bloggs', + 'john@example.org' => 'John Doe', + 'no-name@example.org' + )); + +If you don't wish to concern yourself with the complicated accepted input +formats accepted by ``setNameAddresses()`` as described in the previous chapter +and you only want to set one or more addresses (not names) then you can just +use the ``setAddresses()`` method instead. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setAddresses(array( + 'joe@example.org', + 'john@example.org', + 'no-name@example.org' + )); + +.. note:: + + Both methods will accept the above input format in practice. + +If all you want to do is set a single address in the header, you can use a +string as the input parameter to ``setAddresses()`` and/or +``setNameAddresses()``. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setAddresses('joe-bloggs@example.org'); + +When output via ``toString()``, a mailbox header produces something like the +following: + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setNameAddresses(array( + 'person1@example.org' => 'Name of Person', + 'person2@example.org', + 'person3@example.org' => 'Another Person' + )); + + echo $to->toString(); + + /* + + To: Name of Person , person2@example.org, Another Person + + + */ + +ID Headers +~~~~~~~~~~ + +ID headers contain identifiers for the entity (or the message). The most +notable ID header is the Message-ID header on the message itself. + +An ID that exists inside an ID header looks more-or-less less like an email +address. For example, ``<1234955437.499becad62ec2@example.org>``. +The part to the left of the @ sign is usually unique, based on the current time +and some random factor. The part on the right is usually a domain name. + +Any ID passed to the header's ``setId()`` method absolutely MUST conform to +this structure, otherwise you'll get an Exception thrown at you by Swift Mailer +(a ``Swift_RfcComplianceException``). This is to ensure that the generated +email complies with relevant RFC documents and therefore is less likely to be +blocked as spam. + +It's easy to add a new ID header to a HeaderSet. You do this by calling +the HeaderSet's ``addIdHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addIdHeader('Your-Header-Name', '123456.unqiue@example.org'); + +Changing the value of an existing date header is done by calling its +``setId()`` method. + +.. code-block:: php + + $msgId = $message->getHeaders()->get('Message-ID'); + + $msgId->setId(time() . '.' . uniqid('thing') . '@example.org'); + +When output via ``toString()``, an ID header produces something like the +following: + +.. code-block:: php + + $msgId = $message->getHeaders()->get('Message-ID'); + + echo $msgId->toString(); + + /* + + Message-ID: <1234955437.499becad62ec2@example.org> + + */ + +Path Headers +~~~~~~~~~~~~ + +Path headers are like very-restricted mailbox headers. They contain a single +email address with no associated name. The Return-Path header of a message is +a path header. + +You add a new path header to a HeaderSet by calling the HeaderSet's +``addPathHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addPathHeader('Your-Header-Name', 'person@example.org'); + + +Changing the value of an existing path header is done by calling its +``setAddress()`` method. + +.. code-block:: php + + $return = $message->getHeaders()->get('Return-Path'); + + $return->setAddress('my-address@example.org'); + +When output via ``toString()``, a path header produces something like the +following: + +.. code-block:: php + + $return = $message->getHeaders()->get('Return-Path'); + + $return->setAddress('person@example.org'); + + echo $return->toString(); + + /* + + Return-Path: + + */ + +Header Operations +----------------- + +Working with the headers in a message involves knowing how to use the methods +on the HeaderSet and on the individual Headers within the HeaderSet. + +Adding new Headers +~~~~~~~~~~~~~~~~~~ + +New headers can be added to the HeaderSet by using one of the provided +``add..Header()`` methods. + +To add a header to a MIME entity (such as the message): + +Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Add the header to the HeaderSet by calling one of the ``add..Header()`` + methods. + +The added header will appear in the message when it is sent. + +.. code-block:: php + + // Adding a custom header to a message + $message = Swift_Message::newInstance(); + $headers = $message->getHeaders(); + $headers->addTextHeader('X-Mine', 'something here'); + + // Adding a custom header to an attachment + $attachment = Swift_Attachment::fromPath('/path/to/doc.pdf'); + $attachment->getHeaders()->addDateHeader('X-Created-Time', time()); + +Retrieving Headers +~~~~~~~~~~~~~~~~~~ + +Headers are retrieved through the HeaderSet's ``get()`` and ``getAll()`` +methods. + +To get a header, or several headers from a MIME entity: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Get the header(s) from the HeaderSet by calling either ``get()`` or + ``getAll()``. + +When using ``get()`` a single header is returned that matches the name (case +insensitive) that is passed to it. When using ``getAll()`` with a header name, +an array of headers with that name are returned. Calling ``getAll()`` with no +arguments returns an array of all headers present in the entity. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``getAll()`` exists to fetch all + headers with a specified name. In addition, ``get()`` accepts an optional + numerical index, starting from zero to specify which header you want more + specifically. + +.. note:: + + If you want to modify the contents of the header and you don't know for + sure what type of header it is then you may need to check the type by + calling its ``getFieldType()`` method. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Get the To: header + $toHeader = $headers->get('To'); + + // Get all headers named "X-Foo" + $fooHeaders = $headers->getAll('X-Foo'); + + // Get the second header named "X-Foo" + $foo = $headers->get('X-Foo', 1); + + // Get all headers that are present + $all = $headers->getAll(); + +Check if a Header Exists +~~~~~~~~~~~~~~~~~~~~~~~~ + +You can check if a named header is present in a HeaderSet by calling its +``has()`` method. + +To check if a header exists: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Call the HeaderSet's ``has()`` method specifying the header you're looking + for. + +If the header exists, ``true`` will be returned or ``false`` if not. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``has()`` accepts an optional + numerical index, starting from zero to specify which header you want to + check more specifically. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Check if the To: header exists + if ($headers->has('To')) { + echo 'To: exists'; + } + + // Check if an X-Foo header exists twice (i.e. check for the 2nd one) + if ($headers->has('X-Foo', 1)) { + echo 'Second X-Foo header exists'; + } + +Removing Headers +~~~~~~~~~~~~~~~~ + +Removing a Header from the HeaderSet is done by calling the HeaderSet's +``remove()`` or ``removeAll()`` methods. + +To remove an existing header: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Call the HeaderSet's ``remove()`` or ``removeAll()`` methods specifying the + header you want to remove. + +When calling ``remove()`` a single header will be removed. When calling +``removeAll()`` all headers with the given name will be removed. If no headers +exist with the given name, no errors will occur. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``remove()`` accepts an optional + numerical index, starting from zero to specify which header you want to + check more specifically. For the same reason, ``removeAll()`` exists to + remove all headers that have the given name. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Remove the Subject: header + $headers->remove('Subject'); + + // Remove all X-Foo headers + $headers->removeAll('X-Foo'); + + // Remove only the second X-Foo header + $headers->remove('X-Foo', 1); + +Modifying a Header's Content +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To change a Header's content you should know what type of header it is and then +call it's appropriate setter method. All headers also have a +``setFieldBodyModel()`` method that accepts a mixed parameter and delegates to +the correct setter. + +To modify an existing header: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Get the Header by using the HeaderSet's ``get()``. + +* Call the Header's appropriate setter method or call the header's + ``setFieldBodyModel()`` method. + +The header will be updated inside the HeaderSet and the changes will be seen +when the message is sent. + +.. code-block:: php + + $headers = $message->getHeaders(); + + // Change the Subject: header + $subj = $headers->get('Subject'); + $subj->setValue('new subject here'); + + // Change the To: header + $to = $headers->get('To'); + $to->setNameAddresses(array( + 'person@example.org' => 'Person', + 'thing@example.org' + )); + + // Using the setFieldBodyModel() just delegates to the correct method + // So here to calls setNameAddresses() + $to->setFieldBodyModel(array( + 'person@example.org' => 'Person', + 'thing@example.org' + )); diff --git a/vendor/swiftmailer/swiftmailer/doc/help-resources.rst b/vendor/swiftmailer/swiftmailer/doc/help-resources.rst new file mode 100644 index 000000000..420893590 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/help-resources.rst @@ -0,0 +1,44 @@ +Getting Help +============ + +There are a number of ways you can get help when using Swift Mailer, depending +upon the nature of your problem. For bug reports and feature requests create a +new ticket in GitHub. For general advice ask on the Google Group +(swiftmailer). + +Submitting Bugs & Feature Requests +---------------------------------- + +Bugs and feature requests should be posted on GitHub. + +If you post a bug or request a feature in the forum, or on the Google Group +you will most likely be asked to create a ticket in `GitHub`_ since it is +simply not feasible to manage such requests from a number of a different +sources. + +When you go to GitHub you will be asked to create a username and password +before you can create a ticket. This is free and takes very little time. + +When you create your ticket, do not assign it to any milestones. A developer +will assess your ticket and re-assign it as needed. + +If your ticket is reporting a bug present in the current version, which was +not present in the previous version please include the tag "regression" in +your ticket. + +GitHub will update you when work is performed on your ticket. + +Ask on the Google Group +----------------------- + +You can seek advice at Google Groups, within the "swiftmailer" `group`_. + +You can post messages to this group if you want help, or there's something you +wish to discuss with the developers and with other users. + +This is probably the fastest way to get help since it is primarily email-based +for most users, though bug reports should not be posted here since they may +not be resolved. + +.. _`GitHub`: https://github.com/swiftmailer/swiftmailer/issues +.. _`group`: http://groups.google.com/group/swiftmailer diff --git a/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst b/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst new file mode 100644 index 000000000..978dca206 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst @@ -0,0 +1,46 @@ +Including Swift Mailer (Autoloading) +==================================== + +If you are using Composer, Swift Mailer will be automatically autoloaded. + +If not, you can use the built-in autoloader by requiring the +``swift_required.php`` file:: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + /* rest of code goes here */ + +If you want to override the default Swift Mailer configuration, call the +``init()`` method on the ``Swift`` class and pass it a valid PHP callable (a +PHP function name, a PHP 5.3 anonymous function, ...):: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + function swiftmailer_configurator() { + // configure Swift Mailer + + Swift_DependencyContainer::getInstance()->... + Swift_Preferences::getInstance()->... + } + + Swift::init('swiftmailer_configurator'); + + /* rest of code goes here */ + +The advantage of using the ``init()`` method is that your code will be +executed only if you use Swift Mailer in your script. + +.. note:: + + While Swift Mailer's autoloader is designed to play nicely with other + autoloaders, sometimes you may have a need to avoid using Swift Mailer's + autoloader and use your own instead. Include the ``swift_init.php`` + instead of the ``swift_required.php`` if you need to do this. The very + minimum include is the ``swift_init.php`` file since Swift Mailer will not + work without the dependency injection this file sets up: + + .. code-block:: php + + require_once '/path/to/swift-mailer/lib/swift_init.php'; + + /* rest of code goes here */ diff --git a/vendor/swiftmailer/swiftmailer/doc/index.rst b/vendor/swiftmailer/swiftmailer/doc/index.rst new file mode 100644 index 000000000..a1a0a9246 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/index.rst @@ -0,0 +1,16 @@ +Swiftmailer +=========== + +.. toctree:: + :maxdepth: 2 + + introduction + overview + installing + help-resources + including-the-files + messages + headers + sending + plugins + japanese diff --git a/vendor/swiftmailer/swiftmailer/doc/installing.rst b/vendor/swiftmailer/swiftmailer/doc/installing.rst new file mode 100644 index 000000000..557211d48 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/installing.rst @@ -0,0 +1,89 @@ +Installing the Library +====================== + +Installing with Composer +------------------------ + +The recommended way to install Swiftmailer is via Composer: + +.. code-block:: bash + + $ php composer.phar require swiftmailer/swiftmailer @stable + +Installing from Git +------------------- + +It's possible to download and install Swift Mailer directly from github.com if +you want to keep up-to-date with ease. + +Swift Mailer's source code is kept in a git repository at github.com so you +can get the source directly from the repository. + +.. note:: + + You do not need to have git installed to use Swift Mailer from GitHub. If + you don't have git installed, go to `GitHub`_ and click the "Download" + button. + +Cloning the Repository +~~~~~~~~~~~~~~~~~~~~~~ + +The repository can be cloned from git://github.com/swiftmailer/swiftmailer.git +using the ``git clone`` command. + +You will need to have ``git`` installed before you can use the +``git clone`` command. + +To clone the repository: + +* Open your favorite terminal environment (command line). + +* Move to the directory you want to clone to. + +* Run the command ``git clone git://github.com/swiftmailer/swiftmailer.git + swiftmailer``. + +The source code will be downloaded into a directory called "swiftmailer". + +The example shows the process on a UNIX-like system such as Linux, BSD or Mac +OS X. + +.. code-block:: bash + + $ cd source_code/ + $ git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer + Initialized empty Git repository in /Users/chris/source_code/swiftmailer/.git/ + remote: Counting objects: 6815, done. + remote: Compressing objects: 100% (2761/2761), done. + remote: Total 6815 (delta 3641), reused 6326 (delta 3286) + Receiving objects: 100% (6815/6815), 4.35 MiB | 162 KiB/s, done. + Resolving deltas: 100% (3641/3641), done. + Checking out files: 100% (1847/1847), done. + $ cd swiftmailer/ + $ ls + CHANGES LICENSE ... + $ + +Troubleshooting +--------------- + +Swift Mailer does not work when used with function overloading as implemented +by ``mbstring`` (``mbstring.func_overload`` set to ``2``). A workaround is to +temporarily change the internal encoding to ``ASCII`` when sending an email: + +.. code-block:: php + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) + { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + // Create your message and send it with Swift Mailer + + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } + +.. _`GitHub`: http://github.com/swiftmailer/swiftmailer diff --git a/vendor/swiftmailer/swiftmailer/doc/introduction.rst b/vendor/swiftmailer/swiftmailer/doc/introduction.rst new file mode 100644 index 000000000..a85336b7c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/introduction.rst @@ -0,0 +1,135 @@ +Introduction +============ + +Swift Mailer is a component-based library for sending e-mails from PHP +applications. + +Organization of this Book +------------------------- + +This book has been written so that those who need information quickly are able +to find what they need, and those who wish to learn more advanced topics can +read deeper into each chapter. + +The book begins with an overview of Swift Mailer, discussing what's included +in the package and preparing you for the remainder of the book. + +It is possible to read this user guide just like any other book (from +beginning to end). Each chapter begins with a discussion of the contents it +contains, followed by a short code sample designed to give you a head start. +As you get further into a chapter you will learn more about Swift Mailer's +capabilities, but often you will be able to head directly to the topic you +wish to learn about. + +Throughout this book you will be presented with code samples, which most +people should find ample to implement Swift Mailer appropriately in their own +projects. We will also use diagrams where appropriate, and where we believe +readers may find it helpful we will discuss some related theory, including +reference to certain documents you are able to find online. + +Code Samples +------------ + +Code samples presented in this book will be displayed on a different colored +background in a monospaced font. Samples are not to be taken as copy & paste +code snippets. + +Code examples are used through the book to clarify what is written in text. +They will sometimes be usable as-is, but they should always be taken as +outline/pseudo code only. + +A code sample will look like this:: + + class AClass + { + ... + } + + // A Comment + $obj = new AClass($arg1, $arg2, ... ); + + /* A note about another way of doing something + $obj = AClass::newInstance($arg1, $arg2, ... ); + + */ + +The presence of 3 dots ``...`` in a code sample indicates that we have left +out a chunk of the code for brevity, they are not actually part of the code. + +We will often place multi-line comments ``/* ... */`` in the code so that we +can show alternative ways of achieving the same result. + +You should read the code examples given and try to understand them. They are +kept concise so that you are not overwhelmed with information. + +History of Swift Mailer +----------------------- + +Swift Mailer began back in 2005 as a one-class project for sending mail over +SMTP. It has since grown into the flexible component-based library that is in +development today. + +Chris Corbyn first posted Swift Mailer on a web forum asking for comments from +other developers. It was never intended as a fully supported open source +project, but members of the forum began to adopt it and make use of it. + +Very quickly feature requests were coming for the ability to add attachments +and use SMTP authentication, along with a number of other "obvious" missing +features. Considering the only alternative was PHPMailer it seemed like a good +time to bring some fresh tools to the table. Chris began working towards a +more component based, PHP5-like approach unlike the existing single-class, +legacy PHP4 approach taken by PHPMailer. + +Members of the forum offered a lot of advice and critique on the code as he +worked through this project and released versions 2 and 3 of the library in +2005 and 2006, which by then had been broken down into smaller classes +offering more flexibility and supporting plugins. To this day the Swift Mailer +team still receive a lot of feature requests from users both on the forum and +in by email. + +Until 2008 Chris was the sole developer of Swift Mailer, but entering 2009 he +gained the support of two experienced developers well-known to him: Paul +Annesley and Christopher Thompson. This has been an extremely welcome change. + +As of September 2009, Chris handed over the maintenance of Swift Mailer to +Fabien Potencier. + +Now 2009 and in its fourth major version Swift Mailer is more object-oriented +and flexible than ever, both from a usability standpoint and from a +development standpoint. + +By no means is Swift Mailer ready to call "finished". There are still many +features that can be added to the library along with the constant refactoring +that happens behind the scenes. + +It's a Library! +--------------- + +Swift Mailer is not an application - it's a library. + +To most experienced developers this is probably an obvious point to make, but +it's certainly worth mentioning. Many people often contact us having gotten +the completely wrong end of the stick in terms of what Swift Mailer is +actually for. + +It's not an application. It does not have a graphical user interface. It +cannot be opened in your web browser directly. + +It's a library (or a framework if you like). It provides a whole lot of +classes that do some very complicated things, so that you don't have to. You +"use" Swift Mailer within an application so that your application can have the +ability to send emails. + +The component-based structure of the library means that you are free to +implement it in a number of different ways and that you can pick and choose +what you want to use. + +An application on the other hand (such as a blog or a forum) is already "put +together" in a particular way, (usually) provides a graphical user interface +and most likely doesn't offer a great deal of integration with your own +application. + +Embrace the structure of the library and use the components it offers to your +advantage. Learning what the components do, rather than blindly copying and +pasting existing code will put you in a great position to build a powerful +application! diff --git a/vendor/swiftmailer/swiftmailer/doc/japanese.rst b/vendor/swiftmailer/swiftmailer/doc/japanese.rst new file mode 100644 index 000000000..34afa7b8f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/japanese.rst @@ -0,0 +1,22 @@ +Using Swift Mailer for Japanese Emails +====================================== + +To send emails in Japanese, you need to tweak the default configuration. + +After requiring the Swift Mailer autoloader (by including the +``swift_required.php`` file), call the ``Swift::init()`` method with the +following code:: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + Swift::init(function () { + Swift_DependencyContainer::getInstance() + ->register('mime.qpheaderencoder') + ->asAliasOf('mime.base64headerencoder'); + + Swift_Preferences::getInstance()->setCharset('iso-2022-jp'); + }); + + /* rest of code goes here */ + +That's all! diff --git a/vendor/swiftmailer/swiftmailer/doc/messages.rst b/vendor/swiftmailer/swiftmailer/doc/messages.rst new file mode 100644 index 000000000..7a1925364 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/messages.rst @@ -0,0 +1,1057 @@ +Creating Messages +================= + +Creating messages in Swift Mailer is done by making use of the various MIME +entities provided with the library. Complex messages can be quickly created +with very little effort. + +Quick Reference for Creating a Message +--------------------------------------- + +You can think of creating a Message as being similar to the steps you perform +when you click the Compose button in your mail client. You give it a subject, +specify some recipients, add any attachments and write your message. + +To create a Message: + +* Call the ``newInstance()`` method of ``Swift_Message``. + +* Set your sender address (``From:``) with ``setFrom()`` or ``setSender()``. + +* Set a subject line with ``setSubject()``. + +* Set recipients with ``setTo()``, ``setCc()`` and/or ``setBcc()``. + +* Set a body with ``setBody()``. + +* Add attachments with ``attach()``. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the message + $message = Swift_Message::newInstance() + + // Give the message a subject + ->setSubject('Your subject') + + // Set the From address with an associative array + ->setFrom(array('john@doe.com' => 'John Doe')) + + // Set the To addresses with an associative array + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + + // Give it a body + ->setBody('Here is the message itself') + + // And optionally an alternative body + ->addPart('Here is the message itself', 'text/html') + + // Optionally add any attachments + ->attach(Swift_Attachment::fromPath('my-document.pdf')) + ; + +Message Basics +-------------- + +A message is a container for anything you want to send to somebody else. There +are several basic aspects of a message that you should know. + +An e-mail message is made up of several relatively simple entities that are +combined in different ways to achieve different results. All of these entities +have the same fundamental outline but serve a different purpose. The Message +itself can be defined as a MIME entity, an Attachment is a MIME entity, all +MIME parts are MIME entities -- and so on! + +The basic units of each MIME entity -- be it the Message itself, or an +Attachment -- are its Headers and its body: + +.. code-block:: text + + Header-Name: A header value + Other-Header: Another value + + The body content itself + +The Headers of a MIME entity, and its body must conform to some strict +standards defined by various RFC documents. Swift Mailer ensures that these +specifications are followed by using various types of object, including +Encoders and different Header types to generate the entity. + +The Structure of a Message +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Of all of the MIME entities, a message -- ``Swift_Message`` +is the largest and most complex. It has many properties that can be updated +and it can contain other MIME entities -- attachments for example -- +nested inside it. + +A Message has a lot of different Headers which are there to present +information about the message to the recipients' mail client. Most of these +headers will be familiar to the majority of users, but we'll list the basic +ones. Although it's possible to work directly with the Headers of a Message +(or other MIME entity), the standard Headers have accessor methods provided to +abstract away the complex details for you. For example, although the Date on a +message is written with a strict format, you only need to pass a UNIX +timestamp to ``setDate()``. + ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| Header | Description | Accessors | ++===============================+====================================================================================================================================+=============================================+ +| ``Message-ID`` | Identifies this message with a unique ID, usually containing the domain name and time generated | ``getId()`` / ``setId()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Return-Path`` | Specifies where bounces should go (Swift Mailer reads this for other uses) | ``getReturnPath()`` / ``setReturnPath()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``From`` | Specifies the address of the person who the message is from. This can be multiple addresses if multiple people wrote the message. | ``getFrom()`` / ``setFrom()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Sender`` | Specifies the address of the person who physically sent the message (higher precedence than ``From:``) | ``getSender()`` / ``setSender()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``To`` | Specifies the addresses of the intended recipients | ``getTo()`` / ``setTo()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Cc`` | Specifies the addresses of recipients who will be copied in on the message | ``getCc()`` / ``setCc()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Bcc`` | Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies. | ``getBcc()`` / ``setBcc()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Reply-To`` | Specifies the address where replies are sent to | ``getReplyTo()`` / ``setReplyTo()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Subject`` | Specifies the subject line that is displayed in the recipients' mail client | ``getSubject()`` / ``setSubject()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Date`` | Specifies the date at which the message was sent | ``getDate()`` / ``setDate()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Content-Type`` | Specifies the format of the message (usually text/plain or text/html) | ``getContentType()`` / ``setContentType()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Content-Transfer-Encoding`` | Specifies the encoding scheme in the message | ``getEncoder()`` / ``setEncoder()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ + +Working with a Message Object +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Although there are a lot of available methods on a message object, you only +need to make use of a small subset of them. Usually you'll use +``setSubject()``, ``setTo()`` and +``setFrom()`` before setting the body of your message with +``setBody()``. + +Calling methods is simple. You just call them like functions, but using the +object operator "``->``" to do so. If you've created +a message object and called it ``$message`` then you'd set a +subject on it like so: + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + $message = Swift_Message::newInstance(); + $message->setSubject('My subject'); + +All MIME entities (including a message) have a ``toString()`` +method that you can call if you want to take a look at what is going to be +sent. For example, if you ``echo +$message->toString();`` you would see something like this: + +.. code-block:: bash + + Message-ID: <1230173678.4952f5eeb1432@swift.generated> + Date: Thu, 25 Dec 2008 13:54:38 +1100 + Subject: Example subject + From: Chris Corbyn + To: Receiver Name + MIME-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + + Here is the message + +We'll take a closer look at the methods you use to create your message in the +following sections. + +Adding Content to Your Message +------------------------------ + +Rich content can be added to messages in Swift Mailer with relative ease by +calling methods such as ``setSubject()``, ``setBody()``, ``addPart()`` and +``attach()``. + +Setting the Subject Line +~~~~~~~~~~~~~~~~~~~~~~~~ + +The subject line, displayed in the recipients' mail client can be set with the +``setSubject()`` method, or as a parameter to ``Swift_Message::newInstance()``. + +To set the subject of your Message: + +* Call the ``setSubject()`` method of the Message, or specify it at the time + you create the message. + + .. code-block:: php + + // Pass it as a parameter when you create the message + $message = Swift_Message::newInstance('My amazing subject'); + + // Or set it after like this + $message->setSubject('My amazing subject'); + +Setting the Body Content +~~~~~~~~~~~~~~~~~~~~~~~~ + +The body of the message -- seen when the user opens the message -- +is specified by calling the ``setBody()`` method. If an alternative body is to +be included ``addPart()`` can be used. + +The body of a message is the main part that is read by the user. Often people +want to send a message in HTML format (``text/html``), other +times people want to send in plain text (``text/plain``), or +sometimes people want to send both versions and allow the recipient to choose +how they view the message. + +As a rule of thumb, if you're going to send a HTML email, always include a +plain-text equivalent of the same content so that users who prefer to read +plain text can do so. + +To set the body of your Message: + +* Call the ``setBody()`` method of the Message, or specify it at the time you + create the message. + +* Add any alternative bodies with ``addPart()``. + +If the recipient's mail client offers preferences for displaying text vs. HTML +then the mail client will present that part to the user where available. In +other cases the mail client will display the "best" part it can - usually HTML +if you've included HTML. + +.. code-block:: php + + // Pass it as a parameter when you create the message + $message = Swift_Message::newInstance('Subject here', 'My amazing body'); + + // Or set it after like this + $message->setBody('My amazing body', 'text/html'); + + // Add alternative parts with addPart() + $message->addPart('My amazing body in plain text', 'text/plain'); + +Attaching Files +--------------- + +Attachments are downloadable parts of a message and can be added by calling +the ``attach()`` method on the message. You can add attachments that exist on +disk, or you can create attachments on-the-fly. + +Attachments are actually an interesting area of Swift Mailer and something +that could put a lot of power at your fingertips if you grasp the concept +behind the way a message is held together. + +Although we refer to files sent over e-mails as "attachments" -- because +they're attached to the message -- lots of other parts of the message are +actually "attached" even if we don't refer to these parts as attachments. + +File attachments are created by the ``Swift_Attachment`` class +and then attached to the message via the ``attach()`` method on +it. For all of the "every day" MIME types such as all image formats, word +documents, PDFs and spreadsheets you don't need to explicitly set the +content-type of the attachment, though it would do no harm to do so. For less +common formats you should set the content-type -- which we'll cover in a +moment. + +Attaching Existing Files +~~~~~~~~~~~~~~~~~~~~~~~~ + +Files that already exist, either on disk or at a URL can be attached to a +message with just one line of code, using ``Swift_Attachment::fromPath()``. + +You can attach files that exist locally, or if your PHP installation has +``allow_url_fopen`` turned on you can attach files from other +websites. + +To attach an existing file: + +* Create an attachment with ``Swift_Attachment::fromPath()``. + +* Add the attachment to the message with ``attach()``. + +The attachment will be presented to the recipient as a downloadable file with +the same filename as the one you attached. + +.. code-block:: php + + // Create the attachment + // * Note that you can technically leave the content-type parameter out + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg', 'image/jpeg'); + + // Attach it to the message + $message->attach($attachment); + + + // The two statements above could be written in one line instead + $message->attach(Swift_Attachment::fromPath('/path/to/image.jpg')); + + + // You can attach files from a URL if allow_url_fopen is on in php.ini + $message->attach(Swift_Attachment::fromPath('http://site.tld/logo.png')); + +Setting the Filename +~~~~~~~~~~~~~~~~~~~~ + +Usually you don't need to explicitly set the filename of an attachment because +the name of the attached file will be used by default, but if you want to set +the filename you use the ``setFilename()`` method of the Attachment. + +To change the filename of an attachment: + +* Call its ``setFilename()`` method. + +The attachment will be attached in the normal way, but meta-data sent inside +the email will rename the file to something else. + +.. code-block:: php + + // Create the attachment and call its setFilename() method + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg') + ->setFilename('cool.jpg'); + + + // Because there's a fluid interface, you can do this in one statement + $message->attach( + Swift_Attachment::fromPath('/path/to/image.jpg')->setFilename('cool.jpg') + ); + +Attaching Dynamic Content +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Files that are generated at runtime, such as PDF documents or images created +via GD can be attached directly to a message without writing them out to disk. +Use the standard ``Swift_Attachment::newInstance()`` method. + +To attach dynamically created content: + +* Create your content as you normally would. + +* Create an attachment with ``Swift_Attachment::newInstance()``, specifying + the source data of your content along with a name and the content-type. + +* Add the attachment to the message with ``attach()``. + +The attachment will be presented to the recipient as a downloadable file +with the filename and content-type you specify. + +.. note:: + + If you would usually write the file to disk anyway you should just attach + it with ``Swift_Attachment::fromPath()`` since this will use less memory: + + .. code-block:: php + + // Create your file contents in the normal way, but don't write them to disk + $data = create_my_pdf_data(); + + // Create the attachment with your data + $attachment = Swift_Attachment::newInstance($data, 'my-file.pdf', 'application/pdf'); + + // Attach it to the message + $message->attach($attachment); + + + // You can alternatively use method chaining to build the attachment + $attachment = Swift_Attachment::newInstance() + ->setFilename('my-file.pdf') + ->setContentType('application/pdf') + ->setBody($data) + ; + +Changing the Disposition +~~~~~~~~~~~~~~~~~~~~~~~~ + +Attachments just appear as files that can be saved to the Desktop if desired. +You can make attachment appear inline where possible by using the +``setDisposition()`` method of an attachment. + +To make an attachment appear inline: + +* Call its ``setDisposition()`` method. + +The attachment will be displayed within the email viewing window if the mail +client knows how to display it. + +.. note:: + + If you try to create an inline attachment for a non-displayable file type + such as a ZIP file, the mail client should just present the attachment as + normal: + + .. code-block:: php + + // Create the attachment and call its setDisposition() method + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg') + ->setDisposition('inline'); + + + // Because there's a fluid interface, you can do this in one statement + $message->attach( + Swift_Attachment::fromPath('/path/to/image.jpg')->setDisposition('inline') + ); + +Embedding Inline Media Files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Often people want to include an image or other content inline with a HTML +message. It's easy to do this with HTML linking to remote resources, but this +approach is usually blocked by mail clients. Swift Mailer allows you to embed +your media directly into the message. + +Mail clients usually block downloads from remote resources because this +technique was often abused as a mean of tracking who opened an email. If +you're sending a HTML email and you want to include an image in the message +another approach you can take is to embed the image directly. + +Swift Mailer makes embedding files into messages extremely streamlined. You +embed a file by calling the ``embed()`` method of the message, +which returns a value you can use in a ``src`` or +``href`` attribute in your HTML. + +Just like with attachments, it's possible to embed dynamically generated +content without having an existing file available. + +The embedded files are sent in the email as a special type of attachment that +has a unique ID used to reference them within your HTML attributes. On mail +clients that do not support embedded files they may appear as attachments. + +Although this is commonly done for images, in theory it will work for any +displayable (or playable) media type. Support for other media types (such as +video) is dependent on the mail client however. + +Embedding Existing Files +........................ + +Files that already exist, either on disk or at a URL can be embedded in a +message with just one line of code, using ``Swift_EmbeddedFile::fromPath()``. + +You can embed files that exist locally, or if your PHP installation has +``allow_url_fopen`` turned on you can embed files from other websites. + +To embed an existing file: + +* Create a message object with ``Swift_Message::newInstance()``. + +* Set the body as HTML, and embed a file at the correct point in the message with ``embed()``. + +The file will be displayed with the message inline with the HTML wherever its ID +is used as a ``src`` attribute. + +.. note:: + + ``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one + another. ``Swift_Image`` exists for semantic purposes. + +.. note:: + + You can embed files in two stages if you prefer. Just capture the return + value of ``embed()`` in a variable and use that as the ``src`` attribute. + + .. code-block:: php + + // Create the message + $message = Swift_Message::newInstance('My subject'); + + // Set the body + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + + // You can embed files from a URL if allow_url_fopen is on in php.ini + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' + ); + + + // If placing the embed() code inline becomes cumbersome + // it's easy to do this in two steps + $cid = $message->embed(Swift_Image::fromPath('image.png')); + + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + +Embedding Dynamic Content +......................... + +Images that are generated at runtime, such as images created via GD can be +embedded directly to a message without writing them out to disk. Use the +standard ``Swift_Image::newInstance()`` method. + +To embed dynamically created content: + +* Create a message object with ``Swift_Message::newInstance()``. + +* Set the body as HTML, and embed a file at the correct point in the message + with ``embed()``. You will need to specify a filename and a content-type. + +The file will be displayed with the message inline with the HTML wherever its ID +is used as a ``src`` attribute. + +.. note:: + + ``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one + another. ``Swift_Image`` exists for semantic purposes. + +.. note:: + + You can embed files in two stages if you prefer. Just capture the return + value of ``embed()`` in a variable and use that as the ``src`` attribute. + + .. code-block:: php + + // Create your file contents in the normal way, but don't write them to disk + $img_data = create_my_image_data(); + + // Create the message + $message = Swift_Message::newInstance('My subject'); + + // Set the body + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + + + // If placing the embed() code inline becomes cumbersome + // it's easy to do this in two steps + $cid = $message->embed(Swift_Image::newInstance($img_data, 'image.jpg', 'image/jpeg')); + + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + +Adding Recipients to Your Message +--------------------------------- + +Recipients are specified within the message itself via ``setTo()``, ``setCc()`` +and ``setBcc()``. Swift Mailer reads these recipients from the message when it +gets sent so that it knows where to send the message to. + +Message recipients are one of three types: + +* ``To:`` recipients -- the primary recipients (required) + +* ``Cc:`` recipients -- receive a copy of the message (optional) + +* ``Bcc:`` recipients -- hidden from other recipients (optional) + +Each type can contain one, or several addresses. It's possible to list only +the addresses of the recipients, or you can personalize the address by +providing the real name of the recipient. + +Make sure to add only valid email addresses as recipients. If you try to add an +invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift +Mailer will throw a ``Swift_RfcComplianceException``. + +If you add recipients automatically based on a data source that may contain +invalid email addresses, you can prevent possible exceptions by validating the +addresses using ``Swift_Validate::email($email)`` and only adding addresses +that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and +``setBcc()`` calls in a try-catch block and handle the +``Swift_RfcComplianceException`` in the catch block. + +.. sidebar:: Syntax for Addresses + + If you only wish to refer to a single email address (for example your + ``From:`` address) then you can just use a string. + + .. code-block:: php + + $message->setFrom('some@address.tld'); + + If you want to include a name then you must use an associative array. + + .. code-block:: php + + $message->setFrom(array('some@address.tld' => 'The Name')); + + If you want to include multiple addresses then you must use an array. + + .. code-block:: php + + $message->setTo(array('some@address.tld', 'other@address.tld')); + + You can mix personalized (addresses with a name) and non-personalized + addresses in the same list by mixing the use of associative and + non-associative array syntax. + + .. code-block:: php + + $message->setTo(array( + 'recipient-with-name@example.org' => 'Recipient Name One', + 'no-name@example.org', // Note that this is not a key-value pair + 'named-recipient@example.org' => 'Recipient Name Two' + )); + +Setting ``To:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``To:`` recipients are required in a message and are set with the +``setTo()`` or ``addTo()`` methods of the message. + +To set ``To:`` recipients, create the message object using either +``new Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, +then call the ``setTo()`` method with a complete array of addresses, or use the +``addTo()`` method to iteratively add recipients. + +The ``setTo()`` method accepts input in various formats as described earlier in +this chapter. The ``addTo()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +``To:`` recipients are visible in the message headers and will be +seen by the other recipients. + +.. note:: + + Multiple calls to ``setTo()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add + recipients, use the ``addTo()`` method. + + .. code-block:: php + + // Using setTo() to set all recipients in one go + $message->setTo(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addTo() to add recipients iteratively + $message->addTo('person1@example.org'); + $message->addTo('person2@example.org', 'Person 2 Name'); + +Setting ``Cc:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Cc:`` recipients are set with the ``setCc()`` or ``addCc()`` methods of the +message. + +To set ``Cc:`` recipients, create the message object using either +``new Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, then call +the ``setCc()`` method with a complete array of addresses, or use the +``addCc()`` method to iteratively add recipients. + +The ``setCc()`` method accepts input in various formats as described earlier in +this chapter. The ``addCc()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +``Cc:`` recipients are visible in the message headers and will be +seen by the other recipients. + +.. note:: + + Multiple calls to ``setCc()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add Cc: + recipients, use the ``addCc()`` method. + + .. code-block:: php + + // Using setCc() to set all recipients in one go + $message->setCc(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addCc() to add recipients iteratively + $message->addCc('person1@example.org'); + $message->addCc('person2@example.org', 'Person 2 Name'); + +Setting ``Bcc:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Bcc:`` recipients receive a copy of the message without anybody else knowing +it, and are set with the ``setBcc()`` or ``addBcc()`` methods of the message. + +To set ``Bcc:`` recipients, create the message object using either ``new +Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, then call the +``setBcc()`` method with a complete array of addresses, or use +the ``addBcc()`` method to iteratively add recipients. + +The ``setBcc()`` method accepts input in various formats as described earlier in +this chapter. The ``addBcc()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +Only the individual ``Bcc:`` recipient will see their address in the message +headers. Other recipients (including other ``Bcc:`` recipients) will not see the +address. + +.. note:: + + Multiple calls to ``setBcc()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add Bcc: + recipients, use the ``addBcc()`` method. + + .. code-block:: php + + // Using setBcc() to set all recipients in one go + $message->setBcc(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addBcc() to add recipients iteratively + $message->addBcc('person1@example.org'); + $message->addBcc('person2@example.org', 'Person 2 Name'); + +Specifying Sender Details +------------------------- + +An email must include information about who sent it. Usually this is managed +by the ``From:`` address, however there are other options. + +The sender information is contained in three possible places: + +* ``From:`` -- the address(es) of who wrote the message (required) + +* ``Sender:`` -- the address of the single person who sent the message + (optional) + +* ``Return-Path:`` -- the address where bounces should go to (optional) + +You must always include a ``From:`` address by using ``setFrom()`` on the +message. Swift Mailer will use this as the default ``Return-Path:`` unless +otherwise specified. + +The ``Sender:`` address exists because the person who actually sent the email +may not be the person who wrote the email. It has a higher precedence than the +``From:`` address and will be used as the ``Return-Path:`` unless otherwise +specified. + +Setting the ``From:`` Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A ``From:`` address is required and is set with the ``setFrom()`` method of the +message. ``From:`` addresses specify who actually wrote the email, and usually who sent it. + +What most people probably don't realise is that you can have more than one +``From:`` address if more than one person wrote the email -- for example if an +email was put together by a committee. + +To set the ``From:`` address(es): + +* Call the ``setFrom()`` method on the Message. + +The ``From:`` address(es) are visible in the message headers and +will be seen by the recipients. + +.. note:: + + If you set multiple ``From:`` addresses then you absolutely must set a + ``Sender:`` address to indicate who physically sent the message. + + .. code-block:: php + + // Set a single From: address + $message->setFrom('your@address.tld'); + + // Set a From: address including a name + $message->setFrom(array('your@address.tld' => 'Your Name')); + + // Set multiple From: addresses if multiple people wrote the email + $message->setFrom(array( + 'person1@example.org' => 'Sender One', + 'person2@example.org' => 'Sender Two' + )); + +Setting the ``Sender:`` Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A ``Sender:`` address specifies who sent the message and is set with the +``setSender()`` method of the message. + +To set the ``Sender:`` address: + +* Call the ``setSender()`` method on the Message. + +The ``Sender:`` address is visible in the message headers and will be seen by +the recipients. + +This address will be used as the ``Return-Path:`` unless otherwise specified. + +.. note:: + + If you set multiple ``From:`` addresses then you absolutely must set a + ``Sender:`` address to indicate who physically sent the message. + +You must not set more than one sender address on a message because it's not +possible for more than one person to send a single message. + +.. code-block:: php + + $message->setSender('your@address.tld'); + +Setting the ``Return-Path:`` (Bounce) Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``Return-Path:`` address specifies where bounce notifications should +be sent and is set with the ``setReturnPath()`` method of the message. + +You can only have one ``Return-Path:`` and it must not include +a personal name. + +To set the ``Return-Path:`` address: + +* Call the ``setReturnPath()`` method on the Message. + +Bounce notifications will be sent to this address. + +.. code-block:: php + + $message->setReturnPath('bounces@address.tld'); + + +Signed/Encrypted Message +------------------------ + +To increase the integrity/security of a message it is possible to sign and/or +encrypt an message using one or multiple signers. + +S/MIME +~~~~~~ + +S/MIME can sign and/or encrypt a message using the OpenSSL extension. + +When signing a message, the signer creates a signature of the entire content of the message (including attachments). + +The certificate and private key must be PEM encoded, and can be either created using for example OpenSSL or +obtained at an official Certificate Authority (CA). + +**The recipient must have the CA certificate in the list of trusted issuers in order to verify the signature.** + +**Make sure the certificate supports emailProtection.** + +When using OpenSSL this can done by the including the *-addtrust emailProtection* parameter when creating the certificate. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem'); + $message->attachSigner($smimeSigner); + +When the private key is secured using a passphrase use the following instead. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/certificate.pem', array('/path/to/private-key.pem', 'passphrase')); + $message->attachSigner($smimeSigner); + +By default the signature is added as attachment, +making the message still readable for mailing agents not supporting signed messages. + +Storing the message as binary is also possible but not recommended. + +.. code-block:: php + + $smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem', PKCS7_BINARY); + +When encrypting the message (also known as enveloping), the entire message (including attachments) +is encrypted using a certificate, and the recipient can then decrypt the message using corresponding private key. + +Encrypting ensures nobody can read the contents of the message without the private key. + +Normally the recipient provides a certificate for encrypting and keeping the decryption key private. + +Using both signing and encrypting is also possible. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/sign-certificate.pem', '/path/to/private-key.pem'); + $smimeSigner->setEncryptCertificate('/path/to/encrypt-certificate.pem'); + $message->attachSigner($smimeSigner); + +The used encryption cipher can be set as the second parameter of setEncryptCertificate() + +See http://php.net/manual/openssl.ciphers for a list of supported ciphers. + +By default the message is first signed and then encrypted, this can be changed by adding. + +.. code-block:: php + + $smimeSigner->setSignThenEncrypt(false); + +**Changing this is not recommended as most mail agents don't support this none-standard way.** + +Only when having trouble with sign then encrypt method, this should be changed. + +Requesting a Read Receipt +------------------------- + +It is possible to request a read-receipt to be sent to an address when the +email is opened. To request a read receipt set the address with +``setReadReceiptTo()``. + +To request a read receipt: + +* Set the address you want the receipt to be sent to with the + ``setReadReceiptTo()`` method on the Message. + +When the email is opened, if the mail client supports it a notification will be sent to this address. + +.. note:: + + Read receipts won't work for the majority of recipients since many mail + clients auto-disable them. Those clients that will send a read receipt + will make the user aware that one has been requested. + + .. code-block:: php + + $message->setReadReceiptTo('your@address.tld'); + +Setting the Character Set +------------------------- + +The character set of the message (and it's MIME parts) is set with the +``setCharset()`` method. You can also change the global default of UTF-8 by +working with the ``Swift_Preferences`` class. + +Swift Mailer will default to the UTF-8 character set unless otherwise +overridden. UTF-8 will work in most instances since it includes all of the +standard US keyboard characters in addition to most international characters. + +It is absolutely vital however that you know what character set your message +(or it's MIME parts) are written in otherwise your message may be received +completely garbled. + +There are two places in Swift Mailer where you can change the character set: + +* In the ``Swift_Preferences`` class + +* On each individual message and/or MIME part + +To set the character set of your Message: + +* Change the global UTF-8 setting by calling + ``Swift_Preferences::setCharset()``; or + +* Call the ``setCharset()`` method on the message or the MIME part. + + .. code-block:: php + + // Approach 1: Change the global setting (suggested) + Swift_Preferences::getInstance()->setCharset('iso-8859-2'); + + // Approach 2: Call the setCharset() method of the message + $message = Swift_Message::newInstance() + ->setCharset('iso-8859-2'); + + // Approach 3: Specify the charset when setting the body + $message->setBody('My body', 'text/html', 'iso-8859-2'); + + // Approach 4: Specify the charset for each part added + $message->addPart('My part', 'text/plain', 'iso-8859-2'); + +Setting the Line Length +----------------------- + +The length of lines in a message can be changed by using the ``setMaxLineLength()`` method on the message. It should be kept to less than +1000 characters. + +Swift Mailer defaults to using 78 characters per line in a message. This is +done for historical reasons and so that the message can be easily viewed in +plain-text terminals. + +To change the maximum length of lines in your Message: + +* Call the ``setMaxLineLength()`` method on the Message. + +Lines that are longer than the line length specified will be wrapped between +words. + +.. note:: + + You should never set a maximum length longer than 1000 characters + according to RFC 2822. Doing so could have unspecified side-effects such + as truncating parts of your message when it is transported between SMTP + servers. + + .. code-block:: php + + $message->setMaxLineLength(1000); + +Setting the Message Priority +---------------------------- + +You can change the priority of the message with ``setPriority()``. Setting the +priority will not change the way your email is sent -- it is purely an +indicative setting for the recipient. + +The priority of a message is an indication to the recipient what significance +it has. Swift Mailer allows you to set the priority by calling the ``setPriority`` method. This method takes an integer value between 1 and 5: + +* Highest +* High +* Normal +* Low +* Lowest + +To set the message priority: + +* Set the priority as an integer between 1 and 5 with the ``setPriority()`` + method on the Message. + +.. code-block:: php + + // Indicate "High" priority + $message->setPriority(2); diff --git a/vendor/swiftmailer/swiftmailer/doc/overview.rst b/vendor/swiftmailer/swiftmailer/doc/overview.rst new file mode 100644 index 000000000..c9126173c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/overview.rst @@ -0,0 +1,161 @@ +Library Overview +================ + +Most features (and more) of your every day mail client software are provided +by Swift Mailer, using object-oriented PHP code as the interface. + +In this chapter we will take a short tour of the various components, which put +together form the Swift Mailer library as a whole. You will learn key +terminology used throughout the rest of this book and you will gain a little +understanding of the classes you will work with as you integrate Swift Mailer +into your application. + +This chapter is intended to prepare you for the information contained in the +subsequent chapters of this book. You may choose to skip this chapter if you +are fairly technically minded, though it is likely to save you some time in +the long run if you at least read between the lines here. + +System Requirements +------------------- + +The basic requirements to operate Swift Mailer are extremely minimal and +easily achieved. Historically, Swift Mailer has supported both PHP 4 and PHP 5 +by following a parallel development workflow. Now in it's fourth major +version, and Swift Mailer operates on servers running PHP 5.2 or higher. + +The library aims to work with as many PHP 5 projects as possible: + +* PHP 5.2 or higher, with the SPL extension (standard) + +* Limited network access to connect to remote SMTP servers + +* 8 MB or more memory limit (Swift Mailer uses around 2 MB) + +Component Breakdown +------------------- + +Swift Mailer is made up of many classes. Each of these classes can be grouped +into a general "component" group which describes the task it is designed to +perform. + +We'll take a brief look at the components which form Swift Mailer in this +section of the book. + +The Mailer +~~~~~~~~~~ + +The mailer class, ``Swift_Mailer`` is the central class in the library where +all of the other components meet one another. ``Swift_Mailer`` acts as a sort +of message dispatcher, communicating with the underlying Transport to deliver +your Message to all intended recipients. + +If you were to dig around in the source code for Swift Mailer you'd notice +that ``Swift_Mailer`` itself is pretty bare. It delegates to other objects for +most tasks and in theory, if you knew the internals of Swift Mailer well you +could by-pass this class entirely. We wouldn't advise doing such a thing +however -- there are reasons this class exists: + +* for consistency, regardless of the Transport used + +* to provide abstraction from the internals in the event internal API changes + are made + +* to provide convenience wrappers around aspects of the internal API + +An instance of ``Swift_Mailer`` is created by the developer before sending any +Messages. + +Transports +~~~~~~~~~~ + +Transports are the classes in Swift Mailer that are responsible for +communicating with a service in order to deliver a Message. There are several +types of Transport in Swift Mailer, all of which implement the Swift_Transport +interface and offer underlying start(), stop() and send() methods. + +Typically you will not need to know how a Transport works under-the-surface, +you will only need to know how to create an instance of one, and which one to +use for your environment. + ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| Class | Features | Pros/cons | ++=================================+=============================================================================================+===============================================================================================================================================+ +| ``Swift_SmtpTransport`` | Sends messages over SMTP; Supports Authentication; Supports Encryption | Very portable; Pleasingly predictable results; Provides good feedback | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_SendmailTransport`` | Communicates with a locally installed ``sendmail`` executable (Linux/UNIX) | Quick time-to-run; Provides less-accurate feedback than SMTP; Requires ``sendmail`` installation | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_MailTransport`` | Uses PHP's built-in ``mail()`` function | Very portable; Potentially unpredictable results; Provides extremely weak feedback | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_LoadBalancedTransport`` | Cycles through a collection of the other Transports to manage load-reduction | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down); Keeps the load on remote services down by spreading the work | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_FailoverTransport`` | Works in conjunction with a collection of the other Transports to provide high-availability | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down) | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + +MIME Entities +~~~~~~~~~~~~~ + +Everything that forms part of a Message is called a MIME Entity. All MIME +entities in Swift Mailer share a common set of features. There are various +types of MIME entity that serve different purposes such as Attachments and +MIME parts. + +An e-mail message is made up of several relatively simple entities that are +combined in different ways to achieve different results. All of these entities +have the same fundamental outline but serve a different purpose. The Message +itself can be defined as a MIME entity, an Attachment is a MIME entity, all +MIME parts are MIME entities -- and so on! + +The basic units of each MIME entity -- be it the Message itself, or an +Attachment -- are its Headers and its body: + +.. code-block:: text + + Other-Header: Another value + + The body content itself + +The Headers of a MIME entity, and its body must conform to some strict +standards defined by various RFC documents. Swift Mailer ensures that these +specifications are followed by using various types of object, including +Encoders and different Header types to generate the entity. + +Each MIME component implements the base ``Swift_Mime_MimeEntity`` interface, +which offers methods for retrieving Headers, adding new Headers, changing the +Encoder, updating the body and so on! + +All MIME entities have one Header in common -- the Content-Type Header, +updated with the entity's ``setContentType()`` method. + +Encoders +~~~~~~~~ + +Encoders are used to transform the content of Messages generated in Swift +Mailer into a format that is safe to send across the internet and that +conforms to RFC specifications. + +Generally speaking you will not need to interact with the Encoders in Swift +Mailer -- the correct settings will be handled by the library itself. +However they are probably worth a brief mention in the event that you do want +to play with them. + +Both the Headers and the body of all MIME entities (including the Message +itself) use Encoders to ensure the data they contain can be sent over the +internet without becoming corrupted or misinterpreted. + +There are two types of Encoder: Base64 and Quoted-Printable. + +Plugins +~~~~~~~ + +Plugins exist to extend, or modify the behaviour of Swift Mailer. They respond +to Events that are fired within the Transports during sending. + +There are a number of Plugins provided as part of the base Swift Mailer +package and they all follow a common interface to respond to Events fired +within the library. Interfaces are provided to "listen" to each type of Event +fired and to act as desired when a listened-to Event occurs. + +Although several plugins are provided with Swift Mailer out-of-the-box, the +Events system has been specifically designed to make it easy for experienced +object-oriented developers to write their own plugins in order to achieve +goals that may not be possible with the base library. diff --git a/vendor/swiftmailer/swiftmailer/doc/plugins.rst b/vendor/swiftmailer/swiftmailer/doc/plugins.rst new file mode 100644 index 000000000..16ae3356f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/plugins.rst @@ -0,0 +1,385 @@ +Plugins +======= + +Plugins are provided with Swift Mailer and can be used to extend the behavior +of the library in situations where using simple class inheritance would be more complex. + +AntiFlood Plugin +---------------- + +Many SMTP servers have limits on the number of messages that may be sent +during any single SMTP connection. The AntiFlood plugin provides a way to stay +within this limit while still managing a large number of emails. + +A typical limit for a single connection is 100 emails. If the server you +connect to imposes such a limit, it expects you to disconnect after that +number of emails has been sent. You could manage this manually within a loop, +but the AntiFlood plugin provides the necessary wrapper code so that you don't +need to worry about this logic. + +Regardless of limits imposed by the server, it's usually a good idea to be +conservative with the resources of the SMTP server. Sending will become +sluggish if the server is being over-used so using the AntiFlood plugin will +not be a bad idea even if no limits exist. + +The AntiFlood plugin's logic is basically to disconnect and the immediately +re-connect with the SMTP server every X number of emails sent, where X is a +number you specify to the plugin. + +You can also specify a time period in seconds that Swift Mailer should pause +for between the disconnect/re-connect process. It's a good idea to pause for a +short time (say 30 seconds every 100 emails) simply to give the SMTP server a +chance to process its queue and recover some resources. + +Using the AntiFlood Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The AntiFlood Plugin -- like all plugins -- is added with the Mailer class's +``registerPlugin()`` method. It takes two constructor parameters: the number of +emails to pause after, and optionally the number of seconds to pause for. + +To use the AntiFlood plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the ``Swift_Plugins_AntiFloodPlugin`` class, passing + in one or two constructor parameters. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +When Swift Mailer sends messages it will count the number of messages that +have been sent since the last re-connect. Once the number hits your specified +threshold it will disconnect and re-connect, optionally pausing for a +specified amount of time. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // Use AntiFlood to re-connect after 100 emails + $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100)); + + // And specify a time in seconds to pause for (30 secs) + $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30)); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + +Throttler Plugin +---------------- + +If your SMTP server has restrictions in place to limit the rate at which you +send emails, then your code will need to be aware of this rate-limiting. The +Throttler plugin makes Swift Mailer run at a rate-limited speed. + +Many shared hosts don't open their SMTP servers as a free-for-all. Usually +they have policies in place (probably to discourage spammers) that only allow +you to send a fixed number of emails per-hour/day. + +The Throttler plugin supports two modes of rate-limiting and with each, you +will need to do that math to figure out the values you want. The plugin can +limit based on the number of emails per minute, or the number of +bytes-transferred per-minute. + +Using the Throttler Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Throttler Plugin -- like all plugins -- is added with the Mailer class' +``registerPlugin()`` method. It has two required constructor parameters that +tell it how to do its rate-limiting. + +To use the Throttler plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the ``Swift_Plugins_ThrottlerPlugin`` class, passing + the number of emails, or bytes you wish to limit by, along with the mode + you're using. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +When Swift Mailer sends messages it will keep track of the rate at which sending +messages is occurring. If it realises that sending is happening too fast, it +will cause your program to ``sleep()`` for enough time to average out the rate. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // Rate limit to 100 emails per-minute + $mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin( + 100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE + )); + + // Rate limit to 10MB per-minute + $mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin( + 1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE + )); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + +Logger Plugin +------------- + +The Logger plugins helps with debugging during the process of sending. It can +help to identify why an SMTP server is rejecting addresses, or any other +hard-to-find problems that may arise. + +The Logger plugin comes in two parts. There's the plugin itself, along with +one of a number of possible Loggers that you may choose to use. For example, +the logger may output messages directly in realtime, or it may capture +messages in an array. + +One other notable feature is the way in which the Logger plugin changes +Exception messages. If Exceptions are being thrown but the error message does +not provide conclusive information as to the source of the problem (such as an +ambiguous SMTP error) the Logger plugin includes the entire SMTP transcript in +the error message so that debugging becomes a simpler task. + +There are a few available Loggers included with Swift Mailer, but writing your +own implementation is incredibly simple and is achieved by creating a short +class that implements the ``Swift_Plugins_Logger`` interface. + +* ``Swift_Plugins_Loggers_ArrayLogger``: Keeps a collection of log messages + inside an array. The array content can be cleared or dumped out to the + screen. + +* ``Swift_Plugins_Loggers_EchoLogger``: Prints output to the screen in + realtime. Handy for very rudimentary debug output. + +Using the Logger Plugin +~~~~~~~~~~~~~~~~~~~~~~~ + +The Logger Plugin -- like all plugins -- is added with the Mailer class' +``registerPlugin()`` method. It accepts an instance of ``Swift_Plugins_Logger`` +in its constructor. + +To use the Logger plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the a Logger implementation of + ``Swift_Plugins_Logger``. + +* Create an instance of the ``Swift_Plugins_LoggerPlugin`` class, passing the + created Logger instance to its constructor. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +* Dump the contents of the log with the logger's ``dump()`` method. + +When Swift Mailer sends messages it will keep a log of all the interactions +with the underlying Transport being used. Depending upon the Logger that has +been used the behaviour will differ, but all implementations offer a way to +get the contents of the log. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // To use the ArrayLogger + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger)); + + // Or to use the Echo Logger + $logger = new Swift_Plugins_Loggers_EchoLogger(); + $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger)); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + + // Dump the log contents + // NOTE: The EchoLogger dumps in realtime so dump() does nothing for it + echo $logger->dump(); + +Decorator Plugin +---------------- + +Often there's a need to send the same message to multiple recipients, but with +tiny variations such as the recipient's name being used inside the message +body. The Decorator plugin aims to provide a solution for allowing these small +differences. + +The decorator plugin works by intercepting the sending process of Swift +Mailer, reading the email address in the To: field and then looking up a set +of replacements for a template. + +While the use of this plugin is simple, it is probably the most commonly +misunderstood plugin due to the way in which it works. The typical mistake +users make is to try registering the plugin multiple times (once for each +recipient) -- inside a loop for example. This is incorrect. + +The Decorator plugin should be registered just once, but containing the list +of all recipients prior to sending. It will use this list of recipients to +find the required replacements during sending. + +Using the Decorator Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use the Decorator plugin, simply create an associative array of replacements +based on email addresses and then use the mailer's ``registerPlugin()`` method +to add the plugin. + +First create an associative array of replacements based on the email addresses +you'll be sending the message to. + +.. note:: + + The replacements array becomes a 2-dimensional array whose keys are the + email addresses and whose values are an associative array of replacements + for that email address. The curly braces used in this example can be any + type of syntax you choose, provided they match the placeholders in your + email template. + + .. code-block:: php + + $replacements = array(); + foreach ($users as $user) { + $replacements[$user['email']] = array( + '{username}'=>$user['username'], + '{password}'=>$user['password'] + ); + } + +Now create an instance of the Decorator plugin using this array of replacements +and then register it with the Mailer. Do this only once! + +.. code-block:: php + + $decorator = new Swift_Plugins_DecoratorPlugin($replacements); + + $mailer->registerPlugin($decorator); + +When you create your message, replace elements in the body (and/or the subject +line) with your placeholders. + +.. code-block:: php + + $message = Swift_Message::newInstance() + ->setSubject('Important notice for {username}') + ->setBody( + "Hello {username}, we have reset your password to {password}\n" . + "Please log in and change it at your earliest convenience." + ) + ; + + foreach ($users as $user) { + $message->addTo($user['email']); + } + +When you send this message to each of your recipients listed in your +``$replacements`` array they will receive a message customized for just +themselves. For example, the message used above when received may appear like +this to one user: + +.. code-block:: text + + Subject: Important notice for smilingsunshine2009 + + Hello smilingsunshine2009, we have reset your password to rainyDays + Please log in and change it at your earliest convenience. + +While another use may receive the message as: + +.. code-block:: text + + Subject: Important notice for billy-bo-bob + + Hello billy-bo-bob, we have reset your password to dancingOctopus + Please log in and change it at your earliest convenience. + +While the decorator plugin provides a means to solve this problem, there are +various ways you could tackle this problem without the need for a plugin. +We're trying to come up with a better way ourselves and while we have several +(obvious) ideas we don't quite have the perfect solution to go ahead and +implement it. Watch this space. + +Providing Your Own Replacements Lookup for the Decorator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Filling an array with replacements may not be the best solution for providing +replacement information to the decorator. If you have a more elegant algorithm +that performs replacement lookups on-the-fly you may provide your own +implementation. + +Providing your own replacements lookup implementation for the Decorator is +simply a matter of passing an instance of ``Swift_Plugins_Decorator_Replacements`` to the decorator plugin's constructor, +rather than passing in an array. + +The Replacements interface is very simple to implement since it has just one +method: ``getReplacementsFor($address)``. + +Imagine you want to look up replacements from a database on-the-fly, you might +provide an implementation that does this. You need to create a small class. + +.. code-block:: php + + class DbReplacements implements Swift_Plugins_Decorator_Replacements { + public function getReplacementsFor($address) { + $sql = sprintf( + "SELECT * FROM user WHERE email = '%s'", + mysql_real_escape_string($address) + ); + + $result = mysql_query($sql); + + if ($row = mysql_fetch_assoc($result)) { + return array( + '{username}'=>$row['username'], + '{password}'=>$row['password'] + ); + } + } + } + +Now all you need to do is pass an instance of your class into the Decorator +plugin's constructor instead of passing an array. + +.. code-block:: php + + $decorator = new Swift_Plugins_DecoratorPlugin(new DbReplacements()); + + $mailer->registerPlugin($decorator); + +For each message sent, the plugin will call your class' ``getReplacementsFor()`` +method to find the array of replacements it needs. + +.. note:: + + If your lookup algorithm is case sensitive, you should transform the + ``$address`` argument as appropriate -- for example by passing it + through ``strtolower()``. diff --git a/vendor/swiftmailer/swiftmailer/doc/sending.rst b/vendor/swiftmailer/swiftmailer/doc/sending.rst new file mode 100644 index 000000000..44608455d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/sending.rst @@ -0,0 +1,607 @@ +Sending Messages +================ + +Quick Reference for Sending a Message +------------------------------------- + +Sending a message is very straightforward. You create a Transport, use it to +create the Mailer, then you use the Mailer to send the message. + +To send a Message: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, ``Swift_MailTransport`` + or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Send the message via the ``send()`` method on the Mailer object. + +.. caution:: + + The ``Swift_SmtpTransport`` and ``Swift_SendmailTransport`` transports use + ``proc_*`` PHP functions, which might not be available on your PHP + installation. You can easily check if that's the case by running the + following PHP script: ``setUsername('your username') + ->setPassword('your password') + ; + + /* + You could alternatively use a different transport such as Sendmail or Mail: + + // Sendmail + $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); + + // Mail + $transport = Swift_MailTransport::newInstance(); + */ + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself') + ; + + // Send the message + $result = $mailer->send($message); + +Transport Types +~~~~~~~~~~~~~~~ + +A Transport is the component which actually does the sending. You need to +provide a Transport object to the Mailer class and there are several possible +options. + +Typically you will not need to know how a Transport works under-the-surface, +you will only need to know how to create an instance of one, and which one to +use for your environment. + +The SMTP Transport +.................. + +The SMTP Transport sends messages over the (standardized) Simple Message +Transfer Protocol. It can deal with encryption and authentication. + +The SMTP Transport, ``Swift_SmtpTransport`` is without doubt the most commonly +used Transport because it will work on 99% of web servers (I just made that +number up, but you get the idea). All the server needs is the ability to +connect to a remote (or even local) SMTP server on the correct port number +(usually 25). + +SMTP servers often require users to authenticate with a username and password +before any mail can be sent to other domains. This is easily achieved using +Swift Mailer with the SMTP Transport. + +SMTP is a protocol -- in other words it's a "way" of communicating a job +to be done (i.e. sending a message). The SMTP protocol is the fundamental +basis on which messages are delivered all over the internet 7 days a week, 365 +days a year. For this reason it's the most "direct" method of sending messages +you can use and it's the one that will give you the most power and feedback +(such as delivery failures) when using Swift Mailer. + +Because SMTP is generally run as a remote service (i.e. you connect to it over +the network/internet) it's extremely portable from server-to-server. You can +easily store the SMTP server address and port number in a configuration file +within your application and adjust the settings accordingly if the code is +moved or if the SMTP server is changed. + +Some SMTP servers -- Google for example -- use encryption for security reasons. +Swift Mailer supports using both SSL and TLS encryption settings. + +Using the SMTP Transport +^^^^^^^^^^^^^^^^^^^^^^^^ + +The SMTP Transport is easy to use. Most configuration options can be set with +the constructor. + +To use the SMTP Transport you need to know which SMTP server your code needs +to connect to. Ask your web host if you're not sure. Lots of people ask me who +to connect to -- I really can't answer that since it's a setting that's +extremely specific to your hosting environment. + +To use the SMTP Transport: + +* Call ``Swift_SmtpTransport::newInstance()`` with the SMTP server name and + optionally with a port number (defaults to 25). + +* Use the returned object to create the Mailer. + +A connection to the SMTP server will be established upon the first call to +``send()``. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + /* + It's also possible to use multiple method calls + + $transport = Swift_SmtpTransport::newInstance() + ->setHost('smtp.example.org') + ->setPort(25) + ; + */ + +Encrypted SMTP +^^^^^^^^^^^^^^ + +You can use SSL or TLS encryption with the SMTP Transport by specifying it as +a parameter or with a method call. + +To use encryption with the SMTP Transport: + +* Pass the encryption setting as a third parameter to + ``Swift_SmtpTransport::newInstance()``; or + +* Call the ``setEncryption()`` method on the Transport. + +A connection to the SMTP server will be established upon the first call to +``send()``. The connection will be initiated with the correct encryption +settings. + +.. note:: + + For SSL or TLS encryption to work your PHP installation must have + appropriate OpenSSL transports wrappers. You can check if "tls" and/or + "ssl" are present in your PHP installation by using the PHP function + ``stream_get_transports()`` + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 587, 'ssl'); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + /* + It's also possible to use multiple method calls + + $transport = Swift_SmtpTransport::newInstance() + ->setHost('smtp.example.org') + ->setPort(587) + ->setEncryption('ssl') + ; + */ + +SMTP with a Username and Password +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some servers require authentication. You can provide a username and password +with ``setUsername()`` and ``setPassword()`` methods. + +To use a username and password with the SMTP Transport: + +* Create the Transport with ``Swift_SmtpTransport::newInstance()``. + +* Call the ``setUsername()`` and ``setPassword()`` methods on the Transport. + +Your username and password will be used to authenticate upon first connect +when ``send()`` are first used on the Mailer. + +If authentication fails, an Exception of type ``Swift_TransportException`` will +be thrown. + +.. note:: + + If you need to know early whether or not authentication has failed and an + Exception is going to be thrown, call the ``start()`` method on the + created Transport. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport the call setUsername() and setPassword() + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ->setUsername('username') + ->setPassword('password') + ; + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +The Sendmail Transport +...................... + +The Sendmail Transport sends messages by communicating with a locally +installed MTA -- such as ``sendmail``. + +The Sendmail Transport, ``Swift_SendmailTransport`` does not directly connect to +any remote services. It is designed for Linux servers that have ``sendmail`` +installed. The Transport starts a local ``sendmail`` process and sends messages +to it. Usually the ``sendmail`` process will respond quickly as it spools your +messages to disk before sending them. + +The Transport is named the Sendmail Transport for historical reasons +(``sendmail`` was the "standard" UNIX tool for sending e-mail for years). It +will send messages using other transfer agents such as Exim or Postfix despite +its name, provided they have the relevant sendmail wrappers so that they can be +started with the correct command-line flags. + +It's a common misconception that because the Sendmail Transport returns a +result very quickly it must therefore deliver messages to recipients quickly +-- this is not true. It's not slow by any means, but it's certainly not +faster than SMTP when it comes to getting messages to the intended recipients. +This is because sendmail itself sends the messages over SMTP once they have +been quickly spooled to disk. + +The Sendmail Transport has the potential to be just as smart of the SMTP +Transport when it comes to notifying Swift Mailer about which recipients were +rejected, but in reality the majority of locally installed ``sendmail`` +instances are not configured well enough to provide any useful feedback. As such +Swift Mailer may report successful deliveries where they did in fact fail before +they even left your server. + +You can run the Sendmail Transport in two different modes specified by command +line flags: + +* "``-bs``" runs in SMTP mode so theoretically it will act like the SMTP + Transport + +* "``-t``" runs in piped mode with no feedback, but theoretically faster, + though not advised + +You can think of the Sendmail Transport as a sort of asynchronous SMTP Transport +-- though if you have problems with delivery failures you should try using the +SMTP Transport instead. Swift Mailer isn't doing the work here, it's simply +passing the work to somebody else (i.e. ``sendmail``). + +Using the Sendmail Transport +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To use the Sendmail Transport you simply need to call +``Swift_SendmailTransport::newInstance()`` with the command as a parameter. + +To use the Sendmail Transport you need to know where ``sendmail`` or another MTA +exists on the server. Swift Mailer uses a default value of +``/usr/sbin/sendmail``, which should work on most systems. + +You specify the entire command as a parameter (i.e. including the command line +flags). Swift Mailer supports operational modes of "``-bs``" (default) and +"``-t``". + +.. note:: + + If you run sendmail in "``-t``" mode you will get no feedback as to whether + or not sending has succeeded. Use "``-bs``" unless you have a reason not to. + +To use the Sendmail Transport: + +* Call ``Swift_SendmailTransport::newInstance()`` with the command, including + the correct command line flags. The default is to use ``/usr/sbin/sendmail + -bs`` if this is not specified. + +* Use the returned object to create the Mailer. + +A sendmail process will be started upon the first call to ``send()``. If the +process cannot be started successfully an Exception of type +``Swift_TransportException`` will be thrown. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs'); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +The Mail Transport +.................. + +The Mail Transport sends messages by delegating to PHP's internal +``mail()`` function. + +In my experience -- and others' -- the ``mail()`` function is not particularly +predictable, or helpful. + +Quite notably, the ``mail()`` function behaves entirely differently between +Linux and Windows servers. On linux it uses ``sendmail``, but on Windows it uses +SMTP. + +In order for the ``mail()`` function to even work at all ``php.ini`` needs to be +configured correctly, specifying the location of sendmail or of an SMTP server. + +The problem with ``mail()`` is that it "tries" to simplify things to the point +that it actually makes things more complex due to poor interface design. The +developers of Swift Mailer have gone to a lot of effort to make the Mail +Transport work with a reasonable degree of consistency. + +Serious drawbacks when using this Transport are: + +* Unpredictable message headers + +* Lack of feedback regarding delivery failures + +* Lack of support for several plugins that require real-time delivery feedback + +It's a last resort, and we say that with a passion! + +Using the Mail Transport +^^^^^^^^^^^^^^^^^^^^^^^^ + +To use the Mail Transport you simply need to call +``Swift_MailTransport::newInstance()``. It's unlikely you'll need to configure +the Transport. + +To use the Mail Transport: + +* Call ``Swift_MailTransport::newInstance()``. + +* Use the returned object to create the Mailer. + +Messages will be sent using the ``mail()`` function. + +.. note:: + + The ``mail()`` function can take a ``$additional_parameters`` parameter. + Swift Mailer sets this to "``-f%s``" by default, where the "``%s``" is + substituted with the address of the sender (via a ``sprintf()``) at send + time. You may override this default by passing an argument to + ``newInstance()``. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_MailTransport::newInstance(); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +Available Methods for Sending Messages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Mailer class offers two methods for sending Messages -- ``send()``. +Each behaves in a slightly different way. + +When a message is sent in Swift Mailer, the Mailer class communicates with +whichever Transport class you have chosen to use. + +Each recipient in the message should either be accepted or rejected by the +Transport. For example, if the domain name on the email address is not +reachable the SMTP Transport may reject the address because it cannot process +it. Whichever method you use -- ``send()`` -- Swift Mailer will return +an integer indicating the number of accepted recipients. + +.. note:: + + It's possible to find out which recipients were rejected -- we'll cover that + later in this chapter. + +Using the ``send()`` Method +........................... + +The ``send()`` method of the ``Swift_Mailer`` class sends a message using +exactly the same logic as your Desktop mail client would use. Just pass it a +Message and get a result. + +To send a Message with ``send()``: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, + ``Swift_MailTransport`` or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Send the message via the ``send()`` method on the Mailer object. + +The message will be sent just like it would be sent if you used your mail +client. An integer is returned which includes the number of successful +recipients. If none of the recipients could be sent to then zero will be +returned, which equates to a boolean ``false``. If you set two +``To:`` recipients and three ``Bcc:`` recipients in the message and all of the +recipients are delivered to successfully then the value 5 will be returned. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('localhost', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself') + ; + + // Send the message + $numSent = $mailer->send($message); + + printf("Sent %d messages\n", $numSent); + + /* Note that often that only the boolean equivalent of the + return value is of concern (zero indicates FALSE) + + if ($mailer->send($message)) + { + echo "Sent\n"; + } + else + { + echo "Failed\n"; + } + + */ + +Sending Emails in Batch +....................... + +If you want to send a separate message to each recipient so that only their +own address shows up in the ``To:`` field, follow the following recipe: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, + ``Swift_MailTransport`` or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Iterate over the recipients and send message via the ``send()`` method on + the Mailer object. + +Each recipient of the messages receives a different copy with only their own +email address on the ``To:`` field. + +Make sure to add only valid email addresses as recipients. If you try to add an +invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift +Mailer will throw a ``Swift_RfcComplianceException``. + +If you add recipients automatically based on a data source that may contain +invalid email addresses, you can prevent possible exceptions by validating the +addresses using ``Swift_Validate::email($email)`` and only adding addresses +that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and +``setBcc()`` calls in a try-catch block and handle the +``Swift_RfcComplianceException`` in the catch block. + +Handling invalid addresses properly is especially important when sending emails +in large batches since a single invalid address might cause an unhandled +exception and stop the execution or your script early. + +.. note:: + + In the following example, two emails are sent. One to each of + ``receiver@domain.org`` and ``other@domain.org``. These recipients will + not be aware of each other. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('localhost', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setBody('Here is the message itself') + ; + + // Send the message + $failedRecipients = array(); + $numSent = 0; + $to = array('receiver@domain.org', 'other@domain.org' => 'A name'); + + foreach ($to as $address => $name) + { + if (is_int($address)) { + $message->setTo($name); + } else { + $message->setTo(array($address => $name)); + } + + $numSent += $mailer->send($message, $failedRecipients); + } + + printf("Sent %d messages\n", $numSent); + +Finding out Rejected Addresses +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It's possible to get a list of addresses that were rejected by the Transport +by using a by-reference parameter to ``send()``. + +As Swift Mailer attempts to send the message to each address given to it, if a +recipient is rejected it will be added to the array. You can pass an existing +array, otherwise one will be created by-reference. + +Collecting the list of recipients that were rejected can be useful in +circumstances where you need to "prune" a mailing list for example when some +addresses cannot be delivered to. + +Getting Failures By-reference +............................. + +Collecting delivery failures by-reference with the ``send()`` method is as +simple as passing a variable name to the method call. + +To get failed recipients by-reference: + +* Pass a by-reference variable name to the ``send()`` method of the Mailer + class. + +If the Transport rejects any of the recipients, the culprit addresses will be +added to the array provided by-reference. + +.. note:: + + If the variable name does not yet exist, it will be initialized as an + empty array and then failures will be added to that array. If the variable + already exists it will be type-cast to an array and failures will be added + to it. + + .. code-block:: php + + $mailer = Swift_Mailer::newInstance( ... ); + + $message = Swift_Message::newInstance( ... ) + ->setFrom( ... ) + ->setTo(array( + 'receiver@bad-domain.org' => 'Receiver Name', + 'other@domain.org' => 'A name', + 'other-receiver@bad-domain.org' => 'Other Name' + )) + ->setBody( ... ) + ; + + // Pass a variable name to the send() method + if (!$mailer->send($message, $failures)) + { + echo "Failures:"; + print_r($failures); + } + + /* + Failures: + Array ( + 0 => receiver@bad-domain.org, + 1 => other-receiver@bad-domain.org + ) + */ diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle new file mode 100644 index 0000000000000000000000000000000000000000..f895752b70947592db74b6a3b8a6bd135a9fd150 GIT binary patch literal 3503 zcmV;g4N&qQiwFP!000030PS6EQ`@)}{tUmumk&GLSx6-LC3cr~Cj@BOOAAXvd$*G> z#!(V4j-A>HA=~MHzmo0vRW^_oh=XTJ?O5mN_0gjv>B!#y<91>RH`w(|$9}T|8(>Gk zw&4s+d-P`KvUj|v?)>p~d;dR&XPw^P=SRZSGCd-kUml#EbcCI~X0tt=TDaLf>>Uc{ zrzhQ>K;vjOk3Q}QJ7Yqouba*JeBRKRRKsv4OwendyUrB5WN}I(+oKAN0U7MjWP;dJ z*`ZGdra|6rZ|z^>#oM+)%o}{FFR*)J5Af}NlRc$@rcLk&yKljMb9uW|p=q0jPH2>$ zf|w&E-F0<#v$gLLmlpXg&0)it*yhM}X4A$Qy?f{C!=Z&~j`y3PP(mIetpVjk$bNGf zXOQ-cIPJkdGmk`R5_g81%kYkF-{@Y)u^cxN2#XsC%$JYjBvYv+>n4co%r!@5T*OfJ z8`u@V_oQm9(KU1nM+z?1EtZIXUCKGuY+|=9b7bc#9Of!KknT=(gC>=ZS5z_)(;uv1 z4t0XFSw;Y~_8_AF1O#6L>9q`n-yj4aR|*zMq5{Lv&e%0Qq2st$3p=ZFXnIpiU!+UE ztYE>I2yX;-$*NH>Ovi_gF`HnUWWlto1vytCzM5%x4DKB4EgL*6jiq~D)ap^LPE8w! z@g#v5=)A}JAfXaP7=)f2#$kzeL#dYAiowKDi?tLfqs2td9r`Gl>8NmV0lp~;YN&E+ zS3oV)kiVx&5ld-+2JQ+X&>BF6X{oq#h3R(5B5uEY!Ktcqjgy6s1>%ZpyRI`&2t|46 z64SU2Lz8(8R9S=c7E_$k zRgnlKRooR+P=vuC96}`v(vyWLhgXIFcpWnyON49dQNL z$~ZsQ3Bj&i6Z0oBv5EQ%;+ zHqGN{xvWvpqS?AUaAx+vSU{X4H#Guccu##o=?0T273 z=CMh7_?GZ=KVg?PrEYQ6EPe}KV9)%QYty9KB-tkvF7fyo=ciy$yJ=)`6UiVuUEP7m z(6p?iL|PaM_U6{!WXeL98r zs9TQpLAug;SwD33xyMiW<5_7c=^uV4%K{^pr>sO=%Dzj6u&>*m>HlX;M|1>5eZw&v zod#)=7TkNYEBX_)!1lNP(6I@*vid{NA9{1s^ZG+$th*j2KzNU>8_eMN`*$j7u%%%t z`g`BS10>7+k&Cg-Zmz5urdKM}pX%<)DU|1zQv=wE-kLyMpr z^zj8{P3#`id&gbmx-qx*&n+4iTUF)u9gsD<6LGA-GnyFj43svHXIeGSRF-E_do1Oh z;6*c&)&FYiWajEtKv6M4jW7xM$8leE{i+bcBK#`67BVFD$n2D}NZ+~U;C+F?RBS1f zbnYOAW>IR?aO*g>O}lvBw)^|2d++sw^ekXatw>rs+OD7|jNPHy+DvvAYj&@#$f{eB z@34(s(>OM7@!+#LAmis^9oOob7x$8qamS zqHb5Vbe!r=**s)A+e_+daYwtrbPj2If<2pDVOMa5!qtLcPauv!+=W0nnR&uCgf_ip zlERHnv&rQC#jYbvFs&kijIlq%^rw}A=`kU5z*E|TMJk5ly0a-^N>hJ3`38q-rafTZ zt2oN!#Bp()O_s$*b{k~PSNp>qL|J7$n>Of1F852IwnS=6_We9Wl_T@;-TegKg|m@D``aT-PHdAsKA@IUm-e(*Vc1&k0OX8^ zl3xEbI{+Ccv^DUGlU8v|5?6Li(ln(Zx9F%MX|Uw@iq@hMGOS&=Q~pS6?BJHg(IcE2 z5P!fK6MzQuSttb^ld4gdN1eL9s9Wvuohbi^TO|h~8K+8ws0={$p@E+XLq5Tj9U9PD zvZ!cs3n`)|DQw60c}@+8(&~d{s~l|`%vcpAmz7V5v>3C9qITDb-mFCJtsOQO&?@Gw zP3L#M1AbtXFlQS{+Q{8xq}3}d^%`!~*Km(bD_$h&5(i|Yb0vzQaE>TO+dzt` zkAu`c058`EfO$W@q7@}r*dCEF+tLr50Q%c=*CaS~0PxrTHZ7XJrioo&YZ~024TtP> zV1IjP&Ac(S!U#p6_bQN&IS!NTdBXm-IhoRm2_7#)gC>areTM^|A790{g5&+VmYxSW zo27(np2qVavzq<<%j?R6_j43kQxy?HNt6{$lezmjWmN!I_F9l-N|Z>E8weFH(90l@ zsdta7^1@8zv0WCFAHrM7W{{7y=iUkeo4W(_=vccaVf`3@poU5TlnY-609DH^L0sQg zxfc8Flt2!x>|+&B5)d0=5#}VxpGcxcOOk8fn4d{}4>hG)atlgGm7oe`O;RQ8xm;tE zA41z*{I-?@IWa&(p(7 zykR7;-qnB>k+O-jDAsQnsadh|tazY%Sdl7DilSHRs}|sH0JIF0>2Dp6J5Wg+ViXC!%g=5dK#j9IIW04jc8@_?5z6jmbJIn3-~-r%W9kNpBqxqg4=3wnR&G3)VyMf*4H>mff31ZPI3Ga}6C=q1>gJ|K>8g#~X+ zv(8?(IgBI;twi?vO)B6KT0Mee3p$PH*7OKt7Z&r+db#G~&#RC`dmHrE-didiGG!qC zYzwGp0qBXh3ZHU(U)dgI%>n&oKPa+W?Wr0=+T6yd=WwO`=tph31@==oY4gf#pE4V! zz(1RBB*fa0{gd=i^_#32h0e?Y_D&t+8b|J8Ty!L)Kbf9+6=Rcc-UPlb=lTdo*yH=G z1O=Q>!4B=xi5W?mxOc8wm=Jt-mj8?KwC8l`1ThvK>XwJ2Dmc{_v}vNisOmF=3#%iJ zDRY(|SU&0#j?v>MBfz})IsJKGYw?qb=XZ)0A%W(A4$#F|pw{|zQRC(-_JcmMF?oo* z$Ifz$F(z5zAShKgS(Urnr){uzcl)(`Vh`{wr^oQV{@tDtr#<**<|UhexHH^L*cG~c zqkA33FvVu!oMRKh0t+S??U`$iOq*lFgIxjeY<6EO1?c63A10mhd|AhuP3+A4x6nU5 z*62=kgC?4dUsSRQ9Gc$L(ihp>EQ>D~6XA`(F2&~8shO(!{ zFQ>K6W`s=yvXjCvQwO@oo1R`c^M@dwir*XVJ{9#$!pjYZ#6qo0+x$Ai{4t!9p-=b2 za}mpba0cd(eYk*D^P!#}A`t-U9zc6g5)gbXNv|bM_zgk;a_s9zlo*f0;Lg~k6St1z zUM=jb4x8EEe@Nf}f)9tKG$qRWN6x`c5pu#$myhrPZSQOE9+r*Y$#O%f-!6VVbPpUt zoXH2>O_F*bX_bZh-zP9F_cWF~09!`UN zpW-2@Uaoo6!pXKzjGRov^4QPm{LM`Ze!j1mYCX6!%_eiDd?@N@VlHIq6{nr&m zYp|t03CXabrN7XgPwm1SjVsvDJ!e{-Ove=M4>VXGoY~gmZtBX8U?nr5{OFY%y9!3G zh|Ya`GH-l$Cv;ZsXM-)n2Q$CG#=ZwV`pVQe^pDFtP&YeVmX!X|!$-7lxtMWxB)_!Y zIiqPwT%S#Q;LM9Dy)$!NS`n!UOwrULT6e*2Prr(#!-9rGQwlV(hW}Z{SjTTg1QG{s zf~`$A#YYLJH}-m0|3ic9Guw(Prx(9Mlg}SSFYqWum{BDD)WcuRWN+_)P(qwYzBtY# dlTFZwk616kA77^y1;pF!{{uPR7LWUs0009F*SY`z literal 0 HcmV?d00001 diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle new file mode 100644 index 0000000000000000000000000000000000000000..e1e33cbf16ea45d29ad48eb9b2f37959292881b2 GIT binary patch literal 5575 zcmV;&6*%f2iwFP!000030PS6CbK5r7{v7`bzWLBe-gRUE1b9i)?8vgyxa-(%tR&m6 zcXntIlGsqBLQ-+Oo&NU)NL?u2Y*Us5G02P~i97&7;+zK$4h|1q{r%g>Rld?7bbRlp zr?3T{D%9)ww&M+cditUJ=7sU}@2~e>{om1fr~BK*u`+g@Fj6i)9G;$Zl&3Ea4%*|f zOAii?x<|^z>B(hRVRalF9G^W^o(`jE{PN)7=H{klaj90%A92C(;3DwHG>C3bS!FL+ zftDTFPuXRX+LxNcj@nKydcF7L)n|J9y4{PMuk_TqrNN13({Ha1_)&J!@gh2)!E5m9 zVD@!Zgk9U|SrM!9V^Z_HkQD?L|MKKj7zON>U$Yjr{E_Dj0)H}YowIL02UfrDQr6;E z2UDSxJVa&-lGK@32eUepYfmD-ZT~R|qxm(XU_uXO=R217)e1Yl>j!gz>Fp*0H?zZw zODcAG~9ZtcYfti~ulR0Qdqy1)-M^yu_yRHwXd9-36~C^#G@5 zJHx;Um5v`=-+I|1M@~3)t=r{0pFLouH&T95_(!%FQ-<;I$nQ-?)QhspGnoUre&cjgE=_cok3^5pp#MDE0W4Yj;A~CzHAwTY-HQeIpuR|3ir456$2o2;um{ z0Q^H$V-eMiMKF#<2#7^kY5t+XSVYsA$d}&UUeZQ{m8)JKDBU4d{y}d$R*!uNnL5)@ zv8~8bCLwzmilvML=PR=k#j{2*Z(f#JH&+$6u$b%L6qR{TL+8J=s6^Vjmh1~I+gGuLrLWM7 zEN|czUgR>mb(c$}9(N+rcU(6uu`Dw0Lfc{Z)=sXI5}tuLz;hHYDA!?sG{_X3_38`I zLMDdL*jM;h4eLP5c4|r?b3Y33qTn{O65kc3T&Gaw2RHhW|8X4)`V2IF7_bBE?`m%b zHaU|jeBKu>E6hi|LOliKfgv~8GzUMJ8%TGUlJHEWP`(pX_A3D)Jbv#y^ytk-cM9 z)c>3w4sv5Te`4(*C>|O=ygNPdhBR>4@YO3Ey?AeQZ!^PQp%-#tAC}{mUJ+!TN7^!$ zdxcl?@U8}BT`hnbf?8^*)mKBPwE$B?O(iX8;8Inb$q}S&RU0qa`1^T!cIPz_k;l@+ zO?m!eM8YQI%-#fz^a5yD5_{?S+luFJ!D=_pFdvE7Wq6dRIHnRKW?$Hd7wsS<&BQXf ziXpLVJ6QI{aW{iyH7%b&G`D<+n`ilQEkn8|MRZRNXmnvk!)FV}pOD@(t=yZIGp)_I z%rwDVW@;^u8L926fEq?E6g$M!maf4vR|NznVq^}1G69XKEk27?)x5_;dNb;KGYoOv zY6#ZSRZ!clrsAnv4V#s2HG~s3QYa@Ky`s3+MA1mB*G5lMCtS^pQdI;@WfN62THM38 zO;rR9&^|2iG6N*Fv=6VQeb~HP`*Jc;^H$cpsj%1gi^QS0YHHNdQgt;gC0gl%EHrep zRVX8e>UF5>g&#Um>P?QhqX4uBQTacNfKF7bn<>A+nl!jX+rZjJbPff}JykjD+6;$+ zM67UCXyQ821OV2LS0y?JY=p|=38o@YH)J@$BZd<|0}C6}0!_V^9@dXD;6W>Q=wU1Z zr6NAQBI-N#hBq`&!aAXrOez6snPwwh_t2CpopM^a#%blD6;cf!^Q_%8*wr_>v*VSh zxTQf9Q>g^DOwdfkA`-DAVyzFcejV>TT4BMaoup1iCur6WV%Igs-jIq)$$lbWN~Zs) zOy7KH1UuH5QJOk73HxX0y1xDp_F4*T=(QBM{(MzOs9J#yfC~iVi$Ys;lWc5u8h1U4 zGYdlkTL2i1BzlINno6R#_Ngf&ToLP(UFUqpZp=`LsV=Y!na#v4IYE`Uwblu0Q!q=k zc`AQ}_Te<&K($k(03I!@X446$1RyXA1mrw*HO^1KuH_s~^dL#s*UX&5Y+56SO*w3C zB~RzB52TrKOMrp2PG%>l*WXD3nz&`aeZ??9d3qfK7YN9)bhWWm7dXs_sI}B^#ROv& zItUHTY(Z11;p3|z+&M}&gDg#py&-YxlxBKzb?Fh2)NYN`?$Q}})P6_9&>9GqG$l<; znr`Lt4K?`+i>R-#a0}?OhDKEI*I4p{Wrc-p2@|;O?dJwHF;aOd5fDw&W$B++s@)9PwaB+MNV`plxJ*V`zA@* zKGB+I`!cnQ^oxn;7dt)vczpVw?)ioCQen^QYA-p^?snUqx9^V6y35B;&Q4Fxj+c*J zemJ~nzn=<6`T`+iElQui5q@`}s9J&&cA&OM*O6FYI}+qdm7sb#6c$S*v&*m?fh;;Z6> zLgr=9&nPMgM+H=DCJ~mg8|f1Wiq~qn{w3ju$L0No=NhfX;CpLFfQl0 zWGj&}nFT;$-@-;9$$rCzI&7e3GF&J}ImvLh!f-eGdUhSt=PwjD+4NnJxgz&DH&yyh5Jo&S<-Ff#cb^;_S>O1fQ|b*E`xTR~!E(Naw!_ze zU@y+9wIT&Esh^x4L&3bnY_Q=+m~wX*(}1aQpJ%;3eL;a{abXQY={qYn8Z$ps|2+;J8K|nAvu4QsI^vyTQd*~2{wZ@Yb{iv`Uzg4$t(t! zC+vq1>IDLFZn_fFHwZ=Ag*Iuua&VL zkd<@}mqSvlbGh?U=T_D^5!hLYGNH8rSfR4X@oh_3qt^030I(X?Xr(hjji@bBAR(#t zI-sX&i2@s@ZW2RNHDsuU{y1wCn~FD%mtqlUaOj>Xb6?BIy){PeF(nQeG9=-9LZxz= z$5}MkxMf(bOyneJBBv=Z2)>(aZg?!Wt&L<{$^@&4%$qcv>?EtgMnbDh0xfyd8hO*H z6GozvCLZh8V9SPQ2O;o|DQK+$C{Z zBXQ!pPzXt!rlDyKwro{ewj@qs5~r>+qG4o>#S{Br<-dywRk| zkdAywn$}2~n7&ZwE42kAPK%Tg4Q5V2nzv+5VlpQ-pR$&`O=9|+awBB9aczV<89T9M za}ov))Fx9W>CTtbX^qs0!Q!OHz;i?7X?=i2c4x9jlKlXXh8l@j(vKz)YmJE2w(Wq1 zp|Ep3qG@yM#*N!P-oVnj4N!6B}ydGL3+wPlD2?6I*oVgiDzd*$Q(~cP8c&1JYzvmEL^GoYu&kK6qh6qCPV@ zqDvtw3n(c#G4Q^EOoPLTsuiF~737s8NimL8qDTRTR3J$CGtr8+f5>1*HFDf1vup-4 zau9wLST}{}dv;!$;&qy{c4*m4K>C<<-9|t$prOeG=8vs@8`+8UEXgp36L%BTnh0T7zG5sPY&#H^c%L={WOeLbSLb%$JU26z zQH^r(PT*Jh1Yf?(4V&eLwUOmJyb~D^Wfk#|VaAG(QJ8s=UGpl+&1 zaC3V^63R+K8CUHDB?HDgXGE*;z6!UC0~|_Hz${A7F+aTteB50J^RpAjrs1jI`%LF6 zFbgp;B>%Ykjj+kJF*>s8+Rf&femP@0E-reMXP&)4V zmyD+_g!`5o()lAewQgy!Xyp9SXT}%)jPk=v#(H8&P6-ME6ZmBmm>0ibKkqw2est)~ zouXx$z*^u>qHlZDbgDFT^0?k|TN)uvp49#2yE@uUbr?x2#( zI8reV7hp*>niS(nIieI|N`-jU2$jc{d`B@&XOo!twX&j+se;}*pG2#xwDIt9uMZT_-APO#z5aOMUR1FB4ikh8HyG{6IC`7S3 z%%mAm-oNq!-6_+Y#BSJQKV<#=IlKq6iH$5bl*auMKZnahKZ^X(J1a&fNuusuBg00_MP^o!dYbl7kE`~&=b zc>VUH+h*rG$E4duzkK=q(-~-=d^&Dleql0iKD#%apO>k^VmM9OeMVRh{nZ0;5;A#p+7$wy)JAH0ZThJBB#T*mIvimT*aSeQpGYns_YCU*i8*fRCM zs;~Cm84P!@qr3iicN)Eb=y;%^mVNHIw|7HVb_A=K3FSwx+}Kqza?Rm9=978yeK}$? z^0*n?^_a~35{`Wjc#I1(au~-4Kd@|exU9JQ4c(#92 z4(Xjq5U>ZaG=V9bTFiYeH0WB_3+d^NPKTx?rCF5t)RMqpvajeWSay6(DPKH@zNdpFz?@fN7<}%*>M(e8vBv7l*YUgWk20-X%s*zD VzxW)xOdDSB{SO2kTt$6+0RTlqtKk3u literal 0 HcmV?d00001 diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle new file mode 100644 index 0000000000000000000000000000000000000000..5670e2b65ada6e01406334a4b462f58e8f48f4fd GIT binary patch literal 3061 zcmVFR$!k`4GK0ih`&)N3_0pskCgy+3{0lD+r;eCXT4SBN~zb^h1_1#wG& zj^Ub?)BR)Xy7_Lmy!Gcne*Ztmm(}LS`iU^GEe{Lz>!Y(;RoL1s77qsl8y1Vl&10c{ zR%Kt2=7fl7mw;KqICO?N&#%hc9O;Fe+vbt7yi(}bu z;*KDGk7f;XGz{H_(+mjeHm$_JPUKvB*mn+XtLvmX9HcrtkZufggH#nSSJn~*lP`2& zj&%%^O_oHlyemq(KoKOcCrNv9N%$`SqL{i1T1cb=$EnpGvOJ;cqV}Vc%yMjb16zNL z-}$721*0$gA<#=Q8&QTq@7Ohledyq%GEI6xO?8N$%`!Zy?hM_V40s@XmDO}qo)s`Ic`Zh*EtC3bt{q2YCtXvDb<W8~h!=PoWHn5H?lmh)iHWH@*oz4 zQ)qvMn4tOF??lp|xJg9cwh%NWRc&<_`L;#7>JXurafdKUl<#hw8f|5el@3AkF$!Th z&O{knj&9l9+Qh|;nH2NX@zqMa@qKaC)8u7TPhM8_NESeTd4O*-+}%xpG$02z#oH6#%eVrxl)m(62lY;%bBHj|$vM5ZHXT7+*O2K7XQ zCyNSEnXW1r`Ksg(qD02YpzewVsiFW--Vx|WO(}^<6o?bF#1{tnVccd?;@2QZM!<{O z5oYw8jo;Egs$;058}PR-`GNek@?@#pBO^su>Mlx|6|>XpHYtHF#hALBBC1iE{bakR z#AAc)UdrtLC)j;*5j8_Qe`%!PFQvK=Q(*WDK8{>uZod)sgofWCt-Kxr2HZaJ`gm|O z>~tWaYpVf7LVMWR84C+T52ERp0kKkAP}_BFs5?IyYf>!nJ+jPG4jtjn!+c8(@)vn^ z5mHoj9f#QKg1#L#wT|E5ni8~N1qplySw&kB$zB$C%KW62Mis0-mI=8z3*)YNuR&GY320}8UK@>?Q*=JM1&N7PMFI$Z&>u_ zFMisUF~H0;9ar6cpEPWqgVhMcb_6ompTCf=CiFiU#nJVkLgo z#8TkJmnN#R%+f?!dTCN2I3<-7-qNHZX^iyj9LAa~Po7=+Z* zSHEm!yc*S8$|)oMkW)rdW}iRlsVTPwa5Shprlty_^c&bsByx--7D zhJ1@O_0;w7gi!U!=QsW~Se-O?oAjVS;Uf6y#4*t0fWAdyA`Ts6Eq9wzlPTX2SHrTv zdhIqT(h@#bMP1hC3N*DKN_59buJHV>Kr9#3vVRD;l=)tt(f7*V+Ie}`e`N_ZluFC0 zp+r=y1hkoIC~2hvpgx~W4cAo-SG4AoDHef>Pf8_e6PU+219)Gh#{e?Q18Fi2dxrpZB6k~@@LHnU}_r)m|_N)8DMTOU|tUKMj&Ql zVX>x&SsJg1>C>;Ew26QzmomW20CSTW=6Hj8t@cxVT+vEXT-m(s6ghi4$LqzFY}4jP zH*GA(!j?|{*~DzNFWdhR_5S=t82Aqsy=mo%9`!B9e-?;78Kj%kRp@W#c<_F`&&Q+~ z1K;LXvU8JgTdwo@7_B_rK;J+nnLS3HG09D4l52c4rxKpKQ?-o)mh3Tzj7t8(RMKl; za(gg%41WBg&Q{)|KT`JSVRztPp<`~JL(kK@Q0NC&nuGN5TGB}F)k*yH9a z*u9}|BneJnmQ_G8A3QhGa{w5uco%w=IJWe>ONT>}{MW0})9&R}jfJwgW08^7nPk;3 z+CrRZV#-dvS!h2CwVAL8I6K>k;BFN0Yfi_FMQ)phc6&dxOz54t#vL@1A;x0*5s|*J zJgc3KNEQe5;E-0G%yixY!PshjB3LCh9id*c#J#$1L!6GrmTvN25DuDdJcL?Dx4kgB zogb#pn;Y?r_R+kTGzO9vdY|#yQokAjq{Zvx>!S1HjRi+@MR}S)THp>bUl-0S=Z-hH z>5e_uyAH%pk@v{pHhK`^q;QZF>zibj`QyWjxyUCvD)~%Yn(m!sA9A=^pDa^_4q%ipCT1h1K1MqNasetzm%JIM=mf-47vq z4reszW-)!{q5QdPTAgtu*;xTgC0PJqPcH2#3OitFP!N1l#L^2F!^NirhC;B_VIoa{ za`D0$y2I0)z-~ylACd9C^A=z>zLBM-(rG~4i^h?QvD-h_Q54)Gz!1jrH7WCo>dd5( zhxlLf^n?BJ7KreFNA{=Mse7pWee`#&and{NU0#bSXy1OYjc%2EH!rWjr(XN?#y%wJ z)f2VZls?>ly1ft&Yquwdje8>V?#>=n-^Zy!IGqOVK7$?n`dZC`7DlsuU}Q8J%r3o7 zR&XeW#Ei0o3$yrZ2UE;27pSG-J78zjl6t59H1MRRRSGl^fFh}&P>DZ)k*@8^>h@mY zKsVjN>uGd6@bwkc%}d9AoDW^e8EnQ%C_Q_zLs+M0t|^@Rd@@bG8-21a_nSc-kHN|> z;Mfbmqo0|OL;v}kC+1B~mox7E+Jh&=wh*M)&5m7uv*;4^)^bdD#E10i5FyeLu>}lo zX)*P@K-ARRso?12sVSy3VUAnN#Jw<&KZ=rA3AsqHhl65x6mxzB$H+lN*%3-gV$*3% z`TR-r3U*_FIW2@b&`KaEr9>b_lO;wepIo<}XlEoM`&jqG>%b=ZaFG8$W3gsW&3^y@ D6q4x9 literal 0 HcmV?d00001 diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php new file mode 100644 index 000000000..72419b334 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php @@ -0,0 +1,80 @@ +createDependenciesFor('mime.attachment') + ); + + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new Attachment. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + * + * @return Swift_Mime_Attachment + */ + public static function newInstance($data = null, $filename = null, $contentType = null) + { + return new self($data, $filename, $contentType); + } + + /** + * Create a new Attachment from a filesystem path. + * + * @param string $path + * @param string $contentType optional + * + * @return Swift_Mime_Attachment + */ + public static function fromPath($path, $contentType = null) + { + return self::newInstance()->setFile( + new Swift_ByteStream_FileByteStream($path), + $contentType + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php new file mode 100644 index 000000000..c397c8bbc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -0,0 +1,179 @@ +_filters[$key] = $filter; + } + + /** + * Remove an already present StreamFilter based on its $key. + * + * @param string $key + */ + public function removeFilter($key) + { + unset($this->_filters[$key]); + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes) + { + $this->_writeBuffer .= $bytes; + foreach ($this->_filters as $filter) { + if ($filter->shouldBuffer($this->_writeBuffer)) { + return; + } + } + $this->_doWrite($this->_writeBuffer); + + return ++$this->_sequence; + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + $this->_doWrite($this->_writeBuffer); + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + if ($this->_writeBuffer !== '') { + $stream->write($this->_writeBuffer); + } + unset($this->_mirrors[$k]); + } + } + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + if ($this->_writeBuffer !== '') { + $this->_doWrite($this->_writeBuffer); + } + $this->_flush(); + + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } + + /** Run $bytes through all filters */ + private function _filter($bytes) + { + foreach ($this->_filters as $filter) { + $bytes = $filter->filter($bytes); + } + + return $bytes; + } + + /** Just write the bytes to the stream */ + private function _doWrite($bytes) + { + $this->_commit($this->_filter($bytes)); + + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + + $this->_writeBuffer = ''; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php new file mode 100644 index 000000000..561cda828 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -0,0 +1,184 @@ +_array = $stack; + $this->_arraySize = count($stack); + } elseif (is_string($stack)) { + $this->write($stack); + } else { + $this->_array = array(); + } + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_offset == $this->_arraySize) { + return false; + } + + // Don't use array slice + $end = $length + $this->_offset; + $end = $this->_arraySize < $end + ? $this->_arraySize + : $end; + $ret = ''; + for (; $this->_offset < $end; ++$this->_offset) { + $ret .= $this->_array[$this->_offset]; + } + + return $ret; + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + */ + public function write($bytes) + { + $to_add = str_split($bytes); + foreach ($to_add as $value) { + $this->_array[] = $value; + } + $this->_arraySize = count($this->_array); + + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->_mirrors[$k]); + } + } + } + + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if ($byteOffset > $this->_arraySize) { + $byteOffset = $this->_arraySize; + } elseif ($byteOffset < 0) { + $byteOffset = 0; + } + + $this->_offset = $byteOffset; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->_offset = 0; + $this->_array = array(); + $this->_arraySize = 0; + + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php new file mode 100644 index 000000000..406104371 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -0,0 +1,229 @@ +_path = $path; + $this->_mode = $writable ? 'w+b' : 'rb'; + + if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { + $this->_quotes = true; + } + } + + /** + * Get the complete path to the file. + * + * @return string + */ + public function getPath() + { + return $this->_path; + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @throws Swift_IoException + * + * @return string|bool + */ + public function read($length) + { + $fp = $this->_getReadHandle(); + if (!feof($fp)) { + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + $bytes = fread($fp, $length); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_offset = ftell($fp); + + // If we read one byte after reaching the end of the file + // feof() will return false and an empty string is returned + if ($bytes === '' && feof($fp)) { + $this->_resetReadHandle(); + + return false; + } + + return $bytes; + } + + $this->_resetReadHandle(); + + return false; + } + + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if (isset($this->_reader)) { + $this->_seekReadStreamToPosition($byteOffset); + } + $this->_offset = $byteOffset; + } + + /** Just write the bytes to the file */ + protected function _commit($bytes) + { + fwrite($this->_getWriteHandle(), $bytes); + $this->_resetReadHandle(); + } + + /** Not used */ + protected function _flush() + { + } + + /** Get the resource for reading */ + private function _getReadHandle() + { + if (!isset($this->_reader)) { + if (!$this->_reader = fopen($this->_path, 'rb')) { + throw new Swift_IoException( + 'Unable to open file for reading ['.$this->_path.']' + ); + } + if ($this->_offset != 0) { + $this->_getReadStreamSeekableStatus(); + $this->_seekReadStreamToPosition($this->_offset); + } + } + + return $this->_reader; + } + + /** Get the resource for writing */ + private function _getWriteHandle() + { + if (!isset($this->_writer)) { + if (!$this->_writer = fopen($this->_path, $this->_mode)) { + throw new Swift_IoException( + 'Unable to open file for writing ['.$this->_path.']' + ); + } + } + + return $this->_writer; + } + + /** Force a reload of the resource for reading */ + private function _resetReadHandle() + { + if (isset($this->_reader)) { + fclose($this->_reader); + $this->_reader = null; + } + } + + /** Check if ReadOnly Stream is seekable */ + private function _getReadStreamSeekableStatus() + { + $metas = stream_get_meta_data($this->_reader); + $this->_seekable = $metas['seekable']; + } + + /** Streams in a readOnly stream ensuring copy if needed */ + private function _seekReadStreamToPosition($offset) + { + if ($this->_seekable === null) { + $this->_getReadStreamSeekableStatus(); + } + if ($this->_seekable === false) { + $currentPos = ftell($this->_reader); + if ($currentPos < $offset) { + $toDiscard = $offset - $currentPos; + fread($this->_reader, $toDiscard); + + return; + } + $this->_copyReadStream(); + } + fseek($this->_reader, $offset, SEEK_SET); + } + + /** Copy a readOnly Stream to ensure seekability */ + private function _copyReadStream() + { + if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { + /* We have opened a php:// Stream Should work without problem */ + } elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { + /* We have opened a tmpfile */ + } else { + throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); + } + $currentPos = ftell($this->_reader); + fclose($this->_reader); + $source = fopen($this->_path, 'rb'); + if (!$source) { + throw new Swift_IoException('Unable to open file for copying ['.$this->_path.']'); + } + fseek($tmpFile, 0, SEEK_SET); + while (!feof($source)) { + fwrite($tmpFile, fread($source, 4096)); + } + fseek($tmpFile, $currentPos, SEEK_SET); + fclose($source); + $this->_reader = $tmpFile; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php new file mode 100644 index 000000000..1c9a80c03 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -0,0 +1,42 @@ +getPath())) === false) { + throw new Swift_IoException('Failed to get temporary file content.'); + } + + return $content; + } + + public function __destruct() + { + if (file_exists($this->getPath())) { + @unlink($this->getPath()); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php new file mode 100644 index 000000000..3d5e854a8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php @@ -0,0 +1,67 @@ + + */ +interface Swift_CharacterReader +{ + const MAP_TYPE_INVALID = 0x01; + const MAP_TYPE_FIXED_LEN = 0x02; + const MAP_TYPE_POSITIONS = 0x03; + + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars); + + /** + * Returns the mapType, see constants. + * + * @return int + */ + public function getMapType(); + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param integer[] $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size); + + /** + * Returns the number of bytes which should be read to start each character. + * + * For fixed width character sets this should be the number of octets-per-character. + * For multibyte character sets this will probably be 1. + * + * @return int + */ + public function getInitialByteSize(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php new file mode 100644 index 000000000..c1029b953 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -0,0 +1,97 @@ + + */ +class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader +{ + /** + * The number of bytes in a single character. + * + * @var int + */ + private $_width; + + /** + * Creates a new GenericFixedWidthReader using $width bytes per character. + * + * @param int $width + */ + public function __construct($width) + { + $this->_width = $width; + } + + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = strlen($string); + // % and / are CPU intensive, so, maybe find a better way + $ignored = $strlen % $this->_width; + $ignoredChars = substr($string, -$ignored); + $currentMap = $this->_width; + + return ($strlen - $ignored) / $this->_width; + } + + /** + * Returns the mapType. + * + * @return int + */ + public function getMapType() + { + return self::MAP_TYPE_FIXED_LEN; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $needed = $this->_width - $size; + + return ($needed > -1) ? $needed : -1; + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return $this->_width; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php new file mode 100644 index 000000000..ddc34ca7c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -0,0 +1,84 @@ + "\x07F") { + // Invalid char + $currentMap[$i + $startOffset] = $string[$i]; + } + } + + return $strlen; + } + + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_INVALID; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $byte = reset($bytes); + if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { + return 0; + } else { + return -1; + } + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php new file mode 100644 index 000000000..d5fa9c929 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -0,0 +1,179 @@ + + */ +class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader +{ + /** Pre-computed for optimization */ + private static $length_map = array( + // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x0N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x2N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x3N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x4N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x5N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x6N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x7N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x8N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xAN + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBN + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xCN + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDN + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEN + 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, // 0xFN + ); + + private static $s_length_map = array( + "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, + "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, + "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, + "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, + "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, + "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, + "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, + "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, + "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, + "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, + "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, + "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, + "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, + "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, + "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, + "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, + "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, + "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, + "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, + "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, + "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, + "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, + "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, + "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, + "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, + "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, + "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, + "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, + "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, + "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, + "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, + "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, + ); + + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + if (!isset($currentMap['i']) || !isset($currentMap['p'])) { + $currentMap['p'] = $currentMap['i'] = array(); + } + + $strlen = strlen($string); + $charPos = count($currentMap['p']); + $foundChars = 0; + $invalid = false; + for ($i = 0; $i < $strlen; ++$i) { + $char = $string[$i]; + $size = self::$s_length_map[$char]; + if ($size == 0) { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue; + } else { + if ($invalid == true) { + /* We mark the chars as invalid and start a new char */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; + $currentMap['i'][$charPos + $foundChars] = true; + ++$foundChars; + $invalid = false; + } + if (($i + $size) > $strlen) { + $ignoredChars = substr($string, $i); + break; + } + for ($j = 1; $j < $size; ++$j) { + $char = $string[$i + $j]; + if ($char > "\x7F" && $char < "\xC0") { + // Valid - continue parsing + } else { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue 2; + } + } + /* Ok we got a complete char here */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; + $i += $j - 1; + ++$foundChars; + } + } + + return $foundChars; + } + + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_POSITIONS; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + if ($size < 1) { + return -1; + } + $needed = self::$length_map[$bytes[0]] - $size; + + return ($needed > -1) + ? $needed + : -1 + ; + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php new file mode 100644 index 000000000..15b6c6920 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php @@ -0,0 +1,26 @@ +init(); + } + + public function __wakeup() + { + $this->init(); + } + + public function init() + { + if (count(self::$_map) > 0) { + return; + } + + $prefix = 'Swift_CharacterReader_'; + + $singleByte = array( + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(1), + ); + + $doubleByte = array( + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(2), + ); + + $fourBytes = array( + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(4), + ); + + // Utf-8 + self::$_map['utf-?8'] = array( + 'class' => $prefix.'Utf8Reader', + 'constructor' => array(), + ); + + //7-8 bit charsets + self::$_map['(us-)?ascii'] = $singleByte; + self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; + self::$_map['windows-?125[0-9]'] = $singleByte; + self::$_map['cp-?[0-9]+'] = $singleByte; + self::$_map['ansi'] = $singleByte; + self::$_map['macintosh'] = $singleByte; + self::$_map['koi-?7'] = $singleByte; + self::$_map['koi-?8-?.+'] = $singleByte; + self::$_map['mik'] = $singleByte; + self::$_map['(cork|t1)'] = $singleByte; + self::$_map['v?iscii'] = $singleByte; + + //16 bits + self::$_map['(ucs-?2|utf-?16)'] = $doubleByte; + + //32 bits + self::$_map['(ucs-?4|utf-?32)'] = $fourBytes; + + // Fallback + self::$_map['.*'] = $singleByte; + } + + /** + * Returns a CharacterReader suitable for the charset applied. + * + * @param string $charset + * + * @return Swift_CharacterReader + */ + public function getReaderFor($charset) + { + $charset = trim(strtolower($charset)); + foreach (self::$_map as $pattern => $spec) { + $re = '/^'.$pattern.'$/D'; + if (preg_match($re, $charset)) { + if (!array_key_exists($pattern, self::$_loaded)) { + $reflector = new ReflectionClass($spec['class']); + if ($reflector->getConstructor()) { + $reader = $reflector->newInstanceArgs($spec['constructor']); + } else { + $reader = $reflector->newInstance(); + } + self::$_loaded[$pattern] = $reader; + } + + return self::$_loaded[$pattern]; + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php new file mode 100644 index 000000000..717924f5d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -0,0 +1,89 @@ +setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } + + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->_charset = $charset; + $this->_charReader = null; + } + + /** + * Set the CharacterReaderFactory for multi charset support. + * + * @param Swift_CharacterReaderFactory $factory + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->_charReaderFactory = $factory; + } + + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory + ->getReaderFor($this->_charset); + } + + $startLength = $this->_charReader->getInitialByteSize(); + while (false !== $bytes = $os->read($startLength)) { + $c = array(); + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $c[] = self::$_byteMap[$bytes[$i]]; + } + $size = count($c); + $need = $this->_charReader + ->validateByteSequence($c, $size); + if ($need > 0 && + false !== $bytes = $os->read($need)) { + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $c[] = self::$_byteMap[$bytes[$i]]; + } + } + $this->_array[] = $c; + ++$this->_array_size; + } + } + + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } + + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_offset == $this->_array_size) { + return false; + } + + // Don't use array slice + $arrays = array(); + $end = $length + $this->_offset; + for ($i = $this->_offset; $i < $end; ++$i) { + if (!isset($this->_array[$i])) { + break; + } + $arrays[] = $this->_array[$i]; + } + $this->_offset += $i - $this->_offset; // Limit function calls + $chars = false; + foreach ($arrays as $array) { + $chars .= implode('', array_map('chr', $array)); + } + + return $chars; + } + + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return integer[] + */ + public function readBytes($length) + { + if ($this->_offset == $this->_array_size) { + return false; + } + $arrays = array(); + $end = $length + $this->_offset; + for ($i = $this->_offset; $i < $end; ++$i) { + if (!isset($this->_array[$i])) { + break; + } + $arrays[] = $this->_array[$i]; + } + $this->_offset += ($i - $this->_offset); // Limit function calls + + return call_user_func_array('array_merge', $arrays); + } + + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory->getReaderFor( + $this->_charset); + } + + $startLength = $this->_charReader->getInitialByteSize(); + + $fp = fopen('php://memory', 'w+b'); + fwrite($fp, $chars); + unset($chars); + fseek($fp, 0, SEEK_SET); + + $buffer = array(0); + $buf_pos = 1; + $buf_len = 1; + $has_datas = true; + do { + $bytes = array(); + // Buffer Filing + if ($buf_len - $buf_pos < $startLength) { + $buf = array_splice($buffer, $buf_pos); + $new = $this->_reloadBuffer($fp, 100); + if ($new) { + $buffer = array_merge($buf, $new); + $buf_len = count($buffer); + $buf_pos = 0; + } else { + $has_datas = false; + } + } + if ($buf_len - $buf_pos > 0) { + $size = 0; + for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { + ++$size; + $bytes[] = $buffer[$buf_pos++]; + } + $need = $this->_charReader->validateByteSequence( + $bytes, $size); + if ($need > 0) { + if ($buf_len - $buf_pos < $need) { + $new = $this->_reloadBuffer($fp, $need); + + if ($new) { + $buffer = array_merge($buffer, $new); + $buf_len = count($buffer); + } + } + for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { + $bytes[] = $buffer[$buf_pos++]; + } + } + $this->_array[] = $bytes; + ++$this->_array_size; + } + } while ($has_datas); + + fclose($fp); + } + + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($charOffset > $this->_array_size) { + $charOffset = $this->_array_size; + } elseif ($charOffset < 0) { + $charOffset = 0; + } + $this->_offset = $charOffset; + } + + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents() + { + $this->_offset = 0; + $this->_array = array(); + $this->_array_size = 0; + } + + private function _reloadBuffer($fp, $len) + { + if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) { + $buf = array(); + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $buf[] = self::$_byteMap[$bytes[$i]]; + } + + return $buf; + } + + return false; + } + + private static function _initializeMaps() + { + if (!isset(self::$_charMap)) { + self::$_charMap = array(); + for ($byte = 0; $byte < 256; ++$byte) { + self::$_charMap[$byte] = chr($byte); + } + self::$_byteMap = array_flip(self::$_charMap); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php new file mode 100644 index 000000000..7620d0e37 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -0,0 +1,275 @@ + + */ +class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream +{ + /** + * The char reader (lazy-loaded) for the current charset. + * + * @var Swift_CharacterReader + */ + private $_charReader; + + /** + * A factory for creating CharacterReader instances. + * + * @var Swift_CharacterReaderFactory + */ + private $_charReaderFactory; + + /** + * The character set this stream is using. + * + * @var string + */ + private $_charset; + + /** + * The data's stored as-is. + * + * @var string + */ + private $_datas = ''; + + /** + * Number of bytes in the stream. + * + * @var int + */ + private $_datasSize = 0; + + /** + * Map. + * + * @var mixed + */ + private $_map; + + /** + * Map Type. + * + * @var int + */ + private $_mapType = 0; + + /** + * Number of characters in the stream. + * + * @var int + */ + private $_charCount = 0; + + /** + * Position in the stream. + * + * @var int + */ + private $_currentPos = 0; + + /** + * Constructor. + * + * @param Swift_CharacterReaderFactory $factory + * @param string $charset + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } + + /* -- Changing parameters of the stream -- */ + + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->_charset = $charset; + $this->_charReader = null; + $this->_mapType = 0; + } + + /** + * Set the CharacterReaderFactory for multi charset support. + * + * @param Swift_CharacterReaderFactory $factory + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->_charReaderFactory = $factory; + } + + /** + * @see Swift_CharacterStream::flushContents() + */ + public function flushContents() + { + $this->_datas = null; + $this->_map = null; + $this->_charCount = 0; + $this->_currentPos = 0; + $this->_datasSize = 0; + } + + /** + * @see Swift_CharacterStream::importByteStream() + * + * @param Swift_OutputByteStream $os + */ + public function importByteStream(Swift_OutputByteStream $os) + { + $this->flushContents(); + $blocks = 512; + $os->setReadPointer(0); + while (false !== ($read = $os->read($blocks))) { + $this->write($read); + } + } + + /** + * @see Swift_CharacterStream::importString() + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } + + /** + * @see Swift_CharacterStream::read() + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_currentPos >= $this->_charCount) { + return false; + } + $ret = false; + $length = ($this->_currentPos + $length > $this->_charCount) + ? $this->_charCount - $this->_currentPos + : $length; + switch ($this->_mapType) { + case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: + $len = $length * $this->_map; + $ret = substr($this->_datas, + $this->_currentPos * $this->_map, + $len); + $this->_currentPos += $length; + break; + + case Swift_CharacterReader::MAP_TYPE_INVALID: + $end = $this->_currentPos + $length; + $end = $end > $this->_charCount + ? $this->_charCount + : $end; + $ret = ''; + for (; $this->_currentPos < $length; ++$this->_currentPos) { + if (isset($this->_map[$this->_currentPos])) { + $ret .= '?'; + } else { + $ret .= $this->_datas[$this->_currentPos]; + } + } + break; + + case Swift_CharacterReader::MAP_TYPE_POSITIONS: + $end = $this->_currentPos + $length; + $end = $end > $this->_charCount + ? $this->_charCount + : $end; + $ret = ''; + $start = 0; + if ($this->_currentPos > 0) { + $start = $this->_map['p'][$this->_currentPos - 1]; + } + $to = $start; + for (; $this->_currentPos < $end; ++$this->_currentPos) { + if (isset($this->_map['i'][$this->_currentPos])) { + $ret .= substr($this->_datas, $start, $to - $start).'?'; + $start = $this->_map['p'][$this->_currentPos]; + } else { + $to = $this->_map['p'][$this->_currentPos]; + } + } + $ret .= substr($this->_datas, $start, $to - $start); + break; + } + + return $ret; + } + + /** + * @see Swift_CharacterStream::readBytes() + * + * @param int $length + * + * @return integer[] + */ + public function readBytes($length) + { + $read = $this->read($length); + if ($read !== false) { + $ret = array_map('ord', str_split($read, 1)); + + return $ret; + } + + return false; + } + + /** + * @see Swift_CharacterStream::setPointer() + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($this->_charCount < $charOffset) { + $charOffset = $this->_charCount; + } + $this->_currentPos = $charOffset; + } + + /** + * @see Swift_CharacterStream::write() + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory->getReaderFor( + $this->_charset); + $this->_map = array(); + $this->_mapType = $this->_charReader->getMapType(); + } + $ignored = ''; + $this->_datas .= $chars; + $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored); + if ($ignored !== false) { + $this->_datasSize = strlen($this->_datas) - strlen($ignored); + } else { + $this->_datasSize = strlen($this->_datas); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php new file mode 100644 index 000000000..4ae5bacfc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Base class for Spools (implements time and message limits). + * + * @author Fabien Potencier + */ +abstract class Swift_ConfigurableSpool implements Swift_Spool +{ + /** The maximum number of messages to send per flush */ + private $_message_limit; + + /** The time limit per flush */ + private $_time_limit; + + /** + * Sets the maximum number of messages to send per flush. + * + * @param int $limit + */ + public function setMessageLimit($limit) + { + $this->_message_limit = (int) $limit; + } + + /** + * Gets the maximum number of messages to send per flush. + * + * @return int The limit + */ + public function getMessageLimit() + { + return $this->_message_limit; + } + + /** + * Sets the time limit (in seconds) per flush. + * + * @param int $limit The limit + */ + public function setTimeLimit($limit) + { + $this->_time_limit = (int) $limit; + } + + /** + * Gets the time limit (in seconds) per flush. + * + * @return int The limit + */ + public function getTimeLimit() + { + return $this->_time_limit; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php new file mode 100644 index 000000000..660cc84ae --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -0,0 +1,373 @@ +_store); + } + + /** + * Test if an item is registered in this container with the given name. + * + * @see register() + * + * @param string $itemName + * + * @return bool + */ + public function has($itemName) + { + return array_key_exists($itemName, $this->_store) + && isset($this->_store[$itemName]['lookupType']); + } + + /** + * Lookup the item with the given $itemName. + * + * @see register() + * + * @param string $itemName + * + * @throws Swift_DependencyException If the dependency is not found + * + * @return mixed + */ + public function lookup($itemName) + { + if (!$this->has($itemName)) { + throw new Swift_DependencyException( + 'Cannot lookup dependency "'.$itemName.'" since it is not registered.' + ); + } + + switch ($this->_store[$itemName]['lookupType']) { + case self::TYPE_ALIAS: + return $this->_createAlias($itemName); + case self::TYPE_VALUE: + return $this->_getValue($itemName); + case self::TYPE_INSTANCE: + return $this->_createNewInstance($itemName); + case self::TYPE_SHARED: + return $this->_createSharedInstance($itemName); + } + } + + /** + * Create an array of arguments passed to the constructor of $itemName. + * + * @param string $itemName + * + * @return array + */ + public function createDependenciesFor($itemName) + { + $args = array(); + if (isset($this->_store[$itemName]['args'])) { + $args = $this->_resolveArgs($this->_store[$itemName]['args']); + } + + return $args; + } + + /** + * Register a new dependency with $itemName. + * + * This method returns the current DependencyContainer instance because it + * requires the use of the fluid interface to set the specific details for the + * dependency. + * + * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() + * + * @param string $itemName + * + * @return Swift_DependencyContainer + */ + public function register($itemName) + { + $this->_store[$itemName] = array(); + $this->_endPoint = &$this->_store[$itemName]; + + return $this; + } + + /** + * Specify the previously registered item as a literal value. + * + * {@link register()} must be called before this will work. + * + * @param mixed $value + * + * @return Swift_DependencyContainer + */ + public function asValue($value) + { + $endPoint = &$this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_VALUE; + $endPoint['value'] = $value; + + return $this; + } + + /** + * Specify the previously registered item as an alias of another item. + * + * @param string $lookup + * + * @return Swift_DependencyContainer + */ + public function asAliasOf($lookup) + { + $endPoint = &$this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ALIAS; + $endPoint['ref'] = $lookup; + + return $this; + } + + /** + * Specify the previously registered item as a new instance of $className. + * + * {@link register()} must be called before this will work. + * Any arguments can be set with {@link withDependencies()}, + * {@link addConstructorValue()} or {@link addConstructorLookup()}. + * + * @see withDependencies(), addConstructorValue(), addConstructorLookup() + * + * @param string $className + * + * @return Swift_DependencyContainer + */ + public function asNewInstanceOf($className) + { + $endPoint = &$this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_INSTANCE; + $endPoint['className'] = $className; + + return $this; + } + + /** + * Specify the previously registered item as a shared instance of $className. + * + * {@link register()} must be called before this will work. + * + * @param string $className + * + * @return Swift_DependencyContainer + */ + public function asSharedInstanceOf($className) + { + $endPoint = &$this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_SHARED; + $endPoint['className'] = $className; + + return $this; + } + + /** + * Specify a list of injected dependencies for the previously registered item. + * + * This method takes an array of lookup names. + * + * @see addConstructorValue(), addConstructorLookup() + * + * @param array $lookups + * + * @return Swift_DependencyContainer + */ + public function withDependencies(array $lookups) + { + $endPoint = &$this->_getEndPoint(); + $endPoint['args'] = array(); + foreach ($lookups as $lookup) { + $this->addConstructorLookup($lookup); + } + + return $this; + } + + /** + * Specify a literal (non looked up) value for the constructor of the + * previously registered item. + * + * @see withDependencies(), addConstructorLookup() + * + * @param mixed $value + * + * @return Swift_DependencyContainer + */ + public function addConstructorValue($value) + { + $endPoint = &$this->_getEndPoint(); + if (!isset($endPoint['args'])) { + $endPoint['args'] = array(); + } + $endPoint['args'][] = array('type' => 'value', 'item' => $value); + + return $this; + } + + /** + * Specify a dependency lookup for the constructor of the previously + * registered item. + * + * @see withDependencies(), addConstructorValue() + * + * @param string $lookup + * + * @return Swift_DependencyContainer + */ + public function addConstructorLookup($lookup) + { + $endPoint = &$this->_getEndPoint(); + if (!isset($this->_endPoint['args'])) { + $endPoint['args'] = array(); + } + $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup); + + return $this; + } + + /** Get the literal value with $itemName */ + private function _getValue($itemName) + { + return $this->_store[$itemName]['value']; + } + + /** Resolve an alias to another item */ + private function _createAlias($itemName) + { + return $this->lookup($this->_store[$itemName]['ref']); + } + + /** Create a fresh instance of $itemName */ + private function _createNewInstance($itemName) + { + $reflector = new ReflectionClass($this->_store[$itemName]['className']); + if ($reflector->getConstructor()) { + return $reflector->newInstanceArgs( + $this->createDependenciesFor($itemName) + ); + } else { + return $reflector->newInstance(); + } + } + + /** Create and register a shared instance of $itemName */ + private function _createSharedInstance($itemName) + { + if (!isset($this->_store[$itemName]['instance'])) { + $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName); + } + + return $this->_store[$itemName]['instance']; + } + + /** Get the current endpoint in the store */ + private function &_getEndPoint() + { + if (!isset($this->_endPoint)) { + throw new BadMethodCallException( + 'Component must first be registered by calling register()' + ); + } + + return $this->_endPoint; + } + + /** Get an argument list with dependencies resolved */ + private function _resolveArgs(array $args) + { + $resolved = array(); + foreach ($args as $argDefinition) { + switch ($argDefinition['type']) { + case 'lookup': + $resolved[] = $this->_lookupRecursive($argDefinition['item']); + break; + case 'value': + $resolved[] = $argDefinition['item']; + break; + } + } + + return $resolved; + } + + /** Resolve a single dependency with an collections */ + private function _lookupRecursive($item) + { + if (is_array($item)) { + $collection = array(); + foreach ($item as $k => $v) { + $collection[$k] = $this->_lookupRecursive($v); + } + + return $collection; + } else { + return $this->lookup($item); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php new file mode 100644 index 000000000..799d38d83 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php @@ -0,0 +1,27 @@ +createDependenciesFor('mime.embeddedfile') + ); + + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new EmbeddedFile. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + * + * @return Swift_Mime_EmbeddedFile + */ + public static function newInstance($data = null, $filename = null, $contentType = null) + { + return new self($data, $filename, $contentType); + } + + /** + * Create a new EmbeddedFile from a filesystem path. + * + * @param string $path + * + * @return Swift_Mime_EmbeddedFile + */ + public static function fromPath($path) + { + return self::newInstance()->setFile( + new Swift_ByteStream_FileByteStream($path) + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php new file mode 100644 index 000000000..2073abca1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php @@ -0,0 +1,28 @@ += $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } + + $encodedString = base64_encode($string); + $firstLine = ''; + + if (0 != $firstLineOffset) { + $firstLine = substr( + $encodedString, 0, $maxLineLength - $firstLineOffset + )."\r\n"; + $encodedString = substr( + $encodedString, $maxLineLength - $firstLineOffset + ); + } + + return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); + } + + /** + * Does nothing. + */ + public function charsetChanged($charset) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php new file mode 100644 index 000000000..f989c8d4e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -0,0 +1,289 @@ + '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', + 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', + 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', + 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', + 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', + 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', + 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', + 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', + 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', + 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', + 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', + 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', + 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', + 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', + 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', + 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', + 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', + 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', + 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', + 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', + 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', + 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', + 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', + 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', + 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', + 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', + 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', + 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', + 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', + 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', + 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', + 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', + 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', + 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', + 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', + 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', + 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', + 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', + 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', + 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', + 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', + 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', + 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', + 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', + 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', + 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', + 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', + 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', + 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', + 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', + 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', + 255 => '=FF', + ); + + protected static $_safeMapShare = array(); + + /** + * A map of non-encoded ascii characters. + * + * @var string[] + */ + protected $_safeMap = array(); + + /** + * Creates a new QpEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if input should be canonicalized + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) + { + $this->_charStream = $charStream; + if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + } else { + $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + } + $this->_filter = $filter; + } + + public function __sleep() + { + return array('_charStream', '_filter'); + } + + public function __wakeup() + { + if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + } else { + $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + } + } + + protected function getSafeMapShareId() + { + return get_class($this); + } + + protected function initSafeMap() + { + foreach (array_merge( + array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { + $this->_safeMap[$byte] = chr($byte); + } + } + + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset, optional + * @param int $maxLineLength, optional 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } + + $thisLineLength = $maxLineLength - $firstLineOffset; + + $lines = array(); + $lNo = 0; + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $size = $lineLen = 0; + + $this->_charStream->flushContents(); + $this->_charStream->importString($string); + + // Fetching more than 4 chars at one is slower, as is fetching fewer bytes + // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 + // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes + while (false !== $bytes = $this->_nextSequence()) { + // If we're filtering the input + if (isset($this->_filter)) { + // If we can't filter because we need more bytes + while ($this->_filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->_nextSequence(1)) { + break; + } + + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->_filter->filter($bytes); + } + + $enc = $this->_encodeByteSequence($bytes, $size); + if ($currentLine && $lineLen + $size >= $thisLineLength) { + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } + $lineLen += $size; + $currentLine .= $enc; + } + + return $this->_standardize(implode("=\r\n", $lines)); + } + + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charStream->setCharacterSet($charset); + } + + /** + * Encode the given byte array into a verbatim QP form. + * + * @param integer[] $bytes + * @param int $size + * + * @return string + */ + protected function _encodeByteSequence(array $bytes, &$size) + { + $ret = ''; + $size = 0; + foreach ($bytes as $b) { + if (isset($this->_safeMap[$b])) { + $ret .= $this->_safeMap[$b]; + ++$size; + } else { + $ret .= self::$_qpMap[$b]; + $size += 3; + } + } + + return $ret; + } + + /** + * Get the next sequence of bytes to read from the char stream. + * + * @param int $size number of bytes to read + * + * @return integer[] + */ + protected function _nextSequence($size = 4) + { + return $this->_charStream->readBytes($size); + } + + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function _standardize($string) + { + $string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), + array("=09\r\n", "=20\r\n", "\r\n"), $string + ); + switch ($end = ord(substr($string, -1))) { + case 0x09: + case 0x20: + $string = substr_replace($string, self::$_qpMap[$end], -1); + } + + return $string; + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_charStream = clone $this->_charStream; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php new file mode 100644 index 000000000..b0215e883 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -0,0 +1,92 @@ +_charStream = $charStream; + } + + /** + * Takes an unencoded string and produces a string encoded according to + * RFC 2231 from it. + * + * @param string $string + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 75 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + $lines = array(); + $lineCount = 0; + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + + if (0 >= $maxLineLength) { + $maxLineLength = 75; + } + + $this->_charStream->flushContents(); + $this->_charStream->importString($string); + + $thisLineLength = $maxLineLength - $firstLineOffset; + + while (false !== $char = $this->_charStream->read(4)) { + $encodedChar = rawurlencode($char); + if (0 != strlen($currentLine) + && strlen($currentLine.$encodedChar) > $thisLineLength) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + $thisLineLength = $maxLineLength; + } + $currentLine .= $encodedChar; + } + + return implode("\r\n", $lines); + } + + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charStream->setCharacterSet($charset); + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_charStream = clone $this->_charStream; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php new file mode 100644 index 000000000..253977b60 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php @@ -0,0 +1,64 @@ +lookup($key); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php new file mode 100644 index 000000000..7dc381d98 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -0,0 +1,65 @@ +_command = $command; + $this->_successCodes = $successCodes; + } + + /** + * Get the command which was sent to the server. + * + * @return string + */ + public function getCommand() + { + return $this->_command; + } + + /** + * Get the numeric response codes which indicate success for this command. + * + * @return integer[] + */ + public function getSuccessCodes() + { + return $this->_successCodes; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php new file mode 100644 index 000000000..7545404e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -0,0 +1,24 @@ +_source = $source; + } + + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource() + { + return $this->_source; + } + + /** + * Prevent this Event from bubbling any further up the stack. + * + * @param bool $cancel, optional + */ + public function cancelBubble($cancel = true) + { + $this->_bubbleCancelled = $cancel; + } + + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled() + { + return $this->_bubbleCancelled; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php new file mode 100644 index 000000000..2e92ba940 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -0,0 +1,65 @@ +_response = $response; + $this->_valid = $valid; + } + + /** + * Get the response which was received from the server. + * + * @return string + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Get the success status of this Event. + * + * @return bool + */ + public function isValid() + { + return $this->_valid; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php new file mode 100644 index 000000000..c40919d21 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -0,0 +1,24 @@ +_message = $message; + $this->_result = self::RESULT_PENDING; + } + + /** + * Get the Transport used to send the Message. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } + + /** + * Get the Message being sent. + * + * @return Swift_Mime_Message + */ + public function getMessage() + { + return $this->_message; + } + + /** + * Set the array of addresses that failed in sending. + * + * @param array $recipients + */ + public function setFailedRecipients($recipients) + { + $this->_failedRecipients = $recipients; + } + + /** + * Get an recipient addresses which were not accepted for delivery. + * + * @return string[] + */ + public function getFailedRecipients() + { + return $this->_failedRecipients; + } + + /** + * Set the result of sending. + * + * @param int $result + */ + public function setResult($result) + { + $this->_result = $result; + } + + /** + * Get the result of this Event. + * + * The return value is a bitmask from + * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} + * + * @return int + */ + public function getResult() + { + return $this->_result; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php new file mode 100644 index 000000000..d922e1bfa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -0,0 +1,31 @@ +_eventMap = array( + 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', + 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', + 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', + 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', + ); + } + + /** + * Create a new SendEvent for $source and $message. + * + * @param Swift_Transport $source + * @param Swift_Mime_Message + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message) + { + return new Swift_Events_SendEvent($source, $message); + } + + /** + * Create a new CommandEvent for $source and $command. + * + * @param Swift_Transport $source + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } + + /** + * Create a new ResponseEvent for $source and $response. + * + * @param Swift_Transport $source + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid) + { + return new Swift_Events_ResponseEvent($source, $response, $valid); + } + + /** + * Create a new TransportChangeEvent for $source. + * + * @param Swift_Transport $source + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } + + /** + * Create a new TransportExceptionEvent for $source. + * + * @param Swift_Transport $source + * @param Swift_TransportException $ex + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($source, $ex); + } + + /** + * Bind an event listener to this dispatcher. + * + * @param Swift_Events_EventListener $listener + */ + public function bindEventListener(Swift_Events_EventListener $listener) + { + foreach ($this->_listeners as $l) { + // Already loaded + if ($l === $listener) { + return; + } + } + $this->_listeners[] = $listener; + } + + /** + * Dispatch the given Event to all suitable listeners. + * + * @param Swift_Events_EventObject $evt + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target) + { + $this->_prepareBubbleQueue($evt); + $this->_bubble($evt, $target); + } + + /** Queue listeners on a stack ready for $evt to be bubbled up it */ + private function _prepareBubbleQueue(Swift_Events_EventObject $evt) + { + $this->_bubbleQueue = array(); + $evtClass = get_class($evt); + foreach ($this->_listeners as $listener) { + if (array_key_exists($evtClass, $this->_eventMap) + && ($listener instanceof $this->_eventMap[$evtClass])) { + $this->_bubbleQueue[] = $listener; + } + } + } + + /** Bubble $evt up the stack calling $target() on each listener */ + private function _bubble(Swift_Events_EventObject $evt, $target) + { + if (!$evt->bubbleCancelled() && $listener = array_shift($this->_bubbleQueue)) { + $listener->$target($evt); + $this->_bubble($evt, $target); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php new file mode 100644 index 000000000..a8972fda9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php @@ -0,0 +1,27 @@ +getSource(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php new file mode 100644 index 000000000..253165de8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -0,0 +1,45 @@ +_exception = $ex; + } + + /** + * Get the TransportException thrown. + * + * @return Swift_TransportException + */ + public function getException() + { + return $this->_exception; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php new file mode 100644 index 000000000..cc3c09937 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -0,0 +1,24 @@ +createDependenciesFor('transport.failover') + ); + + $this->setTransports($transports); + } + + /** + * Create a new FailoverTransport instance. + * + * @param Swift_Transport[] $transports + * + * @return Swift_FailoverTransport + */ + public static function newInstance($transports = array()) + { + return new self($transports); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php new file mode 100644 index 000000000..220853989 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php @@ -0,0 +1,208 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages on the filesystem. + * + * @author Fabien Potencier + * @author Xavier De Cock + */ +class Swift_FileSpool extends Swift_ConfigurableSpool +{ + /** The spool directory */ + private $_path; + + /** + * File WriteRetry Limit. + * + * @var int + */ + private $_retryLimit = 10; + + /** + * Create a new FileSpool. + * + * @param string $path + * + * @throws Swift_IoException + */ + public function __construct($path) + { + $this->_path = $path; + + if (!file_exists($this->_path)) { + if (!mkdir($this->_path, 0777, true)) { + throw new Swift_IoException('Unable to create Path ['.$this->_path.']'); + } + } + } + + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Spool mechanism. + */ + public function start() + { + } + + /** + * Stops this Spool mechanism. + */ + public function stop() + { + } + + /** + * Allow to manage the enqueuing retry limit. + * + * Default, is ten and allows over 64^20 different fileNames + * + * @param int $limit + */ + public function setRetryLimit($limit) + { + $this->_retryLimit = $limit; + } + + /** + * Queues a message. + * + * @param Swift_Mime_Message $message The message to store + * + * @throws Swift_IoException + * + * @return bool + */ + public function queueMessage(Swift_Mime_Message $message) + { + $ser = serialize($message); + $fileName = $this->_path.'/'.$this->getRandomString(10); + for ($i = 0; $i < $this->_retryLimit; ++$i) { + /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ + $fp = @fopen($fileName.'.message', 'x'); + if (false !== $fp) { + if (false === fwrite($fp, $ser)) { + return false; + } + + return fclose($fp); + } else { + /* The file already exists, we try a longer fileName */ + $fileName .= $this->getRandomString(1); + } + } + + throw new Swift_IoException('Unable to create a file for enqueuing Message'); + } + + /** + * Execute a recovery if for any reason a process is sending for too long. + * + * @param int $timeout in second Defaults is for very slow smtp responses + */ + public function recover($timeout = 900) + { + foreach (new DirectoryIterator($this->_path) as $file) { + $file = $file->getRealPath(); + + if (substr($file, -16) == '.message.sending') { + $lockedtime = filectime($file); + if ((time() - $lockedtime) > $timeout) { + rename($file, substr($file, 0, -8)); + } + } + } + } + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + $directoryIterator = new DirectoryIterator($this->_path); + + /* Start the transport only if there are queued files to send */ + if (!$transport->isStarted()) { + foreach ($directoryIterator as $file) { + if (substr($file->getRealPath(), -8) == '.message') { + $transport->start(); + break; + } + } + } + + $failedRecipients = (array) $failedRecipients; + $count = 0; + $time = time(); + foreach ($directoryIterator as $file) { + $file = $file->getRealPath(); + + if (substr($file, -8) != '.message') { + continue; + } + + /* We try a rename, it's an atomic operation, and avoid locking the file */ + if (rename($file, $file.'.sending')) { + $message = unserialize(file_get_contents($file.'.sending')); + + $count += $transport->send($message, $failedRecipients); + + unlink($file.'.sending'); + } else { + /* This message has just been catched by another process */ + continue; + } + + if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { + break; + } + + if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { + break; + } + } + + return $count; + } + + /** + * Returns a random string needed to generate a fileName for the queue. + * + * @param int $count + * + * @return string + */ + protected function getRandomString($count) + { + // This string MUST stay FS safe, avoid special chars + $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; + $ret = ''; + $strlen = strlen($base); + for ($i = 0; $i < $count; ++$i) { + $ret .= $base[((int) rand(0, $strlen - 1))]; + } + + return $ret; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php new file mode 100644 index 000000000..0b24db1ce --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php @@ -0,0 +1,24 @@ +setFile( + new Swift_ByteStream_FileByteStream($path) + ); + + return $image; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php new file mode 100644 index 000000000..56efc7593 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -0,0 +1,75 @@ +_stream = $stream; + } + + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->_contents[$nsKey][$itemKey] = $string; + break; + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->_contents[$nsKey][$itemKey] = ''; + } + $this->_contents[$nsKey][$itemKey] .= $string; + break; + default: + throw new Swift_SwiftException( + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey + ); + } + } + + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_OutputByteStream $os + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->clearKey($nsKey, $itemKey); + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->_contents[$nsKey][$itemKey] = ''; + } + while (false !== $bytes = $os->read(8192)) { + $this->_contents[$nsKey][$itemKey] .= $bytes; + } + break; + default: + throw new Swift_SwiftException( + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey + ); + } + } + + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $writeThrough + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->_stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } + + return $is; + } + + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + return $this->_contents[$nsKey][$itemKey]; + } + } + + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + $this->_prepareCache($nsKey); + $is->write($this->getString($nsKey, $itemKey)); + } + + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + + return array_key_exists($itemKey, $this->_contents[$nsKey]); + } + + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + unset($this->_contents[$nsKey][$itemKey]); + } + + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + unset($this->_contents[$nsKey]); + } + + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function _prepareCache($nsKey) + { + if (!array_key_exists($nsKey, $this->_contents)) { + $this->_contents[$nsKey] = array(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php new file mode 100644 index 000000000..dc1515abb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -0,0 +1,324 @@ +_stream = $stream; + $this->_path = $path; + + if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { + $this->_quotes = true; + } + } + + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + * + * @throws Swift_IoException + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException( + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey + ); + break; + } + fwrite($fp, $string); + $this->_freeHandle($nsKey, $itemKey); + } + + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_OutputByteStream $os + * @param int $mode + * + * @throws Swift_IoException + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException( + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey + ); + break; + } + while (false !== $bytes = $os->read(8192)) { + fwrite($fp, $bytes); + } + $this->_freeHandle($nsKey, $itemKey); + } + + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $writeThrough + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->_stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } + + return $is; + } + + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @throws Swift_IoException + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + $str = ''; + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $str .= $bytes; + } + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_freeHandle($nsKey, $itemKey); + + return $str; + } + } + + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $is->write($bytes); + } + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_freeHandle($nsKey, $itemKey); + } + } + + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return is_file($this->_path.'/'.$nsKey.'/'.$itemKey); + } + + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + if ($this->hasKey($nsKey, $itemKey)) { + $this->_freeHandle($nsKey, $itemKey); + unlink($this->_path.'/'.$nsKey.'/'.$itemKey); + } + } + + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + if (array_key_exists($nsKey, $this->_keys)) { + foreach ($this->_keys[$nsKey] as $itemKey => $null) { + $this->clearKey($nsKey, $itemKey); + } + if (is_dir($this->_path.'/'.$nsKey)) { + rmdir($this->_path.'/'.$nsKey); + } + unset($this->_keys[$nsKey]); + } + } + + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function _prepareCache($nsKey) + { + $cacheDir = $this->_path.'/'.$nsKey; + if (!is_dir($cacheDir)) { + if (!mkdir($cacheDir)) { + throw new Swift_IoException('Failed to create cache directory '.$cacheDir); + } + $this->_keys[$nsKey] = array(); + } + } + + /** + * Get a file handle on the cache item. + * + * @param string $nsKey + * @param string $itemKey + * @param int $position + * + * @return resource + */ + private function _getHandle($nsKey, $itemKey, $position) + { + if (!isset($this->_keys[$nsKey][$itemKey])) { + $openMode = $this->hasKey($nsKey, $itemKey) + ? 'r+b' + : 'w+b' + ; + $fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode); + $this->_keys[$nsKey][$itemKey] = $fp; + } + if (self::POSITION_START == $position) { + fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET); + } elseif (self::POSITION_END == $position) { + fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END); + } + + return $this->_keys[$nsKey][$itemKey]; + } + + private function _freeHandle($nsKey, $itemKey) + { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_CURRENT); + fclose($fp); + $this->_keys[$nsKey][$itemKey] = null; + } + + /** + * Destructor. + */ + public function __destruct() + { + foreach ($this->_keys as $nsKey => $null) { + $this->clearAll($nsKey); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php new file mode 100644 index 000000000..af80bdca6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -0,0 +1,51 @@ +_keyCache = $keyCache; + } + + /** + * Specify a stream to write through for each write(). + * + * @param Swift_InputByteStream $is + */ + public function setWriteThroughStream(Swift_InputByteStream $is) + { + $this->_writeThrough = $is; + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * @param Swift_InputByteStream $is optional + */ + public function write($bytes, Swift_InputByteStream $is = null) + { + $this->_keyCache->setString( + $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND + ); + if (isset($is)) { + $is->write($bytes); + } + if (isset($this->_writeThrough)) { + $this->_writeThrough->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Not used. + */ + public function bind(Swift_InputByteStream $is) + { + } + + /** + * Not used. + */ + public function unbind(Swift_InputByteStream $is) + { + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->_keyCache->clearKey($this->_nsKey, $this->_itemKey); + } + + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey) + { + $this->_nsKey = $nsKey; + } + + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey) + { + $this->_itemKey = $itemKey; + } + + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone() + { + $this->_writeThrough = null; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php new file mode 100644 index 000000000..fdba9df50 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -0,0 +1,45 @@ +createDependenciesFor('transport.loadbalanced') + ); + + $this->setTransports($transports); + } + + /** + * Create a new LoadBalancedTransport instance. + * + * @param array $transports + * + * @return Swift_LoadBalancedTransport + */ + public static function newInstance($transports = array()) + { + return new self($transports); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php new file mode 100644 index 000000000..858ca8147 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php @@ -0,0 +1,45 @@ +createDependenciesFor('transport.mail') + ); + + $this->setExtraParams($extraParams); + } + + /** + * Create a new MailTransport instance. + * + * @param string $extraParams To be passed to mail() + * + * @return Swift_MailTransport + */ + public static function newInstance($extraParams = '-f%s') + { + return new self($extraParams); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php new file mode 100644 index 000000000..34a78d47b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php @@ -0,0 +1,114 @@ +_transport = $transport; + } + + /** + * Create a new Mailer instance. + * + * @param Swift_Transport $transport + * + * @return Swift_Mailer + */ + public static function newInstance(Swift_Transport $transport) + { + return new self($transport); + } + + /** + * Create a new class instance of one of the message services. + * + * For example 'mimepart' would create a 'message.mimepart' instance + * + * @param string $service + * + * @return object + */ + public function createMessage($service = 'message') + { + return Swift_DependencyContainer::getInstance() + ->lookup('message.'.$service); + } + + /** + * Send the given Message like it would be sent in a mail client. + * + * All recipients (with the exception of Bcc) will be able to see the other + * recipients this message was sent to. + * + * Recipient/sender data will be retrieved from the Message object. + * + * The return value is the number of recipients who were accepted for + * delivery. + * + * @param Swift_Mime_Message $message + * @param array $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + + if (!$this->_transport->isStarted()) { + $this->_transport->start(); + } + + $sent = 0; + + try { + $sent = $this->_transport->send($message, $failedRecipients); + } catch (Swift_RfcComplianceException $e) { + foreach ($message->getTo() as $address => $name) { + $failedRecipients[] = $address; + } + } + + return $sent; + } + + /** + * Register a plugin using a known unique key (e.g. myPlugin). + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_transport->registerPlugin($plugin); + } + + /** + * The Transport used to send messages. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->_transport; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php new file mode 100644 index 000000000..e3e6cad05 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -0,0 +1,55 @@ +_recipients = $recipients; + } + + /** + * Returns true only if there are more recipients to send to. + * + * @return bool + */ + public function hasNext() + { + return !empty($this->_recipients); + } + + /** + * Returns an array where the keys are the addresses of recipients and the + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). + * + * @return array + */ + public function nextRecipient() + { + return array_splice($this->_recipients, 0, 1); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php new file mode 100644 index 000000000..650f3ec3d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php @@ -0,0 +1,32 @@ + 'Foo') or ('foo@bar' => NULL). + * + * @return array + */ + public function nextRecipient(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php new file mode 100644 index 000000000..5b239694d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in memory. + * + * @author Fabien Potencier + */ +class Swift_MemorySpool implements Swift_Spool +{ + protected $messages = array(); + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Stores a message in the queue. + * + * @param Swift_Mime_Message $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_Message $message) + { + //clone the message to make sure it is not changed while in the queue + $this->messages[] = clone $message; + + return true; + } + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + if (!$this->messages) { + return 0; + } + + if (!$transport->isStarted()) { + $transport->start(); + } + + $count = 0; + while ($message = array_pop($this->messages)) { + $count += $transport->send($message, $failedRecipients); + } + + return $count; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php new file mode 100644 index 000000000..11aa5a9a0 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php @@ -0,0 +1,291 @@ +createDependenciesFor('mime.message') + ); + + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setSubject($subject); + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new Message. + * + * @param string $subject + * @param string $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Message + */ + public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) + { + return new self($subject, $body, $contentType, $charset); + } + + /** + * Add a MimePart to this Message. + * + * @param string|Swift_OutputByteStream $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Mime_SimpleMessage + */ + public function addPart($body, $contentType = null, $charset = null) + { + return $this->attach(Swift_MimePart::newInstance( + $body, $contentType, $charset + )); + } + + /** + * Attach a new signature handler to the message. + * + * @param Swift_Signer $signer + * + * @return Swift_Message + */ + public function attachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + $this->headerSigners[] = $signer; + } elseif ($signer instanceof Swift_Signers_BodySigner) { + $this->bodySigners[] = $signer; + } + + return $this; + } + + /** + * Attach a new signature handler to the message. + * + * @param Swift_Signer $signer + * + * @return Swift_Message + */ + public function detachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + foreach ($this->headerSigners as $k => $headerSigner) { + if ($headerSigner === $signer) { + unset($this->headerSigners[$k]); + + return $this; + } + } + } elseif ($signer instanceof Swift_Signers_BodySigner) { + foreach ($this->bodySigners as $k => $bodySigner) { + if ($bodySigner === $signer) { + unset($this->bodySigners[$k]); + + return $this; + } + } + } + + return $this; + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + return parent::toString(); + } + + $this->saveMessage(); + + $this->doSign(); + + $string = parent::toString(); + + $this->restoreMessage(); + + return $string; + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream $is + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + parent::toByteStream($is); + + return; + } + + $this->saveMessage(); + + $this->doSign(); + + parent::toByteStream($is); + + $this->restoreMessage(); + } + + public function __wakeup() + { + Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); + } + + /** + * loops through signers and apply the signatures. + */ + protected function doSign() + { + foreach ($this->bodySigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->signMessage($this); + } + + foreach ($this->headerSigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->reset(); + + $signer->setHeaders($this->getHeaders()); + + $signer->startBody(); + $this->_bodyToByteStream($signer); + $signer->endBody(); + + $signer->addSignature($this->getHeaders()); + } + } + + /** + * save the message before any signature is applied. + */ + protected function saveMessage() + { + $this->savedMessage = array('headers' => array()); + $this->savedMessage['body'] = $this->getBody(); + $this->savedMessage['children'] = $this->getChildren(); + if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children'])); + $this->setBody(''); + } + } + + /** + * save the original headers. + * + * @param array $altered + */ + protected function saveHeaders(array $altered) + { + foreach ($altered as $head) { + $lc = strtolower($head); + + if (!isset($this->savedMessage['headers'][$lc])) { + $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); + } + } + } + + /** + * Remove or restore altered headers. + */ + protected function restoreHeaders() + { + foreach ($this->savedMessage['headers'] as $name => $savedValue) { + $headers = $this->getHeaders()->getAll($name); + + foreach ($headers as $key => $value) { + if (!isset($savedValue[$key])) { + $this->getHeaders()->remove($name, $key); + } + } + } + } + + /** + * Restore message body. + */ + protected function restoreMessage() + { + $this->setBody($this->savedMessage['body']); + $this->setChildren($this->savedMessage['children']); + + $this->restoreHeaders(); + $this->savedMessage = array(); + } + + /** + * Clone Message Signers. + * + * @see Swift_Mime_SimpleMimeEntity::__clone() + */ + public function __clone() + { + parent::__clone(); + foreach ($this->bodySigners as $key => $bodySigner) { + $this->bodySigners[$key] = clone($bodySigner); + } + + foreach ($this->headerSigners as $key => $headerSigner) { + $this->headerSigners[$key] = clone($headerSigner); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php new file mode 100644 index 000000000..0a72606d9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -0,0 +1,153 @@ +setDisposition('attachment'); + $this->setContentType('application/octet-stream'); + $this->_mimeTypes = $mimeTypes; + } + + /** + * Get the nesting level used for this attachment. + * + * Always returns {@link LEVEL_MIXED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_MIXED; + } + + /** + * Get the Content-Disposition of this attachment. + * + * By default attachments have a disposition of "attachment". + * + * @return string + */ + public function getDisposition() + { + return $this->_getHeaderFieldModel('Content-Disposition'); + } + + /** + * Set the Content-Disposition of this attachment. + * + * @param string $disposition + * + * @return Swift_Mime_Attachment + */ + public function setDisposition($disposition) + { + if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { + $this->getHeaders()->addParameterizedHeader( + 'Content-Disposition', $disposition + ); + } + + return $this; + } + + /** + * Get the filename of this attachment when downloaded. + * + * @return string + */ + public function getFilename() + { + return $this->_getHeaderParameter('Content-Disposition', 'filename'); + } + + /** + * Set the filename of this attachment. + * + * @param string $filename + * + * @return Swift_Mime_Attachment + */ + public function setFilename($filename) + { + $this->_setHeaderParameter('Content-Disposition', 'filename', $filename); + $this->_setHeaderParameter('Content-Type', 'name', $filename); + + return $this; + } + + /** + * Get the file size of this attachment. + * + * @return int + */ + public function getSize() + { + return $this->_getHeaderParameter('Content-Disposition', 'size'); + } + + /** + * Set the file size of this attachment. + * + * @param int $size + * + * @return Swift_Mime_Attachment + */ + public function setSize($size) + { + $this->_setHeaderParameter('Content-Disposition', 'size', $size); + + return $this; + } + + /** + * Set the file that this attachment is for. + * + * @param Swift_FileStream $file + * @param string $contentType optional + * + * @return Swift_Mime_Attachment + */ + public function setFile(Swift_FileStream $file, $contentType = null) + { + $this->setFilename(basename($file->getPath())); + $this->setBody($file, $contentType); + if (!isset($contentType)) { + $extension = strtolower(substr( + $file->getPath(), strrpos($file->getPath(), '.') + 1 + )); + + if (array_key_exists($extension, $this->_mimeTypes)) { + $this->setContentType($this->_mimeTypes[$extension]); + } + } + + return $this; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php new file mode 100644 index 000000000..b49c3a873 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php @@ -0,0 +1,24 @@ += $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } + + $remainder = 0; + $base64ReadBufferRemainderBytes = null; + + // To reduce memory usage, the output buffer is streamed to the input buffer like so: + // Output Stream => base64encode => wrap line length => Input Stream + // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) + // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. + // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the + // chunk of bytes read in the next iteration. + // When the OutputStream is empty, we must flush any remainder bytes. + while (true) { + $readBytes = $os->read(8192); + $atEOF = ($readBytes === false); + + if ($atEOF) { + $streamTheseBytes = $base64ReadBufferRemainderBytes; + } else { + $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; + } + $base64ReadBufferRemainderBytes = null; + $bytesLength = strlen($streamTheseBytes); + + if ($bytesLength === 0) { // no data left to encode + break; + } + + // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data + // and carry over remainder 1-2 bytes to the next loop iteration + if (!$atEOF) { + $excessBytes = $bytesLength % 3; + if ($excessBytes !== 0) { + $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); + $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); + } + } + + $encoded = base64_encode($streamTheseBytes); + $encodedTransformed = ''; + $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; + + while ($thisMaxLineLength < strlen($encoded)) { + $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; + $firstLineOffset = 0; + $encoded = substr($encoded, $thisMaxLineLength); + $thisMaxLineLength = $maxLineLength; + $remainder = 0; + } + + if (0 < $remainingLength = strlen($encoded)) { + $remainder += $remainingLength; + $encodedTransformed .= $encoded; + $encoded = null; + } + + $is->write($encodedTransformed); + + if ($atEOF) { + break; + } + } + } + + /** + * Get the name of this encoding scheme. + * Returns the string 'base64'. + * + * @return string + */ + public function getName() + { + return 'base64'; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php new file mode 100644 index 000000000..710b5ac9e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -0,0 +1,123 @@ +charset = $charset ? $charset : 'utf-8'; + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } + + /** + * Encode $in to $out. + * + * @param Swift_OutputByteStream $os to read from + * @param Swift_InputByteStream $is to write to + * @param int $firstLineOffset + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->charset !== 'utf-8') { + throw new RuntimeException( + sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } + + $string = ''; + + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + $is->write($this->encodeString($string)); + } + + /** + * Get the MIME name of this content encoding scheme. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } + + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->charset !== 'utf-8') { + throw new RuntimeException( + sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } + + return $this->_standardize(quoted_printable_encode($string)); + } + + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function _standardize($string) + { + // transform CR or LF to CRLF + $string = preg_replace('~=0D(?!=0A)|(?_name = $name; + $this->_canonical = $canonical; + } + + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength - 0 means no wrapping will occur + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->_canonical) { + $string = $this->_canonicalize($string); + } + + return $this->_safeWordWrap($string, $maxLineLength, "\r\n"); + } + + /** + * Encode stream $in to stream $out. + * + * @param Swift_OutputByteStream $os + * @param Swift_InputByteStream $is + * @param int $firstLineOffset ignored + * @param int $maxLineLength optional, 0 means no wrapping will occur + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $leftOver = ''; + while (false !== $bytes = $os->read(8192)) { + $toencode = $leftOver.$bytes; + if ($this->_canonical) { + $toencode = $this->_canonicalize($toencode); + } + $wrapped = $this->_safeWordWrap($toencode, $maxLineLength, "\r\n"); + $lastLinePos = strrpos($wrapped, "\r\n"); + $leftOver = substr($wrapped, $lastLinePos); + $wrapped = substr($wrapped, 0, $lastLinePos); + + $is->write($wrapped); + } + if (strlen($leftOver)) { + $is->write($leftOver); + } + } + + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->_name; + } + + /** + * Not used. + */ + public function charsetChanged($charset) + { + } + + /** + * A safer (but weaker) wordwrap for unicode. + * + * @param string $string + * @param int $length + * @param string $le + * + * @return string + */ + private function _safeWordwrap($string, $length = 75, $le = "\r\n") + { + if (0 >= $length) { + return $string; + } + + $originalLines = explode($le, $string); + + $lines = array(); + $lineCount = 0; + + foreach ($originalLines as $originalLine) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + + //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); + $chunks = preg_split('/(?<=\s)/', $originalLine); + + foreach ($chunks as $chunk) { + if (0 != strlen($currentLine) + && strlen($currentLine.$chunk) > $length) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + } + $currentLine .= $chunk; + } + } + + return implode("\r\n", $lines); + } + + /** + * Canonicalize string input (fix CRLF). + * + * @param string $string + * + * @return string + */ + private function _canonicalize($string) + { + return str_replace( + array("\r\n", "\r", "\n"), + array("\n", "\n", "\r\n"), + $string + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php new file mode 100644 index 000000000..8ee4c755e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -0,0 +1,123 @@ +_dotEscape = $dotEscape; + parent::__construct($charStream, $filter); + } + + public function __sleep() + { + return array('_charStream', '_filter', '_dotEscape'); + } + + protected function getSafeMapShareId() + { + return get_class($this).($this->_dotEscape ? '.dotEscape' : ''); + } + + protected function initSafeMap() + { + parent::initSafeMap(); + if ($this->_dotEscape) { + /* Encode . as =2e for buggy remote servers */ + unset($this->_safeMap[0x2e]); + } + } + + /** + * Encode stream $in to stream $out. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param Swift_OutputByteStream $os output stream + * @param Swift_InputByteStream $is input stream + * @param int $firstLineOffset + * @param int $maxLineLength + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } + + $thisLineLength = $maxLineLength - $firstLineOffset; + + $this->_charStream->flushContents(); + $this->_charStream->importByteStream($os); + + $currentLine = ''; + $prepend = ''; + $size = $lineLen = 0; + + while (false !== $bytes = $this->_nextSequence()) { + // If we're filtering the input + if (isset($this->_filter)) { + // If we can't filter because we need more bytes + while ($this->_filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->_nextSequence(1)) { + break; + } + + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->_filter->filter($bytes); + } + + $enc = $this->_encodeByteSequence($bytes, $size); + if ($currentLine && $lineLen + $size >= $thisLineLength) { + $is->write($prepend.$this->_standardize($currentLine)); + $currentLine = ''; + $prepend = "=\r\n"; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } + $lineLen += $size; + $currentLine .= $enc; + } + if (strlen($currentLine)) { + $is->write($prepend.$this->_standardize($currentLine)); + } + } + + /** + * Get the name of this encoding scheme. + * Returns the string 'quoted-printable'. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php new file mode 100644 index 000000000..8113e52dc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -0,0 +1,97 @@ + + */ +class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder +{ + /** + * @var Swift_Mime_ContentEncoder_QpContentEncoder + */ + private $safeEncoder; + + /** + * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder + */ + private $nativeEncoder; + + /** + * @var null|string + */ + private $charset; + + /** + * Constructor. + * + * @param Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder + * @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder + * @param string|null $charset + */ + public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) + { + $this->safeEncoder = $safeEncoder; + $this->nativeEncoder = $nativeEncoder; + $this->charset = $charset; + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->safeEncoder = clone $this->safeEncoder; + $this->nativeEncoder = clone $this->nativeEncoder; + } + + /** + * {@inheritdoc} + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } + + /** + * {@inheritdoc} + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'quoted-printable'; + } + + /** + * {@inheritdoc} + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); + } + + /** + * @return Swift_Mime_ContentEncoder + */ + private function getEncoder() + { + return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php new file mode 100644 index 000000000..0b8526e38 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -0,0 +1,64 @@ + + */ +class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder +{ + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } + + /** + * Encode stream $in to stream $out. + * + * @param Swift_OutputByteStream $in + * @param Swift_InputByteStream $out + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } + + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return 'raw'; + } + + /** + * Not used. + */ + public function charsetChanged($charset) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php new file mode 100644 index 000000000..6af757124 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -0,0 +1,45 @@ +setDisposition('inline'); + $this->setId($this->getId()); + } + + /** + * Get the nesting level of this EmbeddedFile. + * + * Returns {@see LEVEL_RELATED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_RELATED; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php new file mode 100644 index 000000000..cc44a6efb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -0,0 +1,24 @@ +init(); + } + + public function __wakeup() + { + $this->init(); + } + + protected function init() + { + if (count(self::$_specials) > 0) { + return; + } + + self::$_specials = array( + '(', ')', '<', '>', '[', ']', + ':', ';', '@', ',', '.', '"', + ); + + /*** Refer to RFC 2822 for ABNF grammar ***/ + + // All basic building blocks + self::$_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]'; + self::$_grammar['WSP'] = '[ \t]'; + self::$_grammar['CRLF'] = '(?:\r\n)'; + self::$_grammar['FWS'] = '(?:(?:'.self::$_grammar['WSP'].'*'. + self::$_grammar['CRLF'].')?'.self::$_grammar['WSP'].')'; + self::$_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]'; + self::$_grammar['quoted-pair'] = '(?:\\\\'.self::$_grammar['text'].')'; + self::$_grammar['ctext'] = '(?:'.self::$_grammar['NO-WS-CTL']. + '|[\x21-\x27\x2A-\x5B\x5D-\x7E])'; + // Uses recursive PCRE (?1) -- could be a weak point?? + self::$_grammar['ccontent'] = '(?:'.self::$_grammar['ctext'].'|'. + self::$_grammar['quoted-pair'].'|(?1))'; + self::$_grammar['comment'] = '(\((?:'.self::$_grammar['FWS'].'|'. + self::$_grammar['ccontent'].')*'.self::$_grammar['FWS'].'?\))'; + self::$_grammar['CFWS'] = '(?:(?:'.self::$_grammar['FWS'].'?'. + self::$_grammar['comment'].')*(?:(?:'.self::$_grammar['FWS'].'?'. + self::$_grammar['comment'].')|'.self::$_grammar['FWS'].'))'; + self::$_grammar['qtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. + '|[\x21\x23-\x5B\x5D-\x7E])'; + self::$_grammar['qcontent'] = '(?:'.self::$_grammar['qtext'].'|'. + self::$_grammar['quoted-pair'].')'; + self::$_grammar['quoted-string'] = '(?:'.self::$_grammar['CFWS'].'?"'. + '('.self::$_grammar['FWS'].'?'.self::$_grammar['qcontent'].')*'. + self::$_grammar['FWS'].'?"'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]'; + self::$_grammar['atom'] = '(?:'.self::$_grammar['CFWS'].'?'. + self::$_grammar['atext'].'+'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['dot-atom-text'] = '(?:'.self::$_grammar['atext'].'+'. + '(\.'.self::$_grammar['atext'].'+)*)'; + self::$_grammar['dot-atom'] = '(?:'.self::$_grammar['CFWS'].'?'. + self::$_grammar['dot-atom-text'].'+'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['word'] = '(?:'.self::$_grammar['atom'].'|'. + self::$_grammar['quoted-string'].')'; + self::$_grammar['phrase'] = '(?:'.self::$_grammar['word'].'+?)'; + self::$_grammar['no-fold-quote'] = '(?:"(?:'.self::$_grammar['qtext']. + '|'.self::$_grammar['quoted-pair'].')*")'; + self::$_grammar['dtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. + '|[\x21-\x5A\x5E-\x7E])'; + self::$_grammar['no-fold-literal'] = '(?:\[(?:'.self::$_grammar['dtext']. + '|'.self::$_grammar['quoted-pair'].')*\])'; + + // Message IDs + self::$_grammar['id-left'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. + self::$_grammar['no-fold-quote'].')'; + self::$_grammar['id-right'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. + self::$_grammar['no-fold-literal'].')'; + + // Addresses, mailboxes and paths + self::$_grammar['local-part'] = '(?:'.self::$_grammar['dot-atom'].'|'. + self::$_grammar['quoted-string'].')'; + self::$_grammar['dcontent'] = '(?:'.self::$_grammar['dtext'].'|'. + self::$_grammar['quoted-pair'].')'; + self::$_grammar['domain-literal'] = '(?:'.self::$_grammar['CFWS'].'?\[('. + self::$_grammar['FWS'].'?'.self::$_grammar['dcontent'].')*?'. + self::$_grammar['FWS'].'?\]'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['domain'] = '(?:'.self::$_grammar['dot-atom'].'|'. + self::$_grammar['domain-literal'].')'; + self::$_grammar['addr-spec'] = '(?:'.self::$_grammar['local-part'].'@'. + self::$_grammar['domain'].')'; + } + + /** + * Get the grammar defined for $name token. + * + * @param string $name exactly as written in the RFC + * + * @return string + */ + public function getDefinition($name) + { + if (array_key_exists($name, self::$_grammar)) { + return self::$_grammar[$name]; + } else { + throw new Swift_RfcComplianceException( + "No such grammar '".$name."' defined." + ); + } + } + + /** + * Returns the tokens defined in RFC 2822 (and some related RFCs). + * + * @return array + */ + public function getGrammarDefinitions() + { + return self::$_grammar; + } + + /** + * Returns the current special characters used in the syntax which need to be escaped. + * + * @return array + */ + public function getSpecials() + { + return self::$_specials; + } + + /** + * Escape special characters in a string (convert to quoted-pairs). + * + * @param string $token + * @param string[] $include additional chars to escape + * @param string[] $exclude chars from escaping + * + * @return string + */ + public function escapeSpecials($token, $include = array(), $exclude = array()) + { + foreach (array_merge(array('\\'), array_diff(self::$_specials, $exclude), $include) as $char) { + $token = str_replace($char, '\\'.$char, $token); + } + + return $token; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php new file mode 100644 index 000000000..a8ddd2721 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -0,0 +1,93 @@ +getName(), "\r\n"); + mb_internal_encoding($old); + + return $newstring; + } + + return parent::encodeString($string, $firstLineOffset, $maxLineLength); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php new file mode 100644 index 000000000..510dd6637 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -0,0 +1,65 @@ +_safeMap[$byte] = chr($byte); + } + } + + /** + * Get the name of this encoding scheme. + * + * Returns the string 'Q'. + * + * @return string + */ + public function getName() + { + return 'Q'; + } + + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"), + parent::encodeString($string, $firstLineOffset, $maxLineLength) + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php new file mode 100644 index 000000000..c65f26d72 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php @@ -0,0 +1,78 @@ +setGrammar($grammar); + } + + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->clearCachedValueIf($charset != $this->_charset); + $this->_charset = $charset; + if (isset($this->_encoder)) { + $this->_encoder->charsetChanged($charset); + } + } + + /** + * Get the character set used in this Header. + * + * @return string + */ + public function getCharset() + { + return $this->_charset; + } + + /** + * Set the language used in this Header. + * + * For example, for US English, 'en-us'. + * This can be unspecified. + * + * @param string $lang + */ + public function setLanguage($lang) + { + $this->clearCachedValueIf($this->_lang != $lang); + $this->_lang = $lang; + } + + /** + * Get the language used in this Header. + * + * @return string + */ + public function getLanguage() + { + return $this->_lang; + } + + /** + * Set the encoder used for encoding the header. + * + * @param Swift_Mime_HeaderEncoder $encoder + */ + public function setEncoder(Swift_Mime_HeaderEncoder $encoder) + { + $this->_encoder = $encoder; + $this->setCachedValue(null); + } + + /** + * Get the encoder used for encoding this Header. + * + * @return Swift_Mime_HeaderEncoder + */ + public function getEncoder() + { + return $this->_encoder; + } + + /** + * Set the grammar used for the header. + * + * @param Swift_Mime_Grammar $grammar + */ + public function setGrammar(Swift_Mime_Grammar $grammar) + { + $this->_grammar = $grammar; + $this->setCachedValue(null); + } + + /** + * Get the grammar used for this Header. + * + * @return Swift_Mime_Grammar + */ + public function getGrammar() + { + return $this->_grammar; + } + + /** + * Get the name of this header (e.g. charset). + * + * @return string + */ + public function getFieldName() + { + return $this->_name; + } + + /** + * Set the maximum length of lines in the header (excluding EOL). + * + * @param int $lineLength + */ + public function setMaxLineLength($lineLength) + { + $this->clearCachedValueIf($this->_lineLength != $lineLength); + $this->_lineLength = $lineLength; + } + + /** + * Get the maximum permitted length of lines in this Header. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->_lineLength; + } + + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function toString() + { + return $this->_tokensToString($this->toTokens()); + } + + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } + + // -- Points of extension + + /** + * Set the name of this Header field. + * + * @param string $name + */ + protected function setFieldName($name) + { + $this->_name = $name; + } + + /** + * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. + * + * @param Swift_Mime_Header $header + * @param string $string as displayed + * @param string $charset of the text + * @param Swift_Mime_HeaderEncoder $encoder + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) + { + // Treat token as exactly what was given + $phraseStr = $string; + // If it's not valid + if (!preg_match('/^'.$this->getGrammar()->getDefinition('phrase').'$/D', $phraseStr)) { + // .. but it is just ascii text, try escaping some characters + // and make it a quoted-string + if (preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $phraseStr)) { + $phraseStr = $this->getGrammar()->escapeSpecials( + $phraseStr, array('"'), $this->getGrammar()->getSpecials() + ); + $phraseStr = '"'.$phraseStr.'"'; + } else { + // ... otherwise it needs encoding + // Determine space remaining on line if first line + if ($shorten) { + $usedLength = strlen($header->getFieldName().': '); + } else { + $usedLength = 0; + } + $phraseStr = $this->encodeWords($header, $string, $usedLength); + } + } + + return $phraseStr; + } + + /** + * Encode needed word tokens within a string of input. + * + * @param Swift_Mime_Header $header + * @param string $input + * @param string $usedLength optional + * + * @return string + */ + protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) + { + $value = ''; + + $tokens = $this->getEncodableWordTokens($input); + + foreach ($tokens as $token) { + // See RFC 2822, Sect 2.2 (really 2.2 ??) + if ($this->tokenNeedsEncoding($token)) { + // Don't encode starting WSP + $firstChar = substr($token, 0, 1); + switch ($firstChar) { + case ' ': + case "\t": + $value .= $firstChar; + $token = substr($token, 1); + } + + if (-1 == $usedLength) { + $usedLength = strlen($header->getFieldName().': ') + strlen($value); + } + $value .= $this->getTokenAsEncodedWord($token, $usedLength); + + $header->setMaxLineLength(76); // Forcefully override + } else { + $value .= $token; + } + } + + return $value; + } + + /** + * Test if a token needs to be encoded or not. + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); + } + + /** + * Splits a string into tokens in blocks of words which can be encoded quickly. + * + * @param string $string + * + * @return string[] + */ + protected function getEncodableWordTokens($string) + { + $tokens = array(); + + $encodedToken = ''; + // Split at all whitespace boundaries + foreach (preg_split('~(?=[\t ])~', $string) as $token) { + if ($this->tokenNeedsEncoding($token)) { + $encodedToken .= $token; + } else { + if (strlen($encodedToken) > 0) { + $tokens[] = $encodedToken; + $encodedToken = ''; + } + $tokens[] = $token; + } + } + if (strlen($encodedToken)) { + $tokens[] = $encodedToken; + } + + return $tokens; + } + + /** + * Get a token as an encoded word for safe insertion into headers. + * + * @param string $token token to encode + * @param int $firstLineOffset optional + * + * @return string + */ + protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) + { + // Adjust $firstLineOffset to account for space needed for syntax + $charsetDecl = $this->_charset; + if (isset($this->_lang)) { + $charsetDecl .= '*'.$this->_lang; + } + $encodingWrapperLength = strlen( + '=?'.$charsetDecl.'?'.$this->_encoder->getName().'??=' + ); + + if ($firstLineOffset >= 75) { + //Does this logic need to be here? + $firstLineOffset = 0; + } + + $encodedTextLines = explode("\r\n", + $this->_encoder->encodeString( + $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->_charset + ) + ); + + if (strtolower($this->_charset) !== 'iso-2022-jp') { + // special encoding for iso-2022-jp using mb_encode_mimeheader + foreach ($encodedTextLines as $lineNum => $line) { + $encodedTextLines[$lineNum] = '=?'.$charsetDecl. + '?'.$this->_encoder->getName(). + '?'.$line.'?='; + } + } + + return implode("\r\n ", $encodedTextLines); + } + + /** + * Generates tokens from the given string which include CRLF as individual tokens. + * + * @param string $token + * + * @return string[] + */ + protected function generateTokenLines($token) + { + return preg_split('~(\r\n)~', $token, -1, PREG_SPLIT_DELIM_CAPTURE); + } + + /** + * Set a value into the cache. + * + * @param string $value + */ + protected function setCachedValue($value) + { + $this->_cachedValue = $value; + } + + /** + * Get the value in the cache. + * + * @return string + */ + protected function getCachedValue() + { + return $this->_cachedValue; + } + + /** + * Clear the cached value if $condition is met. + * + * @param bool $condition + */ + protected function clearCachedValueIf($condition) + { + if ($condition) { + $this->setCachedValue(null); + } + } + + /** + * Generate a list of all tokens in the final header. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + if (is_null($string)) { + $string = $this->getFieldBody(); + } + + $tokens = array(); + + // Generate atoms; split at all invisible boundaries followed by WSP + foreach (preg_split('~(?=[ \t])~', $string) as $token) { + $newTokens = $this->generateTokenLines($token); + foreach ($newTokens as $newToken) { + $tokens[] = $newToken; + } + } + + return $tokens; + } + + /** + * Takes an array of tokens which appear in the header and turns them into + * an RFC 2822 compliant string, adding FWSP where needed. + * + * @param string[] $tokens + * + * @return string + */ + private function _tokensToString(array $tokens) + { + $lineCount = 0; + $headerLines = array(); + $headerLines[] = $this->_name.': '; + $currentLine = &$headerLines[$lineCount++]; + + // Build all tokens back into compliant header + foreach ($tokens as $i => $token) { + // Line longer than specified maximum or token was just a new line + if (("\r\n" == $token) || + ($i > 0 && strlen($currentLine.$token) > $this->_lineLength) + && 0 < strlen($currentLine)) { + $headerLines[] = ''; + $currentLine = &$headerLines[$lineCount++]; + } + + // Append token to the line + if ("\r\n" != $token) { + $currentLine .= $token; + } + } + + // Implode with FWS (RFC 2822, 2.2.3) + return implode("\r\n", $headerLines)."\r\n"; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php new file mode 100644 index 000000000..4fd667429 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -0,0 +1,125 @@ + + * + * + * + * @param string $name of Header + * @param Swift_Mime_Grammar $grammar + */ + public function __construct($name, Swift_Mime_Grammar $grammar) + { + $this->setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_DATE; + } + + /** + * Set the model for the field body. + * + * This method takes a UNIX timestamp. + * + * @param int $model + */ + public function setFieldBodyModel($model) + { + $this->setTimestamp($model); + } + + /** + * Get the model for the field body. + * + * This method returns a UNIX timestamp. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getTimestamp(); + } + + /** + * Get the UNIX timestamp of the Date in this Header. + * + * @return int + */ + public function getTimestamp() + { + return $this->_timestamp; + } + + /** + * Set the UNIX timestamp of the Date in this Header. + * + * @param int $timestamp + */ + public function setTimestamp($timestamp) + { + if (!is_null($timestamp)) { + $timestamp = (int) $timestamp; + } + $this->clearCachedValueIf($this->_timestamp != $timestamp); + $this->_timestamp = $timestamp; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->_timestamp)) { + $this->setCachedValue(date('r', $this->_timestamp)); + } + } + + return $this->getCachedValue(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php new file mode 100644 index 000000000..b114506b4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -0,0 +1,180 @@ +setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_ID; + } + + /** + * Set the model for the field body. + * + * This method takes a string ID, or an array of IDs. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setId($model); + } + + /** + * Get the model for the field body. + * + * This method returns an array of IDs + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getIds(); + } + + /** + * Set the ID used in the value of this header. + * + * @param string|array $id + * + * @throws Swift_RfcComplianceException + */ + public function setId($id) + { + $this->setIds(is_array($id) ? $id : array($id)); + } + + /** + * Get the ID used in the value of this Header. + * + * If multiple IDs are set only the first is returned. + * + * @return string + */ + public function getId() + { + if (count($this->_ids) > 0) { + return $this->_ids[0]; + } + } + + /** + * Set a collection of IDs to use in the value of this Header. + * + * @param string[] $ids + * + * @throws Swift_RfcComplianceException + */ + public function setIds(array $ids) + { + $actualIds = array(); + + foreach ($ids as $id) { + $this->_assertValidId($id); + $actualIds[] = $id; + } + + $this->clearCachedValueIf($this->_ids != $actualIds); + $this->_ids = $actualIds; + } + + /** + * Get the list of IDs used in this Header. + * + * @return string[] + */ + public function getIds() + { + return $this->_ids; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@see toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $angleAddrs = array(); + + foreach ($this->_ids as $id) { + $angleAddrs[] = '<'.$id.'>'; + } + + $this->setCachedValue(implode(' ', $angleAddrs)); + } + + return $this->getCachedValue(); + } + + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function _assertValidId($id) + { + if (!preg_match( + '/^'.$this->getGrammar()->getDefinition('id-left').'@'. + $this->getGrammar()->getDefinition('id-right').'$/D', + $id + )) { + throw new Swift_RfcComplianceException( + 'Invalid ID given <'.$id.'>' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php new file mode 100644 index 000000000..798e7f42a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -0,0 +1,354 @@ +setFieldName($name); + $this->setEncoder($encoder); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_MAILBOX; + } + + /** + * Set the model for the field body. + * + * This method takes a string, or an array of addresses. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setNameAddresses($model); + } + + /** + * Get the model for the field body. + * + * This method returns an associative array like {@link getNameAddresses()} + * + * @throws Swift_RfcComplianceException + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getNameAddresses(); + } + + /** + * Set a list of mailboxes to be shown in this Header. + * + * The mailboxes can be a simple array of addresses, or an array of + * key=>value pairs where (email => personalName). + * Example: + * + * setNameAddresses(array( + * 'chris@swiftmailer.org' => 'Chris Corbyn', + * 'mark@swiftmailer.org' //No associated personal name + * )); + * ?> + * + * + * @see __construct() + * @see setAddresses() + * @see setValue() + * + * @param string|string[] $mailboxes + * + * @throws Swift_RfcComplianceException + */ + public function setNameAddresses($mailboxes) + { + $this->_mailboxes = $this->normalizeMailboxes((array) $mailboxes); + $this->setCachedValue(null); //Clear any cached value + } + + /** + * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. + * + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddressStrings()); + * // array ( + * // 0 => Chris Corbyn , + * // 1 => Mark Corbyn + * // ) + * ?> + * + * + * @see getNameAddresses() + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string[] + */ + public function getNameAddressStrings() + { + return $this->_createNameAddressStrings($this->getNameAddresses()); + } + + /** + * Get all mailboxes in this Header as key=>value pairs. + * + * The key is the address and the value is the name (or null if none set). + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddresses()); + * // array ( + * // chris@swiftmailer.org => Chris Corbyn, + * // mark@swiftmailer.org => Mark Corbyn + * // ) + * ?> + * + * + * @see getAddresses() + * @see getNameAddressStrings() + * + * @return string[] + */ + public function getNameAddresses() + { + return $this->_mailboxes; + } + + /** + * Makes this Header represent a list of plain email addresses with no names. + * + * Example: + * + * setAddresses( + * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') + * ); + * ?> + * + * + * @see setNameAddresses() + * @see setValue() + * + * @param string[] $addresses + * + * @throws Swift_RfcComplianceException + */ + public function setAddresses($addresses) + { + $this->setNameAddresses(array_values((array) $addresses)); + } + + /** + * Get all email addresses in this Header. + * + * @see getNameAddresses() + * + * @return string[] + */ + public function getAddresses() + { + return array_keys($this->_mailboxes); + } + + /** + * Remove one or more addresses from this Header. + * + * @param string|string[] $addresses + */ + public function removeAddresses($addresses) + { + $this->setCachedValue(null); + foreach ((array) $addresses as $address) { + unset($this->_mailboxes[$address]); + } + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + // Compute the string value of the header only if needed + if (is_null($this->getCachedValue())) { + $this->setCachedValue($this->createMailboxListString($this->_mailboxes)); + } + + return $this->getCachedValue(); + } + + // -- Points of extension + + /** + * Normalizes a user-input list of mailboxes into consistent key=>value pairs. + * + * @param string[] $mailboxes + * + * @return string[] + */ + protected function normalizeMailboxes(array $mailboxes) + { + $actualMailboxes = array(); + + foreach ($mailboxes as $key => $value) { + if (is_string($key)) { + //key is email addr + $address = $key; + $name = $value; + } else { + $address = $value; + $name = null; + } + $this->_assertValidAddress($address); + $actualMailboxes[$address] = $name; + } + + return $actualMailboxes; + } + + /** + * Produces a compliant, formatted display-name based on the string given. + * + * @param string $displayName as displayed + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createDisplayNameString($displayName, $shorten = false) + { + return $this->createPhrase($this, $displayName, + $this->getCharset(), $this->getEncoder(), $shorten + ); + } + + /** + * Creates a string form of all the mailboxes in the passed array. + * + * @param string[] $mailboxes + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + protected function createMailboxListString(array $mailboxes) + { + return implode(', ', $this->_createNameAddressStrings($mailboxes)); + } + + /** + * Redefine the encoding requirements for mailboxes. + * + * Commas and semicolons are used to separate + * multiple addresses, and should therefore be encoded + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token); + } + + /** + * Return an array of strings conforming the the name-addr spec of RFC 2822. + * + * @param string[] $mailboxes + * + * @return string[] + */ + private function _createNameAddressStrings(array $mailboxes) + { + $strings = array(); + + foreach ($mailboxes as $email => $name) { + $mailboxStr = $email; + if (!is_null($name)) { + $nameStr = $this->createDisplayNameString($name, empty($strings)); + $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; + } + $strings[] = $mailboxStr; + } + + return $strings; + } + + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If invalid. + */ + private function _assertValidAddress($address) + { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', + $address)) { + throw new Swift_RfcComplianceException( + 'Address in mailbox given ['.$address. + '] does not comply with RFC 2822, 3.6.2.' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php new file mode 100644 index 000000000..b52b964b7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -0,0 +1,137 @@ + + */ +class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header +{ + /** + * The value of this Header. + * + * @var string + */ + private $_value; + + /** + * The name of this Header. + * + * @var string + */ + private $_fieldName; + + /** + * Creates a new SimpleHeader with $name. + * + * @param string $name + * @param Swift_Mime_HeaderEncoder $encoder + * @param Swift_Mime_Grammar $grammar + */ + public function __construct($name) + { + $this->_fieldName = $name; + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } + + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } + + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } + + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->_value; + } + + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->_value = $value; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + return $this->_value; + } + + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + */ + public function toString() + { + return $this->_fieldName.': '.$this->_value; + } + + /** + * Set the Header FieldName. + * + * @see Swift_Mime_Header::getFieldName() + */ + public function getFieldName() + { + return $this->_fieldName; + } + + /** + * Ignored. + */ + public function setCharset($charset) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php new file mode 100644 index 000000000..0dcf1fcf2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -0,0 +1,260 @@ +_paramEncoder = $paramEncoder; + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PARAMETERIZED; + } + + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + parent::setCharset($charset); + if (isset($this->_paramEncoder)) { + $this->_paramEncoder->charsetChanged($charset); + } + } + + /** + * Set the value of $parameter. + * + * @param string $parameter + * @param string $value + */ + public function setParameter($parameter, $value) + { + $this->setParameters(array_merge($this->getParameters(), array($parameter => $value))); + } + + /** + * Get the value of $parameter. + * + * @param string $parameter + * + * @return string + */ + public function getParameter($parameter) + { + $params = $this->getParameters(); + + return array_key_exists($parameter, $params) + ? $params[$parameter] + : null; + } + + /** + * Set an associative array of parameter names mapped to values. + * + * @param string[] $parameters + */ + public function setParameters(array $parameters) + { + $this->clearCachedValueIf($this->_params != $parameters); + $this->_params = $parameters; + } + + /** + * Returns an associative array of parameter names mapped to values. + * + * @return string[] + */ + public function getParameters() + { + return $this->_params; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() //TODO: Check caching here + { + $body = parent::getFieldBody(); + foreach ($this->_params as $name => $value) { + if (!is_null($value)) { + // Add the parameter + $body .= '; '.$this->_createParameter($name, $value); + } + } + + return $body; + } + + /** + * Generate a list of all tokens in the final header. + * + * This doesn't need to be overridden in theory, but it is for implementation + * reasons to prevent potential breakage of attributes. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + $tokens = parent::toTokens(parent::getFieldBody()); + + // Try creating any parameters + foreach ($this->_params as $name => $value) { + if (!is_null($value)) { + // Add the semi-colon separator + $tokens[count($tokens) - 1] .= ';'; + $tokens = array_merge($tokens, $this->generateTokenLines( + ' '.$this->_createParameter($name, $value) + )); + } + } + + return $tokens; + } + + /** + * Render a RFC 2047 compliant header parameter from the $name and $value. + * + * @param string $name + * @param string $value + * + * @return string + */ + private function _createParameter($name, $value) + { + $origValue = $value; + + $encoded = false; + // Allow room for parameter name, indices, "=" and DQUOTEs + $maxValueLength = $this->getMaxLineLength() - strlen($name.'=*N"";') - 1; + $firstLineOffset = 0; + + // If it's not already a valid parameter value... + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + // TODO: text, or something else?? + // ... and it's not ascii + if (!preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $value)) { + $encoded = true; + // Allow space for the indices, charset and language + $maxValueLength = $this->getMaxLineLength() - strlen($name.'*N*="";') - 1; + $firstLineOffset = strlen( + $this->getCharset()."'".$this->getLanguage()."'" + ); + } + } + + // Encode if we need to + if ($encoded || strlen($value) > $maxValueLength) { + if (isset($this->_paramEncoder)) { + $value = $this->_paramEncoder->encodeString( + $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() + ); + } else { + // We have to go against RFC 2183/2231 in some areas for interoperability + $value = $this->getTokenAsEncodedWord($origValue); + $encoded = false; + } + } + + $valueLines = isset($this->_paramEncoder) ? explode("\r\n", $value) : array($value); + + // Need to add indices + if (count($valueLines) > 1) { + $paramLines = array(); + foreach ($valueLines as $i => $line) { + $paramLines[] = $name.'*'.$i. + $this->_getEndOfParameterValue($line, true, $i == 0); + } + + return implode(";\r\n ", $paramLines); + } else { + return $name.$this->_getEndOfParameterValue( + $valueLines[0], $encoded, true + ); + } + } + + /** + * Returns the parameter value from the "=" and beyond. + * + * @param string $value to append + * @param bool $encoded + * @param bool $firstLine + * + * @return string + */ + private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false) + { + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + $value = '"'.$value.'"'; + } + $prepend = '='; + if ($encoded) { + $prepend = '*='; + if ($firstLine) { + $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). + "'"; + } + } + + return $prepend.$value; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php new file mode 100644 index 000000000..2fffc7b4a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -0,0 +1,143 @@ +setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PATH; + } + + /** + * Set the model for the field body. + * This method takes a string for an address. + * + * @param string $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setAddress($model); + } + + /** + * Get the model for the field body. + * This method returns a string email address. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getAddress(); + } + + /** + * Set the Address which should appear in this Header. + * + * @param string $address + * + * @throws Swift_RfcComplianceException + */ + public function setAddress($address) + { + if (is_null($address)) { + $this->_address = null; + } elseif ('' == $address) { + $this->_address = ''; + } else { + $this->_assertValidAddress($address); + $this->_address = $address; + } + $this->setCachedValue(null); + } + + /** + * Get the address which is used in this Header (if any). + * + * Null is returned if no address is set. + * + * @return string + */ + public function getAddress() + { + return $this->_address; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->_address)) { + $this->setCachedValue('<'.$this->_address.'>'); + } + } + + return $this->getCachedValue(); + } + + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If address is invalid + */ + private function _assertValidAddress($address) + { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', + $address)) { + throw new Swift_RfcComplianceException( + 'Address set in PathHeader does not comply with addr-spec of RFC 2822.' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php new file mode 100644 index 000000000..86177f14a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -0,0 +1,112 @@ +setFieldName($name); + $this->setEncoder($encoder); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } + + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } + + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } + + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->_value; + } + + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->clearCachedValueIf($this->_value != $value); + $this->_value = $value; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $this->setCachedValue( + $this->encodeWords($this, $this->_value) + ); + } + + return $this->getCachedValue(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php new file mode 100644 index 000000000..9b36d2162 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php @@ -0,0 +1,223 @@ + 'Real Name'). + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $address + * @param string $name optional + */ + public function setSender($address, $name = null); + + /** + * Get the sender address for this message. + * + * This has a higher significance than the From address. + * + * @return string + */ + public function getSender(); + + /** + * Set the From address of this message. + * + * It is permissible for multiple From addresses to be set using an array. + * + * If multiple From addresses are used, you SHOULD set the Sender address and + * according to RFC 2822, MUST set the sender address. + * + * An array can be used if display names are to be provided: i.e. + * array('email@address.com' => 'Real Name'). + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setFrom($addresses, $name = null); + + /** + * Get the From address(es) of this message. + * + * This method always returns an associative array where the keys are the + * addresses. + * + * @return string[] + */ + public function getFrom(); + + /** + * Set the Reply-To address(es). + * + * Any replies from the receiver will be sent to this address. + * + * It is permissible for multiple reply-to addresses to be set using an array. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setReplyTo($addresses, $name = null); + + /** + * Get the Reply-To addresses for this message. + * + * This method always returns an associative array where the keys provide the + * email addresses. + * + * @return string[] + */ + public function getReplyTo(); + + /** + * Set the To address(es). + * + * Recipients set in this field will receive a copy of this message. + * + * This method has the same synopsis as {@link setFrom()} and {@link setCc()}. + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setTo($addresses, $name = null); + + /** + * Get the To addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getTo(); + + /** + * Set the Cc address(es). + * + * Recipients set in this field will receive a 'carbon-copy' of this message. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setCc($addresses, $name = null); + + /** + * Get the Cc addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getCc(); + + /** + * Set the Bcc address(es). + * + * Recipients set in this field will receive a 'blind-carbon-copy' of this + * message. + * + * In other words, they will get the message, but any other recipients of the + * message will have no such knowledge of their receipt of it. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setBcc($addresses, $name = null); + + /** + * Get the Bcc addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getBcc(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php new file mode 100644 index 000000000..30f460cdc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php @@ -0,0 +1,117 @@ +setContentType('text/plain'); + if (!is_null($charset)) { + $this->setCharset($charset); + } + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * @param string $charset optional + * + * @return Swift_Mime_MimePart + */ + public function setBody($body, $contentType = null, $charset = null) + { + if (isset($charset)) { + $this->setCharset($charset); + } + $body = $this->_convertString($body); + + parent::setBody($body, $contentType); + + return $this; + } + + /** + * Get the character set of this entity. + * + * @return string + */ + public function getCharset() + { + return $this->_getHeaderParameter('Content-Type', 'charset'); + } + + /** + * Set the character set of this entity. + * + * @param string $charset + * + * @return Swift_Mime_MimePart + */ + public function setCharset($charset) + { + $this->_setHeaderParameter('Content-Type', 'charset', $charset); + if ($charset !== $this->_userCharset) { + $this->_clearCache(); + } + $this->_userCharset = $charset; + parent::charsetChanged($charset); + + return $this; + } + + /** + * Get the format of this entity (i.e. flowed or fixed). + * + * @return string + */ + public function getFormat() + { + return $this->_getHeaderParameter('Content-Type', 'format'); + } + + /** + * Set the format of this entity (flowed or fixed). + * + * @param string $format + * + * @return Swift_Mime_MimePart + */ + public function setFormat($format) + { + $this->_setHeaderParameter('Content-Type', 'format', $format); + $this->_userFormat = $format; + + return $this; + } + + /** + * Test if delsp is being used for this entity. + * + * @return bool + */ + public function getDelSp() + { + return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes') + ? true + : false; + } + + /** + * Turn delsp on or off for this entity. + * + * @param bool $delsp + * + * @return Swift_Mime_MimePart + */ + public function setDelSp($delsp = true) + { + $this->_setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); + $this->_userDelSp = $delsp; + + return $this; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED + * + * @return int + */ + public function getNestingLevel() + { + return $this->_nestingLevel; + } + + /** + * Receive notification that the charset has changed on this document, or a + * parent document. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } + + /** Fix the content-type and encoding of this entity */ + protected function _fixHeaders() + { + parent::_fixHeaders(); + if (count($this->getChildren())) { + $this->_setHeaderParameter('Content-Type', 'charset', null); + $this->_setHeaderParameter('Content-Type', 'format', null); + $this->_setHeaderParameter('Content-Type', 'delsp', null); + } else { + $this->setCharset($this->_userCharset); + $this->setFormat($this->_userFormat); + $this->setDelSp($this->_userDelSp); + } + } + + /** Set the nesting level of this entity */ + protected function _setNestingLevel($level) + { + $this->_nestingLevel = $level; + } + + /** Encode charset when charset is not utf-8 */ + protected function _convertString($string) + { + $charset = strtolower($this->getCharset()); + if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) { + // mb_convert_encoding must be the first one to check, since iconv cannot convert some words. + if (function_exists('mb_convert_encoding')) { + $string = mb_convert_encoding($string, $charset, 'utf-8'); + } elseif (function_exists('iconv')) { + $string = iconv('utf-8//TRANSLIT//IGNORE', $charset, $string); + } else { + throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your charset or install the mbstring or iconv extension).'); + } + + return $string; + } + + return $string; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php new file mode 100644 index 000000000..e15c6ef95 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php @@ -0,0 +1,34 @@ +_encoder = $encoder; + $this->_paramEncoder = $paramEncoder; + $this->_grammar = $grammar; + $this->_charset = $charset; + } + + /** + * Create a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string|null $addresses + * + * @return Swift_Mime_Header + */ + public function createMailboxHeader($name, $addresses = null) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder, $this->_grammar); + if (isset($addresses)) { + $header->setFieldBodyModel($addresses); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new Date header using $timestamp (UNIX time). + * + * @param string $name + * @param int|null $timestamp + * + * @return Swift_Mime_Header + */ + public function createDateHeader($name, $timestamp = null) + { + $header = new Swift_Mime_Headers_DateHeader($name, $this->_grammar); + if (isset($timestamp)) { + $header->setFieldBodyModel($timestamp); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + * + * @return Swift_Mime_Header + */ + public function createTextHeader($name, $value = null) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder, $this->_grammar); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + * + * @return Swift_Mime_ParameterizedHeader + */ + public function createParameterizedHeader($name, $value = null, + $params = array()) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, + $this->_encoder, (strtolower($name) == 'content-disposition') + ? $this->_paramEncoder + : null, + $this->_grammar + ); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + foreach ($params as $k => $v) { + $header->setParameter($k, $v); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + * + * @return Swift_Mime_Header + */ + public function createIdHeader($name, $ids = null) + { + $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->_grammar); + if (isset($ids)) { + $header->setFieldBodyModel($ids); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + * + * @return Swift_Mime_Header + */ + public function createPathHeader($name, $path = null) + { + $header = new Swift_Mime_Headers_PathHeader($name, $this->_grammar); + if (isset($path)) { + $header->setFieldBodyModel($path); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charset = $charset; + $this->_encoder->charsetChanged($charset); + $this->_paramEncoder->charsetChanged($charset); + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_encoder = clone $this->_encoder; + $this->_paramEncoder = clone $this->_paramEncoder; + } + + /** Apply the charset to the Header */ + private function _setHeaderCharset(Swift_Mime_Header $header) + { + if (isset($this->_charset)) { + $header->setCharset($this->_charset); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php new file mode 100644 index 000000000..077624017 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -0,0 +1,396 @@ +_factory = $factory; + if (isset($charset)) { + $this->setCharset($charset); + } + } + + /** + * Set the charset used by these headers. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->_charset = $charset; + $this->_factory->charsetChanged($charset); + $this->_notifyHeadersOfCharset($charset); + } + + /** + * Add a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string $addresses + */ + public function addMailboxHeader($name, $addresses = null) + { + $this->_storeHeader($name, + $this->_factory->createMailboxHeader($name, $addresses)); + } + + /** + * Add a new Date header using $timestamp (UNIX time). + * + * @param string $name + * @param int $timestamp + */ + public function addDateHeader($name, $timestamp = null) + { + $this->_storeHeader($name, + $this->_factory->createDateHeader($name, $timestamp)); + } + + /** + * Add a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + */ + public function addTextHeader($name, $value = null) + { + $this->_storeHeader($name, + $this->_factory->createTextHeader($name, $value)); + } + + /** + * Add a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + */ + public function addParameterizedHeader($name, $value = null, $params = array()) + { + $this->_storeHeader($name, $this->_factory->createParameterizedHeader($name, $value, $params)); + } + + /** + * Add a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + */ + public function addIdHeader($name, $ids = null) + { + $this->_storeHeader($name, $this->_factory->createIdHeader($name, $ids)); + } + + /** + * Add a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + */ + public function addPathHeader($name, $path = null) + { + $this->_storeHeader($name, $this->_factory->createPathHeader($name, $path)); + } + + /** + * Returns true if at least one header with the given $name exists. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + * + * @return bool + */ + public function has($name, $index = 0) + { + $lowerName = strtolower($name); + + return array_key_exists($lowerName, $this->_headers) && array_key_exists($index, $this->_headers[$lowerName]); + } + + /** + * Set a header in the HeaderSet. + * + * The header may be a previously fetched header via {@link get()} or it may + * be one that has been created separately. + * + * If $index is specified, the header will be inserted into the set at this + * offset. + * + * @param Swift_Mime_Header $header + * @param int $index + */ + public function set(Swift_Mime_Header $header, $index = 0) + { + $this->_storeHeader($header->getFieldName(), $header, $index); + } + + /** + * Get the header with the given $name. + * + * If multiple headers match, the actual one may be specified by $index. + * Returns NULL if none present. + * + * @param string $name + * @param int $index + * + * @return Swift_Mime_Header + */ + public function get($name, $index = 0) + { + if ($this->has($name, $index)) { + $lowerName = strtolower($name); + + return $this->_headers[$lowerName][$index]; + } + } + + /** + * Get all headers with the given $name. + * + * @param string $name + * + * @return array + */ + public function getAll($name = null) + { + if (!isset($name)) { + $headers = array(); + foreach ($this->_headers as $collection) { + $headers = array_merge($headers, $collection); + } + + return $headers; + } + + $lowerName = strtolower($name); + if (!array_key_exists($lowerName, $this->_headers)) { + return array(); + } + + return $this->_headers[$lowerName]; + } + + /** + * Return the name of all Headers. + * + * @return array + */ + public function listAll() + { + $headers = $this->_headers; + if ($this->_canSort()) { + uksort($headers, array($this, '_sortHeaders')); + } + + return array_keys($headers); + } + + /** + * Remove the header with the given $name if it's set. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + */ + public function remove($name, $index = 0) + { + $lowerName = strtolower($name); + unset($this->_headers[$lowerName][$index]); + } + + /** + * Remove all headers with the given $name. + * + * @param string $name + */ + public function removeAll($name) + { + $lowerName = strtolower($name); + unset($this->_headers[$lowerName]); + } + + /** + * Create a new instance of this HeaderSet. + * + * @return Swift_Mime_HeaderSet + */ + public function newInstance() + { + return new self($this->_factory); + } + + /** + * Define a list of Header names as an array in the correct order. + * + * These Headers will be output in the given order where present. + * + * @param array $sequence + */ + public function defineOrdering(array $sequence) + { + $this->_order = array_flip(array_map('strtolower', $sequence)); + } + + /** + * Set a list of header names which must always be displayed when set. + * + * Usually headers without a field value won't be output unless set here. + * + * @param array $names + */ + public function setAlwaysDisplayed(array $names) + { + $this->_required = array_flip(array_map('strtolower', $names)); + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } + + /** + * Returns a string with a representation of all headers. + * + * @return string + */ + public function toString() + { + $string = ''; + $headers = $this->_headers; + if ($this->_canSort()) { + uksort($headers, array($this, '_sortHeaders')); + } + foreach ($headers as $collection) { + foreach ($collection as $header) { + if ($this->_isDisplayed($header) || $header->getFieldBody() != '') { + $string .= $header->toString(); + } + } + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } + + /** Save a Header to the internal collection */ + private function _storeHeader($name, Swift_Mime_Header $header, $offset = null) + { + if (!isset($this->_headers[strtolower($name)])) { + $this->_headers[strtolower($name)] = array(); + } + if (!isset($offset)) { + $this->_headers[strtolower($name)][] = $header; + } else { + $this->_headers[strtolower($name)][$offset] = $header; + } + } + + /** Test if the headers can be sorted */ + private function _canSort() + { + return count($this->_order) > 0; + } + + /** uksort() algorithm for Header ordering */ + private function _sortHeaders($a, $b) + { + $lowerA = strtolower($a); + $lowerB = strtolower($b); + $aPos = array_key_exists($lowerA, $this->_order) + ? $this->_order[$lowerA] + : -1; + $bPos = array_key_exists($lowerB, $this->_order) + ? $this->_order[$lowerB] + : -1; + + if ($aPos == -1) { + return 1; + } elseif ($bPos == -1) { + return -1; + } + + return ($aPos < $bPos) ? -1 : 1; + } + + /** Test if the given Header is always displayed */ + private function _isDisplayed(Swift_Mime_Header $header) + { + return array_key_exists(strtolower($header->getFieldName()), $this->_required); + } + + /** Notify all Headers of the new charset */ + private function _notifyHeadersOfCharset($charset) + { + foreach ($this->_headers as $headerGroup) { + foreach ($headerGroup as $header) { + $header->setCharset($charset); + } + } + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_factory = clone $this->_factory; + foreach ($this->_headers as $groupKey => $headerGroup) { + foreach ($headerGroup as $key => $header) { + $this->_headers[$groupKey][$key] = clone $header; + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php new file mode 100644 index 000000000..72b6ad9cd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -0,0 +1,649 @@ +getHeaders()->defineOrdering(array( + 'Return-Path', + 'Received', + 'DKIM-Signature', + 'DomainKey-Signature', + 'Sender', + 'Message-ID', + 'Date', + 'Subject', + 'From', + 'Reply-To', + 'To', + 'Cc', + 'Bcc', + 'MIME-Version', + 'Content-Type', + 'Content-Transfer-Encoding', + )); + $this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From')); + $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); + $this->setDate(time()); + $this->setId($this->getId()); + $this->getHeaders()->addMailboxHeader('From'); + } + + /** + * Always returns {@link LEVEL_TOP} for a message instance. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_TOP; + } + + /** + * Set the subject of this message. + * + * @param string $subject + * + * @return Swift_Mime_SimpleMessage + */ + public function setSubject($subject) + { + if (!$this->_setHeaderFieldModel('Subject', $subject)) { + $this->getHeaders()->addTextHeader('Subject', $subject); + } + + return $this; + } + + /** + * Get the subject of this message. + * + * @return string + */ + public function getSubject() + { + return $this->_getHeaderFieldModel('Subject'); + } + + /** + * Set the date at which this message was created. + * + * @param int $date + * + * @return Swift_Mime_SimpleMessage + */ + public function setDate($date) + { + if (!$this->_setHeaderFieldModel('Date', $date)) { + $this->getHeaders()->addDateHeader('Date', $date); + } + + return $this; + } + + /** + * Get the date at which this message was created. + * + * @return int + */ + public function getDate() + { + return $this->_getHeaderFieldModel('Date'); + } + + /** + * Set the return-path (the bounce address) of this message. + * + * @param string $address + * + * @return Swift_Mime_SimpleMessage + */ + public function setReturnPath($address) + { + if (!$this->_setHeaderFieldModel('Return-Path', $address)) { + $this->getHeaders()->addPathHeader('Return-Path', $address); + } + + return $this; + } + + /** + * Get the return-path (bounce address) of this message. + * + * @return string + */ + public function getReturnPath() + { + return $this->_getHeaderFieldModel('Return-Path'); + } + + /** + * Set the sender of this message. + * + * This does not override the From field, but it has a higher significance. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setSender($address, $name = null) + { + if (!is_array($address) && isset($name)) { + $address = array($address => $name); + } + + if (!$this->_setHeaderFieldModel('Sender', (array) $address)) { + $this->getHeaders()->addMailboxHeader('Sender', (array) $address); + } + + return $this; + } + + /** + * Get the sender of this message. + * + * @return string + */ + public function getSender() + { + return $this->_getHeaderFieldModel('Sender'); + } + + /** + * Add a From: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addFrom($address, $name = null) + { + $current = $this->getFrom(); + $current[$address] = $name; + + return $this->setFrom($current); + } + + /** + * Set the from address of this message. + * + * You may pass an array of addresses if this message is from multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string|array $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setFrom($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('From', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('From', (array) $addresses); + } + + return $this; + } + + /** + * Get the from address of this message. + * + * @return mixed + */ + public function getFrom() + { + return $this->_getHeaderFieldModel('From'); + } + + /** + * Add a Reply-To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addReplyTo($address, $name = null) + { + $current = $this->getReplyTo(); + $current[$address] = $name; + + return $this->setReplyTo($current); + } + + /** + * Set the reply-to address of this message. + * + * You may pass an array of addresses if replies will go to multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setReplyTo($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Reply-To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); + } + + return $this; + } + + /** + * Get the reply-to address of this message. + * + * @return string + */ + public function getReplyTo() + { + return $this->_getHeaderFieldModel('Reply-To'); + } + + /** + * Add a To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addTo($address, $name = null) + { + $current = $this->getTo(); + $current[$address] = $name; + + return $this->setTo($current); + } + + /** + * Set the to addresses of this message. + * + * If multiple recipients will receive the message an array should be used. + * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setTo($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('To', (array) $addresses); + } + + return $this; + } + + /** + * Get the To addresses of this message. + * + * @return array + */ + public function getTo() + { + return $this->_getHeaderFieldModel('To'); + } + + /** + * Add a Cc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addCc($address, $name = null) + { + $current = $this->getCc(); + $current[$address] = $name; + + return $this->setCc($current); + } + + /** + * Set the Cc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setCc($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Cc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Cc address of this message. + * + * @return array + */ + public function getCc() + { + return $this->_getHeaderFieldModel('Cc'); + } + + /** + * Add a Bcc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addBcc($address, $name = null) + { + $current = $this->getBcc(); + $current[$address] = $name; + + return $this->setBcc($current); + } + + /** + * Set the Bcc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setBcc($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Bcc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Bcc addresses of this message. + * + * @return array + */ + public function getBcc() + { + return $this->_getHeaderFieldModel('Bcc'); + } + + /** + * Set the priority of this message. + * + * The value is an integer where 1 is the highest priority and 5 is the lowest. + * + * @param int $priority + * + * @return Swift_Mime_SimpleMessage + */ + public function setPriority($priority) + { + $priorityMap = array( + 1 => 'Highest', + 2 => 'High', + 3 => 'Normal', + 4 => 'Low', + 5 => 'Lowest', + ); + $pMapKeys = array_keys($priorityMap); + if ($priority > max($pMapKeys)) { + $priority = max($pMapKeys); + } elseif ($priority < min($pMapKeys)) { + $priority = min($pMapKeys); + } + if (!$this->_setHeaderFieldModel('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { + $this->getHeaders()->addTextHeader('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority])); + } + + return $this; + } + + /** + * Get the priority of this message. + * + * The returned value is an integer where 1 is the highest priority and 5 + * is the lowest. + * + * @return int + */ + public function getPriority() + { + list($priority) = sscanf($this->_getHeaderFieldModel('X-Priority'), + '%[1-5]' + ); + + return isset($priority) ? $priority : 3; + } + + /** + * Ask for a delivery receipt from the recipient to be sent to $addresses. + * + * @param array $addresses + * + * @return Swift_Mime_SimpleMessage + */ + public function setReadReceiptTo($addresses) + { + if (!$this->_setHeaderFieldModel('Disposition-Notification-To', $addresses)) { + $this->getHeaders() + ->addMailboxHeader('Disposition-Notification-To', $addresses); + } + + return $this; + } + + /** + * Get the addresses to which a read-receipt will be sent. + * + * @return string + */ + public function getReadReceiptTo() + { + return $this->_getHeaderFieldModel('Disposition-Notification-To'); + } + + /** + * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return Swift_Mime_SimpleMessage + */ + public function attach(Swift_Mime_MimeEntity $entity) + { + $this->setChildren(array_merge($this->getChildren(), array($entity))); + + return $this; + } + + /** + * Remove an already attached entity. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return Swift_Mime_SimpleMessage + */ + public function detach(Swift_Mime_MimeEntity $entity) + { + $newChildren = array(); + foreach ($this->getChildren() as $child) { + if ($entity !== $child) { + $newChildren[] = $child; + } + } + $this->setChildren($newChildren); + + return $this; + } + + /** + * Attach a {@link Swift_Mime_MimeEntity} and return it's CID source. + * This method should be used when embedding images or other data in a message. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return string + */ + public function embed(Swift_Mime_MimeEntity $entity) + { + $this->attach($entity); + + return 'cid:'.$entity->getId(); + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + $string = parent::toString(); + $this->setChildren($children); + } else { + $string = parent::toString(); + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream $is + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + parent::toByteStream($is); + $this->setChildren($children); + } else { + parent::toByteStream($is); + } + } + + /** @see Swift_Mime_SimpleMimeEntity::_getIdField() */ + protected function _getIdField() + { + return 'Message-ID'; + } + + /** Turn the body of this message into a child of itself if needed */ + protected function _becomeMimePart() + { + $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), + $this->_getCache(), $this->_getGrammar(), $this->_userCharset + ); + $part->setContentType($this->_userContentType); + $part->setBody($this->getBody()); + $part->setFormat($this->_userFormat); + $part->setDelSp($this->_userDelSp); + $part->_setNestingLevel($this->_getTopNestingLevel()); + + return $part; + } + + /** Get the highest nesting level nested inside this message */ + private function _getTopNestingLevel() + { + $highestLevel = $this->getNestingLevel(); + foreach ($this->getChildren() as $child) { + $childLevel = $child->getNestingLevel(); + if ($highestLevel < $childLevel) { + $highestLevel = $childLevel; + } + } + + return $highestLevel; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php new file mode 100644 index 000000000..8e14ba86e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -0,0 +1,867 @@ + array(self::LEVEL_TOP, self::LEVEL_MIXED), + 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE), + 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED), + ); + + /** A set of filter rules to define what level an entity should be nested at */ + private $_compoundLevelFilters = array(); + + /** The nesting level of this entity */ + private $_nestingLevel = self::LEVEL_ALTERNATIVE; + + /** A KeyCache instance used during encoding and streaming */ + private $_cache; + + /** Direct descendants of this entity */ + private $_immediateChildren = array(); + + /** All descendants of this entity */ + private $_children = array(); + + /** The maximum line length of the body of this entity */ + private $_maxLineLength = 78; + + /** The order in which alternative mime types should appear */ + private $_alternativePartOrder = array( + 'text/plain' => 1, + 'text/html' => 2, + 'multipart/related' => 3, + ); + + /** The CID of this entity */ + private $_id; + + /** The key used for accessing the cache */ + private $_cacheKey; + + protected $_userContentType; + + /** + * Create a new SimpleMimeEntity with $headers, $encoder and $cache. + * + * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_Mime_Grammar $grammar + */ + public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar) + { + $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); + $this->_cache = $cache; + $this->_headers = $headers; + $this->_grammar = $grammar; + $this->setEncoder($encoder); + $this->_headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding')); + + // This array specifies that, when the entire MIME document contains + // $compoundLevel, then for each child within $level, if its Content-Type + // is $contentType then it should be treated as if it's level is + // $neededLevel instead. I tried to write that unambiguously! :-\ + // Data Structure: + // array ( + // $compoundLevel => array( + // $level => array( + // $contentType => $neededLevel + // ) + // ) + // ) + + $this->_compoundLevelFilters = array( + (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array( + self::LEVEL_ALTERNATIVE => array( + 'text/plain' => self::LEVEL_ALTERNATIVE, + 'text/html' => self::LEVEL_RELATED, + ), + ), + ); + + $this->_id = $this->getRandomId(); + } + + /** + * Generate a new Content-ID or Message-ID for this MIME entity. + * + * @return string + */ + public function generateId() + { + $this->setId($this->getRandomId()); + + return $this->_id; + } + + /** + * Get the {@link Swift_Mime_HeaderSet} for this entity. + * + * @return Swift_Mime_HeaderSet + */ + public function getHeaders() + { + return $this->_headers; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE + * + * @return int + */ + public function getNestingLevel() + { + return $this->_nestingLevel; + } + + /** + * Get the Content-type of this entity. + * + * @return string + */ + public function getContentType() + { + return $this->_getHeaderFieldModel('Content-Type'); + } + + /** + * Set the Content-type of this entity. + * + * @param string $type + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setContentType($type) + { + $this->_setContentTypeInHeaders($type); + // Keep track of the value so that if the content-type changes automatically + // due to added child entities, it can be restored if they are later removed + $this->_userContentType = $type; + + return $this; + } + + /** + * Get the CID of this entity. + * + * The CID will only be present in headers if a Content-ID header is present. + * + * @return string + */ + public function getId() + { + $tmp = (array) $this->_getHeaderFieldModel($this->_getIdField()); + + return $this->_headers->has($this->_getIdField()) ? current($tmp) : $this->_id; + } + + /** + * Set the CID of this entity. + * + * @param string $id + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setId($id) + { + if (!$this->_setHeaderFieldModel($this->_getIdField(), $id)) { + $this->_headers->addIdHeader($this->_getIdField(), $id); + } + $this->_id = $id; + + return $this; + } + + /** + * Get the description of this entity. + * + * This value comes from the Content-Description header if set. + * + * @return string + */ + public function getDescription() + { + return $this->_getHeaderFieldModel('Content-Description'); + } + + /** + * Set the description of this entity. + * + * This method sets a value in the Content-ID header. + * + * @param string $description + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setDescription($description) + { + if (!$this->_setHeaderFieldModel('Content-Description', $description)) { + $this->_headers->addTextHeader('Content-Description', $description); + } + + return $this; + } + + /** + * Get the maximum line length of the body of this entity. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->_maxLineLength; + } + + /** + * Set the maximum line length of lines in this body. + * + * Though not enforced by the library, lines should not exceed 1000 chars. + * + * @param int $length + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setMaxLineLength($length) + { + $this->_maxLineLength = $length; + + return $this; + } + + /** + * Get all children added to this entity. + * + * @return Swift_Mime_MimeEntity[] + */ + public function getChildren() + { + return $this->_children; + } + + /** + * Set all children of this entity. + * + * @param Swift_Mime_MimeEntity[] $children + * @param int $compoundLevel For internal use only + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setChildren(array $children, $compoundLevel = null) + { + // TODO: Try to refactor this logic + + $compoundLevel = isset($compoundLevel) + ? $compoundLevel + : $this->_getCompoundLevel($children) + ; + + $immediateChildren = array(); + $grandchildren = array(); + $newContentType = $this->_userContentType; + + foreach ($children as $child) { + $level = $this->_getNeededChildLevel($child, $compoundLevel); + if (empty($immediateChildren)) { + //first iteration + $immediateChildren = array($child); + } else { + $nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + if ($nextLevel == $level) { + $immediateChildren[] = $child; + } elseif ($level < $nextLevel) { + // Re-assign immediateChildren to grandchildren + $grandchildren = array_merge($grandchildren, $immediateChildren); + // Set new children + $immediateChildren = array($child); + } else { + $grandchildren[] = $child; + } + } + } + + if (!empty($immediateChildren)) { + $lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + + // Determine which composite media type is needed to accommodate the + // immediate children + foreach ($this->_compositeRanges as $mediaType => $range) { + if ($lowestLevel > $range[0] + && $lowestLevel <= $range[1]) { + $newContentType = $mediaType; + break; + } + } + + // Put any grandchildren in a subpart + if (!empty($grandchildren)) { + $subentity = $this->_createChild(); + $subentity->_setNestingLevel($lowestLevel); + $subentity->setChildren($grandchildren, $compoundLevel); + array_unshift($immediateChildren, $subentity); + } + } + + $this->_immediateChildren = $immediateChildren; + $this->_children = $children; + $this->_setContentTypeInHeaders($newContentType); + $this->_fixHeaders(); + $this->_sortChildren(); + + return $this; + } + + /** + * Get the body of this entity as a string. + * + * @return string + */ + public function getBody() + { + return ($this->_body instanceof Swift_OutputByteStream) + ? $this->_readStream($this->_body) + : $this->_body; + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setBody($body, $contentType = null) + { + if ($body !== $this->_body) { + $this->_clearCache(); + } + + $this->_body = $body; + if (isset($contentType)) { + $this->setContentType($contentType); + } + + return $this; + } + + /** + * Get the encoder used for the body of this entity. + * + * @return Swift_Mime_ContentEncoder + */ + public function getEncoder() + { + return $this->_encoder; + } + + /** + * Set the encoder used for the body of this entity. + * + * @param Swift_Mime_ContentEncoder $encoder + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setEncoder(Swift_Mime_ContentEncoder $encoder) + { + if ($encoder !== $this->_encoder) { + $this->_clearCache(); + } + + $this->_encoder = $encoder; + $this->_setEncoding($encoder->getName()); + $this->_notifyEncoderChanged($encoder); + + return $this; + } + + /** + * Get the boundary used to separate children in this entity. + * + * @return string + */ + public function getBoundary() + { + if (!isset($this->_boundary)) { + $this->_boundary = '_=_swift_v4_'.time().'_'.md5(getmypid().mt_rand().uniqid('', true)).'_=_'; + } + + return $this->_boundary; + } + + /** + * Set the boundary used to separate children in this entity. + * + * @param string $boundary + * + * @throws Swift_RfcComplianceException + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setBoundary($boundary) + { + $this->_assertValidBoundary($boundary); + $this->_boundary = $boundary; + + return $this; + } + + /** + * Receive notification that the charset of this entity, or a parent entity + * has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_notifyCharsetChanged($charset); + } + + /** + * Receive notification that the encoder of this entity or a parent entity + * has changed. + * + * @param Swift_Mime_ContentEncoder $encoder + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) + { + $this->_notifyEncoderChanged($encoder); + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + public function toString() + { + $string = $this->_headers->toString(); + $string .= $this->_bodyToString(); + + return $string; + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + protected function _bodyToString() + { + $string = ''; + + if (isset($this->_body) && empty($this->_immediateChildren)) { + if ($this->_cache->hasKey($this->_cacheKey, 'body')) { + $body = $this->_cache->getString($this->_cacheKey, 'body'); + } else { + $body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, + $this->getMaxLineLength() + ); + $this->_cache->setString($this->_cacheKey, 'body', $body, + Swift_KeyCache::MODE_WRITE + ); + } + $string .= $body; + } + + if (!empty($this->_immediateChildren)) { + foreach ($this->_immediateChildren as $child) { + $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; + $string .= $child->toString(); + } + $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this entire entity to a {@see Swift_InputByteStream}. + * + * @param Swift_InputByteStream + */ + public function toByteStream(Swift_InputByteStream $is) + { + $is->write($this->_headers->toString()); + $is->commit(); + + $this->_bodyToByteStream($is); + } + + /** + * Write this entire entity to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream + */ + protected function _bodyToByteStream(Swift_InputByteStream $is) + { + if (empty($this->_immediateChildren)) { + if (isset($this->_body)) { + if ($this->_cache->hasKey($this->_cacheKey, 'body')) { + $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is); + } else { + $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body'); + if ($cacheIs) { + $is->bind($cacheIs); + } + + $is->write("\r\n"); + + if ($this->_body instanceof Swift_OutputByteStream) { + $this->_body->setReadPointer(0); + + $this->_encoder->encodeByteStream($this->_body, $is, 0, $this->getMaxLineLength()); + } else { + $is->write($this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); + } + + if ($cacheIs) { + $is->unbind($cacheIs); + } + } + } + } + + if (!empty($this->_immediateChildren)) { + foreach ($this->_immediateChildren as $child) { + $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); + $child->toByteStream($is); + } + $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); + } + } + + /** + * Get the name of the header that provides the ID of this entity. + */ + protected function _getIdField() + { + return 'Content-ID'; + } + + /** + * Get the model data (usually an array or a string) for $field. + */ + protected function _getHeaderFieldModel($field) + { + if ($this->_headers->has($field)) { + return $this->_headers->get($field)->getFieldBodyModel(); + } + } + + /** + * Set the model data for $field. + */ + protected function _setHeaderFieldModel($field, $model) + { + if ($this->_headers->has($field)) { + $this->_headers->get($field)->setFieldBodyModel($model); + + return true; + } else { + return false; + } + } + + /** + * Get the parameter value of $parameter on $field header. + */ + protected function _getHeaderParameter($field, $parameter) + { + if ($this->_headers->has($field)) { + return $this->_headers->get($field)->getParameter($parameter); + } + } + + /** + * Set the parameter value of $parameter on $field header. + */ + protected function _setHeaderParameter($field, $parameter, $value) + { + if ($this->_headers->has($field)) { + $this->_headers->get($field)->setParameter($parameter, $value); + + return true; + } else { + return false; + } + } + + /** + * Re-evaluate what content type and encoding should be used on this entity. + */ + protected function _fixHeaders() + { + if (count($this->_immediateChildren)) { + $this->_setHeaderParameter('Content-Type', 'boundary', + $this->getBoundary() + ); + $this->_headers->remove('Content-Transfer-Encoding'); + } else { + $this->_setHeaderParameter('Content-Type', 'boundary', null); + $this->_setEncoding($this->_encoder->getName()); + } + } + + /** + * Get the KeyCache used in this entity. + * + * @return Swift_KeyCache + */ + protected function _getCache() + { + return $this->_cache; + } + + /** + * Get the grammar used for validation. + * + * @return Swift_Mime_Grammar + */ + protected function _getGrammar() + { + return $this->_grammar; + } + + /** + * Empty the KeyCache for this entity. + */ + protected function _clearCache() + { + $this->_cache->clearKey($this->_cacheKey, 'body'); + } + + /** + * Returns a random Content-ID or Message-ID. + * + * @return string + */ + protected function getRandomId() + { + $idLeft = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); + $idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; + $id = $idLeft.'@'.$idRight; + + try { + $this->_assertValidId($id); + } catch (Swift_RfcComplianceException $e) { + $id = $idLeft.'@swift.generated'; + } + + return $id; + } + + private function _readStream(Swift_OutputByteStream $os) + { + $string = ''; + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + $os->setReadPointer(0); + + return $string; + } + + private function _setEncoding($encoding) + { + if (!$this->_setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { + $this->_headers->addTextHeader('Content-Transfer-Encoding', $encoding); + } + } + + private function _assertValidBoundary($boundary) + { + if (!preg_match( + '/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', + $boundary)) { + throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); + } + } + + private function _setContentTypeInHeaders($type) + { + if (!$this->_setHeaderFieldModel('Content-Type', $type)) { + $this->_headers->addParameterizedHeader('Content-Type', $type); + } + } + + private function _setNestingLevel($level) + { + $this->_nestingLevel = $level; + } + + private function _getCompoundLevel($children) + { + $level = 0; + foreach ($children as $child) { + $level |= $child->getNestingLevel(); + } + + return $level; + } + + private function _getNeededChildLevel($child, $compoundLevel) + { + $filter = array(); + foreach ($this->_compoundLevelFilters as $bitmask => $rules) { + if (($compoundLevel & $bitmask) === $bitmask) { + $filter = $rules + $filter; + } + } + + $realLevel = $child->getNestingLevel(); + $lowercaseType = strtolower($child->getContentType()); + + if (isset($filter[$realLevel]) + && isset($filter[$realLevel][$lowercaseType])) { + return $filter[$realLevel][$lowercaseType]; + } else { + return $realLevel; + } + } + + private function _createChild() + { + return new self($this->_headers->newInstance(), + $this->_encoder, $this->_cache, $this->_grammar); + } + + private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) + { + foreach ($this->_immediateChildren as $child) { + $child->encoderChanged($encoder); + } + } + + private function _notifyCharsetChanged($charset) + { + $this->_encoder->charsetChanged($charset); + $this->_headers->charsetChanged($charset); + foreach ($this->_immediateChildren as $child) { + $child->charsetChanged($charset); + } + } + + private function _sortChildren() + { + $shouldSort = false; + foreach ($this->_immediateChildren as $child) { + // NOTE: This include alternative parts moved into a related part + if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE) { + $shouldSort = true; + break; + } + } + + // Sort in order of preference, if there is one + if ($shouldSort) { + usort($this->_immediateChildren, array($this, '_childSortAlgorithm')); + } + } + + private function _childSortAlgorithm($a, $b) + { + $typePrefs = array(); + $types = array( + strtolower($a->getContentType()), + strtolower($b->getContentType()), + ); + foreach ($types as $type) { + $typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder)) + ? $this->_alternativePartOrder[$type] + : (max($this->_alternativePartOrder) + 1); + } + + return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1; + } + + // -- Destructor + + /** + * Empties it's own contents from the cache. + */ + public function __destruct() + { + $this->_cache->clearAll($this->_cacheKey); + } + + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function _assertValidId($id) + { + if (!preg_match( + '/^'.$this->_grammar->getDefinition('id-left').'@'. + $this->_grammar->getDefinition('id-right').'$/D', + $id + )) { + throw new Swift_RfcComplianceException( + 'Invalid ID given <'.$id.'>' + ); + } + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_headers = clone $this->_headers; + $this->_encoder = clone $this->_encoder; + $this->_cacheKey = uniqid(); + $children = array(); + foreach ($this->_children as $pos => $child) { + $children[$pos] = clone $child; + } + $this->setChildren($children); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php new file mode 100644 index 000000000..215f8db34 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php @@ -0,0 +1,59 @@ +createDependenciesFor('mime.part') + ); + + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new MimePart. + * + * @param string $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Mime_MimePart + */ + public static function newInstance($body = null, $contentType = null, $charset = null) + { + return new self($body, $contentType, $charset); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php new file mode 100644 index 000000000..b38e1cf76 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Pretends messages have been sent, but just ignores them. + * + * @author Fabien Potencier + */ +class Swift_NullTransport extends Swift_Transport_NullTransport +{ + /** + * Create a new NullTransport. + */ + public function __construct() + { + call_user_func_array( + array($this, 'Swift_Transport_NullTransport::__construct'), + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.null') + ); + } + + /** + * Create a new NullTransport instance. + * + * @return Swift_NullTransport + */ + public static function newInstance() + { + return new self(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php new file mode 100644 index 000000000..1f26f9be5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php @@ -0,0 +1,46 @@ +setThreshold($threshold); + $this->setSleepTime($sleep); + $this->_sleeper = $sleeper; + } + + /** + * Set the number of emails to send before restarting. + * + * @param int $threshold + */ + public function setThreshold($threshold) + { + $this->_threshold = $threshold; + } + + /** + * Get the number of emails to send before restarting. + * + * @return int + */ + public function getThreshold() + { + return $this->_threshold; + } + + /** + * Set the number of seconds to sleep for during a restart. + * + * @param int $sleep time + */ + public function setSleepTime($sleep) + { + $this->_sleep = $sleep; + } + + /** + * Get the number of seconds to sleep for during a restart. + * + * @return int + */ + public function getSleepTime() + { + return $this->_sleep; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + ++$this->_counter; + if ($this->_counter >= $this->_threshold) { + $transport = $evt->getTransport(); + $transport->stop(); + if ($this->_sleep) { + $this->sleep($this->_sleep); + } + $transport->start(); + $this->_counter = 0; + } + } + + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->_sleeper)) { + $this->_sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php new file mode 100644 index 000000000..f7e18d0eb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -0,0 +1,164 @@ +getMessage(); + $message->toByteStream($this); + } + + /** + * Invoked immediately following a command being sent. + * + * @param Swift_Events_CommandEvent $evt + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->_out += strlen($command); + } + + /** + * Invoked immediately following a response coming back. + * + * @param Swift_Events_ResponseEvent $evt + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->_in += strlen($response); + } + + /** + * Called when a message is sent so that the outgoing counter can be increased. + * + * @param string $bytes + */ + public function write($bytes) + { + $this->_out += strlen($bytes); + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->_mirrors[$k]); + } + } + } + + /** + * Not used. + */ + public function flushBuffers() + { + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } + + /** + * Get the total number of bytes sent to the server. + * + * @return int + */ + public function getBytesOut() + { + return $this->_out; + } + + /** + * Get the total number of bytes received from the server. + * + * @return int + */ + public function getBytesIn() + { + return $this->_in; + } + + /** + * Reset the internal counters to zero. + */ + public function reset() + { + $this->_out = 0; + $this->_in = 0; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php new file mode 100644 index 000000000..9f9f08b56 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php @@ -0,0 +1,31 @@ + + * $replacements = array( + * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), + * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") + * ) + * + * + * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, + * the object should return just the array of replacements for the address + * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + */ + public function __construct($replacements) + { + $this->setReplacements($replacements); + } + + /** + * Sets replacements. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + * + * @see __construct() + */ + public function setReplacements($replacements) + { + if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { + $this->_replacements = (array) $replacements; + } else { + $this->_replacements = $replacements; + } + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $this->_restoreMessage($message); + $to = array_keys($message->getTo()); + $address = array_shift($to); + if ($replacements = $this->getReplacementsFor($address)) { + $body = $message->getBody(); + $search = array_keys($replacements); + $replace = array_values($replacements); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $this->_originalBody = $body; + $message->setBody($bodyReplaced); + } + + foreach ($message->getHeaders()->getAll() as $header) { + $body = $header->getFieldBodyModel(); + $count = 0; + if (is_array($body)) { + $bodyReplaced = array(); + foreach ($body as $key => $value) { + $count1 = 0; + $count2 = 0; + $key = is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; + $value = is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; + $bodyReplaced[$key] = $value; + + if (!$count && ($count1 || $count2)) { + $count = 1; + } + } + } else { + $bodyReplaced = str_replace($search, $replace, $body, $count); + } + + if ($count) { + $this->_originalHeaders[$header->getFieldName()] = $body; + $header->setFieldBodyModel($bodyReplaced); + } + } + + $children = (array) $message->getChildren(); + foreach ($children as $child) { + list($type) = sscanf($child->getContentType(), '%[^/]/%s'); + if ('text' == $type) { + $body = $child->getBody(); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $child->setBody($bodyReplaced); + $this->_originalChildBodies[$child->getId()] = $body; + } + } + } + $this->_lastMessage = $message; + } + } + + /** + * Find a map of replacements for the address. + * + * If this plugin was provided with a delegate instance of + * {@link Swift_Plugins_Decorator_Replacements} then the call will be + * delegated to it. Otherwise, it will attempt to find the replacements + * from the array provided in the constructor. + * + * If no replacements can be found, an empty value (NULL) is returned. + * + * @param string $address + * + * @return array + */ + public function getReplacementsFor($address) + { + if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) { + return $this->_replacements->getReplacementsFor($address); + } else { + return isset($this->_replacements[$address]) + ? $this->_replacements[$address] + : null + ; + } + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->_restoreMessage($evt->getMessage()); + } + + /** Restore a changed message back to its original state */ + private function _restoreMessage(Swift_Mime_Message $message) + { + if ($this->_lastMessage === $message) { + if (isset($this->_originalBody)) { + $message->setBody($this->_originalBody); + $this->_originalBody = null; + } + if (!empty($this->_originalHeaders)) { + foreach ($message->getHeaders()->getAll() as $header) { + if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) { + $header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]); + } + } + $this->_originalHeaders = array(); + } + if (!empty($this->_originalChildBodies)) { + $children = (array) $message->getChildren(); + foreach ($children as $child) { + $id = $child->getId(); + if (array_key_exists($id, $this->_originalChildBodies)) { + $child->setBody($this->_originalChildBodies[$id]); + } + } + $this->_originalChildBodies = array(); + } + $this->_lastMessage = null; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php new file mode 100644 index 000000000..7552b67a2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -0,0 +1,69 @@ +_sender = $sender; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); + + // save current recipients + $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); + + // replace them with the one to send to + $message->setReturnPath($this->_sender); + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + + // restore original headers + $headers = $message->getHeaders(); + + if ($headers->has('X-Swift-Return-Path')) { + $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); + $headers->removeAll('X-Swift-Return-Path'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php new file mode 100644 index 000000000..d9bce8935 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php @@ -0,0 +1,36 @@ +_logger = $logger; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->_logger->add($entry); + } + + /** + * Clear the log contents. + */ + public function clear() + { + $this->_logger->clear(); + } + + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return $this->_logger->dump(); + } + + /** + * Invoked immediately following a command being sent. + * + * @param Swift_Events_CommandEvent $evt + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->_logger->add(sprintf('>> %s', $command)); + } + + /** + * Invoked immediately following a response coming back. + * + * @param Swift_Events_ResponseEvent $evt + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->_logger->add(sprintf('<< %s', $response)); + } + + /** + * Invoked just before a Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf('++ Starting %s', $transportName)); + } + + /** + * Invoked immediately after the Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf('++ %s started', $transportName)); + } + + /** + * Invoked just before a Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf('++ Stopping %s', $transportName)); + } + + /** + * Invoked immediately after the Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf('++ %s stopped', $transportName)); + } + + /** + * Invoked as a TransportException is thrown in the Transport system. + * + * @param Swift_Events_TransportExceptionEvent $evt + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) + { + $e = $evt->getException(); + $message = $e->getMessage(); + $code = $e->getCode(); + $this->_logger->add(sprintf('!! %s (code: %s)', $message, $code)); + $message .= PHP_EOL; + $message .= 'Log data:'.PHP_EOL; + $message .= $this->_logger->dump(); + $evt->cancelBubble(); + throw new Swift_TransportException($message, $code, $e->getPrevious()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php new file mode 100644 index 000000000..865bb0aa3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -0,0 +1,72 @@ +_size = $size; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->_log[] = $entry; + while (count($this->_log) > $this->_size) { + array_shift($this->_log); + } + } + + /** + * Clear the log contents. + */ + public function clear() + { + $this->_log = array(); + } + + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return implode(PHP_EOL, $this->_log); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php new file mode 100644 index 000000000..3583297ab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php @@ -0,0 +1,58 @@ +_isHtml = $isHtml; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + if ($this->_isHtml) { + printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '
', PHP_EOL); + } else { + printf('%s%s', $entry, PHP_EOL); + } + } + + /** + * Not implemented. + */ + public function clear() + { + } + + /** + * Not implemented. + */ + public function dump() + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php new file mode 100644 index 000000000..e622cb37d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -0,0 +1,74 @@ +messages = array(); + } + + /** + * Get the message list. + * + * @return array + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Get the message count. + * + * @return int count + */ + public function countMessages() + { + return count($this->messages); + } + + /** + * Empty the message list. + */ + public function clear() + { + $this->messages = array(); + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $this->messages[] = clone $evt->getMessage(); + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php new file mode 100644 index 000000000..fb99e4c94 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php @@ -0,0 +1,31 @@ +_host = $host; + $this->_port = $port; + $this->_crypto = $crypto; + } + + /** + * Create a new PopBeforeSmtpPlugin for $host and $port. + * + * @param string $host + * @param int $port + * @param string $crypto as "tls" or "ssl" + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public static function newInstance($host, $port = 110, $crypto = null) + { + return new self($host, $port, $crypto); + } + + /** + * Set a Pop3Connection to delegate to instead of connecting directly. + * + * @param Swift_Plugins_Pop_Pop3Connection $connection + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) + { + $this->_connection = $connection; + + return $this; + } + + /** + * Bind this plugin to a specific SMTP transport instance. + * + * @param Swift_Transport + */ + public function bindSmtp(Swift_Transport $smtp) + { + $this->_transport = $smtp; + } + + /** + * Set the connection timeout in seconds (default 10). + * + * @param int $timeout + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setTimeout($timeout) + { + $this->_timeout = (int) $timeout; + + return $this; + } + + /** + * Set the username to use when connecting (if needed). + * + * @param string $username + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setUsername($username) + { + $this->_username = $username; + + return $this; + } + + /** + * Set the password to use when connecting (if needed). + * + * @param string $password + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setPassword($password) + { + $this->_password = $password; + + return $this; + } + + /** + * Connect to the POP3 host and authenticate. + * + * @throws Swift_Plugins_Pop_Pop3Exception if connection fails + */ + public function connect() + { + if (isset($this->_connection)) { + $this->_connection->connect(); + } else { + if (!isset($this->_socket)) { + if (!$socket = fsockopen( + $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr) + ); + } + $this->_socket = $socket; + + if (false === $greeting = fgets($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to connect to POP3 host [%s]', trim($greeting)) + ); + } + + $this->_assertOk($greeting); + + if ($this->_username) { + $this->_command(sprintf("USER %s\r\n", $this->_username)); + $this->_command(sprintf("PASS %s\r\n", $this->_password)); + } + } + } + } + + /** + * Disconnect from the POP3 host. + */ + public function disconnect() + { + if (isset($this->_connection)) { + $this->_connection->disconnect(); + } else { + $this->_command("QUIT\r\n"); + if (!fclose($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('POP3 host [%s] connection could not be stopped', $this->_host) + ); + } + $this->_socket = null; + } + } + + /** + * Invoked just before a Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + if (isset($this->_transport)) { + if ($this->_transport !== $evt->getTransport()) { + return; + } + } + + $this->connect(); + $this->disconnect(); + } + + /** + * Not used. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + } + + /** + * Not used. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + } + + /** + * Not used. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + } + + private function _command($command) + { + if (!fwrite($this->_socket, $command)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to write command [%s] to POP3 host', trim($command)) + ); + } + + if (false === $response = fgets($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to read from POP3 host after command [%s]', trim($command)) + ); + } + + $this->_assertOk($response); + + return $response; + } + + private function _assertOk($response) + { + if (substr($response, 0, 3) != '+OK') { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('POP3 command failed [%s]', trim($response)) + ); + } + } + + private function _getHostString() + { + $host = $this->_host; + switch (strtolower($this->_crypto)) { + case 'ssl': + $host = 'ssl://'.$host; + break; + + case 'tls': + $host = 'tls://'.$host; + break; + } + + return $host; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php new file mode 100644 index 000000000..c3a1f8685 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -0,0 +1,213 @@ +_recipient = $recipient; + $this->_whitelist = $whitelist; + } + + /** + * Set the recipient of all messages. + * + * @param mixed $recipient + */ + public function setRecipient($recipient) + { + $this->_recipient = $recipient; + } + + /** + * Get the recipient of all messages. + * + * @return mixed + */ + public function getRecipient() + { + return $this->_recipient; + } + + /** + * Set a list of regular expressions to whitelist certain recipients. + * + * @param array $whitelist + */ + public function setWhitelist(array $whitelist) + { + $this->_whitelist = $whitelist; + } + + /** + * Get the whitelist. + * + * @return array + */ + public function getWhitelist() + { + return $this->_whitelist; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); + + // conditionally save current recipients + + if ($headers->has('to')) { + $headers->addMailboxHeader('X-Swift-To', $message->getTo()); + } + + if ($headers->has('cc')) { + $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); + } + + if ($headers->has('bcc')) { + $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); + } + + // Filter remaining headers against whitelist + $this->_filterHeaderSet($headers, 'To'); + $this->_filterHeaderSet($headers, 'Cc'); + $this->_filterHeaderSet($headers, 'Bcc'); + + // Add each hard coded recipient + $to = $message->getTo(); + if (null === $to) { + $to = array(); + } + + foreach ((array) $this->_recipient as $recipient) { + if (!array_key_exists($recipient, $to)) { + $message->addTo($recipient); + } + } + } + + /** + * Filter header set against a whitelist of regular expressions. + * + * @param Swift_Mime_HeaderSet $headerSet + * @param string $type + */ + private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) + { + foreach ($headerSet->getAll($type) as $headers) { + $headers->setNameAddresses($this->_filterNameAddresses($headers->getNameAddresses())); + } + } + + /** + * Filtered list of addresses => name pairs. + * + * @param array $recipients + * + * @return array + */ + private function _filterNameAddresses(array $recipients) + { + $filtered = array(); + + foreach ($recipients as $address => $name) { + if ($this->_isWhitelisted($address)) { + $filtered[$address] = $name; + } + } + + return $filtered; + } + + /** + * Matches address against whitelist of regular expressions. + * + * @param $recipient + * + * @return bool + */ + protected function _isWhitelisted($recipient) + { + if (in_array($recipient, (array) $this->_recipient)) { + return true; + } + + foreach ($this->_whitelist as $pattern) { + if (preg_match($pattern, $recipient)) { + return true; + } + } + + return false; + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->_restoreMessage($evt->getMessage()); + } + + private function _restoreMessage(Swift_Mime_Message $message) + { + // restore original headers + $headers = $message->getHeaders(); + + if ($headers->has('X-Swift-To')) { + $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); + $headers->removeAll('X-Swift-To'); + } else { + $message->setTo(null); + } + + if ($headers->has('X-Swift-Cc')) { + $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); + $headers->removeAll('X-Swift-Cc'); + } + + if ($headers->has('X-Swift-Bcc')) { + $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); + $headers->removeAll('X-Swift-Bcc'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php new file mode 100644 index 000000000..0f21b7d60 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -0,0 +1,32 @@ +_reporter = $reporter; + } + + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $failures = array_flip($evt->getFailedRecipients()); + foreach ((array) $message->getTo() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + foreach ((array) $message->getCc() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + foreach ((array) $message->getBcc() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php new file mode 100644 index 000000000..cad9d168e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -0,0 +1,59 @@ +_failures_cache[$address])) { + $this->_failures[] = $address; + $this->_failures_cache[$address] = true; + } + } + + /** + * Get an array of addresses for which delivery failed. + * + * @return array + */ + public function getFailedRecipients() + { + return $this->_failures; + } + + /** + * Clear the buffer (empty the list). + */ + public function clear() + { + $this->_failures = $this->_failures_cache = array(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php new file mode 100644 index 000000000..c62593557 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -0,0 +1,39 @@ +'.PHP_EOL; + echo 'PASS '.$address.PHP_EOL; + echo ''.PHP_EOL; + flush(); + } else { + echo '
'.PHP_EOL; + echo 'FAIL '.$address.PHP_EOL; + echo '
'.PHP_EOL; + flush(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php new file mode 100644 index 000000000..595c0f603 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php @@ -0,0 +1,24 @@ +_rate = $rate; + $this->_mode = $mode; + $this->_sleeper = $sleeper; + $this->_timer = $timer; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $time = $this->getTimestamp(); + if (!isset($this->_start)) { + $this->_start = $time; + } + $duration = $time - $this->_start; + + switch ($this->_mode) { + case self::BYTES_PER_MINUTE : + $sleep = $this->_throttleBytesPerMinute($duration); + break; + case self::MESSAGES_PER_SECOND : + $sleep = $this->_throttleMessagesPerSecond($duration); + break; + case self::MESSAGES_PER_MINUTE : + $sleep = $this->_throttleMessagesPerMinute($duration); + break; + default : + $sleep = 0; + break; + } + + if ($sleep > 0) { + $this->sleep($sleep); + } + } + + /** + * Invoked when a Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + parent::sendPerformed($evt); + ++$this->_messages; + } + + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->_sleeper)) { + $this->_sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } + + /** + * Get the current UNIX timestamp. + * + * @return int + */ + public function getTimestamp() + { + if (isset($this->_timer)) { + return $this->_timer->getTimestamp(); + } else { + return time(); + } + } + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleBytesPerMinute($timePassed) + { + $expectedDuration = $this->getBytesOut() / ($this->_rate / 60); + + return (int) ceil($expectedDuration - $timePassed); + } + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleMessagesPerSecond($timePassed) + { + $expectedDuration = $this->_messages / ($this->_rate); + + return (int) ceil($expectedDuration - $timePassed); + } + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleMessagesPerMinute($timePassed) + { + $expectedDuration = $this->_messages / ($this->_rate / 60); + + return (int) ceil($expectedDuration - $timePassed); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php new file mode 100644 index 000000000..9c8deb38a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php @@ -0,0 +1,24 @@ +register('properties.charset')->asValue($charset); + + return $this; + } + + /** + * Set the directory where temporary files can be saved. + * + * @param string $dir + * + * @return Swift_Preferences + */ + public function setTempDir($dir) + { + Swift_DependencyContainer::getInstance() + ->register('tempdir')->asValue($dir); + + return $this; + } + + /** + * Set the type of cache to use (i.e. "disk" or "array"). + * + * @param string $type + * + * @return Swift_Preferences + */ + public function setCacheType($type) + { + Swift_DependencyContainer::getInstance() + ->register('cache')->asAliasOf(sprintf('cache.%s', $type)); + + return $this; + } + + /** + * Set the QuotedPrintable dot escaper preference. + * + * @param bool $dotEscape + * + * @return Swift_Preferences + */ + public function setQPDotEscape($dotEscape) + { + $dotEscape = !empty($dotEscape); + Swift_DependencyContainer::getInstance() + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + ->addConstructorValue($dotEscape); + + return $this; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php new file mode 100644 index 000000000..2897474e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php @@ -0,0 +1,27 @@ +createDependenciesFor('transport.sendmail') + ); + + $this->setCommand($command); + } + + /** + * Create a new SendmailTransport instance. + * + * @param string $command + * + * @return Swift_SendmailTransport + */ + public static function newInstance($command = '/usr/sbin/sendmail -bs') + { + return new self($command); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php new file mode 100644 index 000000000..2e7a8726d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php @@ -0,0 +1,23 @@ + + * + * @deprecated + */ +class Swift_SignedMessage extends Swift_Message +{ +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php new file mode 100644 index 000000000..2d8176d90 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php @@ -0,0 +1,20 @@ + + */ +interface Swift_Signer +{ + public function reset(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php new file mode 100644 index 000000000..9ffcef39c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -0,0 +1,33 @@ + + */ +interface Swift_Signers_BodySigner extends Swift_Signer +{ + /** + * Change the Swift_Signed_Message to apply the singing. + * + * @param Swift_Message $message + * + * @return Swift_Signers_BodySigner + */ + public function signMessage(Swift_Message $message); + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php new file mode 100644 index 000000000..514b61aa3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -0,0 +1,702 @@ + + */ +class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner +{ + /** + * PrivateKey. + * + * @var string + */ + protected $_privateKey; + + /** + * DomainName. + * + * @var string + */ + protected $_domainName; + + /** + * Selector. + * + * @var string + */ + protected $_selector; + + /** + * Hash algorithm used. + * + * @var string + */ + protected $_hashAlgorithm = 'rsa-sha1'; + + /** + * Body canon method. + * + * @var string + */ + protected $_bodyCanon = 'simple'; + + /** + * Header canon method. + * + * @var string + */ + protected $_headerCanon = 'simple'; + + /** + * Headers not being signed. + * + * @var array + */ + protected $_ignoredHeaders = array(); + + /** + * Signer identity. + * + * @var unknown_type + */ + protected $_signerIdentity; + + /** + * BodyLength. + * + * @var int + */ + protected $_bodyLen = 0; + + /** + * Maximum signedLen. + * + * @var int + */ + protected $_maxLen = PHP_INT_MAX; + + /** + * Embbed bodyLen in signature. + * + * @var bool + */ + protected $_showLen = false; + + /** + * When the signature has been applied (true means time()), false means not embedded. + * + * @var mixed + */ + protected $_signatureTimestamp = true; + + /** + * When will the signature expires false means not embedded, if sigTimestamp is auto + * Expiration is relative, otherwhise it's absolute. + * + * @var int + */ + protected $_signatureExpiration = false; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $_debugHeaders = false; + + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + protected $_signedHeaders = array(); + + /** + * If debugHeaders is set store debugDatas here. + * + * @var string + */ + private $_debugHeadersData = ''; + + /** + * Stores the bodyHash. + * + * @var string + */ + private $_bodyHash = ''; + + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $_dkimHeader; + + /** + * Hash Handler. + * + * @var hash_ressource + */ + private $_headerHashHandler; + + private $_bodyHashHandler; + + private $_headerHash; + + private $_headerCanonData = ''; + + private $_bodyCanonEmptyCounter = 0; + + private $_bodyCanonIgnoreStart = 2; + + private $_bodyCanonSpace = false; + + private $_bodyCanonLastChar = null; + + private $_bodyCanonLine = ''; + + private $_bound = array(); + + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->_privateKey = $privateKey; + $this->_domainName = $domainName; + $this->_signerIdentity = '@'.$domainName; + $this->_selector = $selector; + } + + /** + * Instanciate DKIMSigner. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * + * @return Swift_Signers_DKIMSigner + */ + public static function newInstance($privateKey, $domainName, $selector) + { + return new static($privateKey, $domainName, $selector); + } + + /** + * Reset the Signer. + * + * @see Swift_Signer::reset() + */ + public function reset() + { + $this->_headerHash = null; + $this->_signedHeaders = array(); + $this->_headerHashHandler = null; + $this->_bodyHash = null; + $this->_bodyHashHandler = null; + $this->_bodyCanonIgnoreStart = 2; + $this->_bodyCanonEmptyCounter = 0; + $this->_bodyCanonLastChar = null; + $this->_bodyCanonSpace = false; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes) + { + $this->_canonicalizeBody($bytes); + foreach ($this->_bound as $is) { + $is->write($bytes); + } + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + // Nothing to do + return; + } + + /** + * Attach $is to this stream. + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->_bound[] = $is; + + return; + } + + /** + * Remove an already bound stream. + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->_bound as $k => $stream) { + if ($stream === $is) { + unset($this->_bound[$k]); + + return; + } + } + + return; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + $this->reset(); + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. + * + * @param string $hash + * + * @return Swift_Signers_DKIMSigner + */ + public function setHashAlgorithm($hash) + { + // Unable to sign with rsa-sha256 + if ($hash == 'rsa-sha1') { + $this->_hashAlgorithm = 'rsa-sha1'; + } else { + $this->_hashAlgorithm = 'rsa-sha256'; + } + + return $this; + } + + /** + * Set the body canonicalization algorithm. + * + * @param string $canon + * + * @return Swift_Signers_DKIMSigner + */ + public function setBodyCanon($canon) + { + if ($canon == 'relaxed') { + $this->_bodyCanon = 'relaxed'; + } else { + $this->_bodyCanon = 'simple'; + } + + return $this; + } + + /** + * Set the header canonicalization algorithm. + * + * @param string $canon + * + * @return Swift_Signers_DKIMSigner + */ + public function setHeaderCanon($canon) + { + if ($canon == 'relaxed') { + $this->_headerCanon = 'relaxed'; + } else { + $this->_headerCanon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity. + * + * @param string $identity + * + * @return Swift_Signers_DKIMSigner + */ + public function setSignerIdentity($identity) + { + $this->_signerIdentity = $identity; + + return $this; + } + + /** + * Set the length of the body to sign. + * + * @param mixed $len (bool or int) + * + * @return Swift_Signers_DKIMSigner + */ + public function setBodySignedLen($len) + { + if ($len === true) { + $this->_showLen = true; + $this->_maxLen = PHP_INT_MAX; + } elseif ($len === false) { + $this->showLen = false; + $this->_maxLen = PHP_INT_MAX; + } else { + $this->_showLen = true; + $this->_maxLen = (int) $len; + } + + return $this; + } + + /** + * Set the signature timestamp. + * + * @param timestamp $time + * + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureTimestamp($time) + { + $this->_signatureTimestamp = $time; + + return $this; + } + + /** + * Set the signature expiration timestamp. + * + * @param timestamp $time + * + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureExpiration($time) + { + $this->_signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body. + */ + public function startBody() + { + // Init + switch ($this->_hashAlgorithm) { + case 'rsa-sha256' : + $this->_bodyHashHandler = hash_init('sha256'); + break; + case 'rsa-sha1' : + $this->_bodyHashHandler = hash_init('sha1'); + break; + } + $this->_bodyCanonLine = ''; + } + + /** + * End Body. + */ + public function endBody() + { + $this->_endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->_debugHeaders) { + return array('DKIM-Signature', 'X-DebugHash'); + } else { + return array('DKIM-Signature'); + } + } + + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return Swift_Signers_DKIMSigner + */ + public function ignoreHeader($header_name) + { + $this->_ignoredHeaders[strtolower($header_name)] = true; + + return $this; + } + + /** + * Set the headers to sign. + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_DKIMSigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $this->_headerCanonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $this->_addHeader($header->toString()); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + + return $this; + } + + /** + * Add the signature to the given Headers. + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_DKIMSigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers) + { + // Prepare the DKIM-Signature + $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector); + if ($this->_bodyCanon != 'simple') { + $params['c'] = $this->_headerCanon.'/'.$this->_bodyCanon; + } elseif ($this->_headerCanon != 'simple') { + $params['c'] = $this->_headerCanon; + } + if ($this->_showLen) { + $params['l'] = $this->_bodyLen; + } + if ($this->_signatureTimestamp === true) { + $params['t'] = time(); + if ($this->_signatureExpiration !== false) { + $params['x'] = $params['t'] + $this->_signatureExpiration; + } + } else { + if ($this->_signatureTimestamp !== false) { + $params['t'] = $this->_signatureTimestamp; + } + if ($this->_signatureExpiration !== false) { + $params['x'] = $this->_signatureExpiration; + } + } + if ($this->_debugHeaders) { + $params['z'] = implode('|', $this->_debugHeadersData); + } + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DKIM-Signature', $string); + // Add the last DKIM-Signature + $tmp = $headers->getAll('DKIM-Signature'); + $this->_dkimHeader = end($tmp); + $this->_addHeader(trim($this->_dkimHeader->toString())."\r\n b=", true); + $this->_endOfHeaders(); + if ($this->_debugHeaders) { + $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash)); + } + $this->_dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '))); + + return $this; + } + + /* Private helpers */ + + protected function _addHeader($header, $is_sig = false) + { + switch ($this->_headerCanon) { + case 'relaxed' : + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); + case 'simple' : + // Nothing to do + } + $this->_addToHeaderHash($header); + } + + protected function _endOfHeaders() + { + //$this->_headerHash=hash_final($this->_headerHashHandler, true); + } + + protected function _canonicalizeBody($string) + { + $len = strlen($string); + $canon = ''; + $method = ($this->_bodyCanon == 'relaxed'); + for ($i = 0; $i < $len; ++$i) { + if ($this->_bodyCanonIgnoreStart > 0) { + --$this->_bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r" : + $this->_bodyCanonLastChar = "\r"; + break; + case "\n" : + if ($this->_bodyCanonLastChar == "\r") { + if ($method) { + $this->_bodyCanonSpace = false; + } + if ($this->_bodyCanonLine == '') { + ++$this->_bodyCanonEmptyCounter; + } else { + $this->_bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + // todo handle it but should never happen + } + break; + case ' ' : + case "\t" : + if ($method) { + $this->_bodyCanonSpace = true; + break; + } + default : + if ($this->_bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); + $this->_bodyCanonEmptyCounter = 0; + } + if ($this->_bodyCanonSpace) { + $this->_bodyCanonLine .= ' '; + $canon .= ' '; + $this->_bodyCanonSpace = false; + } + $this->_bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->_addToBodyHash($canon); + } + + protected function _endOfBody() + { + // Add trailing Line return if last line is non empty + if (strlen($this->_bodyCanonLine) > 0) { + $this->_addToBodyHash("\r\n"); + } + $this->_bodyHash = hash_final($this->_bodyHashHandler, true); + } + + private function _addToBodyHash($string) + { + $len = strlen($string); + if ($len > ($new_len = ($this->_maxLen - $this->_bodyLen))) { + $string = substr($string, 0, $new_len); + $len = $new_len; + } + hash_update($this->_bodyHashHandler, $string); + $this->_bodyLen += $len; + } + + private function _addToHeaderHash($header) + { + if ($this->_debugHeaders) { + $this->_debugHeadersData[] = trim($header); + } + $this->_headerCanonData .= $header; + } + + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function _getEncryptedHash() + { + $signature = ''; + switch ($this->_hashAlgorithm) { + case 'rsa-sha1': + $algorithm = OPENSSL_ALGO_SHA1; + break; + case 'rsa-sha256': + $algorithm = OPENSSL_ALGO_SHA256; + break; + } + $pkeyId = openssl_get_privatekey($this->_privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->_headerCanonData, $signature, $pkeyId, $algorithm)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php new file mode 100644 index 000000000..bceda3d73 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -0,0 +1,525 @@ + + */ +class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner +{ + /** + * PrivateKey. + * + * @var string + */ + protected $_privateKey; + + /** + * DomainName. + * + * @var string + */ + protected $_domainName; + + /** + * Selector. + * + * @var string + */ + protected $_selector; + + /** + * Hash algorithm used. + * + * @var string + */ + protected $_hashAlgorithm = 'rsa-sha1'; + + /** + * Canonisation method. + * + * @var string + */ + protected $_canon = 'simple'; + + /** + * Headers not being signed. + * + * @var array + */ + protected $_ignoredHeaders = array(); + + /** + * Signer identity. + * + * @var string + */ + protected $_signerIdentity; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $_debugHeaders = false; + + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + private $_signedHeaders = array(); + + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $_domainKeyHeader; + + /** + * Hash Handler. + * + * @var resource|null + */ + private $_hashHandler; + + private $_hash; + + private $_canonData = ''; + + private $_bodyCanonEmptyCounter = 0; + + private $_bodyCanonIgnoreStart = 2; + + private $_bodyCanonSpace = false; + + private $_bodyCanonLastChar = null; + + private $_bodyCanonLine = ''; + + private $_bound = array(); + + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->_privateKey = $privateKey; + $this->_domainName = $domainName; + $this->_signerIdentity = '@'.$domainName; + $this->_selector = $selector; + } + + /** + * Instanciate DomainKeySigner. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * + * @return Swift_Signers_DomainKeySigner + */ + public static function newInstance($privateKey, $domainName, $selector) + { + return new static($privateKey, $domainName, $selector); + } + + /** + * Resets internal states. + * + * @return Swift_Signers_DomainKeysSigner + */ + public function reset() + { + $this->_hash = null; + $this->_hashHandler = null; + $this->_bodyCanonIgnoreStart = 2; + $this->_bodyCanonEmptyCounter = 0; + $this->_bodyCanonLastChar = null; + $this->_bodyCanonSpace = false; + + return $this; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + * @return Swift_Signers_DomainKeysSigner + */ + public function write($bytes) + { + $this->_canonicalizeBody($bytes); + foreach ($this->_bound as $is) { + $is->write($bytes); + } + + return $this; + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + * + * @return Swift_Signers_DomainKeysSigner + */ + public function commit() + { + // Nothing to do + return $this; + } + + /** + * Attach $is to this stream. + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + * + * @return Swift_Signers_DomainKeysSigner + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->_bound[] = $is; + + return $this; + } + + /** + * Remove an already bound stream. + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + * + * @return Swift_Signers_DomainKeysSigner + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->_bound as $k => $stream) { + if ($stream === $is) { + unset($this->_bound[$k]); + + return; + } + } + + return $this; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + * + * @return Swift_Signers_DomainKeysSigner + */ + public function flushBuffers() + { + $this->reset(); + + return $this; + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. + * + * @param string $hash + * + * @return Swift_Signers_DomainKeysSigner + */ + public function setHashAlgorithm($hash) + { + $this->_hashAlgorithm = 'rsa-sha1'; + + return $this; + } + + /** + * Set the canonicalization algorithm. + * + * @param string $canon simple | nofws defaults to simple + * + * @return Swift_Signers_DomainKeysSigner + */ + public function setCanon($canon) + { + if ($canon == 'nofws') { + $this->_canon = 'nofws'; + } else { + $this->_canon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity. + * + * @param string $identity + * + * @return Swift_Signers_DomainKeySigner + */ + public function setSignerIdentity($identity) + { + $this->_signerIdentity = $identity; + + return $this; + } + + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return Swift_Signers_DomainKeySigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body. + */ + public function startBody() + { + } + + /** + * End Body. + */ + public function endBody() + { + $this->_endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->_debugHeaders) { + return array('DomainKey-Signature', 'X-DebugHash'); + } else { + return array('DomainKey-Signature'); + } + } + + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return Swift_Signers_DomainKeySigner + */ + public function ignoreHeader($header_name) + { + $this->_ignoredHeaders[strtolower($header_name)] = true; + + return $this; + } + + /** + * Set the headers to sign. + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_DomainKeySigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $this->_startHash(); + $this->_canonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $this->_addHeader($header->toString()); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + $this->_endOfHeaders(); + + return $this; + } + + /** + * Add the signature to the given Headers. + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_DomainKeySigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers) + { + // Prepare the DomainKey-Signature Header + $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector); + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DomainKey-Signature', $string); + + return $this; + } + + /* Private helpers */ + + protected function _addHeader($header) + { + switch ($this->_canon) { + case 'nofws' : + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value)."\r\n"; + case 'simple' : + // Nothing to do + } + $this->_addToHash($header); + } + + protected function _endOfHeaders() + { + $this->_bodyCanonEmptyCounter = 1; + } + + protected function _canonicalizeBody($string) + { + $len = strlen($string); + $canon = ''; + $nofws = ($this->_canon == 'nofws'); + for ($i = 0; $i < $len; ++$i) { + if ($this->_bodyCanonIgnoreStart > 0) { + --$this->_bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r" : + $this->_bodyCanonLastChar = "\r"; + break; + case "\n" : + if ($this->_bodyCanonLastChar == "\r") { + if ($nofws) { + $this->_bodyCanonSpace = false; + } + if ($this->_bodyCanonLine == '') { + ++$this->_bodyCanonEmptyCounter; + } else { + $this->_bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); + } + break; + case ' ' : + case "\t" : + case "\x09": //HTAB + if ($nofws) { + $this->_bodyCanonSpace = true; + break; + } + default : + if ($this->_bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); + $this->_bodyCanonEmptyCounter = 0; + } + $this->_bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->_addToHash($canon); + } + + protected function _endOfBody() + { + if (strlen($this->_bodyCanonLine) > 0) { + $this->_addToHash("\r\n"); + } + $this->_hash = hash_final($this->_hashHandler, true); + } + + private function _addToHash($string) + { + $this->_canonData .= $string; + hash_update($this->_hashHandler, $string); + } + + private function _startHash() + { + // Init + switch ($this->_hashAlgorithm) { + case 'rsa-sha1' : + $this->_hashHandler = hash_init('sha1'); + break; + } + $this->_canonLine = ''; + } + + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function _getEncryptedHash() + { + $signature = ''; + $pkeyId = openssl_get_privatekey($this->_privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->_canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php new file mode 100644 index 000000000..c75cb08a5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -0,0 +1,65 @@ + + */ +interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream +{ + /** + * Exclude an header from the signed headers. + * + * @param string $header_name + * + * @return Swift_Signers_HeaderSigner + */ + public function ignoreHeader($header_name); + + /** + * Prepare the Signer to get a new Body. + * + * @return Swift_Signers_HeaderSigner + */ + public function startBody(); + + /** + * Give the signal that the body has finished streaming. + * + * @return Swift_Signers_HeaderSigner + */ + public function endBody(); + + /** + * Give the headers already given. + * + * @param Swift_Mime_SimpleHeaderSet $headers + * + * @return Swift_Signers_HeaderSigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers); + + /** + * Add the header(s) to the headerSet. + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_HeaderSigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers); + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php new file mode 100644 index 000000000..9f1022cd8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -0,0 +1,189 @@ + + */ +class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner +{ + private $_peclLoaded = false; + + private $_dkimHandler = null; + + private $dropFirstLF = true; + + const CANON_RELAXED = 1; + const CANON_SIMPLE = 2; + const SIG_RSA_SHA1 = 3; + const SIG_RSA_SHA256 = 4; + + public function __construct($privateKey, $domainName, $selector) + { + if (extension_loaded('opendkim')) { + $this->_peclLoaded = true; + } else { + throw new Swift_SwiftException('php-opendkim extension not found'); + } + parent::__construct($privateKey, $domainName, $selector); + } + + public static function newInstance($privateKey, $domainName, $selector) + { + return new static($privateKey, $domainName, $selector); + } + + public function addSignature(Swift_Mime_HeaderSet $headers) + { + $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); + $headerVal = $this->_dkimHandler->getSignatureHeader(); + if (!$headerVal) { + throw new Swift_SwiftException('OpenDKIM Error: '.$this->_dkimHandler->getError()); + } + $header->setValue($headerVal); + $headers->set($header); + + return $this; + } + + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $bodyLen = $this->_bodyLen; + if (is_bool($bodyLen)) { + $bodyLen = -1; + } + $hash = ($this->_hashAlgorithm == 'rsa-sha1') ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = ($this->_bodyCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = ($this->_headerCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); + // Hardcode signature Margin for now + $this->_dkimHandler->setMargin(78); + + if (!is_numeric($this->_signatureTimestamp)) { + OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); + } else { + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) { + throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); + } + } + if (isset($this->_signerIdentity)) { + $this->_dkimHandler->setSigner($this->_signerIdentity); + } + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + $tmp = $headers->getAll($hName); + if ($headers->has($hName)) { + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $htosign = $header->toString(); + $this->_dkimHandler->header($htosign); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + + return $this; + } + + public function startBody() + { + if (!$this->_peclLoaded) { + return parent::startBody(); + } + $this->dropFirstLF = true; + $this->_dkimHandler->eoh(); + + return $this; + } + + public function endBody() + { + if (!$this->_peclLoaded) { + return parent::endBody(); + } + $this->_dkimHandler->eom(); + + return $this; + } + + public function reset() + { + $this->_dkimHandler = null; + parent::reset(); + + return $this; + } + + /** + * Set the signature timestamp. + * + * @param timestamp $time + * + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureTimestamp($time) + { + $this->_signatureTimestamp = $time; + + return $this; + } + + /** + * Set the signature expiration timestamp. + * + * @param timestamp $time + * + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureExpiration($time) + { + $this->_signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + // Protected + + protected function _canonicalizeBody($string) + { + if (!$this->_peclLoaded) { + return parent::_canonicalizeBody($string); + } + if (false && $this->dropFirstLF === true) { + if ($string[0] == "\r" && $string[1] == "\n") { + $string = substr($string, 2); + } + } + $this->dropFirstLF = false; + if (strlen($string)) { + $this->_dkimHandler->body($string); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php new file mode 100644 index 000000000..d4c77e7f0 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -0,0 +1,437 @@ + + */ +class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner +{ + protected $signCertificate; + protected $signPrivateKey; + protected $encryptCert; + protected $signThenEncrypt = true; + protected $signLevel; + protected $encryptLevel; + protected $signOptions; + protected $encryptOptions; + protected $encryptCipher; + protected $extraCerts = null; + + /** + * @var Swift_StreamFilters_StringReplacementFilterFactory + */ + protected $replacementFactory; + + /** + * @var Swift_Mime_HeaderFactory + */ + protected $headerFactory; + + /** + * Constructor. + * + * @param string $certificate + * @param string $privateKey + * @param string $encryptCertificate + */ + public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) + { + if (null !== $signPrivateKey) { + $this->setSignCertificate($signCertificate, $signPrivateKey); + } + + if (null !== $encryptCertificate) { + $this->setEncryptCertificate($encryptCertificate); + } + + $this->replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->signOptions = PKCS7_DETACHED; + + // Supported since php5.4 + if (defined('OPENSSL_CIPHER_AES_128_CBC')) { + $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; + } else { + $this->encryptCipher = OPENSSL_CIPHER_RC2_128; + } + } + + /** + * Returns an new Swift_Signers_SMimeSigner instance. + * + * @param string $certificate + * @param string $privateKey + * + * @return Swift_Signers_SMimeSigner + */ + public static function newInstance($certificate = null, $privateKey = null) + { + return new self($certificate, $privateKey); + } + + /** + * Set the certificate location to use for signing. + * + * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php + * + * @param string $certificate + * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead + * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() + * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate + * + * @return Swift_Signers_SMimeSigner + */ + public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) + { + $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); + + if (null !== $privateKey) { + if (is_array($privateKey)) { + $this->signPrivateKey = $privateKey; + $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); + } else { + $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); + } + } + + $this->signOptions = $signOptions; + if (null !== $extraCerts) { + $this->extraCerts = str_replace('\\', '/', realpath($extraCerts)); + } + + return $this; + } + + /** + * Set the certificate location to use for encryption. + * + * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php + * @link http://nl3.php.net/manual/en/openssl.ciphers.php + * + * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. + * @param int $cipher + * + * @return Swift_Signers_SMimeSigner + */ + public function setEncryptCertificate($recipientCerts, $cipher = null) + { + if (is_array($recipientCerts)) { + $this->encryptCert = array(); + + foreach ($recipientCerts as $cert) { + $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); + } + } else { + $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); + } + + if (null !== $cipher) { + $this->encryptCipher = $cipher; + } + + return $this; + } + + /** + * @return string + */ + public function getSignCertificate() + { + return $this->signCertificate; + } + + /** + * @return string + */ + public function getSignPrivateKey() + { + return $this->signPrivateKey; + } + + /** + * Set perform signing before encryption. + * + * The default is to first sign the message and then encrypt. + * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. + * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. + * + * @param string $signThenEncrypt + * + * @return Swift_Signers_SMimeSigner + */ + public function setSignThenEncrypt($signThenEncrypt = true) + { + $this->signThenEncrypt = $signThenEncrypt; + + return $this; + } + + /** + * @return bool + */ + public function isSignThenEncrypt() + { + return $this->signThenEncrypt; + } + + /** + * Resets internal states. + * + * @return Swift_Signers_SMimeSigner + */ + public function reset() + { + return $this; + } + + /** + * Change the Swift_Message to apply the signing. + * + * @param Swift_Message $message + * + * @return Swift_Signers_SMimeSigner + */ + public function signMessage(Swift_Message $message) + { + if (null === $this->signCertificate && null === $this->encryptCert) { + return $this; + } + + // Store the message using ByteStream to a file{1} + // Remove all Children + // Sign file{1}, parse the new MIME headers and set them on the primary MimeEntity + // Set the singed-body as the new body (without boundary) + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $this->toSMimeByteStream($messageStream, $message); + $message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder')); + + $message->setChildren(array()); + $this->streamToMime($messageStream, $message); + } + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders() + { + return array('Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition'); + } + + /** + * @param Swift_InputByteStream $inputStream + * @param Swift_Message $mimeEntity + */ + protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message) + { + $mimeEntity = $this->createMessage($message); + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + $mimeEntity->toByteStream($messageStream); + $messageStream->commit(); + + if (null !== $this->signCertificate && null !== $this->encryptCert) { + $temporaryStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if ($this->signThenEncrypt) { + $this->messageStreamToSignedByteStream($messageStream, $temporaryStream); + $this->messageStreamToEncryptedByteStream($temporaryStream, $inputStream); + } else { + $this->messageStreamToEncryptedByteStream($messageStream, $temporaryStream); + $this->messageStreamToSignedByteStream($temporaryStream, $inputStream); + } + } elseif ($this->signCertificate !== null) { + $this->messageStreamToSignedByteStream($messageStream, $inputStream); + } else { + $this->messageStreamToEncryptedByteStream($messageStream, $inputStream); + } + } + + /** + * @param Swift_Message $message + * + * @return Swift_Message + */ + protected function createMessage(Swift_Message $message) + { + $mimeEntity = new Swift_Message('', $message->getBody(), $message->getContentType(), $message->getCharset()); + $mimeEntity->setChildren($message->getChildren()); + + $messageHeaders = $mimeEntity->getHeaders(); + $messageHeaders->remove('Message-ID'); + $messageHeaders->remove('Date'); + $messageHeaders->remove('Subject'); + $messageHeaders->remove('MIME-Version'); + $messageHeaders->remove('To'); + $messageHeaders->remove('From'); + + return $mimeEntity; + } + + /** + * @param Swift_FileStream $outputStream + * @param Swift_InputByteStream $inputStream + * + * @throws Swift_IoException + */ + protected function messageStreamToSignedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $inputStream) + { + $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + $args = array($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions); + if (null !== $this->extraCerts) { + $args[] = $this->extraCerts; + } + + if (!call_user_func_array('openssl_pkcs7_sign', $args)) { + throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); + } + + $this->copyFromOpenSSLOutput($signedMessageStream, $inputStream); + } + + /** + * @param Swift_FileStream $outputStream + * @param Swift_InputByteStream $is + * + * @throws Swift_IoException + */ + protected function messageStreamToEncryptedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $is) + { + $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_encrypt($outputStream->getPath(), $encryptedMessageStream->getPath(), $this->encryptCert, array(), 0, $this->encryptCipher)) { + throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); + } + + $this->copyFromOpenSSLOutput($encryptedMessageStream, $is); + } + + /** + * @param Swift_OutputByteStream $fromStream + * @param Swift_InputByteStream $toStream + */ + protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) + { + $bufferLength = 4096; + $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); + $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $filteredStream->write($buffer); + } + + $filteredStream->flushBuffers(); + + while (false !== ($buffer = $filteredStream->read($bufferLength))) { + $toStream->write($buffer); + } + + $toStream->commit(); + } + + /** + * Merges an OutputByteStream to Swift_Message. + * + * @param Swift_OutputByteStream $fromStream + * @param Swift_Message $message + */ + protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) + { + $bufferLength = 78; + $headerData = ''; + + $fromStream->setReadPointer(0); + + while (($buffer = $fromStream->read($bufferLength)) !== false) { + $headerData .= $buffer; + + if (false !== strpos($buffer, "\r\n\r\n")) { + break; + } + } + + $headersPosEnd = strpos($headerData, "\r\n\r\n"); + $headerData = trim($headerData); + $headerData = substr($headerData, 0, $headersPosEnd); + $headerLines = explode("\r\n", $headerData); + unset($headerData); + + $headers = array(); + $currentHeaderName = ''; + + foreach ($headerLines as $headerLine) { + // Line separated + if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' '.trim($headerLine); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0]); + $headers[$currentHeaderName] = trim($header[1]); + } + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + $messageHeaders = $message->getHeaders(); + + // No need to check for 'application/pkcs7-mime', as this is always base64 + if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) { + if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $headers['content-type'], $contentTypeData)) { + throw new Swift_SwiftException('Failed to find Boundary parameter'); + } + + $boundary = trim($contentTypeData['1'], '"'); + $boundaryLen = strlen($boundary); + + // Skip the header and CRLF CRLF + $fromStream->setReadPointer($headersPosEnd + 4); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $messageStream->write($buffer); + } + + $messageStream->commit(); + + $messageHeaders->remove('Content-Transfer-Encoding'); + $message->setContentType($headers['content-type']); + $message->setBoundary($boundary); + $message->setBody($messageStream); + } else { + $fromStream->setReadPointer($headersPosEnd + 4); + + if (null === $this->headerFactory) { + $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory'); + } + + $message->setContentType($headers['content-type']); + $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding'])); + $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition'])); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $messageStream->write($buffer); + } + + $messageStream->commit(); + $message->setBody($messageStream); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php new file mode 100644 index 000000000..625161140 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -0,0 +1,58 @@ +createDependenciesFor('transport.smtp') + ); + + $this->setHost($host); + $this->setPort($port); + $this->setEncryption($security); + } + + /** + * Create a new SmtpTransport instance. + * + * @param string $host + * @param int $port + * @param string $security + * + * @return Swift_SmtpTransport + */ + public static function newInstance($host = 'localhost', $port = 25, $security = null) + { + return new self($host, $port, $security); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php new file mode 100644 index 000000000..c16ab4b38 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Interface for spools. + * + * @author Fabien Potencier + */ +interface Swift_Spool +{ + /** + * Starts this Spool mechanism. + */ + public function start(); + + /** + * Stops this Spool mechanism. + */ + public function stop(); + + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted(); + + /** + * Queues a message. + * + * @param Swift_Mime_Message $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_Message $message); + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php new file mode 100644 index 000000000..cf9bf78fb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in a queue. + * + * @author Fabien Potencier + */ +class Swift_SpoolTransport extends Swift_Transport_SpoolTransport +{ + /** + * Create a new SpoolTransport. + * + * @param Swift_Spool $spool + */ + public function __construct(Swift_Spool $spool) + { + $arguments = Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.spool'); + + $arguments[] = $spool; + + call_user_func_array( + array($this, 'Swift_Transport_SpoolTransport::__construct'), + $arguments + ); + } + + /** + * Create a new SpoolTransport instance. + * + * @param Swift_Spool $spool + * + * @return Swift_SpoolTransport + */ + public static function newInstance(Swift_Spool $spool) + { + return new self($spool); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php new file mode 100644 index 000000000..362be2e8d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php @@ -0,0 +1,35 @@ +_search = $search; + $this->_index = array(); + $this->_tree = array(); + $this->_replace = array(); + $this->_repSize = array(); + + $tree = null; + $i = null; + $last_size = $size = 0; + foreach ($search as $i => $search_element) { + if ($tree !== null) { + $tree[-1] = min(count($replace) - 1, $i - 1); + $tree[-2] = $last_size; + } + $tree = &$this->_tree; + if (is_array($search_element)) { + foreach ($search_element as $k => $char) { + $this->_index[$char] = true; + if (!isset($tree[$char])) { + $tree[$char] = array(); + } + $tree = &$tree[$char]; + } + $last_size = $k + 1; + $size = max($size, $last_size); + } else { + $last_size = 1; + if (!isset($tree[$search_element])) { + $tree[$search_element] = array(); + } + $tree = &$tree[$search_element]; + $size = max($last_size, $size); + $this->_index[$search_element] = true; + } + } + if ($i !== null) { + $tree[-1] = min(count($replace) - 1, $i); + $tree[-2] = $last_size; + $this->_treeMaxLen = $size; + } + foreach ($replace as $rep) { + if (!is_array($rep)) { + $rep = array($rep); + } + $this->_replace[] = $rep; + } + for ($i = count($this->_replace) - 1; $i >= 0; --$i) { + $this->_replace[$i] = $rep = $this->filter($this->_replace[$i], $i); + $this->_repSize[$i] = count($rep); + } + } + + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param array $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = end($buffer); + + return isset($this->_index[$endOfBuffer]); + } + + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param array $buffer + * @param int $_minReplaces + * + * @return array + */ + public function filter($buffer, $_minReplaces = -1) + { + if ($this->_treeMaxLen == 0) { + return $buffer; + } + + $newBuffer = array(); + $buf_size = count($buffer); + for ($i = 0; $i < $buf_size; ++$i) { + $search_pos = $this->_tree; + $last_found = PHP_INT_MAX; + // We try to find if the next byte is part of a search pattern + for ($j = 0; $j <= $this->_treeMaxLen; ++$j) { + // We have a new byte for a search pattern + if (isset($buffer [$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { + $search_pos = $search_pos[$buffer[$p]]; + // We have a complete pattern, save, in case we don't find a better match later + if (isset($search_pos[-1]) && $search_pos[-1] < $last_found + && $search_pos[-1] > $_minReplaces) { + $last_found = $search_pos[-1]; + $last_size = $search_pos[-2]; + } + } + // We got a complete pattern + elseif ($last_found !== PHP_INT_MAX) { + // Adding replacement datas to output buffer + $rep_size = $this->_repSize[$last_found]; + for ($j = 0; $j < $rep_size; ++$j) { + $newBuffer[] = $this->_replace[$last_found][$j]; + } + // We Move cursor forward + $i += $last_size - 1; + // Edge Case, last position in buffer + if ($i >= $buf_size) { + $newBuffer[] = $buffer[$i]; + } + + // We start the next loop + continue 2; + } else { + // this byte is not in a pattern and we haven't found another pattern + break; + } + } + // Normal byte, move it to output buffer + $newBuffer[] = $buffer[$i]; + } + + return $newBuffer; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php new file mode 100644 index 000000000..d0db8b961 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php @@ -0,0 +1,66 @@ +_search = $search; + $this->_replace = $replace; + } + + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param string $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = substr($buffer, -1); + foreach ((array) $this->_search as $needle) { + if (false !== strpos($needle, $endOfBuffer)) { + return true; + } + } + + return false; + } + + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param string $buffer + * + * @return string + */ + public function filter($buffer) + { + return str_replace($this->_search, $this->_replace, $buffer); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php new file mode 100644 index 000000000..e98240b5b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -0,0 +1,45 @@ +_filters[$search][$replace])) { + if (!isset($this->_filters[$search])) { + $this->_filters[$search] = array(); + } + + if (!isset($this->_filters[$search][$replace])) { + $this->_filters[$search][$replace] = array(); + } + + $this->_filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } + + return $this->_filters[$search][$replace]; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php new file mode 100644 index 000000000..db3d31093 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php @@ -0,0 +1,29 @@ +_eventDispatcher = $dispatcher; + $this->_buffer = $buf; + $this->_lookupHostname(); + } + + /** + * Set the name of the local domain which Swift will identify itself as. + * + * This should be a fully-qualified domain name and should be truly the domain + * you're using. + * + * If your server doesn't have a domain name, use the IP in square + * brackets (i.e. [127.0.0.1]). + * + * @param string $domain + * + * @return Swift_Transport_AbstractSmtpTransport + */ + public function setLocalDomain($domain) + { + $this->_domain = $domain; + + return $this; + } + + /** + * Get the name of the domain Swift will identify as. + * + * @return string + */ + public function getLocalDomain() + { + return $this->_domain; + } + + /** + * Sets the source IP. + * + * @param string $source + */ + public function setSourceIp($source) + { + $this->_sourceIp = $source; + } + + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->_sourceIp; + } + + /** + * Start the SMTP connection. + */ + public function start() + { + if (!$this->_started) { + if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->_buffer->initialize($this->_getBufferParams()); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + $this->_readGreeting(); + $this->_doHeloCommand(); + + if ($evt) { + $this->_eventDispatcher->dispatchEvent($evt, 'transportStarted'); + } + + $this->_started = true; + } + } + + /** + * Test if an SMTP connection has been established. + * + * @return bool + */ + public function isStarted() + { + return $this->_started; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $sent = 0; + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (!$reversePath = $this->_getReversePath($message)) { + $this->_throwException(new Swift_TransportException( + 'Cannot send message without a sender address' + ) + ); + } + + $to = (array) $message->getTo(); + $cc = (array) $message->getCc(); + $tos = array_merge($to, $cc); + $bcc = (array) $message->getBcc(); + + $message->setBcc(array()); + + try { + $sent += $this->_sendTo($message, $reversePath, $tos, $failedRecipients); + $sent += $this->_sendBcc($message, $reversePath, $bcc, $failedRecipients); + } catch (Exception $e) { + $message->setBcc($bcc); + throw $e; + } + + $message->setBcc($bcc); + + if ($evt) { + if ($sent == count($to) + count($cc) + count($bcc)) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + } elseif ($sent > 0) { + $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); + } else { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + } + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); //Make sure a new Message ID is used + + return $sent; + } + + /** + * Stop the SMTP connection. + */ + public function stop() + { + if ($this->_started) { + if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->executeCommand("QUIT\r\n", array(221)); + } catch (Swift_TransportException $e) { + } + + try { + $this->_buffer->terminate(); + + if ($evt) { + $this->_eventDispatcher->dispatchEvent($evt, 'transportStopped'); + } + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + } + $this->_started = false; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } + + /** + * Reset the current mail transaction. + */ + public function reset() + { + $this->executeCommand("RSET\r\n", array(250)); + } + + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer() + { + return $this->_buffer; + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * + * @return string + */ + public function executeCommand($command, $codes = array(), &$failures = null) + { + $failures = (array) $failures; + $seq = $this->_buffer->write($command); + $response = $this->_getFullResponse($seq); + if ($evt = $this->_eventDispatcher->createCommandEvent($this, $command, $codes)) { + $this->_eventDispatcher->dispatchEvent($evt, 'commandSent'); + } + $this->_assertResponseCode($response, $codes); + + return $response; + } + + /** Read the opening SMTP greeting */ + protected function _readGreeting() + { + $this->_assertResponseCode($this->_getFullResponse(0), array(220)); + } + + /** Send the HELO welcome */ + protected function _doHeloCommand() + { + $this->executeCommand( + sprintf("HELO %s\r\n", $this->_domain), array(250) + ); + } + + /** Send the MAIL FROM command */ + protected function _doMailFromCommand($address) + { + $this->executeCommand( + sprintf("MAIL FROM:<%s>\r\n", $address), array(250) + ); + } + + /** Send the RCPT TO command */ + protected function _doRcptToCommand($address) + { + $this->executeCommand( + sprintf("RCPT TO:<%s>\r\n", $address), array(250, 251, 252) + ); + } + + /** Send the DATA command */ + protected function _doDataCommand() + { + $this->executeCommand("DATA\r\n", array(354)); + } + + /** Stream the contents of the message over the buffer */ + protected function _streamMessage(Swift_Mime_Message $message) + { + $this->_buffer->setWriteTranslations(array("\r\n." => "\r\n..")); + try { + $message->toByteStream($this->_buffer); + $this->_buffer->flushBuffers(); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + $this->_buffer->setWriteTranslations(array()); + $this->executeCommand("\r\n.\r\n", array(250)); + } + + /** Determine the best-use reverse path for this message */ + protected function _getReversePath(Swift_Mime_Message $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + // Don't use array_keys + reset($sender); // Reset Pointer to first pos + $path = key($sender); // Get key + } elseif (!empty($from)) { + reset($from); // Reset Pointer to first pos + $path = key($from); // Get key + } + + return $path; + } + + /** Throw a TransportException, first sending it to any listeners */ + protected function _throwException(Swift_TransportException $e) + { + if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } + + /** Throws an Exception if a response code is incorrect */ + protected function _assertResponseCode($response, $wanted) + { + list($code) = sscanf($response, '%3d'); + $valid = (empty($wanted) || in_array($code, $wanted)); + + if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response, + $valid)) { + $this->_eventDispatcher->dispatchEvent($evt, 'responseReceived'); + } + + if (!$valid) { + $this->_throwException( + new Swift_TransportException( + 'Expected response code '.implode('/', $wanted).' but got code '. + '"'.$code.'", with message "'.$response.'"', + $code) + ); + } + } + + /** Get an entire multi-line response using its sequence number */ + protected function _getFullResponse($seq) + { + $response = ''; + try { + do { + $line = $this->_buffer->readLine($seq); + $response .= $line; + } while (null !== $line && false !== $line && ' ' != $line{3}); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } catch (Swift_IoException $e) { + $this->_throwException( + new Swift_TransportException( + $e->getMessage()) + ); + } + + return $response; + } + + /** Send an email to the given recipients from the given reverse path */ + private function _doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) + { + $sent = 0; + $this->_doMailFromCommand($reversePath); + foreach ($recipients as $forwardPath) { + try { + $this->_doRcptToCommand($forwardPath); + $sent++; + } catch (Swift_TransportException $e) { + $failedRecipients[] = $forwardPath; + } + } + + if ($sent != 0) { + $this->_doDataCommand(); + $this->_streamMessage($message); + } else { + $this->reset(); + } + + return $sent; + } + + /** Send a message to the given To: recipients */ + private function _sendTo(Swift_Mime_Message $message, $reversePath, array $to, array &$failedRecipients) + { + if (empty($to)) { + return 0; + } + + return $this->_doMailTransaction($message, $reversePath, array_keys($to), + $failedRecipients); + } + + /** Send a message to all Bcc: recipients */ + private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, array &$failedRecipients) + { + $sent = 0; + foreach ($bcc as $forwardPath => $name) { + $message->setBcc(array($forwardPath => $name)); + $sent += $this->_doMailTransaction( + $message, $reversePath, array($forwardPath), $failedRecipients + ); + } + + return $sent; + } + + /** Try to determine the hostname of the server this is run on */ + private function _lookupHostname() + { + if (!empty($_SERVER['SERVER_NAME']) + && $this->_isFqdn($_SERVER['SERVER_NAME'])) { + $this->_domain = $_SERVER['SERVER_NAME']; + } elseif (!empty($_SERVER['SERVER_ADDR'])) { + $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']); + } + } + + /** Determine is the $hostname is a fully-qualified name */ + private function _isFqdn($hostname) + { + // We could do a really thorough check, but there's really no point + if (false !== $dotPos = strpos($hostname, '.')) { + return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1); + } else { + return false; + } + } + + /** + * Destructor. + */ + public function __destruct() + { + $this->stop(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php new file mode 100644 index 000000000..53f721d03 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -0,0 +1,81 @@ +executeCommand("AUTH CRAM-MD5\r\n", array(334)); + $challenge = base64_decode(substr($challenge, 4)); + $message = base64_encode( + $username.' '.$this->_getResponse($password, $challenge) + ); + $agent->executeCommand(sprintf("%s\r\n", $message), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + /** + * Generate a CRAM-MD5 response from a server challenge. + * + * @param string $secret + * @param string $challenge + * + * @return string + */ + private function _getResponse($secret, $challenge) + { + if (strlen($secret) > 64) { + $secret = pack('H32', md5($secret)); + } + + if (strlen($secret) < 64) { + $secret = str_pad($secret, 64, chr(0)); + } + + $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64); + $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64); + + $inner = pack('H32', md5($k_ipad.$challenge)); + $digest = md5($k_opad.$inner); + + return $digest; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php new file mode 100644 index 000000000..6ab6e3337 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -0,0 +1,51 @@ +executeCommand("AUTH LOGIN\r\n", array(334)); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334)); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php new file mode 100644 index 000000000..f1102bbb5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -0,0 +1,726 @@ + + */ +class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator +{ + const NTLMSIG = "NTLMSSP\x00"; + const DESCONST = 'KGS!@#$%'; + + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'NTLM'; + } + + /** + * Try to authenticate the user with $username and $password. + * + * @param Swift_Transport_SmtpAgent $agent + * @param string $username + * @param string $password + * + * @return bool + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + if (!function_exists('mcrypt_module_open')) { + throw new LogicException('The mcrypt functions need to be enabled to use the NTLM authenticator.'); + } + + if (!function_exists('openssl_random_pseudo_bytes')) { + throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); + } + + if (!function_exists('bcmul')) { + throw new LogicException('The BCMatch functions must be enabled to use the NTLM authenticator.'); + } + + try { + // execute AUTH command and filter out the code at the beginning + // AUTH NTLM xxxx + $response = base64_decode(substr(trim($this->sendMessage1($agent)), 4)); + + // extra parameters for our unit cases + $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); + $client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8); + + // Message 3 response + $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + protected function si2bin($si, $bits = 32) + { + $bin = null; + if ($si >= -pow(2, $bits - 1) && ($si <= pow(2, $bits - 1))) { + // positive or zero + if ($si >= 0) { + $bin = base_convert($si, 10, 2); + // pad to $bits bit + $bin_length = strlen($bin); + if ($bin_length < $bits) { + $bin = str_repeat('0', $bits - $bin_length).$bin; + } + } else { + // negative + $si = -$si - pow(2, $bits); + $bin = base_convert($si, 10, 2); + $bin_length = strlen($bin); + if ($bin_length > $bits) { + $bin = str_repeat('1', $bits - $bin_length).$bin; + } + } + } + + return $bin; + } + + /** + * Send our auth message and returns the response. + * + * @param Swift_Transport_SmtpAgent $agent + * + * @return string SMTP Response + */ + protected function sendMessage1(Swift_Transport_SmtpAgent $agent) + { + $message = $this->createMessage1(); + + return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), array(334)); + } + + /** + * Fetch all details of our response (message 2). + * + * @param string $response + * + * @return array our response parsed + */ + protected function parseMessage2($response) + { + $responseHex = bin2hex($response); + $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; + $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; + $challenge = $this->hex2bin(substr($responseHex, 48, 16)); + $context = $this->hex2bin(substr($responseHex, 64, 16)); + $targetInfoH = $this->hex2bin(substr($responseHex, 80, 16)); + $targetName = $this->hex2bin(substr($responseHex, $offset, $length)); + $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; + $targetInfoBlock = substr($responseHex, $offset); + list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); + + return array( + $challenge, + $context, + $targetInfoH, + $targetName, + $domainName, + $serverName, + $DNSDomainName, + $DNSServerName, + $this->hex2bin($targetInfoBlock), + $terminatorByte, + ); + } + + /** + * Read the blob information in from message2. + * + * @param $block + * + * @return array + */ + protected function readSubBlock($block) + { + // remove terminatorByte cause it's always the same + $block = substr($block, 0, -8); + + $length = strlen($block); + $offset = 0; + $data = array(); + while ($offset < $length) { + $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; + $offset += 8; + $data[] = $this->hex2bin(substr($block, $offset, $blockLength * 2)); + $offset += $blockLength * 2; + } + + if (count($data) == 3) { + $data[] = $data[2]; + $data[2] = ''; + } + + $data[] = $this->createByte('00'); + + return $data; + } + + /** + * Send our final message with all our data. + * + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client + * @param Swift_Transport_SmtpAgent $agent + * @param bool $v2 Use version2 of the protocol + * + * @return string + */ + protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) + { + list($domain, $username) = $this->getDomainAndUsername($username); + //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter + list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); + + if (!$v2) { + // LMv1 + $lmResponse = $this->createLMPassword($password, $challenge); + // NTLMv1 + $ntlmResponse = $this->createNTLMPassword($password, $challenge); + } else { + // LMv2 + $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); + // NTLMv2 + $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); + } + + $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); + + return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), array(235)); + } + + /** + * Create our message 1. + * + * @return string + */ + protected function createMessage1() + { + return self::NTLMSIG + .$this->createByte('01') // Message 1 +.$this->createByte('0702'); // Flags + } + + /** + * Create our message 3. + * + * @param string $domain + * @param string $username + * @param string $workstation + * @param string $lmResponse + * @param string $ntlmResponse + * + * @return string + */ + protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) + { + // Create security buffers + $domainSec = $this->createSecurityBuffer($domain, 64); + $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); + $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); + $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); + $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); + $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); + $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); + $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); + $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); + + return self::NTLMSIG + .$this->createByte('03') // TYPE 3 message +.$lmSec // LM response header +.$ntlmSec // NTLM response header +.$domainSec // Domain header +.$userSec // User header +.$workSec // Workstation header +.$this->createByte('000000009a', 8) // session key header (empty) +.$this->createByte('01020000') // FLAGS +.$this->convertTo16bit($domain) // domain name +.$this->convertTo16bit($username) // username +.$this->convertTo16bit($workstation) // workstation +.$lmResponse + .$ntlmResponse; + } + + /** + * @param string $timestamp Epoch timestamp in microseconds + * @param string $client Random bytes + * @param string $targetInfo + * + * @return string + */ + protected function createBlob($timestamp, $client, $targetInfo) + { + return $this->createByte('0101') + .$this->createByte('00') + .$timestamp + .$client + .$this->createByte('00') + .$targetInfo + .$this->createByte('00'); + } + + /** + * Get domain and username from our username. + * + * @example DOMAIN\username + * + * @param string $name + * + * @return array + */ + protected function getDomainAndUsername($name) + { + if (strpos($name, '\\') !== false) { + return explode('\\', $name); + } + + list($user, $domain) = explode('@', $name); + + return array($domain, $user); + } + + /** + * Create LMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createLMPassword($password, $challenge) + { + // FIRST PART + $password = $this->createByte(strtoupper($password), 14, false); + list($key1, $key2) = str_split($password, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + + $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); + + // SECOND PART + list($key1, $key2, $key3) = str_split($constantDecrypt, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Create NTLMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createNTLMPassword($password, $challenge) + { + // FIRST PART + $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); + list($key1, $key2, $key3) = str_split($ntlmHash, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Convert a normal timestamp to a tenth of a microtime epoch time. + * + * @param string $time + * + * @return string + */ + protected function getCorrectTimestamp($time) + { + // Get our timestamp (tricky!) + bcscale(0); + + $time = number_format($time, 0, '.', ''); // save microtime to string + $time = bcadd($time, '11644473600000'); // add epoch time + $time = bcmul($time, 10000); // tenths of a microsecond. + + $binary = $this->si2bin($time, 64); // create 64 bit binary string + $timestamp = ''; + for ($i = 0; $i < 8; $i++) { + $timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8))); + } + + return $timestamp; + } + + /** + * Create LMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge NTLM Challenge + * @param string $client Random string + * + * @return string + */ + protected function createLMv2Password($password, $username, $domain, $challenge, $client) + { + $lmPass = '00'; // by default 00 + // if $password > 15 than we can't use this method + if (strlen($password) <= 15) { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); + } + + return $this->createByte($lmPass, 24); + } + + /** + * Create NTLMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge Hex values + * @param string $targetInfo Hex values + * @param string $timestamp + * @param string $client Random bytes + * + * @return string + * + * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse + */ + protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) + { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + // create blob + $blob = $this->createBlob($timestamp, $client, $targetInfo); + + $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); + + return $ntlmv2Response.$blob; + } + + protected function createDesKey($key) + { + $material = array(bin2hex($key[0])); + $len = strlen($key); + for ($i = 1; $i < $len; $i++) { + list($high, $low) = str_split(bin2hex($key[$i])); + $v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); + $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte + } + $material[] = str_pad(substr(dechex($this->castToByte(ord($key[6]) << 1)), -2), 2, '0'); + + // odd parity + foreach ($material as $k => $v) { + $b = $this->castToByte(hexdec($v)); + $needsParity = (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) + ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) + ^ $this->uRShift($b, 1)) & 0x01) == 0; + + list($high, $low) = str_split($v); + if ($needsParity) { + $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); + } else { + $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); + } + } + + return $this->hex2bin(implode('', $material)); + } + + /** HELPER FUNCTIONS */ + /** + * Create our security buffer depending on length and offset. + * + * @param string $value Value we want to put in + * @param int $offset start of value + * @param bool $is16 Do we 16bit string or not? + * + * @return string + */ + protected function createSecurityBuffer($value, $offset, $is16 = false) + { + $length = strlen(bin2hex($value)); + $length = $is16 ? $length / 2 : $length; + $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); + + return $length.$length.$this->createByte(dechex($offset), 4); + } + + /** + * Read our security buffer to fetch length and offset of our value. + * + * @param string $value Securitybuffer in hex + * + * @return array array with length and offset + */ + protected function readSecurityBuffer($value) + { + $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; + $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; + + return array($length, $offset); + } + + /** + * Cast to byte java equivalent to (byte). + * + * @param int $v + * + * @return int + */ + protected function castToByte($v) + { + return (($v + 128) % 256) - 128; + } + + /** + * Java unsigned right bitwise + * $a >>> $b. + * + * @param int $a + * @param int $b + * + * @return int + */ + protected function uRShift($a, $b) + { + if ($b == 0) { + return $a; + } + + return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); + } + + /** + * Right padding with 0 to certain length. + * + * @param string $input + * @param int $bytes Length of bytes + * @param bool $isHex Did we provided hex value + * + * @return string + */ + protected function createByte($input, $bytes = 4, $isHex = true) + { + if ($isHex) { + $byte = $this->hex2bin(str_pad($input, $bytes * 2, '00')); + } else { + $byte = str_pad($input, $bytes, "\x00"); + } + + return $byte; + } + + /** + * Create random bytes. + * + * @param $length + * + * @return string + */ + protected function getRandomBytes($length) + { + $bytes = openssl_random_pseudo_bytes($length, $strong); + + if (false !== $bytes && true === $strong) { + return $bytes; + } + + throw new RuntimeException('OpenSSL did not produce a secure random number.'); + } + + /** ENCRYPTION ALGORITHMS */ + /** + * DES Encryption. + * + * @param string $value + * @param string $key + * + * @return string + */ + protected function desEncrypt($value, $key) + { + $cipher = mcrypt_module_open(MCRYPT_DES, '', 'ecb', ''); + mcrypt_generic_init($cipher, $key, mcrypt_create_iv(mcrypt_enc_get_iv_size($cipher), MCRYPT_DEV_RANDOM)); + + return mcrypt_generic($cipher, $value); + } + + /** + * MD5 Encryption. + * + * @param string $key Encryption key + * @param string $msg Message to encrypt + * + * @return string + */ + protected function md5Encrypt($key, $msg) + { + $blocksize = 64; + if (strlen($key) > $blocksize) { + $key = pack('H*', md5($key)); + } + + $key = str_pad($key, $blocksize, "\0"); + $ipadk = $key ^ str_repeat("\x36", $blocksize); + $opadk = $key ^ str_repeat("\x5c", $blocksize); + + return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); + } + + /** + * MD4 Encryption. + * + * @param string $input + * + * @return string + * + * @see http://php.net/manual/en/ref.hash.php + */ + protected function md4Encrypt($input) + { + $input = $this->convertTo16bit($input); + + return function_exists('hash') ? $this->hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + } + + /** + * Convert UTF-8 to UTF-16. + * + * @param string $input + * + * @return string + */ + protected function convertTo16bit($input) + { + return iconv('UTF-8', 'UTF-16LE', $input); + } + + /** + * Hex2bin replacement for < PHP 5.4. + * + * @param string $hex + * + * @return string Binary + */ + protected function hex2bin($hex) + { + if (function_exists('hex2bin')) { + return hex2bin($hex); + } else { + return pack('H*', $hex); + } + } + + /** + * @param string $message + */ + protected function debug($message) + { + $message = bin2hex($message); + $messageId = substr($message, 16, 8); + echo substr($message, 0, 16)." NTLMSSP Signature
\n"; + echo $messageId." Type Indicator
\n"; + + if ($messageId == '02000000') { + $map = array( + 'Challenge', + 'Context', + 'Target Information Security Buffer', + 'Target Name Data', + 'NetBIOS Domain Name', + 'NetBIOS Server Name', + 'DNS Domain Name', + 'DNS Server Name', + 'BLOB', + 'Target Information Terminator', + ); + + $data = $this->parseMessage2($this->hex2bin($message)); + + foreach ($map as $key => $value) { + echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; + } + } elseif ($messageId == '03000000') { + $i = 0; + $data[$i++] = substr($message, 24, 16); + list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 40, 16); + list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 56, 16); + list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 72, 16); + list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 88, 16); + list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 104, 16); + $data[$i++] = substr($message, 120, 8); + $data[$i++] = substr($message, $targetOffset, $targetLength); + $data[$i++] = substr($message, $userOffset, $userLength); + $data[$i++] = substr($message, $workOffset, $workLength); + $data[$i++] = substr($message, $lmOffset, $lmLength); + $data[$i] = substr($message, $ntmlOffset, $ntmlLength); + + $map = array( + 'LM Response Security Buffer', + 'NTLM Response Security Buffer', + 'Target Name Security Buffer', + 'User Name Security Buffer', + 'Workstation Name Security Buffer', + 'Session Key Security Buffer', + 'Flags', + 'Target Name Data', + 'User Name Data', + 'Workstation Name Data', + 'LM Response Data', + 'NTLM Response Data', + ); + + foreach ($map as $key => $value) { + echo $data[$key].' - '.$this->hex2bin($data[$key]).' ||| '.$value."
\n"; + } + } + + echo '

'; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php new file mode 100644 index 000000000..43219f934 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -0,0 +1,50 @@ +executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php new file mode 100644 index 000000000..ca35e7b83 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -0,0 +1,70 @@ + + * $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls') + * ->setAuthMode('XOAUTH2') + * ->setUsername('YOUR_EMAIL_ADDRESS') + * ->setPassword('YOUR_ACCESS_TOKEN'); + * + * + * @author xu.li + * + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol + */ +class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport_Esmtp_Authenticator +{ + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'XOAUTH2'; + } + + /** + * Try to authenticate the user with $email and $token. + * + * @param Swift_Transport_SmtpAgent $agent + * @param string $email + * @param string $token + * + * @return bool + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) + { + try { + $param = $this->constructXOAuth2Params($email, $token); + $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + /** + * Construct the auth parameter. + * + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism + */ + protected function constructXOAuth2Params($email, $token) + { + return base64_encode("user=$email\1auth=Bearer $token\1\1"); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php new file mode 100644 index 000000000..2b0e6820c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -0,0 +1,263 @@ +setAuthenticators($authenticators); + } + + /** + * Set the Authenticators which can process a login request. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function setAuthenticators(array $authenticators) + { + $this->_authenticators = $authenticators; + } + + /** + * Get the Authenticators which can process a login request. + * + * @return Swift_Transport_Esmtp_Authenticator[] + */ + public function getAuthenticators() + { + return $this->_authenticators; + } + + /** + * Set the username to authenticate with. + * + * @param string $username + */ + public function setUsername($username) + { + $this->_username = $username; + } + + /** + * Get the username to authenticate with. + * + * @return string + */ + public function getUsername() + { + return $this->_username; + } + + /** + * Set the password to authenticate with. + * + * @param string $password + */ + public function setPassword($password) + { + $this->_password = $password; + } + + /** + * Get the password to authenticate with. + * + * @return string + */ + public function getPassword() + { + return $this->_password; + } + + /** + * Set the auth mode to use to authenticate. + * + * @param string $mode + */ + public function setAuthMode($mode) + { + $this->_auth_mode = $mode; + } + + /** + * Get the auth mode to use to authenticate. + * + * @return string + */ + public function getAuthMode() + { + return $this->_auth_mode; + } + + /** + * Get the name of the ESMTP extension this handles. + * + * @return bool + */ + public function getHandledKeyword() + { + return 'AUTH'; + } + + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters) + { + $this->_esmtpParams = $parameters; + } + + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + if ($this->_username) { + $count = 0; + foreach ($this->_getAuthenticatorsForAgent() as $authenticator) { + if (in_array(strtolower($authenticator->getAuthKeyword()), + array_map('strtolower', $this->_esmtpParams))) { + $count++; + if ($authenticator->authenticate($agent, $this->_username, $this->_password)) { + return; + } + } + } + throw new Swift_TransportException( + 'Failed to authenticate on SMTP server with username "'. + $this->_username.'" using '.$count.' possible authenticators' + ); + } + } + + /** + * Not used. + */ + public function getMailParams() + { + return array(); + } + + /** + * Not used. + */ + public function getRcptParams() + { + return array(); + } + + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false) + { + } + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } + + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods() + { + return array('setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode'); + } + + /** + * Not used. + */ + public function resetState() + { + } + + /** + * Returns the authenticator list for the given agent. + * + * @param Swift_Transport_SmtpAgent $agent + * + * @return array + */ + protected function _getAuthenticatorsForAgent() + { + if (!$mode = strtolower($this->_auth_mode)) { + return $this->_authenticators; + } + + foreach ($this->_authenticators as $authenticator) { + if (strtolower($authenticator->getAuthKeyword()) == $mode) { + return array($authenticator); + } + } + + throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php new file mode 100644 index 000000000..12a9abf81 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -0,0 +1,35 @@ +. + * + * @return string[] + */ + public function getMailParams(); + + /** + * Get params which are appended to RCPT TO:<>. + * + * @return string[] + */ + public function getRcptParams(); + + /** + * Runs when a command is due to be sent. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + * @param string $command to send + * @param int[] $codes expected in response + * @param string[] $failedRecipients to collect failures + * @param bool $stop to be set true by-reference if the command is now sent + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false); + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword); + + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods(); + + /** + * Tells this handler to clear any buffers and reset its state. + */ + public function resetState(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php new file mode 100644 index 000000000..5b4f50c25 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -0,0 +1,386 @@ + 'tcp', + 'host' => 'localhost', + 'port' => 25, + 'timeout' => 30, + 'blocking' => 1, + 'tls' => false, + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + ); + + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param Swift_Transport_IoBuffer $buf + * @param Swift_Transport_EsmtpHandler[] $extensionHandlers + * @param Swift_Events_EventDispatcher $dispatcher + */ + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher) + { + parent::__construct($buf, $dispatcher); + $this->setExtensionHandlers($extensionHandlers); + } + + /** + * Set the host to connect to. + * + * @param string $host + * + * @return Swift_Transport_EsmtpTransport + */ + public function setHost($host) + { + $this->_params['host'] = $host; + + return $this; + } + + /** + * Get the host to connect to. + * + * @return string + */ + public function getHost() + { + return $this->_params['host']; + } + + /** + * Set the port to connect to. + * + * @param int $port + * + * @return Swift_Transport_EsmtpTransport + */ + public function setPort($port) + { + $this->_params['port'] = (int) $port; + + return $this; + } + + /** + * Get the port to connect to. + * + * @return int + */ + public function getPort() + { + return $this->_params['port']; + } + + /** + * Set the connection timeout. + * + * @param int $timeout seconds + * + * @return Swift_Transport_EsmtpTransport + */ + public function setTimeout($timeout) + { + $this->_params['timeout'] = (int) $timeout; + $this->_buffer->setParam('timeout', (int) $timeout); + + return $this; + } + + /** + * Get the connection timeout. + * + * @return int + */ + public function getTimeout() + { + return $this->_params['timeout']; + } + + /** + * Set the encryption type (tls or ssl). + * + * @param string $encryption + * + * @return Swift_Transport_EsmtpTransport + */ + public function setEncryption($encryption) + { + if ('tls' == $encryption) { + $this->_params['protocol'] = 'tcp'; + $this->_params['tls'] = true; + } else { + $this->_params['protocol'] = $encryption; + $this->_params['tls'] = false; + } + + return $this; + } + + /** + * Get the encryption type. + * + * @return string + */ + public function getEncryption() + { + return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; + } + + /** + * Sets the source IP. + * + * @param string $source + * + * @return Swift_Transport_EsmtpTransport + */ + public function setSourceIp($source) + { + $this->_params['sourceIp'] = $source; + + return $this; + } + + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return isset($this->_params['sourceIp']) ? $this->_params['sourceIp'] : null; + } + + /** + * Set ESMTP extension handlers. + * + * @param Swift_Transport_EsmtpHandler[] $handlers + * + * @return Swift_Transport_EsmtpTransport + */ + public function setExtensionHandlers(array $handlers) + { + $assoc = array(); + foreach ($handlers as $handler) { + $assoc[$handler->getHandledKeyword()] = $handler; + } + uasort($assoc, array($this, '_sortHandlers')); + $this->_handlers = $assoc; + $this->_setHandlerParams(); + + return $this; + } + + /** + * Get ESMTP extension handlers. + * + * @return Swift_Transport_EsmtpHandler[] + */ + public function getExtensionHandlers() + { + return array_values($this->_handlers); + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * + * @return string + */ + public function executeCommand($command, $codes = array(), &$failures = null) + { + $failures = (array) $failures; + $stopSignal = false; + $response = null; + foreach ($this->_getActiveHandlers() as $handler) { + $response = $handler->onCommand( + $this, $command, $codes, $failures, $stopSignal + ); + if ($stopSignal) { + return $response; + } + } + + return parent::executeCommand($command, $codes, $failures); + } + + // -- Mixin invocation code + + /** Mixin handling method for ESMTP handlers */ + public function __call($method, $args) + { + foreach ($this->_handlers as $handler) { + if (in_array(strtolower($method), + array_map('strtolower', (array) $handler->exposeMixinMethods()) + )) { + $return = call_user_func_array(array($handler, $method), $args); + // Allow fluid method calls + if (is_null($return) && substr($method, 0, 3) == 'set') { + return $this; + } else { + return $return; + } + } + } + trigger_error('Call to undefined method '.$method, E_USER_ERROR); + } + + /** Get the params to initialize the buffer */ + protected function _getBufferParams() + { + return $this->_params; + } + + /** Overridden to perform EHLO instead */ + protected function _doHeloCommand() + { + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->_domain), array(250) + ); + } catch (Swift_TransportException $e) { + return parent::_doHeloCommand(); + } + + if ($this->_params['tls']) { + try { + $this->executeCommand("STARTTLS\r\n", array(220)); + + if (!$this->_buffer->startTLS()) { + throw new Swift_TransportException('Unable to connect with TLS encryption'); + } + + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->_domain), array(250) + ); + } catch (Swift_TransportException $e) { + return parent::_doHeloCommand(); + } + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + } + + $this->_capabilities = $this->_getCapabilities($response); + $this->_setHandlerParams(); + foreach ($this->_getActiveHandlers() as $handler) { + $handler->afterEhlo($this); + } + } + + /** Overridden to add Extension support */ + protected function _doMailFromCommand($address) + { + $handlers = $this->_getActiveHandlers(); + $params = array(); + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getMailParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), array(250) + ); + } + + /** Overridden to add Extension support */ + protected function _doRcptToCommand($address) + { + $handlers = $this->_getActiveHandlers(); + $params = array(); + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getRcptParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), array(250, 251, 252) + ); + } + + /** Determine ESMTP capabilities by function group */ + private function _getCapabilities($ehloResponse) + { + $capabilities = array(); + $ehloResponse = trim($ehloResponse); + $lines = explode("\r\n", $ehloResponse); + array_shift($lines); + foreach ($lines as $line) { + if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { + $keyword = strtoupper($matches[1]); + $paramStr = strtoupper(ltrim($matches[2], ' =')); + $params = !empty($paramStr) ? explode(' ', $paramStr) : array(); + $capabilities[$keyword] = $params; + } + } + + return $capabilities; + } + + /** Set parameters which are used by each extension handler */ + private function _setHandlerParams() + { + foreach ($this->_handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->_capabilities)) { + $handler->setKeywordParams($this->_capabilities[$keyword]); + } + } + } + + /** Get ESMTP handlers which are currently ok to use */ + private function _getActiveHandlers() + { + $handlers = array(); + foreach ($this->_handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->_capabilities)) { + $handlers[] = $handler; + } + } + + return $handlers; + } + + /** Custom sort for extension handler ordering */ + private function _sortHandlers($a, $b) + { + return $a->getPriorityOver($b->getHandledKeyword()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php new file mode 100644 index 000000000..59c730261 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -0,0 +1,85 @@ +_transports); + $sent = 0; + + for ($i = 0; $i < $maxTransports + && $transport = $this->_getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + + return $transport->send($message, $failedRecipients); + } catch (Swift_TransportException $e) { + $this->_killCurrentTransport(); + } + } + + if (count($this->_transports) == 0) { + throw new Swift_TransportException( + 'All Transports in FailoverTransport failed, or no Transports available' + ); + } + + return $sent; + } + + protected function _getNextTransport() + { + if (!isset($this->_currentTransport)) { + $this->_currentTransport = parent::_getNextTransport(); + } + + return $this->_currentTransport; + } + + protected function _killCurrentTransport() + { + $this->_currentTransport = null; + parent::_killCurrentTransport(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php new file mode 100644 index 000000000..af97adf1f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -0,0 +1,67 @@ +_transports = $transports; + $this->_deadTransports = array(); + } + + /** + * Get $transports to delegate to. + * + * @return Swift_Transport[] + */ + public function getTransports() + { + return array_merge($this->_transports, $this->_deadTransports); + } + + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return count($this->_transports) > 0; + } + + /** + * Start this Transport mechanism. + */ + public function start() + { + $this->_transports = array_merge($this->_transports, $this->_deadTransports); + } + + /** + * Stop this Transport mechanism. + */ + public function stop() + { + foreach ($this->_transports as $transport) { + $transport->stop(); + } + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $maxTransports = count($this->_transports); + $sent = 0; + + for ($i = 0; $i < $maxTransports + && $transport = $this->_getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + if ($sent = $transport->send($message, $failedRecipients)) { + break; + } + } catch (Swift_TransportException $e) { + $this->_killCurrentTransport(); + } + } + + if (count($this->_transports) == 0) { + throw new Swift_TransportException( + 'All Transports in LoadBalancedTransport failed, or no Transports available' + ); + } + + return $sent; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + foreach ($this->_transports as $transport) { + $transport->registerPlugin($plugin); + } + } + + /** + * Rotates the transport list around and returns the first instance. + * + * @return Swift_Transport + */ + protected function _getNextTransport() + { + if ($next = array_shift($this->_transports)) { + $this->_transports[] = $next; + } + + return $next; + } + + /** + * Tag the currently used (top of stack) transport as dead/useless. + */ + protected function _killCurrentTransport() + { + if ($transport = array_pop($this->_transports)) { + try { + $transport->stop(); + } catch (Exception $e) { + } + $this->_deadTransports[] = $transport; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php new file mode 100644 index 000000000..77489cedc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php @@ -0,0 +1,32 @@ +_invoker = $invoker; + $this->_eventDispatcher = $eventDispatcher; + } + + /** + * Not used. + */ + public function isStarted() + { + return false; + } + + /** + * Not used. + */ + public function start() + { + } + + /** + * Not used. + */ + public function stop() + { + } + + /** + * Set the additional parameters used on the mail() function. + * + * This string is formatted for sprintf() where %s is the sender address. + * + * @param string $params + * + * @return Swift_Transport_MailTransport + */ + public function setExtraParams($params) + { + $this->_extraParams = $params; + + return $this; + } + + /** + * Get the additional parameters used on the mail() function. + * + * This string is formatted for sprintf() where %s is the sender address. + * + * @return string + */ + public function getExtraParams() + { + return $this->_extraParams; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + $count = ( + count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ); + + $toHeader = $message->getHeaders()->get('To'); + $subjectHeader = $message->getHeaders()->get('Subject'); + + if (!$toHeader) { + $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); + } + $to = $toHeader->getFieldBody(); + $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; + + $reversePath = $this->_getReversePath($message); + + // Remove headers that would otherwise be duplicated + $message->getHeaders()->remove('To'); + $message->getHeaders()->remove('Subject'); + + $messageStr = $message->toString(); + + $message->getHeaders()->set($toHeader); + $message->getHeaders()->set($subjectHeader); + + // Separate headers from body + if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { + $headers = substr($messageStr, 0, $endHeaders)."\r\n"; //Keep last EOL + $body = substr($messageStr, $endHeaders + 4); + } else { + $headers = $messageStr."\r\n"; + $body = ''; + } + + unset($messageStr); + + if ("\r\n" != PHP_EOL) { + // Non-windows (not using SMTP) + $headers = str_replace("\r\n", PHP_EOL, $headers); + $body = str_replace("\r\n", PHP_EOL, $body); + } else { + // Windows, using SMTP + $headers = str_replace("\r\n.", "\r\n..", $headers); + $body = str_replace("\r\n.", "\r\n..", $body); + } + + if ($this->_invoker->mail($to, $subject, $body, $headers, + sprintf($this->_extraParams, $reversePath))) { + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + } else { + $failedRecipients = array_merge( + $failedRecipients, + array_keys((array) $message->getTo()), + array_keys((array) $message->getCc()), + array_keys((array) $message->getBcc()) + ); + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); + + $count = 0; + } + + return $count; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } + + /** Throw a TransportException, first sending it to any listeners */ + protected function _throwException(Swift_TransportException $e) + { + if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } + + /** Determine the best-use reverse path for this message */ + private function _getReversePath(Swift_Mime_Message $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + $keys = array_keys($sender); + $path = array_shift($keys); + } elseif (!empty($from)) { + $keys = array_keys($from); + $path = array_shift($keys); + } + + return $path; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php new file mode 100644 index 000000000..ad20e0e53 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Pretends messages have been sent, but just ignores them. + * + * @author Fabien Potencier + */ +class Swift_Transport_NullTransport implements Swift_Transport +{ + /** The event dispatcher from the plugin API */ + private $_eventDispatcher; + + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher) + { + $this->_eventDispatcher = $eventDispatcher; + } + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Sends the given message. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $count = ( + count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ); + + return $count; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php new file mode 100644 index 000000000..3ef7dec83 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -0,0 +1,159 @@ + 30, + 'blocking' => 1, + 'command' => '/usr/sbin/sendmail -bs', + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, + ); + + /** + * Create a new SendmailTransport with $buf for I/O. + * + * @param Swift_Transport_IoBuffer $buf + * @param Swift_Events_EventDispatcher $dispatcher + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher) + { + parent::__construct($buf, $dispatcher); + } + + /** + * Start the standalone SMTP session if running in -bs mode. + */ + public function start() + { + if (false !== strpos($this->getCommand(), ' -bs')) { + parent::start(); + } + } + + /** + * Set the command to invoke. + * + * If using -t mode you are strongly advised to include -oi or -i in the flags. + * For example: /usr/sbin/sendmail -oi -t + * Swift will append a -f flag if one is not present. + * + * The recommended mode is "-bs" since it is interactive and failure notifications + * are hence possible. + * + * @param string $command + * + * @return Swift_Transport_SendmailTransport + */ + public function setCommand($command) + { + $this->_params['command'] = $command; + + return $this; + } + + /** + * Get the sendmail command which will be invoked. + * + * @return string + */ + public function getCommand() + { + return $this->_params['command']; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * + * The return value is the number of recipients who were accepted for delivery. + * NOTE: If using 'sendmail -t' you will not be aware of any failures until + * they bounce (i.e. send() will always return 100% success). + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + $command = $this->getCommand(); + $buffer = $this->getBuffer(); + + if (false !== strpos($command, ' -t')) { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (false === strpos($command, ' -f')) { + $command .= ' -f'.escapeshellarg($this->_getReversePath($message)); + } + + $buffer->initialize(array_merge($this->_params, array('command' => $command))); + + if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { + $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n..")); + } else { + $buffer->setWriteTranslations(array("\r\n" => "\n")); + } + + $count = count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ; + $message->toByteStream($buffer); + $buffer->flushBuffers(); + $buffer->setWriteTranslations(array()); + $buffer->terminate(); + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); + } elseif (false !== strpos($command, ' -bs')) { + $count = parent::send($message, $failedRecipients); + } else { + $this->_throwException(new Swift_TransportException( + 'Unsupported sendmail command flags ['.$command.']. '. + 'Must be one of "-bs" or "-t" but can include additional flags.' + )); + } + + return $count; + } + + /** Get the params to initialize the buffer */ + protected function _getBufferParams() + { + return $this->_params; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php new file mode 100644 index 000000000..21e629a64 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in a queue. + * + * @author Fabien Potencier + */ +class Swift_Transport_SpoolTransport implements Swift_Transport +{ + /** The spool instance */ + private $_spool; + + /** The event dispatcher from the plugin API */ + private $_eventDispatcher; + + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) + { + $this->_eventDispatcher = $eventDispatcher; + $this->_spool = $spool; + } + + /** + * Sets the spool object. + * + * @param Swift_Spool $spool + * + * @return Swift_Transport_SpoolTransport + */ + public function setSpool(Swift_Spool $spool) + { + $this->_spool = $spool; + + return $this; + } + + /** + * Get the spool object. + * + * @return Swift_Spool + */ + public function getSpool() + { + return $this->_spool; + } + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Sends the given message. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + $success = $this->_spool->queueMessage($message); + + if ($evt) { + $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + return 1; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php new file mode 100644 index 000000000..84ebbee86 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -0,0 +1,321 @@ +_replacementFactory = $replacementFactory; + } + + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + * + * @param array $params + */ + public function initialize(array $params) + { + $this->_params = $params; + switch ($params['type']) { + case self::TYPE_PROCESS: + $this->_establishProcessConnection(); + break; + case self::TYPE_SOCKET: + default: + $this->_establishSocketConnection(); + break; + } + } + + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value) + { + if (isset($this->_stream)) { + switch ($param) { + case 'timeout': + if ($this->_stream) { + stream_set_timeout($this->_stream, $value); + } + break; + + case 'blocking': + if ($this->_stream) { + stream_set_blocking($this->_stream, 1); + } + + } + } + $this->_params[$param] = $value; + } + + public function startTLS() + { + return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); + } + + /** + * Perform any shutdown logic needed. + */ + public function terminate() + { + if (isset($this->_stream)) { + switch ($this->_params['type']) { + case self::TYPE_PROCESS: + fclose($this->_in); + fclose($this->_out); + proc_close($this->_stream); + break; + case self::TYPE_SOCKET: + default: + fclose($this->_stream); + break; + } + } + $this->_stream = null; + $this->_out = null; + $this->_in = null; + } + + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements) + { + foreach ($this->_translations as $search => $replace) { + if (!isset($replacements[$search])) { + $this->removeFilter($search); + unset($this->_translations[$search]); + } + } + + foreach ($replacements as $search => $replace) { + if (!isset($this->_translations[$search])) { + $this->addFilter( + $this->_replacementFactory->createFilter($search, $replace), $search + ); + $this->_translations[$search] = true; + } + } + } + + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @throws Swift_IoException + * + * @return string + */ + public function readLine($sequence) + { + if (isset($this->_out) && !feof($this->_out)) { + $line = fgets($this->_out); + if (strlen($line) == 0) { + $metas = stream_get_meta_data($this->_out); + if ($metas['timed_out']) { + throw new Swift_IoException( + 'Connection to '. + $this->_getReadConnectionDescription(). + ' Timed Out' + ); + } + } + + return $line; + } + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the remaining bytes are given instead. + * If no bytes are remaining at all, boolean false is returned. + * + * @param int $length + * + * @throws Swift_IoException + * + * @return string|bool + */ + public function read($length) + { + if (isset($this->_out) && !feof($this->_out)) { + $ret = fread($this->_out, $length); + if (strlen($ret) == 0) { + $metas = stream_get_meta_data($this->_out); + if ($metas['timed_out']) { + throw new Swift_IoException( + 'Connection to '. + $this->_getReadConnectionDescription(). + ' Timed Out' + ); + } + } + + return $ret; + } + } + + /** Not implemented */ + public function setReadPointer($byteOffset) + { + } + + /** Flush the stream contents */ + protected function _flush() + { + if (isset($this->_in)) { + fflush($this->_in); + } + } + + /** Write this bytes to the stream */ + protected function _commit($bytes) + { + if (isset($this->_in)) { + $bytesToWrite = strlen($bytes); + $totalBytesWritten = 0; + + while ($totalBytesWritten < $bytesToWrite) { + $bytesWritten = fwrite($this->_in, substr($bytes, $totalBytesWritten)); + if (false === $bytesWritten || 0 === $bytesWritten) { + break; + } + + $totalBytesWritten += $bytesWritten; + } + + if ($totalBytesWritten > 0) { + return ++$this->_sequence; + } + } + } + + /** + * Establishes a connection to a remote server. + */ + private function _establishSocketConnection() + { + $host = $this->_params['host']; + if (!empty($this->_params['protocol'])) { + $host = $this->_params['protocol'].'://'.$host; + } + $timeout = 15; + if (!empty($this->_params['timeout'])) { + $timeout = $this->_params['timeout']; + } + $options = array(); + if (!empty($this->_params['sourceIp'])) { + $options['socket']['bindto'] = $this->_params['sourceIp'].':0'; + } + $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options)); + if (false === $this->_stream) { + throw new Swift_TransportException( + 'Connection could not be established with host '.$this->_params['host']. + ' ['.$errstr.' #'.$errno.']' + ); + } + if (!empty($this->_params['blocking'])) { + stream_set_blocking($this->_stream, 1); + } else { + stream_set_blocking($this->_stream, 0); + } + stream_set_timeout($this->_stream, $timeout); + $this->_in = &$this->_stream; + $this->_out = &$this->_stream; + } + + /** + * Opens a process for input/output. + */ + private function _establishProcessConnection() + { + $command = $this->_params['command']; + $descriptorSpec = array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w'), + ); + $this->_stream = proc_open($command, $descriptorSpec, $pipes); + stream_set_blocking($pipes[2], 0); + if ($err = stream_get_contents($pipes[2])) { + throw new Swift_TransportException( + 'Process could not be started ['.$err.']' + ); + } + $this->_in = &$pipes[0]; + $this->_out = &$pipes[1]; + } + + private function _getReadConnectionDescription() + { + switch ($this->_params['type']) { + case self::TYPE_PROCESS: + return 'Process '.$this->_params['command']; + break; + + case self::TYPE_SOCKET: + default: + $host = $this->_params['host']; + if (!empty($this->_params['protocol'])) { + $host = $this->_params['protocol'].'://'.$host; + } + $host .= ':'.$this->_params['port']; + + return $host; + break; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php new file mode 100644 index 000000000..4ae2412e6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php @@ -0,0 +1,29 @@ + + */ +class Swift_Validate +{ + /** + * Grammar Object. + * + * @var Swift_Mime_Grammar + */ + private static $grammar = null; + + /** + * Checks if an e-mail address matches the current grammars. + * + * @param string $email + * + * @return bool + */ + public static function email($email) + { + if (self::$grammar === null) { + self::$grammar = Swift_DependencyContainer::getInstance() + ->lookup('mime.grammar'); + } + + return (bool) preg_match( + '/^'.self::$grammar->getDefinition('addr-spec').'$/D', + $email + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php new file mode 100644 index 000000000..6023448e8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php @@ -0,0 +1,23 @@ +register('cache') + ->asAliasOf('cache.array') + + ->register('tempdir') + ->asValue('/tmp') + + ->register('cache.null') + ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') + + ->register('cache.array') + ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') + ->withDependencies(array('cache.inputstream')) + + ->register('cache.disk') + ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') + ->withDependencies(array('cache.inputstream', 'tempdir')) + + ->register('cache.inputstream') + ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php new file mode 100644 index 000000000..64d69d215 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php @@ -0,0 +1,9 @@ +register('message.message') + ->asNewInstanceOf('Swift_Message') + + ->register('message.mimepart') + ->asNewInstanceOf('Swift_MimePart') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php new file mode 100644 index 000000000..04f394b32 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php @@ -0,0 +1,123 @@ +register('properties.charset') + ->asValue('utf-8') + + ->register('mime.grammar') + ->asSharedInstanceOf('Swift_Mime_Grammar') + + ->register('mime.message') + ->asNewInstanceOf('Swift_Mime_SimpleMessage') + ->withDependencies(array( + 'mime.headerset', + 'mime.qpcontentencoder', + 'cache', + 'mime.grammar', + 'properties.charset', + )) + + ->register('mime.part') + ->asNewInstanceOf('Swift_Mime_MimePart') + ->withDependencies(array( + 'mime.headerset', + 'mime.qpcontentencoder', + 'cache', + 'mime.grammar', + 'properties.charset', + )) + + ->register('mime.attachment') + ->asNewInstanceOf('Swift_Mime_Attachment') + ->withDependencies(array( + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.grammar', + )) + ->addConstructorValue($swift_mime_types) + + ->register('mime.embeddedfile') + ->asNewInstanceOf('Swift_Mime_EmbeddedFile') + ->withDependencies(array( + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.grammar', + )) + ->addConstructorValue($swift_mime_types) + + ->register('mime.headerfactory') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') + ->withDependencies(array( + 'mime.qpheaderencoder', + 'mime.rfc2231encoder', + 'mime.grammar', + 'properties.charset', + )) + + ->register('mime.headerset') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') + ->withDependencies(array('mime.headerfactory', 'properties.charset')) + + ->register('mime.qpheaderencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') + ->withDependencies(array('mime.charstream')) + + ->register('mime.base64headerencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') + ->withDependencies(array('mime.charstream')) + + ->register('mime.charstream') + ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') + ->withDependencies(array('mime.characterreaderfactory', 'properties.charset')) + + ->register('mime.bytecanonicalizer') + ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') + ->addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A))) + ->addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A))) + + ->register('mime.characterreaderfactory') + ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') + + ->register('mime.safeqpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + + ->register('mime.rawcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') + + ->register('mime.nativeqpcontentencoder') + ->withDependencies(array('properties.charset')) + ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') + + ->register('mime.qpcontentencoderproxy') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') + ->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset')) + + ->register('mime.7bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('7bit') + ->addConstructorValue(true) + + ->register('mime.8bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('8bit') + ->addConstructorValue(true) + + ->register('mime.base64contentencoder') + ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') + + ->register('mime.rfc2231encoder') + ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') + ->withDependencies(array('mime.charstream')) + + // As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly. + // see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629 + ->register('mime.qpcontentencoder') + ->asAliasOf(version_compare(phpversion(), '5.4.7', '>=') ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder') +; + +unset($swift_mime_types); diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php new file mode 100644 index 000000000..77e432cfa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php @@ -0,0 +1,76 @@ +register('transport.smtp') + ->asNewInstanceOf('Swift_Transport_EsmtpTransport') + ->withDependencies(array( + 'transport.buffer', + array('transport.authhandler'), + 'transport.eventdispatcher', + )) + + ->register('transport.sendmail') + ->asNewInstanceOf('Swift_Transport_SendmailTransport') + ->withDependencies(array( + 'transport.buffer', + 'transport.eventdispatcher', + )) + + ->register('transport.mail') + ->asNewInstanceOf('Swift_Transport_MailTransport') + ->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher')) + + ->register('transport.loadbalanced') + ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') + + ->register('transport.failover') + ->asNewInstanceOf('Swift_Transport_FailoverTransport') + + ->register('transport.spool') + ->asNewInstanceOf('Swift_Transport_SpoolTransport') + ->withDependencies(array('transport.eventdispatcher')) + + ->register('transport.null') + ->asNewInstanceOf('Swift_Transport_NullTransport') + ->withDependencies(array('transport.eventdispatcher')) + + ->register('transport.mailinvoker') + ->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker') + + ->register('transport.buffer') + ->asNewInstanceOf('Swift_Transport_StreamBuffer') + ->withDependencies(array('transport.replacementfactory')) + + ->register('transport.authhandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') + ->withDependencies(array( + array( + 'transport.crammd5auth', + 'transport.loginauth', + 'transport.plainauth', + 'transport.ntlmauth', + 'transport.xoauth2auth', + ), + )) + + ->register('transport.crammd5auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') + + ->register('transport.loginauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') + + ->register('transport.plainauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') + + ->register('transport.xoauth2auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') + + ->register('transport.ntlmauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') + + ->register('transport.eventdispatcher') + ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') + + ->register('transport.replacementfactory') + ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/mime_types.php b/vendor/swiftmailer/swiftmailer/lib/mime_types.php new file mode 100644 index 000000000..2d7b98dc1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/mime_types.php @@ -0,0 +1,1007 @@ + 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gpp', + '7z' => 'application/x-7z-compressed', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/x-aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/pkix-attr-cert', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'apk' => 'application/vnd.android.package-archive', + 'appcache' => 'text/cache-manifest', + 'apr' => 'application/vnd.lotus-approach', + 'aps' => 'application/postscript', + 'arc' => 'application/x-freearc', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/basic', + 'avi' => 'video/x-msvideo', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azw' => 'application/vnd.amazon.ebook', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'btif' => 'image/prs.btif', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/java-vm', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'csh' => 'application/x-csh', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/x-msdownload', + 'dmg' => 'application/x-apple-diskimage', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.document.macroenabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dra' => 'audio/vnd.dra', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'application/x-msmetafile', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/x-msdownload', + 'exi' => 'application/exi', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/x-f4v', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'geo' => 'application/vnd.dynageo', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/x-gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hdf' => 'application/x-hdf', + 'hh' => 'text/x-c', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'java' => 'text/x-java-source', + 'jisp' => 'application/vnd.jisp', + 'jlt' => 'application/vnd.hp-jlyt', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jpm' => 'video/jpm', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'jsonml' => 'application/jsonml+json', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'lha' => 'application/x-lzh-compressed', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/x-lzh-compressed', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm1v' => 'video/mpeg', + 'm21' => 'application/mp21', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'audio/x-mpegurl', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/mp4', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'mar' => 'application/octet-stream', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp21' => 'application/mp21', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msl' => 'application/vnd.mobius.msl', + 'msty' => 'application/vnd.muvee.style', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'ntf' => 'application/vnd.nitf', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obj' => 'application/x-tgif', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'org' => 'application/vnd.lotus-organizer', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'application/x-font-otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p10' => 'application/pkcs10', + 'p12' => 'application/x-pkcs12', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/vnd.palm', + 'pdf' => 'application/pdf', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp-encrypted', + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'application/x-mobipocket-ebook', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'image/vnd.adobe.photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-pn-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsd' => 'application/rsd+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'rtx' => 'text/richtext', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shf' => 'application/shf+xml', + 'sid' => 'image/x-mrsid-image', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil+xml', + 'smil' => 'application/smil+xml', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'application/vnd.ms-pki.stl', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tga' => 'image/x-tga', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tmo' => 'application/vnd.tmobile-livetv', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trm' => 'application/x-msterminal', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'application/x-font-ttf', + 'ttf' => 'application/x-font-ttf', + 'ttl' => 'text/turtle', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u32' => 'application/x-authorware-bin', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgt' => 'application/widget', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'application/x-msmetafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'application/font-woff', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x32' => 'application/x-authorware-bin', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+binary', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d+vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/vnd.adobe.xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/x-xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + '123' => 'application/vnd.lotus-1-2-3', +); diff --git a/vendor/swiftmailer/swiftmailer/lib/preferences.php b/vendor/swiftmailer/swiftmailer/lib/preferences.php new file mode 100644 index 000000000..e51950148 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/preferences.php @@ -0,0 +1,25 @@ +setCharset('utf-8'); + +// Without these lines the default caching mechanism is "array" but this uses a lot of memory. +// If possible, use a disk cache to enable attaching large attachments etc. +// You can override the default temporary directory by setting the TMPDIR environment variable. +if (@is_writable($tmpDir = sys_get_temp_dir())) { + $preferences->setTempDir($tmpDir)->setCacheType('disk'); +} + +// this should only be done when Swiftmailer won't use the native QP content encoder +// see mime_deps.php +if (version_compare(phpversion(), '5.4.7', '<')) { + $preferences->setQPDotEscape(false); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/swift_init.php b/vendor/swiftmailer/swiftmailer/lib/swift_init.php new file mode 100644 index 000000000..5c4bae4f4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/swift_init.php @@ -0,0 +1,28 @@ + 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'zip' => 'application/zip', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'css' => 'text/css', + 'js' => 'text/javascript', + 'txt' => 'text/plain', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/avi', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bz2', + 'csv' => 'text/csv', + 'dmg' => 'application/x-apple-diskimage', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'eml' => 'message/rfc822', + 'aps' => 'application/postscript', + 'exe' => 'application/x-ms-dos-executable', + 'flv' => 'video/x-flv', + 'gz' => 'application/x-gzip', + 'hqx' => 'application/stuffit', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jar' => 'application/x-java-archive', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'm3u' => 'audio/x-mpegurl', + 'm4a' => 'audio/mp4', + 'mdb' => 'application/x-msaccess', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'odg' => 'vnd.oasis.opendocument.graphics', + 'odp' => 'vnd.oasis.opendocument.presentation', + 'odt' => 'vnd.oasis.opendocument.text', + 'ods' => 'vnd.oasis.opendocument.spreadsheet', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'rar' => 'application/x-rar-compressed', + 'rtf' => 'application/rtf', + 'tar' => 'application/x-tar', + 'sit' => 'application/x-stuffit', + 'svg' => 'image/svg+xml', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'ttf' => 'application/x-font-truetype', + 'vcf' => 'text/x-vcard', + 'wav' => 'audio/wav', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'audio/x-ms-wmv', + 'xls' => 'application/excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + ); + + // wrap array for generating file + foreach ($valid_mime_types_preset as $extension => $mime_type) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + + // collect extensions + $valid_extensions = array(); + + // all extensions from second match + foreach ($matches[2] as $i => $extensions) { + // explode multiple extensions from string + $extensions = explode(' ', strtolower($extensions)); + + // force array for foreach + if (!is_array($extensions)) { + $extensions = array($extensions); + } + + foreach ($extensions as $extension) { + // get mime type + $mime_type = $matches[1][$i]; + + // check if string length lower than 10 + if (strlen($extension) < 10) { + // add extension + $valid_extensions[] = $extension; + + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + } + } + + $xml = simplexml_load_string($mime_xml); + + foreach ($xml as $node) { + // check if there is no pattern + if (!isset($node->glob['pattern'])) { + continue; + } + + // get all matching extensions from match + foreach ((array) $node->glob['pattern'] as $extension) { + // skip none glob extensions + if (strpos($extension, '.') === false) { + continue; + } + + // remove get only last part + $extension = explode('.', strtolower($extension)); + $extension = end($extension); + + // maximum length in database column + if (strlen($extension) <= 9) { + $valid_extensions[] = $extension; + } + } + + if (isset($node->glob['pattern'][0])) { + // mime type + $mime_type = strtolower((string) $node['type']); + + // get first extension + $extension = strtolower(trim($node->glob['ddpattern'][0], '*.')); + + // skip none glob extensions and check if string length between 1 and 10 + if (strpos($extension, '.') !== false || strlen($extension) < 1 || strlen($extension) > 9) { + continue; + } + + // check if string length lower than 10 + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + + // full list of valid extensions only + $valid_mime_types = array_unique($valid_mime_types); + ksort($valid_mime_types); + + // combine mime types and extensions array + $output = "$preamble\$swift_mime_types = array(\n ".implode($valid_mime_types, ",\n ")."\n);"; + + // write mime_types.php config file + @file_put_contents('./mime_types.php', $output); +} + +generateUpToDateMimeArray(); diff --git a/vendor/swiftmailer/swiftmailer/phpunit.xml.dist b/vendor/swiftmailer/swiftmailer/phpunit.xml.dist new file mode 100644 index 000000000..24205867b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/phpunit.xml.dist @@ -0,0 +1,37 @@ + + + + + + + + + + + tests/unit + + + tests/acceptance + + + tests/bug + + + tests/smoke + + + + + + + diff --git a/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php b/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php new file mode 100644 index 000000000..069d11ab7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php @@ -0,0 +1,62 @@ +value = $value; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * + * @return bool + */ + public function matches($other) + { + $aHex = $this->asHexString($this->value); + $bHex = $this->asHexString($other); + + return $aHex === $bHex; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'indentical binary'; + } + + /** + * Get the given string of bytes as a stirng of Hexadecimal sequences. + * + * @param string $binary + * + * @return string + */ + private function asHexString($binary) + { + $hex = ''; + + $bytes = unpack('H*', $binary); + + foreach ($bytes as &$byte) { + $byte = strtoupper($byte); + } + + return implode('', $bytes); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php b/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php new file mode 100644 index 000000000..7f079d983 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php @@ -0,0 +1,11 @@ +content .= $arg; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php new file mode 100644 index 000000000..21d89e83b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php @@ -0,0 +1,46 @@ +markTestSkipped( + 'Smoke tests are skipped if tests/smoke.conf.php is not edited' + ); + } + } + + protected function _getMailer() + { + switch (SWIFT_SMOKE_TRANSPORT_TYPE) { + case 'smtp': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.smtp') + ->setHost(SWIFT_SMOKE_SMTP_HOST) + ->setPort(SWIFT_SMOKE_SMTP_PORT) + ->setUsername(SWIFT_SMOKE_SMTP_USER) + ->setPassword(SWIFT_SMOKE_SMTP_PASS) + ->setEncryption(SWIFT_SMOKE_SMTP_ENCRYPTION) + ; + break; + case 'sendmail': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.sendmail') + ->setCommand(SWIFT_SMOKE_SENDMAIL_COMMAND) + ; + break; + case 'mail': + case 'nativemail': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.mail'); + break; + default: + throw new Exception('Undefined transport ['.SWIFT_SMOKE_TRANSPORT_TYPE.']'); + } + + return new Swift_Mailer($transport); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php new file mode 100644 index 000000000..f0e27361c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/files/swiftmailer.png b/vendor/swiftmailer/swiftmailer/tests/_samples/files/swiftmailer.png new file mode 100644 index 0000000000000000000000000000000000000000..1b95f619af1fcbed1fca382d22022bdf329849cf GIT binary patch literal 3194 zcmV-=42AQFP)MSx|GoLxC1$NK z_Ph69ufRtQ76+DFuvF-8orSRY^mzh{hyTC*`g`GJF2^N{QXxQY!g418;53Gy4`6Wt z@W4WCEiaf6;7tNLOGCi-2=LHCZ7mC!tMIWuL$7RVA;G=7=x|%8^OYGLShnYUDhm&{ zg*qRgG59-xrCOlVLap5bussX4wX{GtNp2L?&||kP)YeRa-p?TroQ0vc-dGelVxhJ` zbHgmj`XYe6V)0vOpab&4Cj>2rw?=>CC(n=L-$$^lSx;?E2D-=Qo8dr^dBcluc+ORJ zo@Ok)#uf8ieAG%L42Q#c`YOud`3-#p& zx0pwR}3v$0N&KqF{v0Ir|mG1_!JrIaAnQ_n_r40Af1%SNq$VGh?- zDXXWpP)~pJk68AdlR|>owIyz$&Kl?@%RbwIX}OKd*e}{@>J;|jNB^t|SqlG$KX_@< zYPOT{srCWpmc{fEdFtc$hkWQ00_xRYTk~Q-#%(ZN)nMakx2TCY4cs|+=~l+UpzgXH z3KFBCVsZn{{@|S|8)bT`V)?Z;Zx^N|a=FAncPT*Yk;goObw@Ek5$~cJb)e&uswQUhp?_8ZB}LDU1)1XVxzQBgVh!5bYS*aa$n|JikshH+4PM@px5US z5KI1hj^xpt1p^u_NV(oZoq@I4d3Q?gY1@Xf0y7?wX2swT7EcHglRVbe z0s_q_WwNWG>Pu4vf1~O-k3Mg0@!VhV^|zdz4O~YIj}5@ z)|!D$l=1lH%JrgXWP>a>qy`4 zfd_Xf*yB0msv=VnO421sgGW<)JvhBrJALv+<+Cq+cK6}C5v;E~_vYC~kG{Uo{Le>+ zz5eve?B>-s*bC2G&c>a(FWeJ{VvUPW=jQFDIEYEMIT|^L*`CApFW>5Gpxq`exeb89 zK7rhmuDQL!NoS)W{BchYPx)ZMZO}SZReVg^Oa`>3+8)*qpg=su`iAD=;tzrDdzX&m zBt-gYJVkUPuC3gN{#jlARs{76&#bZQS6)8f>I#dXe&yLW+0E5AlsiJm3G|b<*-N~2 zQ#XAApDW}JY&X_81Ta_V;cXaP170tBZ-i?d;8r~(n~HKdiE#iXUU^&Ld}NF6C2Whw z-vGGfa~qqI4Vd+ry8rqeEX!*GX zPzuPkInk36ZVgpFze_+8TWRTeWKV;P8V#8kOEY&5b$_oN=C zfVZ9!c1KeSWEKdT+UKXAXurGQxsz=>%?&57Zc?TJIUHR%WUjYKGjD6|O`mFWU-Qsy z8$ex&%YLW|W*0O|TXOeRszyS|bM{oy0VIWM2yYGh6Now-{;$MnFB9tv7p>Bn0mTPK z!QiJ~e83)pUOtEVUq&Z^zk2`=z%|g`FMi`kNt*|xpDPM&E!L90^pHD3t%<+)L}>x= zHZ-2OF^#M+sfjfAr7g+}fWNCK^DS7vtB@f&qSp+K@c*Z;;KpqHsmIns`02nB4 zKwSio^mHYm+UaW~&e@6U0#MmVdv+-Z>#CrJZMv%8!uDfOe*$nqU}t{`TMB zU-0PvdvY3n|LTu*WzdK7X$j|mWieEgSzQ4MV=|V}Au&KJv7|%P<1?LGi1~iu+Cz>4&0c?*B=<+n4#;eO3s47W{ zB(KnrY5~Xa!V72jAAhXU+^x4>?YbX+^mElu_Obwx(tOI-?@m=iD#6~&JN?i2qW>RG*IxzvC z%KL6Ag*@E5P1w+3EWTGe$UjqK^=XXgpk4UJ66dz_(44`X-J*wOdY zC3PE?sU85{Opeu46To)qgaW}McTAwBbX>sVJLeoLAdicbjaw0CU|8T4Yz>qR`*Zx{ z+j~*|8UM!5zy9YpMF>P?YXZdggn*yNM!9B0Ks$Q?rb>=BDOWvU=S|x+dKevHdv6+N zwxXyaOr8>5gMrK9JEM4tCpyjcS$XLuzi#aBtm>469-6Pme$)jpWxpG8LPf}kplnsm zF<8y|{FYhzd|-=GfF_<;r>D7h_Y#gj$N}i82*;<7K8QN|$63<%c^Ed4vvfnRa+O8k zt$hMJcR7Yox0kQ|+vLDli0e4wKui0mXP$0f{gmtdgjU3G+I6I(FJyO6e*FExA7i_h ze)i??Y}=IZgekTUlC}k~cMZTn$FZiU&cg{G2IFg>kt}O0x&1?~f!b4)+h{l!M*UB| zTCG3+$Ip%xItYL4#dzm&aXQ|L7~9OP>cyuT4WkKyD#A@x{zjTR4?7HbbltHp9Ks=4 zvJ^p}1>jph{m!3#)xI_7A$O?_sPhstId7(!_m4)vIEs7c(g0t@$jUKGD|Z1+@@7 z?vvLG$!qTxG$6#j9L))L;gN?9EglOFwWc~p0NO?IXhII!W;iU=sXd`Qp=6(c2<8Mc zA2&H^qfx*Vb46RbBv1<=b=i2o*xcbJ?VM(2P1$mL-?z1bLrp+Aq_e9ExCdEzKJv^6 z^VSqn!+K{6^+Z*FK%Q_g3*Ak@Du2_#q@MX~c7E%fEz~AnyTkNT_J$N#p3r9yCsXKQ z;jeeQ#bz`6&|I~@wUR+CY1~dqSs+S)Earl*U32337r@fWm`K g-$HCnw*Lz-0AR%yng8k!ga7~l07*qoM6N<$f>^s2o&W#< literal 0 HcmV?d00001 diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip b/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip new file mode 100644 index 0000000000000000000000000000000000000000..5a580ecbf81ff98445bc5c6d0fce7a9a301f0e39 GIT binary patch literal 202 zcmWIWW@h1HU}9ikII%0tqR&rhgC39#!aNM33?-=*C25&Csd^<9C7~gl49w;G_PK*_ zXax(ySH`c5AsLy)3P4nlSX82rpQezg5L}*_R-)jW2-H=iP-db~oSUDWs!)markTestSkipped( + 'Cannot run test without a writable directory to use ('. + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_tmpDir = SWIFT_TMP_DIR; + $this->_testFile = $this->_tmpDir.'/swift-test-file'.__CLASS__; + file_put_contents($this->_testFile, 'abcdefghijklm'); + } + + public function tearDown() + { + unlink($this->_testFile); + } + + public function testFileDataCanBeRead() + { + $file = $this->_createFileStream($this->_testFile); + $str = ''; + while (false !== $bytes = $file->read(8192)) { + $str .= $bytes; + } + $this->assertEquals('abcdefghijklm', $str); + } + + public function testFileDataCanBeReadSequentially() + { + $file = $this->_createFileStream($this->_testFile); + $this->assertEquals('abcde', $file->read(5)); + $this->assertEquals('fghijklm', $file->read(8)); + $this->assertFalse($file->read(1)); + } + + public function testFilenameIsReturned() + { + $file = $this->_createFileStream($this->_testFile); + $this->assertEquals($this->_testFile, $file->getPath()); + } + + public function testFileCanBeWrittenTo() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->write('foobar'); + $this->assertEquals('foobar', $file->read(8192)); + } + + public function testReadingFromThenWritingToFile() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->write('foobar'); + $this->assertEquals('foobar', $file->read(8192)); + $file->write('zipbutton'); + $this->assertEquals('zipbutton', $file->read(8192)); + } + + public function testWritingToFileWithCanonicalization() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->addFilter($this->_createFilter(array("\r\n", "\r"), "\n"), 'allToLF'); + $file->write("foo\r\nbar\r"); + $file->write("\nzip\r\ntest\r"); + $file->flushBuffers(); + $this->assertEquals("foo\nbar\nzip\ntest\n", file_get_contents($this->_testFile)); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $file->bind($is1); + $file->bind($is2); + + $file->write('x'); + $file->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $file->bind($is1); + $file->bind($is2); + + $file->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $file->bind($is1); + $file->bind($is2); + + $file->write('x'); + + $file->unbind($is2); + + $file->write('y'); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } + + private function _createMockInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } + + private function _createFileStream($file, $writable = false) + { + return new Swift_ByteStream_FileByteStream($file, $writable); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php new file mode 100644 index 000000000..8ce4a1828 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php @@ -0,0 +1,179 @@ +_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testCreatingUtf8Reader() + { + foreach (array('utf8', 'utf-8', 'UTF-8', 'UTF8') as $utf8) { + $reader = $this->_factory->getReaderFor($utf8); + $this->assertInstanceof($this->_prefix.'Utf8Reader', $reader); + } + } + + public function testCreatingIso8859XReaders() + { + $charsets = array(); + foreach (range(1, 16) as $number) { + foreach (array('iso', 'iec') as $body) { + $charsets[] = $body.'-8859-'.$number; + $charsets[] = $body.'8859-'.$number; + $charsets[] = strtoupper($body).'-8859-'.$number; + $charsets[] = strtoupper($body).'8859-'.$number; + } + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingWindows125XReaders() + { + $charsets = array(); + foreach (range(0, 8) as $number) { + $charsets[] = 'windows-125'.$number; + $charsets[] = 'windows125'.$number; + $charsets[] = 'WINDOWS-125'.$number; + $charsets[] = 'WINDOWS125'.$number; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingCodePageReaders() + { + $charsets = array(); + foreach (range(0, 8) as $number) { + $charsets[] = 'cp-125'.$number; + $charsets[] = 'cp125'.$number; + $charsets[] = 'CP-125'.$number; + $charsets[] = 'CP125'.$number; + } + + foreach (array(437, 737, 850, 855, 857, 858, 860, + 861, 863, 865, 866, 869, ) as $number) { + $charsets[] = 'cp-'.$number; + $charsets[] = 'cp'.$number; + $charsets[] = 'CP-'.$number; + $charsets[] = 'CP'.$number; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingAnsiReader() + { + foreach (array('ansi', 'ANSI') as $ansi) { + $reader = $this->_factory->getReaderFor($ansi); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingMacintoshReader() + { + foreach (array('macintosh', 'MACINTOSH') as $mac) { + $reader = $this->_factory->getReaderFor($mac); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingKOIReaders() + { + $charsets = array(); + foreach (array('7', '8-r', '8-u', '8u', '8r') as $end) { + $charsets[] = 'koi-'.$end; + $charsets[] = 'koi'.$end; + $charsets[] = 'KOI-'.$end; + $charsets[] = 'KOI'.$end; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingIsciiReaders() + { + foreach (array('iscii', 'ISCII', 'viscii', 'VISCII') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingMIKReader() + { + foreach (array('mik', 'MIK') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingCorkReader() + { + foreach (array('cork', 'CORK', 't1', 'T1') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingUcs2Reader() + { + foreach (array('ucs-2', 'UCS-2', 'ucs2', 'UCS2') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(2, $reader->getInitialByteSize()); + } + } + + public function testCreatingUtf16Reader() + { + foreach (array('utf-16', 'UTF-16', 'utf16', 'UTF16') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(2, $reader->getInitialByteSize()); + } + } + + public function testCreatingUcs4Reader() + { + foreach (array('ucs-4', 'UCS-4', 'ucs4', 'UCS4') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(4, $reader->getInitialByteSize()); + } + } + + public function testCreatingUtf32Reader() + { + foreach (array('utf-32', 'UTF-32', 'utf32', 'UTF32') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader); + $this->assertEquals(4, $reader->getInitialByteSize()); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php new file mode 100644 index 000000000..8caf6f54a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php @@ -0,0 +1,20 @@ +listItems() as $itemName) { + try { + $di->lookup($itemName); + } catch (Swift_DependencyException $e) { + $this->fail($e->getMessage()); + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php new file mode 100644 index 000000000..fc5a8147d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php @@ -0,0 +1,12 @@ +_samplesDir = realpath(__DIR__.'/../../../_samples/charsets'); + $this->_encoder = new Swift_Encoder_Base64Encoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + $encodedText = $this->_encoder->encodeString($text); + + $this->assertEquals( + base64_decode($encodedText), $text, + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php new file mode 100644 index 000000000..736dccbe0 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php @@ -0,0 +1,50 @@ +_samplesDir = realpath(__DIR__.'/../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_ArrayCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + $encodedText = $encoder->encodeString($text); + + $this->assertEquals( + quoted_printable_decode($encodedText), $text, + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php new file mode 100644 index 000000000..043ddf8cd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php @@ -0,0 +1,50 @@ +_samplesDir = realpath(__DIR__.'/../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_ArrayCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + $encodedText = $encoder->encodeString($text); + + $this->assertEquals( + urldecode(implode('', explode("\r\n", $encodedText))), $text, + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php new file mode 100644 index 000000000..6a4d05d3c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php @@ -0,0 +1,30 @@ +assertEquals('7bit', $encoder->getName()); + } + + public function testGet8BitEncodingReturns8BitEncoder() + { + $encoder = Swift_Encoding::get8BitEncoding(); + $this->assertEquals('8bit', $encoder->getName()); + } + + public function testGetQpEncodingReturnsQpEncoder() + { + $encoder = Swift_Encoding::getQpEncoding(); + $this->assertEquals('quoted-printable', $encoder->getName()); + } + + public function testGetBase64EncodingReturnsBase64Encoder() + { + $encoder = Swift_Encoding::getBase64Encoding(); + $this->assertEquals('base64', $encoder->getName()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php new file mode 100644 index 000000000..6b06e2ee6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php @@ -0,0 +1,173 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + } + + public function testStringDataCanBeSetAndFetched() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = new Swift_ByteStream_ArrayByteStream(); + $os1->write('abcdef'); + + $os2 = new Swift_ByteStream_ArrayByteStream(); + $os2->write('xyzuvw'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_cache->exportToByteStream($this->_key1, 'foo', $is); + + $string = ''; + while (false !== $bytes = $is->read(8192)) { + $string .= $bytes; + } + + $this->assertEquals('test', $string); + } + + public function testKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'bar')); + $this->_cache->clearAll($this->_key1); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'bar')); + } + + public function testKeyCacheInputStream() + { + $is = $this->_cache->getInputByteStream($this->_key1, 'foo'); + $is->write('abc'); + $is->write('xyz'); + $this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php new file mode 100644 index 000000000..392edde8f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php @@ -0,0 +1,183 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use ('. + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_key1 = uniqid(microtime(true), true); + $this->_key2 = uniqid(microtime(true), true); + $this->_cache = new Swift_KeyCache_DiskKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream(), + SWIFT_TMP_DIR + ); + } + + public function testStringDataCanBeSetAndFetched() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = new Swift_ByteStream_ArrayByteStream(); + $os1->write('abcdef'); + + $os2 = new Swift_ByteStream_ArrayByteStream(); + $os2->write('xyzuvw'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_cache->exportToByteStream($this->_key1, 'foo', $is); + + $string = ''; + while (false !== $bytes = $is->read(8192)) { + $string .= $bytes; + } + + $this->assertEquals('test', $string); + } + + public function testKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'bar')); + $this->_cache->clearAll($this->_key1); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'bar')); + } + + public function testKeyCacheInputStream() + { + $is = $this->_cache->getInputByteStream($this->_key1, 'foo'); + $is->write('abc'); + $is->write('xyz'); + $this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php new file mode 100644 index 000000000..9372fbfdc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php @@ -0,0 +1,57 @@ +_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $message->addPart('foo', 'text/plain', 'iso-8859-1'); + $message->addPart('test foo', 'text/html', 'iso-8859-1'); + + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'test foo'. + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + // -- Private helpers + + protected function _createMessage() + { + Swift_DependencyContainer::getInstance() + ->register('properties.charset')->asValue(null); + + return Swift_Message::newInstance(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php new file mode 100644 index 000000000..e925367e9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php @@ -0,0 +1,125 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testDispositionIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setDisposition('inline'); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline'."\r\n", + $attachment->toString() + ); + } + + public function testDispositionIsAttachmentByDefault() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment'."\r\n", + $attachment->toString() + ); + } + + public function testFilenameIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf'."\r\n", + $attachment->toString() + ); + } + + public function testSizeIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; size=12340'."\r\n", + $attachment->toString() + ); + } + + public function testMultipleParametersInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n", + $attachment->toString() + ); + } + + public function testEndToEnd() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setSize(12340); + $attachment->setBody('abcd'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n". + "\r\n". + base64_encode('abcd'), + $attachment->toString() + ); + } + + // -- Private helpers + + protected function _createAttachment() + { + $entity = new Swift_Mime_Attachment( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php new file mode 100644 index 000000000..2a5c562b4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php @@ -0,0 +1,56 @@ +_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + base64_decode($encoded), $text, + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php new file mode 100644 index 000000000..e8313da1d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php @@ -0,0 +1,86 @@ +_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_NativeQpContentEncoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + quoted_printable_decode($encoded), + // CR and LF are converted to CRLF + preg_replace('~\r(?!\n)|(?_createEncoderFromContainer(); + $this->assertSame('=C3=A4=C3=B6=C3=BC=C3=9F', $encoder->encodeString('äöüß')); + } + + /** + * @expectedException RuntimeException + */ + public function testCharsetChangeNotImplemented() + { + $this->_encoder->charsetChanged('utf-8'); + $this->_encoder->charsetChanged('charset'); + $this->_encoder->encodeString('foo'); + } + + public function testGetName() + { + $this->assertSame('quoted-printable', $this->_encoder->getName()); + } + + private function _createEncoderFromContainer() + { + return Swift_DependencyContainer::getInstance() + ->lookup('mime.nativeqpcontentencoder') + ; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php new file mode 100644 index 000000000..1541b7eac --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php @@ -0,0 +1,88 @@ +_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_PlainContentEncoder('8bit'); + } + + public function testEncodingAndDecodingSamplesString() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + $encodedText = $this->_encoder->encodeString($text); + + $this->assertEquals( + $encodedText, $text, + '%s: Encoded string should be identical to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } + + public function testEncodingAndDecodingSamplesByteStream() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + $encoded, $text, + '%s: Encoded string should be identical to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php new file mode 100644 index 000000000..501dbfa81 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php @@ -0,0 +1,157 @@ +_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_NgCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + quoted_printable_decode($encoded), $text, + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } + + public function testEncodingAndDecodingSamplesFromDiConfiguredInstance() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $encoder = $this->_createEncoderFromContainer(); + + $sampleDir = $this->_samplesDir.'/'.$encodingDir; + + if (is_dir($sampleDir)) { + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir.'/'.$sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + str_replace("\r\n", "\n", quoted_printable_decode($encoded)), str_replace("\r\n", "\n", $text), + '%s: Encoded string should decode back to original string for sample '. + $sampleDir.'/'.$sampleFile + ); + } + closedir($fileFp); + } + } + closedir($sampleFp); + } + + public function testEncodingLFTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\nb\nc")); + } + + public function testEncodingCRTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\rb\rc")); + } + + public function testEncodingLFCRTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\n\r\nb\r\n\r\nc", $encoder->encodeString("a\n\rb\n\rc")); + } + + public function testEncodingCRLFTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\r\nb\r\nc")); + } + + public function testEncodingDotStuffingWithDiConfiguredInstance() + { + // Enable DotEscaping + Swift_Preferences::getInstance()->setQPDotEscape(true); + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a=2E\r\n=2E\r\n=2Eb\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc")); + // Return to default + Swift_Preferences::getInstance()->setQPDotEscape(false); + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a.\r\n.\r\n.b\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc")); + } + + public function testDotStuffingEncodingAndDecodingSamplesFromDiConfiguredInstance() + { + // Enable DotEscaping + Swift_Preferences::getInstance()->setQPDotEscape(true); + $this->testEncodingAndDecodingSamplesFromDiConfiguredInstance(); + // Disable DotStuffing to continue + Swift_Preferences::getInstance()->setQPDotEscape(false); + } + + private function _createEncoderFromContainer() + { + return Swift_DependencyContainer::getInstance() + ->lookup('mime.qpcontentencoder') + ; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php new file mode 100644 index 000000000..75f3c84c1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php @@ -0,0 +1,137 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testContentIdIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $file->setContentType('application/pdf'); + $file->setId('foo@bar'); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline'."\r\n". + 'Content-ID: '."\r\n", + $file->toString() + ); + } + + public function testDispositionIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setDisposition('attachment'); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment'."\r\n". + 'Content-ID: <'.$id.'>'."\r\n", + $file->toString() + ); + } + + public function testFilenameIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=foo.pdf'."\r\n". + 'Content-ID: <'.$id.'>'."\r\n", + $file->toString() + ); + } + + public function testSizeIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; size=12340'."\r\n". + 'Content-ID: <'.$id.'>'."\r\n", + $file->toString() + ); + } + + public function testMultipleParametersInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $file->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n". + 'Content-ID: <'.$id.'>'."\r\n", + $file->toString() + ); + } + + public function testEndToEnd() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $file->setSize(12340); + $file->setBody('abcd'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n". + 'Content-ID: <'.$id.'>'."\r\n". + "\r\n". + base64_encode('abcd'), + $file->toString() + ); + } + + // -- Private helpers + + protected function _createEmbeddedFile() + { + $entity = new Swift_Mime_EmbeddedFile( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php new file mode 100644 index 000000000..304867a48 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php @@ -0,0 +1,32 @@ +_encoder = new Swift_Mime_HeaderEncoder_Base64HeaderEncoder(); + } + + public function testEncodingJIS() + { + if (function_exists('mb_convert_encoding')) { + // base64_encode and split cannot handle long JIS text to fold + $subject = '長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い件名'; + + $encodedWrapperLength = strlen('=?iso-2022-jp?'.$this->_encoder->getName().'??='); + + $old = mb_internal_encoding(); + mb_internal_encoding('utf-8'); + $newstring = mb_encode_mimeheader($subject, 'iso-2022-jp', 'B', "\r\n"); + mb_internal_encoding($old); + + $encoded = $this->_encoder->encodeString($subject, 0, 75 - $encodedWrapperLength, 'iso-2022-jp'); + $this->assertEquals( + $encoded, $newstring, + 'Encoded string should decode back to original string for sample ' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php new file mode 100644 index 000000000..8232fe63b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php @@ -0,0 +1,129 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_QpContentEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'), + new Swift_StreamFilters_ByteArrayReplacementFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ) + ); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testCharsetIsSetInHeader() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foobar', + $part->toString() + ); + } + + public function testFormatIsSetInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setFormat('flowed'); + $part->setBody('> foobar'); + $this->assertEquals( + 'Content-Type: text/plain; format=flowed'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + '> foobar', + $part->toString() + ); + } + + public function testDelSpIsSetInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setDelSp(true); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; delsp=yes'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foobar', + $part->toString() + ); + } + + public function testAll3ParamsInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setFormat('fixed'); + $part->setDelSp(true); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8; format=fixed; delsp=yes'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foobar', + $part->toString() + ); + } + + public function testBodyIsCanonicalized() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setBody("foobar\r\rtest\ning\r"); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + "foobar\r\n". + "\r\n". + "test\r\n". + "ing\r\n", + $part->toString() + ); + } + + // -- Private helpers + + protected function _createMimePart() + { + $entity = new Swift_Mime_MimePart( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php new file mode 100644 index 000000000..84f344301 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php @@ -0,0 +1,1251 @@ +setCharset(null); //TODO: Test with the charset defined + } + + public function testBasicHeaders() + { + /* -- RFC 2822, 3.6. + */ + + $message = $this->_createMessage(); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString(), + '%s: Only required headers, and non-empty headers should be displayed' + ); + } + + public function testSubjectIsDisplayedIfSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testDateCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $id = $message->getId(); + $message->setDate(1234); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', 1234)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMessageIdCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setId('foo@bar'); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: '."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testContentTypeCanBeChanged() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/html'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testCharsetCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $message->setCharset('iso-8859-1'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testFormatCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFormat('flowed'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain; format=flowed'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testEncoderCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $message->setEncoder( + new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit') + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/html'."\r\n". + 'Content-Transfer-Encoding: 7bit'."\r\n", + $message->toString() + ); + } + + public function testFromAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom('chris.corbyn@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: chris.corbyn@swiftmailer.org'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testFromAddressCanBeSetWithName() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMultipleFromAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org', + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn , mark@swiftmailer.org'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testReturnPathAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testEmptyReturnPathHeaderCanBeUsed() + { + $message = $this->_createMessage(); + $message->setReturnPath(''); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: <>'."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testSenderCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setSender('chris.corbyn@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Sender: chris.corbyn@swiftmailer.org'."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testSenderCanBeSetWithName() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setSender(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Sender: Chris '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testReplyToCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array('chris@w3style.co.uk' => 'Myself')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMultipleReplyAddressCanBeUsed() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testToAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo('mark@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMultipleToAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org, Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testCcAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $message->setCc('john@some-site.com'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org, Chris Corbyn '."\r\n". + 'Cc: john@some-site.com'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMultipleCcAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred', + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org, Chris Corbyn '."\r\n". + 'Cc: John West , Big Fred '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testBccAddressCanBeSet() + { + //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // separately in accordance with RFC 2822/2821 + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred', + )); + $message->setBcc('x@alphabet.tld'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org, Chris Corbyn '."\r\n". + 'Cc: John West , Big Fred '."\r\n". + 'Bcc: x@alphabet.tld'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testMultipleBccAddressesCanBeSet() + { + //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // separately in accordance with RFC 2822/2821 + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me', + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred', + )); + $message->setBcc(array('x@alphabet.tld', 'a@alphabet.tld' => 'A')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris '."\r\n". + 'Reply-To: Myself , Me '."\r\n". + 'To: mark@swiftmailer.org, Chris Corbyn '."\r\n". + 'Cc: John West , Big Fred '."\r\n". + 'Bcc: x@alphabet.tld, A '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString() + ); + } + + public function testStringBodyIsAppended() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setBody( + 'just a test body'."\r\n". + 'with a new line' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'just a test body'."\r\n". + 'with a new line', + $message->toString() + ); + } + + public function testStringBodyIsEncoded() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setBody( + 'Just s'.pack('C*', 0xC2, 0x01, 0x01).'me multi-'."\r\n". + 'line message!' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'Just s=C2=01=01me multi-'."\r\n". + 'line message!', + $message->toString() + ); + } + + public function testChildrenCanBeAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'test foo'. + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + public function testAttachmentsBeingAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $this->assertRegExp( + '~^'. + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() + ); + } + + public function testAttachmentsAndEmbeddedFilesBeingAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $message->attach($file); + + $cid = $file->getId(); + + $this->assertRegExp( + '~^'. + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\2'."\r\n". + 'Content-Type: image/jpeg; name=myimage.jpg'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=myimage.jpg'."\r\n". + 'Content-ID: <'.$cid.'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--\\2--'."\r\n". + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() + ); + } + + public function testComplexEmbeddingOfContent() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $part = $this->_createMimePart(); + $part->setContentType('text/html'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo '); + + $message->attach($part); + + $cid = $file->getId(); + + $this->assertRegExp( + '~^'. + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo './/=3D is just = in QP + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: image/jpeg; name=myimage.jpg'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=myimage.jpg'."\r\n". + 'Content-ID: <'.$cid.'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() + ); + } + + public function testAttachingAndDetachingContent() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $message->attach($file); + + $cid = $file->getId(); + + $message->detach($attachment); + + $this->assertRegExp( + '~^'. + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: image/jpeg; name=myimage.jpg'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=myimage.jpg'."\r\n". + 'Content-ID: <'.$cid.'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString(), + '%s: Attachment should have been detached' + ); + } + + public function testBoundaryDoesNotAppearAfterAllPartsAreDetached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $message->detach($part1); + $message->detach($part2); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n", + $message->toString(), + '%s: Message should be restored to orignal state after parts are detached' + ); + } + + public function testCharsetFormatOrDelSpAreNotShownWhenBoundaryIsSet() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setCharset('utf-8'); + $message->setFormat('flowed'); + $message->setDelSp(true); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'test foo'. + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + public function testBodyCanBeSetWithAttachments() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setContentType('text/html'); + $message->setCharset('iso-8859-1'); + $message->setBody('foo'); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=iso-8859-1'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: application/pdf; name=foo.pdf'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=foo.pdf'."\r\n". + "\r\n". + base64_encode(''). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + public function testHtmlPartAlwaysAppearsLast() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/html'); + $part1->setBody('foo'); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/plain'); + $part2->setBody('bar'); + + $message->attach($part1); + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'bar'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + public function testBodyBecomesPartIfOtherPartsAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setContentType('text/html'); + $message->setBody('foo'); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/plain'); + $part2->setBody('bar'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'bar'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'foo'. + "\r\n\r\n". + '--'.$boundary.'--'."\r\n", + $message->toString() + ); + } + + public function testBodyIsCanonicalized() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', )); + $message->setBody( + 'just a test body'."\n". + 'with a new line' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.date('r', $date)."\r\n". + 'Subject: just a test subject'."\r\n". + 'From: Chris Corbyn '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: text/plain'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'just a test body'."\r\n". + 'with a new line', + $message->toString() + ); + } + + // -- Private helpers + + protected function _createMessage() + { + return new Swift_Message(); + } + + protected function _createMimePart() + { + return new Swift_MimePart(); + } + + protected function _createAttachment() + { + return new Swift_Attachment(); + } + + protected function _createEmbeddedFile() + { + return new Swift_EmbeddedFile(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php new file mode 100644 index 000000000..f42405dfd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php @@ -0,0 +1,15 @@ +register('properties.charset')->asValue(null); + + return Swift_MimePart::newInstance(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php new file mode 100644 index 000000000..465f2c189 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php @@ -0,0 +1,134 @@ +markTestSkipped( + 'Will fail on travis-ci if not skipped due to travis blocking '. + 'socket mailing tcp connections.' + ); + } + + $this->_buffer = new Swift_Transport_StreamBuffer( + $this->getMock('Swift_ReplacementFilterFactory') + ); + } + + public function testReadLine() + { + $this->_initializeBuffer(); + + $line = $this->_buffer->readLine(0); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $seq = $this->_buffer->write("QUIT\r\n"); + $this->assertTrue((bool) $seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $this->_buffer->terminate(); + } + + public function testWrite() + { + $this->_initializeBuffer(); + + $line = $this->_buffer->readLine(0); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + + $seq = $this->_buffer->write("HELO foo\r\n"); + $this->assertTrue((bool) $seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + + $seq = $this->_buffer->write("QUIT\r\n"); + $this->assertTrue((bool) $seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $this->_buffer->terminate(); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->write('x'); + $this->_buffer->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->write('x'); + + $this->_buffer->unbind($is2); + + $this->_buffer->write('y'); + } + + // -- Creation Methods + + private function _createMockInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php new file mode 100644 index 000000000..8f6e453a5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php @@ -0,0 +1,34 @@ +markTestSkipped( + 'Cannot run test without an SMTP host to connect to (define '. + 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_SMTP_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tcp', + 'blocking' => 1, + 'timeout' => 15, + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php new file mode 100644 index 000000000..b4e88a7ab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php @@ -0,0 +1,27 @@ +markTestSkipped( + 'Cannot run test without a path to sendmail (define '. + 'SWIFT_SENDMAIL_PATH in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + parent::setUp(); + } + + protected function _initializeBuffer() + { + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, + 'command' => SWIFT_SENDMAIL_PATH.' -bs', + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php new file mode 100644 index 000000000..81db65eba --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php @@ -0,0 +1,65 @@ +markTestSkipped( + 'Cannot run test without an SMTP host to connect to (define '. + 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + $serverStarted = false; + for ($i = 0; $i < 5; ++$i) { + $this->_randomHighPort = rand(50000, 65000); + $this->_server = stream_socket_server('tcp://127.0.0.1:'.$this->_randomHighPort); + if ($this->_server) { + $serverStarted = true; + } + } + + $this->_buffer = new Swift_Transport_StreamBuffer( + $this->getMock('Swift_ReplacementFilterFactory') + ); + } + + protected function _initializeBuffer() + { + $host = '127.0.0.1'; + $port = $this->_randomHighPort; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tcp', + 'blocking' => 1, + 'timeout' => 1, + )); + } + + public function testTimeoutException() + { + $this->_initializeBuffer(); + $e = null; + try { + $line = $this->_buffer->readLine(0); + } catch (Exception $e) { + } + $this->assertInstanceof('Swift_IoException', $e, 'IO Exception Not Thrown On Connection Timeout'); + $this->assertRegExp('/Connection to .* Timed Out/', $e->getMessage()); + } + + public function tearDown() + { + if ($this->_server) { + stream_socket_shutdown($this->_server, STREAM_SHUT_RDWR); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php new file mode 100644 index 000000000..d2d2a38eb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php @@ -0,0 +1,41 @@ +markTestSkipped( + 'SSL is not configured for your system. It is not possible to run this test' + ); + } + if (!defined('SWIFT_SSL_HOST')) { + $this->markTestSkipped( + 'Cannot run test without an SSL enabled SMTP host to connect to (define '. + 'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_SSL_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'ssl', + 'blocking' => 1, + 'timeout' => 15, + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php new file mode 100644 index 000000000..314fffe25 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php @@ -0,0 +1,40 @@ +markTestSkipped( + 'TLS is not configured for your system. It is not possible to run this test' + ); + } + if (!defined('SWIFT_TLS_HOST')) { + $this->markTestSkipped( + 'Cannot run test without a TLS enabled SMTP host to connect to (define '. + 'SWIFT_TLS_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_TLS_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tls', + 'blocking' => 1, + 'timeout' => 15, + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bootstrap.php b/vendor/swiftmailer/swiftmailer/tests/bootstrap.php new file mode 100644 index 000000000..9b169b3e4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bootstrap.php @@ -0,0 +1,19 @@ +add('Swift_', __DIR__.'/unit'); + +set_include_path(get_include_path().PATH_SEPARATOR.dirname(__DIR__).'/lib'); + +\Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + +if (is_file(__DIR__.'/acceptance.conf.php')) { + require_once __DIR__.'/acceptance.conf.php'; +} +if (is_file(__DIR__.'/smoke.conf.php')) { + require_once __DIR__.'/smoke.conf.php'; +} +require_once __DIR__.'/StreamCollector.php'; +require_once __DIR__.'/IdenticalBinaryConstraint.php'; +require_once __DIR__.'/SwiftMailerTestCase.php'; +require_once __DIR__.'/SwiftMailerSmokeTestCase.php'; diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php new file mode 100644 index 000000000..ba29ba87a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php @@ -0,0 +1,42 @@ + array( + 'email1@example.com', + 'email2@example.com', + 'email3@example.com', + 'email4@example.com', + 'email5@example.com', + ), + 'sub' => array( + '-name-' => array( + 'email1', + '"email2"', + 'email3\\', + 'email4', + 'email5', + ), + '-url-' => array( + 'http://google.com', + 'http://yahoo.com', + 'http://hotmail.com', + 'http://aol.com', + 'http://facebook.com', + ), + ), + ); + $json = json_encode($complicated_header); + + $message = new Swift_Message(); + $headers = $message->getHeaders(); + $headers->addTextHeader('X-SMTPAPI', $json); + $header = $headers->get('X-SMTPAPI'); + + $this->assertEquals('Swift_Mime_Headers_UnstructuredHeader', get_class($header)); + $this->assertEquals($json, $header->getFieldBody()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php new file mode 100644 index 000000000..bd10c7163 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php @@ -0,0 +1,20 @@ +_message = new Swift_Message(); + } + + public function testCallingGenerateIdChangesTheMessageId() + { + $currentId = $this->_message->getId(); + $this->_message->generateId(); + $newId = $this->_message->getId(); + + $this->assertNotEquals($currentId, $newId); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php new file mode 100644 index 000000000..fdfa5302c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php @@ -0,0 +1,38 @@ +_factory = new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar); + } + + public function testMailboxHeaderEncoding() + { + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Name, Name', ' "Family Name, Name" '); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé, Name', ' Family =?utf-8?Q?Nam=C3=A9=2C?= Name'); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé , Name', ' Family =?utf-8?Q?Nam=C3=A9_=2C?= Name'); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé ;Name', ' Family =?utf-8?Q?Nam=C3=A9_=3BName?= '); + } + + private function _testHeaderIsFullyEncoded($email, $name, $expected) + { + $mailboxHeader = $this->_factory->createMailboxHeader('To', array( + $email => $name, + )); + + $headerBody = substr($mailboxHeader->toString(), 3, strlen($expected)); + + $this->assertEquals($expected, $headerBody); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php new file mode 100644 index 000000000..d305d02e1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php @@ -0,0 +1,21 @@ +setExpectedException('Swift_IoException', 'The path cannot be empty'); + $message->attach(Swift_Attachment::fromPath('')); + } + + public function testNonEmptyFileNameAsAttachement() + { + $message = new Swift_Message(); + try { + $message->attach(Swift_Attachment::fromPath(__FILE__)); + } catch (Exception $e) { + $this->fail('Path should not be empty'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php new file mode 100644 index 000000000..6a0f33d5b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php @@ -0,0 +1,75 @@ +setCharset('utf-8'); + } + + public function testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative() + { + $message = Swift_Message::newInstance(); + $message->setCharset('utf-8'); + $message->setSubject('test subject'); + $message->addPart('plain part', 'text/plain'); + + $image = Swift_Image::newInstance('', 'image.gif', 'image/gif'); + $cid = $message->embed($image); + + $message->setBody('', 'text/html'); + + $message->setTo(array('user@domain.tld' => 'User')); + + $message->setFrom(array('other@domain.tld' => 'Other')); + $message->setSender(array('other@domain.tld' => 'Other')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $cidVal = $image->getId(); + + $this->assertRegExp( + '~^'. + 'Sender: Other '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: Other '."\r\n". + 'To: User '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'plain part'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + ''. + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=image.gif'."\r\n". + 'Content-ID: <'.$cidVal.'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php new file mode 100644 index 000000000..e07ee8f0b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php @@ -0,0 +1,73 @@ +setCharset('utf-8'); + } + + public function testHTMLPartAppearsLastEvenWhenAttachmentsAdded() + { + $message = Swift_Message::newInstance(); + $message->setCharset('utf-8'); + $message->setSubject('test subject'); + $message->addPart('plain part', 'text/plain'); + + $attachment = Swift_Attachment::newInstance('', 'image.gif', 'image/gif'); + $message->attach($attachment); + + $message->setBody('HTML part', 'text/html'); + + $message->setTo(array('user@domain.tld' => 'User')); + + $message->setFrom(array('other@domain.tld' => 'Other')); + $message->setSender(array('other@domain.tld' => 'Other')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $this->assertRegExp( + '~^'. + 'Sender: Other '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: Other '."\r\n". + 'To: User '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'plain part'. + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'HTML part'. + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=image.gif'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php new file mode 100644 index 000000000..e28151688 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php @@ -0,0 +1,194 @@ +_attFileName = 'data.txt'; + $this->_attFileType = 'text/plain'; + $this->_attFile = __DIR__.'/../../_samples/files/data.txt'; + Swift_Preferences::getInstance()->setCharset('utf-8'); + } + + public function testWritingMessageToByteStreamProducesCorrectStructure() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $image = new Swift_Image('', 'image.gif', 'image/gif'); + + $cid = $message->embed($image); + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $imgId = $image->getId(); + + $stream = new Swift_ByteStream_ArrayByteStream(); + + $message->toByteStream($stream); + + $this->assertPatternInStream( + '~^'. + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: user@domain.tld'."\r\n". + 'To: user@domain.tld'."\r\n". + 'Cc: other@domain.tld'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'HTML part'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=image.gif'."\r\n". + 'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $stream + ); + } + + public function testWritingMessageToByteStreamTwiceProducesCorrectStructure() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $image = new Swift_Image('', 'image.gif', 'image/gif'); + + $cid = $message->embed($image); + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $imgId = $image->getId(); + + $pattern = '~^'. + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: user@domain.tld'."\r\n". + 'To: user@domain.tld'."\r\n". + 'Cc: other@domain.tld'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'HTML part'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: inline; filename=image.gif'."\r\n". + 'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D' + ; + + $streamA = new Swift_ByteStream_ArrayByteStream(); + $streamB = new Swift_ByteStream_ArrayByteStream(); + + $message->toByteStream($streamA); + $message->toByteStream($streamB); + + $this->assertPatternInStream($pattern, $streamA); + $this->assertPatternInStream($pattern, $streamB); + } + + public function testWritingMessageToByteStreamTwiceUsingAFileAttachment() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $attachment = Swift_Attachment::fromPath($this->_attFile); + + $message->attach($attachment); + + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $streamA = new Swift_ByteStream_ArrayByteStream(); + $streamB = new Swift_ByteStream_ArrayByteStream(); + + $pattern = '~^'. + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: user@domain.tld'."\r\n". + 'To: user@domain.tld'."\r\n". + 'Cc: other@domain.tld'."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'HTML part'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: '.$this->_attFileType.'; name='.$this->_attFileName."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename='.$this->_attFileName."\r\n". + "\r\n". + preg_quote(base64_encode(file_get_contents($this->_attFile)), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D' + ; + + $message->toByteStream($streamA); + $message->toByteStream($streamB); + + $this->assertPatternInStream($pattern, $streamA); + $this->assertPatternInStream($pattern, $streamB); + } + + // -- Helpers + + public function assertPatternInStream($pattern, $stream, $message = '%s') + { + $string = ''; + while (false !== $bytes = $stream->read(8192)) { + $string .= $bytes; + } + $this->assertRegExp($pattern, $string, $message); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php new file mode 100644 index 000000000..b83984fec --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php @@ -0,0 +1,38 @@ +setTo('foo@bar.com'); + + $that = $this; + $messageValidation = function ($m) use ($that) { + //the getTo should return the same value as we put in + $that->assertEquals('foo@bar.com', key($m->getTo()), 'The message has changed after it was put to the memory queue'); + + return true; + }; + + $transport = m::mock('Swift_Transport'); + $transport->shouldReceive('isStarted')->andReturn(true); + $transport->shouldReceive('send') + ->with(m::on($messageValidation), $failedRecipients) + ->andReturn(1); + + $memorySpool = new Swift_MemorySpool(); + $memorySpool->queueMessage($message); + + /* + * The message is queued in memory. + * Lets change the message + */ + $message->setTo('other@value.com'); + + $memorySpool->flushQueue($transport, $failedRecipients); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php new file mode 100644 index 000000000..b9c33b09d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php @@ -0,0 +1,121 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use ('. + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_attachmentFile = SWIFT_TMP_DIR.'/attach.rand.bin'; + file_put_contents($this->_attachmentFile, ''); + + $this->_outputFile = SWIFT_TMP_DIR.'/attach.out.bin'; + file_put_contents($this->_outputFile, ''); + } + + public function tearDown() + { + unlink($this->_attachmentFile); + unlink($this->_outputFile); + } + + public function testAttachmentsDoNotGetTruncatedUsingToByteStream() + { + //Run 100 times with 10KB attachments + for ($i = 0; $i < 10; ++$i) { + $message = $this->_createMessageWithRandomAttachment( + 10000, $this->_attachmentFile + ); + + file_put_contents($this->_outputFile, ''); + $message->toByteStream( + new Swift_ByteStream_FileByteStream($this->_outputFile, true) + ); + + $emailSource = file_get_contents($this->_outputFile); + + $this->assertAttachmentFromSourceMatches( + file_get_contents($this->_attachmentFile), + $emailSource + ); + } + } + + public function testAttachmentsDoNotGetTruncatedUsingToString() + { + //Run 100 times with 10KB attachments + for ($i = 0; $i < 10; ++$i) { + $message = $this->_createMessageWithRandomAttachment( + 10000, $this->_attachmentFile + ); + + $emailSource = $message->toString(); + + $this->assertAttachmentFromSourceMatches( + file_get_contents($this->_attachmentFile), + $emailSource + ); + } + } + + // -- Custom Assertions + + public function assertAttachmentFromSourceMatches($attachmentData, $source) + { + $encHeader = 'Content-Transfer-Encoding: base64'; + $base64declaration = strpos($source, $encHeader); + + $attachmentDataStart = strpos($source, "\r\n\r\n", $base64declaration); + $attachmentDataEnd = strpos($source, "\r\n--", $attachmentDataStart); + + if (false === $attachmentDataEnd) { + $attachmentBase64 = trim(substr($source, $attachmentDataStart)); + } else { + $attachmentBase64 = trim(substr( + $source, $attachmentDataStart, + $attachmentDataEnd - $attachmentDataStart + )); + } + + $this->assertIdenticalBinary($attachmentData, base64_decode($attachmentBase64)); + } + + // -- Creation Methods + + private function _fillFileWithRandomBytes($byteCount, $file) + { + // I was going to use dd with if=/dev/random but this way seems more + // cross platform even if a hella expensive!! + + file_put_contents($file, ''); + $fp = fopen($file, 'wb'); + for ($i = 0; $i < $byteCount; ++$i) { + $byteVal = rand(0, 255); + fwrite($fp, pack('i', $byteVal)); + } + fclose($fp); + } + + private function _createMessageWithRandomAttachment($size, $attachmentPath) + { + $this->_fillFileWithRandomBytes($size, $attachmentPath); + + $message = Swift_Message::newInstance() + ->setSubject('test') + ->setBody('test') + ->setFrom('a@b.c') + ->setTo('d@e.f') + ->attach(Swift_Attachment::fromPath($attachmentPath)) + ; + + return $message; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php new file mode 100644 index 000000000..263cae51a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php @@ -0,0 +1,38 @@ +setFrom('from@example.com') + ->setTo('to@example.com') + ->setSubject('test') + ; + $cid = $message->embed(Swift_Image::fromPath(__DIR__.'/../../_samples/files/swiftmailer.png')); + $message->setBody('', 'text/html'); + + $that = $this; + $messageValidation = function (Swift_Mime_Message $message) use ($that) { + preg_match('/cid:(.*)"/', $message->toString(), $matches); + $cid = $matches[1]; + preg_match('/Content-ID: <(.*)>/', $message->toString(), $matches); + $contentId = $matches[1]; + $that->assertEquals($cid, $contentId, 'cid in body and mime part Content-ID differ'); + + return true; + }; + + $failedRecipients = array(); + + $transport = m::mock('Swift_Transport'); + $transport->shouldReceive('isStarted')->andReturn(true); + $transport->shouldReceive('send')->with(m::on($messageValidation), $failedRecipients)->andReturn(1); + + $memorySpool = new Swift_MemorySpool(); + $memorySpool->queueMessage($message); + $memorySpool->flushQueue($transport, $failedRecipients); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php new file mode 100644 index 000000000..4b8045370 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php @@ -0,0 +1,20 @@ +_message = new Swift_Message('test'); + } + + public function testCallingToStringAfterSettingNewBodyReflectsChanges() + { + $this->_message->setBody('BODY1'); + $this->assertRegExp('/BODY1/', $this->_message->toString()); + + $this->_message->setBody('BODY2'); + $this->assertRegExp('/BODY2/', $this->_message->toString()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php new file mode 100644 index 000000000..c2b12cb4c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php @@ -0,0 +1,82 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use ('. + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_inputFile = SWIFT_TMP_DIR.'/in.bin'; + file_put_contents($this->_inputFile, ''); + + $this->_outputFile = SWIFT_TMP_DIR.'/out.bin'; + file_put_contents($this->_outputFile, ''); + + $this->_encoder = $this->_createEncoder(); + } + + public function tearDown() + { + unlink($this->_inputFile); + unlink($this->_outputFile); + } + + public function testBase64EncodedLineLengthNeverExceeds76CharactersEvenIfArgsDo() + { + $this->_fillFileWithRandomBytes(1000, $this->_inputFile); + + $os = $this->_createStream($this->_inputFile); + $is = $this->_createStream($this->_outputFile); + + $this->_encoder->encodeByteStream($os, $is, 0, 80); //Exceeds 76 + + $this->assertMaxLineLength(76, $this->_outputFile, + '%s: Line length should not exceed 76 characters' + ); + } + + // -- Custom Assertions + + public function assertMaxLineLength($length, $filePath, $message = '%s') + { + $lines = file($filePath); + foreach ($lines as $line) { + $this->assertTrue((strlen(trim($line)) <= 76), $message); + } + } + + // -- Creation Methods + + private function _fillFileWithRandomBytes($byteCount, $file) + { + // I was going to use dd with if=/dev/random but this way seems more + // cross platform even if a hella expensive!! + + file_put_contents($file, ''); + $fp = fopen($file, 'wb'); + for ($i = 0; $i < $byteCount; ++$i) { + $byteVal = rand(0, 255); + fwrite($fp, pack('i', $byteVal)); + } + fclose($fp); + } + + private function _createEncoder() + { + return new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + private function _createStream($file) + { + return new Swift_ByteStream_FileByteStream($file, true); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php b/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php new file mode 100644 index 000000000..d56d88d3b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php @@ -0,0 +1,10 @@ +level = $level; + $this->string = $string; + $this->contentType = $contentType; + } + + public function getNestingLevel() + { + return $this->level; + } + + public function toString() + { + return $this->string; + } + + public function getContentType() + { + return $this->contentType; + } + + // These methods are here to account for the implemented interfaces + public function getId() + { + } + public function getHeaders() + { + } + public function getBody() + { + } + public function setBody($body, $contentType = null) + { + } + public function toByteStream(Swift_InputByteStream $is) + { + } + public function charsetChanged($charset) + { + } + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) + { + } + public function getChildren() + { + } + public function setChildren(array $children) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default b/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default new file mode 100644 index 000000000..0de2763fa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default @@ -0,0 +1,63 @@ +_attFile = __DIR__.'/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance() + ->setSubject('[Swift Mailer] AttachmentSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('This message should contain an attached ZIP file (named "textfile.zip").'.PHP_EOL. + 'When unzipped, the archive should produce a text file which reads:'.PHP_EOL. + '"This is part of a Swift Mailer v4 smoke test."' + ) + ->attach(Swift_Attachment::fromPath($this->_attFile)) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php new file mode 100644 index 000000000..c7501d46e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php @@ -0,0 +1,23 @@ +_getMailer(); + $message = Swift_Message::newInstance() + ->setSubject('[Swift Mailer] BasicSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('One, two, three, four, five...'.PHP_EOL. + 'six, seven, eight...' + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php new file mode 100644 index 000000000..a589752bc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php @@ -0,0 +1,29 @@ +_attFile = __DIR__.'/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance('[Swift Mailer] HtmlWithAttachmentSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->attach(Swift_Attachment::fromPath($this->_attFile)) + ->setBody('

This HTML-formatted message should contain an attached ZIP file (named "textfile.zip").'.PHP_EOL. + 'When unzipped, the archive should produce a text file which reads:

'.PHP_EOL. + '

This is part of a Swift Mailer v4 smoke test.

', 'text/html' + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php new file mode 100644 index 000000000..e7c695e42 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php @@ -0,0 +1,37 @@ +_attFile = __DIR__.'/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance() + ->setCharset('utf-8') + ->setSubject('[Swift Mailer] InternationalSmokeTest (διεθνής)') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Χριστοφορου (Swift Mailer)')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('This message should contain an attached ZIP file (named "κείμενο, εδάφιο, θέμα.zip").'.PHP_EOL. + 'When unzipped, the archive should produce a text file which reads:'.PHP_EOL. + '"This is part of a Swift Mailer v4 smoke test."'.PHP_EOL. + PHP_EOL. + 'Following is some arbitrary Greek text:'.PHP_EOL. + 'Δεν βρέθηκαν λέξεις.' + ) + ->attach(Swift_Attachment::fromPath($this->_attFile) + ->setContentType('application/zip') + ->setFilename('κείμενο, εδάφιο, θέμα.zip') + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php new file mode 100644 index 000000000..01934849f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php @@ -0,0 +1,204 @@ +_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals($input, $output, + '%s: Bytes read from stream should be the same as bytes in constructor' + ); + } + + public function testReadingMultipleBytesFromBaseInput() + { + $input = array('a', 'b', 'c', 'd'); + $bs = $this->_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(2)) { + $output[] = $bytes; + } + $this->assertEquals(array('ab', 'cd'), $output, + '%s: Bytes read from stream should be in pairs' + ); + } + + public function testReadingOddOffsetOnLastByte() + { + $input = array('a', 'b', 'c', 'd', 'e'); + $bs = $this->_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(2)) { + $output[] = $bytes; + } + $this->assertEquals(array('ab', 'cd', 'e'), $output, + '%s: Bytes read from stream should be in pairs except final read' + ); + } + + public function testSettingPointerPartway() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + $bs->setReadPointer(1); + $this->assertEquals('b', $bs->read(1), + '%s: Byte should be second byte since pointer as at offset 1' + ); + } + + public function testResettingPointerAfterExhaustion() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + while (false !== $bs->read(1)); + + $bs->setReadPointer(0); + $this->assertEquals('a', $bs->read(1), + '%s: Byte should be first byte since pointer as at offset 0' + ); + } + + public function testPointerNeverSetsBelowZero() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->setReadPointer(-1); + $this->assertEquals('a', $bs->read(1), + '%s: Byte should be first byte since pointer should be at offset 0' + ); + } + + public function testPointerNeverSetsAboveStackSize() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->setReadPointer(3); + $this->assertSame(false, $bs->read(1), + '%s: Stream should be at end and thus return false' + ); + } + + public function testBytesCanBeWrittenToStream() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->write('de'); + + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals(array('a', 'b', 'c', 'd', 'e'), $output, + '%s: Bytes read from stream should be from initial stack + written' + ); + } + + public function testContentsCanBeFlushed() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->flushBuffers(); + + $this->assertSame(false, $bs->read(1), + '%s: Contents have been flushed so read() should return false' + ); + } + + public function testConstructorCanTakeStringArgument() + { + $bs = $this->_createArrayStream('abc'); + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals(array('a', 'b', 'c'), $output, + '%s: Bytes read from stream should be the same as bytes in constructor' + ); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->write('x'); + $bs->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->write('x'); + + $bs->unbind($is2); + + $bs->write('y'); + } + + // -- Creation Methods + + private function _createArrayStream($input) + { + return new Swift_ByteStream_ArrayByteStream($input); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php new file mode 100644 index 000000000..3f7a46cf5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php @@ -0,0 +1,43 @@ +assertSame(1, $reader->getInitialByteSize()); + + $reader = new Swift_CharacterReader_GenericFixedWidthReader(4); + $this->assertSame(4, $reader->getInitialByteSize()); + } + + public function testValidationValueIsBasedOnOctetCount() + { + $reader = new Swift_CharacterReader_GenericFixedWidthReader(4); + + $this->assertSame( + 1, $reader->validateByteSequence(array(0x01, 0x02, 0x03), 3) + ); //3 octets + + $this->assertSame( + 2, $reader->validateByteSequence(array(0x01, 0x0A), 2) + ); //2 octets + + $this->assertSame( + 3, $reader->validateByteSequence(array(0xFE), 1) + ); //1 octet + + $this->assertSame( + 0, $reader->validateByteSequence(array(0xFE, 0x03, 0x67, 0x9A), 4) + ); //All 4 octets + } + + public function testValidationFailsIfTooManyOctets() + { + $reader = new Swift_CharacterReader_GenericFixedWidthReader(6); + + $this->assertSame(-1, $reader->validateByteSequence( + array(0xFE, 0x03, 0x67, 0x9A, 0x10, 0x09, 0x85), 7 + )); //7 octets + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php new file mode 100644 index 000000000..41f8f7035 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php @@ -0,0 +1,52 @@ +read($size); ) { + $c .= $bytes; + $size = $v->validateCharacter($c); + if (-1 == $size) { + throw new Exception( ... invalid char .. ); + } elseif (0 == $size) { + return $c; //next character in $os + } + } + + */ + + private $_reader; + + public function setUp() + { + $this->_reader = new Swift_CharacterReader_UsAsciiReader(); + } + + public function testAllValidAsciiCharactersReturnZero() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) { + $this->assertSame( + 0, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } + + public function testMultipleBytesAreInvalid() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; $ordinal += 2) { + $this->assertSame( + -1, $this->_reader->validateByteSequence(array($ordinal, $ordinal + 1), 2) + ); + } + } + + public function testBytesAboveAsciiRangeAreInvalid() + { + for ($ordinal = 0x80; $ordinal <= 0xFF; ++$ordinal) { + $this->assertSame( + -1, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php new file mode 100644 index 000000000..34e9c91de --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php @@ -0,0 +1,65 @@ +_reader = new Swift_CharacterReader_Utf8Reader(); + } + + public function testLeading7BitOctetCausesReturnZero() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) { + $this->assertSame( + 0, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } + + public function testLeadingByteOf2OctetCharCausesReturn1() + { + for ($octet = 0xC0; $octet <= 0xDF; ++$octet) { + $this->assertSame( + 1, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf3OctetCharCausesReturn2() + { + for ($octet = 0xE0; $octet <= 0xEF; ++$octet) { + $this->assertSame( + 2, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf4OctetCharCausesReturn3() + { + for ($octet = 0xF0; $octet <= 0xF7; ++$octet) { + $this->assertSame( + 3, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf5OctetCharCausesReturn4() + { + for ($octet = 0xF8; $octet <= 0xFB; ++$octet) { + $this->assertSame( + 4, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf6OctetCharCausesReturn5() + { + for ($octet = 0xFC; $octet <= 0xFD; ++$octet) { + $this->assertSame( + 5, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php new file mode 100644 index 000000000..e22e496f9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php @@ -0,0 +1,360 @@ +_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', + 0xD0, 0x94, + 0xD0, 0xB6, + 0xD0, 0xBE, + 0xD1, 0x8D, + 0xD0, 0xBB, + 0xD0, 0xB0 + ) + ); + } + + public function testCharactersWrittenUseValidator() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + } + + public function testReadCharactersAreInTact() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + //String + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + //Stream + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + $this->assertIdenticalBinary( + pack('C*', 0xD0, 0xB6, 0xD0, 0xBE), $stream->read(2) + ); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBB), $stream->read(1)); + $this->assertIdenticalBinary( + pack('C*', 0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->read(3) + ); + $this->assertIdenticalBinary(pack('C*', 0xD1, 0x85), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + public function testCharactersCanBeReadAsByteArrays() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + //String + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + //Stream + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + + $this->assertEquals(array(0xD0, 0x94), $stream->readBytes(1)); + $this->assertEquals(array(0xD0, 0xB6, 0xD0, 0xBE), $stream->readBytes(2)); + $this->assertEquals(array(0xD0, 0xBB), $stream->readBytes(1)); + $this->assertEquals( + array(0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->readBytes(3) + ); + $this->assertEquals(array(0xD1, 0x85), $stream->readBytes(1)); + + $this->assertSame(false, $stream->readBytes(1)); + } + + public function testRequestingLargeCharCountPastEndOfStream() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE), + $stream->read(100) + ); + + $this->assertSame(false, $stream->read(1)); + } + + public function testRequestingByteArrayCountPastEndOfStream() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertEquals(array(0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE), + $stream->readBytes(100) + ); + + $this->assertSame(false, $stream->readBytes(1)); + } + + public function testPointerOffsetCanBeSet() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + + $stream->setPointer(0); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + + $stream->setPointer(2); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBE), $stream->read(1)); + } + + public function testContentsCanBeFlushed() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->flushContents(); + + $this->assertSame(false, $stream->read(1)); + } + + public function testByteStreamCanBeImportingUsesValidator() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + $os = $this->_getByteStream(); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $os->shouldReceive('setReadPointer') + ->between(0, 1) + ->with(0); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0x94)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xB6)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xBE)); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importByteStream($os); + } + + public function testImportingStreamProducesCorrectCharArray() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + $os = $this->_getByteStream(); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $os->shouldReceive('setReadPointer') + ->between(0, 1) + ->with(0); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0x94)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xB6)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xBE)); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importByteStream($os); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xB6), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBE), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + public function testAlgorithmWithFixedWidthCharsets() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1, 0x8D), 2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0, 0xBB), 2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0, 0xB0), 2); + + $stream = new Swift_CharacterStream_ArrayCharacterStream( + $factory, 'utf-8' + ); + $stream->importString(pack('C*', 0xD1, 0x8D, 0xD0, 0xBB, 0xD0, 0xB0)); + + $this->assertIdenticalBinary(pack('C*', 0xD1, 0x8D), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBB), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xB0), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + // -- Creation methods + + private function _getReader() + { + return $this->getMockery('Swift_CharacterReader'); + } + + private function _getFactory($reader) + { + $factory = $this->getMockery('Swift_CharacterReaderFactory'); + $factory->shouldReceive('getReaderFor') + ->zeroOrMoreTimes() + ->with('utf-8') + ->andReturn($reader); + + return $factory; + } + + private function _getByteStream() + { + return $this->getMockery('Swift_OutputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php new file mode 100644 index 000000000..bc4a79bcb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php @@ -0,0 +1,174 @@ +arg1 = $arg1; + $this->arg2 = $arg2; + } +} + +class Swift_DependencyContainerTest extends \PHPUnit_Framework_TestCase +{ + private $_container; + + public function setUp() + { + $this->_container = new Swift_DependencyContainer(); + } + + public function testRegisterAndLookupValue() + { + $this->_container->register('foo')->asValue('bar'); + $this->assertEquals('bar', $this->_container->lookup('foo')); + } + + public function testHasReturnsTrueForRegisteredValue() + { + $this->_container->register('foo')->asValue('bar'); + $this->assertTrue($this->_container->has('foo')); + } + + public function testHasReturnsFalseForUnregisteredValue() + { + $this->assertFalse($this->_container->has('foo')); + } + + public function testRegisterAndLookupNewInstance() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $this->assertInstanceof('One', $this->_container->lookup('one')); + } + + public function testHasReturnsTrueForRegisteredInstance() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $this->assertTrue($this->_container->has('one')); + } + + public function testNewInstanceIsAlwaysNew() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $a = $this->_container->lookup('one'); + $b = $this->_container->lookup('one'); + $this->assertEquals($a, $b); + } + + public function testRegisterAndLookupSharedInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $this->assertInstanceof('One', $this->_container->lookup('one')); + } + + public function testHasReturnsTrueForSharedInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $this->assertTrue($this->_container->has('one')); + } + + public function testMultipleSharedInstancesAreSameInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $a = $this->_container->lookup('one'); + $b = $this->_container->lookup('one'); + $this->assertEquals($a, $b); + } + + public function testNewInstanceWithDependencies() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One') + ->withDependencies(array('foo')); + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + } + + public function testNewInstanceWithMultipleDependencies() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asValue(42); + $this->_container->register('one')->asNewInstanceOf('One') + ->withDependencies(array('foo', 'bar')); + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + $this->assertSame(42, $obj->arg2); + } + + public function testNewInstanceWithInjectedObjects() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array('one', 'foo')); + $obj = $this->_container->lookup('two'); + $this->assertEquals($this->_container->lookup('one'), $obj->arg1); + $this->assertSame('FOO', $obj->arg2); + } + + public function testNewInstanceWithAddConstructorValue() + { + $this->_container->register('one')->asNewInstanceOf('One') + ->addConstructorValue('x') + ->addConstructorValue(99); + $obj = $this->_container->lookup('one'); + $this->assertSame('x', $obj->arg1); + $this->assertSame(99, $obj->arg2); + } + + public function testNewInstanceWithAddConstructorLookup() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asValue(42); + $this->_container->register('one')->asNewInstanceOf('One') + ->addConstructorLookup('foo') + ->addConstructorLookup('bar'); + + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + $this->assertSame(42, $obj->arg2); + } + + public function testResolvedDependenciesCanBeLookedUp() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array('one', 'foo')); + $deps = $this->_container->createDependenciesFor('two'); + $this->assertEquals( + array($this->_container->lookup('one'), 'FOO'), $deps + ); + } + + public function testArrayOfDependenciesCanBeSpecified() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array(array('one', 'foo'), 'foo')); + + $obj = $this->_container->lookup('two'); + $this->assertEquals(array($this->_container->lookup('one'), 'FOO'), $obj->arg1); + $this->assertSame('FOO', $obj->arg2); + } + + public function testAliasCanBeSet() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asAliasOf('foo'); + + $this->assertSame('FOO', $this->_container->lookup('bar')); + } + + public function testAliasOfAliasCanBeSet() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asAliasOf('foo'); + $this->_container->register('zip')->asAliasOf('bar'); + $this->_container->register('button')->asAliasOf('zip'); + + $this->assertSame('FOO', $this->_container->lookup('button')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php new file mode 100644 index 000000000..1e712fe52 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php @@ -0,0 +1,173 @@ +_encoder = new Swift_Encoder_Base64Encoder(); + } + + /* + There's really no point in testing the entire base64 encoding to the + level QP encoding has been tested. base64_encode() has been in PHP for + years. + */ + + public function testInputOutputRatioIs3to4Bytes() + { + /* + RFC 2045, 6.8 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + */ + + $this->assertEquals( + 'MTIz', $this->_encoder->encodeString('123'), + '%s: 3 bytes of input should yield 4 bytes of output' + ); + $this->assertEquals( + 'MTIzNDU2', $this->_encoder->encodeString('123456'), + '%s: 6 bytes in input should yield 8 bytes of output' + ); + $this->assertEquals( + 'MTIzNDU2Nzg5', $this->_encoder->encodeString('123456789'), + '%s: 9 bytes in input should yield 12 bytes of output' + ); + } + + public function testPadLength() + { + /* + RFC 2045, 6.8 + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the "=" character. Since all base64 + input is an integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C', rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{2}==$~', $this->_encoder->encodeString($input), + '%s: A single byte should have 2 bytes of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C*', rand(0, 255), rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{3}=$~', $this->_encoder->encodeString($input), + '%s: Two bytes should have 1 byte of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C*', rand(0, 255), rand(0, 255), rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{4}$~', $this->_encoder->encodeString($input), + '%s: Three bytes should have no padding' + ); + } + } + + public function testMaximumLineLengthIs76Characters() + { + /* + The encoded output stream must be represented in lines of no more + than 76 characters each. All line breaks or other characters not + found in Table 1 must be ignored by decoding software. + */ + + $input = + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 + 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1'."\r\n".//76 * + 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3'.//38 + 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla'."\r\n".//76 * + 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl'.//38 + 'NUVVZXWFla'; //48 + + $this->assertEquals( + $output, $this->_encoder->encodeString($input), + '%s: Lines should be no more than 76 characters' + ); + } + + public function testMaximumLineLengthCanBeSpecified() + { + $input = + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 + 'NERUZHSElKS0'."\r\n".//50 * + 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk'.//38 + 'ZWZnaGlqa2xt'."\r\n".//50 * + 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1'.//38 + 'BRUlNUVVZXWF'."\r\n".//50 * + 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR'.//38 + 'UlNUVVZXWFla'; //50 * + + $this->assertEquals( + $output, $this->_encoder->encodeString($input, 0, 50), + '%s: Lines should be no more than 100 characters' + ); + } + + public function testFirstLineLengthCanBeDifferent() + { + $input = + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. + '1234567890'. + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 + 'NERUZHSElKS0xNTk9QU'."\r\n".//57 * + 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl'.//38 + 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT'."\r\n".//76 * + 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R'.//38 + 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; //67 + + $this->assertEquals( + $output, $this->_encoder->encodeString($input, 19), + '%s: First line offset is 19 so first line should be 57 chars long' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php new file mode 100644 index 000000000..adf485d7a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php @@ -0,0 +1,381 @@ +_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertIdenticalBinary($char, $encoder->encodeString($char)); + } + } + + public function testWhiteSpaceAtLineEndingIsEncoded() + { + /* -- RFC 2045, 6.7 -- + (3) (White Space) Octets with values of 9 and 32 MAY be + represented as US-ASCII TAB (HT) and SPACE characters, + respectively, but MUST NOT be so represented at the end + of an encoded line. Any TAB (HT) or SPACE characters + on an encoded line MUST thus be followed on that line + by a printable character. In particular, an "=" at the + end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE + characters. It follows that an octet with decimal + value 9 or 32 appearing at the end of an encoded line + must be represented according to Rule #1. This rule is + necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to + another, or perform a portion of such transfers) are + known to pad lines of text with SPACEs, and others are + known to remove "white space" characters from the end + of a line. Therefore, when decoding a Quoted-Printable + body, any trailing white space on a line must be + deleted, as it will necessarily have been added by + intermediate transport agents. + */ + + $HT = chr(0x09); //9 + $SPACE = chr(0x20); //32 + + //HT + $string = 'a'.$HT.$HT."\r\n".'b'; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + 'a'.$HT.'=09'."\r\n".'b', + $encoder->encodeString($string) + ); + + //SPACE + $string = 'a'.$SPACE.$SPACE."\r\n".'b'; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + 'a'.$SPACE.'=20'."\r\n".'b', + $encoder->encodeString($string) + ); + } + + public function testCRLFIsLeftAlone() + { + /* + (4) (Line Breaks) A line break in a text body, represented + as a CRLF sequence in the text canonical form, must be + represented by a (RFC 822) line break, which is also a + CRLF sequence, in the Quoted-Printable encoding. Since + the canonical representation of media types other than + text do not generally include the representation of + line breaks as CRLF sequences, no hard line breaks + (i.e. line breaks that are intended to be meaningful + and to be displayed to the user) can occur in the + quoted-printable encoding of such types. Sequences + like "=0D", "=0A", "=0A=0D" and "=0D=0A" will routinely + appear in non-text data represented in quoted- + printable, of course. + + Note that many implementations may elect to encode the + local representation of various content types directly + rather than converting to canonical form first, + encoding, and then converting back to local + representation. In particular, this may apply to plain + text material on systems that use newline conventions + other than a CRLF terminator sequence. Such an + implementation optimization is permissible, but only + when the combined canonicalization-encoding step is + equivalent to performing the three steps separately. + */ + + $string = 'a'."\r\n".'b'."\r\n".'c'."\r\n"; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('c'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($string, $encoder->encodeString($string)); + } + + public function testLinesLongerThan76CharactersAreSoftBroken() + { + /* + (5) (Soft Line Breaks) The Quoted-Printable encoding + REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded + with the Quoted-Printable encoding, "soft" line breaks + must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ("soft") + line break in the encoded text. + */ + + $input = str_repeat('a', 140); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 140; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (75 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input)); + } + + public function testMaxLineLengthCanBeSpecified() + { + $input = str_repeat('a', 100); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 100; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (53 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input, 0, 54)); + } + + public function testBytesBelowPermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(0, 32) as $ordinal) { + $char = chr($ordinal); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals( + sprintf('=%02X', $ordinal), $encoder->encodeString($char) + ); + } + } + + public function testDecimalByte61IsEncoded() + { + /* + According to Rule (1 & 2) + */ + + $char = '='; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(61)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals('=3D', $encoder->encodeString('=')); + } + + public function testBytesAbovePermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(127, 255) as $ordinal) { + $char = chr($ordinal); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals( + sprintf('=%02X', $ordinal), $encoder->encodeString($char) + ); + } + } + + public function testFirstLineLengthCanBeDifferent() + { + $input = str_repeat('a', 140); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 140; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (53 == $i || 53 + 75 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + $output, $encoder->encodeString($input, 22), + '%s: First line should start at offset 22 so can only have max length 54' + ); + } + + // -- Creation methods + + private function _createCharStream() + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php new file mode 100644 index 000000000..28eae6f86 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php @@ -0,0 +1,141 @@ +getMockery('Swift_CharacterStream'); + + $string = ''; + foreach (range(0x00, 0x7F) as $octet) { + $char = pack('C', $octet); + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + $encoded = $encoder->encodeString($string); + + foreach (explode("\r\n", $encoded) as $line) { + $this->assertRegExp($this->_rfc2045Token, $line, + '%s: Encoder should always return a valid RFC 2045 token.'); + } + } + + public function testEncodingNonAsciiCharactersProducesValidToken() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + foreach (range(0x80, 0xFF) as $octet) { + $char = pack('C', $octet); + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $encoded = $encoder->encodeString($string); + + foreach (explode("\r\n", $encoded) as $line) { + $this->assertRegExp($this->_rfc2045Token, $line, + '%s: Encoder should always return a valid RFC 2045 token.'); + } + } + + public function testMaximumLineLengthCanBeSet() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + for ($x = 0; $x < 200; ++$x) { + $char = 'a'; + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $encoded = $encoder->encodeString($string, 0, 75); + + $this->assertEquals( + str_repeat('a', 75)."\r\n". + str_repeat('a', 75)."\r\n". + str_repeat('a', 50), + $encoded, + '%s: Lines should be wrapped at each 75 characters' + ); + } + + public function testFirstLineCanHaveShorterLength() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + for ($x = 0; $x < 200; ++$x) { + $char = 'a'; + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + $encoded = $encoder->encodeString($string, 25, 75); + + $this->assertEquals( + str_repeat('a', 50)."\r\n". + str_repeat('a', 75)."\r\n". + str_repeat('a', 75), + $encoded, + '%s: First line should be 25 bytes shorter than the others.' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php new file mode 100644 index 000000000..7e5980252 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php @@ -0,0 +1,36 @@ +_createEvent($this->_createTransport(), "FOO\r\n"); + $this->assertEquals("FOO\r\n", $evt->getCommand()); + } + + public function testSuccessCodesCanBeFetchedViaGetter() + { + $evt = $this->_createEvent($this->_createTransport(), "FOO\r\n", array(250)); + $this->assertEquals(array(250), $evt->getSuccessCodes()); + } + + public function testSourceIsBuffer() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, "FOO\r\n"); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, $command, $successCodes = array()) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php new file mode 100644 index 000000000..62a91be54 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php @@ -0,0 +1,34 @@ +_createEvent($source); + $ref = $evt->getSource(); + $this->assertEquals($source, $ref); + } + + public function testEventDoesNotHaveCancelledBubbleWhenNew() + { + $source = new stdClass(); + $evt = $this->_createEvent($source); + $this->assertFalse($evt->bubbleCancelled()); + } + + public function testBubbleCanBeCancelledInEvent() + { + $source = new stdClass(); + $evt = $this->_createEvent($source); + $evt->cancelBubble(); + $this->assertTrue($evt->bubbleCancelled()); + } + + // -- Creation Methods + + private function _createEvent($source) + { + return new Swift_Events_EventObject($source); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php new file mode 100644 index 000000000..e0f3e362d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php @@ -0,0 +1,40 @@ +_createEvent($this->_createTransport(), "250 Ok\r\n", true); + $this->assertEquals("250 Ok\r\n", $evt->getResponse(), + '%s: Response should be available via getResponse()' + ); + } + + public function testResultCanBeFetchedViaGetter() + { + $evt = $this->_createEvent($this->_createTransport(), "250 Ok\r\n", false); + $this->assertFalse($evt->isValid(), + '%s: Result should be checkable via isValid()' + ); + } + + public function testSourceIsBuffer() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, "250 Ok\r\n", true); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, $response, $result) + { + return new Swift_Events_ResponseEvent($source, $response, $result); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php new file mode 100644 index 000000000..800387009 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php @@ -0,0 +1,99 @@ +_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getMessage(); + $this->assertEquals($message, $ref, + '%s: Message should be returned from getMessage()' + ); + } + + public function testTransportCanBeFetchViaGetter() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getTransport(); + $this->assertEquals($transport, $ref, + '%s: Transport should be returned from getTransport()' + ); + } + + public function testTransportCanBeFetchViaGetSource() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref, + '%s: Transport should be returned from getSource()' + ); + } + + public function testResultCanBeSetAndGet() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $evt->setResult( + Swift_Events_SendEvent::RESULT_SUCCESS | Swift_Events_SendEvent::RESULT_TENTATIVE + ); + + $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_SUCCESS)); + $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_TENTATIVE)); + } + + public function testFailedRecipientsCanBeSetAndGet() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $evt->setFailedRecipients(array('foo@bar', 'zip@button')); + + $this->assertEquals(array('foo@bar', 'zip@button'), $evt->getFailedRecipients(), + '%s: FailedRecipients should be returned from getter' + ); + } + + public function testFailedRecipientsGetsPickedUpCorrectly() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + $this->assertEquals(array(), $evt->getFailedRecipients()); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, + Swift_Mime_Message $message) + { + return new Swift_Events_SendEvent($source, $message); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createMessage() + { + return $this->getMock('Swift_Mime_Message'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php new file mode 100644 index 000000000..52ae07c66 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php @@ -0,0 +1,135 @@ +_dispatcher = new Swift_Events_SimpleEventDispatcher(); + } + + public function testSendEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + $evt = $this->_dispatcher->createSendEvent($transport, $message); + $this->assertInstanceof('Swift_Events_SendEvent', $evt); + $this->assertSame($message, $evt->getMessage()); + $this->assertSame($transport, $evt->getTransport()); + } + + public function testCommandEventCanBeCreated() + { + $buf = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createCommandEvent($buf, "FOO\r\n", array(250)); + $this->assertInstanceof('Swift_Events_CommandEvent', $evt); + $this->assertSame($buf, $evt->getSource()); + $this->assertEquals("FOO\r\n", $evt->getCommand()); + $this->assertEquals(array(250), $evt->getSuccessCodes()); + } + + public function testResponseEventCanBeCreated() + { + $buf = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createResponseEvent($buf, "250 Ok\r\n", true); + $this->assertInstanceof('Swift_Events_ResponseEvent', $evt); + $this->assertSame($buf, $evt->getSource()); + $this->assertEquals("250 Ok\r\n", $evt->getResponse()); + $this->assertTrue($evt->isValid()); + } + + public function testTransportChangeEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createTransportChangeEvent($transport); + $this->assertInstanceof('Swift_Events_TransportChangeEvent', $evt); + $this->assertSame($transport, $evt->getSource()); + } + + public function testTransportExceptionEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $ex = new Swift_TransportException(''); + $evt = $this->_dispatcher->createTransportExceptionEvent($transport, $ex); + $this->assertInstanceof('Swift_Events_TransportExceptionEvent', $evt); + $this->assertSame($transport, $evt->getSource()); + $this->assertSame($ex, $evt->getException()); + } + + public function testListenersAreNotifiedOfDispatchedEvent() + { + $transport = $this->getMock('Swift_Transport'); + + $evt = $this->_dispatcher->createTransportChangeEvent($transport); + + $listenerA = $this->getMock('Swift_Events_TransportChangeListener'); + $listenerB = $this->getMock('Swift_Events_TransportChangeListener'); + + $this->_dispatcher->bindEventListener($listenerA); + $this->_dispatcher->bindEventListener($listenerB); + + $listenerA->expects($this->once()) + ->method('transportStarted') + ->with($evt); + $listenerB->expects($this->once()) + ->method('transportStarted') + ->with($evt); + + $this->_dispatcher->dispatchEvent($evt, 'transportStarted'); + } + + public function testListenersAreOnlyCalledIfImplementingCorrectInterface() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + + $evt = $this->_dispatcher->createSendEvent($transport, $message); + + $targetListener = $this->getMock('Swift_Events_SendListener'); + $otherListener = $this->getMock('Swift_Events_TransportChangeListener'); + + $this->_dispatcher->bindEventListener($targetListener); + $this->_dispatcher->bindEventListener($otherListener); + + $targetListener->expects($this->once()) + ->method('sendPerformed') + ->with($evt); + $otherListener->expects($this->never()) + ->method('sendPerformed'); + + $this->_dispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + public function testListenersCanCancelBubblingOfEvent() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + + $evt = $this->_dispatcher->createSendEvent($transport, $message); + + $listenerA = $this->getMock('Swift_Events_SendListener'); + $listenerB = $this->getMock('Swift_Events_SendListener'); + + $this->_dispatcher->bindEventListener($listenerA); + $this->_dispatcher->bindEventListener($listenerB); + + $listenerA->expects($this->once()) + ->method('sendPerformed') + ->with($evt) + ->will($this->returnCallback(function ($object) { + $object->cancelBubble(true); + })); + $listenerB->expects($this->never()) + ->method('sendPerformed'); + + $this->_dispatcher->dispatchEvent($evt, 'sendPerformed'); + + $this->assertTrue($evt->bubbleCancelled()); + } + + private function _createDispatcher(array $map) + { + return new Swift_Events_SimpleEventDispatcher($map); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php new file mode 100644 index 000000000..40bec8345 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php @@ -0,0 +1,32 @@ +_createTransport(); + $evt = $this->_createEvent($transport); + $ref = $evt->getTransport(); + $this->assertEquals($transport, $ref); + } + + public function testSourceIsTransport() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php new file mode 100644 index 000000000..86c636b54 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php @@ -0,0 +1,43 @@ +_createException(); + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, $ex); + $ref = $evt->getException(); + $this->assertEquals($ex, $ref, + '%s: Exception should be available via getException()' + ); + } + + public function testSourceIsTransport() + { + $ex = $this->_createException(); + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, $ex); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref, + '%s: Transport should be available via getSource()' + ); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $transport, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($transport, $ex); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createException() + { + return new Swift_TransportException(''); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php new file mode 100644 index 000000000..36512cff4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php @@ -0,0 +1,242 @@ +_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('whatever', $cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('testing', $cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = $this->_createOutputStream(); + $os->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = $this->_createOutputStream(); + $os1->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os1->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os1->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $os2 = $this->_createOutputStream(); + $os2->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('xyz')); + $os2->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('uvw')); + $os2->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($is); + + $cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $os = $this->_createOutputStream(); + $os->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + $cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + //See acceptance test for more detail + $is = $this->_createInputStream(); + $is->expects($this->atLeastOnce()) + ->method('write'); + + $kcis = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($kcis); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $cache->exportToByteStream($this->_key1, 'foo', $is); + } + + public function testKeyCanBeCleared() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + $cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($cache->hasKey($this->_key1, 'bar')); + $cache->clearAll($this->_key1); + $this->assertFalse($cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($cache->hasKey($this->_key1, 'bar')); + } + + // -- Creation methods + + private function _createCache($is) + { + return new Swift_KeyCache_ArrayKeyCache($is); + } + + private function _createKeyCacheInputStream() + { + return $this->getMock('Swift_KeyCache_KeyCacheInputStream'); + } + + private function _createOutputStream() + { + return $this->getMock('Swift_OutputByteStream'); + } + + private function _createInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php new file mode 100644 index 000000000..691c1e790 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php @@ -0,0 +1,73 @@ +getMock('Swift_KeyCache'); + $cache->expects($this->at(0)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'a', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(1)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'b', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(2)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'c', Swift_KeyCache::MODE_APPEND); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->write('a'); + $stream->write('b'); + $stream->write('c'); + } + + public function testFlushContentClearsKey() + { + $cache = $this->getMock('Swift_KeyCache'); + $cache->expects($this->once()) + ->method('clearKey') + ->with($this->_nsKey, 'foo'); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->flushBuffers(); + } + + public function testClonedStreamStillReferencesSameCache() + { + $cache = $this->getMock('Swift_KeyCache'); + $cache->expects($this->at(0)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'a', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(1)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'b', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(2)) + ->method('setString') + ->with('test', 'bar', 'x', Swift_KeyCache::MODE_APPEND); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->write('a'); + $stream->write('b'); + + $newStream = clone $stream; + $newStream->setKeyCache($cache); + $newStream->setNsKey('test'); + $newStream->setItemKey('bar'); + + $newStream->write('x'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php new file mode 100644 index 000000000..ff0bce4fa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php @@ -0,0 +1,42 @@ +assertFalse($it->hasNext()); + } + + public function testHasNextReturnsTrueIfItemsLeft() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertTrue($it->hasNext()); + } + + public function testReadingToEndOfListCausesHasNextToReturnFalse() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertTrue($it->hasNext()); + $it->nextRecipient(); + $this->assertFalse($it->hasNext()); + } + + public function testReturnedValueHasPreservedKeyValuePair() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertEquals(array('foo@bar' => 'Foo'), $it->nextRecipient()); + } + + public function testIteratorMovesNextAfterEachIteration() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array( + 'foo@bar' => 'Foo', + 'zip@button' => 'Zip thing', + 'test@test' => null, + )); + $this->assertEquals(array('foo@bar' => 'Foo'), $it->nextRecipient()); + $this->assertEquals(array('zip@button' => 'Zip thing'), $it->nextRecipient()); + $this->assertEquals(array('test@test' => null), $it->nextRecipient()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php new file mode 100644 index 000000000..db0b35a06 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php @@ -0,0 +1,152 @@ +_createTransport(); + $message = $this->_createMessage(); + + $started = false; + $transport->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$started) { + return $started; + }); + $transport->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$started) { + $started = true; + + return; + }); + + $mailer = $this->_createMailer($transport); + $mailer->send($message); + } + + public function testTransportIsOnlyStartedOnce() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + + $started = false; + $transport->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$started) { + return $started; + }); + $transport->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$started) { + $started = true; + + return; + }); + + $mailer = $this->_createMailer($transport); + for ($i = 0; $i < 10; ++$i) { + $mailer->send($message); + } + } + + public function testMessageIsPassedToTransport() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()); + + $mailer = $this->_createMailer($transport); + $mailer->send($message); + } + + public function testSendReturnsCountFromTransport() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturn(57); + + $mailer = $this->_createMailer($transport); + $this->assertEquals(57, $mailer->send($message)); + } + + public function testFailedRecipientReferenceIsPassedToTransport() + { + $failures = array(); + + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andReturn(57); + + $mailer = $this->_createMailer($transport); + $mailer->send($message, $failures); + } + + public function testSendRecordsRfcComplianceExceptionAsEntireSendFailure() + { + $failures = array(); + + $rfcException = new Swift_RfcComplianceException('test'); + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo&invalid' => 'Foo', 'bar@valid.tld' => 'Bar')); + $transport->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andThrow($rfcException); + + $mailer = $this->_createMailer($transport); + $this->assertEquals(0, $mailer->send($message, $failures), '%s: Should return 0'); + $this->assertEquals(array('foo&invalid', 'bar@valid.tld'), $failures, '%s: Failures should contain all addresses since the entire message failed to compile'); + } + + public function testRegisterPluginDelegatesToTransport() + { + $plugin = $this->_createPlugin(); + $transport = $this->_createTransport(); + $mailer = $this->_createMailer($transport); + + $transport->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $mailer->registerPlugin($plugin); + } + + // -- Creation methods + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener')->shouldIgnoreMissing(); + } + + private function _createTransport() + { + return $this->getMockery('Swift_Transport')->shouldIgnoreMissing(); + } + + private function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + private function _createIterator() + { + return $this->getMockery('Swift_Mailer_RecipientIterator')->shouldIgnoreMissing(); + } + + private function _createMailer(Swift_Transport $transport) + { + return new Swift_Mailer($transport); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MessageTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MessageTest.php new file mode 100644 index 000000000..c9e738336 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MessageTest.php @@ -0,0 +1,130 @@ +_recursiveObjectCloningCheck($message1, $message2, $message1_clone); + } + + public function testCloningWithSigners() + { + $message1 = new Swift_Message('subj', 'body', 'ctype'); + $signer = new Swift_Signers_DKIMSigner(dirname(dirname(__DIR__)).'/_samples/dkim/dkim.test.priv', 'test.example', 'example'); + $message1->attachSigner($signer); + $message2 = new Swift_Message('subj', 'body', 'ctype'); + $signer = new Swift_Signers_DKIMSigner(dirname(dirname(__DIR__)).'/_samples/dkim/dkim.test.priv', 'test.example', 'example'); + $message2->attachSigner($signer); + $message1_clone = clone $message1; + + $this->_recursiveObjectCloningCheck($message1, $message2, $message1_clone); + } + + public function testBodySwap() + { + $message1 = new Swift_Message('Test'); + $html = Swift_MimePart::newInstance('', 'text/html'); + $html->getHeaders()->addTextHeader('X-Test-Remove', 'Test-Value'); + $html->getHeaders()->addTextHeader('X-Test-Alter', 'Test-Value'); + $message1->attach($html); + $source = $message1->toString(); + $message2 = clone $message1; + $message2->setSubject('Message2'); + foreach ($message2->getChildren() as $child) { + $child->setBody('Test'); + $child->getHeaders()->removeAll('X-Test-Remove'); + $child->getHeaders()->get('X-Test-Alter')->setValue('Altered'); + } + $final = $message1->toString(); + if ($source != $final) { + $this->fail("Difference although object cloned \n [".$source."]\n[".$final."]\n"); + } + $final = $message2->toString(); + if ($final == $source) { + $this->fail('Two body matches although they should differ'."\n [".$source."]\n[".$final."]\n"); + } + $id_1 = $message1->getId(); + $id_2 = $message2->getId(); + $this->assertEquals($id_1, $id_2, 'Message Ids differ'); + $id_2 = $message2->generateId(); + $this->assertNotEquals($id_1, $id_2, 'Message Ids are the same'); + } + + // -- Private helpers + protected function _recursiveObjectCloningCheck($obj1, $obj2, $obj1_clone) + { + $obj1_properties = (array) $obj1; + $obj2_properties = (array) $obj2; + $obj1_clone_properties = (array) $obj1_clone; + + foreach ($obj1_properties as $property => $value) { + if (is_object($value)) { + $obj1_value = $obj1_properties[$property]; + $obj2_value = $obj2_properties[$property]; + $obj1_clone_value = $obj1_clone_properties[$property]; + + if ($obj1_value !== $obj2_value) { + // two separetely instanciated objects property not referencing same object + $this->assertFalse( + // but object's clone does - not everything copied + $obj1_value === $obj1_clone_value, + "Property `$property` cloning error: source and cloned objects property is referencing same object" + ); + } else { + // two separetely instanciated objects have same reference + $this->assertFalse( + // but object's clone doesn't - overdone making copies + $obj1_value !== $obj1_clone_value, + "Property `$property` not properly cloned: it should reference same object as cloning source (overdone copping)" + ); + } + // recurse + $this->_recursiveObjectCloningCheck($obj1_value, $obj2_value, $obj1_clone_value); + } elseif (is_array($value)) { + $obj1_value = $obj1_properties[$property]; + $obj2_value = $obj2_properties[$property]; + $obj1_clone_value = $obj1_clone_properties[$property]; + + return $this->_recursiveArrayCloningCheck($obj1_value, $obj2_value, $obj1_clone_value); + } + } + } + + protected function _recursiveArrayCloningCheck($array1, $array2, $array1_clone) + { + foreach ($array1 as $key => $value) { + if (is_object($value)) { + $arr1_value = $array1[$key]; + $arr2_value = $array2[$key]; + $arr1_clone_value = $array1_clone[$key]; + if ($arr1_value !== $arr2_value) { + // two separetely instanciated objects property not referencing same object + $this->assertFalse( + // but object's clone does - not everything copied + $arr1_value === $arr1_clone_value, + "Key `$key` cloning error: source and cloned objects property is referencing same object" + ); + } else { + // two separetely instanciated objects have same reference + $this->assertFalse( + // but object's clone doesn't - overdone making copies + $arr1_value !== $arr1_clone_value, + "Key `$key` not properly cloned: it should reference same object as cloning source (overdone copping)" + ); + } + // recurse + $this->_recursiveObjectCloningCheck($arr1_value, $arr2_value, $arr1_clone_value); + } elseif (is_array($value)) { + $arr1_value = $array1[$key]; + $arr2_value = $array2[$key]; + $arr1_clone_value = $array1_clone[$key]; + + return $this->_recursiveArrayCloningCheck($obj1_value, $obj2_value, $obj1_clone_value); + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php new file mode 100644 index 000000000..dc8ea092c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php @@ -0,0 +1,1054 @@ +_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertSame($headers, $entity->getHeaders()); + } + + public function testContentTypeIsReturnedFromHeader() + { + $ctype = $this->_createHeader('Content-Type', 'image/jpeg-test'); + $headers = $this->_createHeaderSet(array('Content-Type' => $ctype)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('image/jpeg-test', $entity->getContentType()); + } + + public function testContentTypeIsSetInHeader() + { + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $headers = $this->_createHeaderSet(array('Content-Type' => $ctype)); + + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('image/jpeg'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes() + ->with(\Mockery::not('image/jpeg')); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setContentType('image/jpeg'); + } + + public function testContentTypeHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Type', 'image/jpeg'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setContentType('image/jpeg'); + } + + public function testContentTypeCanBeSetViaSetBody() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Type', 'text/html'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody('foo', 'text/html'); + } + + public function testGetEncoderFromConstructor() + { + $encoder = $this->_createEncoder('base64'); + $entity = $this->_createEntity($this->_createHeaderSet(), $encoder, + $this->_createCache() + ); + $this->assertSame($encoder, $entity->getEncoder()); + } + + public function testSetAndGetEncoder() + { + $encoder = $this->_createEncoder('base64'); + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($encoder); + $this->assertSame($encoder, $entity->getEncoder()); + } + + public function testSettingEncoderUpdatesTransferEncoding() + { + $encoder = $this->_createEncoder('base64'); + $encoding = $this->_createHeader( + 'Content-Transfer-Encoding', '8bit', array(), false + ); + $headers = $this->_createHeaderSet(array( + 'Content-Transfer-Encoding' => $encoding, + )); + $encoding->shouldReceive('setFieldBodyModel') + ->once() + ->with('base64'); + $encoding->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($encoder); + } + + public function testSettingEncoderAddsEncodingHeaderIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Content-Transfer-Encoding', 'something'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($this->_createEncoder('something')); + } + + public function testIdIsReturnedFromHeader() + { + /* -- RFC 2045, 7. + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labelled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field + */ + + $cid = $this->_createHeader('Content-ID', 'zip@button'); + $headers = $this->_createHeaderSet(array('Content-ID' => $cid)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('zip@button', $entity->getId()); + } + + public function testIdIsSetInHeader() + { + $cid = $this->_createHeader('Content-ID', 'zip@button', array(), false); + $headers = $this->_createHeaderSet(array('Content-ID' => $cid)); + + $cid->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo@bar'); + $cid->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setId('foo@bar'); + } + + public function testIdIsAutoGenerated() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertRegExp('/^.*?@.*?$/D', $entity->getId()); + } + + public function testGenerateIdCreatesNewId() + { + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $id1 = $entity->generateId(); + $id2 = $entity->generateId(); + $this->assertNotEquals($id1, $id2); + } + + public function testGenerateIdSetsNewId() + { + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $id = $entity->generateId(); + $this->assertEquals($id, $entity->getId()); + } + + public function testDescriptionIsReadFromHeader() + { + /* -- RFC 2045, 8. + The ability to associate some descriptive information with a given + body is often desirable. For example, it may be useful to mark an + "image" body as "a picture of the Space Shuttle Endeavor." Such text + may be placed in the Content-Description header field. This header + field is always optional. + */ + + $desc = $this->_createHeader('Content-Description', 'something'); + $headers = $this->_createHeaderSet(array('Content-Description' => $desc)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('something', $entity->getDescription()); + } + + public function testDescriptionIsSetInHeader() + { + $desc = $this->_createHeader('Content-Description', '', array(), false); + $desc->shouldReceive('setFieldBodyModel')->once()->with('whatever'); + + $headers = $this->_createHeaderSet(array('Content-Description' => $desc)); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setDescription('whatever'); + } + + public function testDescriptionHeaderIsAddedIfNotPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Content-Description', 'whatever'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setDescription('whatever'); + } + + public function testSetAndGetMaxLineLength() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setMaxLineLength(60); + $this->assertEquals(60, $entity->getMaxLineLength()); + } + + public function testEncoderIsUsedForStringGeneration() + { + $encoder = $this->_createEncoder('base64', false); + $encoder->expects($this->once()) + ->method('encodeString') + ->with('blah'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $entity->setBody('blah'); + $entity->toString(); + } + + public function testMaxLineLengthIsProvidedWhenEncoding() + { + $encoder = $this->_createEncoder('base64', false); + $encoder->expects($this->once()) + ->method('encodeString') + ->with('blah', 0, 65); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $entity->setBody('blah'); + $entity->setMaxLineLength(65); + $entity->toString(); + } + + public function testHeadersAppearInString() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->once() + ->andReturn( + "Content-Type: text/plain; charset=utf-8\r\n". + "X-MyHeader: foobar\r\n" + ); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n". + "X-MyHeader: foobar\r\n", + $entity->toString() + ); + } + + public function testSetAndGetBody() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBody("blah\r\nblah!"); + $this->assertEquals("blah\r\nblah!", $entity->getBody()); + } + + public function testBodyIsAppended() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->once() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody("blah\r\nblah!"); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n". + "\r\n". + "blah\r\nblah!", + $entity->toString() + ); + } + + public function testGetBodyReturnsStringFromByteStream() + { + $os = $this->_createOutputStream('byte stream string'); + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBody($os); + $this->assertEquals('byte stream string', $entity->getBody()); + } + + public function testByteStreamBodyIsAppended() + { + $headers = $this->_createHeaderSet(array(), false); + $os = $this->_createOutputStream('streamed'); + $headers->shouldReceive('toString') + ->once() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody($os); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n". + "\r\n". + 'streamed', + $entity->toString() + ); + } + + public function testBoundaryCanBeRetrieved() + { + /* -- RFC 2046, 5.1.1. + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / + "+" / "_" / "," / "-" / "." / + "/" / ":" / "=" / "?" + */ + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertRegExp( + '/^[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?]$/D', + $entity->getBoundary() + ); + } + + public function testBoundaryNeverChanges() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $firstBoundary = $entity->getBoundary(); + for ($i = 0; $i < 10; $i++) { + $this->assertEquals($firstBoundary, $entity->getBoundary()); + } + } + + public function testBoundaryCanBeSet() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBoundary('foobar'); + $this->assertEquals('foobar', $entity->getBoundary()); + } + + public function testAddingChildrenGeneratesBoundaryInHeaders() + { + $child = $this->_createChild(); + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter') + ->once() + ->with('boundary', \Mockery::any()); + $cType->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType, + )), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + + public function testChildrenOfLevelAttachmentAndLessCauseMultipartMixed() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_MIXED; + $level > Swift_Mime_MimeEntity::LEVEL_TOP; $level /= 2) { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/mixed'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testChildrenOfLevelAlternativeAndLessCauseMultipartAlternative() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE; + $level > Swift_Mime_MimeEntity::LEVEL_MIXED; $level /= 2) { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/alternative'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testChildrenOfLevelRelatedAndLessCauseMultipartRelated() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_RELATED; + $level > Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE; $level /= 2) { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/related'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testHighestLevelChildDeterminesContentType() + { + $combinations = array( + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + Swift_Mime_MimeEntity::LEVEL_RELATED, + ), + 'type' => 'multipart/mixed', + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_RELATED, + ), + 'type' => 'multipart/mixed', + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + ), + 'type' => 'multipart/mixed', + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + Swift_Mime_MimeEntity::LEVEL_RELATED, + ), + 'type' => 'multipart/alternative', + ), + ); + + foreach ($combinations as $combination) { + $children = array(); + foreach ($combination['levels'] as $level) { + $children[] = $this->_createChild($level); + } + + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with($combination['type']); + + $headerSet = $this->_createHeaderSet(array('Content-Type' => $cType)); + $headerSet->shouldReceive('newInstance') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use ($headerSet) { + return $headerSet; + }); + $entity = $this->_createEntity($headerSet, + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren($children); + } + } + + public function testChildrenAppearNestedInString() + { + /* -- RFC 2046, 5.1.1. + (excerpt too verbose to paste here) + */ + + $headers = $this->_createHeaderSet(array(), false); + + $child1 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n". + "\r\n". + 'foobar' + ); + + $child2 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/html\r\n". + "\r\n". + 'foobar' + ); + + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"xxx\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($child1, $child2)); + + $this->assertEquals( + "Content-Type: multipart/alternative; boundary=\"xxx\"\r\n". + "\r\n". + "\r\n--xxx\r\n". + "Content-Type: text/plain\r\n". + "\r\n". + "foobar\r\n". + "\r\n--xxx\r\n". + "Content-Type: text/html\r\n". + "\r\n". + "foobar\r\n". + "\r\n--xxx--\r\n", + $entity->toString() + ); + } + + public function testMixingLevelsIsHierarchical() + { + $headers = $this->_createHeaderSet(array(), false); + $newHeaders = $this->_createHeaderSet(array(), false); + + $part = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n". + "\r\n". + 'foobar' + ); + + $attachment = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_MIXED, + "Content-Type: application/octet-stream\r\n". + "\r\n". + 'data' + ); + + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/mixed; boundary=\"xxx\"\r\n"); + $headers->shouldReceive('newInstance') + ->zeroOrMoreTimes() + ->andReturn($newHeaders); + $newHeaders->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"yyy\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($part, $attachment)); + + $this->assertRegExp( + '~^'. + "Content-Type: multipart/mixed; boundary=\"xxx\"\r\n". + "\r\n\r\n--xxx\r\n". + "Content-Type: multipart/alternative; boundary=\"yyy\"\r\n". + "\r\n\r\n--(.*?)\r\n". + "Content-Type: text/plain\r\n". + "\r\n". + 'foobar'. + "\r\n\r\n--\\1--\r\n". + "\r\n\r\n--xxx\r\n". + "Content-Type: application/octet-stream\r\n". + "\r\n". + 'data'. + "\r\n\r\n--xxx--\r\n". + "\$~", + $entity->toString() + ); + } + + public function testSettingEncoderNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $encoder = $this->_createEncoder('base64'); + + $child->shouldReceive('encoderChanged') + ->once() + ->with($encoder); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->setEncoder($encoder); + } + + public function testReceiptOfEncoderChangeNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $encoder = $this->_createEncoder('base64'); + + $child->shouldReceive('encoderChanged') + ->once() + ->with($encoder); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->encoderChanged($encoder); + } + + public function testReceiptOfCharsetChangeNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $child->shouldReceive('charsetChanged') + ->once() + ->with('windows-874'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->charsetChanged('windows-874'); + } + + public function testEntityIsWrittenToByteStream() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $is = $this->_createInputStream(false); + $is->expects($this->atLeastOnce()) + ->method('write'); + + $entity->toByteStream($is); + } + + public function testEntityHeadersAreComittedToByteStream() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $is = $this->_createInputStream(false); + $is->expects($this->atLeastOnce()) + ->method('write'); + $is->expects($this->atLeastOnce()) + ->method('commit'); + + $entity->toByteStream($is); + } + + public function testOrderingTextBeforeHtml() + { + $htmlChild = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/html\r\n". + "\r\n". + 'HTML PART', + 'text/html' + ); + $textChild = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n". + "\r\n". + 'TEXT PART', + 'text/plain' + ); + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"xxx\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($htmlChild, $textChild)); + + $this->assertEquals( + "Content-Type: multipart/alternative; boundary=\"xxx\"\r\n". + "\r\n\r\n--xxx\r\n". + "Content-Type: text/plain\r\n". + "\r\n". + 'TEXT PART'. + "\r\n\r\n--xxx\r\n". + "Content-Type: text/html\r\n". + "\r\n". + 'HTML PART'. + "\r\n\r\n--xxx--\r\n", + $entity->toString() + ); + } + + public function testUnsettingChildrenRestoresContentType() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $child = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE); + + $cType->shouldReceive('setFieldBodyModel') + ->twice() + ->with('image/jpeg'); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/alternative'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes() + ->with(\Mockery::not('multipart/alternative', 'image/jpeg')); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType, + )), + $this->_createEncoder(), $this->_createCache() + ); + + $entity->setContentType('image/jpeg'); + $entity->setChildren(array($child)); + $entity->setChildren(array()); + } + + public function testBodyIsReadFromCacheWhenUsingToStringIfPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(true); + $cache->shouldReceive('getString') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn("\r\ncache\r\ncache!"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n". + "\r\n". + "cache\r\ncache!", + $entity->toString() + ); + } + + public function testBodyIsAddedToCacheWhenUsingToString() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(false); + $cache->shouldReceive('setString') + ->once() + ->with(\Mockery::any(), 'body', "\r\nblah\r\nblah!", Swift_KeyCache::MODE_WRITE); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + } + + public function testBodyIsClearedFromCacheIfNewBodySet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setBody() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setBody("new\r\nnew!"); + } + + public function testBodyIsNotClearedFromCacheIfSameBodySet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setBody() + $cache->shouldReceive('clearKey') + ->never(); + + $entity->setBody("blah\r\nblah!"); + } + + public function testBodyIsClearedFromCacheIfNewEncoderSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $otherEncoder = $this->_createEncoder(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setEncoder() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setEncoder($otherEncoder); + } + + public function testBodyIsReadFromCacheWhenUsingToByteStreamIfPresent() + { + $is = $this->_createInputStream(); + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(true); + $cache->shouldReceive('exportToByteStream') + ->once() + ->with(\Mockery::any(), 'body', $is); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $cache + ); + $entity->setBody('foo'); + + $entity->toByteStream($is); + } + + public function testBodyIsAddedToCacheWhenUsingToByteStream() + { + $is = $this->_createInputStream(); + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(false); + $cache->shouldReceive('getInputByteStream') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $cache + ); + $entity->setBody('foo'); + + $entity->toByteStream($is); + } + + public function testFluidInterface() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertSame($entity, + $entity + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ); + } + + // -- Private helpers + + abstract protected function _createEntity($headers, $encoder, $cache); + + protected function _createChild($level = null, $string = '', $stub = true) + { + $child = $this->getMockery('Swift_Mime_MimeEntity')->shouldIgnoreMissing(); + if (isset($level)) { + $child->shouldReceive('getNestingLevel') + ->zeroOrMoreTimes() + ->andReturn($level); + } + $child->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn($string); + + return $child; + } + + protected function _createEncoder($name = 'quoted-printable', $stub = true) + { + $encoder = $this->getMock('Swift_Mime_ContentEncoder'); + $encoder->expects($this->any()) + ->method('getName') + ->will($this->returnValue($name)); + $encoder->expects($this->any()) + ->method('encodeString') + ->will($this->returnCallback(function () { + $args = func_get_args(); + + return array_shift($args); + })); + + return $encoder; + } + + protected function _createCache($stub = true) + { + return $this->getMockery('Swift_KeyCache')->shouldIgnoreMissing(); + } + + protected function _createHeaderSet($headers = array(), $stub = true) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->andReturnUsing(function ($key) use ($headers) { + return $headers[$key]; + }); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->andReturnUsing(function ($key) use ($headers) { + return array_key_exists($key, $headers); + }); + + return $set; + } + + protected function _createHeader($name, $model = null, $params = array(), $stub = true) + { + $header = $this->getMockery('Swift_Mime_ParameterizedHeader')->shouldIgnoreMissing(); + $header->shouldReceive('getFieldName') + ->zeroOrMoreTimes() + ->andReturn($name); + $header->shouldReceive('getFieldBodyModel') + ->zeroOrMoreTimes() + ->andReturn($model); + $header->shouldReceive('getParameter') + ->zeroOrMoreTimes() + ->andReturnUsing(function ($key) use ($params) { + return $params[$key]; + }); + + return $header; + } + + protected function _createOutputStream($data = null, $stub = true) + { + $os = $this->getMockery('Swift_OutputByteStream'); + if (isset($data)) { + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use ($data) { + static $first = true; + if (!$first) { + return false; + } + + $first = false; + + return $data; + }); + $os->shouldReceive('setReadPointer') + ->zeroOrMoreTimes(); + } + + return $os; + } + + protected function _createInputStream($stub = true) + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php new file mode 100644 index 000000000..bd2499c0c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php @@ -0,0 +1,320 @@ +_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_MIXED, $attachment->getNestingLevel() + ); + } + + public function testDispositionIsReturnedFromHeader() + { + /* -- RFC 2183, 2.1, 2.2. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment'); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('attachment', $attachment->getDisposition()); + } + + public function testDispositionIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array(), false + ); + $disposition->shouldReceive('setFieldBodyModel') + ->once() + ->with('inline'); + $disposition->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setDisposition('inline'); + } + + public function testDispositionIsAddedIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'inline'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + $attachment->setDisposition('inline'); + } + + public function testDispositionIsAutoDefaultedToAttachment() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'attachment'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testDefaultContentTypeInitializedToOctetStream() + { + $cType = $this->_createHeader('Content-Type', '', + array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('application/octet-stream'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + } + + public function testFilenameIsReturnedFromHeader() + { + /* -- RFC 2183, 2.3. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename' => 'foo.txt') + ); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('foo.txt', $attachment->getFilename()); + } + + public function testFilenameIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename' => 'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'bar.txt'); + $disposition->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFilename('bar.txt'); + } + + public function testSettingFilenameSetsNameInContentType() + { + /* + This is a legacy requirement which isn't covered by up-to-date RFCs. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array(), false + ); + $cType->shouldReceive('setParameter') + ->once() + ->with('name', 'bar.txt'); + $cType->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFilename('bar.txt'); + } + + public function testSizeIsReturnedFromHeader() + { + /* -- RFC 2183, 2.7. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('size' => 1234) + ); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(1234, $attachment->getSize()); + } + + public function testSizeIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array(), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('size', 12345); + $disposition->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setSize(12345); + } + + public function testFilnameCanBeReadFromFileStream() + { + $file = $this->_createFileStream('/bar/file.ext', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename' => 'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.ext'); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, )), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFile($file); + } + + public function testContentTypeCanBeSetViaSetFile() + { + $file = $this->_createFileStream('/bar/file.ext', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename' => 'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.ext'); + + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('text/html'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $headers = $this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, + 'Content-Type' => $ctype, + )); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + $attachment->setFile($file, 'text/html'); + } + + public function XtestContentTypeCanBeLookedUpFromCommonListIfNotProvided() + { + $file = $this->_createFileStream('/bar/file.zip', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename' => 'foo.zip'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.zip'); + + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('application/zip'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $headers = $this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, + 'Content-Type' => $ctype, + )); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache(), array('zip' => 'application/zip', 'txt' => 'text/plain') + ); + $attachment->setFile($file); + } + + public function testDataCanBeReadFromFile() + { + $file = $this->_createFileStream('/foo/file.ext', ''); + $attachment = $this->_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFile($file); + $this->assertEquals('', $attachment->getBody()); + } + + public function testFluidInterface() + { + $attachment = $this->_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame($attachment, + $attachment + ->setContentType('application/pdf') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my pdf') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setDisposition('inline') + ->setFilename('afile.txt') + ->setSize(123) + ->setFile($this->_createFileStream('foo.txt', '')) + ); + } + + // -- Private helpers + + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createAttachment($headers, $encoder, $cache); + } + + protected function _createAttachment($headers, $encoder, $cache, $mimeTypes = array()) + { + return new Swift_Mime_Attachment($headers, $encoder, $cache, new Swift_Mime_Grammar(), $mimeTypes); + } + + protected function _createFileStream($path, $data, $stub = true) + { + $file = $this->getMockery('Swift_FileStream'); + $file->shouldReceive('getPath') + ->zeroOrMoreTimes() + ->andReturn($path); + $file->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use ($data) { + static $first = true; + if (!$first) { + return false; + } + + $first = false; + + return $data; + }); + $file->shouldReceive('setReadPointer') + ->zeroOrMoreTimes(); + + return $file; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php new file mode 100644 index 000000000..0442af33f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php @@ -0,0 +1,323 @@ +_encoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + public function testNameIsBase64() + { + $this->assertEquals('base64', $this->_encoder->getName()); + } + + /* + There's really no point in testing the entire base64 encoding to the + level QP encoding has been tested. base64_encode() has been in PHP for + years. + */ + + public function testInputOutputRatioIs3to4Bytes() + { + /* + RFC 2045, 6.8 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + */ + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('123'); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertEquals('MTIz', $collection->content); + } + + public function testPadLength() + { + /* + RFC 2045, 6.8 + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the "=" character. Since all base64 + input is an integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C', rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{2}==$~', $collection->content, + '%s: A single byte should have 2 bytes of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C*', rand(0, 255), rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{3}=$~', $collection->content, + '%s: Two bytes should have 1 byte of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C*', rand(0, 255), rand(0, 255), rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{4}$~', $collection->content, + '%s: Three bytes should have no padding' + ); + } + } + + public function testMaximumLineLengthIs76Characters() + { + /* + The encoded output stream must be represented in lines of no more + than 76 characters each. All line breaks or other characters not + found in Table 1 must be ignored by decoding software. + */ + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n". + 'U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', + $collection->content + ); + } + + public function testMaximumLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 0, 50); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3OD\r\n". + "kwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJj\r\n". + 'ZGVmZ2hpamts', + $collection->content + ); + } + + public function testMaximumLineLengthIsNeverMoreThan76Chars() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 0, 100); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n". + 'U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', + $collection->content + ); + } + + public function testFirstLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 19); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDR\r\n". + 'EVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', + $collection->content + ); + } + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php new file mode 100644 index 000000000..526cedc5c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php @@ -0,0 +1,173 @@ +_getEncoder('7bit'); + $this->assertEquals('7bit', $encoder->getName()); + + $encoder = $this->_getEncoder('8bit'); + $this->assertEquals('8bit', $encoder->getName()); + } + + public function testNoOctetsAreModifiedInString() + { + $encoder = $this->_getEncoder('7bit'); + foreach (range(0x00, 0xFF) as $octet) { + $byte = pack('C', $octet); + $this->assertIdenticalBinary($byte, $encoder->encodeString($byte)); + } + } + + public function testNoOctetsAreModifiedInByteStream() + { + $encoder = $this->_getEncoder('7bit'); + foreach (range(0x00, 0xFF) as $octet) { + $byte = pack('C', $octet); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn($byte); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is); + $this->assertIdenticalBinary($byte, $collection->content); + } + } + + public function testLineLengthCanBeSpecified() + { + $encoder = $this->_getEncoder('7bit'); + + $chars = array(); + for ($i = 0; $i < 50; $i++) { + $chars[] = 'a'; + } + $input = implode(' ', $chars); //99 chars long + + $this->assertEquals( + 'a a a a a a a a a a a a a a a a a a a a a a a a a '."\r\n".//50 * + 'a a a a a a a a a a a a a a a a a a a a a a a a a', //99 + $encoder->encodeString($input, 0, 50), + '%s: Lines should be wrapped at 50 chars' + ); + } + + public function testLineLengthCanBeSpecifiedInByteStream() + { + $encoder = $this->_getEncoder('7bit'); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + + for ($i = 0; $i < 50; $i++) { + $os->shouldReceive('read') + ->once() + ->andReturn('a '); + } + + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is, 0, 50); + $this->assertEquals( + str_repeat('a ', 25)."\r\n".str_repeat('a ', 25), + $collection->content + ); + } + + public function testencodeStringGeneratesCorrectCrlf() + { + $encoder = $this->_getEncoder('7bit', true); + $this->assertEquals("a\r\nb", $encoder->encodeString("a\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\nb", $encoder->encodeString("a\nb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\r\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\nb"), + '%s: Line endings should be standardized' + ); + } + + public function crlfProvider() + { + return array( + array("\r", "a\r\nb"), + array("\n", "a\r\nb"), + array("\n\r", "a\r\n\r\nb"), + array("\n\n", "a\r\n\r\nb"), + array("\r\r", "a\r\n\r\nb"), + ); + } + + /** + * @dataProvider crlfProvider + */ + public function testCanonicEncodeByteStreamGeneratesCorrectCrlf($test, $expected) + { + $encoder = $this->_getEncoder('7bit', true); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('a'); + $os->shouldReceive('read') + ->once() + ->andReturn($test); + $os->shouldReceive('read') + ->once() + ->andReturn('b'); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is); + $this->assertEquals($expected, $collection->content); + } + + // -- Private helpers + + private function _getEncoder($name, $canonical = false) + { + return new Swift_Mime_ContentEncoder_PlainContentEncoder($name, $canonical); + } + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php new file mode 100644 index 000000000..66fa8f389 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php @@ -0,0 +1,496 @@ +_createCharacterStream(true) + ); + $this->assertEquals('quoted-printable', $encoder->getName()); + } + + /* -- RFC 2045, 6.7 -- + (1) (General 8bit representation) Any octet, except a CR or + LF that is part of a CRLF line break of the canonical + (standard) form of the data being encoded, may be + represented by an "=" followed by a two digit + hexadecimal representation of the octet's value. The + digits of the hexadecimal alphabet, for this purpose, + are "0123456789ABCDEF". Uppercase letters must be + used; lowercase letters are not allowed. Thus, for + example, the decimal value 12 (US-ASCII form feed) can + be represented by "=0C", and the decimal value 61 (US- + ASCII EQUAL SIGN) can be represented by "=3D". This + rule must be followed except when the following rules + allow an alternative encoding. + */ + + public function testPermittedCharactersAreNotEncoded() + { + /* -- RFC 2045, 6.7 -- + (2) (Literal representation) Octets with decimal values of + 33 through 60 inclusive, and 62 through 126, inclusive, + MAY be represented as the US-ASCII characters which + correspond to those octets (EXCLAMATION POINT through + LESS THAN, and GREATER THAN through TILDE, + respectively). + */ + + foreach (array_merge(range(33, 60), range(62, 126)) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertIdenticalBinary($char, $collection->content); + } + } + + public function testLinearWhiteSpaceAtLineEndingIsEncoded() + { + /* -- RFC 2045, 6.7 -- + (3) (White Space) Octets with values of 9 and 32 MAY be + represented as US-ASCII TAB (HT) and SPACE characters, + respectively, but MUST NOT be so represented at the end + of an encoded line. Any TAB (HT) or SPACE characters + on an encoded line MUST thus be followed on that line + by a printable character. In particular, an "=" at the + end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE + characters. It follows that an octet with decimal + value 9 or 32 appearing at the end of an encoded line + must be represented according to Rule #1. This rule is + necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to + another, or perform a portion of such transfers) are + known to pad lines of text with SPACEs, and others are + known to remove "white space" characters from the end + of a line. Therefore, when decoding a Quoted-Printable + body, any trailing white space on a line must be + deleted, as it will necessarily have been added by + intermediate transport agents. + */ + + $HT = chr(0x09); //9 + $SPACE = chr(0x20); //32 + + //HT + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + + $this->assertEquals("a\t=09\r\nb", $collection->content); + + //SPACE + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + + $this->assertEquals("a =20\r\nb", $collection->content); + } + + public function testCRLFIsLeftAlone() + { + /* + (4) (Line Breaks) A line break in a text body, represented + as a CRLF sequence in the text canonical form, must be + represented by a (RFC 822) line break, which is also a + CRLF sequence, in the Quoted-Printable encoding. Since + the canonical representation of media types other than + text do not generally include the representation of + line breaks as CRLF sequences, no hard line breaks + (i.e. line breaks that are intended to be meaningful + and to be displayed to the user) can occur in the + quoted-printable encoding of such types. Sequences + like "=0D", "=0A", "=0A=0D" and "=0D=0A" will routinely + appear in non-text data represented in quoted- + printable, of course. + + Note that many implementations may elect to encode the + local representation of various content types directly + rather than converting to canonical form first, + encoding, and then converting back to local + representation. In particular, this may apply to plain + text material on systems that use newline conventions + other than a CRLF terminator sequence. Such an + implementation optimization is permissible, but only + when the combined canonicalization-encoding step is + equivalent to performing the three steps separately. + */ + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('c'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals("a\r\nb\r\nc\r\n", $collection->content); + } + + public function testLinesLongerThan76CharactersAreSoftBroken() + { + /* + (5) (Soft Line Breaks) The Quoted-Printable encoding + REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded + with the Quoted-Printable encoding, "soft" line breaks + must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ("soft") + line break in the encoded text. + */ + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(str_repeat('a', 75)."=\r\n".str_repeat('a', 66), $collection->content); + } + + public function testMaxLineLengthCanBeSpecified() + { + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 100; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is, 0, 54); + $this->assertEquals(str_repeat('a', 53)."=\r\n".str_repeat('a', 48), $collection->content); + } + + public function testBytesBelowPermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(0, 32) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', $ordinal), $collection->content); + } + } + + public function testDecimalByte61IsEncoded() + { + /* + According to Rule (1 & 2) + */ + + $char = chr(61); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(61)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', 61), $collection->content); + } + + public function testBytesAbovePermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(127, 255) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', $ordinal), $collection->content); + } + } + + public function testFirstLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is, 22); + $this->assertEquals( + str_repeat('a', 53)."=\r\n".str_repeat('a', 75)."=\r\n".str_repeat('a', 13), + $collection->content + ); + } + + public function testObserverInterfaceCanChangeCharset() + { + $stream = $this->_createCharacterStream(); + $stream->shouldReceive('setCharacterSet') + ->once() + ->with('windows-1252'); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($stream); + $encoder->charsetChanged('windows-1252'); + } + + // -- Creation Methods + + private function _createCharacterStream($stub = false) + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } + + private function _createEncoder($charStream) + { + return new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream); + } + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php new file mode 100644 index 000000000..f4c3ac898 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php @@ -0,0 +1,57 @@ +_createEmbeddedFile($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_RELATED, $file->getNestingLevel() + ); + } + + public function testIdIsAutoGenerated() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addIdHeader') + ->once() + ->with('Content-ID', '/^.*?@.*?$/D'); + + $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testDefaultDispositionIsInline() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'inline'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + // -- Private helpers + + protected function _createAttachment($headers, $encoder, $cache, $mimeTypes = array()) + { + return $this->_createEmbeddedFile($headers, $encoder, $cache, $mimeTypes); + } + + private function _createEmbeddedFile($headers, $encoder, $cache) + { + return new Swift_Mime_EmbeddedFile($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php new file mode 100644 index 000000000..35801556e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php @@ -0,0 +1,13 @@ +assertEquals('B', $encoder->getName()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php new file mode 100644 index 000000000..54a792a67 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php @@ -0,0 +1,223 @@ +_createEncoder( + $this->_createCharacterStream(true) + ); + $this->assertEquals('Q', $encoder->getName()); + } + + public function testSpaceAndTabNeverAppear() + { + /* -- RFC 2047, 4. + Only a subset of the printable ASCII characters may be used in + 'encoded-text'. Space and tab characters are not allowed, so that + the beginning and end of an 'encoded-word' are obvious. + */ + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(6) + ->andReturn(array(ord('a')), array(0x20), array(0x09), array(0x20), array(ord('b')), false); + + $encoder = $this->_createEncoder($charStream); + $this->assertNotRegExp('~[ \t]~', $encoder->encodeString("a \t b"), + '%s: encoded-words in headers cannot contain LWSP as per RFC 2047.' + ); + } + + public function testSpaceIsRepresentedByUnderscore() + { + /* -- RFC 2047, 4.2. + (2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be + represented as "_" (underscore, ASCII 95.). (This character may + not pass through some internetwork mail gateways, but its use + will greatly enhance readability of "Q" encoded data with mail + readers that do not support this encoding.) Note that the "_" + always represents hexadecimal 20, even if the SPACE character + occupies a different code position in the character set in use. + */ + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('a_b', $encoder->encodeString('a b'), + '%s: Spaces can be represented by more readable underscores as per RFC 2047.' + ); + } + + public function testEqualsAndQuestionAndUnderscoreAreEncoded() + { + /* -- RFC 2047, 4.2. + (3) 8-bit values which correspond to printable ASCII characters other + than "=", "?", and "_" (underscore), MAY be represented as those + characters. (But see section 5 for restrictions.) In + particular, SPACE and TAB MUST NOT be represented as themselves + within encoded words. + */ + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('='))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('?'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('_'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('=3D=3F=5F', $encoder->encodeString('=?_'), + '%s: Chars =, ? and _ (underscore) may not appear as per RFC 2047.' + ); + } + + public function testParensAndQuotesAreEncoded() + { + /* -- RFC 2047, 5 (2). + A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT + contain the characters "(", ")" or " + */ + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('('))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('"'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord(')'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('=28=22=29', $encoder->encodeString('(")'), + '%s: Chars (, " (DQUOTE) and ) may not appear as per RFC 2047.' + ); + } + + public function testOnlyCharactersAllowedInPhrasesAreUsed() + { + /* -- RFC 2047, 5. + (3) As a replacement for a 'word' entity within a 'phrase', for example, + one that precedes an address in a From, To, or Cc header. The ABNF + definition for 'phrase' from RFC 822 thus becomes: + + phrase = 1*( encoded-word / word ) + + In this case the set of characters that may be used in a "Q"-encoded + 'encoded-word' is restricted to: . An 'encoded-word' that appears within a + 'phrase' MUST be separated from any adjacent 'word', 'text' or + 'special' by 'linear-white-space'. + */ + + $allowedBytes = array_merge( + range(ord('a'), ord('z')), range(ord('A'), ord('Z')), + range(ord('0'), ord('9')), + array(ord('!'), ord('*'), ord('+'), ord('-'), ord('/')) + ); + + foreach (range(0x00, 0xFF) as $byte) { + $char = pack('C', $byte); + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($byte)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $encodedChar = $encoder->encodeString($char); + + if (in_array($byte, $allowedBytes)) { + $this->assertEquals($char, $encodedChar, + '%s: Character '.$char.' should not be encoded.' + ); + } elseif (0x20 == $byte) { + //Special case + $this->assertEquals('_', $encodedChar, + '%s: Space character should be replaced.' + ); + } else { + $this->assertEquals(sprintf('=%02X', $byte), $encodedChar, + '%s: Byte '.$byte.' should be encoded.' + ); + } + } + } + + public function testEqualsNeverAppearsAtEndOfLine() + { + /* -- RFC 2047, 5 (3). + The 'encoded-text' in an 'encoded-word' must be self-contained; + 'encoded-text' MUST NOT be continued from one 'encoded-word' to + another. This implies that the 'encoded-text' portion of a "B" + 'encoded-word' will be a multiple of 4 characters long; for a "Q" + 'encoded-word', any "=" character that appears in the 'encoded-text' + portion will be followed by two hexadecimal characters. + */ + + $input = str_repeat('a', 140); + + $charStream = $this->_createCharacterStream(); + + $output = ''; + $seq = 0; + for (; $seq < 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (75 == $seq) { + $output .= "\r\n"; // =\r\n + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input)); + } + + // -- Creation Methods + + private function _createEncoder($charStream) + { + return new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream); + } + + private function _createCharacterStream($stub = false) + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php new file mode 100644 index 000000000..1822ea688 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php @@ -0,0 +1,69 @@ +_getHeader('Date'); + $this->assertEquals(Swift_Mime_Header::TYPE_DATE, $header->getFieldType()); + } + + public function testGetTimestamp() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertSame($timestamp, $header->getTimestamp()); + } + + public function testTimestampCanBeSetBySetter() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertSame($timestamp, $header->getTimestamp()); + } + + public function testIntegerTimestampIsConvertedToRfc2822Date() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals(date('r', $timestamp), $header->getFieldBody()); + } + + public function testSetBodyModel() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setFieldBodyModel($timestamp); + $this->assertEquals(date('r', $timestamp), $header->getFieldBody()); + } + + public function testGetBodyModel() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals($timestamp, $header->getFieldBodyModel()); + } + + public function testToString() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals('Date: '.date('r', $timestamp)."\r\n", + $header->toString() + ); + } + + private function _getHeader($name) + { + return new Swift_Mime_Headers_DateHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php new file mode 100644 index 000000000..93b3f6092 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php @@ -0,0 +1,189 @@ +_getHeader('Message-ID'); + $this->assertEquals(Swift_Mime_Header::TYPE_ID, $header->getFieldType()); + } + + public function testValueMatchesMsgIdSpec() + { + /* -- RFC 2822, 3.6.4. + message-id = "Message-ID:" msg-id CRLF + + in-reply-to = "In-Reply-To:" 1*msg-id CRLF + + references = "References:" 1*msg-id CRLF + + msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] + + id-left = dot-atom-text / no-fold-quote / obs-id-left + + id-right = dot-atom-text / no-fold-literal / obs-id-right + + no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE + + no-fold-literal = "[" *(dtext / quoted-pair) "]" + */ + + $header = $this->_getHeader('Message-ID'); + $header->setId('id-left@id-right'); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testIdCanBeRetrievedVerbatim() + { + $header = $this->_getHeader('Message-ID'); + $header->setId('id-left@id-right'); + $this->assertEquals('id-left@id-right', $header->getId()); + } + + public function testMultipleIdsCanBeSet() + { + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals(array('a@b', 'x@y'), $header->getIds()); + } + + public function testSettingMultipleIdsProducesAListValue() + { + /* -- RFC 2822, 3.6.4. + The "References:" and "In-Reply-To:" field each contain one or more + unique message identifiers, optionally separated by CFWS. + + .. SNIP .. + + in-reply-to = "In-Reply-To:" 1*msg-id CRLF + + references = "References:" 1*msg-id CRLF + */ + + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals(' ', $header->getFieldBody()); + } + + public function testIdLeftCanBeQuoted() + { + /* -- RFC 2822, 3.6.4. + id-left = dot-atom-text / no-fold-quote / obs-id-left + */ + + $header = $this->_getHeader('References'); + $header->setId('"ab"@c'); + $this->assertEquals('"ab"@c', $header->getId()); + $this->assertEquals('<"ab"@c>', $header->getFieldBody()); + } + + public function testIdLeftCanContainAnglesAsQuotedPairs() + { + /* -- RFC 2822, 3.6.4. + no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE + */ + + $header = $this->_getHeader('References'); + $header->setId('"a\\<\\>b"@c'); + $this->assertEquals('"a\\<\\>b"@c', $header->getId()); + $this->assertEquals('<"a\\<\\>b"@c>', $header->getFieldBody()); + } + + public function testIdLeftCanBeDotAtom() + { + $header = $this->_getHeader('References'); + $header->setId('a.b+&%$.c@d'); + $this->assertEquals('a.b+&%$.c@d', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testInvalidIdLeftThrowsException() + { + try { + $header = $this->_getHeader('References'); + $header->setId('a b c@d'); + $this->fail( + 'Exception should be thrown since "a b c" is not valid id-left.' + ); + } catch (Exception $e) { + } + } + + public function testIdRightCanBeDotAtom() + { + /* -- RFC 2822, 3.6.4. + id-right = dot-atom-text / no-fold-literal / obs-id-right + */ + + $header = $this->_getHeader('References'); + $header->setId('a@b.c+&%$.d'); + $this->assertEquals('a@b.c+&%$.d', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testIdRightCanBeLiteral() + { + /* -- RFC 2822, 3.6.4. + no-fold-literal = "[" *(dtext / quoted-pair) "]" + */ + + $header = $this->_getHeader('References'); + $header->setId('a@[1.2.3.4]'); + $this->assertEquals('a@[1.2.3.4]', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testInvalidIdRightThrowsException() + { + try { + $header = $this->_getHeader('References'); + $header->setId('a@b c d'); + $this->fail( + 'Exception should be thrown since "b c d" is not valid id-right.' + ); + } catch (Exception $e) { + } + } + + public function testMissingAtSignThrowsException() + { + /* -- RFC 2822, 3.6.4. + msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] + */ + + try { + $header = $this->_getHeader('References'); + $header->setId('abc'); + $this->fail( + 'Exception should be thrown since "abc" is does not contain @.' + ); + } catch (Exception $e) { + } + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Message-ID'); + $header->setFieldBodyModel('a@b'); + $this->assertEquals(array('a@b'), $header->getIds()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Message-ID'); + $header->setId('a@b'); + $this->assertEquals(array('a@b'), $header->getFieldBodyModel()); + } + + public function testStringValue() + { + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals('References: '."\r\n", $header->toString()); + } + + private function _getHeader($name) + { + return new Swift_Mime_Headers_IdentificationHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php new file mode 100644 index 000000000..0713ff4e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php @@ -0,0 +1,327 @@ +_getHeader('To', $this->_getEncoder('Q', true)); + $this->assertEquals(Swift_Mime_Header::TYPE_MAILBOX, $header->getFieldType()); + } + + public function testMailboxIsSetForAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org'), + $header->getNameAddressStrings() + ); + } + + public function testMailboxIsRenderedForNameAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); + $this->assertEquals( + array('Chris Corbyn '), $header->getNameAddressStrings() + ); + } + + public function testAddressCanBeReturnedForAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); + } + + public function testAddressCanBeReturnedForNameAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); + $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); + } + + public function testQuotesInNameAreQuoted() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, "DHE"', + )); + $this->assertEquals( + array('"Chris Corbyn, \"DHE\"" '), + $header->getNameAddressStrings() + ); + } + + public function testEscapeCharsInNameAreQuoted() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, \\escaped\\', + )); + $this->assertEquals( + array('"Chris Corbyn, \\\\escaped\\\\" '), + $header->getNameAddressStrings() + ); + } + + public function testGetMailboxesReturnsNameValuePairs() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, DHE', + )); + $this->assertEquals( + array('chris@swiftmailer.org' => 'Chris Corbyn, DHE'), $header->getNameAddresses() + ); + } + + public function testMultipleAddressesCanBeSetAndFetched() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org', + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testMultipleAddressesAsMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org', + )); + $this->assertEquals( + array('chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null), + $header->getNameAddresses() + ); + } + + public function testMultipleAddressesAsMailboxStrings() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org', + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getNameAddressStrings() + ); + } + + public function testMultipleNamedMailboxesReturnsMultipleAddresses() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testMultipleNamedMailboxesReturnsMultipleMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + ), + $header->getNameAddresses() + ); + } + + public function testMultipleMailboxesProducesMultipleMailboxStrings() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals(array( + 'Chris Corbyn ', + 'Mark Corbyn ', + ), + $header->getNameAddressStrings() + ); + } + + public function testSetAddressesOverwritesAnyMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals( + array('chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', ), + $header->getNameAddresses() + ); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + + $header->setAddresses(array('chris@swiftmailer.org', 'mark@swiftmailer.org')); + + $this->assertEquals( + array('chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null), + $header->getNameAddresses() + ); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testNameIsEncodedIfNonAscii() + { + $name = 'C'.pack('C', 0x8F).'rbyn'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('C=8Frbyn'); + + $header = $this->_getHeader('From', $encoder); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris '.$name)); + + $addresses = $header->getNameAddressStrings(); + $this->assertEquals( + 'Chris =?'.$this->_charset.'?Q?C=8Frbyn?= ', + array_shift($addresses) + ); + } + + public function testEncodingLineLengthCalculations() + { + /* -- RFC 2047, 2. + An 'encoded-word' may not be more than 75 characters long, including + 'charset', 'encoding', 'encoded-text', and delimiters. + */ + + $name = 'C'.pack('C', 0x8F).'rbyn'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('C=8Frbyn'); + + $header = $this->_getHeader('From', $encoder); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris '.$name)); + + $header->getNameAddressStrings(); + } + + public function testGetValueReturnsMailboxStringValue() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + )); + $this->assertEquals( + 'Chris Corbyn ', $header->getFieldBody() + ); + } + + public function testGetValueReturnsMailboxStringValueForMultipleMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals( + 'Chris Corbyn , Mark Corbyn ', + $header->getFieldBody() + ); + } + + public function testRemoveAddressesWithSingleValue() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $header->removeAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testRemoveAddressesWithList() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $header->removeAddresses( + array('chris@swiftmailer.org', 'mark@swiftmailer.org') + ); + $this->assertEquals(array(), $header->getAddresses()); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setFieldBodyModel('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org' => null), $header->getNameAddresses()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array('chris@swiftmailer.org')); + $this->assertEquals(array('chris@swiftmailer.org' => null), $header->getFieldBodyModel()); + } + + public function testToString() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn', + )); + $this->assertEquals( + 'From: Chris Corbyn , '. + 'Mark Corbyn '."\r\n", + $header->toString() + ); + } + + private function _getHeader($name, $encoder) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $encoder, new Swift_Mime_Grammar()); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php new file mode 100644 index 000000000..0f3fe1454 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php @@ -0,0 +1,400 @@ +_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $this->assertEquals(Swift_Mime_Header::TYPE_PARAMETERIZED, $header->getFieldType()); + } + + public function testValueIsReturnedVerbatim() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $this->assertEquals('text/plain', $header->getValue()); + } + + public function testParametersAreAppended() + { + /* -- RFC 2045, 5.1 + parameter := attribute "=" value + + attribute := token + ; Matching of attributes + ; is ALWAYS case-insensitive. + + value := token / quoted-string + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" / + "," / ";" / ":" / "\" / <"> + "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + */ + + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $header->setParameters(array('charset' => 'utf-8')); + $this->assertEquals('text/plain; charset=utf-8', $header->getFieldBody()); + } + + public function testSpaceInParamResultsInQuotedString() + { + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => 'my file.txt')); + $this->assertEquals('attachment; filename="my file.txt"', + $header->getFieldBody() + ); + } + + public function testLongParamsAreBrokenIntoMultipleAttributeStrings() + { + /* -- RFC 2231, 3. + The asterisk character ("*") followed + by a decimal count is employed to indicate that multiple parameters + are being used to encapsulate a single parameter value. The count + starts at 0 and increments by 1 for each subsequent section of the + parameter value. Decimal values are used and neither leading zeroes + nor gaps in the sequence are allowed. + + The original parameter value is recovered by concatenating the + various sections of the parameter, in order. For example, the + content-type field + + Content-Type: message/external-body; access-type=URL; + URL*0="ftp://"; + URL*1="cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + is semantically identical to + + Content-Type: message/external-body; access-type=URL; + URL="ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + Note that quotes around parameter values are part of the value + syntax; they are NOT part of the value itself. Furthermore, it is + explicitly permitted to have a mixture of quoted and unquoted + continuation fields. + */ + + $value = str_repeat('a', 180); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), 63, \Mockery::any()) + ->andReturn(str_repeat('a', 63)."\r\n". + str_repeat('a', 63)."\r\n".str_repeat('a', 54)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $this->assertEquals( + 'attachment; '. + 'filename*0*=utf-8\'\''.str_repeat('a', 63).";\r\n ". + 'filename*1*='.str_repeat('a', 63).";\r\n ". + 'filename*2*='.str_repeat('a', 54), + $header->getFieldBody() + ); + } + + public function testEncodedParamDataIncludesCharsetAndLanguage() + { + /* -- RFC 2231, 4. + Asterisks ("*") are reused to provide the indicator that language and + character set information is present and encoding is being used. A + single quote ("'") is used to delimit the character set and language + information at the beginning of the parameter value. Percent signs + ("%") are used as the encoding flag, which agrees with RFC 2047. + + Specifically, an asterisk at the end of a parameter name acts as an + indicator that character set and language information may appear at + the beginning of the parameter value. A single quote is used to + separate the character set, language, and actual value information in + the parameter value string, and an percent sign is used to flag + octets encoded in hexadecimal. For example: + + Content-Type: application/x-stuff; + title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A + + Note that it is perfectly permissible to leave either the character + set or language field blank. Note also that the single quote + delimiters MUST be present even when one of the field values is + omitted. + */ + + $value = str_repeat('a', 20).pack('C', 0x8F).str_repeat('a', 10); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, 12, 62, \Mockery::any()) + ->andReturn(str_repeat('a', 20).'%8F'.str_repeat('a', 10)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $header->setLanguage($this->_lang); + $this->assertEquals( + 'attachment; filename*='.$this->_charset."'".$this->_lang."'". + str_repeat('a', 20).'%8F'.str_repeat('a', 10), + $header->getFieldBody() + ); + } + + public function testMultipleEncodedParamLinesAreFormattedCorrectly() + { + /* -- RFC 2231, 4.1. + Character set and language information may be combined with the + parameter continuation mechanism. For example: + + Content-Type: application/x-stuff + title*0*=us-ascii'en'This%20is%20even%20more%20 + title*1*=%2A%2A%2Afun%2A%2A%2A%20 + title*2="isn't it!" + + Note that: + + (1) Language and character set information only appear at + the beginning of a given parameter value. + + (2) Continuations do not provide a facility for using more + than one character set or language in the same + parameter value. + + (3) A value presented using multiple continuations may + contain a mixture of encoded and unencoded segments. + + (4) The first segment of a continuation MUST be encoded if + language and character set information are given. + + (5) If the first segment of a continued parameter value is + encoded the language and character set field delimiters + MUST be present even when the fields are left blank. + */ + + $value = str_repeat('a', 20).pack('C', 0x8F).str_repeat('a', 60); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, 12, 62, \Mockery::any()) + ->andReturn(str_repeat('a', 20).'%8F'.str_repeat('a', 28)."\r\n". + str_repeat('a', 32)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $header->setLanguage($this->_lang); + $this->assertEquals( + 'attachment; filename*0*='.$this->_charset."'".$this->_lang."'". + str_repeat('a', 20).'%8F'.str_repeat('a', 28).";\r\n ". + 'filename*1*='.str_repeat('a', 32), + $header->getFieldBody() + ); + } + + public function testToString() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/html'); + $header->setParameters(array('charset' => 'utf-8')); + $this->assertEquals('Content-Type: text/html; charset=utf-8'."\r\n", + $header->toString() + ); + } + + public function testValueCanBeEncodedIfNonAscii() + { + $value = 'fo'.pack('C', 0x8F).'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $this->_getParameterEncoder(true)); + $header->setValue($value); + $header->setParameters(array('lookslike' => 'foobar')); + $this->assertEquals('X-Foo: =?utf-8?Q?fo=8Fbar?=; lookslike=foobar'."\r\n", + $header->toString() + ); + } + + public function testValueAndParamCanBeEncodedIfNonAscii() + { + $value = 'fo'.pack('C', 0x8F).'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $paramEncoder = $this->_getParameterEncoder(); + $paramEncoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo%8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $paramEncoder); + $header->setValue($value); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: =?utf-8?Q?fo=8Fbar?=; says*=utf-8''fo%8Fbar\r\n", + $header->toString() + ); + } + + public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() + { + $value = 'fo'.pack('C', 0x8F).'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, null); + $header->setValue('bar'); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: bar; says=\"=?utf-8?Q?fo=8Fbar?=\"\r\n", + $header->toString() + ); + } + + public function testLanguageInformationAppearsInEncodedWords() + { + /* -- RFC 2231, 5. + 5. Language specification in Encoded Words + + RFC 2047 provides support for non-US-ASCII character sets in RFC 822 + message header comments, phrases, and any unstructured text field. + This is done by defining an encoded word construct which can appear + in any of these places. Given that these are fields intended for + display, it is sometimes necessary to associate language information + with encoded words as well as just the character set. This + specification extends the definition of an encoded word to allow the + inclusion of such information. This is simply done by suffixing the + character set specification with an asterisk followed by the language + tag. For example: + + From: =?US-ASCII*EN?Q?Keith_Moore?= + */ + + $value = 'fo'.pack('C', 0x8F).'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $paramEncoder = $this->_getParameterEncoder(); + $paramEncoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo%8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $paramEncoder); + $header->setLanguage('en'); + $header->setValue($value); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: =?utf-8*en?Q?fo=8Fbar?=; says*=utf-8'en'fo%8Fbar\r\n", + $header->toString() + ); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setFieldBodyModel('text/html'); + $this->assertEquals('text/html', $header->getValue()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $this->assertEquals('text/plain', $header->getFieldBodyModel()); + } + + public function testSetParameter() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setParameters(array('charset' => 'utf-8', 'delsp' => 'yes')); + $header->setParameter('delsp', 'no'); + $this->assertEquals(array('charset' => 'utf-8', 'delsp' => 'no'), + $header->getParameters() + ); + } + + public function testGetParameter() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setParameters(array('charset' => 'utf-8', 'delsp' => 'yes')); + $this->assertEquals('utf-8', $header->getParameter('charset')); + } + + // -- Private helper + + private function _getHeader($name, $encoder, $paramEncoder) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $encoder, + $paramEncoder, new Swift_Mime_Grammar() + ); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getHeaderEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } + + private function _getParameterEncoder($stub = false) + { + return $this->getMockery('Swift_Encoder')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php new file mode 100644 index 000000000..a9f35e9de --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php @@ -0,0 +1,77 @@ +_getHeader('Return-Path'); + $this->assertEquals(Swift_Mime_Header::TYPE_PATH, $header->getFieldType()); + } + + public function testSingleAddressCanBeSetAndFetched() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('chris@swiftmailer.org', $header->getAddress()); + } + + public function testAddressMustComplyWithRfc2822() + { + try { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chr is@swiftmailer.org'); + $this->fail('Addresses not valid according to RFC 2822 addr-spec grammar must be rejected.'); + } catch (Exception $e) { + } + } + + public function testValueIsAngleAddrWithValidAddress() + { + /* -- RFC 2822, 3.6.7. + + return = "Return-Path:" path CRLF + + path = ([CFWS] "<" ([CFWS] / addr-spec) ">" [CFWS]) / + obs-path + */ + + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testValueIsEmptyAngleBracketsIfEmptyAddressSet() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress(''); + $this->assertEquals('<>', $header->getFieldBody()); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Return-Path'); + $header->setFieldBodyModel('foo@bar.tld'); + $this->assertEquals('foo@bar.tld', $header->getAddress()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('foo@bar.tld'); + $this->assertEquals('foo@bar.tld', $header->getFieldBodyModel()); + } + + public function testToString() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('Return-Path: '."\r\n", + $header->toString() + ); + } + + private function _getHeader($name) + { + return new Swift_Mime_Headers_PathHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php new file mode 100644 index 000000000..2e1dc8cab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php @@ -0,0 +1,355 @@ +_getHeader('Subject', $this->_getEncoder('Q', true)); + $this->assertEquals(Swift_Mime_Header::TYPE_TEXT, $header->getFieldType()); + } + + public function testGetNameReturnsNameVerbatim() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $this->assertEquals('Subject', $header->getFieldName()); + } + + public function testGetValueReturnsValueVerbatim() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('Test'); + $this->assertEquals('Test', $header->getValue()); + } + + public function testBasicStructureIsKeyValuePair() + { + /* -- RFC 2822, 2.2 + Header fields are lines composed of a field name, followed by a colon + (":"), followed by a field body, and terminated by CRLF. + */ + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('Test'); + $this->assertEquals('Subject: Test'."\r\n", $header->toString()); + } + + public function testLongHeadersAreFoldedAtWordBoundary() + { + /* -- RFC 2822, 2.2.3 + Each header field is logically a single line of characters comprising + the field name, the colon, and the field body. For convenience + however, and to deal with the 998/78 character limitations per line, + the field body portion of a header field can be split into a multiple + line representation; this is called "folding". The general rule is + that wherever this standard allows for folding white space (not + simply WSP characters), a CRLF may be inserted before any WSP. + */ + + $value = 'The quick brown fox jumped over the fence, he was a very very '. + 'scary brown fox with a bushy tail'; + $header = $this->_getHeader('X-Custom-Header', + $this->_getEncoder('Q', true) + ); + $header->setValue($value); + $header->setMaxLineLength(78); //A safe [RFC 2822, 2.2.3] default + /* + X-Custom-Header: The quick brown fox jumped over the fence, he was a very very + scary brown fox with a bushy tail + */ + $this->assertEquals( + 'X-Custom-Header: The quick brown fox jumped over the fence, he was a'. + ' very very'."\r\n".//Folding + ' scary brown fox with a bushy tail'."\r\n", + $header->toString(), '%s: The header should have been folded at 78th char' + ); + } + + public function testPrintableAsciiOnlyAppearsInHeaders() + { + /* -- RFC 2822, 2.2. + A field name MUST be composed of printable US-ASCII characters (i.e., + characters that have values between 33 and 126, inclusive), except + colon. A field body may be composed of any US-ASCII characters, + except for CR and LF. + */ + + $nonAsciiChar = pack('C', 0x8F); + $header = $this->_getHeader('X-Test', $this->_getEncoder('Q', true)); + $header->setValue($nonAsciiChar); + $this->assertRegExp( + '~^[^:\x00-\x20\x80-\xFF]+: [^\x80-\xFF\r\n]+\r\n$~s', + $header->toString() + ); + } + + public function testEncodedWordsFollowGeneralStructure() + { + /* -- RFC 2047, 1. + Generally, an "encoded-word" is a sequence of printable ASCII + characters that begins with "=?", ends with "?=", and has two "?"s in + between. + */ + + $nonAsciiChar = pack('C', 0x8F); + $header = $this->_getHeader('X-Test', $this->_getEncoder('Q', true)); + $header->setValue($nonAsciiChar); + $this->assertRegExp( + '~^X-Test: \=?.*?\?.*?\?.*?\?=\r\n$~s', + $header->toString() + ); + } + + public function testEncodedWordIncludesCharsetAndEncodingMethodAndText() + { + /* -- RFC 2047, 2. + An 'encoded-word' is defined by the following ABNF grammar. The + notation of RFC 822 is used, with the exception that white space + characters MUST NOT appear between components of an 'encoded-word'. + + encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" + */ + + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('=8F'); + + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + $this->assertEquals( + 'X-Test: =?'.$this->_charset.'?Q?=8F?='."\r\n", + $header->toString() + ); + } + + public function testEncodedWordsAreUsedToEncodedNonPrintableAscii() + { + //SPACE and TAB permitted + $nonPrintableBytes = array_merge( + range(0x00, 0x08), range(0x10, 0x19), array(0x7F) + ); + + foreach ($nonPrintableBytes as $byte) { + $char = pack('C', $byte); + $encodedChar = sprintf('=%02X', $byte); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn($encodedChar); + + $header = $this->_getHeader('X-A', $encoder); + $header->setValue($char); + + $this->assertEquals( + 'X-A: =?'.$this->_charset.'?Q?'.$encodedChar.'?='."\r\n", + $header->toString(), '%s: Non-printable ascii should be encoded' + ); + } + } + + public function testEncodedWordsAreUsedToEncode8BitOctets() + { + $_8BitBytes = range(0x80, 0xFF); + + foreach ($_8BitBytes as $byte) { + $char = pack('C', $byte); + $encodedChar = sprintf('=%02X', $byte); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn($encodedChar); + + $header = $this->_getHeader('X-A', $encoder); + $header->setValue($char); + + $this->assertEquals( + 'X-A: =?'.$this->_charset.'?Q?'.$encodedChar.'?='."\r\n", + $header->toString(), '%s: 8-bit octets should be encoded' + ); + } + } + + public function testEncodedWordsAreNoMoreThan75CharsPerLine() + { + /* -- RFC 2047, 2. + An 'encoded-word' may not be more than 75 characters long, including + 'charset', 'encoding', 'encoded-text', and delimiters. + + ... SNIP ... + + While there is no limit to the length of a multiple-line header + field, each line of a header field that contains one or more + 'encoded-word's is limited to 76 characters. + */ + + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('=8F'); + //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + + //* X-Test: is 8 chars + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + + $this->assertEquals( + 'X-Test: =?'.$this->_charset.'?Q?=8F?='."\r\n", + $header->toString() + ); + } + + public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() + { + /* --RFC 2047, 2. + If it is desirable to encode more text than will fit in an 'encoded-word' of + 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may + be used. + */ + + //Note the Mock does NOT return 8F encoded, the 8F merely triggers + // encoding for the sake of testing + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, 8, 63, \Mockery::any()) + ->andReturn('line_one_here'."\r\n".'line_two_here'); + + //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + + //* X-Test: is 8 chars + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + + $this->assertEquals( + 'X-Test: =?'.$this->_charset.'?Q?line_one_here?='."\r\n". + ' =?'.$this->_charset.'?Q?line_two_here?='."\r\n", + $header->toString() + ); + } + + public function testAdjacentWordsAreEncodedTogether() + { + /* -- RFC 2047, 5 (1) + Ordinary ASCII text and 'encoded-word's may appear together in the + same header field. However, an 'encoded-word' that appears in a + header field defined as '*text' MUST be separated from any adjacent + 'encoded-word' or 'text' by 'linear-white-space'. + + -- RFC 2047, 2. + IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's + by an RFC 822 parser. As a consequence, unencoded white space + characters (such as SPACE and HTAB) are FORBIDDEN within an + 'encoded-word'. + */ + + //It would be valid to encode all words needed, however it's probably + // easiest to encode the longest amount required at a time + + $word = 'w'.pack('C', 0x8F).'rd'; + $text = 'start '.$word.' '.$word.' then end '.$word; + // 'start', ' word word', ' and end', ' word' + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($word.' '.$word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('w=8Frd_w=8Frd'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('w=8Frd'); + + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($text); + + $headerString = $header->toString(); + + $this->assertEquals('X-Test: start =?'.$this->_charset.'?Q?'. + 'w=8Frd_w=8Frd?= then end =?'.$this->_charset.'?Q?'. + 'w=8Frd?='."\r\n", $headerString, + '%s: Adjacent encoded words should appear grouped with WSP encoded' + ); + } + + public function testLanguageInformationAppearsInEncodedWords() + { + /* -- RFC 2231, 5. + 5. Language specification in Encoded Words + + RFC 2047 provides support for non-US-ASCII character sets in RFC 822 + message header comments, phrases, and any unstructured text field. + This is done by defining an encoded word construct which can appear + in any of these places. Given that these are fields intended for + display, it is sometimes necessary to associate language information + with encoded words as well as just the character set. This + specification extends the definition of an encoded word to allow the + inclusion of such information. This is simply done by suffixing the + character set specification with an asterisk followed by the language + tag. For example: + + From: =?US-ASCII*EN?Q?Keith_Moore?= + */ + + $value = 'fo'.pack('C', 0x8F).'bar'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('Subject', $encoder); + $header->setLanguage('en'); + $header->setValue($value); + $this->assertEquals("Subject: =?utf-8*en?Q?fo=8Fbar?=\r\n", + $header->toString() + ); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setFieldBodyModel('test'); + $this->assertEquals('test', $header->getValue()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('test'); + $this->assertEquals('test', $header->getFieldBodyModel()); + } + + private function _getHeader($name, $encoder) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $encoder, new Swift_Mime_Grammar()); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php new file mode 100644 index 000000000..af69088a1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php @@ -0,0 +1,233 @@ +_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, $part->getNestingLevel() + ); + } + + public function testCharsetIsReturnedFromHeader() + { + /* -- RFC 2046, 4.1.2. + A critical parameter that may be specified in the Content-Type field + for "text/plain" data is the character set. This is specified with a + "charset" parameter, as in: + + Content-type: text/plain; charset=iso-8859-1 + + Unlike some other parameter values, the values of the charset + parameter are NOT case sensitive. The default character set, which + must be assumed in the absence of a charset parameter, is US-ASCII. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('iso-8859-1', $part->getCharset()); + } + + public function testCharsetIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testCharsetIsSetInHeaderIfPassedToSetBody() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $part->setBody('', 'text/plian', 'utf-8'); + } + + public function testSettingCharsetNotifiesEncoder() + { + $encoder = $this->_createEncoder('quoted-printable', false); + $encoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testSettingCharsetNotifiesHeaders() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('charsetChanged') + ->zeroOrMoreTimes() + ->with('utf-8'); + + $part = $this->_createMimePart($headers, $this->_createEncoder(), + $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testSettingCharsetNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $child->shouldReceive('charsetChanged') + ->once() + ->with('windows-874'); + + $part = $this->_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $part->setChildren(array($child)); + $part->setCharset('windows-874'); + } + + public function testCharsetChangeUpdatesCharset() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $part->charsetChanged('utf-8'); + } + + public function testSettingCharsetClearsCache() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // Initialize the expectation here because we only care about what happens in setCharset() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setCharset('iso-2022'); + } + + public function testFormatIsReturnedFromHeader() + { + /* -- RFC 3676. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('format' => 'flowed') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('flowed', $part->getFormat()); + } + + public function testFormatIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter')->once()->with('format', 'fixed'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $part->setFormat('fixed'); + } + + public function testDelSpIsReturnedFromHeader() + { + /* -- RFC 3676. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('delsp' => 'no') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame(false, $part->getDelSp()); + } + + public function testDelSpIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter')->once()->with('delsp', 'yes'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType, )), + $this->_createEncoder(), $this->_createCache() + ); + $part->setDelSp(true); + } + + public function testFluidInterface() + { + $part = $this->_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertSame($part, + $part + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setCharset('utf-8') + ->setFormat('flowed') + ->setDelSp(true) + ); + } + + // -- Private helpers + + //abstract + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createMimePart($headers, $encoder, $cache); + } + + protected function _createMimePart($headers, $encoder, $cache) + { + return new Swift_Mime_MimePart($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php new file mode 100644 index 000000000..0d5573f89 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php @@ -0,0 +1,168 @@ +_factory = $this->_createFactory(); + } + + public function testMailboxHeaderIsCorrectType() + { + $header = $this->_factory->createMailboxHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_MailboxHeader', $header); + } + + public function testMailboxHeaderHasCorrectName() + { + $header = $this->_factory->createMailboxHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testMailboxHeaderHasCorrectModel() + { + $header = $this->_factory->createMailboxHeader('X-Foo', + array('foo@bar' => 'FooBar') + ); + $this->assertEquals(array('foo@bar' => 'FooBar'), $header->getFieldBodyModel()); + } + + public function testDateHeaderHasCorrectType() + { + $header = $this->_factory->createDateHeader('X-Date'); + $this->assertInstanceof('Swift_Mime_Headers_DateHeader', $header); + } + + public function testDateHeaderHasCorrectName() + { + $header = $this->_factory->createDateHeader('X-Date'); + $this->assertEquals('X-Date', $header->getFieldName()); + } + + public function testDateHeaderHasCorrectModel() + { + $header = $this->_factory->createDateHeader('X-Date', 123); + $this->assertEquals(123, $header->getFieldBodyModel()); + } + + public function testTextHeaderHasCorrectType() + { + $header = $this->_factory->createTextHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_UnstructuredHeader', $header); + } + + public function testTextHeaderHasCorrectName() + { + $header = $this->_factory->createTextHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testTextHeaderHasCorrectModel() + { + $header = $this->_factory->createTextHeader('X-Foo', 'bar'); + $this->assertEquals('bar', $header->getFieldBodyModel()); + } + + public function testParameterizedHeaderHasCorrectType() + { + $header = $this->_factory->createParameterizedHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_ParameterizedHeader', $header); + } + + public function testParameterizedHeaderHasCorrectName() + { + $header = $this->_factory->createParameterizedHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testParameterizedHeaderHasCorrectModel() + { + $header = $this->_factory->createParameterizedHeader('X-Foo', 'bar'); + $this->assertEquals('bar', $header->getFieldBodyModel()); + } + + public function testParameterizedHeaderHasCorrectParams() + { + $header = $this->_factory->createParameterizedHeader('X-Foo', 'bar', + array('zip' => 'button') + ); + $this->assertEquals(array('zip' => 'button'), $header->getParameters()); + } + + public function testIdHeaderHasCorrectType() + { + $header = $this->_factory->createIdHeader('X-ID'); + $this->assertInstanceof('Swift_Mime_Headers_IdentificationHeader', $header); + } + + public function testIdHeaderHasCorrectName() + { + $header = $this->_factory->createIdHeader('X-ID'); + $this->assertEquals('X-ID', $header->getFieldName()); + } + + public function testIdHeaderHasCorrectModel() + { + $header = $this->_factory->createIdHeader('X-ID', 'xyz@abc'); + $this->assertEquals(array('xyz@abc'), $header->getFieldBodyModel()); + } + + public function testPathHeaderHasCorrectType() + { + $header = $this->_factory->createPathHeader('X-Path'); + $this->assertInstanceof('Swift_Mime_Headers_PathHeader', $header); + } + + public function testPathHeaderHasCorrectName() + { + $header = $this->_factory->createPathHeader('X-Path'); + $this->assertEquals('X-Path', $header->getFieldName()); + } + + public function testPathHeaderHasCorrectModel() + { + $header = $this->_factory->createPathHeader('X-Path', 'foo@bar'); + $this->assertEquals('foo@bar', $header->getFieldBodyModel()); + } + + public function testCharsetChangeNotificationNotifiesEncoders() + { + $encoder = $this->_createHeaderEncoder(); + $encoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + $paramEncoder = $this->_createParamEncoder(); + $paramEncoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $factory = $this->_createFactory($encoder, $paramEncoder); + + $factory->charsetChanged('utf-8'); + } + + // -- Creation methods + + private function _createFactory($encoder = null, $paramEncoder = null) + { + return new Swift_Mime_SimpleHeaderFactory( + $encoder + ? $encoder : $this->_createHeaderEncoder(), + $paramEncoder + ? $paramEncoder : $this->_createParamEncoder(), + new Swift_Mime_Grammar() + ); + } + + private function _createHeaderEncoder() + { + return $this->getMock('Swift_Mime_HeaderEncoder'); + } + + private function _createParamEncoder() + { + return $this->getMock('Swift_Encoder'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php new file mode 100644 index 000000000..a781a088e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php @@ -0,0 +1,734 @@ +_createFactory(); + $factory->expects($this->once()) + ->method('createMailboxHeader') + ->with('From', array('person@domain' => 'Person')) + ->will($this->returnValue($this->_createHeader('From'))); + + $set = $this->_createSet($factory); + $set->addMailboxHeader('From', array('person@domain' => 'Person')); + } + + public function testAddDateHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createDateHeader') + ->with('Date', 1234) + ->will($this->returnValue($this->_createHeader('Date'))); + + $set = $this->_createSet($factory); + $set->addDateHeader('Date', 1234); + } + + public function testAddTextHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($this->_createHeader('Subject'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + } + + public function testAddParameterizedHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createParameterizedHeader') + ->with('Content-Type', 'text/plain', array('charset' => 'utf-8')) + ->will($this->returnValue($this->_createHeader('Content-Type'))); + + $set = $this->_createSet($factory); + $set->addParameterizedHeader('Content-Type', 'text/plain', + array('charset' => 'utf-8') + ); + } + + public function testAddIdHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + } + + public function testAddPathHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createPathHeader') + ->with('Return-Path', 'some@path') + ->will($this->returnValue($this->_createHeader('Return-Path'))); + + $set = $this->_createSet($factory); + $set->addPathHeader('Return-Path', 'some@path'); + } + + public function testHasReturnsFalseWhenNoHeaders() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertFalse($set->has('Some-Header')); + } + + public function testAddedMailboxHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createMailboxHeader') + ->with('From', array('person@domain' => 'Person')) + ->will($this->returnValue($this->_createHeader('From'))); + + $set = $this->_createSet($factory); + $set->addMailboxHeader('From', array('person@domain' => 'Person')); + $this->assertTrue($set->has('From')); + } + + public function testAddedDateHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createDateHeader') + ->with('Date', 1234) + ->will($this->returnValue($this->_createHeader('Date'))); + + $set = $this->_createSet($factory); + $set->addDateHeader('Date', 1234); + $this->assertTrue($set->has('Date')); + } + + public function testAddedTextHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($this->_createHeader('Subject'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $this->assertTrue($set->has('Subject')); + } + + public function testAddedParameterizedHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createParameterizedHeader') + ->with('Content-Type', 'text/plain', array('charset' => 'utf-8')) + ->will($this->returnValue($this->_createHeader('Content-Type'))); + + $set = $this->_createSet($factory); + $set->addParameterizedHeader('Content-Type', 'text/plain', + array('charset' => 'utf-8') + ); + $this->assertTrue($set->has('Content-Type')); + } + + public function testAddedIdHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('Message-ID')); + } + + public function testAddedPathHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createPathHeader') + ->with('Return-Path', 'some@path') + ->will($this->returnValue($this->_createHeader('Return-Path'))); + + $set = $this->_createSet($factory); + $set->addPathHeader('Return-Path', 'some@path'); + $this->assertTrue($set->has('Return-Path')); + } + + public function testNewlySetHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $header = $this->_createHeader('X-Foo', 'bar'); + $set = $this->_createSet($factory); + $set->set($header); + $this->assertTrue($set->has('X-Foo')); + } + + public function testHasCanAcceptOffset() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('Message-ID', 0)); + } + + public function testHasWithIllegalOffsetReturnsFalse() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testHasCanDistinguishMultipleHeaders() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $this->assertTrue($set->has('Message-ID', 1)); + } + + public function testGetWithUnspecifiedOffset() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertSame($header, $set->get('Message-ID')); + } + + public function testGetWithSpeiciedOffset() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $header2 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('Message-ID', 'more@id') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->addIdHeader('Message-ID', 'more@id'); + $this->assertSame($header1, $set->get('Message-ID', 1)); + } + + public function testGetReturnsNullIfHeaderNotSet() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertNull($set->get('Message-ID', 99)); + } + + public function testGetAllReturnsAllHeadersMatchingName() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $header2 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('Message-ID', 'more@id') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->addIdHeader('Message-ID', 'more@id'); + + $this->assertEquals(array($header0, $header1, $header2), + $set->getAll('Message-ID') + ); + } + + public function testGetAllReturnsAllHeadersIfNoArguments() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Subject'); + $header2 = $this->_createHeader('To'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Subject', 'thing') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('To', 'person@example.org') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Subject', 'thing'); + $set->addIdHeader('To', 'person@example.org'); + + $this->assertEquals(array($header0, $header1, $header2), + $set->getAll() + ); + } + + public function testGetAllReturnsEmptyArrayIfNoneSet() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertEquals(array(), $set->getAll('Received')); + } + + public function testRemoveWithUnspecifiedOffset() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('Message-ID'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testRemoveWithSpecifiedIndexRemovesHeader() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->remove('Message-ID', 1); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testRemoveWithSpecifiedIndexLeavesOtherHeaders() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->remove('Message-ID', 1); + $this->assertTrue($set->has('Message-ID', 0)); + } + + public function testRemoveWithInvalidOffsetDoesNothing() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('Message-ID', 50); + $this->assertTrue($set->has('Message-ID')); + } + + public function testRemoveAllRemovesAllHeadersWithName() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->removeAll('Message-ID'); + $this->assertFalse($set->has('Message-ID', 0)); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testHasIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('message-id')); + } + + public function testGetIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertSame($header, $set->get('message-id')); + } + + public function testGetAllIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertEquals(array($header), $set->getAll('message-id')); + } + + public function testRemoveIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('message-id'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testRemoveAllIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->removeAll('message-id'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testNewInstance() + { + $set = $this->_createSet($this->_createFactory()); + $instance = $set->newInstance(); + $this->assertInstanceof('Swift_Mime_HeaderSet', $instance); + } + + public function testToStringJoinsHeadersTogether() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', 'bar') + ->will($this->returnValue($this->_createHeader('Foo', 'bar'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', 'buttons') + ->will($this->returnValue($this->_createHeader('Zip', 'buttons'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', 'bar'); + $set->addTextHeader('Zip', 'buttons'); + $this->assertEquals( + "Foo: bar\r\n". + "Zip: buttons\r\n", + $set->toString() + ); + } + + public function testHeadersWithoutBodiesAreNotDisplayed() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', 'bar') + ->will($this->returnValue($this->_createHeader('Foo', 'bar'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', '') + ->will($this->returnValue($this->_createHeader('Zip', ''))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', 'bar'); + $set->addTextHeader('Zip', ''); + $this->assertEquals( + "Foo: bar\r\n", + $set->toString() + ); + } + + public function testHeadersWithoutBodiesCanBeForcedToDisplay() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', '') + ->will($this->returnValue($this->_createHeader('Foo', ''))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', '') + ->will($this->returnValue($this->_createHeader('Zip', ''))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', ''); + $set->addTextHeader('Zip', ''); + $set->setAlwaysDisplayed(array('Foo', 'Zip')); + $this->assertEquals( + "Foo: \r\n". + "Zip: \r\n", + $set->toString() + ); + } + + public function testHeaderSequencesCanBeSpecified() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Third', 'three') + ->will($this->returnValue($this->_createHeader('Third', 'three'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('First', 'one') + ->will($this->returnValue($this->_createHeader('First', 'one'))); + $factory->expects($this->at(2)) + ->method('createTextHeader') + ->with('Second', 'two') + ->will($this->returnValue($this->_createHeader('Second', 'two'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Third', 'three'); + $set->addTextHeader('First', 'one'); + $set->addTextHeader('Second', 'two'); + + $set->defineOrdering(array('First', 'Second', 'Third')); + + $this->assertEquals( + "First: one\r\n". + "Second: two\r\n". + "Third: three\r\n", + $set->toString() + ); + } + + public function testUnsortedHeadersAppearAtEnd() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Fourth', 'four') + ->will($this->returnValue($this->_createHeader('Fourth', 'four'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Fifth', 'five') + ->will($this->returnValue($this->_createHeader('Fifth', 'five'))); + $factory->expects($this->at(2)) + ->method('createTextHeader') + ->with('Third', 'three') + ->will($this->returnValue($this->_createHeader('Third', 'three'))); + $factory->expects($this->at(3)) + ->method('createTextHeader') + ->with('First', 'one') + ->will($this->returnValue($this->_createHeader('First', 'one'))); + $factory->expects($this->at(4)) + ->method('createTextHeader') + ->with('Second', 'two') + ->will($this->returnValue($this->_createHeader('Second', 'two'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Fourth', 'four'); + $set->addTextHeader('Fifth', 'five'); + $set->addTextHeader('Third', 'three'); + $set->addTextHeader('First', 'one'); + $set->addTextHeader('Second', 'two'); + + $set->defineOrdering(array('First', 'Second', 'Third')); + + $this->assertEquals( + "First: one\r\n". + "Second: two\r\n". + "Third: three\r\n". + "Fourth: four\r\n". + "Fifth: five\r\n", + $set->toString() + ); + } + + public function testSettingCharsetNotifiesAlreadyExistingHeaders() + { + $subject = $this->_createHeader('Subject', 'some text'); + $xHeader = $this->_createHeader('X-Header', 'some text'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($subject)); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('X-Header', 'some text') + ->will($this->returnValue($xHeader)); + $subject->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + $xHeader->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $set->addTextHeader('X-Header', 'some text'); + + $set->setCharset('utf-8'); + } + + public function testCharsetChangeNotifiesAlreadyExistingHeaders() + { + $subject = $this->_createHeader('Subject', 'some text'); + $xHeader = $this->_createHeader('X-Header', 'some text'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($subject)); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('X-Header', 'some text') + ->will($this->returnValue($xHeader)); + $subject->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + $xHeader->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $set->addTextHeader('X-Header', 'some text'); + + $set->charsetChanged('utf-8'); + } + + public function testCharsetChangeNotifiesFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $set = $this->_createSet($factory); + + $set->setCharset('utf-8'); + } + + // -- Creation methods + + private function _createSet($factory) + { + return new Swift_Mime_SimpleHeaderSet($factory); + } + + private function _createFactory() + { + return $this->getMock('Swift_Mime_HeaderFactory'); + } + + private function _createHeader($name, $body = '') + { + $header = $this->getMock('Swift_Mime_Header'); + $header->expects($this->any()) + ->method('getFieldName') + ->will($this->returnValue($name)); + $header->expects($this->any()) + ->method('toString') + ->will($this->returnValue(sprintf("%s: %s\r\n", $name, $body))); + $header->expects($this->any()) + ->method('getFieldBody') + ->will($this->returnValue($body)); + + return $header; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php new file mode 100644 index 000000000..a2cbbcab2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php @@ -0,0 +1,829 @@ +_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_TOP, $message->getNestingLevel() + ); + } + + public function testDateIsReturnedFromHeader() + { + $date = $this->_createHeader('Date', 123); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Date' => $date)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(123, $message->getDate()); + } + + public function testDateIsSetInHeader() + { + $date = $this->_createHeader('Date', 123, array(), false); + $date->shouldReceive('setFieldBodyModel') + ->once() + ->with(1234); + $date->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Date' => $date)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setDate(1234); + } + + public function testDateHeaderIsCreatedIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addDateHeader') + ->once() + ->with('Date', 1234); + $headers->shouldReceive('addDateHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setDate(1234); + } + + public function testDateHeaderIsAddedDuringConstruction() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addDateHeader') + ->once() + ->with('Date', '/^[0-9]+$/D'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testIdIsReturnedFromHeader() + { + /* -- RFC 2045, 7. + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labelled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field + */ + + $messageId = $this->_createHeader('Message-ID', 'a@b'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Message-ID' => $messageId)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('a@b', $message->getId()); + } + + public function testIdIsSetInHeader() + { + $messageId = $this->_createHeader('Message-ID', 'a@b', array(), false); + $messageId->shouldReceive('setFieldBodyModel') + ->once() + ->with('x@y'); + $messageId->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Message-ID' => $messageId)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setId('x@y'); + } + + public function testIdIsAutoGenerated() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addIdHeader') + ->once() + ->with('Message-ID', '/^.*?@.*?$/D'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testSubjectIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.5. + */ + + $subject = $this->_createHeader('Subject', 'example subject'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Subject' => $subject)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('example subject', $message->getSubject()); + } + + public function testSubjectIsSetInHeader() + { + $subject = $this->_createHeader('Subject', '', array(), false); + $subject->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Subject' => $subject)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setSubject('foo'); + } + + public function testSubjectHeaderIsCreatedIfNotPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Subject', 'example subject'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSubject('example subject'); + } + + public function testReturnPathIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.7. + */ + + $path = $this->_createHeader('Return-Path', 'bounces@domain'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Return-Path' => $path)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('bounces@domain', $message->getReturnPath()); + } + + public function testReturnPathIsSetInHeader() + { + $path = $this->_createHeader('Return-Path', '', array(), false); + $path->shouldReceive('setFieldBodyModel') + ->once() + ->with('bounces@domain'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Return-Path' => $path)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReturnPath('bounces@domain'); + } + + public function testReturnPathHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addPathHeader') + ->once() + ->with('Return-Path', 'bounces@domain'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReturnPath('bounces@domain'); + } + + public function testSenderIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $sender = $this->_createHeader('Sender', array('sender@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Sender' => $sender)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('sender@domain' => 'Name'), $message->getSender()); + } + + public function testSenderIsSetInHeader() + { + $sender = $this->_createHeader('Sender', array('sender@domain' => 'Name'), + array(), false + ); + $sender->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Sender' => $sender)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setSender(array('other@domain' => 'Other')); + } + + public function testSenderHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Sender', (array) 'sender@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSender('sender@domain'); + } + + public function testNameCanBeUsedInSenderHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Sender', array('sender@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSender('sender@domain', 'Name'); + } + + public function testFromIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $from = $this->_createHeader('From', array('from@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('from@domain' => 'Name'), $message->getFrom()); + } + + public function testFromIsSetInHeader() + { + $from = $this->_createHeader('From', array('from@domain' => 'Name'), + array(), false + ); + $from->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setFrom(array('other@domain' => 'Other')); + } + + public function testFromIsAddedToHeadersDuringAddFrom() + { + $from = $this->_createHeader('From', array('from@domain' => 'Name'), + array(), false + ); + $from->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain' => 'Name', 'other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addFrom('other@domain', 'Other'); + } + + public function testFromHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('From', (array) 'from@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setFrom('from@domain'); + } + + public function testPersonalNameCanBeUsedInFromAddress() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('From', array('from@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setFrom('from@domain', 'Name'); + } + + public function testReplyToIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $reply = $this->_createHeader('Reply-To', array('reply@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $reply)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('reply@domain' => 'Name'), $message->getReplyTo()); + } + + public function testReplyToIsSetInHeader() + { + $reply = $this->_createHeader('Reply-To', array('reply@domain' => 'Name'), + array(), false + ); + $reply->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $reply)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReplyTo(array('other@domain' => 'Other')); + } + + public function testReplyToIsAddedToHeadersDuringAddReplyTo() + { + $replyTo = $this->_createHeader('Reply-To', array('from@domain' => 'Name'), + array(), false + ); + $replyTo->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain' => 'Name', 'other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $replyTo)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addReplyTo('other@domain', 'Other'); + } + + public function testReplyToHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Reply-To', (array) 'reply@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReplyTo('reply@domain'); + } + + public function testNameCanBeUsedInReplyTo() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Reply-To', array('reply@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReplyTo('reply@domain', 'Name'); + } + + public function testToIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $to = $this->_createHeader('To', array('to@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('to@domain' => 'Name'), $message->getTo()); + } + + public function testToIsSetInHeader() + { + $to = $this->_createHeader('To', array('to@domain' => 'Name'), + array(), false + ); + $to->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setTo(array('other@domain' => 'Other')); + } + + public function testToIsAddedToHeadersDuringAddTo() + { + $to = $this->_createHeader('To', array('from@domain' => 'Name'), + array(), false + ); + $to->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain' => 'Name', 'other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addTo('other@domain', 'Other'); + } + + public function testToHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('To', (array) 'to@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setTo('to@domain'); + } + + public function testNameCanBeUsedInToHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('To', array('to@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setTo('to@domain', 'Name'); + } + + public function testCcIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $cc = $this->_createHeader('Cc', array('cc@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('cc@domain' => 'Name'), $message->getCc()); + } + + public function testCcIsSetInHeader() + { + $cc = $this->_createHeader('Cc', array('cc@domain' => 'Name'), + array(), false + ); + $cc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setCc(array('other@domain' => 'Other')); + } + + public function testCcIsAddedToHeadersDuringAddCc() + { + $cc = $this->_createHeader('Cc', array('from@domain' => 'Name'), + array(), false + ); + $cc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain' => 'Name', 'other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addCc('other@domain', 'Other'); + } + + public function testCcHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Cc', (array) 'cc@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setCc('cc@domain'); + } + + public function testNameCanBeUsedInCcHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Cc', array('cc@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setCc('cc@domain', 'Name'); + } + + public function testBccIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $bcc = $this->_createHeader('Bcc', array('bcc@domain' => 'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('bcc@domain' => 'Name'), $message->getBcc()); + } + + public function testBccIsSetInHeader() + { + $bcc = $this->_createHeader('Bcc', array('bcc@domain' => 'Name'), + array(), false + ); + $bcc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setBcc(array('other@domain' => 'Other')); + } + + public function testBccIsAddedToHeadersDuringAddBcc() + { + $bcc = $this->_createHeader('Bcc', array('from@domain' => 'Name'), + array(), false + ); + $bcc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain' => 'Name', 'other@domain' => 'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addBcc('other@domain', 'Other'); + } + + public function testBccHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Bcc', (array) 'bcc@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setBcc('bcc@domain'); + } + + public function testNameCanBeUsedInBcc() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Bcc', array('bcc@domain' => 'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setBcc('bcc@domain', 'Name'); + } + + public function testPriorityIsReadFromHeader() + { + $prio = $this->_createHeader('X-Priority', '2 (High)'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('X-Priority' => $prio)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(2, $message->getPriority()); + } + + public function testPriorityIsSetInHeader() + { + $prio = $this->_createHeader('X-Priority', '2 (High)', array(), false); + $prio->shouldReceive('setFieldBodyModel') + ->once() + ->with('5 (Lowest)'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('X-Priority' => $prio)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setPriority(5); + } + + public function testPriorityHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('X-Priority', '4 (Low)'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setPriority(4); + } + + public function testReadReceiptAddressReadFromHeader() + { + $rcpt = $this->_createHeader('Disposition-Notification-To', + array('chris@swiftmailer.org' => 'Chris') + ); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Disposition-Notification-To' => $rcpt)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('chris@swiftmailer.org' => 'Chris'), + $message->getReadReceiptTo() + ); + } + + public function testReadReceiptIsSetInHeader() + { + $rcpt = $this->_createHeader('Disposition-Notification-To', array(), array(), false); + $rcpt->shouldReceive('setFieldBodyModel') + ->once() + ->with('mark@swiftmailer.org'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Disposition-Notification-To' => $rcpt)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReadReceiptTo('mark@swiftmailer.org'); + } + + public function testReadReceiptHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Disposition-Notification-To', 'mark@swiftmailer.org'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReadReceiptTo('mark@swiftmailer.org'); + } + + public function testChildrenCanBeAttached() + { + $child1 = $this->_createChild(); + $child2 = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->attach($child1); + $message->attach($child2); + + $this->assertEquals(array($child1, $child2), $message->getChildren()); + } + + public function testChildrenCanBeDetached() + { + $child1 = $this->_createChild(); + $child2 = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->attach($child1); + $message->attach($child2); + + $message->detach($child1); + + $this->assertEquals(array($child2), $message->getChildren()); + } + + public function testEmbedAttachesChild() + { + $child = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->embed($child); + + $this->assertEquals(array($child), $message->getChildren()); + } + + public function testEmbedReturnsValidCid() + { + $child = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_RELATED, '', + false + ); + $child->shouldReceive('getId') + ->zeroOrMoreTimes() + ->andReturn('foo@bar'); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertEquals('cid:foo@bar', $message->embed($child)); + } + + public function testFluidInterface() + { + $child = $this->_createChild(); + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame($message, + $message + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setCharset('iso-8859-1') + ->setFormat('flowed') + ->setDelSp(false) + ->setSubject('subj') + ->setDate(123) + ->setReturnPath('foo@bar') + ->setSender('foo@bar') + ->setFrom(array('x@y' => 'XY')) + ->setReplyTo(array('ab@cd' => 'ABCD')) + ->setTo(array('chris@site.tld', 'mark@site.tld')) + ->setCc('john@somewhere.tld') + ->setBcc(array('one@site', 'two@site' => 'Two')) + ->setPriority(4) + ->setReadReceiptTo('a@b') + ->attach($child) + ->detach($child) + ); + } + + // -- Private helpers + + //abstract + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createMessage($headers, $encoder, $cache); + } + + protected function _createMimePart($headers, $encoder, $cache) + { + return $this->_createMessage($headers, $encoder, $cache); + } + + private function _createMessage($headers, $encoder, $cache) + { + return new Swift_Mime_SimpleMessage($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php new file mode 100644 index 000000000..b54d7f874 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php @@ -0,0 +1,11 @@ +assertEquals(10, $plugin->getThreshold()); + $plugin->setThreshold(100); + $this->assertEquals(100, $plugin->getThreshold()); + } + + public function testSleepTimeCanBeSetAndFetched() + { + $plugin = new Swift_Plugins_AntiFloodPlugin(10, 5); + $this->assertEquals(5, $plugin->getSleepTime()); + $plugin->setSleepTime(1); + $this->assertEquals(1, $plugin->getSleepTime()); + } + + public function testPluginStopsConnectionAfterThreshold() + { + $transport = $this->_createTransport(); + $transport->expects($this->once()) + ->method('start'); + $transport->expects($this->once()) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(10); + for ($i = 0; $i < 12; $i++) { + $plugin->sendPerformed($evt); + } + } + + public function testPluginCanStopAndStartMultipleTimes() + { + $transport = $this->_createTransport(); + $transport->expects($this->exactly(5)) + ->method('start'); + $transport->expects($this->exactly(5)) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(2); + for ($i = 0; $i < 11; $i++) { + $plugin->sendPerformed($evt); + } + } + + public function testPluginCanSleepDuringRestart() + { + $sleeper = $this->getMock('Swift_Plugins_Sleeper'); + $sleeper->expects($this->once()) + ->method('sleep') + ->with(10); + + $transport = $this->_createTransport(); + $transport->expects($this->once()) + ->method('start'); + $transport->expects($this->once()) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(99, 10, $sleeper); + for ($i = 0; $i < 101; $i++) { + $plugin->sendPerformed($evt); + } + } + + // -- Creation Methods + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createSendEvent($transport) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($transport)); + $evt->expects($this->any()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php new file mode 100644 index 000000000..f14099316 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php @@ -0,0 +1,127 @@ +_monitor = new Swift_Plugins_BandwidthMonitorPlugin(); + } + + public function testBytesOutIncreasesWhenCommandsSent() + { + $evt = $this->_createCommandEvent("RCPT TO:\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(23, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(46, $this->_monitor->getBytesOut()); + } + + public function testBytesInIncreasesWhenResponsesReceived() + { + $evt = $this->_createResponseEvent("250 Ok\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(8, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(16, $this->_monitor->getBytesIn()); + } + + public function testCountersCanBeReset() + { + $evt = $this->_createResponseEvent("250 Ok\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(8, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(16, $this->_monitor->getBytesIn()); + + $evt = $this->_createCommandEvent("RCPT TO:\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(23, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(46, $this->_monitor->getBytesOut()); + + $this->_monitor->reset(); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->assertEquals(0, $this->_monitor->getBytesIn()); + } + + public function testBytesOutIncreasesAccordingToMessageLength() + { + $message = $this->_createMessageWithByteCount(6); + $evt = $this->_createSendEvent($message); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->sendPerformed($evt); + $this->assertEquals(6, $this->_monitor->getBytesOut()); + $this->_monitor->sendPerformed($evt); + $this->assertEquals(12, $this->_monitor->getBytesOut()); + } + + // -- Creation Methods + + private function _createSendEvent($message) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getMessage') + ->will($this->returnValue($message)); + + return $evt; + } + + private function _createCommandEvent($command) + { + $evt = $this->getMockBuilder('Swift_Events_CommandEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getCommand') + ->will($this->returnValue($command)); + + return $evt; + } + + private function _createResponseEvent($response) + { + $evt = $this->getMockBuilder('Swift_Events_ResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($response)); + + return $evt; + } + + private function _createMessageWithByteCount($bytes) + { + $this->_bytes = $bytes; + $msg = $this->getMock('Swift_Mime_Message'); + $msg->expects($this->any()) + ->method('toByteStream') + ->will($this->returnCallback(array($this, '_write'))); + /* $this->_checking(Expectations::create() + -> ignoring($msg)->toByteStream(any()) -> calls(array($this, '_write')) + ); */ + + return $msg; + } + + private $_bytes = 0; + public function _write($is) + { + for ($i = 0; $i < $this->_bytes; ++$i) { + $is->write('x'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php new file mode 100644 index 000000000..7f4cdef15 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php @@ -0,0 +1,269 @@ +_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Hello {name}, you are customer #{id}' + ); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeAppliedToSameMessageMultipleTimes() + { + $message = $this->_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon', 'foo@bar.tld' => 'Foo'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Hello {name}, you are customer #{id}' + ); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $message->shouldReceive('setBody') + ->once() + ->with('Hello {name}, you are customer #{id}'); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Foo, you are customer #123'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array( + 'foo@bar.tld' => array('{name}' => 'Foo', '{id}' => '123'), + 'zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456'), + ) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeMadeInHeaders() + { + $headers = $this->_createHeaders(array( + $returnPathHeader = $this->_createHeader('Return-Path', 'foo-{id}@swiftmailer.org'), + $toHeader = $this->_createHeader('Subject', 'A message for {name}!'), + )); + + $message = $this->_createMessage( + $headers, + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'A message for {name}!', + 'Hello {name}, you are customer #{id}' + ); + + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $toHeader->shouldReceive('setFieldBodyModel') + ->once() + ->with('A message for Zip!'); + $returnPathHeader->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo-456@swiftmailer.org'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $toHeader->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + $returnPathHeader->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsAreMadeOnSubparts() + { + $part1 = $this->_createPart('text/plain', 'Your name is {name}?', '1@x'); + $part2 = $this->_createPart('text/html', 'Your name is {name}?', '2@x'); + $message = $this->_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'A message for {name}!', + 'Subject' + ); + $message->shouldReceive('getChildren') + ->zeroOrMoreTimes() + ->andReturn(array($part1, $part2)); + $part1->shouldReceive('setBody') + ->once() + ->with('Your name is Zip?'); + $part2->shouldReceive('setBody') + ->once() + ->with('Your name is Zip?'); + $part1->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $part2->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeTakenFromCustomReplacementsObject() + { + $message = $this->_createMessage( + $this->_createHeaders(), + array('foo@bar' => 'Foobar', 'zip@zap' => 'Zip zap'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Something {a}' + ); + + $replacements = $this->_createReplacements(); + + $message->shouldReceive('setBody') + ->once() + ->with('Something b'); + $message->shouldReceive('setBody') + ->once() + ->with('Something c'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $replacements->shouldReceive('getReplacementsFor') + ->once() + ->with('foo@bar') + ->andReturn(array('{a}' => 'b')); + $replacements->shouldReceive('getReplacementsFor') + ->once() + ->with('zip@zap') + ->andReturn(array('{a}' => 'c')); + + $plugin = $this->_createPlugin($replacements); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + // -- Creation methods + + private function _createMessage($headers, $to = array(), $from = null, $subject = null, + $body = null) + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + foreach ($to as $addr => $name) { + $message->shouldReceive('getTo') + ->once() + ->andReturn(array($addr => $name)); + } + $message->shouldReceive('getHeaders') + ->zeroOrMoreTimes() + ->andReturn($headers); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn($from); + $message->shouldReceive('getSubject') + ->zeroOrMoreTimes() + ->andReturn($subject); + $message->shouldReceive('getBody') + ->zeroOrMoreTimes() + ->andReturn($body); + + return $message; + } + + private function _createPlugin($replacements) + { + return new Swift_Plugins_DecoratorPlugin($replacements); + } + + private function _createReplacements() + { + return $this->getMockery('Swift_Plugins_Decorator_Replacements')->shouldIgnoreMissing(); + } + + private function _createSendEvent(Swift_Mime_Message $message) + { + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $evt->shouldReceive('getMessage') + ->zeroOrMoreTimes() + ->andReturn($message); + + return $evt; + } + + private function _createPart($type, $body, $id) + { + $part = $this->getMockery('Swift_Mime_MimeEntity')->shouldIgnoreMissing(); + $part->shouldReceive('getContentType') + ->zeroOrMoreTimes() + ->andReturn($type); + $part->shouldReceive('getBody') + ->zeroOrMoreTimes() + ->andReturn($body); + $part->shouldReceive('getId') + ->zeroOrMoreTimes() + ->andReturn($id); + + return $part; + } + + private function _createHeaders($headers = array()) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + $set->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->andReturn($headers); + + foreach ($headers as $header) { + $set->set($header); + } + + return $set; + } + + private function _createHeader($name, $body = '') + { + $header = $this->getMockery('Swift_Mime_Header')->shouldIgnoreMissing(); + $header->shouldReceive('getFieldName') + ->zeroOrMoreTimes() + ->andReturn($name); + $header->shouldReceive('getFieldBodyModel') + ->zeroOrMoreTimes() + ->andReturn($body); + + return $header; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php new file mode 100644 index 000000000..bd1fd97af --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php @@ -0,0 +1,190 @@ +_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with('foo'); + + $plugin = $this->_createPlugin($logger); + $plugin->add('foo'); + } + + public function testLoggerDelegatesDumpingEntries() + { + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('dump') + ->will($this->returnValue('foobar')); + + $plugin = $this->_createPlugin($logger); + $this->assertEquals('foobar', $plugin->dump()); + } + + public function testLoggerDelegatesClearingEntries() + { + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('clear'); + + $plugin = $this->_createPlugin($logger); + $plugin->clear(); + } + + public function testCommandIsSentToLogger() + { + $evt = $this->_createCommandEvent("foo\r\n"); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->regExp('~foo\r\n~')); + + $plugin = $this->_createPlugin($logger); + $plugin->commandSent($evt); + } + + public function testResponseIsSentToLogger() + { + $evt = $this->_createResponseEvent("354 Go ahead\r\n"); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->regExp('~354 Go ahead\r\n~')); + + $plugin = $this->_createPlugin($logger); + $plugin->responseReceived($evt); + } + + public function testTransportBeforeStartChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->beforeTransportStarted($evt); + } + + public function testTransportStartChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->transportStarted($evt); + } + + public function testTransportStopChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->transportStopped($evt); + } + + public function testTransportBeforeStopChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->beforeTransportStopped($evt); + } + + public function testExceptionsArePassedToDelegateAndLeftToBubbleUp() + { + $transport = $this->_createTransport(); + $evt = $this->_createTransportExceptionEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + try { + $plugin->exceptionThrown($evt); + $this->fail('Exception should bubble up.'); + } catch (Swift_TransportException $ex) { + } + } + + // -- Creation Methods + + private function _createLogger() + { + return $this->getMock('Swift_Plugins_Logger'); + } + + private function _createPlugin($logger) + { + return new Swift_Plugins_LoggerPlugin($logger); + } + + private function _createCommandEvent($command) + { + $evt = $this->getMockBuilder('Swift_Events_CommandEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getCommand') + ->will($this->returnValue($command)); + + return $evt; + } + + private function _createResponseEvent($response) + { + $evt = $this->getMockBuilder('Swift_Events_ResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($response)); + + return $evt; + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createTransportChangeEvent() + { + $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($this->_createTransport())); + + return $evt; + } + + public function _createTransportExceptionEvent() + { + $evt = $this->getMockBuilder('Swift_Events_TransportExceptionEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getException') + ->will($this->returnValue(new Swift_TransportException(''))); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php new file mode 100644 index 000000000..880bb32c9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php @@ -0,0 +1,65 @@ +add(">> Foo\r\n"); + $this->assertEquals(">> Foo\r\n", $logger->dump()); + } + + public function testAddingMultipleEntriesDumpsMultipleLines() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> FOO\r\n".PHP_EOL. + "<< 502 That makes no sense\r\n".PHP_EOL. + ">> RSET\r\n".PHP_EOL. + "<< 250 OK\r\n", + $logger->dump() + ); + } + + public function testLogCanBeCleared() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> FOO\r\n".PHP_EOL. + "<< 502 That makes no sense\r\n".PHP_EOL. + ">> RSET\r\n".PHP_EOL. + "<< 250 OK\r\n", + $logger->dump() + ); + + $logger->clear(); + + $this->assertEquals('', $logger->dump()); + } + + public function testLengthCanBeTruncated() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(2); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> RSET\r\n".PHP_EOL. + "<< 250 OK\r\n", + $logger->dump(), + '%s: Log should be truncated to last 2 entries' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php new file mode 100644 index 000000000..6134fe64e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php @@ -0,0 +1,24 @@ +add('>> Foo'); + $data = ob_get_clean(); + + $this->assertEquals('>> Foo'.PHP_EOL, $data); + } + + public function testAddingEntryDumpsEscapedLineWithHtml() + { + $logger = new Swift_Plugins_Loggers_EchoLogger(true); + ob_start(); + $logger->add('>> Foo'); + $data = ob_get_clean(); + + $this->assertEquals('>> Foo
'.PHP_EOL, $data); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php new file mode 100644 index 000000000..1227c24c5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php @@ -0,0 +1,103 @@ +_createConnection(); + $connection->expects($this->once()) + ->method('connect'); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginDisconnectsFromPop3HostBeforeTransportStarts() + { + $connection = $this->_createConnection(); + $connection->expects($this->once()) + ->method('disconnect'); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginDoesNotConnectToSmtpIfBoundToDifferentTransport() + { + $connection = $this->_createConnection(); + $connection->expects($this->never()) + ->method('disconnect'); + $connection->expects($this->never()) + ->method('connect'); + + $smtp = $this->_createTransport(); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + $plugin->bindSmtp($smtp); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginCanBindToSpecificTransport() + { + $connection = $this->_createConnection(); + $connection->expects($this->once()) + ->method('connect'); + + $smtp = $this->_createTransport(); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + $plugin->bindSmtp($smtp); + + $evt = $this->_createTransportChangeEvent($smtp); + + $plugin->beforeTransportStarted($evt); + } + + // -- Creation Methods + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createTransportChangeEvent($transport) + { + $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($transport)); + $evt->expects($this->any()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + return $evt; + } + + public function _createConnection() + { + return $this->getMock('Swift_Plugins_Pop_Pop3Connection'); + } + + public function _createPlugin($host, $port, $crypto = null) + { + return new Swift_Plugins_PopBeforeSmtpPlugin($host, $port, $crypto); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php new file mode 100644 index 000000000..4cc7e89f1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php @@ -0,0 +1,185 @@ +assertEquals('fabien@example.com', $plugin->getRecipient()); + $plugin->setRecipient('chris@example.com'); + $this->assertEquals('chris@example.com', $plugin->getRecipient()); + } + + public function testPluginChangesRecipients() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo($to = array( + 'fabien-to@example.com' => 'Fabien (To)', + 'chris-to@example.com' => 'Chris (To)', + )) + ->setCc($cc = array( + 'fabien-cc@example.com' => 'Fabien (Cc)', + 'chris-cc@example.com' => 'Chris (Cc)', + )) + ->setBcc($bcc = array( + 'fabien-bcc@example.com' => 'Fabien (Bcc)', + 'chris-bcc@example.com' => 'Chris (Bcc)', + )) + ->setBody('...') + ; + + $plugin = new Swift_Plugins_RedirectingPlugin('god@example.com'); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals($message->getTo(), array('god@example.com' => '')); + $this->assertEquals($message->getCc(), array()); + $this->assertEquals($message->getBcc(), array()); + + $plugin->sendPerformed($evt); + + $this->assertEquals($message->getTo(), $to); + $this->assertEquals($message->getCc(), $cc); + $this->assertEquals($message->getBcc(), $bcc); + } + + public function testPluginRespectsUnsetToList() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setCc($cc = array( + 'fabien-cc@example.com' => 'Fabien (Cc)', + 'chris-cc@example.com' => 'Chris (Cc)', + )) + ->setBcc($bcc = array( + 'fabien-bcc@example.com' => 'Fabien (Bcc)', + 'chris-bcc@example.com' => 'Chris (Bcc)', + )) + ->setBody('...') + ; + + $plugin = new Swift_Plugins_RedirectingPlugin('god@example.com'); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals($message->getTo(), array('god@example.com' => '')); + $this->assertEquals($message->getCc(), array()); + $this->assertEquals($message->getBcc(), array()); + + $plugin->sendPerformed($evt); + + $this->assertEquals($message->getTo(), array()); + $this->assertEquals($message->getCc(), $cc); + $this->assertEquals($message->getBcc(), $bcc); + } + + public function testPluginRespectsAWhitelistOfPatterns() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo($to = array( + 'fabien-to@example.com' => 'Fabien (To)', + 'chris-to@example.com' => 'Chris (To)', + 'lars-to@internal.com' => 'Lars (To)', + )) + ->setCc($cc = array( + 'fabien-cc@example.com' => 'Fabien (Cc)', + 'chris-cc@example.com' => 'Chris (Cc)', + 'lars-cc@internal.org' => 'Lars (Cc)', + )) + ->setBcc($bcc = array( + 'fabien-bcc@example.com' => 'Fabien (Bcc)', + 'chris-bcc@example.com' => 'Chris (Bcc)', + 'john-bcc@example.org' => 'John (Bcc)', + )) + ->setBody('...') + ; + + $recipient = 'god@example.com'; + $patterns = array('/^.*@internal.[a-z]+$/', '/^john-.*$/'); + + $plugin = new Swift_Plugins_RedirectingPlugin($recipient, $patterns); + + $this->assertEquals($recipient, $plugin->getRecipient()); + $this->assertEquals($plugin->getWhitelist(), $patterns); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals($message->getTo(), array('lars-to@internal.com' => 'Lars (To)', 'god@example.com' => null)); + $this->assertEquals($message->getCc(), array('lars-cc@internal.org' => 'Lars (Cc)')); + $this->assertEquals($message->getBcc(), array('john-bcc@example.org' => 'John (Bcc)')); + + $plugin->sendPerformed($evt); + + $this->assertEquals($message->getTo(), $to); + $this->assertEquals($message->getCc(), $cc); + $this->assertEquals($message->getBcc(), $bcc); + } + + public function testArrayOfRecipientsCanBeExplicitlyDefined() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo(array( + 'fabien@example.com' => 'Fabien', + 'chris@example.com' => 'Chris (To)', + 'lars-to@internal.com' => 'Lars (To)', + )) + ->setCc(array( + 'fabien@example.com' => 'Fabien', + 'chris-cc@example.com' => 'Chris (Cc)', + 'lars-cc@internal.org' => 'Lars (Cc)', + )) + ->setBcc(array( + 'fabien@example.com' => 'Fabien', + 'chris-bcc@example.com' => 'Chris (Bcc)', + 'john-bcc@example.org' => 'John (Bcc)', + )) + ->setBody('...') + ; + + $recipients = array('god@example.com', 'fabien@example.com'); + $patterns = array('/^.*@internal.[a-z]+$/'); + + $plugin = new Swift_Plugins_RedirectingPlugin($recipients, $patterns); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals( + $message->getTo(), + array('fabien@example.com' => 'Fabien', 'lars-to@internal.com' => 'Lars (To)', 'god@example.com' => null) + ); + $this->assertEquals( + $message->getCc(), + array('fabien@example.com' => 'Fabien', 'lars-cc@internal.org' => 'Lars (Cc)') + ); + $this->assertEquals($message->getBcc(), array('fabien@example.com' => 'Fabien')); + } + + // -- Creation Methods + + private function _createSendEvent(Swift_Mime_Message $message) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getMessage') + ->will($this->returnValue($message)); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php new file mode 100644 index 000000000..810188300 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php @@ -0,0 +1,88 @@ +_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array()); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedTo() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo', 'zip@button' => 'Zip')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedCc() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $message->shouldReceive('getCc')->zeroOrMoreTimes()->andReturn(array('zip@button' => 'Zip', 'test@test.com' => 'Test')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + $reporter->shouldReceive('notify')->once()->with($message, 'test@test.com', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedBcc() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $message->shouldReceive('getBcc')->zeroOrMoreTimes()->andReturn(array('zip@button' => 'Zip', 'test@test.com' => 'Test')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + $reporter->shouldReceive('notify')->once()->with($message, 'test@test.com', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + // -- Creation Methods + + private function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + private function _createSendEvent() + { + return $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + } + + private function _createReporter() + { + return $this->getMockery('Swift_Plugins_Reporter')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php new file mode 100644 index 000000000..4d31c3c6a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php @@ -0,0 +1,64 @@ +_hitReporter = new Swift_Plugins_Reporters_HitReporter(); + $this->_message = $this->getMock('Swift_Mime_Message'); + } + + public function testReportingFail() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testMultipleReports() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld', 'zip@button'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testReportingPassIsIgnored() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_PASS + ); + $this->assertEquals(array('foo@bar.tld'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testBufferCanBeCleared() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld', 'zip@button'), + $this->_hitReporter->getFailedRecipients() + ); + $this->_hitReporter->clear(); + $this->assertEquals(array(), $this->_hitReporter->getFailedRecipients()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php new file mode 100644 index 000000000..3e78fca5b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php @@ -0,0 +1,54 @@ +_html = new Swift_Plugins_Reporters_HtmlReporter(); + $this->_message = $this->getMock('Swift_Mime_Message'); + } + + public function testReportingPass() + { + ob_start(); + $this->_html->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_PASS + ); + $html = ob_get_clean(); + + $this->assertRegExp('~ok|pass~i', $html, '%s: Reporter should indicate pass'); + $this->assertRegExp('~foo@bar\.tld~', $html, '%s: Reporter should show address'); + } + + public function testReportingFail() + { + ob_start(); + $this->_html->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $html = ob_get_clean(); + + $this->assertRegExp('~fail~i', $html, '%s: Reporter should indicate fail'); + $this->assertRegExp('~zip@button~', $html, '%s: Reporter should show address'); + } + + public function testMultipleReports() + { + ob_start(); + $this->_html->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_PASS + ); + $this->_html->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $html = ob_get_clean(); + + $this->assertRegExp('~ok|pass~i', $html, '%s: Reporter should indicate pass'); + $this->assertRegExp('~foo@bar\.tld~', $html, '%s: Reporter should show address'); + $this->assertRegExp('~fail~i', $html, '%s: Reporter should indicate fail'); + $this->assertRegExp('~zip@button~', $html, '%s: Reporter should show address'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php new file mode 100644 index 000000000..a50f14f9f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php @@ -0,0 +1,104 @@ +_createSleeper(); + $timer = $this->_createTimer(); + + //10MB/min + $plugin = new Swift_Plugins_ThrottlerPlugin( + 10000000, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE, + $sleeper, $timer + ); + + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 0.6 + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 1.2 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 1.8 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2.4 (sleep 1) + $sleeper->shouldReceive('sleep')->twice()->with(1); + + //10,000,000 bytes per minute + //100,000 bytes per email + + // .: (10,000,000/100,000)/60 emails per second = 1.667 emais/sec + + $message = $this->_createMessageWithByteCount(100000); //100KB + + $evt = $this->_createSendEvent($message); + + for ($i = 0; $i < 5; ++$i) { + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + } + + public function testMessagesPerMinuteThrottling() + { + $sleeper = $this->_createSleeper(); + $timer = $this->_createTimer(); + + //60/min + $plugin = new Swift_Plugins_ThrottlerPlugin( + 60, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE, + $sleeper, $timer + ); + + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); //expected 1 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 3 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(4); //expected 4 + $sleeper->shouldReceive('sleep')->twice()->with(1); + + //60 messages per minute + //1 message per second + + $message = $this->_createMessageWithByteCount(10); + + $evt = $this->_createSendEvent($message); + + for ($i = 0; $i < 5; ++$i) { + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + } + + // -- Creation Methods + + private function _createSleeper() + { + return $this->getMockery('Swift_Plugins_Sleeper'); + } + + private function _createTimer() + { + return $this->getMockery('Swift_Plugins_Timer'); + } + + private function _createMessageWithByteCount($bytes) + { + $msg = $this->getMockery('Swift_Mime_Message'); + $msg->shouldReceive('toByteStream') + ->zeroOrMoreTimes() + ->andReturnUsing(function ($is) use ($bytes) { + for ($i = 0; $i < $bytes; ++$i) { + $is->write('x'); + } + }); + + return $msg; + } + + private function _createSendEvent($message) + { + $evt = $this->getMockery('Swift_Events_SendEvent'); + $evt->shouldReceive('getMessage') + ->zeroOrMoreTimes() + ->andReturn($message); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php new file mode 100644 index 000000000..13c1b4c1e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php @@ -0,0 +1,227 @@ +markTestSkipped( + 'skipping because of https://bugs.php.net/bug.php?id=61421' + ); + } + } + + public function testBasicSigningHeaderManipulation() + { + $headers = $this->_createHeaders(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + /* @var $signer Swift_Signers_HeaderSigner */ + $altered = $signer->getAlteredHeaders(); + $signer->reset(); + // Headers + $signer->setHeaders($headers); + // Body + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + // Signing + $signer->addSignature($headers); + } + + // Default Signing + public function testSigningDefaults() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setSignatureTimestamp('1299879181'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha1; bh=wlbYcY9O9OPInGJ4D0E/rGsvMLE=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; t=1299879181; b=RMSNelzM2O5MAAnMjT3G3/VF36S3DGJXoPCXR001F1WDReu0prGphWjuzK/m6V1pwqQL8cCNg Hi74mTx2bvyAvmkjvQtJf1VMUOCc9WHGcm1Yec66I3ZWoNMGSWZ1EKAm2CtTzyG0IFw4ml9DI wSkyAFxlgicckDD6FibhqwX4w='); + } + + // SHA256 Signing + public function testSigning256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; t=1299879181; b=jqPmieHzF5vR9F4mXCAkowuphpO4iJ8IAVuioh1BFZ3VITXZj5jlOFxULJMBiiApm2keJirnh u4mzogj444QkpT3lJg8/TBGAYQPdcvkG3KC0jdyN6QpSgpITBJG2BwWa+keXsv2bkQgLRAzNx qRhP45vpHCKun0Tg9LrwW/KCg='); + } + + // Relaxed/Relaxed Hash Signing + public function testSigningRelaxedRelaxed256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setBodyCanon('relaxed'); + $signer->setHeaderCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=relaxed/relaxed; t=1299879181; b=gzOI+PX6HpZKQFzwwmxzcVJsyirdLXOS+4pgfCpVHQIdqYusKLrhlLeFBTNoz75HrhNvGH6T0 Rt3w5aTqkrWfUuAEYt0Ns14GowLM7JojaFN+pZ4eYnRB3CBBgW6fee4NEMD5WPca3uS09tr1E 10RYh9ILlRtl+84sovhx5id3Y='); + } + + // Relaxed/Simple Hash Signing + public function testSigningRelaxedSimple256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setHeaderCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=relaxed; t=1299879181; b=dLPJNec5v81oelyzGOY0qPqTlGnQeNfUNBOrV/JKbStr3NqWGI9jH4JAe2YvO2V32lfPNoby1 4MMzZ6EPkaZkZDDSPa+53YbCPQAlqiD9QZZIUe2UNM33HN8yAMgiWEF5aP7MbQnxeVZMfVLEl 9S8qOImu+K5JZqhQQTL0dgLwA='); + } + + // Simple/Relaxed Hash Signing + public function testSigningSimpleRelaxed256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = 'Hello World'; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))).'/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setBodyCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=simple/relaxed; t=1299879181; b=M5eomH/zamyzix9kOes+6YLzQZxuJdBP4x3nP9zF2N26eMLG2/cBKbnNyqiOTDhJdYfWPbLIa 1CWnjST0j5p4CpeOkGYuiE+M4TWEZwhRmRWootlPO3Ii6XpbBJKFk1o9zviS7OmXblUUE4aqb yRSIMDhtLdCK5GlaCneFLN7RQ='); + } + + // -- Creation Methods + private function _createHeaderSet() + { + $cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $grammar = new Swift_Mime_Grammar(); + $headers = new Swift_Mime_SimpleHeaderSet(new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar)); + + return $headers; + } + + /** + * @return Swift_Mime_Headers + */ + private function _createHeaders() + { + $x = 0; + $cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $grammar = new Swift_Mime_Grammar(); + $headerFactory = new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar); + $headers = $this->getMockery('Swift_Mime_HeaderSet'); + + $headers->shouldReceive('listAll') + ->zeroOrMoreTimes() + ->andReturn(array('From', 'To', 'Date', 'Subject')); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('From') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('From') + ->andReturn(array($headerFactory->createMailboxHeader('From', 'test@test.test'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('To') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('To') + ->andReturn(array($headerFactory->createMailboxHeader('To', 'test@test.test'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('Date') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('Date') + ->andReturn(array($headerFactory->createTextHeader('Date', 'Fri, 11 Mar 2011 20:56:12 +0000 (GMT)'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('Subject') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('Subject') + ->andReturn(array($headerFactory->createTextHeader('Subject', 'Foo Bar Text Message'))); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes() + ->with('DKIM-Signature', \Mockery::any()) + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('DKIM-Signature') + ->andReturn(array($headerFactory->createTextHeader('DKIM-Signature', 'Foo Bar Text Message'))); + + return $headers; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php new file mode 100644 index 000000000..00e48c139 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php @@ -0,0 +1,45 @@ +markTestSkipped( + 'Need OpenDKIM extension run these tests.' + ); + } + } + + public function testBasicSigningHeaderManipulation() + { + } + + // Default Signing + public function testSigningDefaults() + { + } + + // SHA256 Signing + public function testSigning256() + { + } + + // Relaxed/Relaxed Hash Signing + public function testSigningRelaxedRelaxed256() + { + } + + // Relaxed/Simple Hash Signing + public function testSigningRelaxedSimple256() + { + } + + // Simple/Relaxed Hash Signing + public function testSigningSimpleRelaxed256() + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php new file mode 100644 index 000000000..df745ef2d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php @@ -0,0 +1,554 @@ +replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->samplesDir = str_replace('\\', '/', realpath(__DIR__.'/../../../_samples/')).'/'; + } + + public function testUnSingedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $this->assertEquals('Here is the message itself', $message->getBody()); + } + + public function testSingedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir.'smime/sign.crt', $this->samplesDir.'smime/sign.key'); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $messageStream); + unset($messageStream); + } + + public function testSingedMessageExtraCerts() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir.'smime/sign2.crt', $this->samplesDir.'smime/sign2.key', PKCS7_DETACHED, $this->samplesDir.'smime/intermediate.crt'); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $messageStream); + unset($messageStream); + } + + public function testSingedMessageBinary() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir.'smime/sign.crt', $this->samplesDir.'smime/sign.key', PKCS7_BINARY); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=signed\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $this->assertEquals($headers['content-transfer-encoding'], 'base64'); + $this->assertEquals($headers['content-disposition'], 'attachment; filename="smime.p7m"'); + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $messageStreamClean = $this->newFilteredStream(); + + $this->assertValidVerify($expectedBody, $messageStream); + unset($messageStreamClean, $messageStream); + } + + public function testSingedMessageWithAttachments() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $message->attach(Swift_Attachment::fromPath($this->samplesDir.'/files/textfile.zip')); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir.'smime/sign.crt', $this->samplesDir.'smime/sign.key'); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $messageStream); + unset($messageStream); + } + + public function testEncryptedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setEncryptCertificate($this->samplesDir.'smime/encrypt.crt'); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://'.$this->samplesDir.'smime/encrypt.crt', array('file://'.$this->samplesDir.'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream, $messageStream); + } + + public function testEncryptedMessageWithMultipleCerts() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setEncryptCertificate(array($this->samplesDir.'smime/encrypt.crt', $this->samplesDir.'smime/encrypt2.crt')); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://'.$this->samplesDir.'smime/encrypt.crt', array('file://'.$this->samplesDir.'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream); + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://'.$this->samplesDir.'smime/encrypt2.crt', array('file://'.$this->samplesDir.'smime/encrypt2.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream, $messageStream); + } + + public function testSignThenEncryptedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir.'smime/sign.crt', $this->samplesDir.'smime/sign.key'); + $signer->setEncryptCertificate($this->samplesDir.'smime/encrypt.crt'); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://'.$this->samplesDir.'smime/encrypt.crt', array('file://'.$this->samplesDir.'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $entityString = $decryptedMessageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $decryptedMessageStream)) { + return false; + } + + unset($decryptedMessageStream, $messageStream); + } + + public function testEncryptThenSignMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = Swift_Signers_SMimeSigner::newInstance(); + $signer->setSignCertificate($this->samplesDir.'smime/sign.crt', $this->samplesDir.'smime/sign.key'); + $signer->setEncryptCertificate($this->samplesDir.'smime/encrypt.crt'); + $signer->setSignThenEncrypt(false); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<MIME-Version: 1\.0 +Content-Disposition: attachment; filename="smime\.p7m" +Content-Type: application/(x\-)?pkcs7-mime; smime-type=enveloped-data; name="smime\.p7m" +Content-Transfer-Encoding: base64 + +(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2}) + + +)--$boundary +Content-Type: application/(x\-)?pkcs7-signature; name="smime\.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime\.p7s" + +(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2}) + +--$boundary-- +OEL; + + if (!$this->assertValidVerify($expectedBody, $messageStream)) { + return false; + } + + $expectedBody = str_replace("\n", "\r\n", $expectedBody); + if (!preg_match('%'.$expectedBody.'*%m', $entityString, $entities)) { + $this->fail('Failed regex match.'); + + return false; + } + + $messageStreamClean = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStreamClean->write($entities['encrypted_message']); + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStreamClean->getPath(), $decryptedMessageStream->getPath(), 'file://'.$this->samplesDir.'smime/encrypt.crt', array('file://'.$this->samplesDir.'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($messageStreamClean, $messageStream, $decryptedMessageStream); + } + + protected function assertValidVerify($expected, Swift_ByteStream_TemporaryFileByteStream $messageStream) + { + $actual = $messageStream->getContent(); + + // File is UNIX encoded so convert them to correct line ending + $expected = str_replace("\n", "\r\n", $expected); + + $actual = trim(self::getBodyOfMessage($actual)); + if (!$this->assertRegExp('%^'.$expected.'$\s*%m', $actual)) { + return false; + } + + $opensslOutput = new Swift_ByteStream_TemporaryFileByteStream(); + $verify = openssl_pkcs7_verify($messageStream->getPath(), null, $opensslOutput->getPath(), array($this->samplesDir.'smime/ca.crt')); + + if (false === $verify) { + $this->fail('Verification of the message failed.'); + + return false; + } elseif (-1 === $verify) { + $this->fail(sprintf('Verification of the message failed. Internal error "%s".', openssl_error_string())); + + return false; + } + + return true; + } + + protected function getBoundary($contentType) + { + if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $contentType, $contentTypeData)) { + $this->fail('Failed to find Boundary parameter'); + + return false; + } + + return trim($contentTypeData[1], '"'); + } + + protected function newFilteredStream() + { + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + return $messageStream; + } + + protected static function getBodyOfMessage($message) + { + return substr($message, strpos($message, "\r\n\r\n")); + } + + /** + * Strips of the sender headers and Mime-Version. + * + * @param Swift_ByteStream_TemporaryFileByteStream $messageStream + * @param Swift_ByteStream_TemporaryFileByteStream $inputStream + */ + protected function cleanMessage($content) + { + $newContent = ''; + + $headers = self::getHeadersOfMessage($content); + foreach ($headers as $headerName => $value) { + if (!in_array($headerName, array('content-type', 'content-transfer-encoding', 'content-disposition'))) { + continue; + } + + $headerName = explode('-', $headerName); + $headerName = array_map('ucfirst', $headerName); + $headerName = implode('-', $headerName); + + if (strlen($value) > 62) { + $value = wordwrap($value, 62, "\n "); + } + + $newContent .= "$headerName: $value\r\n"; + } + + return $newContent."\r\n".ltrim(self::getBodyOfMessage($content)); + } + + /** + * Returns the headers of the message. + * + * Header-names are lowercase. + * + * @param string $message + * + * @return array + */ + protected static function getHeadersOfMessage($message) + { + $headersPosEnd = strpos($message, "\r\n\r\n"); + $headerData = substr($message, 0, $headersPosEnd); + $headerLines = explode("\r\n", $headerData); + + if (empty($headerLines)) { + return array(); + } + + $headers = array(); + + foreach ($headerLines as $headerLine) { + if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' '.trim($headerLine); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0]); + $headers[$currentHeaderName] = trim($header[1]); + } + + return $headers; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php new file mode 100644 index 000000000..e4d4f48d8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php @@ -0,0 +1,131 @@ +_createFilter(array(0x61, 0x62), array(0x63, 0x64)); + $this->assertEquals( + array(0x59, 0x60, 0x63, 0x64, 0x65), + $filter->filter(array(0x59, 0x60, 0x61, 0x62, 0x65)) + ); + } + + public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() + { + $filter = $this->_createFilter(array(0x61, 0x62), array(0x63, 0x64)); + $this->assertTrue($filter->shouldBuffer(array(0x59, 0x60, 0x61)), + '%s: Filter should buffer since 0x61 0x62 is the needle and the ending '. + '0x61 could be from 0x61 0x62' + ); + } + + public function testFilterCanMakeMultipleReplacements() + { + $filter = $this->_createFilter(array(array(0x61), array(0x62)), array(0x63)); + $this->assertEquals( + array(0x60, 0x63, 0x60, 0x63, 0x60), + $filter->filter(array(0x60, 0x61, 0x60, 0x62, 0x60)) + ); + } + + public function testMultipleReplacementsCanBeDifferent() + { + $filter = $this->_createFilter(array(array(0x61), array(0x62)), array(array(0x63), array(0x64))); + $this->assertEquals( + array(0x60, 0x63, 0x60, 0x64, 0x60), + $filter->filter(array(0x60, 0x61, 0x60, 0x62, 0x60)) + ); + } + + public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() + { + $filter = $this->_createFilter(array(0x0D, 0x0A), array(0x0A)); + $this->assertFalse($filter->shouldBuffer(array(0x61, 0x62, 0x0D, 0x0A, 0x63)), + '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' + ); + } + + public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() + { + $filter = $this->_createFilter(array(array(0x61, 0x62), array(0x63)), array(0x64)); + $this->assertTrue($filter->shouldBuffer(array(0x59, 0x60, 0x61)), + '%s: Filter should buffer since 0x61 0x62 is a needle and the ending '. + '0x61 could be from 0x61 0x62' + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsLF() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x61, 0x0A, 0x62, 0x0A, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsCR() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0D, 0x61, 0x0D, 0x62, 0x0D, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsCRLF() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsLFCR() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x0D, 0x61, 0x0A, 0x0D, 0x62, 0x0A, 0x0D, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputContainsLFLF() + { + //Lighthouse Bug #23 + + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x0A, 0x61, 0x0A, 0x0A, 0x62, 0x0A, 0x0A, 0x63)) + ); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_ByteArrayReplacementFilter($search, $replace); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php new file mode 100644 index 000000000..bd44f5c74 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php @@ -0,0 +1,38 @@ +_createFactory(); + $this->assertInstanceof( + 'Swift_StreamFilters_StringReplacementFilter', + $factory->createFilter('a', 'b') + ); + } + + public function testSameInstancesAreCached() + { + $factory = $this->_createFactory(); + $filter1 = $factory->createFilter('a', 'b'); + $filter2 = $factory->createFilter('a', 'b'); + $this->assertSame($filter1, $filter2, '%s: Instances should be cached'); + } + + public function testDifferingInstancesAreNotCached() + { + $factory = $this->_createFactory(); + $filter1 = $factory->createFilter('a', 'b'); + $filter2 = $factory->createFilter('a', 'c'); + $this->assertNotEquals($filter1, $filter2, + '%s: Differing instances should not be cached' + ); + } + + // -- Creation methods + + private function _createFactory() + { + return new Swift_StreamFilters_StringReplacementFilterFactory(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php new file mode 100644 index 000000000..7a98a2f27 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php @@ -0,0 +1,55 @@ +_createFilter('foo', 'bar'); + $this->assertEquals('XbarYbarZ', $filter->filter('XfooYfooZ')); + } + + public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() + { + $filter = $this->_createFilter('foo', 'bar'); + $this->assertTrue($filter->shouldBuffer('XfooYf'), + '%s: Filter should buffer since "foo" is the needle and the ending '. + '"f" could be from "foo"' + ); + } + + public function testFilterCanMakeMultipleReplacements() + { + $filter = $this->_createFilter(array('a', 'b'), 'foo'); + $this->assertEquals('XfooYfooZ', $filter->filter('XaYbZ')); + } + + public function testMultipleReplacementsCanBeDifferent() + { + $filter = $this->_createFilter(array('a', 'b'), array('foo', 'zip')); + $this->assertEquals('XfooYzipZ', $filter->filter('XaYbZ')); + } + + public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() + { + $filter = $this->_createFilter("\r\n", "\n"); + $this->assertFalse($filter->shouldBuffer("foo\r\nbar"), + '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' + ); + } + + public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() + { + $filter = $this->_createFilter(array('foo', 'zip'), 'bar'); + $this->assertTrue($filter->shouldBuffer('XfooYzi'), + '%s: Filter should buffer since "zip" is a needle and the ending '. + '"zi" could be from "zip"' + ); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php new file mode 100644 index 000000000..121aaba09 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php @@ -0,0 +1,560 @@ +_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $listener = $this->getMockery('Swift_Events_EventListener'); + $smtp = $this->_getTransport($buf, $dispatcher); + $dispatcher->shouldReceive('bindEventListener') + ->once() + ->with($listener); + + $smtp->registerPlugin($listener); + } + + public function testSendingDispatchesBeforeSendEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $message = $this->_createMessage(); + $smtp = $this->_getTransport($buf, $dispatcher); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org' => 'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->once() + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeSendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendingDispatchesSendEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $message = $this->_createMessage(); + $smtp = $this->_getTransport($buf, $dispatcher); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org' => 'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->once() + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendEventCapturesFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org' => 'Mark')); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setFailedRecipients') + ->once() + ->with(array('mark@swiftmailer.org')); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testSendEventHasResultFailedIfAllFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org' => 'Mark')); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_FAILED); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testSendEventHasResultTentativeIfSomeFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array( + 'mark@swiftmailer.org' => 'Mark', + 'chris@site.tld' => 'Chris', + )); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_TENTATIVE); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendEventHasResultSuccessIfNoFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array( + 'mark@swiftmailer.org' => 'Mark', + 'chris@site.tld' => 'Chris', + )); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_SUCCESS); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(2, $smtp->send($message)); + } + + public function testCancellingEventBubbleBeforeSendStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org' => null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org' => 'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeSendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testStartingTransportDispatchesTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'transportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testStartingTransportDispatchesBeforeTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testCancellingBubbleBeforeTransportStartStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + + $this->assertFalse($smtp->isStarted(), + '%s: Transport should not be started since event bubble was cancelled' + ); + } + + public function testStoppingTransportDispatchesTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'transportStopped'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + } + + public function testStoppingTransportDispatchesBeforeTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStopped'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + } + + public function testCancellingBubbleBeforeTransportStoppedStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $hasRun = false; + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStopped') + ->andReturnUsing(function () use (&$hasRun) { + $hasRun = true; + }); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$hasRun) { + return $hasRun; + }); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + + $this->assertTrue($smtp->isStarted(), + '%s: Transport should not be stopped since event bubble was cancelled' + ); + } + + public function testResponseEventsAreGenerated() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_ResponseEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createResponseEvent') + ->atLeast()->once() + ->with($smtp, \Mockery::any(), \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->atLeast()->once() + ->with($evt, 'responseReceived'); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testCommandEventsAreGenerated() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_CommandEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createCommandEvent') + ->once() + ->with($smtp, \Mockery::any(), \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'commandSent'); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testExceptionsCauseExceptionEvents() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportExceptionEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $buf->shouldReceive('readLine') + ->atLeast()->once() + ->andReturn("503 I'm sleepy, go away!\r\n"); + $dispatcher->shouldReceive('createTransportExceptionEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'exceptionThrown'); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + try { + $smtp->start(); + $this->fail('TransportException should be thrown on invalid response'); + } catch (Swift_TransportException $e) { + } + } + + public function testExceptionBubblesCanBeCancelled() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportExceptionEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $buf->shouldReceive('readLine') + ->atLeast()->once() + ->andReturn("503 I'm sleepy, go away!\r\n"); + $dispatcher->shouldReceive('createTransportExceptionEvent') + ->twice() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->twice() + ->with($evt, 'exceptionThrown'); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + // -- Creation Methods + + protected function _createEventDispatcher($stub = true) + { + return $this->getMockery('Swift_Events_EventDispatcher')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php new file mode 100644 index 000000000..f49b489ed --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php @@ -0,0 +1,1249 @@ +_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->assertTrue($smtp->isStarted(), '%s: start() should have started connection'); + } catch (Exception $e) { + $this->fail('220 is a valid SMTP greeting and should be accepted'); + } + } + + public function testBadGreetingCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("554 I'm busy\r\n"); + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('554 greeting indicates an error and should cause an exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: start() should have failed'); + } + } + + public function testStartSendsHeloToInitiate() + { + /* -- RFC 2821, 3.2. + + 3.2 Client Initiation + + Once the server has sent the welcoming message and the client has + received it, the client normally sends the EHLO command to the + server, indicating the client's identity. In addition to opening the + session, use of EHLO indicates that the client is able to process + service extensions and requests that the server provide a list of the + extensions it supports. Older SMTP systems which are unable to + support service extensions and contemporary clients which do not + require service extensions in the mail session being initiated, MAY + use HELO instead of EHLO. Servers MUST NOT return the extended + EHLO-style response to a HELO command. For a particular connection + attempt, if the server returns a "command not recognized" response to + EHLO, the client SHOULD be able to fall back and send HELO. + + In the EHLO command the host sending the command identifies itself; + the command may be interpreted as saying "Hello, I am " (and, + in the case of EHLO, "and I support service extension requests"). + + -- RFC 2281, 4.1.1.1. + + ehlo = "EHLO" SP Domain CRLF + helo = "HELO" SP Domain CRLF + + -- RFC 2821, 4.3.2. + + EHLO or HELO + S: 250 + E: 504, 550 + + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail('Starting SMTP should send HELO and accept 250 response'); + } + } + + public function testInvalidHeloResponseCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('504 WTF'."\r\n"); + + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('Non 250 HELO response should raise Exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: SMTP start() should have failed'); + } + } + + public function testDomainNameIsPlacedInHelo() + { + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("HELO mydomain.com\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testSuccessfulMailCommand() + { + /* -- RFC 2821, 3.3. + + There are three steps to SMTP mail transactions. The transaction + starts with a MAIL command which gives the sender identification. + + ..... + + The first step in the procedure is the MAIL command. + + MAIL FROM: [SP ] + + -- RFC 2821, 4.1.1.2. + + Syntax: + + "MAIL FROM:" ("<>" / Reverse-Path) + [SP Mail-parameters] CRLF + -- RFC 2821, 4.1.2. + + Reverse-path = Path + Forward-path = Path + Path = "<" [ A-d-l ":" ] Mailbox ">" + A-d-l = At-domain *( "," A-d-l ) + ; Note that this form, the so-called "source route", + ; MUST BE accepted, SHOULD NOT be generated, and SHOULD be + ; ignored. + At-domain = "@" domain + + -- RFC 2821, 4.3.2. + + MAIL + S: 250 + E: 552, 451, 452, 550, 553, 503 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('MAIL FROM should accept a 250 response'); + } + } + + public function testInvalidResponseCodeFromMailCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('553 Bad'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('MAIL FROM should accept a 250 response'); + } catch (Exception $e) { + } + } + + public function testSenderIsPreferredOverFrom() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getSender') + ->once() + ->andReturn(array('another@domain.com' => 'Someone')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testReturnPathIsPreferredOverSender() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getSender') + ->once() + ->andReturn(array('another@domain.com' => 'Someone')); + $message->shouldReceive('getReturnPath') + ->once() + ->andReturn('more@domain.com'); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testSuccessfulRcptCommandWith250Response() + { + /* -- RFC 2821, 3.3. + + The second step in the procedure is the RCPT command. + + RCPT TO: [ SP ] + + The first or only argument to this command includes a forward-path + (normally a mailbox and domain, always surrounded by "<" and ">" + brackets) identifying one recipient. If accepted, the SMTP server + returns a 250 OK reply and stores the forward-path. If the recipient + is known not to be a deliverable address, the SMTP server returns a + 550 reply, typically with a string such as "no such user - " and the + mailbox name (other circumstances and reply codes are possible). + This step of the procedure can be repeated any number of times. + + -- RFC 2821, 4.1.1.3. + + This command is used to identify an individual recipient of the mail + data; multiple recipients are specified by multiple use of this + command. The argument field contains a forward-path and may contain + optional parameters. + + The forward-path normally consists of the required destination + mailbox. Sending systems SHOULD not generate the optional list of + hosts known as a source route. + + ....... + + "RCPT TO:" ("" / "" / Forward-Path) + [SP Rcpt-parameters] CRLF + + -- RFC 2821, 4.2.2. + + 250 Requested mail action okay, completed + 251 User not local; will forward to + (See section 3.4) + 252 Cannot VRFY user, but will accept message and attempt + delivery + + -- RFC 2821, 4.3.2. + + RCPT + S: 250, 251 (but see section 3.4 for discussion of 251 and 551) + E: 550, 551, 552, 553, 450, 451, 452, 503, 550 + */ + + //We'll treat 252 as accepted since it isn't really a failure + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('RCPT TO should accept a 250 response'); + } + } + + public function testMailFromCommandIsOnlySentOncePerMessage() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->never() + ->with("MAIL FROM:\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testMultipleRecipientsSendsMultipleRcpt() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array( + 'foo@bar' => null, + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testCcRecipientsSendsMultipleRcpt() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getCc') + ->once() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testSendReturnsNumberOfSuccessfulRecipients() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getCc') + ->once() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('501 Nobody here'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(2, $smtp->send($message), + '%s: 1 of 3 recipients failed so 2 should be returned' + ); + } + + public function testRsetIsSentIfNoSuccessfulRecipients() + { + /* --RFC 2821, 4.1.1.5. + + This command specifies that the current mail transaction will be + aborted. Any stored sender, recipients, and mail data MUST be + discarded, and all buffers and state tables cleared. The receiver + MUST send a "250 OK" reply to a RSET command with no arguments. A + reset command may be issued by the client at any time. + + -- RFC 2821, 4.3.2. + + RSET + S: 250 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('503 Bad'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RSET\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message), + '%s: 1 of 1 recipients failed so 0 should be returned' + ); + } + + public function testSuccessfulDataCommand() + { + /* -- RFC 2821, 3.3. + + The third step in the procedure is the DATA command (or some + alternative specified in a service extension). + + DATA + + If accepted, the SMTP server returns a 354 Intermediate reply and + considers all succeeding lines up to but not including the end of + mail data indicator to be the message text. + + -- RFC 2821, 4.1.1.4. + + The receiver normally sends a 354 response to DATA, and then treats + the lines (strings ending in sequences, as described in + section 2.3.7) following the command as mail data from the sender. + This command causes the mail data to be appended to the mail data + buffer. The mail data may contain any of the 128 ASCII character + codes, although experience has indicated that use of control + characters other than SP, HT, CR, and LF may cause problems and + SHOULD be avoided when possible. + + -- RFC 2821, 4.3.2. + + DATA + I: 354 -> data -> S: 250 + E: 552, 554, 451, 452 + E: 451, 554, 503 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 Go ahead'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('354 is the expected response to DATA'); + } + } + + public function testBadDataResponseCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('451 Bad'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('354 is the expected response to DATA (not observed)'); + } catch (Exception $e) { + } + } + + public function testMessageIsStreamedToBufferForData() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("\r\n.\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testBadResponseAfterDataTransmissionCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 OK'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("\r\n.\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('554 Error'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('250 is the expected response after a DATA transmission (not observed)'); + } catch (Exception $e) { + } + } + + public function testBccRecipientsAreRemovedFromHeaders() + { + /* -- RFC 2821, 7.2. + + Addresses that do not appear in the message headers may appear in the + RCPT commands to an SMTP server for a number of reasons. The two + most common involve the use of a mailing address as a "list exploder" + (a single address that resolves into multiple addresses) and the + appearance of "blind copies". Especially when more than one RCPT + command is present, and in order to avoid defeating some of the + purpose of these mechanisms, SMTP clients and servers SHOULD NOT copy + the full set of RCPT command arguments into the headers, either as + part of trace headers or as informational or private-extension + headers. Since this rule is often violated in practice, and cannot + be enforced, sending SMTP systems that are aware of "bcc" use MAY + find it helpful to send each blind copy as a separate message + transaction containing only a single RCPT command. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $message->shouldReceive('setBcc') + ->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testEachBccRecipientIsSentASeparateMessage() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array('zip@button' => 'Zip Button')); + $message->shouldReceive('setBcc') + ->once() + ->with(array('test@domain' => 'Test user')); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(1); + $buf->shouldReceive('readLine')->once()->with(1)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(2); + $buf->shouldReceive('readLine')->once()->with(2)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(3); + $buf->shouldReceive('readLine')->once()->with(3)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(4); + $buf->shouldReceive('readLine')->once()->with(4)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(5); + $buf->shouldReceive('readLine')->once()->with(5)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(6); + $buf->shouldReceive('readLine')->once()->with(6)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(7); + $buf->shouldReceive('readLine')->once()->with(7)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(8); + $buf->shouldReceive('readLine')->once()->with(8)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(9); + $buf->shouldReceive('readLine')->once()->with(9)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(10); + $buf->shouldReceive('readLine')->once()->with(10)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(11); + $buf->shouldReceive('readLine')->once()->with(11)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(12); + $buf->shouldReceive('readLine')->once()->with(12)->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(3, $smtp->send($message)); + } + + public function testMessageStateIsRestoredOnFailure() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $message->shouldReceive('setBcc') + ->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("451 No\r\n"); + + $this->_finishBuffer($buf); + + $smtp->start(); + try { + $smtp->send($message); + $this->fail('A bad response was given so exception is expected'); + } catch (Exception $e) { + } + } + + public function testStopSendsQuitCommand() + { + /* -- RFC 2821, 4.1.1.10. + + This command specifies that the receiver MUST send an OK reply, and + then close the transmission channel. + + The receiver MUST NOT intentionally close the transmission channel + until it receives and replies to a QUIT command (even if there was an + error). The sender MUST NOT intentionally close the transmission + channel until it sends a QUIT command and SHOULD wait until it + receives the reply (even if there was an error response to a previous + command). If the connection is closed prematurely due to violations + of the above or system or network failure, the server MUST cancel any + pending transaction, but not undo any previously completed + transaction, and generally MUST act as if the command or transaction + in progress had received a temporary error (i.e., a 4yz response). + + The QUIT command may be issued at any time. + + Syntax: + "QUIT" CRLF + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('write') + ->once() + ->with("QUIT\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("221 Bye\r\n"); + $buf->shouldReceive('terminate') + ->once(); + + $this->_finishBuffer($buf); + + $this->assertFalse($smtp->isStarted()); + $smtp->start(); + $this->assertTrue($smtp->isStarted()); + $smtp->stop(); + $this->assertFalse($smtp->isStarted()); + } + + public function testBufferCanBeFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ref = $smtp->getBuffer(); + $this->assertEquals($buf, $ref); + } + + public function testBufferCanBeWrittenToUsingExecuteCommand() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("FOO\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(1) + ->andReturn("250 OK\r\n"); + + $res = $smtp->executeCommand("FOO\r\n"); + $this->assertEquals("250 OK\r\n", $res); + } + + public function testResponseCodesAreValidated() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("FOO\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(1) + ->andReturn("551 Not ok\r\n"); + + try { + $smtp->executeCommand("FOO\r\n", array(250, 251)); + $this->fail('A 250 or 251 response was needed but 551 was returned.'); + } catch (Exception $e) { + } + } + + public function testFailedRecipientsCanBeCollectedByReference() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array('zip@button' => 'Zip Button')); + $message->shouldReceive('setBcc') + ->once() + ->with(array('test@domain' => 'Test user')); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user', + )); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(1); + $buf->shouldReceive('readLine')->once()->with(1)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(2); + $buf->shouldReceive('readLine')->once()->with(2)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(3); + $buf->shouldReceive('readLine')->once()->with(3)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(4); + $buf->shouldReceive('readLine')->once()->with(4)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(5); + $buf->shouldReceive('readLine')->once()->with(5)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(6); + $buf->shouldReceive('readLine')->once()->with(6)->andReturn("500 Bad\r\n"); + $buf->shouldReceive('write')->once()->with("RSET\r\n")->andReturn(7); + $buf->shouldReceive('readLine')->once()->with(7)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM:\r\n")->andReturn(9); + $buf->shouldReceive('readLine')->once()->with(9)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO:\r\n")->andReturn(10); + $buf->shouldReceive('readLine')->once()->with(10)->andReturn("500 Bad\r\n"); + $buf->shouldReceive('write')->once()->with("RSET\r\n")->andReturn(11); + $buf->shouldReceive('readLine')->once()->with(11)->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message, $failures)); + $this->assertEquals(array('zip@button', 'test@domain'), $failures, + '%s: Failures should be caught in an array' + ); + } + + public function testSendingRegeneratesMessageId() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('generateId') + ->once(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + protected function _getBuffer() + { + return $this->getMockery('Swift_Transport_IoBuffer')->shouldIgnoreMissing(); + } + + protected function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + protected function _finishBuffer($buf) + { + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(0) + ->andReturn('220 server.com foo'."\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^(EH|HE)LO .*?\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn('250 ServerName'."\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^MAIL FROM:<.*?>\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^RCPT TO:<.*?>\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("DATA\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("354 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("\r\n.\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("RSET\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturn(false); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->andReturn(false); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php new file mode 100644 index 000000000..f64b0716a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php @@ -0,0 +1,66 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsCramMd5() + { + /* -- RFC 2195, 2. + The authentication type associated with CRAM is "CRAM-MD5". + */ + + $cram = $this->_getAuthenticator(); + $this->assertEquals('CRAM-MD5', $cram->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + $cram = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH CRAM-MD5\r\n", array(334)) + ->andReturn('334 '.base64_encode('')."\r\n"); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(\Mockery::any(), array(235)); + + $this->assertTrue($cram->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $cram = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH CRAM-MD5\r\n", array(334)) + ->andReturn('334 '.base64_encode('')."\r\n"); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(\Mockery::any(), array(235)) + ->andThrow(new Swift_TransportException('')); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($cram->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_CramMd5Authenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php new file mode 100644 index 000000000..fc6e80695 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php @@ -0,0 +1,66 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsLogin() + { + $login = $this->_getAuthenticator(); + $this->assertEquals('LOGIN', $login->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + $login = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH LOGIN\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('jack')."\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('pass')."\r\n", array(235)); + + $this->assertTrue($login->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $login = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH LOGIN\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('jack')."\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('pass')."\r\n", array(235)) + ->andThrow(new Swift_TransportException('')); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($login->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_LoginAuthenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php new file mode 100644 index 000000000..dd26294cd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php @@ -0,0 +1,235 @@ +markTestSkipped( + 'One of the required functions is not available.' + ); + } + } + + public function testKeywordIsNtlm() + { + $login = $this->_getAuthenticator(); + $this->assertEquals('NTLM', $login->getAuthKeyword()); + } + + public function testMessage1Generator() + { + $login = $this->_getAuthenticator(); + $message1 = $this->_invokePrivateMethod('createMessage1', $login); + + $this->assertEquals($this->_message1, bin2hex($message1), + '%s: We send the smallest ntlm message which should never fail.' + ); + } + + public function testLMv1Generator() + { + $password = 'test1234'; + $challenge = 'b019d38bad875c9d'; + $lmv1 = '1879f60127f8a877022132ec221bcbf3ca016a9f76095606'; + + $login = $this->_getAuthenticator(); + $lmv1Result = $this->_invokePrivateMethod('createLMPassword', $login, array($password, $this->hex2bin($challenge))); + + $this->assertEquals($lmv1, bin2hex($lmv1Result), + '%s: The keys should be the same cause we use the same values to generate them.' + ); + } + + public function testLMv2Generator() + { + $username = 'user'; + $password = 'SecREt01'; + $domain = 'DOMAIN'; + $challenge = '0123456789abcdef'; + $lmv2 = 'd6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344'; + + $login = $this->_getAuthenticator(); + $lmv2Result = $this->_invokePrivateMethod('createLMv2Password', $login, array($password, $username, $domain, $this->hex2bin($challenge), $this->hex2bin('ffffff0011223344'))); + + $this->assertEquals($lmv2, bin2hex($lmv2Result), + '%s: The keys should be the same cause we use the same values to generate them.' + ); + } + + public function testMessage3v1Generator() + { + $username = 'test'; + $domain = 'TESTNT'; + $workstation = 'MEMBER'; + $lmResponse = '1879f60127f8a877022132ec221bcbf3ca016a9f76095606'; + $ntlmResponse = 'e6285df3287c5d194f84df1a94817c7282d09754b6f9e02a'; + $message3T = '4e544c4d5353500003000000180018006000000018001800780000000c000c0040000000080008004c0000000c000c0054000000000000009a0000000102000054004500530054004e00540074006500730074004d0045004d004200450052001879f60127f8a877022132ec221bcbf3ca016a9f76095606e6285df3287c5d194f84df1a94817c7282d09754b6f9e02a'; + + $login = $this->_getAuthenticator(); + $message3 = $this->_invokePrivateMethod('createMessage3', $login, array($domain, $username, $workstation, $this->hex2bin($lmResponse), $this->hex2bin($ntlmResponse))); + + $this->assertEquals($message3T, bin2hex($message3), + '%s: We send the same information as the example is created with so this should be the same' + ); + } + + public function testMessage3v2Generator() + { + $username = 'test'; + $domain = 'TESTNT'; + $workstation = 'MEMBER'; + $lmResponse = 'bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9'; + $ntlmResponse = 'caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000'; + + $login = $this->_getAuthenticator(); + $message3 = $this->_invokePrivateMethod('createMessage3', $login, array($domain, $username, $workstation, $this->hex2bin($lmResponse), $this->hex2bin($ntlmResponse))); + + $this->assertEquals($this->_message3, bin2hex($message3), + '%s: We send the same information as the example is created with so this should be the same' + ); + } + + public function testGetDomainAndUsername() + { + $username = "DOMAIN\user"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('DOMAIN', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithExtension() + { + $username = "domain.com\user"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('domain.com', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithAtSymbol() + { + $username = 'user@DOMAIN'; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('DOMAIN', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithAtSymbolAndExtension() + { + $username = 'user@domain.com'; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('domain.com', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testSuccessfulAuthentication() + { + $domain = 'TESTNT'; + $username = 'test'; + $secret = 'test1234'; + + $ntlm = $this->_getAuthenticator(); + $agent = $this->_getAgent(); + $agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH NTLM '.base64_encode( + $this->_invokePrivateMethod('createMessage1', $ntlm) + )."\r\n", array(334)) + ->andReturn('334 '.base64_encode($this->hex2bin('4e544c4d53535000020000000c000c003000000035828980514246973ea892c10000000000000000460046003c00000054004500530054004e00540002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d0000000000'))); + $agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode( + $this->_invokePrivateMethod('createMessage3', $ntlm, array($domain, $username, $this->hex2bin('4d0045004d00420045005200'), $this->hex2bin('bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9'), $this->hex2bin('caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000')) + ))."\r\n", array(235)); + + $this->assertTrue($ntlm->authenticate($agent, $username.'@'.$domain, $secret, $this->hex2bin('30fa7e3c677bc301'), $this->hex2bin('f5ce3d2401c8f6e9')), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $domain = 'TESTNT'; + $username = 'test'; + $secret = 'test1234'; + + $ntlm = $this->_getAuthenticator(); + $agent = $this->_getAgent(); + $agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH NTLM '.base64_encode( + $this->_invokePrivateMethod('createMessage1', $ntlm) + )."\r\n", array(334)) + ->andThrow(new Swift_TransportException('')); + $agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($ntlm->authenticate($agent, $username.'@'.$domain, $secret, $this->hex2bin('30fa7e3c677bc301'), $this->hex2bin('f5ce3d2401c8f6e9')), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_NTLMAuthenticator(); + } + + private function _getAgent() + { + return $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + private function _invokePrivateMethod($method, $instance, array $args = array()) + { + $methodC = new ReflectionMethod($instance, trim($method)); + $methodC->setAccessible(true); + + return $methodC->invokeArgs($instance, $args); + } + + /** + * Hex2bin replacement for < PHP 5.4. + * + * @param string $hex + * + * @return string Binary + */ + protected function hex2bin($hex) + { + return function_exists('hex2bin') ? hex2bin($hex) : pack('H*', $hex); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php new file mode 100644 index 000000000..4fe9db80e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php @@ -0,0 +1,69 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsPlain() + { + /* -- RFC 4616, 1. + The name associated with this mechanism is "PLAIN". + */ + + $login = $this->_getAuthenticator(); + $this->assertEquals('PLAIN', $login->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + /* -- RFC 4616, 2. + The client presents the authorization identity (identity to act as), + followed by a NUL (U+0000) character, followed by the authentication + identity (identity whose password will be used), followed by a NUL + (U+0000) character, followed by the clear-text password. + */ + + $plain = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH PLAIN '.base64_encode( + 'jack'.chr(0).'jack'.chr(0).'pass' + )."\r\n", array(235)); + + $this->assertTrue($plain->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $plain = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH PLAIN '.base64_encode( + 'jack'.chr(0).'jack'.chr(0).'pass' + )."\r\n", array(235)) + ->andThrow(new Swift_TransportException('')); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($plain->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_PlainAuthenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php new file mode 100644 index 000000000..64327d478 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php @@ -0,0 +1,167 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsAuth() + { + $auth = $this->_createHandler(array()); + $this->assertEquals('AUTH', $auth->getHandledKeyword()); + } + + public function testUsernameCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setUsername('jack'); + $this->assertEquals('jack', $auth->getUsername()); + } + + public function testPasswordCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setPassword('pass'); + $this->assertEquals('pass', $auth->getPassword()); + } + + public function testAuthModeCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setAuthMode('PLAIN'); + $this->assertEquals('PLAIN', $auth->getAuthMode()); + } + + public function testMixinMethods() + { + $auth = $this->_createHandler(array()); + $mixins = $auth->exposeMixinMethods(); + $this->assertTrue(in_array('getUsername', $mixins), + '%s: getUsername() should be accessible via mixin' + ); + $this->assertTrue(in_array('setUsername', $mixins), + '%s: setUsername() should be accessible via mixin' + ); + $this->assertTrue(in_array('getPassword', $mixins), + '%s: getPassword() should be accessible via mixin' + ); + $this->assertTrue(in_array('setPassword', $mixins), + '%s: setPassword() should be accessible via mixin' + ); + $this->assertTrue(in_array('setAuthMode', $mixins), + '%s: setAuthMode() should be accessible via mixin' + ); + $this->assertTrue(in_array('getAuthMode', $mixins), + '%s: getAuthMode() should be accessible via mixin' + ); + } + + public function testAuthenticatorsAreCalledAccordingToParamsAfterEhlo() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('CRAM-MD5', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testAuthenticatorsAreNotUsedIfNoUsernameSet() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + $a2->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + + $auth->setKeywordParams(array('CRAM-MD5', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testSeveralAuthenticatorsAreTriedIfNeeded() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(false); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('PLAIN', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testFirstAuthenticatorToPassBreaksChain() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + $a3 = $this->_createMockAuthenticator('CRAM-MD5'); + + $a1->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(false); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + $a3->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('PLAIN', 'LOGIN', 'CRAM-MD5')); + $auth->afterEhlo($this->_agent); + } + + // -- Private helpers + + private function _createHandler($authenticators) + { + return new Swift_Transport_Esmtp_AuthHandler($authenticators); + } + + private function _createMockAuthenticator($type) + { + $authenticator = $this->getMockery('Swift_Transport_Esmtp_Authenticator')->shouldIgnoreMissing(); + $authenticator->shouldReceive('getAuthKeyword') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $authenticator; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php new file mode 100644 index 000000000..44e5413b1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php @@ -0,0 +1,530 @@ +_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('STARTTLS') + ->andReturn(0); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $this->assertEquals(array($ext2, $ext1), $smtp->getExtensionHandlers()); + } + + public function testHandlersAreNotifiedOfParams() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('setKeywordParams') + ->once() + ->with(array('PLAIN', 'LOGIN')); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('setKeywordParams') + ->zeroOrMoreTimes() + ->with(array('123456')); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $smtp->start(); + } + + public function testSupportedExtensionHandlersAreRunAfterEhlo() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('afterEhlo') + ->once() + ->with($smtp); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('afterEhlo') + ->zeroOrMoreTimes() + ->with($smtp); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('afterEhlo') + ->never() + ->with($smtp); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + } + + public function testExtensionsCanModifyMailFromParams() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(); + $smtp = new EsmtpTransportFixture($buf, array(), $dispatcher); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: FOO ZIP\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO:\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("250 OK\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getMailParams') + ->once() + ->andReturn('FOO'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('getMailParams') + ->once() + ->andReturn('ZIP'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(1); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('getMailParams') + ->never(); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->send($message); + } + + public function testExtensionsCanModifyRcptParams() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(); + $smtp = new EsmtpTransportFixture($buf, array(), $dispatcher); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM:\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: FOO ZIP\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("250 OK\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getRcptParams') + ->once() + ->andReturn('FOO'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('getRcptParams') + ->once() + ->andReturn('ZIP'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(1); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('getRcptParams') + ->never(); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->send($message); + } + + public function testExtensionsAreNotifiedOnCommand() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("FOO\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 Cool\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->executeCommand("FOO\r\n", array(250, 251)); + } + + public function testChainOfCommandAlgorithmWhenNotifyingExtensions() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->never() + ->with("FOO\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()) + ->andReturnUsing(function ($a, $b, $c, $d, &$e) { + $e = true; + + return '250 ok'; + }); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->executeCommand("FOO\r\n", array(250, 251)); + } + + public function testExtensionsCanExposeMixinMethods() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick'); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass'); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $smtp->setUsername('mick'); + $smtp->setPassword('pass'); + } + + public function testMixinMethodsBeginningWithSetAndNullReturnAreFluid() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick') + ->andReturn(null); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass') + ->andReturn(null); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $ret = $smtp->setUsername('mick'); + $this->assertEquals($smtp, $ret); + $ret = $smtp->setPassword('pass'); + $this->assertEquals($smtp, $ret); + } + + public function testMixinSetterWhichReturnValuesAreNotFluid() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick') + ->andReturn('x'); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass') + ->andReturn('x'); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $this->assertEquals('x', $smtp->setUsername('mick')); + $this->assertEquals('x', $smtp->setPassword('pass')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php new file mode 100644 index 000000000..95a9ce2fe --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php @@ -0,0 +1,298 @@ +_createEventDispatcher(); + } + + return new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher); + } + + public function testHostCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setHost('foo'); + $this->assertEquals('foo', $smtp->getHost(), '%s: Host should be returned'); + } + + public function testPortCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setPort(25); + $this->assertEquals(25, $smtp->getPort(), '%s: Port should be returned'); + } + + public function testTimeoutCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $buf->shouldReceive('setParam') + ->once() + ->with('timeout', 10); + + $smtp = $this->_getTransport($buf); + $smtp->setTimeout(10); + $this->assertEquals(10, $smtp->getTimeout(), '%s: Timeout should be returned'); + } + + public function testEncryptionCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setEncryption('tls'); + $this->assertEquals('tls', $smtp->getEncryption(), '%s: Crypto should be returned'); + } + + public function testStartSendsHeloToInitiate() + { + //Overridden for EHLO instead + } + + public function testStartSendsEhloToInitiate() + { + /* -- RFC 2821, 3.2. + + 3.2 Client Initiation + + Once the server has sent the welcoming message and the client has + received it, the client normally sends the EHLO command to the + server, indicating the client's identity. In addition to opening the + session, use of EHLO indicates that the client is able to process + service extensions and requests that the server provide a list of the + extensions it supports. Older SMTP systems which are unable to + support service extensions and contemporary clients which do not + require service extensions in the mail session being initiated, MAY + use HELO instead of EHLO. Servers MUST NOT return the extended + EHLO-style response to a HELO command. For a particular connection + attempt, if the server returns a "command not recognized" response to + EHLO, the client SHOULD be able to fall back and send HELO. + + In the EHLO command the host sending the command identifies itself; + the command may be interpreted as saying "Hello, I am " (and, + in the case of EHLO, "and I support service extension requests"). + + -- RFC 2281, 4.1.1.1. + + ehlo = "EHLO" SP Domain CRLF + helo = "HELO" SP Domain CRLF + + -- RFC 2821, 4.3.2. + + EHLO or HELO + S: 250 + E: 504, 550 + + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail('Starting Esmtp should send EHLO and accept 250 response'); + } + } + + public function testHeloIsUsedAsFallback() + { + /* -- RFC 2821, 4.1.4. + + If the EHLO command is not acceptable to the SMTP server, 501, 500, + or 502 failure replies MUST be returned as appropriate. The SMTP + server MUST stay in the same state after transmitting these replies + that it was in before the EHLO was received. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .+?\r\n$~D') + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 HELO'."\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail( + 'Starting Esmtp should fallback to HELO if needed and accept 250 response' + ); + } + } + + public function testInvalidHeloResponseCausesException() + { + //Overridden to first try EHLO + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .+?\r\n$~D') + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('504 WTF'."\r\n"); + $this->_finishBuffer($buf); + + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('Non 250 HELO response should raise Exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: SMTP start() should have failed'); + } + } + + public function testDomainNameIsPlacedInEhlo() + { + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("EHLO mydomain.com\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testDomainNameIsPlacedInHelo() + { + //Overridden to include ESMTP + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF'."\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("HELO mydomain.com\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 ServerName'."\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testFluidInterface() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('setParam') + ->once() + ->with('timeout', 30); + + $ref = $smtp + ->setHost('foo') + ->setPort(25) + ->setEncryption('tls') + ->setTimeout(30) + ; + $this->assertEquals($ref, $smtp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php new file mode 100644 index 000000000..8d80f3593 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php @@ -0,0 +1,520 @@ +getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->twice() + ->with(\Mockery::anyOf($message1, $message2), \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState) { + if ($connectionState) { + return 1; + } + }); + $t2->shouldReceive('start')->never(); + $t2->shouldReceive('send')->never(); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + } + + public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testZeroIsReturnedIfTransportReturnsZero() + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + $t1 = $this->getMockery('Swift_Transport')->shouldIgnoreMissing(); + + $connectionState = false; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $testCase = $this; + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState, $testCase) { + if (!$connectionState) { + $testCase->fail(); + } + + return 0; + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $this->assertEquals(0, $transport->send($message)); + } + + public function testTransportsWhichThrowExceptionsAreNotRetried() + { + $e = new Swift_TransportException('maur b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->times(4) + ->with(\Mockery::anyOf($message1, $message2, $message3, $message4), \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testExceptionIsThrownIfAllTransportsDie() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + } + } + + public function testStoppingTransportStopsAllDelegates() + { + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = true; + $connectionState2 = true; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('stop') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if ($connectionState1) { + $connectionState1 = false; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('stop') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if ($connectionState2) { + $connectionState2 = false; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $transport->stop(); + } + + public function testTransportShowsAsNotStartedIfAllDelegatesDead() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + $connectionState2 = false; + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + } + + public function testRestartingTransportRestartsDeadDelegates() + { + $e = new Swift_TransportException('b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->twice() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1) { + if ($connectionState1) { + return 10; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + $connectionState2 = false; + throw $e; + } + }); + $t2->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message1); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + //Restart and re-try + $transport->start(); + $this->assertTrue($transport->isStarted()); + $this->assertEquals(10, $transport->send($message2)); + } + + public function testFailureReferenceIsPassedToDelegates() + { + $failures = array(); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use ($connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use ($connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andReturnUsing(function () use ($connectionState) { + if ($connectionState) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $transport->send($message, $failures); + } + + public function testRegisterPluginDelegatesToLoadedTransports() + { + $plugin = $this->_createPlugin(); + + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $t1->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + $t2->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->registerPlugin($plugin); + } + + // -- Private helpers + + private function _getTransport(array $transports) + { + $transport = new Swift_Transport_FailoverTransport(); + $transport->setTransports($transports); + + return $transport; + } + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php new file mode 100644 index 000000000..273f13563 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php @@ -0,0 +1,751 @@ +getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message1, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + } + + public function testTransportsAreReusedInRotatingFashion() + { + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->once() + ->with($message3, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message1, \Mockery::any()); + $t2->shouldReceive('send') + ->once() + ->with($message4, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e, $testCase) { + if ($connectionState1) { + throw $e; + } + $testCase->fail(); + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testMessageIsTriedOnNextTransportIfZeroReturned() + { + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1) { + if ($connectionState1) { + return 0; + } + + return 1; + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2) { + if ($connectionState2) { + return 1; + } + + return 0; + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testZeroIsReturnedIfAllTransportsReturnZero() + { + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1) { + if ($connectionState1) { + return 0; + } + + return 1; + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2) { + if ($connectionState2) { + return 0; + } + + return 1; + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(0, $transport->send($message)); + } + + public function testTransportsWhichThrowExceptionsAreNotRetried() + { + $e = new Swift_TransportException('maur b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e, $testCase) { + if ($connectionState1) { + throw $e; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->times(4) + ->with(\Mockery::anyOf($message1, $message3, $message3, $message4), \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testExceptionIsThrownIfAllTransportsDie() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + } + } + + public function testStoppingTransportStopsAllDelegates() + { + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = true; + $connectionState2 = true; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('stop') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if ($connectionState1) { + $connectionState1 = false; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('stop') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if ($connectionState2) { + $connectionState2 = false; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $transport->stop(); + } + + public function testTransportShowsAsNotStartedIfAllDelegatesDead() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + } + + public function testRestartingTransportRestartsDeadDelegates() + { + $e = new Swift_TransportException('b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->twice() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e) { + if ($connectionState1) { + return 10; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + $t2->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message1); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + //Restart and re-try + $transport->start(); + $this->assertTrue($transport->isStarted()); + $this->assertEquals(10, $transport->send($message2)); + } + + public function testFailureReferenceIsPassedToDelegates() + { + $failures = array(); + $testCase = $this; + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::on(function (&$var) use (&$failures, $testCase) { + return $testCase->varsAreReferences($var, $failures); + })) + ->andReturnUsing(function () use (&$connectionState) { + if ($connectionState) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $transport->send($message, $failures); + } + + public function testRegisterPluginDelegatesToLoadedTransports() + { + $plugin = $this->_createPlugin(); + + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $t1->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + $t2->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->registerPlugin($plugin); + } + + /** + * Adapted from Yay_Matchers_ReferenceMatcher. + */ + public function varsAreReferences(&$ref1, &$ref2) + { + if (is_object($ref2)) { + return ($ref1 === $ref2); + } + if ($ref1 !== $ref2) { + return false; + } + + $copy = $ref2; + $randomString = uniqid('yay'); + $ref2 = $randomString; + $isRef = ($ref1 === $ref2); + $ref2 = $copy; + + return $isRef; + } + + // -- Private helpers + + private function _getTransport(array $transports) + { + $transport = new Swift_Transport_LoadBalancedTransport(); + $transport->setTransports($transports); + + return $transport; + } + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php new file mode 100644 index 000000000..d86d11ac6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php @@ -0,0 +1,311 @@ +_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $invoker->shouldReceive('mail') + ->once(); + + $transport->send($message); + } + + public function testTransportUsesToFieldBodyInSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to, + )); + $message = $this->_createMessage($headers); + + $to->shouldReceive('getFieldBody') + ->zeroOrMoreTimes() + ->andReturn('Foo '); + $invoker->shouldReceive('mail') + ->once() + ->with('Foo ', \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesSubjectFieldBodyInSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subj = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subj, + )); + $message = $this->_createMessage($headers); + + $subj->shouldReceive('getFieldBody') + ->zeroOrMoreTimes() + ->andReturn('Thing'); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), 'Thing', \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesBodyOfMessage() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn( + "To: Foo \r\n". + "\r\n". + 'This body' + ); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), 'This body', \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesHeadersFromMessage() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn( + "Subject: Stuff\r\n". + "\r\n". + 'This body' + ); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), 'Subject: Stuff'.PHP_EOL, \Mockery::any()); + + $transport->send($message); + } + + public function testTransportReturnsCountOfAllRecipientsIfInvokerReturnsTrue() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null, 'zip@button' => null)); + $message->shouldReceive('getCc') + ->zeroOrMoreTimes() + ->andReturn(array('test@test' => null)); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn(true); + + $this->assertEquals(3, $transport->send($message)); + } + + public function testTransportReturnsZeroIfInvokerReturnsFalse() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null, 'zip@button' => null)); + $message->shouldReceive('getCc') + ->zeroOrMoreTimes() + ->andReturn(array('test@test' => null)); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn(false); + + $this->assertEquals(0, $transport->send($message)); + } + + public function testToHeaderIsRemovedFromHeaderSetDuringSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to, + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('remove') + ->once() + ->with('To'); + $headers->shouldReceive('remove') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testSubjectHeaderIsRemovedFromHeaderSetDuringSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subject = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subject, + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('remove') + ->once() + ->with('Subject'); + $headers->shouldReceive('remove') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testToHeaderIsPutBackAfterSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to, + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('set') + ->once() + ->with($to); + $headers->shouldReceive('set') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testSubjectHeaderIsPutBackAfterSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subject = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subject, + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('set') + ->once() + ->with($subject); + $headers->shouldReceive('set') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + // -- Creation Methods + + private function _createTransport($invoker, $dispatcher) + { + return new Swift_Transport_MailTransport($invoker, $dispatcher); + } + + private function _createEventDispatcher() + { + return $this->getMockery('Swift_Events_EventDispatcher')->shouldIgnoreMissing(); + } + + private function _createInvoker() + { + return $this->getMockery('Swift_Transport_MailInvoker'); + } + + private function _createMessage($headers) + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + $message->shouldReceive('getHeaders') + ->zeroOrMoreTimes() + ->andReturn($headers); + + return $message; + } + + private function _createHeaders($headers = array()) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + + if (count($headers) > 0) { + foreach ($headers as $name => $header) { + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->with($name) + ->andReturn($header); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->with($name) + ->andReturn(true); + } + } + + $header = $this->_createHeader(); + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->andReturn($header); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->andReturn(true); + + return $set; + } + + private function _createHeader() + { + return $this->getMockery('Swift_Mime_Header')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php new file mode 100644 index 000000000..c704c3c35 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php @@ -0,0 +1,152 @@ +_createEventDispatcher(); + } + $transport = new Swift_Transport_SendmailTransport($buf, $dispatcher); + $transport->setCommand($command); + + return $transport; + } + + protected function _getSendmail($buf, $dispatcher = null) + { + if (!$dispatcher) { + $dispatcher = $this->_createEventDispatcher(); + } + $sendmail = new Swift_Transport_SendmailTransport($buf, $dispatcher); + + return $sendmail; + } + + public function testCommandCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + + $sendmail->setCommand('/usr/sbin/sendmail -bs'); + $this->assertEquals('/usr/sbin/sendmail -bs', $sendmail->getCommand()); + $sendmail->setCommand('/usr/sbin/sendmail -oi -t'); + $this->assertEquals('/usr/sbin/sendmail -oi -t', $sendmail->getCommand()); + } + + public function testSendingMessageIn_t_ModeUsesSimplePipe() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => 'Foobar', 'zip@button' => 'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n" => "\n", "\n." => "\n..")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingIn_t_ModeWith_i_FlagDoesntEscapeDot() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => 'Foobar', 'zip@button' => 'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n" => "\n")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -i -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingInTModeWith_oi_FlagDoesntEscapeDot() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => 'Foobar', 'zip@button' => 'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n" => "\n")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -oi -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingMessageRegeneratesId() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => 'Foobar', 'zip@button' => 'Zippy')); + $message->shouldReceive('generateId'); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n" => "\n", "\n." => "\n..")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testFluidInterface() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getTransport($buf); + + $ref = $sendmail->setCommand('/foo'); + $this->assertEquals($ref, $sendmail); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php new file mode 100644 index 000000000..3ec74b3e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php @@ -0,0 +1,45 @@ +_createFactory(); + $factory->expects($this->once()) + ->method('createFilter') + ->with('a', 'b') + ->will($this->returnCallback(array($this, '_createFilter'))); + + $buffer = $this->_createBuffer($factory); + $buffer->setWriteTranslations(array('a' => 'b')); + } + + public function testOverridingTranslationsOnlyAddsNeededFilters() + { + $factory = $this->_createFactory(); + $factory->expects($this->exactly(2)) + ->method('createFilter') + ->will($this->returnCallback(array($this, '_createFilter'))); + + $buffer = $this->_createBuffer($factory); + $buffer->setWriteTranslations(array('a' => 'b')); + $buffer->setWriteTranslations(array('x' => 'y', 'a' => 'b')); + } + + // -- Creation methods + + private function _createBuffer($replacementFactory) + { + return new Swift_Transport_StreamBuffer($replacementFactory); + } + + private function _createFactory() + { + return $this->getMock('Swift_ReplacementFilterFactory'); + } + + public function _createFilter() + { + return $this->getMock('Swift_StreamFilter'); + } +} diff --git a/vendor/true/punycode/.gitignore b/vendor/true/punycode/.gitignore new file mode 100644 index 000000000..d6a14f73c --- /dev/null +++ b/vendor/true/punycode/.gitignore @@ -0,0 +1,3 @@ +build/ +vendor/ +composer.lock diff --git a/vendor/true/punycode/.travis.yml b/vendor/true/punycode/.travis.yml new file mode 100644 index 000000000..19ea78a01 --- /dev/null +++ b/vendor/true/punycode/.travis.yml @@ -0,0 +1,31 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +matrix: + fast_finish: true + include: + - php: 5.3 + env: PHPCS=1 + +sudo: false + +before_script: + - composer self-update + - composer install + - if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then mkdir -p build/logs; fi + - if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi + +script: + - if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi + - if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then ./vendor/bin/phpunit --coverage-text; fi + - if [[ "$PHPCS" == "1" ]]; then ./vendor/bin/phpcs --standard=PSR2 -np src/ tests/; fi + +after_script: + - if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi diff --git a/vendor/true/punycode/CHANGELOG.md b/vendor/true/punycode/CHANGELOG.md new file mode 100644 index 000000000..42f62e9fa --- /dev/null +++ b/vendor/true/punycode/CHANGELOG.md @@ -0,0 +1,35 @@ +# Changelog + +## 2.0.2 - 2016-01-07 + +- [Fix] Encode and decode domains regardless of their casing (#16) + - Thanks to [@abcdmitry](https://github.com/abcdmitry) for the full patch. + + +## 2.0.1 - 2015-09-01 + +- [Fix] Removed `version` property from `composer.json` file + - Thanks to [@GrahamCampbell](https://github.com/GrahamCampbell) for the patch. + + +## 2.0.0 - 2015-06-24 + +- [Enhancement] PHP 7 support +- [Fix] Renamed `True` namespace to `TrueBV` as it is a reserved word in PHP 7 + + +## 1.1.0 - 2015-03-12 + +- [Enhancement] Character encoding is now passed to the constructor, defaulting to UTF-8, as opposite to relying on `mb_internal_encoding` function call (#9). + + +## 1.0.1 - 2014-08-26 + +- [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compliant and automation on Travis-CI + - Thanks to [@nyamsprod](https://github.com/nyamsprod) for initial patch. +- [Fix] Domain containing `x`, `n` or `-` would result in failures while decoding (#6). + + +## 1.0.0 - 2014-03-10 + +- Initial release diff --git a/vendor/true/punycode/LICENSE b/vendor/true/punycode/LICENSE new file mode 100644 index 000000000..963c72ad7 --- /dev/null +++ b/vendor/true/punycode/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 TrueServer B.V. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/true/punycode/README.md b/vendor/true/punycode/README.md new file mode 100644 index 000000000..c290f97a7 --- /dev/null +++ b/vendor/true/punycode/README.md @@ -0,0 +1,45 @@ +# Punycode + +[![Build Status](https://secure.travis-ci.org/true/php-punycode.png?branch=master)](http://travis-ci.org/true/php-punycode) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/true/php-punycode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/true/php-punycode/?branch=master) +[![Code Coverage](https://scrutinizer-ci.com/g/true/php-punycode/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/true/php-punycode/?branch=master) +[![Latest Stable Version](https://poser.pugx.org/true/punycode/version.png)](https://packagist.org/packages/true/punycode) + +A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA). + + +## Install + +``` +composer require true/punycode:~2.0 +``` + + +## Usage + +```php +encode('renangonçalves.com')); +// outputs: xn--renangonalves-pgb.com + +var_dump($Punycode->decode('xn--renangonalves-pgb.com')); +// outputs: renangonçalves.com +``` + + +## FAQ + +### 1. What is this library for? + +This library converts a Unicode encoded domain name to a IDNA ASCII form and vice-versa. + + +### 2. Why should I use this instead of [PHP's IDN Functions](http://php.net/manual/en/ref.intl.idn.php)? + +If you can compile the needed dependencies (intl, libidn) there is not much difference. +But if you want to write portable code between hosts (including Windows and Mac OS), or can't install PECL extensions, this is the right library for you. diff --git a/vendor/true/punycode/composer.json b/vendor/true/punycode/composer.json new file mode 100644 index 000000000..63adea98e --- /dev/null +++ b/vendor/true/punycode/composer.json @@ -0,0 +1,26 @@ +{ + "name": "true/punycode", + "description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)", + "keywords": ["IDNA", "punycode"], + "homepage": "https://github.com/true/php-punycode", + "license": "MIT", + "authors": [ + { + "name": "Renan Gonçalves", + "email": "renan.saddam@gmail.com" + } + ], + "autoload": { + "psr-4": { + "TrueBV\\": "src/" + } + }, + "require": { + "php": ">=5.3.0", + "ext-mbstring": "*" + }, + "require-dev": { + "phpunit/phpunit": "~4.7", + "squizlabs/php_codesniffer": "~2.0" + } +} diff --git a/vendor/true/punycode/phpunit.xml.dist b/vendor/true/punycode/phpunit.xml.dist new file mode 100644 index 000000000..2ecdf1b61 --- /dev/null +++ b/vendor/true/punycode/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + tests/ + + + + + src/ + + + tests + vendor + + + diff --git a/vendor/true/punycode/src/Punycode.php b/vendor/true/punycode/src/Punycode.php new file mode 100644 index 000000000..c54adbd94 --- /dev/null +++ b/vendor/true/punycode/src/Punycode.php @@ -0,0 +1,334 @@ + 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, + 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, + 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, + 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, + 'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29, + '4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35 + ); + + /** + * Character encoding + * + * @param string + */ + protected $encoding; + + /** + * Constructor + * + * @param string $encoding Character encoding + */ + public function __construct($encoding = 'UTF-8') + { + $this->encoding = $encoding; + } + + /** + * Encode a domain to its Punycode version + * + * @param string $input Domain name in Unicode to be encoded + * @return string Punycode representation in ASCII + */ + public function encode($input) + { + $input = mb_strtolower($input, $this->encoding); + $parts = explode('.', $input); + foreach ($parts as &$part) { + $part = $this->encodePart($part); + } + + return implode('.', $parts); + } + + /** + * Encode a part of a domain name, such as tld, to its Punycode version + * + * @param string $input Part of a domain name + * @return string Punycode representation of a domain part + */ + protected function encodePart($input) + { + $codePoints = $this->listCodePoints($input); + + $n = static::INITIAL_N; + $bias = static::INITIAL_BIAS; + $delta = 0; + $h = $b = count($codePoints['basic']); + + $output = ''; + foreach ($codePoints['basic'] as $code) { + $output .= $this->codePointToChar($code); + } + if ($input === $output) { + return $output; + } + if ($b > 0) { + $output .= static::DELIMITER; + } + + $codePoints['nonBasic'] = array_unique($codePoints['nonBasic']); + sort($codePoints['nonBasic']); + + $i = 0; + $length = mb_strlen($input, $this->encoding); + while ($h < $length) { + $m = $codePoints['nonBasic'][$i++]; + $delta = $delta + ($m - $n) * ($h + 1); + $n = $m; + + foreach ($codePoints['all'] as $c) { + if ($c < $n || $c < static::INITIAL_N) { + $delta++; + } + if ($c === $n) { + $q = $delta; + for ($k = static::BASE;; $k += static::BASE) { + $t = $this->calculateThreshold($k, $bias); + if ($q < $t) { + break; + } + + $code = $t + (($q - $t) % (static::BASE - $t)); + $output .= static::$encodeTable[$code]; + + $q = ($q - $t) / (static::BASE - $t); + } + + $output .= static::$encodeTable[$q]; + $bias = $this->adapt($delta, $h + 1, ($h === $b)); + $delta = 0; + $h++; + } + } + + $delta++; + $n++; + } + + return static::PREFIX . $output; + } + + /** + * Decode a Punycode domain name to its Unicode counterpart + * + * @param string $input Domain name in Punycode + * @return string Unicode domain name + */ + public function decode($input) + { + $input = strtolower($input); + $parts = explode('.', $input); + foreach ($parts as &$part) { + if (strpos($part, static::PREFIX) !== 0) { + continue; + } + + $part = substr($part, strlen(static::PREFIX)); + $part = $this->decodePart($part); + } + + return implode('.', $parts); + } + + /** + * Decode a part of domain name, such as tld + * + * @param string $input Part of a domain name + * @return string Unicode domain part + */ + protected function decodePart($input) + { + $n = static::INITIAL_N; + $i = 0; + $bias = static::INITIAL_BIAS; + $output = ''; + + $pos = strrpos($input, static::DELIMITER); + if ($pos !== false) { + $output = substr($input, 0, $pos++); + } else { + $pos = 0; + } + + $outputLength = strlen($output); + $inputLength = strlen($input); + while ($pos < $inputLength) { + $oldi = $i; + $w = 1; + + for ($k = static::BASE;; $k += static::BASE) { + $digit = static::$decodeTable[$input[$pos++]]; + $i = $i + ($digit * $w); + $t = $this->calculateThreshold($k, $bias); + + if ($digit < $t) { + break; + } + + $w = $w * (static::BASE - $t); + } + + $bias = $this->adapt($i - $oldi, ++$outputLength, ($oldi === 0)); + $n = $n + (int) ($i / $outputLength); + $i = $i % ($outputLength); + $output = mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . mb_substr($output, $i, $outputLength - 1, $this->encoding); + + $i++; + } + + return $output; + } + + /** + * Calculate the bias threshold to fall between TMIN and TMAX + * + * @param integer $k + * @param integer $bias + * @return integer + */ + protected function calculateThreshold($k, $bias) + { + if ($k <= $bias + static::TMIN) { + return static::TMIN; + } elseif ($k >= $bias + static::TMAX) { + return static::TMAX; + } + return $k - $bias; + } + + /** + * Bias adaptation + * + * @param integer $delta + * @param integer $numPoints + * @param boolean $firstTime + * @return integer + */ + protected function adapt($delta, $numPoints, $firstTime) + { + $delta = (int) ( + ($firstTime) + ? $delta / static::DAMP + : $delta / 2 + ); + $delta += (int) ($delta / $numPoints); + + $k = 0; + while ($delta > ((static::BASE - static::TMIN) * static::TMAX) / 2) { + $delta = (int) ($delta / (static::BASE - static::TMIN)); + $k = $k + static::BASE; + } + $k = $k + (int) (((static::BASE - static::TMIN + 1) * $delta) / ($delta + static::SKEW)); + + return $k; + } + + /** + * List code points for a given input + * + * @param string $input + * @return array Multi-dimension array with basic, non-basic and aggregated code points + */ + protected function listCodePoints($input) + { + $codePoints = array( + 'all' => array(), + 'basic' => array(), + 'nonBasic' => array(), + ); + + $length = mb_strlen($input, $this->encoding); + for ($i = 0; $i < $length; $i++) { + $char = mb_substr($input, $i, 1, $this->encoding); + $code = $this->charToCodePoint($char); + if ($code < 128) { + $codePoints['all'][] = $codePoints['basic'][] = $code; + } else { + $codePoints['all'][] = $codePoints['nonBasic'][] = $code; + } + } + + return $codePoints; + } + + /** + * Convert a single or multi-byte character to its code point + * + * @param string $char + * @return integer + */ + protected function charToCodePoint($char) + { + $code = ord($char[0]); + if ($code < 128) { + return $code; + } elseif ($code < 224) { + return (($code - 192) * 64) + (ord($char[1]) - 128); + } elseif ($code < 240) { + return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128); + } else { + return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128); + } + } + + /** + * Convert a code point to its single or multi-byte character + * + * @param integer $code + * @return string + */ + protected function codePointToChar($code) + { + if ($code <= 0x7F) { + return chr($code); + } elseif ($code <= 0x7FF) { + return chr(($code >> 6) + 192) . chr(($code & 63) + 128); + } elseif ($code <= 0xFFFF) { + return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128); + } else { + return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128); + } + } +} diff --git a/vendor/true/punycode/tests/PunycodeTest.php b/vendor/true/punycode/tests/PunycodeTest.php new file mode 100644 index 000000000..61902dc9b --- /dev/null +++ b/vendor/true/punycode/tests/PunycodeTest.php @@ -0,0 +1,151 @@ +encode($decoded); + $this->assertEquals($encoded, $result); + } + + /** + * Test decoding Punycode + * + * @param string $decoded Decoded domain + * @param string $encoded Encoded domain + * @dataProvider domainNamesProvider + */ + public function testDecode($decoded, $encoded) + { + $Punycode = new Punycode(); + $result = $Punycode->decode($encoded); + $this->assertEquals($decoded, $result); + } + + /** + * Test encoding Punycode in uppercase + * + * @param string $decoded Decoded domain + * @param string $encoded Encoded domain + * @dataProvider domainNamesProvider + */ + public function testEncodeUppercase($decoded, $encoded) + { + $Punycode = new Punycode(); + $result = $Punycode->encode(mb_strtoupper($decoded, 'UTF-8')); + $this->assertEquals($encoded, $result); + } + + /** + * Test decoding Punycode in uppercase + * + * @param string $decoded Decoded domain + * @param string $encoded Encoded domain + * @dataProvider domainNamesProvider + */ + public function testDecodeUppercase($decoded, $encoded) + { + $Punycode = new Punycode(); + $result = $Punycode->decode(strtoupper($encoded)); + $this->assertEquals($decoded, $result); + } + + /** + * Provide domain names containing the decoded and encoded names + * + * @return array + */ + public function domainNamesProvider() + { + return array( + // http://en.wikipedia.org/wiki/.test_(international_domain_name)#Test_TLDs + array( + 'مثال.إختبار', + 'xn--mgbh0fb.xn--kgbechtv', + ), + array( + 'مثال.آزمایشی', + 'xn--mgbh0fb.xn--hgbk6aj7f53bba', + ), + array( + '例子.测试', + 'xn--fsqu00a.xn--0zwm56d', + ), + array( + '例子.測試', + 'xn--fsqu00a.xn--g6w251d', + ), + array( + 'пример.испытание', + 'xn--e1afmkfd.xn--80akhbyknj4f', + ), + array( + 'उदाहरण.परीक्षा', + 'xn--p1b6ci4b4b3a.xn--11b5bs3a9aj6g', + ), + array( + 'παράδειγμα.δοκιμή', + 'xn--hxajbheg2az3al.xn--jxalpdlp', + ), + array( + '실례.테스트', + 'xn--9n2bp8q.xn--9t4b11yi5a', + ), + array( + 'בײַשפּיל.טעסט', + 'xn--fdbk5d8ap9b8a8d.xn--deba0ad', + ), + array( + '例え.テスト', + 'xn--r8jz45g.xn--zckzah', + ), + array( + 'உதாரணம்.பரிட்சை', + 'xn--zkc6cc5bi7f6e.xn--hlcj6aya9esc7a', + ), + + array( + 'derhausüberwacher.de', + 'xn--derhausberwacher-pzb.de', + ), + array( + 'renangonçalves.com', + 'xn--renangonalves-pgb.com', + ), + array( + 'рф.ru', + 'xn--p1ai.ru', + ), + array( + 'δοκιμή.gr', + 'xn--jxalpdlp.gr', + ), + array( + 'ফাহাদ্১৯.বাংলা', + 'xn--65bj6btb5gwimc.xn--54b7fta0cc', + ), + array( + '𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑.gr', + 'xn--uba5533kmaba1adkfh6ch2cg.gr', + ), + array( + 'guangdong.广东', + 'guangdong.xn--xhq521b', + ), + array( + 'gwóźdź.pl', + 'xn--gwd-hna98db.pl', + ), + ); + } +} From ecbf7e188b76cf0070fe599d74f6f60624d6d6fd Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 14:07:22 +0900 Subject: [PATCH 2/8] Replace FirePHP with composer library --- composer.json | 1 + config/config.inc.php | 6 - libs/FirePHPCore/CHANGELOG | 110 - libs/FirePHPCore/CREDITS | 12 - libs/FirePHPCore/LICENSE | 29 - libs/FirePHPCore/README | 32 - libs/FirePHPCore/fb.php | 261 --- vendor/composer/autoload_classmap.php | 2 + vendor/composer/installed.json | 38 + vendor/firephp/firephp-core/.gitignore | 1 + vendor/firephp/firephp-core/CHANGELOG.md | 171 ++ vendor/firephp/firephp-core/README.md | 75 + vendor/firephp/firephp-core/composer.json | 26 + vendor/firephp/firephp-core/examples/oo.php | 82 + vendor/firephp/firephp-core/examples/oo.php4 | 72 + .../firephp-core/examples/procedural.php | 79 + .../firephp-core/examples/procedural.php4 | 69 + .../lib/FirePHPCore/FirePHP.class.php | 1828 +++++++++++++++++ .../lib/FirePHPCore/FirePHP.class.php4 | 730 +++---- .../firephp-core/lib/FirePHPCore/fb.php | 275 +++ .../firephp-core/lib/FirePHPCore/fb.php4 | 245 +++ vendor/firephp/firephp-core/package.json | 43 + vendor/firephp/firephp-core/program.json | 5 + .../firephp-core/tests/API/newlines.php | 12 + .../tests/FirePHPCore/FirePHPTest.php | 181 ++ .../firephp/firephp-core/tests/TestHelper.php | 55 + vendor/firephp/firephp-core/tests/phpunit.xml | 2 + .../firephp/firephp-core/workspace/README.md | 19 + .../firephp-core/workspace/lib/project.js | 5 + .../firephp-core/workspace/package.json | 28 + .../firephp-core/workspace/program.json | 78 + .../firephp-core/workspace/scripts/build.js | 164 ++ .../firephp-core/workspace/scripts/publish.js | 65 + .../firephp-core/workspace/tpl/license.tpl.md | 21 + .../workspace/tpl/pear.package.tpl.xml | 61 + .../firephp-core/workspace/tpl/readme.tpl.md | 17 + 36 files changed, 3984 insertions(+), 916 deletions(-) delete mode 100644 libs/FirePHPCore/CHANGELOG delete mode 100644 libs/FirePHPCore/CREDITS delete mode 100644 libs/FirePHPCore/LICENSE delete mode 100644 libs/FirePHPCore/README delete mode 100644 libs/FirePHPCore/fb.php create mode 100644 vendor/firephp/firephp-core/.gitignore create mode 100644 vendor/firephp/firephp-core/CHANGELOG.md create mode 100644 vendor/firephp/firephp-core/README.md create mode 100644 vendor/firephp/firephp-core/composer.json create mode 100644 vendor/firephp/firephp-core/examples/oo.php create mode 100644 vendor/firephp/firephp-core/examples/oo.php4 create mode 100644 vendor/firephp/firephp-core/examples/procedural.php create mode 100644 vendor/firephp/firephp-core/examples/procedural.php4 create mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php rename libs/FirePHPCore/FirePHP.class.php => vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 (66%) create mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/fb.php create mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 create mode 100644 vendor/firephp/firephp-core/package.json create mode 100644 vendor/firephp/firephp-core/program.json create mode 100644 vendor/firephp/firephp-core/tests/API/newlines.php create mode 100644 vendor/firephp/firephp-core/tests/FirePHPCore/FirePHPTest.php create mode 100644 vendor/firephp/firephp-core/tests/TestHelper.php create mode 100644 vendor/firephp/firephp-core/tests/phpunit.xml create mode 100644 vendor/firephp/firephp-core/workspace/README.md create mode 100644 vendor/firephp/firephp-core/workspace/lib/project.js create mode 100644 vendor/firephp/firephp-core/workspace/package.json create mode 100644 vendor/firephp/firephp-core/workspace/program.json create mode 100644 vendor/firephp/firephp-core/workspace/scripts/build.js create mode 100644 vendor/firephp/firephp-core/workspace/scripts/publish.js create mode 100644 vendor/firephp/firephp-core/workspace/tpl/license.tpl.md create mode 100644 vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml create mode 100644 vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md diff --git a/composer.json b/composer.json index 0d67b09d1..3678be41e 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "ext-xml": "*", "defuse/php-encryption": "1.2.1", "ezyang/htmlpurifier": "4.7.*", + "firephp/firephp-core": "0.4.0", "matthiasmullie/minify": "1.3.*", "michelf/php-markdown": "1.5.*", "pear/http_request2": "2.2.*", diff --git a/config/config.inc.php b/config/config.inc.php index dd8090ff6..92f4fa8af 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -289,12 +289,6 @@ if(!defined('__PROXY_SERVER__')) define('__PROXY_SERVER__', NULL); } -// Require specific files when using Firebug console output -if((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1) -{ - require _XE_PATH_ . 'libs/FirePHPCore/FirePHP.class.php'; -} - // Set Timezone as server time date_default_timezone_set(@date_default_timezone_get()); diff --git a/libs/FirePHPCore/CHANGELOG b/libs/FirePHPCore/CHANGELOG deleted file mode 100644 index 619198079..000000000 --- a/libs/FirePHPCore/CHANGELOG +++ /dev/null @@ -1,110 +0,0 @@ - -2008-06-14 - Release Version: 0.3.1 - - - (Issue 108) ignore class name case in object filter - -2009-05-11 - Release Version: 0.3 -2009-05-01 - Release Version: 0.3.rc.1 - - - (Issue 90) PHP4 compatible version of FirePHPCore - - (Issue 98) Thrown exceptions don't send an HTTP 500 if the FirePHP exception handler is enabled - - (Issue 85) Support associative arrays in encodeTable method in FirePHP.class.php - - (Issue 66) Add a new getOptions() public method in API - - (Issue 82) Define $this->options outside of __construct - - (Issue 72) Message error if group name is null - - (Issue 68) registerErrorHandler() and registerExceptionHandler() should returns previous handlers defined - - (Issue 69) Add the missing register handler in the triumvirate (error, exception, assert) - - (Issue 75) [Error & Exception Handling] Option to not exit script execution - - (Issue 83) Exception handler can't throw exceptions - - (Issue 80) Auto/Pre collapsing groups AND Custom group row colors - -2008-11-09 - Release Version: 0.2.1 - - - (Issue 70) Problem when logging resources - -2008-10-21 - Release Version: 0.2.0 - - - Updated version to 0.2.0 - - Switched to using __sleep instead of __wakeup - - Added support to exclude object members when encoding - - Add support to enable/disable logging - -2008-10-17 - Release Version: 0.2.b.8 - - - New implementation for is_utf8() - - (Issue 55) maxObjectDepth Option not working correctly when using TABLE and EXCEPTION Type - - Bugfix for max[Object|Array]Depth when encoding nested array/object graphs - - Bugfix for FB::setOptions() - -2008-10-16 - Release Version: 0.2.b.7 - - - (Issue 45) Truncate dump when string have non utf8 cars - - (Issue 52) logging will not work when firephp object gets stored in the session. - -2008-10-16 - Release Version: 0.2.b.6 - - - (Issue 37) Display file and line information for each log message - - (Issue 51) Limit output of object graphs - - Bugfix for encoding object members set to NULL|false|'' - -2008-10-14 - Release Version: 0.2.b.5 - - - Updated JsonStream wildfire protocol to be more robust - - (Issue 33) PHP error notices running demos - - (Issue 48) Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given - -2008-10-08 - Release Version: 0.2.b.4 - - - Bugfix for logging objects with recursion - -2008-10-08 - Release Version: 0.2.b.3 - - - (Issue 43) Notice message in 0.2b2 - - Added support for PHP's native json_encode() if available - - Revised object encoder to detect object recursion - -2008-10-07 - Release Version: 0.2.b.2 - - - (Issue 28) Need solution for logging private and protected object variables - - Added trace() and table() aliases in FirePHP class - - (Issue 41) Use PHP doc in FirePHP - - (Issue 39) Static logging method for object oriented API - -2008-10-01 - Release Version: 0.2.b.1 - - - Added support for error and exception handling - - Updated min PHP version for PEAR package to 5.2 - - Added version constant for library - - Gave server library it's own wildfire plugin namespace - - Migrated communication protocol to Wildfire JsonStream - - Added support for console groups using "group" and "groupEnd" - - Added support for log, info, warn and error logging aliases - - (Issue 29) problem with TRACE when using with error_handler - - (Issue 33) PHP error notices running demos - - (Issue 12) undefined index php notice - - Removed closing ?> php tags - - (Issue 13) the code in the fb() function has a second return statement that will never be reached - -2008-07-30 - Release Version: 0.1.1.3 - - - Include __className property in JSON string if variable was an object - - Bugfix - Mis-spelt "Exception" in JSON encoding code - -2008-06-13 - Release Version: 0.1.1.1 - - - Bugfix - Standardize windows paths in stack traces - - Bugfix - Display correct stack trace info in windows environments - - Bugfix - Check $_SERVER['HTTP_USER_AGENT'] before returning - -2008-06-13 - Release Version: 0.1.1 - - - Added support for FirePHP::TRACE log style - - Changed license to New BSD License - -2008-06-06 - Release Version: 0.0.2 - - - Bugfix - Added usleep() to header writing loop to ensure unique index - - Bugfix - Ensure chunk_split does not generate trailing "\n" with empty data header - - Added support for FirePHP::TABLE log style - - \ No newline at end of file diff --git a/libs/FirePHPCore/CREDITS b/libs/FirePHPCore/CREDITS deleted file mode 100644 index 5f0d463d1..000000000 --- a/libs/FirePHPCore/CREDITS +++ /dev/null @@ -1,12 +0,0 @@ - _______________________________ - F i r e P H P C o r e - - Current Development - ------------------- - - Christoph Dorn - Michael Day - - If you've done work on FirePHPCore and you are not listed here, - please feel free to add yourself. - diff --git a/libs/FirePHPCore/LICENSE b/libs/FirePHPCore/LICENSE deleted file mode 100644 index 3e390f9d9..000000000 --- a/libs/FirePHPCore/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -Software License Agreement (New BSD License) - -Copyright (c) 2006-2009, Christoph Dorn -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of Christoph Dorn nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/FirePHPCore/README b/libs/FirePHPCore/README deleted file mode 100644 index 033719fae..000000000 --- a/libs/FirePHPCore/README +++ /dev/null @@ -1,32 +0,0 @@ - -Version: 0.3.1 - ------------------------------------------------------- - Requirements ------------------------------------------------------- - -Client Side: - - - Firefox - http://www.getfirefox.com/ - - Firebug - http://www.getfirebug.com/ - - FirePHP - http://www.firephp.org/ - -Server Side: - - - PHP 5 (complete functionality) - - PHP 4 (most functionality) - - ------------------------------------------------------- - Install Tutorial ------------------------------------------------------- - - http://www.firephp.org/HQ/Install.htm - - ------------------------------------------------------- - Support ------------------------------------------------------- - - http://forum.firephp.org/ - diff --git a/libs/FirePHPCore/fb.php b/libs/FirePHPCore/fb.php deleted file mode 100644 index 9d1857cbc..000000000 --- a/libs/FirePHPCore/fb.php +++ /dev/null @@ -1,261 +0,0 @@ - - * @license http://www.opensource.org/licenses/bsd-license.php - * @package FirePHP - */ - -require_once dirname(__FILE__).'/FirePHP.class.php'; - -/** - * Sends the given data to the FirePHP Firefox Extension. - * The data can be displayed in the Firebug Console or in the - * "Server" request tab. - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object - * @return true - * @throws Exception - */ -function fb() -{ - $instance = FirePHP::getInstance(true); - - $args = func_get_args(); - return call_user_func_array(array($instance,'fb'),$args); -} - - -class FB -{ - /** - * Enable and disable logging to Firebug - * - * @see FirePHP->setEnabled() - * @param boolean $Enabled TRUE to enable, FALSE to disable - * @return void - */ - public static function setEnabled($Enabled) { - $instance = FirePHP::getInstance(true); - $instance->setEnabled($Enabled); - } - - /** - * Check if logging is enabled - * - * @see FirePHP->getEnabled() - * @return boolean TRUE if enabled - */ - public static function getEnabled() { - $instance = FirePHP::getInstance(true); - return $instance->getEnabled(); - } - - /** - * Specify a filter to be used when encoding an object - * - * Filters are used to exclude object members. - * - * @see FirePHP->setObjectFilter() - * @param string $Class The class name of the object - * @param array $Filter An array or members to exclude - * @return void - */ - public static function setObjectFilter($Class, $Filter) { - $instance = FirePHP::getInstance(true); - $instance->setObjectFilter($Class, $Filter); - } - - /** - * Set some options for the library - * - * @see FirePHP->setOptions() - * @param array $Options The options to be set - * @return void - */ - public static function setOptions($Options) { - $instance = FirePHP::getInstance(true); - $instance->setOptions($Options); - } - - /** - * Get options for the library - * - * @see FirePHP->getOptions() - * @return array The options - */ - public static function getOptions() { - $instance = FirePHP::getInstance(true); - return $instance->getOptions(); - } - - /** - * Log object to firebug - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object - * @return true - * @throws Exception - */ - public static function send() - { - $instance = FirePHP::getInstance(true); - $args = func_get_args(); - return call_user_func_array(array($instance,'fb'),$args); - } - - /** - * Start a group for following messages - * - * Options: - * Collapsed: [true|false] - * Color: [#RRGGBB|ColorName] - * - * @param string $Name - * @param array $Options OPTIONAL Instructions on how to log the group - * @return true - */ - public static function group($Name, $Options=null) { - $instance = FirePHP::getInstance(true); - return $instance->group($Name, $Options); - } - - /** - * Ends a group you have started before - * - * @return true - * @throws Exception - */ - public static function groupEnd() { - return self::send(null, null, FirePHP::GROUP_END); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::LOG - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - public static function log($Object, $Label=null) { - return self::send($Object, $Label, FirePHP::LOG); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::INFO - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - public static function info($Object, $Label=null) { - return self::send($Object, $Label, FirePHP::INFO); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::WARN - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - public static function warn($Object, $Label=null) { - return self::send($Object, $Label, FirePHP::WARN); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::ERROR - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - public static function error($Object, $Label=null) { - return self::send($Object, $Label, FirePHP::ERROR); - } - - /** - * Dumps key and variable to firebug server panel - * - * @see FirePHP::DUMP - * @param string $Key - * @param mixed $Variable - * @return true - * @throws Exception - */ - public static function dump($Key, $Variable) { - return self::send($Variable, $Key, FirePHP::DUMP); - } - - /** - * Log a trace in the firebug console - * - * @see FirePHP::TRACE - * @param string $Label - * @return true - * @throws Exception - */ - public static function trace($Label) { - return self::send($Label, FirePHP::TRACE); - } - - /** - * Log a table in the firebug console - * - * @see FirePHP::TABLE - * @param string $Label - * @param string $Table - * @return true - * @throws Exception - */ - public static function table($Label, $Table) { - return self::send($Table, $Label, FirePHP::TABLE); - } - -} - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 40d51d0bd..2e26eea08 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,6 +6,8 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'FB' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/fb.php', + 'FirePHP' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php', 'HTMLPurifier' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.php', 'HTMLPurifier_Arborize' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php', 'HTMLPurifier_AttrCollections' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e37d76f29..7d68ddc7e 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -628,5 +628,43 @@ "idna", "punycode" ] + }, + { + "name": "firephp/firephp-core", + "version": "v0.4.0", + "version_normalized": "0.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/firephp/firephp-core.git", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firephp/firephp-core/zipball/fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "shasum": "" + }, + "time": "2013-04-23 15:28:20", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "lib/FirePHPCore/FirePHP.class.php", + "lib/FirePHPCore/fb.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "homepage": "http://christophdorn.com" + } + ], + "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", + "homepage": "https://github.com/firephp/firephp-core" } ] diff --git a/vendor/firephp/firephp-core/.gitignore b/vendor/firephp/firephp-core/.gitignore new file mode 100644 index 000000000..d16386367 --- /dev/null +++ b/vendor/firephp/firephp-core/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/vendor/firephp/firephp-core/CHANGELOG.md b/vendor/firephp/firephp-core/CHANGELOG.md new file mode 100644 index 000000000..d8b0f86df --- /dev/null +++ b/vendor/firephp/firephp-core/CHANGELOG.md @@ -0,0 +1,171 @@ + +TODO: + + * Fix code indenting in PHP 4 code + * Port maxDepth option to PHP 4 code + +2013-04-23 - Release Version: 0.4.0 + + * No changes + +2011-06-22 - Release Version: 0.4.0rc3 + + * Build fixes + +2011-06-20 - Release Version: 0.4.0rc1 + + * (Issue 163) PHP5 class_exists() throws Exception without second parameter + * (Issue 166) Non-utf8 array values replaced with null + * Cleaned up code formatting [sokolov.innokenty@gmail.com] + * Ensure JSON keys are never NULL (due to NULL key in some arrays) + * Better UTF-8 encoding detection + * Code style cleanup (qbbr) + * Changed license to MIT + * Refactored project + +2010-10-26 - Release Version: 0.3.2 + +2010-10-12 - Release Version: 0.3.2rc6 + + * (Issue 154) getRequestHeader uses "getallheaders" even though it doesn't always exist. [25m] + +2010-10-09 - Release Version: 0.3.2rc5 + + * (Issue 153) FirePHP incorrectly double-encodes UTF8 when mbstring.func_overload is enabled + +2010-10-08 - Release Version: 0.3.2rc4 + + * Trigger upgrade message if part of FirePHP 1.0 + * Removed FirePHP/Init.php inclusion logic and only load FirePHP.class.php if not already loaded + +2010-07-19 - Release Version: 0.3.2rc3 + + * Fixed FirePHP/Init.php inclusion logic + +2010-07-19 - Release Version: 0.3.2rc2 + + * (Issue 145) maxDepth option + * Changed maxObjectDepth and maxArrayDepth option defaults to 5 + * Fixed code indentation + +2010-03-05 - Release Version: 0.3.2rc1 + + * (Issue 114) Allow options to be passed on to basic logging wrappers + * (Issue 122) Filter objectStack property of FirePHP class + * (Issue 123) registerErrorHandler(false) by default + * Added setOption() and getOption() methods + * (Issue 117) dump() method argument validation + * Started adding PHPUnit tests + * Some refactoring to support unit testing + * Deprecated setProcessorUrl() and setRendererUrl() + * Check User-Agent and X-FirePHP-Version header to detect FirePHP on client + * (Issue 135) FirePHP 0.4.3 with Firebug 1.5 changes user agent on the fly + * (Issue 112) Error Predefined Constants Not available for PHP 5.x versions + +2008-06-14 - Release Version: 0.3.1 + + * (Issue 108) ignore class name case in object filter + +2009-05-11 - Release Version: 0.3 +2009-05-01 - Release Version: 0.3.rc.1 + + * (Issue 90) PHP4 compatible version of FirePHPCore + * (Issue 98) Thrown exceptions don't send an HTTP 500 if the FirePHP exception handler is enabled + * (Issue 85) Support associative arrays in encodeTable method in FirePHP.class.php + * (Issue 66) Add a new getOptions() public method in API + * (Issue 82) Define $this->options outside of __construct + * (Issue 72) Message error if group name is null + * (Issue 68) registerErrorHandler() and registerExceptionHandler() should returns previous handlers defined + * (Issue 69) Add the missing register handler in the triumvirate (error, exception, assert) + * (Issue 75) [Error & Exception Handling] Option to not exit script execution + * (Issue 83) Exception handler can't throw exceptions + * (Issue 80) Auto/Pre collapsing groups AND Custom group row colors + +2008-11-09 - Release Version: 0.2.1 + + * (Issue 70) Problem when logging resources + +2008-10-21 - Release Version: 0.2.0 + + * Updated version to 0.2.0 + * Switched to using __sleep instead of __wakeup + * Added support to exclude object members when encoding + * Add support to enable/disable logging + +2008-10-17 - Release Version: 0.2.b.8 + + * New implementation for is_utf8() + * (Issue 55) maxObjectDepth Option not working correctly when using TABLE and EXCEPTION Type + * Bugfix for max[Object|Array]Depth when encoding nested array/object graphs + * Bugfix for FB::setOptions() + +2008-10-16 - Release Version: 0.2.b.7 + + * (Issue 45) Truncate dump when string have non utf8 cars + * (Issue 52) logging will not work when firephp object gets stored in the session. + +2008-10-16 - Release Version: 0.2.b.6 + + * (Issue 37) Display file and line information for each log message + * (Issue 51) Limit output of object graphs + * Bugfix for encoding object members set to NULL|false|'' + +2008-10-14 - Release Version: 0.2.b.5 + + * Updated JsonStream wildfire protocol to be more robust + * (Issue 33) PHP error notices running demos + * (Issue 48) Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given + +2008-10-08 - Release Version: 0.2.b.4 + + * Bugfix for logging objects with recursion + +2008-10-08 - Release Version: 0.2.b.3 + + * (Issue 43) Notice message in 0.2b2 + * Added support for PHP's native json_encode() if available + * Revised object encoder to detect object recursion + +2008-10-07 - Release Version: 0.2.b.2 + + * (Issue 28) Need solution for logging private and protected object variables + * Added trace() and table() aliases in FirePHP class + * (Issue 41) Use PHP doc in FirePHP + * (Issue 39) Static logging method for object oriented API + +2008-10-01 - Release Version: 0.2.b.1 + + * Added support for error and exception handling + * Updated min PHP version for PEAR package to 5.2 + * Added version constant for library + * Gave server library it's own wildfire plugin namespace + * Migrated communication protocol to Wildfire JsonStream + * Added support for console groups using "group" and "groupEnd" + * Added support for log, info, warn and error logging aliases + * (Issue 29) problem with TRACE when using with error_handler + * (Issue 33) PHP error notices running demos + * (Issue 12) undefined index php notice + * Removed closing ?> php tags + * (Issue 13) the code in the fb() function has a second return statement that will never be reached + +2008-07-30 - Release Version: 0.1.1.3 + + * Include __className property in JSON string if variable was an object + * Bugfix - Mis-spelt "Exception" in JSON encoding code + +2008-06-13 - Release Version: 0.1.1.1 + + * Bugfix - Standardize windows paths in stack traces + * Bugfix - Display correct stack trace info in windows environments + * Bugfix - Check $_SERVER['HTTP_USER_AGENT'] before returning + +2008-06-13 - Release Version: 0.1.1 + + * Added support for FirePHP::TRACE log style + * Changed license to New BSD License + +2008-06-06 - Release Version: 0.0.2 + + * Bugfix - Added usleep() to header writing loop to ensure unique index + * Bugfix - Ensure chunk_split does not generate trailing "\n" with empty data header + * Added support for FirePHP::TABLE log style diff --git a/vendor/firephp/firephp-core/README.md b/vendor/firephp/firephp-core/README.md new file mode 100644 index 000000000..b1b32f842 --- /dev/null +++ b/vendor/firephp/firephp-core/README.md @@ -0,0 +1,75 @@ +FirePHPCore +=========== + +**Status: stable** + +> **FirePHP is an advanced logging system that can display PHP variables in the browser as an application is navigated.** +> All communication is out of band to the application meaning that the logging data will not interfere with the normal functioning of the application. + +This project contains the *FirePHPCore* PHP server library and provides a development environment (see `./workspace/`) for working on *FirePHPCore*. + + +Usage +===== + +See [Install/Traditional: FirePHPCore](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Configuration/Traditional) in the +[FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). + + +Testing +======= + + cd tests + phpunit . + + +Support & Feedback +================== + +See [Support](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#support) in the [FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). + + +Contribute +========== + +See [Contribute](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#contribute) in the [FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). + + +Author +====== + +This project is authored and maintained by [Christoph Dorn](http://www.christophdorn.com/). + + +Documentation License +===================== + +[Creative Commons Attribution-NonCommercial-ShareAlike 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/) + +Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + + +Code License +============ + +[MIT License](http://www.opensource.org/licenses/mit-license.php) + +Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/firephp/firephp-core/composer.json b/vendor/firephp/firephp-core/composer.json new file mode 100644 index 000000000..7cab85a9f --- /dev/null +++ b/vendor/firephp/firephp-core/composer.json @@ -0,0 +1,26 @@ +{ + "name": "firephp/firephp-core", + "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", + "type": "library", + "homepage": "https://github.com/firephp/firephp-core", + "license": "MIT", + "authors": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "homepage": "http://christophdorn.com" + } + ], + "support": { + "forum": "http://groups.google.com/group/firephp-dev", + "issues": "https://github.com/firephp/firephp-core/issues", + "source": "https://github.com/firephp/firephp-core" + }, + "autoload": { + "classmap": [ + "lib/FirePHPCore/FirePHP.class.php", + "lib/FirePHPCore/fb.php" + ] + } +} + diff --git a/vendor/firephp/firephp-core/examples/oo.php b/vendor/firephp/firephp-core/examples/oo.php new file mode 100644 index 000000000..f5f39875c --- /dev/null +++ b/vendor/firephp/firephp-core/examples/oo.php @@ -0,0 +1,82 @@ +, Copyright 2007, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/* *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** */ + + +/* NOTE: You must have the FirePHPCore library in your include path */ + +set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); + + +require('FirePHPCore/FirePHP.class.php'); + +/* NOTE: You must have Output Buffering enabled via + ob_start() or output_buffering ini directive. */ + + +$firephp = FirePHP::getInstance(true); + + +$firephp->fb('Hello World'); /* Defaults to FirePHP::LOG */ + +$firephp->fb('Log message' ,FirePHP::LOG); +$firephp->fb('Info message' ,FirePHP::INFO); +$firephp->fb('Warn message' ,FirePHP::WARN); +$firephp->fb('Error message',FirePHP::ERROR); + +$firephp->fb('Message with label','Label',FirePHP::LOG); + +$firephp->fb(array('key1'=>'val1', + 'key2'=>array(array('v1','v2'),'v3')), + 'TestArray',FirePHP::LOG); + +function test($Arg1) { + throw new Exception('Test Exception'); +} +try { + test(array('Hello'=>'World')); +} catch(Exception $e) { + /* Log exception including stack trace & variables */ + $firephp->fb($e); +} + +$firephp->fb('Backtrace to here',FirePHP::TRACE); + +$firephp->fb(array('2 SQL queries took 0.06 seconds',array( + array('SQL Statement','Time','Result'), + array('SELECT * FROM Foo','0.02',array('row1','row2')), + array('SELECT * FROM Bar','0.04',array('row1','row2')) + )),FirePHP::TABLE); + +/* Will show only in "Server" tab for the request */ +$firephp->fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP); + + +print 'Hello World'; diff --git a/vendor/firephp/firephp-core/examples/oo.php4 b/vendor/firephp/firephp-core/examples/oo.php4 new file mode 100644 index 000000000..75ec1ee3f --- /dev/null +++ b/vendor/firephp/firephp-core/examples/oo.php4 @@ -0,0 +1,72 @@ +, Copyright 2007, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/* *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** */ + + +/* NOTE: You must have the FirePHPCore library in your include path */ + +set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); + + +require('FirePHPCore/FirePHP.class.php4'); + +/* NOTE: You must have Output Buffering enabled via + ob_start() or output_buffering ini directive. */ + + +$firephp =& FirePHP::getInstance(true); + + +$firephp->fb('Hello World'); /* Defaults to FirePHP::LOG */ + +$firephp->fb('Log message' ,FirePHP_LOG); +$firephp->fb('Info message' ,FirePHP_INFO); +$firephp->fb('Warn message' ,FirePHP_WARN); +$firephp->fb('Error message',FirePHP_ERROR); + +$firephp->fb('Message with label','Label',FirePHP_LOG); + +$firephp->fb(array('key1'=>'val1', + 'key2'=>array(array('v1','v2'),'v3')), + 'TestArray',FirePHP_LOG); + +$firephp->fb('Backtrace to here',FirePHP_TRACE); + +$firephp->fb(array('2 SQL queries took 0.06 seconds',array( + array('SQL Statement','Time','Result'), + array('SELECT * FROM Foo','0.02',array('row1','row2')), + array('SELECT * FROM Bar','0.04',array('row1','row2')) + )),FirePHP_TABLE); + +/* Will show only in "Server" tab for the request */ +$firephp->fb(apache_request_headers(),'RequestHeaders',FirePHP_DUMP); + + +print 'Hello World'; diff --git a/vendor/firephp/firephp-core/examples/procedural.php b/vendor/firephp/firephp-core/examples/procedural.php new file mode 100644 index 000000000..d1d3920bf --- /dev/null +++ b/vendor/firephp/firephp-core/examples/procedural.php @@ -0,0 +1,79 @@ +, Copyright 2007, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/* *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** */ + + +/* NOTE: You must have the FirePHPCore library in your include path */ + +set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); + + +require('FirePHPCore/fb.php'); + +/* NOTE: You must have Output Buffering enabled via + ob_start() or output_buffering ini directive. */ + +fb('Hello World'); /* Defaults to FirePHP::LOG */ + +fb('Log message' ,FirePHP::LOG); +fb('Info message' ,FirePHP::INFO); +fb('Warn message' ,FirePHP::WARN); +fb('Error message',FirePHP::ERROR); + +fb('Message with label','Label',FirePHP::LOG); + +fb(array('key1'=>'val1', + 'key2'=>array(array('v1','v2'),'v3')), + 'TestArray',FirePHP::LOG); + +function test($Arg1) { + throw new Exception('Test Exception'); +} +try { + test(array('Hello'=>'World')); +} catch(Exception $e) { + /* Log exception including stack trace & variables */ + fb($e); +} + +fb('Backtrace to here',FirePHP::TRACE); + +fb(array('2 SQL queries took 0.06 seconds',array( + array('SQL Statement','Time','Result'), + array('SELECT * FROM Foo','0.02',array('row1','row2')), + array('SELECT * FROM Bar','0.04',array('row1','row2')) + )),FirePHP::TABLE); + +/* Will show only in "Server" tab for the request */ +fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP); + + +print 'Hello World'; + diff --git a/vendor/firephp/firephp-core/examples/procedural.php4 b/vendor/firephp/firephp-core/examples/procedural.php4 new file mode 100644 index 000000000..28eb7dc17 --- /dev/null +++ b/vendor/firephp/firephp-core/examples/procedural.php4 @@ -0,0 +1,69 @@ +, Copyright 2007, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/* *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** */ + + +/* NOTE: You must have the FirePHPCore library in your include path */ + +set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); + + +require('FirePHPCore/fb.php'); + +/* NOTE: You must have Output Buffering enabled via + ob_start() or output_buffering ini directive. */ + +fb('Hello World'); /* Defaults to FirePHP::LOG */ + +fb('Log message' ,FirePHP_LOG); +fb('Info message' ,FirePHP_INFO); +fb('Warn message' ,FirePHP_WARN); +fb('Error message',FirePHP_ERROR); + +fb('Message with label','Label',FirePHP_LOG); + +fb(array('key1'=>'val1', + 'key2'=>array(array('v1','v2'),'v3')), + 'TestArray',FirePHP_LOG); + +fb('Backtrace to here',FirePHP_TRACE); + +fb(array('2 SQL queries took 0.06 seconds',array( + array('SQL Statement','Time','Result'), + array('SELECT * FROM Foo','0.02',array('row1','row2')), + array('SELECT * FROM Bar','0.04',array('row1','row2')) + )),FirePHP_TABLE); + +/* Will show only in "Server" tab for the request */ +fb(apache_request_headers(),'RequestHeaders',FirePHP_DUMP); + + +print 'Hello World'; + diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php new file mode 100644 index 000000000..65d83b56d --- /dev/null +++ b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php @@ -0,0 +1,1828 @@ +, Copyright 2007, New BSD License +// - qbbr, Sokolov Innokenty , Copyright 2011, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/** + * *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ + +/** + * @see http://code.google.com/p/firephp/issues/detail?id=112 + */ +if (!defined('E_STRICT')) { + define('E_STRICT', 2048); +} +if (!defined('E_RECOVERABLE_ERROR')) { + define('E_RECOVERABLE_ERROR', 4096); +} +if (!defined('E_DEPRECATED')) { + define('E_DEPRECATED', 8192); +} +if (!defined('E_USER_DEPRECATED')) { + define('E_USER_DEPRECATED', 16384); +} + +/** + * Sends the given data to the FirePHP Firefox Extension. + * The data can be displayed in the Firebug Console or in the + * "Server" request tab. + * + * For more information see: http://www.firephp.org/ + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ +class FirePHP { + + /** + * FirePHP version + * + * @var string + */ + const VERSION = '0.3'; // @pinf replace '0.3' with '%%VERSION%%' + + /** + * Firebug LOG level + * + * Logs a message to firebug console. + * + * @var string + */ + const LOG = 'LOG'; + + /** + * Firebug INFO level + * + * Logs a message to firebug console and displays an info icon before the message. + * + * @var string + */ + const INFO = 'INFO'; + + /** + * Firebug WARN level + * + * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. + * + * @var string + */ + const WARN = 'WARN'; + + /** + * Firebug ERROR level + * + * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. + * + * @var string + */ + const ERROR = 'ERROR'; + + /** + * Dumps a variable to firebug's server panel + * + * @var string + */ + const DUMP = 'DUMP'; + + /** + * Displays a stack trace in firebug console + * + * @var string + */ + const TRACE = 'TRACE'; + + /** + * Displays an exception in firebug console + * + * Increments the firebug error count. + * + * @var string + */ + const EXCEPTION = 'EXCEPTION'; + + /** + * Displays an table in firebug console + * + * @var string + */ + const TABLE = 'TABLE'; + + /** + * Starts a group in firebug console + * + * @var string + */ + const GROUP_START = 'GROUP_START'; + + /** + * Ends a group in firebug console + * + * @var string + */ + const GROUP_END = 'GROUP_END'; + + /** + * Singleton instance of FirePHP + * + * @var FirePHP + */ + protected static $instance = null; + + /** + * Flag whether we are logging from within the exception handler + * + * @var boolean + */ + protected $inExceptionHandler = false; + + /** + * Flag whether to throw PHP errors that have been converted to ErrorExceptions + * + * @var boolean + */ + protected $throwErrorExceptions = true; + + /** + * Flag whether to convert PHP assertion errors to Exceptions + * + * @var boolean + */ + protected $convertAssertionErrorsToExceptions = true; + + /** + * Flag whether to throw PHP assertion errors that have been converted to Exceptions + * + * @var boolean + */ + protected $throwAssertionExceptions = false; + + /** + * Wildfire protocol message index + * + * @var integer + */ + protected $messageIndex = 1; + + /** + * Options for the library + * + * @var array + */ + protected $options = array('maxDepth' => 10, + 'maxObjectDepth' => 5, + 'maxArrayDepth' => 5, + 'useNativeJsonEncode' => true, + 'includeLineNumbers' => true); + + /** + * Filters used to exclude object members when encoding + * + * @var array + */ + protected $objectFilters = array( + 'firephp' => array('objectStack', 'instance', 'json_objectStack'), + 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack') + ); + + /** + * A stack of objects used to detect recursion during object encoding + * + * @var object + */ + protected $objectStack = array(); + + /** + * Flag to enable/disable logging + * + * @var boolean + */ + protected $enabled = true; + + /** + * The insight console to log to if applicable + * + * @var object + */ + protected $logToInsightConsole = null; + + /** + * When the object gets serialized only include specific object members. + * + * @return array + */ + public function __sleep() + { + return array('options', 'objectFilters', 'enabled'); + } + + /** + * Gets singleton instance of FirePHP + * + * @param boolean $autoCreate + * @return FirePHP + */ + public static function getInstance($autoCreate = false) + { + if ($autoCreate === true && !self::$instance) { + self::init(); + } + return self::$instance; + } + + /** + * Creates FirePHP object and stores it for singleton access + * + * @return FirePHP + */ + public static function init() + { + return self::setInstance(new self()); + } + + /** + * Set the instance of the FirePHP singleton + * + * @param FirePHP $instance The FirePHP object instance + * @return FirePHP + */ + public static function setInstance($instance) + { + return self::$instance = $instance; + } + + /** + * Set an Insight console to direct all logging calls to + * + * @param object $console The console object to log to + * @return void + */ + public function setLogToInsightConsole($console) + { + if (is_string($console)) { + if (get_class($this) != 'FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { + throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); + } + $this->logToInsightConsole = $this->to('request')->console($console); + } else { + $this->logToInsightConsole = $console; + } + } + + /** + * Enable and disable logging to Firebug + * + * @param boolean $enabled TRUE to enable, FALSE to disable + * @return void + */ + public function setEnabled($enabled) + { + $this->enabled = $enabled; + } + + /** + * Check if logging is enabled + * + * @return boolean TRUE if enabled + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * Specify a filter to be used when encoding an object + * + * Filters are used to exclude object members. + * + * @param string $class The class name of the object + * @param array $filter An array of members to exclude + * @return void + */ + public function setObjectFilter($class, $filter) + { + $this->objectFilters[strtolower($class)] = $filter; + } + + /** + * Set some options for the library + * + * Options: + * - maxDepth: The maximum depth to traverse (default: 10) + * - maxObjectDepth: The maximum depth to traverse objects (default: 5) + * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) + * - useNativeJsonEncode: If true will use json_encode() (default: true) + * - includeLineNumbers: If true will include line numbers and filenames (default: true) + * + * @param array $options The options to be set + * @return void + */ + public function setOptions($options) + { + $this->options = array_merge($this->options, $options); + } + + /** + * Get options from the library + * + * @return array The currently set options + */ + public function getOptions() + { + return $this->options; + } + + /** + * Set an option for the library + * + * @param string $name + * @param mixed $value + * @return void + * @throws Exception + */ + public function setOption($name, $value) + { + if (!isset($this->options[$name])) { + throw $this->newException('Unknown option: ' . $name); + } + $this->options[$name] = $value; + } + + /** + * Get an option from the library + * + * @param string $name + * @return mixed + * @throws Exception + */ + public function getOption($name) + { + if (!isset($this->options[$name])) { + throw $this->newException('Unknown option: ' . $name); + } + return $this->options[$name]; + } + + /** + * Register FirePHP as your error handler + * + * Will throw exceptions for each php error. + * + * @return mixed Returns a string containing the previously defined error handler (if any) + */ + public function registerErrorHandler($throwErrorExceptions = false) + { + //NOTE: The following errors will not be caught by this error handler: + // E_ERROR, E_PARSE, E_CORE_ERROR, + // E_CORE_WARNING, E_COMPILE_ERROR, + // E_COMPILE_WARNING, E_STRICT + + $this->throwErrorExceptions = $throwErrorExceptions; + + return set_error_handler(array($this, 'errorHandler')); + } + + /** + * FirePHP's error handler + * + * Throws exception for each php error that will occur. + * + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + * @param array $errcontext + */ + public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) + { + // Don't throw exception if error reporting is switched off + if (error_reporting() == 0) { + return; + } + // Only throw exceptions for errors we are asking for + if (error_reporting() & $errno) { + + $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); + if ($this->throwErrorExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + } + } + + /** + * Register FirePHP as your exception handler + * + * @return mixed Returns the name of the previously defined exception handler, + * or NULL on error. + * If no previous handler was defined, NULL is also returned. + */ + public function registerExceptionHandler() + { + return set_exception_handler(array($this, 'exceptionHandler')); + } + + /** + * FirePHP's exception handler + * + * Logs all exceptions to your firebug console and then stops the script. + * + * @param Exception $exception + * @throws Exception + */ + function exceptionHandler($exception) + { + $this->inExceptionHandler = true; + + header('HTTP/1.1 500 Internal Server Error'); + + try { + $this->fb($exception); + } catch (Exception $e) { + echo 'We had an exception: ' . $e; + } + + $this->inExceptionHandler = false; + } + + /** + * Register FirePHP driver as your assert callback + * + * @param boolean $convertAssertionErrorsToExceptions + * @param boolean $throwAssertionExceptions + * @return mixed Returns the original setting or FALSE on errors + */ + public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) + { + $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; + $this->throwAssertionExceptions = $throwAssertionExceptions; + + if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { + throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); + } + + return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); + } + + /** + * FirePHP's assertion handler + * + * Logs all assertions to your firebug console and then stops the script. + * + * @param string $file File source of assertion + * @param integer $line Line source of assertion + * @param mixed $code Assertion code + */ + public function assertionHandler($file, $line, $code) + { + if ($this->convertAssertionErrorsToExceptions) { + + $exception = new ErrorException('Assertion Failed - Code[ ' . $code . ' ]', 0, null, $file, $line); + + if ($this->throwAssertionExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + + } else { + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File' => $file, 'Line' => $line)); + } + } + + /** + * Start a group for following messages. + * + * Options: + * Collapsed: [true|false] + * Color: [#RRGGBB|ColorName] + * + * @param string $name + * @param array $options OPTIONAL Instructions on how to log the group + * @return true + * @throws Exception + */ + public function group($name, $options = null) + { + + if (!$name) { + throw $this->newException('You must specify a label for the group!'); + } + + if ($options) { + if (!is_array($options)) { + throw $this->newException('Options must be defined as an array!'); + } + if (array_key_exists('Collapsed', $options)) { + $options['Collapsed'] = ($options['Collapsed']) ? 'true' : 'false'; + } + } + + return $this->fb(null, $name, FirePHP::GROUP_START, $options); + } + + /** + * Ends a group you have started before + * + * @return true + * @throws Exception + */ + public function groupEnd() + { + return $this->fb(null, null, FirePHP::GROUP_END); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::LOG + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function log($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::LOG, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::INFO + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function info($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::INFO, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::WARN + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function warn($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::WARN, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::ERROR + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function error($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::ERROR, $options); + } + + /** + * Dumps key and variable to firebug server panel + * + * @see FirePHP::DUMP + * @param string $key + * @param mixed $variable + * @return true + * @throws Exception + */ + public function dump($key, $variable, $options = array()) + { + if (!is_string($key)) { + throw $this->newException('Key passed to dump() is not a string'); + } + if (strlen($key) > 100) { + throw $this->newException('Key passed to dump() is longer than 100 characters'); + } + if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $key, $m)) { + throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); + } + return $this->fb($variable, $key, FirePHP::DUMP, $options); + } + + /** + * Log a trace in the firebug console + * + * @see FirePHP::TRACE + * @param string $label + * @return true + * @throws Exception + */ + public function trace($label) + { + return $this->fb($label, FirePHP::TRACE); + } + + /** + * Log a table in the firebug console + * + * @see FirePHP::TABLE + * @param string $label + * @param string $table + * @return true + * @throws Exception + */ + public function table($label, $table, $options = array()) + { + return $this->fb($table, $label, FirePHP::TABLE, $options); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::to() + */ + public static function to() + { + $instance = self::getInstance(); + if (!method_exists($instance, '_to')) { + throw new Exception('FirePHP::to() implementation not loaded'); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_to'), $args); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::plugin() + */ + public static function plugin() + { + $instance = self::getInstance(); + if (!method_exists($instance, '_plugin')) { + throw new Exception('FirePHP::plugin() implementation not loaded'); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_plugin'), $args); + } + + /** + * Check if FirePHP is installed on client + * + * @return boolean + */ + public function detectClientExtension() + { + // Check if FirePHP is installed on client via User-Agent header + if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si', $this->getUserAgent(), $m) && + version_compare($m[1][0], '0.0.6', '>=')) { + return true; + } else + // Check if FirePHP is installed on client via X-FirePHP-Version header + if (@preg_match_all('/^([\.\d]*)$/si', $this->getRequestHeader('X-FirePHP-Version'), $m) && + version_compare($m[1][0], '0.0.6', '>=')) { + return true; + } + return false; + } + + /** + * Log varible to Firebug + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $object The variable to be logged + * @return boolean Return TRUE if message was added to headers, FALSE otherwise + * @throws Exception + */ + public function fb($object) + { + if ($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) { + if (!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message + $this->_logUpgradeClientMessage(); + } + } + + static $insightGroupStack = array(); + + if (!$this->getEnabled()) { + return false; + } + + if ($this->headersSent($filename, $linenum)) { + // If we are logging from within the exception handler we cannot throw another exception + if ($this->inExceptionHandler) { + // Simply echo the error out to the page + echo '
FirePHP ERROR: Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.
'; + } else { + throw $this->newException('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); + } + } + + $type = null; + $label = null; + $options = array(); + + if (func_num_args() == 1) { + } else if (func_num_args() == 2) { + switch (func_get_arg(1)) { + case self::LOG: + case self::INFO: + case self::WARN: + case self::ERROR: + case self::DUMP: + case self::TRACE: + case self::EXCEPTION: + case self::TABLE: + case self::GROUP_START: + case self::GROUP_END: + $type = func_get_arg(1); + break; + default: + $label = func_get_arg(1); + break; + } + } else if (func_num_args() == 3) { + $type = func_get_arg(2); + $label = func_get_arg(1); + } else if (func_num_args() == 4) { + $type = func_get_arg(2); + $label = func_get_arg(1); + $options = func_get_arg(3); + } else { + throw $this->newException('Wrong number of arguments to fb() function!'); + } + + if ($this->logToInsightConsole !== null && (get_class($this) == 'FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) { + $trace = debug_backtrace(); + if (!$trace) return false; + for ($i = 0; $i < sizeof($trace); $i++) { + if (isset($trace[$i]['class'])) { + if ($trace[$i]['class'] == 'FirePHP' || $trace[$i]['class'] == 'FB') { + continue; + } + } + if (isset($trace[$i]['file'])) { + $path = $this->_standardizePath($trace[$i]['file']); + if (substr($path, -18, 18) == 'FirePHPCore/fb.php' || substr($path, -29, 29) == 'FirePHPCore/FirePHP.class.php') { + continue; + } + } + if (isset($trace[$i]['function']) && $trace[$i]['function'] == 'fb' && + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + continue; + } + if (isset($trace[$i]['class']) && $trace[$i]['class'] == 'FB' && + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + continue; + } + break; + } + // adjust trace offset + $msg = $this->logToInsightConsole->option('encoder.trace.offsetAdjustment', $i); + + if ($object instanceof Exception) { + $type = self::EXCEPTION; + } + if ($label && $type != self::TABLE && $type != self::GROUP_START) { + $msg = $msg->label($label); + } + switch ($type) { + case self::DUMP: + case self::LOG: + return $msg->log($object); + case self::INFO: + return $msg->info($object); + case self::WARN: + return $msg->warn($object); + case self::ERROR: + return $msg->error($object); + case self::TRACE: + return $msg->trace($object); + case self::EXCEPTION: + return $this->plugin('error')->handleException($object, $msg); + case self::TABLE: + if (isset($object[0]) && !is_string($object[0]) && $label) { + $object = array($label, $object); + } + return $msg->table($object[0], array_slice($object[1], 1), $object[1][0]); + case self::GROUP_START: + $insightGroupStack[] = $msg->group(md5($label))->open(); + return $msg->log($label); + case self::GROUP_END: + if (count($insightGroupStack) == 0) { + throw new Error('Too many groupEnd() as opposed to group() calls!'); + } + $group = array_pop($insightGroupStack); + return $group->close(); + default: + return $msg->log($object); + } + } + + if (!$this->detectClientExtension()) { + return false; + } + + $meta = array(); + $skipFinalObjectEncode = false; + + if ($object instanceof Exception) { + + $meta['file'] = $this->_escapeTraceFile($object->getFile()); + $meta['line'] = $object->getLine(); + + $trace = $object->getTrace(); + if ($object instanceof ErrorException + && isset($trace[0]['function']) + && $trace[0]['function'] == 'errorHandler' + && isset($trace[0]['class']) + && $trace[0]['class'] == 'FirePHP') { + + $severity = false; + switch ($object->getSeverity()) { + case E_WARNING: + $severity = 'E_WARNING'; + break; + + case E_NOTICE: + $severity = 'E_NOTICE'; + break; + + case E_USER_ERROR: + $severity = 'E_USER_ERROR'; + break; + + case E_USER_WARNING: + $severity = 'E_USER_WARNING'; + break; + + case E_USER_NOTICE: + $severity = 'E_USER_NOTICE'; + break; + + case E_STRICT: + $severity = 'E_STRICT'; + break; + + case E_RECOVERABLE_ERROR: + $severity = 'E_RECOVERABLE_ERROR'; + break; + + case E_DEPRECATED: + $severity = 'E_DEPRECATED'; + break; + + case E_USER_DEPRECATED: + $severity = 'E_USER_DEPRECATED'; + break; + } + + $object = array('Class' => get_class($object), + 'Message' => $severity . ': ' . $object->getMessage(), + 'File' => $this->_escapeTraceFile($object->getFile()), + 'Line' => $object->getLine(), + 'Type' => 'trigger', + 'Trace' => $this->_escapeTrace(array_splice($trace, 2))); + $skipFinalObjectEncode = true; + } else { + $object = array('Class' => get_class($object), + 'Message' => $object->getMessage(), + 'File' => $this->_escapeTraceFile($object->getFile()), + 'Line' => $object->getLine(), + 'Type' => 'throw', + 'Trace' => $this->_escapeTrace($trace)); + $skipFinalObjectEncode = true; + } + $type = self::EXCEPTION; + + } else if ($type == self::TRACE) { + + $trace = debug_backtrace(); + if (!$trace) return false; + for ($i = 0; $i < sizeof($trace); $i++) { + + if (isset($trace[$i]['class']) + && isset($trace[$i]['file']) + && ($trace[$i]['class'] == 'FirePHP' + || $trace[$i]['class'] == 'FB') + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i+1]['file']) + && $trace[$i]['class'] == 'FirePHP' + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if ($trace[$i]['function'] == 'fb' + || $trace[$i]['function'] == 'trace' + || $trace[$i]['function'] == 'send') { + + $object = array('Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '', + 'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '', + 'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '', + 'Message' => $trace[$i]['args'][0], + 'File' => isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '', + 'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '', + 'Args' => isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '', + 'Trace' => $this->_escapeTrace(array_splice($trace, $i + 1))); + + $skipFinalObjectEncode = true; + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; + break; + } + } + + } else + if ($type == self::TABLE) { + + if (isset($object[0]) && is_string($object[0])) { + $object[1] = $this->encodeTable($object[1]); + } else { + $object = $this->encodeTable($object); + } + + $skipFinalObjectEncode = true; + + } else if ($type == self::GROUP_START) { + + if (!$label) { + throw $this->newException('You must specify a label for the group!'); + } + + } else { + if ($type === null) { + $type = self::LOG; + } + } + + if ($this->options['includeLineNumbers']) { + if (!isset($meta['file']) || !isset($meta['line'])) { + + $trace = debug_backtrace(); + for ($i = 0; $trace && $i < sizeof($trace); $i++) { + + if (isset($trace[$i]['class']) + && isset($trace[$i]['file']) + && ($trace[$i]['class'] == 'FirePHP' + || $trace[$i]['class'] == 'FB') + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i + 1]['file']) + && $trace[$i]['class'] == 'FirePHP' + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if (isset($trace[$i]['file']) + && substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip FB::fb() */ + } else { + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; + break; + } + } + } + } else { + unset($meta['file']); + unset($meta['line']); + } + + $this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); + $this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . self::VERSION); + + $structureIndex = 1; + if ($type == self::DUMP) { + $structureIndex = 2; + $this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); + } else { + $this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); + } + + if ($type == self::DUMP) { + $msg = '{"' . $label . '":' . $this->jsonEncode($object, $skipFinalObjectEncode) . '}'; + } else { + $msgMeta = $options; + $msgMeta['Type'] = $type; + if ($label !== null) { + $msgMeta['Label'] = $label; + } + if (isset($meta['file']) && !isset($msgMeta['File'])) { + $msgMeta['File'] = $meta['file']; + } + if (isset($meta['line']) && !isset($msgMeta['Line'])) { + $msgMeta['Line'] = $meta['line']; + } + $msg = '[' . $this->jsonEncode($msgMeta) . ',' . $this->jsonEncode($object, $skipFinalObjectEncode) . ']'; + } + + $parts = explode("\n", chunk_split($msg, 5000, "\n")); + + for ($i = 0; $i < count($parts); $i++) { + + $part = $parts[$i]; + if ($part) { + + if (count($parts) > 2) { + // Message needs to be split into multiple parts + $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, + (($i == 0) ? strlen($msg) : '') + . '|' . $part . '|' + . (($i < count($parts) - 2) ? '\\' : '')); + } else { + $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, + strlen($part) . '|' . $part . '|'); + } + + $this->messageIndex++; + + if ($this->messageIndex > 99999) { + throw $this->newException('Maximum number (99,999) of messages reached!'); + } + } + } + + $this->setHeader('X-Wf-1-Index', $this->messageIndex - 1); + + return true; + } + + /** + * Standardizes path for windows systems. + * + * @param string $path + * @return string + */ + protected function _standardizePath($path) + { + return preg_replace('/\\\\+/', '/', $path); + } + + /** + * Escape trace path for windows systems + * + * @param array $trace + * @return array + */ + protected function _escapeTrace($trace) + { + if (!$trace) return $trace; + for ($i = 0; $i < sizeof($trace); $i++) { + if (isset($trace[$i]['file'])) { + $trace[$i]['file'] = $this->_escapeTraceFile($trace[$i]['file']); + } + if (isset($trace[$i]['args'])) { + $trace[$i]['args'] = $this->encodeObject($trace[$i]['args']); + } + } + return $trace; + } + + /** + * Escape file information of trace for windows systems + * + * @param string $file + * @return string + */ + protected function _escapeTraceFile($file) + { + /* Check if we have a windows filepath */ + if (strpos($file, '\\')) { + /* First strip down to single \ */ + + $file = preg_replace('/\\\\+/', '\\', $file); + + return $file; + } + return $file; + } + + /** + * Check if headers have already been sent + * + * @param string $filename + * @param integer $linenum + */ + protected function headersSent(&$filename, &$linenum) + { + return headers_sent($filename, $linenum); + } + + /** + * Send header + * + * @param string $name + * @param string $value + */ + protected function setHeader($name, $value) + { + return header($name . ': ' . $value); + } + + /** + * Get user agent + * + * @return string|false + */ + protected function getUserAgent() + { + if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; + return $_SERVER['HTTP_USER_AGENT']; + } + + /** + * Get all request headers + * + * @return array + */ + public static function getAllRequestHeaders() + { + static $_cachedHeaders = false; + if ($_cachedHeaders !== false) { + return $_cachedHeaders; + } + $headers = array(); + if (function_exists('getallheaders')) { + foreach (getallheaders() as $name => $value) { + $headers[strtolower($name)] = $value; + } + } else { + foreach ($_SERVER as $name => $value) { + if (substr($name, 0, 5) == 'HTTP_') { + $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; + } + } + } + return $_cachedHeaders = $headers; + } + + /** + * Get a request header + * + * @return string|false + */ + protected function getRequestHeader($name) + { + $headers = self::getAllRequestHeaders(); + if (isset($headers[strtolower($name)])) { + return $headers[strtolower($name)]; + } + return false; + } + + /** + * Returns a new exception + * + * @param string $message + * @return Exception + */ + protected function newException($message) + { + return new Exception($message); + } + + /** + * Encode an object into a JSON string + * + * Uses PHP's jeson_encode() if available + * + * @param object $object The object to be encoded + * @param boolean $skipObjectEncode + * @return string The JSON string + */ + public function jsonEncode($object, $skipObjectEncode = false) + { + if (!$skipObjectEncode) { + $object = $this->encodeObject($object); + } + + if (function_exists('json_encode') + && $this->options['useNativeJsonEncode'] != false) { + + return json_encode($object); + } else { + return $this->json_encode($object); + } + } + + /** + * Encodes a table by encoding each row and column with encodeObject() + * + * @param array $table The table to be encoded + * @return array + */ + protected function encodeTable($table) + { + if (!$table) return $table; + + $newTable = array(); + foreach ($table as $row) { + + if (is_array($row)) { + $newRow = array(); + + foreach ($row as $item) { + $newRow[] = $this->encodeObject($item); + } + + $newTable[] = $newRow; + } + } + + return $newTable; + } + + /** + * Encodes an object including members with + * protected and private visibility + * + * @param object $object The object to be encoded + * @param integer $Depth The current traversal depth + * @return array All members of the object + */ + protected function encodeObject($object, $objectDepth = 1, $arrayDepth = 1, $maxDepth = 1) + { + if ($maxDepth > $this->options['maxDepth']) { + return '** Max Depth (' . $this->options['maxDepth'] . ') **'; + } + + $return = array(); + + if (is_resource($object)) { + + return '** ' . (string) $object . ' **'; + + } else if (is_object($object)) { + + if ($objectDepth > $this->options['maxObjectDepth']) { + return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **'; + } + + foreach ($this->objectStack as $refVal) { + if ($refVal === $object) { + return '** Recursion (' . get_class($object) . ') **'; + } + } + array_push($this->objectStack, $object); + + $return['__className'] = $class = get_class($object); + $classLower = strtolower($class); + + $reflectionClass = new ReflectionClass($class); + $properties = array(); + foreach ($reflectionClass->getProperties() as $property) { + $properties[$property->getName()] = $property; + } + + $members = (array)$object; + + foreach ($properties as $plainName => $property) { + + $name = $rawName = $plainName; + if ($property->isStatic()) { + $name = 'static:' . $name; + } + if ($property->isPublic()) { + $name = 'public:' . $name; + } else if ($property->isPrivate()) { + $name = 'private:' . $name; + $rawName = "\0" . $class . "\0" . $rawName; + } else if ($property->isProtected()) { + $name = 'protected:' . $name; + $rawName = "\0" . '*' . "\0" . $rawName; + } + + if (!(isset($this->objectFilters[$classLower]) + && is_array($this->objectFilters[$classLower]) + && in_array($plainName, $this->objectFilters[$classLower]))) { + + if (array_key_exists($rawName, $members) && !$property->isStatic()) { + $return[$name] = $this->encodeObject($members[$rawName], $objectDepth + 1, 1, $maxDepth + 1); + } else { + if (method_exists($property, 'setAccessible')) { + $property->setAccessible(true); + $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); + } else + if ($property->isPublic()) { + $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); + } else { + $return[$name] = '** Need PHP 5.3 to get value **'; + } + } + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + + // Include all members that are not defined in the class + // but exist in the object + foreach ($members as $rawName => $value) { + + $name = $rawName; + + if ($name{0} == "\0") { + $parts = explode("\0", $name); + $name = $parts[2]; + } + + $plainName = $name; + + if (!isset($properties[$name])) { + $name = 'undeclared:' . $name; + + if (!(isset($this->objectFilters[$classLower]) + && is_array($this->objectFilters[$classLower]) + && in_array($plainName, $this->objectFilters[$classLower]))) { + + $return[$name] = $this->encodeObject($value, $objectDepth + 1, 1, $maxDepth + 1); + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + } + + array_pop($this->objectStack); + + } elseif (is_array($object)) { + + if ($arrayDepth > $this->options['maxArrayDepth']) { + return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **'; + } + + foreach ($object as $key => $val) { + + // Encoding the $GLOBALS PHP array causes an infinite loop + // if the recursion is not reset here as it contains + // a reference to itself. This is the only way I have come up + // with to stop infinite recursion in this case. + if ($key == 'GLOBALS' + && is_array($val) + && array_key_exists('GLOBALS', $val)) { + $val['GLOBALS'] = '** Recursion (GLOBALS) **'; + } + + if (!$this->is_utf8($key)) { + $key = utf8_encode($key); + } + + $return[$key] = $this->encodeObject($val, 1, $arrayDepth + 1, $maxDepth + 1); + } + } else { + if ($this->is_utf8($object)) { + return $object; + } else { + return utf8_encode($object); + } + } + return $return; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + protected function is_utf8($str) + { + if (function_exists('mb_detect_encoding')) { + return ( + mb_detect_encoding($str, 'UTF-8', true) == 'UTF-8' && + ($str === null || $this->jsonEncode($str, true) !== 'null') + ); + } + $c = 0; + $b = 0; + $bits = 0; + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $c = ord($str[$i]); + if ($c > 128) { + if (($c >= 254)) return false; + elseif ($c >= 252) $bits = 6; + elseif ($c >= 248) $bits = 5; + elseif ($c >= 240) $bits = 4; + elseif ($c >= 224) $bits = 3; + elseif ($c >= 192) $bits = 2; + else return false; + if (($i + $bits) > $len) return false; + while($bits > 1) { + $i++; + $b = ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bits--; + } + } + } + return ($str === null || $this->jsonEncode($str, true) !== 'null'); + } + + /** + * Converts to and from JSON format. + * + * JSON (JavaScript Object Notation) is a lightweight data-interchange + * format. It is easy for humans to read and write. It is easy for machines + * to parse and generate. It is based on a subset of the JavaScript + * Programming Language, Standard ECMA-262 3rd Edition - December 1999. + * This feature can also be found in Python. JSON is a text format that is + * completely language independent but uses conventions that are familiar + * to programmers of the C-family of languages, including C, C++, C#, Java, + * JavaScript, Perl, TCL, and many others. These properties make JSON an + * ideal data-interchange language. + * + * This package provides a simple encoder and decoder for JSON notation. It + * is intended for use with client-side Javascript applications that make + * use of HTTPRequest to perform server communication functions - data can + * be encoded into JSON notation for use in a client-side javascript, or + * decoded from incoming Javascript requests. JSON format is native to + * Javascript, and can be directly eval()'ed with no further parsing + * overhead + * + * All strings should be in ASCII or UTF-8 format! + * + * LICENSE: Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: Redistributions of source code must retain the + * above copyright notice, this list of conditions and the following + * disclaimer. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * @category + * @package Services_JSON + * @author Michal Migurski + * @author Matt Knapp + * @author Brett Stimmerman + * @author Christoph Dorn + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + + + /** + * Keep a list of objects as we descend into the array so we can detect recursion. + */ + private $json_objectStack = array(); + + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + private function json_utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch (strlen($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + private function json_encode($var) + { + if (is_object($var)) { + if (in_array($var, $this->json_objectStack)) { + return '"** Recursion **"'; + } + } + + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = strlen($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\' . $var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2})); + $c += 2; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + + return '"' . $ascii . '"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + + $this->json_objectStack[] = $var; + + $properties = array_map(array($this, 'json_name_value'), + array_keys($var), + array_values($var)); + + array_pop($this->json_objectStack); + + foreach ($properties as $property) { + if ($property instanceof Exception) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + } + + $this->json_objectStack[] = $var; + + // treat it like a regular array + $elements = array_map(array($this, 'json_encode'), $var); + + array_pop($this->json_objectStack); + + foreach ($elements as $element) { + if ($element instanceof Exception) { + return $element; + } + } + + return '[' . join(',', $elements) . ']'; + + case 'object': + $vars = self::encodeObject($var); + + $this->json_objectStack[] = $var; + + $properties = array_map(array($this, 'json_name_value'), + array_keys($vars), + array_values($vars)); + + array_pop($this->json_objectStack); + + foreach ($properties as $property) { + if ($property instanceof Exception) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + + default: + return null; + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + private function json_name_value($name, $value) + { + // Encoding the $GLOBALS PHP array causes an infinite loop + // if the recursion is not reset here as it contains + // a reference to itself. This is the only way I have come up + // with to stop infinite recursion in this case. + if ($name == 'GLOBALS' + && is_array($value) + && array_key_exists('GLOBALS', $value)) { + $value['GLOBALS'] = '** Recursion **'; + } + + $encodedValue = $this->json_encode($value); + + if ($encodedValue instanceof Exception) { + return $encodedValue; + } + + return $this->json_encode(strval($name)) . ':' . $encodedValue; + } + + /** + * @deprecated + */ + public function setProcessorUrl($URL) + { + trigger_error('The FirePHP::setProcessorUrl() method is no longer supported', E_USER_DEPRECATED); + } + + /** + * @deprecated + */ + public function setRendererUrl($URL) + { + trigger_error('The FirePHP::setRendererUrl() method is no longer supported', E_USER_DEPRECATED); + } +} \ No newline at end of file diff --git a/libs/FirePHPCore/FirePHP.class.php b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 similarity index 66% rename from libs/FirePHPCore/FirePHP.class.php rename to vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 index d8ae13f34..d702cea4a 100644 --- a/libs/FirePHPCore/FirePHP.class.php +++ b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 @@ -1,48 +1,124 @@ , Copyright 2007, New BSD License +// - qbbr, Michael Day , Copyright 2008, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + /** * *** BEGIN LICENSE BLOCK ***** * - * This file is part of FirePHP (http://www.firephp.org/). + * [MIT License](http://www.opensource.org/licenses/mit-license.php) * - * Software License Agreement (New BSD License) + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) * - * Copyright (c) 2006-2009, Christoph Dorn - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of Christoph Dorn nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. * * ***** END LICENSE BLOCK ***** * - * @copyright Copyright (C) 2007-2009 Christoph Dorn + * This verion of FirePHPCore is for use with PHP4. If you do not require PHP4 + * compatibility, it is suggested you use FirePHPCore.class.php instead. + * + * @copyright Copyright (C) 2007+ Christoph Dorn * @author Christoph Dorn - * @license http://www.opensource.org/licenses/bsd-license.php - * @package FirePHP + * @author Michael Day + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore */ +/** + * FirePHP version + * + * @var string + */ +define('FirePHP_VERSION', '0.3'); // @pinf replace '0.3' with '%%VERSION%%' + +/** + * Firebug LOG level + * + * Logs a message to firebug console + * + * @var string + */ +define('FirePHP_LOG', 'LOG'); + +/** + * Firebug INFO level + * + * Logs a message to firebug console and displays an info icon before the message + * + * @var string + */ +define('FirePHP_INFO', 'INFO'); + +/** + * Firebug WARN level + * + * Logs a message to firebug console, displays a warning icon before the message and colors the line turquoise + * + * @var string + */ +define('FirePHP_WARN', 'WARN'); + +/** + * Firebug ERROR level + * + * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. + * + * @var string + */ +define('FirePHP_ERROR', 'ERROR'); + +/** + * Dumps a variable to firebug's server panel + * + * @var string + */ +define('FirePHP_DUMP', 'DUMP'); + +/** + * Displays a stack trace in firebug console + * + * @var string + */ +define('FirePHP_TRACE', 'TRACE'); + +/** + * Displays a table in firebug console + * + * @var string + */ +define('FirePHP_TABLE', 'TABLE'); +/** + * Starts a group in firebug console + * + * @var string + */ +define('FirePHP_GROUP_START', 'GROUP_START'); + +/** + * Ends a group in firebug console + * + * @var string + */ +define('FirePHP_GROUP_END', 'GROUP_END'); + /** * Sends the given data to the FirePHP Firefox Extension. * The data can be displayed in the Firebug Console or in the @@ -50,217 +126,90 @@ * * For more information see: http://www.firephp.org/ * - * @copyright Copyright (C) 2007-2009 Christoph Dorn + * @copyright Copyright (C) 2007+ Christoph Dorn * @author Christoph Dorn - * @license http://www.opensource.org/licenses/bsd-license.php - * @package FirePHP + * @author Michael Day + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore */ class FirePHP { - - /** - * FirePHP version - * - * @var string - */ - const VERSION = '0.3'; - - /** - * Firebug LOG level - * - * Logs a message to firebug console. - * - * @var string - */ - const LOG = 'LOG'; - - /** - * Firebug INFO level - * - * Logs a message to firebug console and displays an info icon before the message. - * - * @var string - */ - const INFO = 'INFO'; - - /** - * Firebug WARN level - * - * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. - * - * @var string - */ - const WARN = 'WARN'; - - /** - * Firebug ERROR level - * - * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. - * - * @var string - */ - const ERROR = 'ERROR'; - - /** - * Dumps a variable to firebug's server panel - * - * @var string - */ - const DUMP = 'DUMP'; - - /** - * Displays a stack trace in firebug console - * - * @var string - */ - const TRACE = 'TRACE'; - - /** - * Displays an exception in firebug console - * - * Increments the firebug error count. - * - * @var string - */ - const EXCEPTION = 'EXCEPTION'; - - /** - * Displays an table in firebug console - * - * @var string - */ - const TABLE = 'TABLE'; - - /** - * Starts a group in firebug console - * - * @var string - */ - const GROUP_START = 'GROUP_START'; - - /** - * Ends a group in firebug console - * - * @var string - */ - const GROUP_END = 'GROUP_END'; - - /** - * Singleton instance of FirePHP - * - * @var FirePHP - */ - protected static $instance = null; - - /** - * Flag whether we are logging from within the exception handler - * - * @var boolean - */ - protected $inExceptionHandler = false; - - /** - * Flag whether to throw PHP errors that have been converted to ErrorExceptions - * - * @var boolean - */ - protected $throwErrorExceptions = true; - - /** - * Flag whether to convert PHP assertion errors to Exceptions - * - * @var boolean - */ - protected $convertAssertionErrorsToExceptions = true; - - /** - * Flag whether to throw PHP assertion errors that have been converted to Exceptions - * - * @var boolean - */ - protected $throwAssertionExceptions = false; - /** * Wildfire protocol message index * * @var int */ - protected $messageIndex = 1; + var $messageIndex = 1; /** * Options for the library * * @var array */ - protected $options = array('maxObjectDepth' => 10, - 'maxArrayDepth' => 20, - 'useNativeJsonEncode' => true, - 'includeLineNumbers' => true); + var $options = array('maxObjectDepth' => 5, + 'maxArrayDepth' => 5, + 'useNativeJsonEncode' => true, + 'includeLineNumbers' => true); /** * Filters used to exclude object members when encoding * * @var array */ - protected $objectFilters = array(); + var $objectFilters = array(); /** * A stack of objects used to detect recursion during object encoding * * @var object */ - protected $objectStack = array(); + var $objectStack = array(); /** * Flag to enable/disable logging * * @var boolean */ - protected $enabled = true; + var $enabled = true; /** * The object constructor */ - function __construct() { + function FirePHP() { } + /** * When the object gets serialized only include specific object members. * * @return array */ - public function __sleep() { + function __sleep() { return array('options','objectFilters','enabled'); } - + /** * Gets singleton instance of FirePHP * * @param boolean $AutoCreate * @return FirePHP */ - public static function getInstance($AutoCreate=false) { - if($AutoCreate===true && !self::$instance) { - self::init(); - } - return self::$instance; + function &getInstance($AutoCreate=false) { + global $FirePHP_Instance; + + if($AutoCreate===true && !$FirePHP_Instance) { + $FirePHP_Instance = new FirePHP(); + } + + return $FirePHP_Instance; } - - /** - * Creates FirePHP object and stores it for singleton access - * - * @return FirePHP - */ - public static function init() { - return self::$instance = new self(); - } - + /** * Enable and disable logging to Firebug * * @param boolean $Enabled TRUE to enable, FALSE to disable * @return void */ - public function setEnabled($Enabled) { + function setEnabled($Enabled) { $this->enabled = $Enabled; } @@ -269,7 +218,7 @@ class FirePHP { * * @return boolean TRUE if enabled */ - public function getEnabled() { + function getEnabled() { return $this->enabled; } @@ -282,7 +231,7 @@ class FirePHP { * @param array $Filter An array of members to exclude * @return void */ - public function setObjectFilter($Class, $Filter) { + function setObjectFilter($Class, $Filter) { $this->objectFilters[strtolower($Class)] = $Filter; } @@ -290,15 +239,15 @@ class FirePHP { * Set some options for the library * * Options: - * - maxObjectDepth: The maximum depth to traverse objects (default: 10) - * - maxArrayDepth: The maximum depth to traverse arrays (default: 20) + * - maxObjectDepth: The maximum depth to traverse objects (default: 5) + * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) * - useNativeJsonEncode: If true will use json_encode() (default: true) * - includeLineNumbers: If true will include line numbers and filenames (default: true) * * @param array $Options The options to be set * @return void */ - public function setOptions($Options) { + function setOptions($Options) { $this->options = array_merge($this->options,$Options); } @@ -307,33 +256,31 @@ class FirePHP { * * @return array The currently set options */ - public function getOptions() { + function getOptions() { return $this->options; } /** * Register FirePHP as your error handler * - * Will throw exceptions for each php error. - * + * Will use FirePHP to log each php error. + * * @return mixed Returns a string containing the previously defined error handler (if any) */ - public function registerErrorHandler($throwErrorExceptions=true) + function registerErrorHandler() { //NOTE: The following errors will not be caught by this error handler: // E_ERROR, E_PARSE, E_CORE_ERROR, // E_CORE_WARNING, E_COMPILE_ERROR, // E_COMPILE_WARNING, E_STRICT - $this->throwErrorExceptions = $throwErrorExceptions; - return set_error_handler(array($this,'errorHandler')); } /** * FirePHP's error handler * - * Throws exception for each php error that will occur. + * Logs each php error that will occur. * * @param int $errno * @param string $errstr @@ -341,71 +288,28 @@ class FirePHP { * @param int $errline * @param array $errcontext */ - public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) + function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { - // Don't throw exception if error reporting is switched off + global $FirePHP_Instance; + // Don't log error if error reporting is switched off if (error_reporting() == 0) { return; } - // Only throw exceptions for errors we are asking for + // Only log error for errors we are asking for if (error_reporting() & $errno) { - - $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); - if($this->throwErrorExceptions) { - throw $exception; - } else { - $this->fb($exception); - } + $FirePHP_Instance->group($errstr); + $FirePHP_Instance->error("{$errfile}, line $errline"); + $FirePHP_Instance->groupEnd(); } } - /** - * Register FirePHP as your exception handler - * - * @return mixed Returns the name of the previously defined exception handler, - * or NULL on error. - * If no previous handler was defined, NULL is also returned. - */ - public function registerExceptionHandler() - { - return set_exception_handler(array($this,'exceptionHandler')); - } - - /** - * FirePHP's exception handler - * - * Logs all exceptions to your firebug console and then stops the script. - * - * @param Exception $Exception - * @throws Exception - */ - function exceptionHandler($Exception) { - - $this->inExceptionHandler = true; - - header('HTTP/1.1 500 Internal Server Error'); - - $this->fb($Exception); - - $this->inExceptionHandler = false; - } - /** * Register FirePHP driver as your assert callback * - * @param boolean $convertAssertionErrorsToExceptions - * @param boolean $throwAssertionExceptions - * @return mixed Returns the original setting or FALSE on errors + * @return mixed Returns the original setting */ - public function registerAssertionHandler($convertAssertionErrorsToExceptions=true, $throwAssertionExceptions=false) + function registerAssertionHandler() { - $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; - $this->throwAssertionExceptions = $throwAssertionExceptions; - - if($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { - throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); - } - return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); } @@ -418,24 +322,9 @@ class FirePHP { * @param int $line Line source of assertion * @param mixed $code Assertion code */ - public function assertionHandler($file, $line, $code) + function assertionHandler($file, $line, $code) { - - if($this->convertAssertionErrorsToExceptions) { - - $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); - - if($this->throwAssertionExceptions) { - throw $exception; - } else { - $this->fb($exception); - } - - } else { - - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); - - } + $this->fb($code, 'Assertion Failed', FirePHP_ERROR, array('File'=>$file,'Line'=>$line)); } /** @@ -443,7 +332,7 @@ class FirePHP { * * @param string $URL */ - public function setProcessorUrl($URL) + function setProcessorUrl($URL) { $this->setHeader('X-FirePHP-ProcessorURL', $URL); } @@ -453,7 +342,7 @@ class FirePHP { * * @param string $URL */ - public function setRendererUrl($URL) + function setRendererUrl($URL) { $this->setHeader('X-FirePHP-RendererURL', $URL); } @@ -470,22 +359,22 @@ class FirePHP { * @return true * @throws Exception */ - public function group($Name, $Options=null) { + function group($Name, $Options=null) { if(!$Name) { - throw $this->newException('You must specify a label for the group!'); + trigger_error('You must specify a label for the group!'); } if($Options) { if(!is_array($Options)) { - throw $this->newException('Options must be defined as an array!'); + trigger_error('Options must be defined as an array!'); } if(array_key_exists('Collapsed', $Options)) { $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; } } - return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); + return $this->fb(null, $Name, FirePHP_GROUP_START, $Options); } /** @@ -494,8 +383,8 @@ class FirePHP { * @return true * @throws Exception */ - public function groupEnd() { - return $this->fb(null, null, FirePHP::GROUP_END); + function groupEnd() { + return $this->fb(null, null, FirePHP_GROUP_END); } /** @@ -507,8 +396,8 @@ class FirePHP { * @return true * @throws Exception */ - public function log($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP::LOG); + function log($Object, $Label=null) { + return $this->fb($Object, $Label, FirePHP_LOG); } /** @@ -520,8 +409,8 @@ class FirePHP { * @return true * @throws Exception */ - public function info($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP::INFO); + function info($Object, $Label=null) { + return $this->fb($Object, $Label, FirePHP_INFO); } /** @@ -533,8 +422,8 @@ class FirePHP { * @return true * @throws Exception */ - public function warn($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP::WARN); + function warn($Object, $Label=null) { + return $this->fb($Object, $Label, FirePHP_WARN); } /** @@ -546,8 +435,8 @@ class FirePHP { * @return true * @throws Exception */ - public function error($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP::ERROR); + function error($Object, $Label=null) { + return $this->fb($Object, $Label, FirePHP_ERROR); } /** @@ -559,8 +448,8 @@ class FirePHP { * @return true * @throws Exception */ - public function dump($Key, $Variable) { - return $this->fb($Variable, $Key, FirePHP::DUMP); + function dump($Key, $Variable) { + return $this->fb($Variable, $Key, FirePHP_DUMP); } /** @@ -571,8 +460,8 @@ class FirePHP { * @return true * @throws Exception */ - public function trace($Label) { - return $this->fb($Label, FirePHP::TRACE); + function trace($Label) { + return $this->fb($Label, FirePHP_TRACE); } /** @@ -584,8 +473,8 @@ class FirePHP { * @return true * @throws Exception */ - public function table($Label, $Table) { - return $this->fb($Table, $Label, FirePHP::TABLE); + function table($Label, $Table) { + return $this->fb($Table, $Label, FirePHP_TABLE); } /** @@ -593,13 +482,18 @@ class FirePHP { * * @return boolean */ - public function detectClientExtension() { - /* Check if FirePHP is installed on client */ - if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) || - !version_compare($m[1][0],'0.0.6','>=')) { - return false; + function detectClientExtension() { + // Check if FirePHP is installed on client via User-Agent header + if(@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && + version_compare($m[1][0],'0.0.6','>=')) { + return true; + } else + // Check if FirePHP is installed on client via X-FirePHP-Version header + if(@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && + version_compare($m[1][0],'0.0.6','>=')) { + return true; } - return true; + return false; } /** @@ -610,20 +504,14 @@ class FirePHP { * @return true Return TRUE if message was added to headers, FALSE otherwise * @throws Exception */ - public function fb($Object) { + function fb($Object) { if(!$this->enabled) { return false; } if (headers_sent($filename, $linenum)) { - // If we are logging from within the exception handler we cannot throw another exception - if($this->inExceptionHandler) { - // Simply echo the error out to the page - echo '
FirePHP ERROR: Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.
'; - } else { - throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); - } + trigger_error('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); } $Type = null; @@ -634,16 +522,15 @@ class FirePHP { } else if(func_num_args()==2) { switch(func_get_arg(1)) { - case self::LOG: - case self::INFO: - case self::WARN: - case self::ERROR: - case self::DUMP: - case self::TRACE: - case self::EXCEPTION: - case self::TABLE: - case self::GROUP_START: - case self::GROUP_END: + case FirePHP_LOG: + case FirePHP_INFO: + case FirePHP_WARN: + case FirePHP_ERROR: + case FirePHP_DUMP: + case FirePHP_TRACE: + case FirePHP_TABLE: + case FirePHP_GROUP_START: + case FirePHP_GROUP_END: $Type = func_get_arg(1); break; default: @@ -660,7 +547,7 @@ class FirePHP { $Label = func_get_arg(1); $Options = func_get_arg(3); } else { - throw $this->newException('Wrong number of arguments to fb() function!'); + trigger_error('Wrong number of arguments to fb() function!'); } @@ -671,51 +558,7 @@ class FirePHP { $meta = array(); $skipFinalObjectEncode = false; - if($Object instanceof Exception) { - - $meta['file'] = $this->_escapeTraceFile($Object->getFile()); - $meta['line'] = $Object->getLine(); - - $trace = $Object->getTrace(); - if($Object instanceof ErrorException - && isset($trace[0]['function']) - && $trace[0]['function']=='errorHandler' - && isset($trace[0]['class']) - && $trace[0]['class']=='FirePHP') { - - $severity = false; - switch($Object->getSeverity()) { - case E_WARNING: $severity = 'E_WARNING'; break; - case E_NOTICE: $severity = 'E_NOTICE'; break; - case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; - case E_USER_WARNING: $severity = 'E_USER_WARNING'; break; - case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break; - case E_STRICT: $severity = 'E_STRICT'; break; - case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break; - case E_DEPRECATED: $severity = 'E_DEPRECATED'; break; - case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break; - } - - $Object = array('Class'=>get_class($Object), - 'Message'=>$severity.': '.$Object->getMessage(), - 'File'=>$this->_escapeTraceFile($Object->getFile()), - 'Line'=>$Object->getLine(), - 'Type'=>'trigger', - 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); - $skipFinalObjectEncode = true; - } else { - $Object = array('Class'=>get_class($Object), - 'Message'=>$Object->getMessage(), - 'File'=>$this->_escapeTraceFile($Object->getFile()), - 'Line'=>$Object->getLine(), - 'Type'=>'throw', - 'Trace'=>$this->_escapeTrace($trace)); - $skipFinalObjectEncode = true; - } - $Type = self::EXCEPTION; - - } else - if($Type==self::TRACE) { + if($Type==FirePHP_TRACE) { $trace = debug_backtrace(); if(!$trace) return false; @@ -755,7 +598,7 @@ class FirePHP { } } else - if($Type==self::TABLE) { + if($Type==FirePHP_TABLE) { if(isset($Object[0]) && is_string($Object[0])) { $Object[1] = $this->encodeTable($Object[1]); @@ -766,15 +609,14 @@ class FirePHP { $skipFinalObjectEncode = true; } else - if($Type==self::GROUP_START) { + if($Type==FirePHP_GROUP_START) { if(!$Label) { - throw $this->newException('You must specify a label for the group!'); + trigger_error('You must specify a label for the group!'); } - } else { if($Type===null) { - $Type = self::LOG; + $Type = FirePHP_LOG; } } @@ -815,17 +657,17 @@ class FirePHP { } $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); - $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); + $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.FirePHP_VERSION); $structure_index = 1; - if($Type==self::DUMP) { + if($Type==FirePHP_DUMP) { $structure_index = 2; $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); } else { $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); } - if($Type==self::DUMP) { + if($Type==FirePHP_DUMP) { $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; } else { $msg_meta = $Options; @@ -863,7 +705,7 @@ class FirePHP { $this->messageIndex++; if ($this->messageIndex > 99999) { - throw $this->newException('Maximum number (99,999) of messages reached!'); + trigger_error('Maximum number (99,999) of messages reached!'); } } } @@ -873,13 +715,14 @@ class FirePHP { return true; } + /** * Standardizes path for windows systems. * * @param string $Path * @return string */ - protected function _standardizePath($Path) { + function _standardizePath($Path) { return preg_replace('/\\\\+/','/',$Path); } @@ -889,7 +732,7 @@ class FirePHP { * @param array $Trace * @return array */ - protected function _escapeTrace($Trace) { + function _escapeTrace($Trace) { if(!$Trace) return $Trace; for( $i=0 ; $i $value ) { + $headers[strtolower($name)] = $value; + } + } else { + foreach($_SERVER as $name => $value) { + if(substr($name, 0, 5) == 'HTTP_') { + $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; + } + } + } + return $headers; + } + + /** + * Get a request header + * + * @return string|false + */ + function getRequestHeader($Name) + { + $headers = $this->getAllRequestHeaders(); + if (isset($headers[strtolower($Name)])) { + return $headers[strtolower($Name)]; + } + return false; + } /** * Encode an object into a JSON string @@ -958,7 +826,7 @@ class FirePHP { * @param object $Object The object to be encoded * @return string The JSON string */ - public function jsonEncode($Object, $skipObjectEncode=false) + function jsonEncode($Object, $skipObjectEncode=false) { if(!$skipObjectEncode) { $Object = $this->encodeObject($Object); @@ -972,14 +840,14 @@ class FirePHP { return $this->json_encode($Object); } } - + /** * Encodes a table by encoding each row and column with encodeObject() * * @param array $Table The table to be encoded * @return array */ - protected function encodeTable($Table) { + function encodeTable($Table) { if(!$Table) return $Table; @@ -999,16 +867,15 @@ class FirePHP { return $new_table; } - + /** - * Encodes an object including members with - * protected and private visibility + * Encodes an object * * @param Object $Object The object to be encoded * @param int $Depth The current traversal depth * @return array All members of the object */ - protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) + function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) { $return = array(); @@ -1033,57 +900,8 @@ class FirePHP { $return['__className'] = $class = get_class($Object); $class_lower = strtolower($class); - $reflectionClass = new ReflectionClass($class); - $properties = array(); - foreach( $reflectionClass->getProperties() as $property) { - $properties[$property->getName()] = $property; - } - $members = (array)$Object; - foreach( $properties as $raw_name => $property ) { - - $name = $raw_name; - if($property->isStatic()) { - $name = 'static:'.$name; - } - if($property->isPublic()) { - $name = 'public:'.$name; - } else - if($property->isPrivate()) { - $name = 'private:'.$name; - $raw_name = "\0".$class."\0".$raw_name; - } else - if($property->isProtected()) { - $name = 'protected:'.$name; - $raw_name = "\0".'*'."\0".$raw_name; - } - - if(!(isset($this->objectFilters[$class_lower]) - && is_array($this->objectFilters[$class_lower]) - && in_array($raw_name,$this->objectFilters[$class_lower]))) { - - if(array_key_exists($raw_name,$members) - && !$property->isStatic()) { - - $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1); - - } else { - if(method_exists($property,'setAccessible')) { - $property->setAccessible(true); - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); - } else - if($property->isPublic()) { - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); - } else { - $return[$name] = '** Need PHP 5.3 to get value **'; - } - } - } else { - $return[$name] = '** Excluded by Filter **'; - } - } - // Include all members that are not defined in the class // but exist in the object foreach( $members as $raw_name => $value ) { @@ -1132,13 +950,14 @@ class FirePHP { $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); } } else { - if(self::is_utf8($Object)) { + if($this->is_utf8($Object)) { return $Object; } else { return utf8_encode($Object); } } return $return; + } /** @@ -1147,7 +966,7 @@ class FirePHP { * @param mixed $str String to be tested * @return boolean */ - protected static function is_utf8($str) { + function is_utf8($str) { $c=0; $b=0; $bits=0; $len=strlen($str); @@ -1233,7 +1052,7 @@ class FirePHP { /** * Keep a list of objects as we descend into the array so we can detect recursion. */ - private $json_objectStack = array(); + var $json_objectStack = array(); /** @@ -1247,7 +1066,7 @@ class FirePHP { * @return string UTF-16 character * @access private */ - private function json_utf82utf16($utf8) + function json_utf82utf16($utf8) { // oh please oh please oh please oh please oh please if(function_exists('mb_convert_encoding')) { @@ -1291,7 +1110,7 @@ class FirePHP { * @return mixed JSON string representation of input var or an error if a problem occurs * @access public */ - private function json_encode($var) + function json_encode($var) { if(is_object($var)) { @@ -1449,12 +1268,6 @@ class FirePHP { array_pop($this->json_objectStack); - foreach($properties as $property) { - if($property instanceof Exception) { - return $property; - } - } - return '{' . join(',', $properties) . '}'; } @@ -1465,16 +1278,10 @@ class FirePHP { array_pop($this->json_objectStack); - foreach($elements as $element) { - if($element instanceof Exception) { - return $element; - } - } - return '[' . join(',', $elements) . ']'; case 'object': - $vars = self::encodeObject($var); + $vars = FirePHP::encodeObject($var); $this->json_objectStack[] = $var; @@ -1484,12 +1291,6 @@ class FirePHP { array_pop($this->json_objectStack); - foreach($properties as $property) { - if($property instanceof Exception) { - return $property; - } - } - return '{' . join(',', $properties) . '}'; default: @@ -1506,7 +1307,7 @@ class FirePHP { * @return string JSON-formatted name-value pair, like '"name":value' * @access private */ - private function json_name_value($name, $value) + function json_name_value($name, $value) { // Encoding the $GLOBALS PHP array causes an infinite loop // if the recursion is not reset here as it contains @@ -1520,10 +1321,7 @@ class FirePHP { $encoded_value = $this->json_encode($value); - if($encoded_value instanceof Exception) { - return $encoded_value; - } - return $this->json_encode(strval($name)) . ':' . $encoded_value; } } + diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php new file mode 100644 index 000000000..8827ba15d --- /dev/null +++ b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php @@ -0,0 +1,275 @@ +, Copyright 2007, New BSD License +// - qbbr, Sokolov Innokenty , Copyright 2011, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/** + * ***** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ + +if (!class_exists('FirePHP', false)) { + require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php'; +} + +/** + * Sends the given data to the FirePHP Firefox Extension. + * The data can be displayed in the Firebug Console or in the + * "Server" request tab. + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $Object + * @return true + * @throws Exception + */ +function fb() +{ + $instance = FirePHP::getInstance(true); + + $args = func_get_args(); + return call_user_func_array(array($instance, 'fb'), $args); +} + + +class FB +{ + /** + * Set an Insight console to direct all logging calls to + * + * @param object $console The console object to log to + * @return void + */ + public static function setLogToInsightConsole($console) + { + FirePHP::getInstance(true)->setLogToInsightConsole($console); + } + + /** + * Enable and disable logging to Firebug + * + * @see FirePHP->setEnabled() + * @param boolean $enabled TRUE to enable, FALSE to disable + * @return void + */ + public static function setEnabled($enabled) + { + FirePHP::getInstance(true)->setEnabled($enabled); + } + + /** + * Check if logging is enabled + * + * @see FirePHP->getEnabled() + * @return boolean TRUE if enabled + */ + public static function getEnabled() + { + return FirePHP::getInstance(true)->getEnabled(); + } + + /** + * Specify a filter to be used when encoding an object + * + * Filters are used to exclude object members. + * + * @see FirePHP->setObjectFilter() + * @param string $class The class name of the object + * @param array $filter An array or members to exclude + * @return void + */ + public static function setObjectFilter($class, $filter) + { + FirePHP::getInstance(true)->setObjectFilter($class, $filter); + } + + /** + * Set some options for the library + * + * @see FirePHP->setOptions() + * @param array $options The options to be set + * @return void + */ + public static function setOptions($options) + { + FirePHP::getInstance(true)->setOptions($options); + } + + /** + * Get options for the library + * + * @see FirePHP->getOptions() + * @return array The options + */ + public static function getOptions() + { + return FirePHP::getInstance(true)->getOptions(); + } + + /** + * Log object to firebug + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $object + * @return true + * @throws Exception + */ + public static function send() + { + $args = func_get_args(); + return call_user_func_array(array(FirePHP::getInstance(true), 'fb'), $args); + } + + /** + * Start a group for following messages + * + * Options: + * Collapsed: [true|false] + * Color: [#RRGGBB|ColorName] + * + * @param string $name + * @param array $options OPTIONAL Instructions on how to log the group + * @return true + */ + public static function group($name, $options=null) + { + return FirePHP::getInstance(true)->group($name, $options); + } + + /** + * Ends a group you have started before + * + * @return true + * @throws Exception + */ + public static function groupEnd() + { + return self::send(null, null, FirePHP::GROUP_END); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::LOG + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public static function log($object, $label=null) + { + return self::send($object, $label, FirePHP::LOG); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::INFO + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public static function info($object, $label=null) + { + return self::send($object, $label, FirePHP::INFO); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::WARN + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public static function warn($object, $label=null) + { + return self::send($object, $label, FirePHP::WARN); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::ERROR + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public static function error($object, $label=null) + { + return self::send($object, $label, FirePHP::ERROR); + } + + /** + * Dumps key and variable to firebug server panel + * + * @see FirePHP::DUMP + * @param string $key + * @param mixed $variable + * @return true + * @throws Exception + */ + public static function dump($key, $variable) + { + return self::send($variable, $key, FirePHP::DUMP); + } + + /** + * Log a trace in the firebug console + * + * @see FirePHP::TRACE + * @param string $label + * @return true + * @throws Exception + */ + public static function trace($label) + { + return self::send($label, FirePHP::TRACE); + } + + /** + * Log a table in the firebug console + * + * @see FirePHP::TABLE + * @param string $label + * @param string $table + * @return true + * @throws Exception + */ + public static function table($label, $table) + { + return self::send($table, $label, FirePHP::TABLE); + } + +} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 new file mode 100644 index 000000000..eab2f0f68 --- /dev/null +++ b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 @@ -0,0 +1,245 @@ +, Copyright 2007, New BSD License +// - qbbr, Michael Day , Copyright 2008, New BSD License +// - cadorn, Christoph Dorn , Copyright 2011, MIT License + +/* ***** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ***** END LICENSE BLOCK ***** + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn + * @author Michael Day + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ + +require_once dirname(__FILE__).'/FirePHP.class.php4'; + +/** + * Sends the given data to the FirePHP Firefox Extension. + * The data can be displayed in the Firebug Console or in the + * "Server" request tab. + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $Object + * @return true + * @throws Exception + */ +function fb() +{ + $instance =& FirePHP::getInstance(true); + + $args = func_get_args(); + return call_user_func_array(array(&$instance,'fb'),$args); +} + + +class FB +{ + /** + * Enable and disable logging to Firebug + * + * @see FirePHP->setEnabled() + * @param boolean $Enabled TRUE to enable, FALSE to disable + * @return void + */ + function setEnabled($Enabled) { + $instance =& FirePHP::getInstance(true); + $instance->setEnabled($Enabled); + } + + /** + * Check if logging is enabled + * + * @see FirePHP->getEnabled() + * @return boolean TRUE if enabled + */ + function getEnabled() { + $instance =& FirePHP::getInstance(true); + return $instance->getEnabled(); + } + + /** + * Specify a filter to be used when encoding an object + * + * Filters are used to exclude object members. + * + * @see FirePHP->setObjectFilter() + * @param string $Class The class name of the object + * @param array $Filter An array or members to exclude + * @return void + */ + function setObjectFilter($Class, $Filter) { + $instance =& FirePHP::getInstance(true); + $instance->setObjectFilter($Class, $Filter); + } + + /** + * Set some options for the library + * + * @see FirePHP->setOptions() + * @param array $Options The options to be set + * @return void + */ + function setOptions($Options) { + $instance =& FirePHP::getInstance(true); + $instance->setOptions($Options); + } + + /** + * Get options for the library + * + * @see FirePHP->getOptions() + * @return array The options + */ + function getOptions() { + $instance =& FirePHP::getInstance(true); + return $instance->getOptions(); + } + + /** + * Log object to firebug + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $Object + * @return true + */ + function send() + { + $instance =& FirePHP::getInstance(true); + $args = func_get_args(); + return call_user_func_array(array(&$instance,'fb'),$args); + } + + /** + * Start a group for following messages + * + * Options: + * Collapsed: [true|false] + * Color: [#RRGGBB|ColorName] + * + * @param string $Name + * @param array $Options OPTIONAL Instructions on how to log the group + * @return true + */ + function group($Name, $Options=null) { + $instance =& FirePHP::getInstance(true); + return $instance->group($Name, $Options); + } + + /** + * Ends a group you have started before + * + * @return true + */ + function groupEnd() { + return FB::send(null, null, FirePHP_GROUP_END); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::LOG + * @param mixes $Object + * @param string $Label + * @return true + */ + function log($Object, $Label=null) { + return FB::send($Object, $Label, FirePHP_LOG); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::INFO + * @param mixes $Object + * @param string $Label + * @return true + */ + function info($Object, $Label=null) { + return FB::send($Object, $Label, FirePHP_INFO); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::WARN + * @param mixes $Object + * @param string $Label + * @return true + */ + function warn($Object, $Label=null) { + return FB::send($Object, $Label, FirePHP_WARN); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::ERROR + * @param mixes $Object + * @param string $Label + * @return true + */ + function error($Object, $Label=null) { + return FB::send($Object, $Label, FirePHP_ERROR); + } + + /** + * Dumps key and variable to firebug server panel + * + * @see FirePHP::DUMP + * @param string $Key + * @param mixed $Variable + * @return true + */ + function dump($Key, $Variable) { + return FB::send($Variable, $Key, FirePHP_DUMP); + } + + /** + * Log a trace in the firebug console + * + * @see FirePHP::TRACE + * @param string $Label + * @return true + */ + function trace($Label) { + return FB::send($Label, FirePHP_TRACE); + } + + /** + * Log a table in the firebug console + * + * @see FirePHP::TABLE + * @param string $Label + * @param string $Table + * @return true + */ + function table($Label, $Table) { + return FB::send($Table, $Label, FirePHP_TABLE); + } +} diff --git a/vendor/firephp/firephp-core/package.json b/vendor/firephp/firephp-core/package.json new file mode 100644 index 000000000..291a92022 --- /dev/null +++ b/vendor/firephp/firephp-core/package.json @@ -0,0 +1,43 @@ +{ + "uid": "https://github.com/firephp/firephp-core/", + "name": "firephp-core", + "version": "0.4.0", + "label": "FirePHP Server Library", + "repositories": [ + { + "type": "git", + "url": "git://github.com/firephp/firephp-core.git" + } + ], + "maintainers": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "web": "http://www.christophdorn.com/", + "alias": { + "github": "cadorn" + } + } + ], + "contributors": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "web": "http://www.christophdorn.com/", + "alias": { + "github": "cadorn" + } + }, + { + "name": "Michael Day", + "email": "manveru.alma@gmail.com" + }, + { + "name": "Sokolov Innokenty", + "email": "sokolov.innokenty@gmail.com", + "alias": { + "github": "qbbr" + } + } + ] +} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/program.json b/vendor/firephp/firephp-core/program.json new file mode 100644 index 000000000..9889e97a3 --- /dev/null +++ b/vendor/firephp/firephp-core/program.json @@ -0,0 +1,5 @@ +{ + "extends": { + "location": "./workspace/program.json" + } +} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/tests/API/newlines.php b/vendor/firephp/firephp-core/tests/API/newlines.php new file mode 100644 index 000000000..1e5511e54 --- /dev/null +++ b/vendor/firephp/firephp-core/tests/API/newlines.php @@ -0,0 +1,12 @@ +dump("key", "value"); + $headers = $firephp->_getHeaders(); + $this->assertEquals('15|{"key":"value"}|', $headers['X-Wf-1-2-1-1']); + $firephp->_clearHeaders(); + + $caught = false; + try { + $firephp->dump(array(), "value"); + } catch(Exception $e) { + // Key passed to dump() is not a string + $caught = true; + } + if(!$caught) $this->fail('No exception thrown'); + + $caught = false; + try { + $firephp->dump("key \n\r value", "value"); + } catch(Exception $e) { + // Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:] + $caught = true; + } + if(!$caught) $this->fail('No exception thrown'); + + $caught = false; + try { + $firephp->dump("keykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeyk1", "value"); + } catch(Exception $e) { + // Key passed to dump() is longer than 100 characters + $caught = true; + } + if(!$caught) $this->fail('No exception thrown'); + } + + /** + * @issue http://code.google.com/p/firephp/issues/detail?id=123 + */ + public function testRegisterErrorHandler() + { + $firephp = new FirePHP_Test_Class(); + $firephp->setOption("maxObjectDepth", 1); + $firephp->setOption("maxArrayDepth", 1); + + $firephp->registerErrorHandler(); + trigger_error("Hello World"); + $headers = $firephp->_getHeaders(); + if(!isset($headers["X-Wf-1-1-1-1"])) { + $this->fail("Error not in headers"); + } + } + + /** + * @issue http://code.google.com/p/firephp/issues/detail?id=122 + */ + public function testFirePHPClassInstanceLogging() + { + $firephp = new FirePHP_Test_Class(); + + $firephp->log($firephp); + $headers = $firephp->_getHeaders(); + if(!preg_match_all('/"protected:objectStack":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { + $this->fail("objectStack member contains value"); + } + if(!preg_match_all('/"protected:static:instance":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { + $this->fail("instance member should not be logged"); + } + if(!preg_match_all('/"undeclared:json_objectStack":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { + $this->fail("json_objectStack member should not be logged"); + } + } + + /** + * @issue http://code.google.com/p/firephp/issues/detail?id=114 + */ + public function testCustomFileLineOptions() + { + $firephp = new FirePHP_Test_Class(); + + $firephp->log("message", "label", array("File"=>"/file/path", "Line"=>"1")); + $firephp->info("message", "label", array("File"=>"/file/path", "Line"=>"1")); + $firephp->warn("message", "label", array("File"=>"/file/path", "Line"=>"1")); + $firephp->error("message", "label", array("File"=>"/file/path", "Line"=>"1")); + $firephp->dump("key", "value", array("File"=>"/file/path", "Line"=>"1")); + $firephp->table("label", array(array("header"),array("cell")), array("File"=>"/file/path", "Line"=>"1")); + + $headers = $firephp->_getHeaders(); + + $this->assertEquals('75|[{"File":"\/file\/path","Line":"1","Type":"LOG","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-1']); + $this->assertEquals('76|[{"File":"\/file\/path","Line":"1","Type":"INFO","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-2']); + $this->assertEquals('76|[{"File":"\/file\/path","Line":"1","Type":"WARN","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-3']); + $this->assertEquals('77|[{"File":"\/file\/path","Line":"1","Type":"ERROR","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-4']); + $this->assertEquals('15|{"key":"value"}|', $headers['X-Wf-1-2-1-5']); + $this->assertEquals('89|[{"File":"\/file\/path","Line":"1","Type":"TABLE","Label":"label"},[["header"],["cell"]]]|', $headers['X-Wf-1-1-1-6']); + } + + public function testRecursiveEncode() + { + $firephp = new FirePHP_Test_Class(); + + $obj = new FirePHPCore_FirePHPTest__TestObject(); + $obj->child = $obj; + + $firephp->log($obj, "label", array("File"=>"/file/path", "Line"=>"1")); + $headers = $firephp->_getHeaders(); + $this->assertEquals('215|[{"File":"\/file\/path","Line":"1","Type":"LOG","Label":"label"},{"__className":"FirePHPCore_FirePHPTest__TestObject","public:var":"value","undeclared:child":"** Recursion (FirePHPCore_FirePHPTest__TestObject) **"}]|', $headers['X-Wf-1-1-1-1']); + } + + public function testOptions() + { + $firephp = new FirePHP_Test_Class(); + + // defaults + $this->assertEquals(5, $firephp->getOption("maxObjectDepth")); + $this->assertEquals(5, $firephp->getOption("maxArrayDepth")); + $this->assertEquals(true, $firephp->getOption("useNativeJsonEncode")); + $this->assertEquals(true, $firephp->getOption("includeLineNumbers")); + + // modify + $firephp->setOption("maxObjectDepth", 1); + $this->assertEquals(1, $firephp->getOption("maxObjectDepth")); + + // invalid + $caught = false; + try { + $firephp->setOption("invalidName", 1); + } catch(Exception $e) { + $caught = true; + } + if(!$caught) $this->fail('No exception thrown'); + + $caught = false; + try { + $firephp->getOption("invalidName"); + } catch(Exception $e) { + $caught = true; + } + if(!$caught) $this->fail('No exception thrown'); + } + + public function testDeprecatedMethods() + { + $firephp = new FirePHP_Test_Class(); + + $caught = false; + try { + $firephp->setProcessorUrl('URL'); + } catch(Exception $e) { + $caught = true; + $this->assertEquals(E_USER_DEPRECATED, $e->getCode()); + $this->assertEquals('The FirePHP::setProcessorUrl() method is no longer supported', $e->getMessage()); + } + if(!$caught) $this->fail('No deprecation error thrown'); + + $caught = false; + try { + $firephp->setRendererUrl('URL'); + } catch(Exception $e) { + $caught = true; + $this->assertEquals(E_USER_DEPRECATED, $e->getCode()); + $this->assertEquals('The FirePHP::setRendererUrl() method is no longer supported', $e->getMessage()); + } + if(!$caught) $this->fail('No deprecation error thrown'); + } + +} + + +class FirePHPCore_FirePHPTest__TestObject +{ + public $var = "value"; +} diff --git a/vendor/firephp/firephp-core/tests/TestHelper.php b/vendor/firephp/firephp-core/tests/TestHelper.php new file mode 100644 index 000000000..bb65e7320 --- /dev/null +++ b/vendor/firephp/firephp-core/tests/TestHelper.php @@ -0,0 +1,55 @@ +_headers; + } + public function _clearHeaders() { + $this->_headers = array(); + } + + + // ###################### + // # Subclassed Methods # + // ###################### + + protected function setHeader($Name, $Value) { + $this->_headers[$Name] = $Value; + } + + protected function headersSent(&$Filename, &$Linenum) { + return false; + } + + public function detectClientExtension() { + return true; + } + +} diff --git a/vendor/firephp/firephp-core/tests/phpunit.xml b/vendor/firephp/firephp-core/tests/phpunit.xml new file mode 100644 index 000000000..b0474e9d6 --- /dev/null +++ b/vendor/firephp/firephp-core/tests/phpunit.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/README.md b/vendor/firephp/firephp-core/workspace/README.md new file mode 100644 index 000000000..999f09a94 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/README.md @@ -0,0 +1,19 @@ + +The [PINF JavaScript Loader](https://github.com/pinf/loader-js) is used to provide a development environment and package releases for this project. + +**NOTE:** It is assumed you have the _PINF JavaScript Loader_ mapped to the `commonjs` command and are using the `node` platform by default as explained [here](https://github.com/pinf/loader-js/blob/master/docs/Setup.md). + + +Publishing +========== + + git tag v... + + commonjs -v --script build . + + commonjs -v --script publish . + + +TODO: Auto-upload to PEAR channel server at http://pear.firephp.org/ + +NOTE: For PEAR RC releases: Change release stability to "beta" and capitalize "RC" in release version in package.xml diff --git a/vendor/firephp/firephp-core/workspace/lib/project.js b/vendor/firephp/firephp-core/workspace/lib/project.js new file mode 100644 index 000000000..913c6d7c6 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/lib/project.js @@ -0,0 +1,5 @@ + +exports.main = function(options) +{ + +} diff --git a/vendor/firephp/firephp-core/workspace/package.json b/vendor/firephp/firephp-core/workspace/package.json new file mode 100644 index 000000000..19e8385ee --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/package.json @@ -0,0 +1,28 @@ +{ + "name": "firephp-core", + "engine": [ + "node" + ], + "main": "lib/project.js", + "scripts": { + "build": { + "location": "./", + "module": "/scripts/build.js" + }, + "publish": { + "location": "./", + "module": "/scripts/publish.js" + } + }, + "mappings": { + "nodejs": { + "id": "nodejs.org/" + }, + "pinf": { + "id": "pinf.org/loader/" + }, + "modules": { + "id": "github.com/pinf/modules-js/" + } + } +} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/program.json b/vendor/firephp/firephp-core/workspace/program.json new file mode 100644 index 000000000..9628b525c --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/program.json @@ -0,0 +1,78 @@ +{ + "boot": "workspace", + "engine": [ + "node" + ], + "packages": { + "workspace": { + "locator": { + "location": "./" + } + }, + "nodejs.org/": { + "provider": "nodejs.org/" + }, + "pinf.org/loader/": { + "provider": "pinf.org/loader/" + }, + "github.com/pinf/modules-js/": { + "locator": { + "archive": "https://github.com/pinf/modules-js/zipball/master" + } + }, + "github.com/kriskowal/q/": { + "locator": { + "archive": "https://github.com/kriskowal/q/zipball/v0.3.0" + }, + "descriptor": { + "uid": "https://github.com/kriskowal/q/", + "dependencies": [ + { + "id": "github.com/pinf/modules-js/" + } + ] + } + }, + "private-registry.appspot.com/cadorn.com/github/com.cadorn.baby/projects/sourcemint/packages/client-js/": { + "locator": { + "archive": "https://github.com/cadorn/com.cadorn.baby/zipball/master", + "path": "projects/sourcemint/packages/client-js" + } + }, + "github.com/cadorn/aws-lib/": { + "locator": { + "archive": "https://github.com/cadorn/aws-lib/zipball/master" + }, + "descriptor": { + "uid": "https://github.com/cadorn/aws-lib/", + "native": true, + "dependencies": [ + { + "id": "registry.npmjs.org/sax/" + }, + { + "id": "registry.npmjs.org/xml2js/" + } + ] + } + }, + "registry.npmjs.org/sax/": { + "locator": { + "archive": "http://registry.npmjs.org/sax/-/sax-0.1.2.tgz" + }, + "descriptor": { + "uid": "http://registry.npmjs.org/sax/", + "native": true + } + }, + "registry.npmjs.org/xml2js/": { + "locator": { + "archive": "http://registry.npmjs.org/xml2js/-/xml2js-0.1.6.tgz" + }, + "descriptor": { + "uid": "http://registry.npmjs.org/xml2js/", + "native": true + } + } + } +} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/scripts/build.js b/vendor/firephp/firephp-core/workspace/scripts/build.js new file mode 100644 index 000000000..2481d99d3 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/scripts/build.js @@ -0,0 +1,164 @@ + +var FILE = require("modules/file"), + Q = require("modules/q"), + SYSTEM = require("modules/system"), + UTIL = require("modules/util"), + JSON = require("modules/json"); + + +var pkgPath = FILE.dirname(FILE.dirname(FILE.dirname(module.id))), + buildPath = pkgPath + "/build", + tplPath = pkgPath + "/workspace/tpl", + version = false; + +exports.getBuildPath = function() +{ + return buildPath; +} + +exports.main = function() +{ + + SYSTEM.exec("rm -Rf " + buildPath, function() + { + FILE.mkdirs(buildPath, 0775); + + SYSTEM.exec("git tag", function(stdout) + { + version = UTIL.trim(stdout).split("\n").pop().match(/^v(.*)$/)[1]; + + // TODO: Compare against version in `../../program.json ~ version` (ensure =) + + module.print("\0cyan(Building version: " + version + "\0)\n"); + + buildZipArchive(function() + { + buildPEARArchive(function() + { + done(); + }); + }); + }); + }); + + function done() + { + module.print("\0green(Done\0)\n"); + } +} + +function buildZipArchive(callback) +{ + var targetBasePath = buildPath + "/FirePHPCore-" + version; + + FILE.mkdirs(targetBasePath, 0775); + + SYSTEM.exec("rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" --exclude \"- .tmp_*\" " + pkgPath + "/lib " + targetBasePath, function() + { + replaceVariablesInFile(targetBasePath + "/lib/FirePHPCore/FirePHP.class.php"); + replaceVariablesInFile(targetBasePath + "/lib/FirePHPCore/FirePHP.class.php4"); + + SYSTEM.exec("cp -Rf " + pkgPath + "/examples " + targetBasePath, function() + { + next1(); + }); + }); + + function next1() + { + var content = FILE.read(tplPath + "/readme.tpl.md"); + content = content.replace(/%%VERSION%%/g, version); + FILE.write(targetBasePath + "/README.md", content); + + var content = FILE.read(tplPath + "/license.tpl.md"); + FILE.write(targetBasePath + "/LICENSE.md", content); + + FILE.write(buildPath + "/info.json", JSON.encode({ + version: version + })); + + next2(); + } + + function next2() + { + SYSTEM.exec("cd " + buildPath + " ; zip -vr FirePHPCore-" + version + ".zip FirePHPCore-" + version, function(stdout) + { + console.log(stdout); + + callback(); + }); + } +} + +function buildPEARArchive(callback) +{ + var targetBasePath = buildPath + "/pear"; + + FILE.mkdirs(targetBasePath, 0775); + + SYSTEM.exec("rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" --exclude \"- .tmp_*\" " + pkgPath + "/lib/FirePHPCore/* " + targetBasePath, function() + { + replaceVariablesInFile(targetBasePath + "/FirePHP.class.php"); + replaceVariablesInFile(targetBasePath + "/FirePHP.class.php4"); + + next1(); + }); + + function next1() + { + var content = FILE.read(tplPath + "/pear.package.tpl.xml"); + + var date = new Date(); + content = content.replace(/%%DATE%%/g, date.getFullYear() + "-" + UTIL.padBegin(date.getMonth()+1, 2, "0") + "-" + date.getDate()); + content = content.replace(/%%VERSION%%/g, version); + content = content.replace(/%%STABILITY%%/g, "stable"); + + FILE.write(targetBasePath + "/package.xml", content); + + next2(); + } + + function next2() + { + SYSTEM.exec("pear channel-discover pear.firephp.org", function(stdout) + { + console.log(stdout); + + SYSTEM.exec("cd " + targetBasePath + "; pear package package.xml", function(stdout) + { + console.log(stdout); + + callback(); + }); + }); + } +} + +function replaceVariablesInFile(path) +{ + var content = FILE.read(path); + + // @pinf replace '0.3' with '%%VERSION%%' + var re1 = /\n(.*)\/\/\s*@pinf\s(.*)\n/g; + var match1; + while (match1 = re1.exec(content)) { + var rule = match1[2].match(/^replace (.*?) with (.*)$/); + if(rule) { + // replace variables in rule + var re2 = /%%([^%]*)%%/g; + var match2; + while (match2 = re2.exec(rule[2])) { + var value; + if(match2[1]=="VERSION") { + value = version; + } + rule[2] = rule[2].replace(match2[0], value); + } + match1[1] = match1[1].replace(rule[1], rule[2]); + content = content.replace(match1[0], "\n"+match1[1]+"\n"); + } + } + + FILE.write(path, content); +} diff --git a/vendor/firephp/firephp-core/workspace/scripts/publish.js b/vendor/firephp/firephp-core/workspace/scripts/publish.js new file mode 100644 index 000000000..39106e1b3 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/scripts/publish.js @@ -0,0 +1,65 @@ + +var PINF_LOADER = require("pinf/loader"), + SANDBOX = PINF_LOADER.getSandbox(), + FILE = require("modules/file"), + Q = require("modules/q"), + SYSTEM = require("modules/system"), + BUILD = require("./build"), + JSON = require("modules/json"), + SOURCEMINT_CLIENT = false; + +exports.main = function() +{ + module.load({ + id: "private-registry.appspot.com/cadorn.com/github/com.cadorn.baby/projects/sourcemint/packages/client-js/", + descriptor: { + main: "lib/client.js" + } + }, function(id) + { + SOURCEMINT_CLIENT = require(id); + + publish(); + }); +} + +function publish() +{ + var buildPath = BUILD.getBuildPath(), + info = JSON.decode(FILE.read(buildPath + "/info.json")), + descriptor = JSON.decode(FILE.read(FILE.dirname(FILE.dirname(FILE.dirname(module.id))) + "/package.json")); + + var bundles = {}; + bundles["firephp-core.zip"] = { + "type": "zip", + "options": { + "archivePath": buildPath + "/FirePHPCore-" + info.version + ".zip", + } + }; + + var packages = [ + { + "uid": descriptor.uid, + "stream": "stable", + "version": info.version, + "bundles": bundles + } + ]; + + try + { + Q.when(SOURCEMINT_CLIENT.publish(packages), function(info) + { + module.print("\0green(Published:\n"); + console.log(info); + module.print("\0)"); + }, function(e) + { + throw e; + }); + } + catch(e) + { + console.error("Error: " + e); + } +} diff --git a/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md b/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md new file mode 100644 index 000000000..1b0aaf269 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md @@ -0,0 +1,21 @@ +[MIT License](http://www.opensource.org/licenses/mit-license.php) + +Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml b/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml new file mode 100644 index 000000000..b9f3d65a4 --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml @@ -0,0 +1,61 @@ + + + + FirePHPCore + pear.firephp.org + Log variables from PHP to the browser (Firebug Console) + Handles all communication between the PHP code on the server and the client. Also implements all core FirePHP features. + + + Christoph Dorn + cadorn + christoph@christophdorn.com + yes + + + %%DATE%% + + %%VERSION%% + 0.3 + + + + %%STABILITY%% + stable + + + MIT + + No Notes + + + + + + + + + + + + + + + + + 4.0 + + + 1.4.5 + + + + + + + diff --git a/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md b/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md new file mode 100644 index 000000000..01264662e --- /dev/null +++ b/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md @@ -0,0 +1,17 @@ +FirePHPCore Server Library +========================== + +Status: stable + +Version: [%%VERSION%%](https://github.com/firephp/firephp-core/tree/v%%VERSION%%) + +This archive contains the *FirePHPCore* PHP server library. + +Links +----- + + * Documentation: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/ + * Install: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Configuration/Traditional + * Support: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#support + * Author: [Christoph Dorn](http://www.christophdorn.com/) + * License: [MIT License](http://www.opensource.org/licenses/mit-license.php) From 192e81620d41dd1d2b7ccfcb71b1b26cfa0eb962 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 15:17:13 +0900 Subject: [PATCH 3/8] Replace Pear HTTP_Request with rmccue/Requests --- classes/file/FileHandler.class.php | 135 +- composer.json | 1 - composer.lock | 208 +- config/func.inc.php | 2 +- libs/PEAR.1.9.5/HTTP/Request.php | 55 - libs/PEAR.1.9.5/HTTP/Request2.php | 1030 --- libs/PEAR.1.9.5/HTTP/Request2/Adapter.php | 137 - .../PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php | 567 -- .../PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php | 166 - .../HTTP/Request2/Adapter/Socket.php | 1121 --- libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php | 494 -- libs/PEAR.1.9.5/HTTP/Request2/Exception.php | 160 - .../HTTP/Request2/MultipartBody.php | 268 - .../PEAR.1.9.5/HTTP/Request2/Observer/Log.php | 192 - libs/PEAR.1.9.5/HTTP/Request2/Response.php | 631 -- libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php | 135 - .../HTTP/Request2/SocketWrapper.php | 297 - libs/PEAR.1.9.5/Net/URL2.php | 1219 --- libs/PEAR.1.9.5/PEAR.php | 1063 --- libs/PEAR.1.9.5/PEAR/Exception.php | 389 - libs/PEAR.1.9.5/PEAR5.php | 33 - libs/PEAR.1.9/HTTP/Request.php | 55 - libs/PEAR.1.9/HTTP/Request2.php | 861 --- libs/PEAR.1.9/HTTP/Request2/Adapter.php | 154 - libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php | 461 -- libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php | 171 - .../PEAR.1.9/HTTP/Request2/Adapter/Socket.php | 1046 --- libs/PEAR.1.9/HTTP/Request2/Exception.php | 62 - libs/PEAR.1.9/HTTP/Request2/MultipartBody.php | 274 - libs/PEAR.1.9/HTTP/Request2/Observer/Log.php | 215 - libs/PEAR.1.9/HTTP/Request2/Response.php | 559 -- libs/PEAR.1.9/Net/URL2.php | 894 --- libs/PEAR.1.9/PEAR.php | 1137 --- libs/PEAR.1.9/PEAR/Exception.php | 391 - libs/PEAR.1.9/PEAR5.php | 33 - libs/PEAR/HTTP/Request.php | 1461 ---- libs/PEAR/HTTP/Request/Listener.php | 106 - libs/PEAR/Net/Socket.php | 528 -- libs/PEAR/Net/URL.php | 410 - libs/PEAR/PEAR.php | 1108 --- vendor/composer/autoload_classmap.php | 34 - vendor/composer/autoload_namespaces.php | 2 - vendor/composer/autoload_real.php | 4 - vendor/composer/include_paths.php | 10 - vendor/composer/installed.json | 174 - vendor/pear/http_request2/HTTP/Request2.php | 1030 --- .../http_request2/HTTP/Request2/Adapter.php | 137 - .../HTTP/Request2/Adapter/Curl.php | 567 -- .../HTTP/Request2/Adapter/Mock.php | 166 - .../HTTP/Request2/Adapter/Socket.php | 1121 --- .../http_request2/HTTP/Request2/CookieJar.php | 494 -- .../http_request2/HTTP/Request2/Exception.php | 160 - .../HTTP/Request2/MultipartBody.php | 268 - .../HTTP/Request2/Observer/Log.php | 192 - .../http_request2/HTTP/Request2/Response.php | 631 -- .../http_request2/HTTP/Request2/SOCKS5.php | 135 - .../HTTP/Request2/SocketWrapper.php | 297 - vendor/pear/http_request2/README.md | 80 - vendor/pear/http_request2/composer.json | 34 - .../pear/http_request2/data/generate-list.php | 96 - .../http_request2/data/public-suffix-list.php | 6701 ----------------- vendor/pear/http_request2/docs/LICENSE | 31 - .../docs/examples/upload-rapidshare.php | 58 - vendor/pear/http_request2/package.xml | 646 -- vendor/pear/http_request2/tests/AllTests.php | 54 - .../tests/NetworkConfig.php.dist | 58 - .../pear/http_request2/tests/ObserverTest.php | 95 - .../tests/Request2/Adapter/AllTests.php | 70 - .../Request2/Adapter/CommonNetworkTest.php | 387 - .../tests/Request2/Adapter/CurlTest.php | 120 - .../tests/Request2/Adapter/MockTest.php | 157 - .../tests/Request2/Adapter/SkippedTests.php | 56 - .../Request2/Adapter/SocketProxyTest.php | 55 - .../tests/Request2/Adapter/SocketTest.php | 159 - .../http_request2/tests/Request2/AllTests.php | 56 - .../tests/Request2/CookieJarTest.php | 370 - .../tests/Request2/MultipartBodyTest.php | 102 - .../tests/Request2/ResponseTest.php | 128 - .../pear/http_request2/tests/Request2Test.php | 391 - .../pear/http_request2/tests/TestHelper.php | 51 - .../pear/http_request2/tests/_files/bug_15305 | Bin 16338 -> 0 bytes .../pear/http_request2/tests/_files/bug_18169 | 9 - .../pear/http_request2/tests/_files/empty.gif | Bin 43 -> 0 bytes .../http_request2/tests/_files/plaintext.txt | 1 - .../tests/_files/response_cookies | 13 - .../tests/_files/response_deflate | Bin 1654 -> 0 bytes .../http_request2/tests/_files/response_gzip | Bin 1672 -> 0 bytes .../tests/_files/response_gzip_broken | Bin 221 -> 0 bytes .../tests/_files/response_headers | 12 - .../tests/_network/basicauth.php | 33 - .../http_request2/tests/_network/bug19934.php | 27 - .../http_request2/tests/_network/cookies.php | 24 - .../tests/_network/digestauth.php | 83 - .../tests/_network/getparameters.php | 24 - .../tests/_network/postparameters.php | 24 - .../tests/_network/rawpostdata.php | 22 - .../tests/_network/redirects.php | 47 - .../tests/_network/setcookie.php | 27 - .../http_request2/tests/_network/timeout.php | 23 - .../http_request2/tests/_network/uploads.php | 36 - vendor/pear/net_url2/.gitignore | 7 - vendor/pear/net_url2/.scrutinizer.yml | 38 - vendor/pear/net_url2/.travis.yml | 17 - vendor/pear/net_url2/Net/URL2.php | 1219 --- vendor/pear/net_url2/README.md | 43 - vendor/pear/net_url2/composer.json | 47 - vendor/pear/net_url2/docs/6470.php | 56 - vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes | 27 - vendor/pear/net_url2/docs/example.php | 62 - vendor/pear/net_url2/package.xml | 469 -- vendor/pear/net_url2/phpunit.xml.dist | 17 - vendor/pear/net_url2/tests/AllTests.php | 59 - vendor/pear/net_url2/tests/Net/URL2Test.php | 1088 --- vendor/pear/pear_exception/.gitignore | 6 - vendor/pear/pear_exception/.travis.yml | 7 - vendor/pear/pear_exception/LICENSE | 27 - vendor/pear/pear_exception/PEAR/Exception.php | 456 -- vendor/pear/pear_exception/composer.json | 43 - vendor/pear/pear_exception/package.xml | 120 - .../tests/PEAR/ExceptionTest.php | 78 - 120 files changed, 94 insertions(+), 37803 deletions(-) delete mode 100644 libs/PEAR.1.9.5/HTTP/Request.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Exception.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Response.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php delete mode 100644 libs/PEAR.1.9.5/Net/URL2.php delete mode 100644 libs/PEAR.1.9.5/PEAR.php delete mode 100644 libs/PEAR.1.9.5/PEAR/Exception.php delete mode 100644 libs/PEAR.1.9.5/PEAR5.php delete mode 100644 libs/PEAR.1.9/HTTP/Request.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Exception.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/MultipartBody.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Observer/Log.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Response.php delete mode 100644 libs/PEAR.1.9/Net/URL2.php delete mode 100644 libs/PEAR.1.9/PEAR.php delete mode 100644 libs/PEAR.1.9/PEAR/Exception.php delete mode 100644 libs/PEAR.1.9/PEAR5.php delete mode 100644 libs/PEAR/HTTP/Request.php delete mode 100644 libs/PEAR/HTTP/Request/Listener.php delete mode 100644 libs/PEAR/Net/Socket.php delete mode 100644 libs/PEAR/Net/URL.php delete mode 100644 libs/PEAR/PEAR.php delete mode 100644 vendor/composer/include_paths.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/CookieJar.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Exception.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/MultipartBody.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Observer/Log.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Response.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/SOCKS5.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php delete mode 100644 vendor/pear/http_request2/README.md delete mode 100644 vendor/pear/http_request2/composer.json delete mode 100644 vendor/pear/http_request2/data/generate-list.php delete mode 100644 vendor/pear/http_request2/data/public-suffix-list.php delete mode 100644 vendor/pear/http_request2/docs/LICENSE delete mode 100644 vendor/pear/http_request2/docs/examples/upload-rapidshare.php delete mode 100644 vendor/pear/http_request2/package.xml delete mode 100644 vendor/pear/http_request2/tests/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/NetworkConfig.php.dist delete mode 100644 vendor/pear/http_request2/tests/ObserverTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/CookieJarTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/ResponseTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2Test.php delete mode 100644 vendor/pear/http_request2/tests/TestHelper.php delete mode 100644 vendor/pear/http_request2/tests/_files/bug_15305 delete mode 100644 vendor/pear/http_request2/tests/_files/bug_18169 delete mode 100644 vendor/pear/http_request2/tests/_files/empty.gif delete mode 100644 vendor/pear/http_request2/tests/_files/plaintext.txt delete mode 100644 vendor/pear/http_request2/tests/_files/response_cookies delete mode 100644 vendor/pear/http_request2/tests/_files/response_deflate delete mode 100644 vendor/pear/http_request2/tests/_files/response_gzip delete mode 100644 vendor/pear/http_request2/tests/_files/response_gzip_broken delete mode 100644 vendor/pear/http_request2/tests/_files/response_headers delete mode 100644 vendor/pear/http_request2/tests/_network/basicauth.php delete mode 100644 vendor/pear/http_request2/tests/_network/bug19934.php delete mode 100644 vendor/pear/http_request2/tests/_network/cookies.php delete mode 100644 vendor/pear/http_request2/tests/_network/digestauth.php delete mode 100644 vendor/pear/http_request2/tests/_network/getparameters.php delete mode 100644 vendor/pear/http_request2/tests/_network/postparameters.php delete mode 100644 vendor/pear/http_request2/tests/_network/rawpostdata.php delete mode 100644 vendor/pear/http_request2/tests/_network/redirects.php delete mode 100644 vendor/pear/http_request2/tests/_network/setcookie.php delete mode 100644 vendor/pear/http_request2/tests/_network/timeout.php delete mode 100644 vendor/pear/http_request2/tests/_network/uploads.php delete mode 100644 vendor/pear/net_url2/.gitignore delete mode 100644 vendor/pear/net_url2/.scrutinizer.yml delete mode 100644 vendor/pear/net_url2/.travis.yml delete mode 100755 vendor/pear/net_url2/Net/URL2.php delete mode 100644 vendor/pear/net_url2/README.md delete mode 100644 vendor/pear/net_url2/composer.json delete mode 100755 vendor/pear/net_url2/docs/6470.php delete mode 100644 vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes delete mode 100755 vendor/pear/net_url2/docs/example.php delete mode 100644 vendor/pear/net_url2/package.xml delete mode 100644 vendor/pear/net_url2/phpunit.xml.dist delete mode 100644 vendor/pear/net_url2/tests/AllTests.php delete mode 100644 vendor/pear/net_url2/tests/Net/URL2Test.php delete mode 100644 vendor/pear/pear_exception/.gitignore delete mode 100644 vendor/pear/pear_exception/.travis.yml delete mode 100644 vendor/pear/pear_exception/LICENSE delete mode 100644 vendor/pear/pear_exception/PEAR/Exception.php delete mode 100644 vendor/pear/pear_exception/composer.json delete mode 100644 vendor/pear/pear_exception/package.xml delete mode 100644 vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index d725d95aa..9bafafd0c 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -516,8 +516,6 @@ class FileHandler /** * Return remote file's content via HTTP * - * If the target is moved (when return code is 300~399), this function follows the location specified response header. - * * @param string $url The address of the target file * @param string $body HTTP request body * @param int $timeout Connection timeout @@ -532,89 +530,66 @@ class FileHandler { try { - requirePear(); - if(!class_exists('HTTP_Request')) require_once('HTTP/Request.php'); - - $parsed_url = parse_url(__PROXY_SERVER__); - if($parsed_url["host"]) + $request_headers = array(); + $request_cookies = array(); + $request_options = array('timeout' => $timeout); + + foreach($headers as $key => $val) { - $oRequest = new HTTP_Request(__PROXY_SERVER__); - $oRequest->setMethod('POST'); - $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); + $request_headers[$key] = $val; + } + + if(isset($cookies[$host]) && is_array($cookies[$host])) + { + foreach($cookies[$host] as $key => $val) + { + $request_cookies[] = rawurlencode($key) . '=' . rawurlencode($val); + } + } + if(count($request_cookies)) + { + $request_headers['Cookie'] = implode('; ', $request_cookies); + } + + foreach($request_config as $key => $val) + { + $request_options[$key] = $val; + } + + if($content_type) + { + $request_headers['Content-Type'] = $content_type; + } + + $proxy = parse_url(__PROXY_SERVER__); + if($proxy["host"]) + { + $request_options['proxy'] = array($proxy['host'] . ($proxy['port'] ? (':' . $proxy['port']) : '')); + if($proxy['user'] && $proxy['pass']) + { + $request_options['proxy'][] = $proxy['user']; + $request_options['proxy'][] = $proxy['pass']; + } + } + + $response = Requests::request($url, $request_headers, $body ?: $post_data, $method, $request_options); + + if(count($response->cookies)) + { + foreach($response->cookies as $cookie) + { + $cookies[$host][$cookie->name] = $cookie->value; + } + } + + if($response->success) + { + return $response->body; } else { - $oRequest = new HTTP_Request($url); - - if(count($request_config) && method_exists($oRequest, 'setConfig')) - { - foreach($request_config as $key=>$val) - { - $oRequest->setConfig($key, $val); - } - } - - if(count($headers) > 0) - { - foreach($headers as $key => $val) - { - $oRequest->addHeader($key, $val); - } - } - if($cookies[$host]) - { - foreach($cookies[$host] as $key => $val) - { - $oRequest->addCookie($key, $val); - } - } - if(count($post_data) > 0) - { - foreach($post_data as $key => $val) - { - $oRequest->addPostData($key, $val); - } - } - if(!$content_type) - $oRequest->addHeader('Content-Type', 'text/html'); - else - $oRequest->addHeader('Content-Type', $content_type); - $oRequest->setMethod($method); - if($body) - $oRequest->setBody($body); + return NULL; } - - if(method_exists($oRequest, 'setConfig')) - { - $oRequest->setConfig('timeout', $timeout); - } - elseif(property_exists($oRequest, '_timeout')) - { - $oRequest->_timeout = $timeout; - } - - $oResponse = $oRequest->sendRequest(); - - $code = $oRequest->getResponseCode(); - $header = $oRequest->getResponseHeader(); - $response = $oRequest->getResponseBody(); - if($c = $oRequest->getResponseCookies()) - { - foreach($c as $k => $v) - { - $cookies[$host][$v['name']] = $v['value']; - } - } - - if($code > 300 && $code < 399 && $header['location']) - { - return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); - } - - if($code != 200) - return; - - return $response; } catch(Exception $e) { diff --git a/composer.json b/composer.json index 3678be41e..faf97627b 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "firephp/firephp-core": "0.4.0", "matthiasmullie/minify": "1.3.*", "michelf/php-markdown": "1.5.*", - "pear/http_request2": "2.2.*", "rmccue/requests": "1.6.*", "sunra/php-simple-html-dom-parser": "1.5.*", "swiftmailer/swiftmailer": "5.4.*", diff --git a/composer.lock b/composer.lock index fb06f62f0..043cbfd87 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "97c72bd2862f9d0a77824d769085e926", - "content-hash": "ffd2aaf7dc6705d78c09488d2c7ab024", + "hash": "a35061b94658a2dbdafe943dddcdc898", + "content-hash": "1a71937e1cbc600f8a237c6445d6a69f", "packages": [ { "name": "defuse/php-encryption", @@ -96,6 +96,42 @@ ], "time": "2015-08-05 01:03:42" }, + { + "name": "firephp/firephp-core", + "version": "v0.4.0", + "source": { + "type": "git", + "url": "https://github.com/firephp/firephp-core.git", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firephp/firephp-core/zipball/fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/FirePHPCore/FirePHP.class.php", + "lib/FirePHPCore/fb.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "homepage": "http://christophdorn.com" + } + ], + "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", + "homepage": "https://github.com/firephp/firephp-core", + "time": "2013-04-23 15:28:20" + }, { "name": "matthiasmullie/minify", "version": "1.3.32", @@ -254,174 +290,6 @@ ], "time": "2015-03-01 12:03:08" }, - { - "name": "pear/http_request2", - "version": "v2.2.1", - "source": { - "type": "git", - "url": "https://github.com/pear/HTTP_Request2.git", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de", - "shasum": "" - }, - "require": { - "pear/net_url2": ">=2.0.0", - "pear/pear_exception": "*", - "php": ">=5.2.0" - }, - "suggest": { - "ext-fileinfo": "Adds support for looking up mime-types using finfo.", - "ext-zlib": "Allows handling gzip compressed responses.", - "lib-curl": "Allows using cURL as a request backend.", - "lib-openssl": "Allows handling SSL requests when not using cURL." - }, - "type": "library", - "autoload": { - "psr-0": { - "HTTP_Request2": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Alexey Borzov", - "email": "avb@php.net", - "role": "Developer HTML_Common2" - } - ], - "description": "Provides an easy way to perform HTTP requests.", - "homepage": "http://pear.php.net/package/HTTP_Request2", - "keywords": [ - "PEAR", - "curl", - "http", - "request" - ], - "time": "2014-01-16 17:27:21" - }, - { - "name": "pear/net_url2", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/pear/Net_URL2.git", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "shasum": "" - }, - "require": { - "php": ">=5.1.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "Net/URL2.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "homepage": "https://github.com/pear/Net_URL2", - "keywords": [ - "PEAR", - "net", - "networking", - "rfc3986", - "uri", - "url" - ], - "time": "2015-04-18 17:36:57" - }, - { - "name": "pear/pear_exception", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/pear/PEAR_Exception.git", - "reference": "8c18719fdae000b690e3912be401c76e406dd13b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b", - "reference": "8c18719fdae000b690e3912be401c76e406dd13b", - "shasum": "" - }, - "require": { - "php": ">=4.4.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "type": "class", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "." - ], - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "description": "The PEAR Exception base class.", - "homepage": "https://github.com/pear/PEAR_Exception", - "keywords": [ - "exception" - ], - "time": "2015-02-10 20:07:52" - }, { "name": "rmccue/requests", "version": "v1.6.1", diff --git a/config/func.inc.php b/config/func.inc.php index 89a3a8e25..c35f9b562 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -1448,7 +1448,7 @@ function stripEmbedTagForAdmin(&$content, $writer_member_srl) */ function requirePear() { - set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path()); + } /** diff --git a/libs/PEAR.1.9.5/HTTP/Request.php b/libs/PEAR.1.9.5/HTTP/Request.php deleted file mode 100644 index 7fb0645d0..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request.php +++ /dev/null @@ -1,55 +0,0 @@ -setHeader($name, $value); - } - - public function sendRequest($saveBody = true) - { - $response = $this->send(); - $this->response = $response; - return $response; - } - - public function getResponseCode() { - if($this->response) - { - return $this->response->getStatus(); - } - } - - public function getResponseHeader() { - if($this->response) - { - return $this->response->getHeader(); - } - } - - public function getResponseBody() { - if($this->response) - { - return $this->response->getBody(); - } - } - - public function getResponseCookies() { - if($this->response) - { - return $this->response->getCookies(); - } - } - - public function addPostData($name, $value, $preencoded = false) - { - $this->addPostParameter($name, $value); - } - -} - -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2.php b/libs/PEAR.1.9.5/HTTP/Request2.php deleted file mode 100644 index d2f36e17b..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2.php +++ /dev/null @@ -1,1030 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - 'local_ip' => null, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - 'proxy_type' => 'http', - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - /** - * Cookie jar to persist cookies between requests - * @var HTTP_Request2_CookieJar - */ - protected $cookieJar = null; - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 $url Request URL - * @param string $method Request method - * @param array $config Configuration for this Request instance - */ - public function __construct( - $url = null, $method = self::METHOD_GET, array $config = array() - ) { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader( - 'user-agent', 'HTTP_Request2/2.2.1 ' . - '(http://pear.php.net/package/http_request2) PHP/' . phpversion() - ); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 $url Request URL - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a valid HTTP URL', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string $method one of the methods defined in RFC 2616 - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_LogicException( - "Invalid request method '{$method}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'local_ip' - Specifies the IP address that will be used for accessing - * the network (string)
  • - *
  • 'proxy_type' - Proxy type, 'http' or 'socks5' (string)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'proxy' - Shorthand for proxy_* parameters, proxy given as URL, - * e.g. 'socks5://localhost:1080/' (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array $nameOrConfig configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed $value parameter value if $nameOrConfig is not an array - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } elseif ('proxy' == $nameOrConfig) { - $url = new Net_URL2($value); - $this->setConfig(array( - 'proxy_type' => $url->getScheme(), - 'proxy_host' => $url->getHost(), - 'proxy_port' => $url->getPort(), - 'proxy_user' => rawurldecode($url->getUser()), - 'proxy_password' => rawurldecode($url->getPassword()) - )); - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$nameOrConfig}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string $name parameter name - * - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string $user user name - * @param string $password password - * @param string $scheme authentication scheme - * - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array $name header name, header string ('Header: value') - * or an array of headers - * @param string|array|null $value header value if $name is not an array, - * header will be removed if value is null - * @param bool $replace whether to replace previous header with the - * same name or append to its value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setHeader($name, $value = null, $replace = true) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v, $replace); - } else { - $this->setHeader($v, null, $replace); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_LogicException( - "Invalid header name '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - - } else { - if (is_array($value)) { - $value = implode(', ', array_map('trim', $value)); - } elseif (is_string($value)) { - $value = trim($value); - } - if (!isset($this->headers[$name]) || $replace) { - $this->headers[$name] = $value; - } else { - $this->headers[$name] .= ', ' . $value; - } - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Adds a cookie to the request - * - * If the request does not have a CookieJar object set, this method simply - * appends a cookie to "Cookie:" header. - * - * If a CookieJar object is available, the cookie is stored in that object. - * Data from request URL will be used for setting its 'domain' and 'path' - * parameters, 'expires' and 'secure' will be set to null and false, - * respectively. If you need further control, use CookieJar's methods. - * - * @param string $name cookie name - * @param string $value cookie value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - * @see setCookieJar() - */ - public function addCookie($name, $value) - { - if (!empty($this->cookieJar)) { - $this->cookieJar->store( - array('name' => $name, 'value' => $value), $this->url - ); - - } else { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_LogicException( - "Invalid cookie: '{$cookie}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - } - - return $this; - } - - /** - * Sets the request body - * - * If you provide file pointer rather than file name, it should support - * fstat() and rewind() operations. - * - * @param string|resource|HTTP_Request2_MultipartBody $body Either a - * string with the body or filename containing body or - * pointer to an open file or object with multipart body data - * @param bool $isFilename Whether - * first parameter is a filename - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename && !is_resource($body)) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - $fileData = $this->fopenWrapper($body, empty($this->headers['content-type'])); - $this->body = $fileData['fp']; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', $fileData['type']); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method - && (!empty($this->postParams) || !empty($this->uploads)) - ) { - if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * If you provide file pointers rather than file names, they should support - * fstat() and rewind() operations. - * - * @param string $fieldName name of file-upload field - * @param string|resource|array $filename full name of local file, - * pointer to open file or an array of files - * @param string $sendFilename filename to send in the request - * @param string $contentType content-type of file being uploaded - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function addUpload( - $fieldName, $filename, $sendFilename = null, $contentType = null - ) { - if (!is_array($filename)) { - $fileData = $this->fopenWrapper($filename, empty($contentType)); - $this->uploads[$fieldName] = array( - 'fp' => $fileData['fp'], - 'filename' => !empty($sendFilename)? $sendFilename - :(is_string($filename)? basename($filename): 'anonymous.blob') , - 'size' => $fileData['size'], - 'type' => empty($contentType)? $fileData['type']: $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - $fileData = $this->fopenWrapper($f[0], empty($f[2])); - $fps[] = $fileData['fp']; - $names[] = !empty($f[1])? $f[1] - :(is_string($f[0])? basename($f[0]): 'anonymous.blob'); - $sizes[] = $fileData['size']; - $types[] = empty($f[2])? $fileData['type']: $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) - || 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array $name parameter name or array ('name' => 'value') - * @param mixed $value parameter value (can be an array) - * - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string $name event name - * @param mixed $data event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'sentBody' - after sending the whole request body, - * data is request body length (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter $adapter Adapter to use - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (!class_exists($adapter, false) - && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter) - ) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_LogicException( - "Class {$adapter} not found", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a HTTP request adapter', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sets the cookie jar - * - * A cookie jar is used to maintain cookies across HTTP requests and - * responses. Cookies from jar will be automatically added to the request - * headers based on request URL. - * - * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to - * create a new one, false to remove - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setCookieJar($jar = true) - { - if (!class_exists('HTTP_Request2_CookieJar', false)) { - require_once 'HTTP/Request2/CookieJar.php'; - } - - if ($jar instanceof HTTP_Request2_CookieJar) { - $this->cookieJar = $jar; - } elseif (true === $jar) { - $this->cookieJar = new HTTP_Request2_CookieJar(); - } elseif (!$jar) { - $this->cookieJar = null; - } else { - throw new HTTP_Request2_LogicException( - 'Invalid parameter passed to setCookieJar()', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - - return $this; - } - - /** - * Returns current CookieJar object or null if none - * - * @return HTTP_Request2_CookieJar|null - */ - public function getCookieJar() - { - return $this->cookieJar; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2 - || !$this->url->isAbsolute() - || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) - ) { - throw new HTTP_Request2_LogicException( - 'HTTP_Request2 needs an absolute HTTP(S) request URL, ' - . ($this->url instanceof Net_URL2 - ? "'" . $this->url->__toString() . "'" : 'none') - . ' given', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Wrapper around fopen()/fstat() used by setBody() and addUpload() - * - * @param string|resource $file file name or pointer to open file - * @param bool $detectType whether to try autodetecting MIME - * type of file, will only work if $file is a - * filename, not pointer - * - * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) - * @throws HTTP_Request2_LogicException - */ - protected function fopenWrapper($file, $detectType = false) - { - if (!is_string($file) && !is_resource($file)) { - throw new HTTP_Request2_LogicException( - "Filename or file pointer resource expected", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $fileData = array( - 'fp' => is_string($file)? null: $file, - 'type' => 'application/octet-stream', - 'size' => 0 - ); - if (is_string($file)) { - if (!($fileData['fp'] = @fopen($file, 'rb'))) { - $error = error_get_last(); - throw new HTTP_Request2_LogicException( - $error['message'], HTTP_Request2_Exception::READ_ERROR - ); - } - if ($detectType) { - $fileData['type'] = self::detectMimeType($file); - } - } - if (!($stat = fstat($fileData['fp']))) { - throw new HTTP_Request2_LogicException( - "fstat() call failed", HTTP_Request2_Exception::READ_ERROR - ); - } - $fileData['size'] = $stat['size']; - - return $fileData; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string $filename file name - * - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php deleted file mode 100644 index 4e4b0b10a..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array &$headers associative array of request headers, this method - * will add proper 'Content-Length' and 'Content-Type' - * headers to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) - if (!isset($headers['transfer-encoding'])) { - $headers['content-length'] = $this->contentLength; - } - } - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index ef75b8c95..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,567 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array - */ - protected static $errorMap = array( - CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), - // error returned from write callback - CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TIMEOUT), - CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), - CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS), - CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), - CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), - CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), - CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::INVALID_ARGUMENT), - CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), - CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), - CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Creates a subclass of HTTP_Request2_Exception from curl error data - * - * @param resource $ch curl handle - * - * @return HTTP_Request2_Exception - */ - protected static function wrapCurlError($ch) - { - $nativeCode = curl_errno($ch); - $message = 'Curl error: ' . curl_error($ch); - if (!isset(self::$errorMap[$nativeCode])) { - return new HTTP_Request2_Exception($message, 0, $nativeCode); - } else { - $class = self::$errorMap[$nativeCode][0]; - $code = empty(self::$errorMap[$nativeCode][1]) - ? 0 : self::$errorMap[$nativeCode][1]; - return new $class($message, $code, $nativeCode); - } - } - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_LogicException( - 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $e = self::wrapCurlError($ch); - } - } catch (Exception $e) { - } - if (isset($ch)) { - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - } - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_NotImplementedException - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) { - throw new HTTP_Request2_LogicException( - 'Redirect support in curl is unavailable due to open_basedir or safe_mode setting', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // set local IP via CURLOPT_INTERFACE (request #19515) - if ($ip = $this->request->getConfig('local_ip')) { - curl_setopt($ch, CURLOPT_INTERFACE, $ip); - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - case HTTP_Request2::METHOD_PUT: - curl_setopt($ch, CURLOPT_UPLOAD, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE - ); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt( - $ch, CURLOPT_PROXYUSERPWD, - $user . ':' . $this->request->getConfig('proxy_password') - ); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - if ($type = $this->request->getConfig('proxy_type')) { - switch ($type) { - case 'http': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - break; - case 'socks5': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); - break; - default: - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource $ch cURL handle - * @param array &$headers Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - } else { - // rewind may be needed, read the whole body into memory - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource $ch cURL handle - * @param resource $fd file descriptor (not used) - * @param integer $length maximum length of data to return - * - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource $ch cURL handle - * @param string $string response header (with trailing CRLF) - * - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders - || $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - if ($upload && (!$this->eventSentHeaders - || $this->response->getStatus() >= 200) - ) { - $this->request->setLastEvent('sentBody', $upload); - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response( - $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) - ); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - - if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - - // for versions lower than 5.2.10, check the redirection URL protocol - if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - - if ($jar = $this->request->getCookieJar()) { - $jar->addCookiesFromResponse($this->response, $this->request->getUrl()); - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $this->request->getUrl()->resolve($redirectUrl); - } - if ($cookies = $jar->getMatching($redirectUrl, true)) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource $ch cURL handle (not used) - * @param string $string part of the response body - * - * @return integer number of bytes saved - * @throws HTTP_Request2_MessageException - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$string}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index d6e274ab9..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * Only responses without explicit URLs or with URLs equal to request URL - * will be considered. If matching response is not found or the queue is - * empty then default empty response with status 400 will be returned, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $requestUrl = (string)$request->getUrl(); - $response = null; - foreach ($this->responses as $k => $v) { - if (!$v[1] || $requestUrl == $v[1]) { - $response = $v[0]; - array_splice($this->responses, $k, 1); - break; - } - } - if (!$response) { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - - } elseif ($response instanceof HTTP_Request2_Response) { - return $response; - - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } - - /** - * Adds response to the queue - * - * @param mixed $response either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @param string $url A request URL this response should be valid for - * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) - * - * @throws HTTP_Request2_Exception - */ - public function addResponse($response, $url = null) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = array($response, $url); - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string $str string containing HTTP response message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource $fp file pointer returned by fopen() - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index 7946b0a37..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1121 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Base class for HTTP_Request2 adapters */ -require_once 'HTTP/Request2/Adapter.php'; - -/** Socket wrapper class */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Whether to wait for "100 Continue" response before sending request body - * @var bool - */ - protected $expect100Continue = false; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - $this->socket->write($headers); - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - - if (!$this->expect100Continue) { - $this->writeBody(); - $response = $this->readResponse(); - - } else { - $response = $this->readResponse(); - if (!$response || 100 == $response->getStatus()) { - $this->expect100Continue = false; - // either got "100 Continue" or timed out -> send body - $this->writeBody(); - $response = $this->readResponse(); - } - } - - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - $this->redirectCountdown = null; - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - $this->redirectCountdown = null; - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - $httpProxy = $socksProxy = false; - if (!($host = $this->request->getConfig('proxy_host'))) { - $host = $reqHost; - $port = $reqPort; - } else { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ('http' == ($type = $this->request->getConfig('proxy_type'))) { - $httpProxy = true; - } elseif ('socks5' == $type) { - $socksProxy = true; - } else { - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - - if ($tunnel && !$httpProxy) { - throw new HTTP_Request2_LogicException( - "Trying to perform CONNECT request without proxy", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_LogicException( - 'Need OpenSSL support for https:// requests', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($httpProxy && !$secure && !empty($headers['connection']) - && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - - $options = array(); - if ($ip = $this->request->getConfig('local_ip')) { - $options['socket'] = array( - 'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0' - ); - } - if ($secure || $tunnel) { - $options['ssl'] = array(); - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['ssl']['CN_match'] = $reqHost; - } - } else { - $options['ssl'][substr($name, 4)] = $value; - } - } - } - ksort($options['ssl']); - } - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $this->request->getConfig('timeout')) { - $deadline = time() + $timeout; - } else { - $deadline = null; - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = ((!$secure || $httpProxy || $socksProxy)? 'tcp://': 'ssl://') - . $host . ':' . $port; - $socketKey = $remote . ( - ($secure && $httpProxy || $socksProxy) - ? "->{$reqHost}:{$reqPort}" : '' - ) . (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) - && !self::$sockets[$socketKey]->eof() - ) { - $this->socket =& self::$sockets[$socketKey]; - - } else { - if ($socksProxy) { - require_once 'HTTP/Request2/SOCKS5.php'; - - $this->socket = new HTTP_Request2_SOCKS5( - $remote, $this->request->getConfig('connect_timeout'), - $options, $this->request->getConfig('proxy_user'), - $this->request->getConfig('proxy_password') - ); - // handle request timeouts ASAP - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - $this->socket->connect($reqHost, $reqPort); - if (!$secure) { - $conninfo = "tcp://{$reqHost}:{$reqPort} via {$remote}"; - } else { - $this->socket->enableCrypto(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - } - - } elseif ($secure && $httpProxy && !$tunnel) { - $this->establishTunnel(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - - } else { - $this->socket = new HTTP_Request2_SocketWrapper( - $remote, $this->request->getConfig('connect_timeout'), $options - ); - } - $this->request->setLastEvent('connect', empty($conninfo)? $remote: $conninfo); - self::$sockets[$socketKey] =& $this->socket; - } - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_ConnectionException( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - $this->socket->enableCrypto(); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean $requestKeepAlive whether connection could - * be persistent in the first place - * @param HTTP_Request2_Response $response response object to check - * - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) - || null !== $response->getHeader('content-length') - // no body possible for such responses, see also request #17031 - || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || in_array($response->getStatus(), array(204, 304)); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (!empty($this->socket)) { - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 $request Original request - * @param HTTP_Request2_Response $response Response containing redirect - * - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect( - HTTP_Request2 $request, HTTP_Request2_Response $response - ) { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - $this->redirectCountdown = null; - // Copying cURL behaviour - throw new HTTP_Request2_MessageException( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - $this->redirectCountdown = null; - throw new HTTP_Request2_MessageException( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), - HTTP_Request2_Exception::NON_HTTP_REDIRECT - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() - || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) - || (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header - * - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) - && !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_NotImplementedException( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_NotImplementedException( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array &$challenge challenge to update - * @param string $headerValue value of [Proxy-]Authentication-Info header - * - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string $user user name - * @param string $password password - * @param string $url request URL - * @param array &$challenge digest challenge parameters - * - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) - && $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5( - $a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2 - ); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestHost request host (needed for digest authentication) - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = 'Basic ' . base64_encode( - $auth['user'] . ':' . $auth['password'] - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') - || !($user = $this->request->getConfig('proxy_user')) - || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) - && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = 'Basic ' . base64_encode( - $user . ':' . $password - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') - || 'http' != $this->request->getConfig('proxy_type') - || 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') - && extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - if ('1.1' == $this->request->getConfig('protocol_version')) { - $this->updateExpectHeader($headers); - } else { - $this->expect100Continue = false; - } - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Adds or removes 'Expect: 100-continue' header from request headers - * - * Also sets the $expect100Continue property. Parsing of existing header - * is somewhat needed due to its complex structure and due to the - * requirement in section 8.2.3 of RFC 2616: - * > A client MUST NOT send an Expect request-header field (section - * > 14.20) with the "100-continue" expectation if it does not intend - * > to send a request body. - * - * @param array &$headers Array of headers prepared for the request - * - * @throws HTTP_Request2_LogicException - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 - */ - protected function updateExpectHeader(&$headers) - { - $this->expect100Continue = false; - $expectations = array(); - if (isset($headers['expect'])) { - if ('' === $headers['expect']) { - // empty 'Expect' header is technically invalid, so just get rid of it - unset($headers['expect']); - return; - } - // build regexp to parse the value of existing Expect header - $expectParam = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . '))?\s*'; - $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . ')\s*(?:' - . $expectParam . ')*)?'; - $expectItem = '!(100-continue|' . $expectExtension . ')!A'; - - $pos = 0; - $length = strlen($headers['expect']); - - while ($pos < $length) { - $pos += strspn($headers['expect'], " \t", $pos); - if (',' === substr($headers['expect'], $pos, 1)) { - $pos++; - continue; - - } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) { - throw new HTTP_Request2_LogicException( - "Cannot parse value '{$headers['expect']}' of Expect header", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - - } else { - $pos += strlen($m[0]); - if (strcasecmp('100-continue', $m[0])) { - $expectations[] = $m[0]; - } - } - } - } - - if (1024 < $this->contentLength) { - $expectations[] = '100-continue'; - $this->expect100Continue = true; - } - - if (empty($expectations)) { - unset($headers['expect']); - } else { - $headers['expect'] = implode(',', $expectations); - } - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_MessageException - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - $headers = $this->request->getHeaders(); - $chunked = isset($headers['transfer-encoding']); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (!$chunked) { - $this->socket->write($str); - } else { - $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n"); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - - // write zero-length chunk - if ($chunked) { - $this->socket->write("0\r\n\r\n"); - } - $this->request->setLastEvent('sentBody', $this->contentLength); - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - // http://tools.ietf.org/html/rfc2616#section-8.2.3 - // ...the client SHOULD NOT wait for an indefinite period before sending the request body - $timeout = $this->expect100Continue ? 1 : null; - - do { - try { - $response = new HTTP_Request2_Response( - $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl() - ); - do { - $headerLine = $this->socket->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - - } catch (HTTP_Request2_MessageException $e) { - if (HTTP_Request2_Exception::TIMEOUT === $e->getCode() - && $this->expect100Continue - ) { - return null; - } - throw $e; - } - if ($this->expect100Continue && 100 == $response->getStatus()) { - return $response; - } - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus()) - || in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!$this->socket->eof() && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->socket->read($bufferSize); - } else { - $data = $this->socket->read(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || $this->socket->eof())) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int $bufferSize buffer size to use for reading - * - * @return string - * @throws HTTP_Request2_MessageException - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->socket->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_MessageException( - "Cannot decode chunked response, invalid chunk length '{$line}'", - HTTP_Request2_Exception::DECODE_ERROR - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); - return ''; - } - } - } - $data = $this->socket->read(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php b/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php deleted file mode 100644 index 79ac08bb7..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php +++ /dev/null @@ -1,494 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Class representing a HTTP request message */ -require_once 'HTTP/Request2.php'; - -/** - * Stores cookies and passes them between HTTP requests - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_CookieJar implements Serializable -{ - /** - * Array of stored cookies - * - * The array is indexed by domain, path and cookie name - * .example.com - * / - * some_cookie => cookie data - * /subdir - * other_cookie => cookie data - * .example.org - * ... - * - * @var array - */ - protected $cookies = array(); - - /** - * Whether session cookies should be serialized when serializing the jar - * @var bool - */ - protected $serializeSession = false; - - /** - * Whether Public Suffix List should be used for domain matching - * @var bool - */ - protected $useList = true; - - /** - * Array with Public Suffix List data - * @var array - * @link http://publicsuffix.org/ - */ - protected static $psl = array(); - - /** - * Class constructor, sets various options - * - * @param bool $serializeSessionCookies Controls serializing session cookies, - * see {@link serializeSessionCookies()} - * @param bool $usePublicSuffixList Controls using Public Suffix List, - * see {@link usePublicSuffixList()} - */ - public function __construct( - $serializeSessionCookies = false, $usePublicSuffixList = true - ) { - $this->serializeSessionCookies($serializeSessionCookies); - $this->usePublicSuffixList($usePublicSuffixList); - } - - /** - * Returns current time formatted in ISO-8601 at UTC timezone - * - * @return string - */ - protected function now() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - return $dt->format(DateTime::ISO8601); - } - - /** - * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields - * - * The checks are as follows: - * - cookie array should contain 'name' and 'value' fields; - * - name and value should not contain disallowed symbols; - * - 'expires' should be either empty parseable by DateTime; - * - 'domain' and 'path' should be either not empty or an URL where - * cookie was set should be provided. - * - if $setter is provided, then document at that URL should be allowed - * to set a cookie for that 'domain'. If $setter is not provided, - * then no domain checks will be made. - * - * 'expires' field will be converted to ISO8601 format from COOKIE format, - * 'domain' and 'path' will be set from setter URL if empty. - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @return array Updated cookie array - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - */ - protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) - { - if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { - throw new HTTP_Request2_LogicException( - "Cookie array should contain 'name' and 'value' fields", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie name: '{$cookie['name']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie value: '{$cookie['value']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); - - // Need ISO-8601 date @ UTC timezone - if (!empty($cookie['expires']) - && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires']) - ) { - try { - $dt = new DateTime($cookie['expires']); - $dt->setTimezone(new DateTimeZone('UTC')); - $cookie['expires'] = $dt->format(DateTime::ISO8601); - } catch (Exception $e) { - throw new HTTP_Request2_LogicException($e->getMessage()); - } - } - - if (empty($cookie['domain']) || empty($cookie['path'])) { - if (!$setter) { - throw new HTTP_Request2_LogicException( - 'Cookie misses domain and/or path component, cookie setter URL needed', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (empty($cookie['domain'])) { - if ($host = $setter->getHost()) { - $cookie['domain'] = $host; - } else { - throw new HTTP_Request2_LogicException( - 'Setter URL does not contain host part, can\'t set cookie domain', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - if (empty($cookie['path'])) { - $path = $setter->getPath(); - $cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); - } - } - - if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) { - throw new HTTP_Request2_MessageException( - "Domain " . $setter->getHost() . " cannot set cookies for " - . $cookie['domain'] - ); - } - - return $cookie; - } - - /** - * Stores a cookie in the jar - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @throws HTTP_Request2_Exception - */ - public function store(array $cookie, Net_URL2 $setter = null) - { - $cookie = $this->checkAndUpdateFields($cookie, $setter); - - if (strlen($cookie['value']) - && (is_null($cookie['expires']) || $cookie['expires'] > $this->now()) - ) { - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - - } elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) { - unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]); - } - } - - /** - * Adds cookies set in HTTP response to the jar - * - * @param HTTP_Request2_Response $response HTTP response message - * @param Net_URL2 $setter original request URL, needed for - * setting default domain/path - */ - public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter) - { - foreach ($response->getCookies() as $cookie) { - $this->store($cookie, $setter); - } - } - - /** - * Returns all cookies matching a given request URL - * - * The following checks are made: - * - cookie domain should match request host - * - cookie path should be a prefix for request path - * - 'secure' cookies will only be sent for HTTPS requests - * - * @param Net_URL2 $url Request url - * @param bool $asString Whether to return cookies as string for "Cookie: " header - * - * @return array|string Matching cookies - */ - public function getMatching(Net_URL2 $url, $asString = false) - { - $host = $url->getHost(); - $path = $url->getPath(); - $secure = 0 == strcasecmp($url->getScheme(), 'https'); - - $matched = $ret = array(); - foreach (array_keys($this->cookies) as $domain) { - if ($this->domainMatch($host, $domain)) { - foreach (array_keys($this->cookies[$domain]) as $cPath) { - if (0 === strpos($path, $cPath)) { - foreach ($this->cookies[$domain][$cPath] as $name => $cookie) { - if (!$cookie['secure'] || $secure) { - $matched[$name][strlen($cookie['path'])] = $cookie; - } - } - } - } - } - } - foreach ($matched as $cookies) { - krsort($cookies); - $ret = array_merge($ret, $cookies); - } - if (!$asString) { - return $ret; - } else { - $str = ''; - foreach ($ret as $c) { - $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value']; - } - return $str; - } - } - - /** - * Returns all cookies stored in a jar - * - * @return array - */ - public function getAll() - { - $cookies = array(); - foreach (array_keys($this->cookies) as $domain) { - foreach (array_keys($this->cookies[$domain]) as $path) { - foreach ($this->cookies[$domain][$path] as $name => $cookie) { - $cookies[] = $cookie; - } - } - } - return $cookies; - } - - /** - * Sets whether session cookies should be serialized when serializing the jar - * - * @param boolean $serialize serialize? - */ - public function serializeSessionCookies($serialize) - { - $this->serializeSession = (bool)$serialize; - } - - /** - * Sets whether Public Suffix List should be used for restricting cookie-setting - * - * Without PSL {@link domainMatch()} will only prevent setting cookies for - * top-level domains like '.com' or '.org'. However, it will not prevent - * setting a cookie for '.co.uk' even though only third-level registrations - * are possible in .uk domain. - * - * With the List it is possible to find the highest level at which a domain - * may be registered for a particular top-level domain and consequently - * prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by - * Firefox, Chrome and Opera browsers to restrict cookie setting. - * - * Note that PSL is licensed differently to HTTP_Request2 package (refer to - * the license information in public-suffix-list.php), so you can disable - * its use if this is an issue for you. - * - * @param boolean $useList use the list? - * - * @link http://publicsuffix.org/learn/ - */ - public function usePublicSuffixList($useList) - { - $this->useList = (bool)$useList; - } - - /** - * Returns string representation of object - * - * @return string - * - * @see Serializable::serialize() - */ - public function serialize() - { - $cookies = $this->getAll(); - if (!$this->serializeSession) { - for ($i = count($cookies) - 1; $i >= 0; $i--) { - if (empty($cookies[$i]['expires'])) { - unset($cookies[$i]); - } - } - } - return serialize(array( - 'cookies' => $cookies, - 'serializeSession' => $this->serializeSession, - 'useList' => $this->useList - )); - } - - /** - * Constructs the object from serialized string - * - * @param string $serialized string representation - * - * @see Serializable::unserialize() - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $now = $this->now(); - $this->serializeSessionCookies($data['serializeSession']); - $this->usePublicSuffixList($data['useList']); - foreach ($data['cookies'] as $cookie) { - if (!empty($cookie['expires']) && $cookie['expires'] <= $now) { - continue; - } - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - } - } - - /** - * Checks whether a cookie domain matches a request host. - * - * The method is used by {@link store()} to check for whether a document - * at given URL can set a cookie with a given domain attribute and by - * {@link getMatching()} to find cookies matching the request URL. - * - * @param string $requestHost request host - * @param string $cookieDomain cookie domain - * - * @return bool match success - */ - public function domainMatch($requestHost, $cookieDomain) - { - if ($requestHost == $cookieDomain) { - return true; - } - // IP address, we require exact match - if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) { - return false; - } - if ('.' != $cookieDomain[0]) { - $cookieDomain = '.' . $cookieDomain; - } - // prevents setting cookies for '.com' and similar domains - if (!$this->useList && substr_count($cookieDomain, '.') < 2 - || $this->useList && !self::getRegisteredDomain($cookieDomain) - ) { - return false; - } - return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain; - } - - /** - * Removes subdomains to get the registered domain (the first after top-level) - * - * The method will check Public Suffix List to find out where top-level - * domain ends and registered domain starts. It will remove domain parts - * to the left of registered one. - * - * @param string $domain domain name - * - * @return string|bool registered domain, will return false if $domain is - * either invalid or a TLD itself - */ - public static function getRegisteredDomain($domain) - { - $domainParts = explode('.', ltrim($domain, '.')); - - // load the list if needed - if (empty(self::$psl)) { - $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2'; - if (0 === strpos($path, '@' . 'data_dir@')) { - $path = realpath( - dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' - ); - } - self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php'; - } - - if (!($result = self::checkDomainsList($domainParts, self::$psl))) { - // known TLD, invalid domain name - return false; - } - - // unknown TLD - if (!strpos($result, '.')) { - // fallback to checking that domain "has at least two dots" - if (2 > ($count = count($domainParts))) { - return false; - } - return $domainParts[$count - 2] . '.' . $domainParts[$count - 1]; - } - return $result; - } - - /** - * Recursive helper method for {@link getRegisteredDomain()} - * - * @param array $domainParts remaining domain parts - * @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check - * - * @return string|null concatenated domain parts, null in case of error - */ - protected static function checkDomainsList(array $domainParts, $listNode) - { - $sub = array_pop($domainParts); - $result = null; - - if (!is_array($listNode) || is_null($sub) - || array_key_exists('!' . $sub, $listNode) - ) { - return $sub; - - } elseif (array_key_exists($sub, $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode[$sub]); - - } elseif (array_key_exists('*', $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode['*']); - - } else { - return $sub; - } - - return (strlen($result) > 0) ? ($result . '.' . $sub) : null; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Exception.php b/libs/PEAR.1.9.5/HTTP/Request2/Exception.php deleted file mode 100644 index d0b5d4ee0..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Exception.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Base exception class for HTTP_Request2 package - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ - /** An invalid argument was passed to a method */ - const INVALID_ARGUMENT = 1; - /** Some required value was not available */ - const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ - const MISCONFIGURATION = 3; - /** Error reading the local file */ - const READ_ERROR = 4; - - /** Server returned a response that does not conform to HTTP protocol */ - const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ - const DECODE_ERROR = 20; - /** Operation timed out */ - const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ - const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ - const NON_HTTP_REDIRECT = 50; - - /** - * Native error code - * @var int - */ - private $_nativeCode; - - /** - * Constructor, can set package error code and native error code - * - * @param string $message exception message - * @param int $code package error code, one of class constants - * @param int $nativeCode error code from underlying PHP extension - */ - public function __construct($message = null, $code = null, $nativeCode = null) - { - parent::__construct($message, $code); - $this->_nativeCode = $nativeCode; - } - - /** - * Returns error code produced by underlying PHP extension - * - * For Socket Adapter this may contain error number returned by - * stream_socket_client(), for Curl Adapter this will contain error number - * returned by curl_errno() - * - * @return integer - */ - public function getNativeCode() - { - return $this->_nativeCode; - } -} - -/** - * Exception thrown in case of missing features - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception -{ -} - -/** - * Exception that represents error in the program logic - * - * This exception usually implies a programmer's error, like passing invalid - * data to methods or trying to use PHP extensions that weren't installed or - * enabled. Usually exceptions of this kind will be thrown before request even - * starts. - * - * The exception will usually contain a package error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_LogicException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when connection to a web or proxy server fails - * - * The exception will not contain a package error code, but will contain - * native error code, as returned by stream_socket_client() or curl_errno(). - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when sending or receiving HTTP message fails - * - * The exception may contain both package error code and native error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_MessageException extends HTTP_Request2_Exception -{ -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php b/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php deleted file mode 100644 index c68b6602b..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception class for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array $params values of form fields set via - * {@link HTTP_Request2::addPostParameter()} - * @param array $uploads file uploads set via - * {@link HTTP_Request2::addUpload()} - * @param bool $useBrackets whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer $length Number of bytes to read - * - * @return string Up to $length bytes of data, empty string if at end - * @throws HTTP_Request2_LogicException - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf( - $this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0] - ) . $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf( - $this->_headerUpload, $boundary, $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type'] - ); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($filePos < $this->_uploads[$pos]['size']) { - while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) { - if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) { - throw new HTTP_Request2_LogicException( - 'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR - ); - } - $ret .= $chunk; - $length -= strlen($chunk); - } - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string $name name for item - * @param mixed $values item's values - * @param bool $useBrackets whether to append [] to array variables' names - * - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php b/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 341e29907..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBody', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBody': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf( - '< HTTP/%s %s %s', $event['data']->getVersion(), - $event['data']->getStatus(), $event['data']->getReasonPhrase() - )); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Response.php b/libs/PEAR.1.9.5/HTTP/Request2/Response.php deleted file mode 100644 index d2f414cf6..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Response.php +++ /dev/null @@ -1,631 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Effective URL (may be different from original request URL in case of redirects) - * @var string - */ - protected $effectiveUrl; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Returns the default reason phrase for the given code or all reason phrases - * - * @param int $code Response code - * - * @return string|array|null Default reason phrase for $code if $code is given - * (null if no phrase is available), array of all - * reason phrases if $code is null - * @link http://pear.php.net/bugs/18716 - */ - public static function getDefaultReasonPhrase($code = null) - { - if (null === $code) { - return self::$phrases; - } else { - return isset(self::$phrases[$code]) ? self::$phrases[$code] : null; - } - } - - /** - * Constructor, parses the response status line - * - * @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding - * @param string $effectiveUrl Effective URL of the response - * - * @throws HTTP_Request2_MessageException if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$statusLine}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - $this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code); - $this->bodyEncoded = (bool)$bodyEncoded; - $this->effectiveUrl = (string)$effectiveUrl; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string $headerLine Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - if ('' == $headerLine) { - // empty string signals the end of headers, process the received ones - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - // string of the form header-name: header value - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - // continuation of a previous header - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string $cookieString value of Set-Cookie header - * - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - if (!strpos($cookieString, ';')) { - // Only a name=value pair - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - } else { - // Some optional parameters are supplied - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * - * @param string $bodyChunk part of response body - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the effective URL of the response - * - * This may be different from the request URL if redirects were followed. - * - * @return string - * @link http://pear.php.net/bugs/bug.php?id=18412 - */ - public function getEffectiveUrl() - { - return $this->effectiveUrl; - } - - /** - * Returns the status code - * - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string $headerName Name of header to return - * - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (0 == strlen($this->body) || !$this->bodyEncoded - || !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string $data gzip-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: unknown compression method', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: reserved bits are set', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_MessageException( - 'Header CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_MessageException( - 'gzinflate() call failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_MessageException( - 'Data size check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception( - 'Data CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string $data deflate-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php b/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php deleted file mode 100644 index d54049585..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Socket wrapper class used by Socket Adapter */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * SOCKS5 proxy connection class (used by Socket Adapter) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper -{ - /** - * Constructor, tries to connect and authenticate to a SOCKS5 proxy - * - * @param string $address Proxy address, e.g. 'tcp://localhost:1080' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Stream context options - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function __construct( - $address, $timeout = 10, array $contextOptions = array(), - $username = null, $password = null - ) { - parent::__construct($address, $timeout, $contextOptions); - - if (strlen($username)) { - $request = pack('C4', 5, 2, 0, 2); - } else { - $request = pack('C3', 5, 1, 0); - } - $this->write($request); - $response = unpack('Cversion/Cmethod', $this->read(3)); - if (5 != $response['version']) { - throw new HTTP_Request2_MessageException( - 'Invalid version received from SOCKS5 proxy: ' . $response['version'], - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - switch ($response['method']) { - case 2: - $this->performAuthentication($username, $password); - case 0: - break; - default: - throw new HTTP_Request2_ConnectionException( - "Connection rejected by proxy due to unsupported auth method" - ); - } - } - - /** - * Performs username/password authentication for SOCKS5 - * - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1929 - */ - protected function performAuthentication($username, $password) - { - $request = pack('C2', 1, strlen($username)) . $username - . pack('C', strlen($password)) . $password; - - $this->write($request); - $response = unpack('Cvn/Cstatus', $this->read(3)); - if (1 != $response['vn'] || 0 != $response['status']) { - throw new HTTP_Request2_ConnectionException( - 'Connection rejected by proxy due to invalid username and/or password' - ); - } - } - - /** - * Connects to a remote host via proxy - * - * @param string $remoteHost Remote host - * @param int $remotePort Remote port - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function connect($remoteHost, $remotePort) - { - $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) - . $remoteHost . pack('n', $remotePort); - - $this->write($request); - $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); - if (5 != $response['version'] || 0 != $response['reserved']) { - throw new HTTP_Request2_MessageException( - 'Invalid response received from SOCKS5 proxy', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } elseif (0 != $response['reply']) { - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", - 0, $response['reply'] - ); - } - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php b/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php deleted file mode 100644 index 43081a196..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception classes for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Socket wrapper class used by Socket Adapter - * - * Needed to properly handle connection errors, global timeout support and - * similar things. Loosely based on Net_Socket used by older HTTP_Request. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SocketWrapper -{ - /** - * PHP warning messages raised during stream_socket_client() call - * @var array - */ - protected $connectionWarnings = array(); - - /** - * Connected socket - * @var resource - */ - protected $socket; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline; - - /** - * Global timeout value, mostly for exception messages - * @var integer - */ - protected $timeout; - - /** - * Class constructor, tries to establish connection - * - * @param string $address Address for stream_socket_client() call, - * e.g. 'tcp://localhost:80' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Context options - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - */ - public function __construct($address, $timeout, array $contextOptions = array()) - { - if (!empty($contextOptions) - && !isset($contextOptions['socket']) && !isset($contextOptions['ssl']) - ) { - // Backwards compatibility with 2.1.0 and 2.1.1 releases - $contextOptions = array('ssl' => $contextOptions); - } - $context = stream_context_create(); - foreach ($contextOptions as $wrapper => $options) { - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, $wrapper, $name, $value)) { - throw new HTTP_Request2_LogicException( - "Error setting '{$wrapper}' wrapper context option '{$name}'" - ); - } - } - } - set_error_handler(array($this, 'connectionWarningsHandler')); - $this->socket = stream_socket_client( - $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context - ); - restore_error_handler(); - // if we fail to bind to a specified local address (see request #19515), - // connection still succeeds, albeit with a warning. Throw an Exception - // with the warning text in this case as that connection is unlikely - // to be what user wants and as Curl throws an error in similar case. - if ($this->connectionWarnings) { - if ($this->socket) { - fclose($this->socket); - } - $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings); - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$address}. Error: {$error}", 0, $errno - ); - } - } - - /** - * Destructor, disconnects socket - */ - public function __destruct() - { - fclose($this->socket); - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int $length Reads up to this number of bytes - * - * @return string Data read from socket - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function read($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $this->checkTimeout(); - return $data; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int $bufferSize buffer size to use for reading - * @param int $localTimeout timeout value to use just for this call - * (used when waiting for "100 Continue" response) - * - * @return string Available data up to the newline (not including newline) - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function readLine($bufferSize, $localTimeout = null) - { - $line = ''; - while (!feof($this->socket)) { - if (null !== $localTimeout) { - stream_set_timeout($this->socket, $localTimeout); - } elseif ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - - $line .= @fgets($this->socket, $bufferSize); - - if (null === $localTimeout) { - $this->checkTimeout(); - - } else { - $info = stream_get_meta_data($this->socket); - // reset socket timeout if we don't have request timeout specified, - // prevents further calls failing with a bogus Exception - if (!$this->deadline) { - $default = (int)@ini_get('default_socket_timeout'); - stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX); - } - if ($info['timed_out']) { - throw new HTTP_Request2_MessageException( - "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT - ); - } - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fwrite(), handles global request timeout - * - * @param string $data String to be written - * - * @return int - * @throws HTTP_Request2_MessageException - */ - public function write($data) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $written = fwrite($this->socket, $data); - $this->checkTimeout(); - // http://www.php.net/manual/en/function.fwrite.php#96951 - if ($written < strlen($data)) { - throw new HTTP_Request2_MessageException('Error writing request'); - } - return $written; - } - - /** - * Tests for end-of-file on a socket - * - * @return bool - */ - public function eof() - { - return feof($this->socket); - } - - /** - * Sets request deadline - * - * @param int $deadline Exception will be thrown if request continues - * past this time - * @param int $timeout Original request timeout value, to use in - * Exception message - */ - public function setDeadline($deadline, $timeout) - { - $this->deadline = $deadline; - $this->timeout = $timeout; - } - - /** - * Turns on encryption on a socket - * - * @throws HTTP_Request2_ConnectionException - */ - public function enableCrypto() - { - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_ConnectionException( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Throws an Exception if stream timed out - * - * @throws HTTP_Request2_MessageException - */ - protected function checkTimeout() - { - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? "after {$this->timeout} second(s)" - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_MessageException( - "Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT - ); - } - } - - /** - * Error handler to use during stream_socket_client() call - * - * One stream_socket_client() call may produce *multiple* PHP warnings - * (especially OpenSSL-related), we keep them in an array to later use for - * the message of HTTP_Request2_ConnectionException - * - * @param int $errno error level - * @param string $errstr error message - * - * @return bool - */ - protected function connectionWarningsHandler($errno, $errstr) - { - if ($errno & E_WARNING) { - array_unshift($this->connectionWarnings, $errstr); - } - return true; - } -} -?> diff --git a/libs/PEAR.1.9.5/Net/URL2.php b/libs/PEAR.1.9.5/Net/URL2.php deleted file mode 100644 index d5bab1141..000000000 --- a/libs/PEAR.1.9.5/Net/URL2.php +++ /dev/null @@ -1,1219 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version CVS: $Id$ - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: 2.1.1 - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * Drop zero-based integer sequences in query using PHP's [] notation. Default - * is true. - */ - const OPTION_DROP_SEQUENCE = 'drop_sequence'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_DROP_SEQUENCE => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - * - * @uses self::parseUrl() - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - $this->parseUrl($url); - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return $this - * @see getScheme - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - return $this; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('(:.*$)', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return $this - */ - public function setUserinfo($userinfo, $password = false) - { - if ($password !== false) { - $userinfo .= ':' . $password; - } - - if ($userinfo !== false) { - $userinfo = $this->_encodeData($userinfo); - } - - $this->_userinfo = $userinfo; - return $this; - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return $this - */ - public function setHost($host) - { - $this->_host = $host; - return $this; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return $this - */ - public function setPort($port) - { - $this->_port = $port; - return $this; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (false === $this->_host) { - return false; - } - - $authority = ''; - - if (strlen($this->_userinfo)) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|bool $authority a hostname or an IP address, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return $this - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - - if ('' === $authority) { - $this->_host = $authority; - return $this; - } - - if (!preg_match('(^(([^\@]*)\@)?(.+?)(:(\d*))?$)', $authority, $matches)) { - return $this; - } - - if ($matches[1]) { - $this->_userinfo = $this->_encodeData($matches[2]); - } - - $this->_host = $matches[3]; - - if (isset($matches[5]) && strlen($matches[5])) { - $this->_port = $matches[5]; - } - return $this; - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return $this - */ - public function setPath($path) - { - $this->_path = $path; - return $this; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see getQueryVariables - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return $this - * @see setQueryVariables - */ - public function setQuery($query) - { - $this->_query = $query; - return $this; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return $this - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - return $this; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $separator = $this->getOption(self::OPTION_SEPARATOR_INPUT); - $encodeKeys = $this->getOption(self::OPTION_ENCODE_KEYS); - $useBrackets = $this->getOption(self::OPTION_USE_BRACKETS); - - $return = array(); - - for ($part = strtok($this->_query, $separator); - strlen($part); - $part = strtok($separator) - ) { - list($key, $value) = explode('=', $part, 2) + array(1 => ''); - - if ($encodeKeys) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($useBrackets) { - $return = $this->_queryArrayByKey($key, $value, $return); - } else { - if (isset($return[$key])) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - } - - return $return; - } - - /** - * Parse a single query key=value pair into an existing php array - * - * @param string $key query-key - * @param string $value query-value - * @param array $array of existing query variables (if any) - * - * @return mixed - */ - private function _queryArrayByKey($key, $value, array $array = array()) - { - if (!strlen($key)) { - return $array; - } - - $offset = $this->_queryKeyBracketOffset($key); - if ($offset === false) { - $name = $key; - } else { - $name = substr($key, 0, $offset); - } - - if (!strlen($name)) { - return $array; - } - - if (!$offset) { - // named value - $array[$name] = $value; - } else { - // array - $brackets = substr($key, $offset); - if (!isset($array[$name])) { - $array[$name] = null; - } - $array[$name] = $this->_queryArrayByBrackets( - $brackets, $value, $array[$name] - ); - } - - return $array; - } - - /** - * Parse a key-buffer to place value in array - * - * @param string $buffer to consume all keys from - * @param string $value to be set/add - * @param array $array to traverse and set/add value in - * - * @throws Exception - * @return array - */ - private function _queryArrayByBrackets($buffer, $value, array $array = null) - { - $entry = &$array; - - for ($iteration = 0; strlen($buffer); $iteration++) { - $open = $this->_queryKeyBracketOffset($buffer); - if ($open !== 0) { - // Opening bracket [ must exist at offset 0, if not, there is - // no bracket to parse and the value dropped. - // if this happens in the first iteration, this is flawed, see - // as well the second exception below. - if ($iteration) { - break; - } - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Opening bracket [ must exist at offset 0' - ); - // @codeCoverageIgnoreEnd - } - - $close = strpos($buffer, ']', 1); - if (!$close) { - // this error condition should never be reached as this is a - // private method and bracket pairs are checked beforehand. - // See as well the first exception for the opening bracket. - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Closing bracket ] must exist, not found' - ); - // @codeCoverageIgnoreEnd - } - - $index = substr($buffer, 1, $close - 1); - if (strlen($index)) { - $entry = &$entry[$index]; - } else { - if (!is_array($entry)) { - $entry = array(); - } - $entry[] = &$new; - $entry = &$new; - unset($new); - } - $buffer = substr($buffer, $close + 1); - } - - $entry = $value; - - return $array; - } - - /** - * Query-key has brackets ("...[]") - * - * @param string $key query-key - * - * @return bool|int offset of opening bracket, false if no brackets - */ - private function _queryKeyBracketOffset($key) - { - if (false !== $open = strpos($key, '[') - and false === strpos($key, ']', $open + 1) - ) { - $open = false; - } - - return $open; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return $this - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - $this->_query = $this->buildQuery( - $array, - $this->getOption(self::OPTION_SEPARATOR_OUTPUT) - ); - } - return $this; - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return $this - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - return $this; - } - - /** - * Removes the specified variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ''; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority === false && strtolower($this->_scheme) === 'file') { - $authority = ''; - } - - $url .= $this->_buildAuthorityAndPath($authority, $this->_path); - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Put authority and path together, wrapping authority - * into proper separators/terminators. - * - * @param string|bool $authority authority - * @param string $path path - * - * @return string - */ - private function _buildAuthorityAndPath($authority, $path) - { - if ($authority === false) { - return $path; - } - - $terminator = ($path !== '' && $path[0] !== '/') ? '/' : ''; - - return '//' . $authority . $terminator . $path; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @link https://php.net/language.oop5.magic#object.tostring - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Normalizes the URL - * - * See RFC 3986, Section 6. Normalization and Comparison - * - * @link https://tools.ietf.org/html/rfc3986#section-6 - * - * @return void - */ - public function normalize() - { - // See RFC 3986, section 6 - - // Scheme is case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostname is case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ('' === $this->_port - || $this->_port - && $this->_scheme - && $this->_port == getservbyname($this->_scheme, 'tcp') - ) { - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - // Normalize percentage-encoded unreserved characters (section 6.2.2.2) - $fields = array(&$this->_userinfo, &$this->_host, &$this->_path, - &$this->_query, &$this->_fragment); - foreach ($fields as &$field) { - if ($field !== false) { - $field = $this->_normalize("$field"); - } - } - unset($field); - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if (false !== $this->_host && '' === $this->_path) { - $this->_path = '/'; - } - - // path should start with '/' if there is authority (section 3.3.) - if (strlen($this->getAuthority()) - && strlen($this->_path) - && $this->_path[0] !== '/' - ) { - $this->_path = '/' . $this->_path; - } - } - - /** - * Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - * Normalize percentage-encoded unreserved characters (section 6.2.2.2) - * - * @param string|array $mixed string or array of strings to normalize - * - * @return string|array - * @see normalize - * @see _normalizeCallback() - */ - private function _normalize($mixed) - { - return preg_replace_callback( - '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), - $mixed - ); - } - - /** - * Callback for _normalize() of %XX percentage-encodings - * - * @param array $matches as by preg_replace_callback - * - * @return string - * @see normalize - * @see _normalize - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _normalizeCallback($matches) - { - return self::urlencode(urldecode($matches[0])); - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @throws Exception - * @return $this - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { - throw new Exception( - 'Base-URL must be absolute if reference is not fragment-only' - ); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) - && $reference->_scheme == $this->_scheme - ) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $reference->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * URL is fragment-only - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @return bool - */ - private function _isFragmentOnly() - { - return ( - $this->_fragment !== false - && $this->_query === false - && $this->_path === '' - && $this->_port === false - && $this->_host === false - && $this->_userinfo === false - && $this->_scheme === false - ); - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $path = (string) $path; - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $loopLimit = 256; - $j = 0; - while ('' !== $path && $j++ < $loopLimit) { - if (substr($path, 0, 2) === './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) === '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) === '/./' || $path === '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) === '/../' || $path === '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path === '.' || $path === '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/', $path[0] === '/'); - if ($i === false) { - $output .= $path; - $path = ''; - break; - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - if ($path !== '') { - $message = sprintf( - 'Unable to remove dot segments; hit loop limit %d (left: %s)', - $j, var_export($path, true) - ); - trigger_error($message, E_USER_WARNING); - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param string $string string to encode - * - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @throws Exception - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 - || $url->_scheme == 'https' && $port != 443 - ) { - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @throws Exception - * @return $this - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - public function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } - - /** - * A simple version of http_build_query in userland. The encoded string is - * percentage encoded according to RFC 3986. - * - * @param array $data An array, which has to be converted into - * QUERY_STRING. Anything is possible. - * @param string $separator Separator {@link self::OPTION_SEPARATOR_OUTPUT} - * @param string $key For stacked values (arrays in an array). - * - * @return string - */ - protected function buildQuery(array $data, $separator, $key = null) - { - $query = array(); - $drop_names = ( - $this->_options[self::OPTION_DROP_SEQUENCE] === true - && array_keys($data) === array_keys(array_values($data)) - ); - foreach ($data as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { - $name = rawurlencode($name); - } - if ($key !== null) { - if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { - $drop_names && $name = ''; - $name = $key . '[' . $name . ']'; - } else { - $name = $key; - } - } - if (is_array($value)) { - $query[] = $this->buildQuery($value, $separator, $name); - } else { - $query[] = $name . '=' . rawurlencode($value); - } - } - return implode($separator, $query); - } - - /** - * This method uses a regex to parse the url into the designated parts. - * - * @param string $url URL - * - * @return void - * @uses self::$_scheme, self::setAuthority(), self::$_path, self::$_query, - * self::$_fragment - * @see __construct - */ - protected function parseUrl($url) - { - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match( - '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', - $url, $matches - ); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $this->_encodeData($matches[5]); - $this->_query = !empty($matches[6]) - ? $this->_encodeData($matches[7]) - : false - ; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Encode characters that might have been forgotten to encode when passing - * in an URL. Applied onto Userinfo, Path and Query. - * - * @param string $url URL - * - * @return string - * @see parseUrl - * @see setAuthority - * @link https://pear.php.net/bugs/bug.php?id=20425 - */ - private function _encodeData($url) - { - return preg_replace_callback( - '([\x-\x20\x22\x3C\x3E\x7F-\xFF]+)', - array($this, '_encodeCallback'), $url - ); - } - - /** - * callback for encoding character data - * - * @param array $matches Matches - * - * @return string - * @see _encodeData - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _encodeCallback(array $matches) - { - return rawurlencode($matches[0]); - } -} diff --git a/libs/PEAR.1.9.5/PEAR.php b/libs/PEAR.1.9.5/PEAR.php deleted file mode 100644 index e6f8edc2a..000000000 --- a/libs/PEAR.1.9.5/PEAR.php +++ /dev/null @@ -1,1063 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2010 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - - if ($error_class !== null) { - $this->_error_class = $error_class; - } - - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - - return $properties[$class][$var]; - } - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (!is_a($data, 'PEAR_Error')) { - return false; - } - - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } - - return $data->getCode() == $code; - } - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return count($this->_expected_errors); - } - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - foreach ($this->_expected_errors as $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - - return $deleted; - } - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; we walk through it trying - // to unset all values - foreach ($error_code as $key => $error) { - $deleted = $this->_checkDelExpect($error) ? true : false; - } - - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } - - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if ( - isset($this) && - isset($this->_expected_errors) && - count($this->_expected_errors) > 0 && - count($exp = end($this->_expected_errors)) - ) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp)) - ) { - $mode = PEAR_ERROR_RETURN; - } - } - - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - - if (intval(PHP_VERSION) < 5) { - // little non-eval hack to fix bug #12147 - include 'PEAR/FixPHP5PEARWarnings.php'; - return $a; - } - - if ($skipmsg) { - $a = new $ec($code, $mode, $options, $userinfo); - } else { - $a = new $ec($message, $code, $mode, $options, $userinfo); - } - - return $a; - } - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @access public - * @return object a PEAR error object - * @see PEAR::raiseError - */ - function &throwError($message = null, $code = null, $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } - - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - /** - * OS independent PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (extension_loaded($ext)) { - return true; - } - - // if either returns true dl() will produce a FATAL error, stop that - if ( - function_exists('dl') === false || - ini_get('enable_dl') != 1 || - ini_get('safe_mode') == 1 - ) { - return false; - } - - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } -} - -if (PEAR_ZE2) { - include_once 'PEAR5.php'; -} - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR_ZE2) { - $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); - } else { - $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); - } - - if ($destructLifoExists) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if ( - isset($GLOBALS['_PEAR_shutdown_funcs']) && - is_array($GLOBALS['_PEAR_shutdown_funcs']) && - !empty($GLOBALS['_PEAR_shutdown_funcs']) - ) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - - if (PEAR_ZE2) { - $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); - } else { - $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); - } - - if (!$skiptrace) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - - $this->level = $options; - $this->callback = null; - } - - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - - printf($format, $this->getMessage()); - } - - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - - if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() - { - return $this->mode; - } - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() - { - return $this->callback; - } - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - function __toString() - { - return $this->getMessage(); - } - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() - { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/libs/PEAR.1.9.5/PEAR/Exception.php b/libs/PEAR.1.9.5/PEAR/Exception.php deleted file mode 100644 index 2990cb612..000000000 --- a/libs/PEAR.1.9.5/PEAR/Exception.php +++ /dev/null @@ -1,389 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.3.3 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category pear - * @package PEAR - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.3.3 - * - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * @param string exception message - * @param int|Exception|PEAR_Error|array|null exception cause - * @param int|null exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception('exception cause must be Exception, ' . - 'array, or PEAR_Error'); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - private function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * @access public - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * @param array - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message']) . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) $args[] = 'null'; - elseif (is_array($arg)) $args[] = 'Array'; - elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')'; - elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; - elseif (is_int($arg) || is_double($arg)) $args[] = $arg; - else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16)); - if (strlen($arg) > 16) $str .= '…'; - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ',$args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} \ No newline at end of file diff --git a/libs/PEAR.1.9.5/PEAR5.php b/libs/PEAR.1.9.5/PEAR5.php deleted file mode 100644 index 428606780..000000000 --- a/libs/PEAR.1.9.5/PEAR5.php +++ /dev/null @@ -1,33 +0,0 @@ -setHeader($name, $value); - } - - public function sendRequest($saveBody = true) - { - $response = $this->send(); - $this->response = $response; - return $response; - } - - public function getResponseCode() { - if($this->response) - { - return $this->response->getStatus(); - } - } - - public function getResponseHeader() { - if($this->response) - { - return $this->response->getHeader(); - } - } - - public function getResponseBody() { - if($this->response) - { - return $this->response->getBody(); - } - } - - public function getResponseCookies() { - if($this->response) - { - return $this->response->getCookies(); - } - } - - public function addPostData($name, $value, $preencoded = false) - { - $this->addPostParameter($name, $value); - } - -} - -?> diff --git a/libs/PEAR.1.9/HTTP/Request2.php b/libs/PEAR.1.9/HTTP/Request2.php deleted file mode 100644 index 1347d6ece..000000000 --- a/libs/PEAR.1.9/HTTP/Request2.php +++ /dev/null @@ -1,861 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Request2.php 298246 2010-04-21 10:41:16Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 Request URL - * @param string Request method - * @param array Configuration for this Request instance - */ - public function __construct($url = null, $method = self::METHOD_GET, array $config = array()) - { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader('user-agent', 'HTTP_Request2/0.5.2 ' . - '(http://pear.php.net/package/http_request2) ' . - 'PHP/' . phpversion()); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 Request URL - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_Exception('Parameter is not a valid HTTP URL'); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_Exception("Invalid request method '{$method}'"); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed parameter value if $nameOrConfig is not an array - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_Exception( - "Unknown configuration parameter '{$nameOrConfig}'" - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string parameter name - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_Exception If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_Exception( - "Unknown configuration parameter '{$name}'" - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string user name - * @param string password - * @param string authentication scheme - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array header name, header string ('Header: value') - * or an array of headers - * @param string|null header value, header will be removed if null - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setHeader($name, $value = null) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v); - } else { - $this->setHeader($v); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_Exception("Invalid header name '{$name}'"); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - } else { - $this->headers[$name] = $value; - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string cookie name - * @param string cookie value - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function addCookie($name, $value) - { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_Exception("Invalid cookie: '{$cookie}'"); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - - return $this; - } - - /** - * Sets the request body - * - * @param string Either a string with the body or filename containing body - * @param bool Whether first parameter is a filename - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - if (!($fp = @fopen($body, 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$body}"); - } - $this->body = $fp; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', self::detectMimeType($body)); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method && - (!empty($this->postParams) || !empty($this->uploads)) - ) { - if ('application/x-www-form-urlencoded' == $this->headers['content-type']) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif ('multipart/form-data' == $this->headers['content-type']) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * @param string name of file-upload field - * @param mixed full name of local file - * @param string filename to send in the request - * @param string content-type of file being uploaded - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function addUpload($fieldName, $filename, $sendFilename = null, - $contentType = null) - { - if (!is_array($filename)) { - if (!($fp = @fopen($filename, 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$filename}"); - } - $this->uploads[$fieldName] = array( - 'fp' => $fp, - 'filename' => empty($sendFilename)? basename($filename): $sendFilename, - 'size' => filesize($filename), - 'type' => empty($contentType)? self::detectMimeType($filename): $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - if (!($fp = @fopen($f[0], 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$f[0]}"); - } - $fps[] = $fp; - $names[] = empty($f[1])? basename($f[0]): $f[1]; - $sizes[] = filesize($f[0]); - $types[] = empty($f[2])? self::detectMimeType($f[0]): $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) || - 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array parameter name or array ('name' => 'value') - * @param mixed parameter value (can be an array) - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string event name - * @param mixed event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter)) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_Exception("Class {$adapter} not found"); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_Exception('Parameter is not a HTTP request adapter'); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2) { - throw new HTTP_Request2_Exception('No URL given'); - } elseif (!$this->url->isAbsolute()) { - throw new HTTP_Request2_Exception('Absolute URL required'); - } elseif (!in_array(strtolower($this->url->getScheme()), array('https', 'http'))) { - throw new HTTP_Request2_Exception('Not a HTTP URL'); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string filename - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter.php b/libs/PEAR.1.9/HTTP/Request2/Adapter.php deleted file mode 100644 index 8ebbf4607..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,154 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Adapter.php 291118 2009-11-21 17:58:23Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array associative array of request headers, this method will - * add proper 'Content-Length' and 'Content-Type' headers - * to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - $headers['content-length'] = $this->contentLength; - } - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index 3d9833403..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,461 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Curl.php 291118 2009-11-21 17:58:23Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_Exception('cURL extension not available'); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $errorMessage = 'Error sending request: #' . curl_errno($ch) . - ' ' . curl_error($ch); - } - } catch (Exception $e) { - } - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } elseif (!empty($errorMessage)) { - throw new HTTP_Request2_Exception($errorMessage); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_Exception - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works sometime after 5.3.0, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR ')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_Exception('Proxy port not provided'); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $user . ':' . - $this->request->getConfig('proxy_password')); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - if (0 == strcasecmp($this->request->getUrl()->getScheme(), 'https')) { - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource cURL handle - * @param array Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - // rewind may be needed, read the whole body into memory - } else { - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource cURL handle - * @param resource file descriptor (not used) - * @param integer maximum length of data to return - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource cURL handle - * @param string response header (with trailing CRLF) - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders || - $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response($string, false); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - // for versions lower than 5.2.10, check the redirection URL protocol - if ($this->request->getConfig('follow_redirects') && !defined('CURLOPT_REDIR_PROTOCOLS') - && $this->response->isRedirect() - ) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource cURL handle (not used) - * @param string part of the response body - * @return integer number of bytes saved - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_Exception("Malformed response: {$string}"); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index fdedccac0..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,171 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Mock.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * If the queue is empty it will return default empty response with status 400, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (count($this->responses) > 0) { - $response = array_shift($this->responses); - if ($response instanceof HTTP_Request2_Response) { - return $response; - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } else { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - } - } - - /** - * Adds response to the queue - * - * @param mixed either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @throws HTTP_Request2_Exception - */ - public function addResponse($response) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource file pointer returned by fopen() - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index a9c9ea361..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1046 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Socket.php 290921 2009-11-18 17:31:58Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?:\\\\.|[^\\\\"])*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var resource - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline = null; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $request->getConfig('timeout')) { - $this->deadline = time() + $timeout; - } else { - $this->deadline = null; - } - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - if (false === @fwrite($this->socket, $headers, strlen($headers))) { - throw new HTTP_Request2_Exception('Error writing request'); - } - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - $this->writeBody(); - - if ($this->deadline && time() > $this->deadline) { - throw new HTTP_Request2_Exception( - 'Request timed out after ' . - $request->getConfig('timeout') . ' second(s)' - ); - } - - $response = $this->readResponse(); - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_Exception('Proxy port not provided'); - } - $proxy = true; - } else { - $host = $reqHost; - $port = $reqPort; - $proxy = false; - } - - if ($tunnel && !$proxy) { - throw new HTTP_Request2_Exception( - "Trying to perform CONNECT request without proxy" - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_Exception( - 'Need OpenSSL support for https:// requests' - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($proxy && !$secure && - !empty($headers['connection']) && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - $host = ((!$secure || $proxy)? 'tcp://': 'ssl://') . $host; - - $options = array(); - if ($secure || $tunnel) { - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['CN_match'] = $reqHost; - } - } else { - $options[substr($name, 4)] = $value; - } - } - } - ksort($options); - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = $host . ':' . $port; - $socketKey = $remote . (($secure && $proxy)? "->{$reqHost}:{$reqPort}": '') . - (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) && - !feof(self::$sockets[$socketKey]) - ) { - $this->socket =& self::$sockets[$socketKey]; - - } elseif ($secure && $proxy && !$tunnel) { - $this->establishTunnel(); - $this->request->setLastEvent( - 'connect', "ssl://{$reqHost}:{$reqPort} via {$host}:{$port}" - ); - self::$sockets[$socketKey] =& $this->socket; - - } else { - // Set SSL context options if doing HTTPS request or creating a tunnel - $context = stream_context_create(); - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, 'ssl', $name, $value)) { - throw new HTTP_Request2_Exception( - "Error setting SSL context option '{$name}'" - ); - } - } - $this->socket = @stream_socket_client( - $remote, $errno, $errstr, - $this->request->getConfig('connect_timeout'), - STREAM_CLIENT_CONNECT, $context - ); - if (!$this->socket) { - throw new HTTP_Request2_Exception( - "Unable to connect to {$remote}. Error #{$errno}: {$errstr}" - ); - } - $this->request->setLastEvent('connect', $remote); - self::$sockets[$socketKey] =& $this->socket; - } - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), - array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_Exception( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_Exception( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean whether connection could be persistent - * in the first place - * @param HTTP_Request2_Response response object to check - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && - 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) || - null !== $response->getHeader('content-length'); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (is_resource($this->socket)) { - fclose($this->socket); - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 Original request - * @param HTTP_Request2_Response Response containing redirect - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect(HTTP_Request2 $request, - HTTP_Request2_Response $response) - { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - // Copying cURL behaviour - throw new HTTP_Request2_Exception( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed' - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - throw new HTTP_Request2_Exception( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString() - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response response to check - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) || - (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) && - (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response response to check - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) && - (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string value of WWW-Authenticate or Proxy-Authenticate header - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) && - !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_Exception( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_Exception( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array challenge to update - * @param string value of [Proxy-]Authentication-Info header - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string user name - * @param string password - * @param string request URL - * @param array digest challenge parameters - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) && - $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array request headers - * @param string request host (needed for digest authentication) - * @param string request URL (needed for digest authentication) - * @throws HTTP_Request2_Exception - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = - 'Basic ' . base64_encode($auth['user'] . ':' . $auth['password']); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_Exception( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array request headers - * @param string request URL (needed for digest authentication) - * @throws HTTP_Request2_Exception - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') || - !($user = $this->request->getConfig('proxy_user')) || - (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) && - HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = - 'Basic ' . base64_encode($user . ':' . $password); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_Exception( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') || - 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') && - extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_Exception - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (false === @fwrite($this->socket, $str, strlen($str))) { - throw new HTTP_Request2_Exception('Error writing request'); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - - do { - $response = new HTTP_Request2_Response($this->readLine($bufferSize), true); - do { - $headerLine = $this->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() || - (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && - 200 <= $response->getStatus() && 300 > $response->getStatus()) || - in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!feof($this->socket) && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->fread($bufferSize); - } else { - $data = $this->fread(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || feof($this->socket))) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int buffer size to use for reading - * @return Available data up to the newline (not including newline) - * @throws HTTP_Request2_Exception In case of timeout - */ - protected function readLine($bufferSize) - { - $line = ''; - while (!feof($this->socket)) { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $line .= @fgets($this->socket, $bufferSize); - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? 'after ' . $this->request->getConfig('timeout') . ' second(s)' - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_Exception("Request timed out {$reason}"); - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int Reads up to this number of bytes - * @return Data read from socket - * @throws HTTP_Request2_Exception In case of timeout - */ - protected function fread($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? 'after ' . $this->request->getConfig('timeout') . ' second(s)' - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_Exception("Request timed out {$reason}"); - } - return $data; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int buffer size to use for reading - * @return string - * @throws HTTP_Request2_Exception - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_Exception( - "Cannot decode chunked response, invalid chunk length '{$line}'" - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->readLine($bufferSize); - return ''; - } - } - } - $data = $this->fread(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Exception.php b/libs/PEAR.1.9/HTTP/Request2/Exception.php deleted file mode 100644 index 2b960fc20..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Exception.php +++ /dev/null @@ -1,62 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Exception.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Exception class for HTTP_Request2 package - * - * Such a class is required by the Exception RFC: - * http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - * - * @category HTTP - * @package HTTP_Request2 - * @version Release: 0.5.2 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php b/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php deleted file mode 100644 index f640de3e7..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,274 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: MultipartBody.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array values of form fields set via {@link HTTP_Request2::addPostParameter()} - * @param array file uploads set via {@link HTTP_Request2::addUpload()} - * @param bool whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer Amount of bytes to read - * @return string Up to $length bytes of data, empty string if at end - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf($this->_headerParam, $boundary, - $this->_params[$this->_pos[0]][0]) . - $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf($this->_headerUpload, $boundary, - $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], - $this->_uploads[$pos]['type']); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($length > 0 && $filePos < $this->_uploads[$pos]['size']) { - $ret .= fread($this->_uploads[$pos]['fp'], $length); - $length -= min($length, $this->_uploads[$pos]['size'] - $filePos); - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @param bool whether to append [] to array variables' names - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php b/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 7df821ef4..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,215 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Log.php 293416 2010-01-11 18:06:15Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 0.5.2 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBodyPart', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBodyPart': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf('< HTTP/%s %s %s', - $event['data']->getVersion(), - $event['data']->getStatus(), - $event['data']->getReasonPhrase())); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Response.php b/libs/PEAR.1.9/HTTP/Request2/Response.php deleted file mode 100644 index f27ea51f4..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Response.php +++ /dev/null @@ -1,559 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Response.php 290520 2009-11-11 20:09:42Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Constructor, parses the response status line - * - * @param string Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool Whether body is still encoded by Content-Encoding - * @throws HTTP_Request2_Exception if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_Exception("Malformed response: {$statusLine}"); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - if (!empty($m[3])) { - $this->reasonPhrase = trim($m[3]); - } elseif (!empty(self::$phrases[$this->code])) { - $this->reasonPhrase = self::$phrases[$this->code]; - } - $this->bodyEncoded = (bool)$bodyEncoded; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - // empty string signals the end of headers, process the received ones - if ('' == $headerLine) { - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - // string of the form header-name: header value - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - // continuation of a previous header - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string value of Set-Cookie header - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($cookieString, ';')) { - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * @param string - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the status code - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string Name of header to return - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (!$this->bodyEncoded || - !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string gzip-encoded data - * @return string decoded data - * @throws HTTP_Request2_Exception - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_Exception('Unable to decode body: gzip extension not available'); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_Exception('Error parsing gzip header: unknown compression method'); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_Exception('Error parsing gzip header: reserved bits are set'); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_Exception('Header CRC check failed'); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_Exception('gzinflate() call failed'); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_Exception('Data size check failed'); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception('Data CRC check failed'); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string deflate-encoded data - * @return string decoded data - * @throws HTTP_Request2_Exception - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_Exception('Unable to decode body: gzip extension not available'); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/Net/URL2.php b/libs/PEAR.1.9/Net/URL2.php deleted file mode 100644 index bbc9f124d..000000000 --- a/libs/PEAR.1.9/Net/URL2.php +++ /dev/null @@ -1,894 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: URL2.php 290036 2009-10-28 19:52:49Z schmidt $ - * @link http://www.rfc-editor.org/rfc/rfc3986.txt - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!', - $url, - $matches); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $matches[5]; - $this->_query = !empty($matches[6]) ? $matches[7] : false; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return void - * @see getScheme() - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('@:.*$@', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return void - */ - public function setUserinfo($userinfo, $password = false) - { - $this->_userinfo = $userinfo; - if ($password !== false) { - $this->_userinfo .= ':' . $password; - } - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return void - */ - public function setHost($host) - { - $this->_host = $host; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return void - */ - public function setPort($port) - { - $this->_port = $port; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (!$this->_host) { - return false; - } - - $authority = ''; - - if ($this->_userinfo !== false) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|false $authority a hostname or an IP addresse, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return void - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - if (preg_match('@^(([^\@]*)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) { - if ($reg[1]) { - $this->_userinfo = $reg[2]; - } - - $this->_host = $reg[3]; - if (isset($reg[5])) { - $this->_port = $reg[5]; - } - } - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return void - */ - public function setPath($path) - { - $this->_path = $path; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see self::getQueryVariables() - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return void - * @see self::setQueryVariables() - */ - public function setQuery($query) - { - $this->_query = $query; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return void - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $pattern = '/[' . - preg_quote($this->getOption(self::OPTION_SEPARATOR_INPUT), '/') . - ']/'; - $parts = preg_split($pattern, $this->_query, -1, PREG_SPLIT_NO_EMPTY); - $return = array(); - - foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - list($key, $value) = explode('=', $part, 2); - } else { - $key = $part; - $value = null; - } - - if ($this->getOption(self::OPTION_ENCODE_KEYS)) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($this->getOption(self::OPTION_USE_BRACKETS) && - preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) { - - $key = $matches[1]; - $idx = $matches[2]; - - // Ensure is an array - if (empty($return[$key]) || !is_array($return[$key])) { - $return[$key] = array(); - } - - // Add data - if ($idx === '') { - $return[$key][] = $value; - } else { - $return[$key][$idx] = $value; - } - } elseif (!$this->getOption(self::OPTION_USE_BRACKETS) - && !empty($return[$key]) - ) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - - return $return; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return void - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - foreach ($array as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS)) { - $name = self::urlencode($name); - } - - if (is_array($value)) { - foreach ($value as $k => $v) { - $parts[] = $this->getOption(self::OPTION_USE_BRACKETS) - ? sprintf('%s[%s]=%s', $name, $k, $v) - : ($name . '=' . $v); - } - } elseif (!is_null($value)) { - $parts[] = $name . '=' . self::urlencode($value); - } else { - $parts[] = $name; - } - } - $this->_query = implode($this->getOption(self::OPTION_SEPARATOR_OUTPUT), - $parts); - } - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return array - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - } - - /** - * Removes the specifed variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ""; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority !== false) { - $url .= '//' . $authority; - } - $url .= $this->_path; - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @see toString() - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Returns a normalized Net_URL2 instance. - * - * @return Net_URL2 - */ - public function normalize() - { - // See RFC 3886, section 6 - - // Schemes are case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostnames are case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ($this->_port && - $this->_scheme && - $this->_port == getservbyname($this->_scheme, 'tcp')) { - - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - foreach (array('_userinfo', '_host', '_path') as $part) { - if ($this->$part) { - $this->$part = preg_replace('/%[0-9a-f]{2}/ie', - 'strtoupper("\0")', - $this->$part); - } - } - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if ($this->_host && !$this->_path) { - $this->_path = '/'; - } - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @return Net_URL2 - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$this->isAbsolute()) { - throw new Exception('Base-URL must be absolute'); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) && $reference->_scheme == $this->_scheme) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $this->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $j = 0; - while ($path && $j++ < 100) { - if (substr($path, 0, 2) == './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) == '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) == '/./' || $path == '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) == '/../' || $path == '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path == '.' || $path == '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/'); - if ($i === 0) { - $i = strpos($path, '/', 1); - } - if ($i === false) { - $i = strlen($path); - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param $raw the string to encode - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 || - $url->_scheme == 'https' && $port != 443) { - - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @return Net_URL2 - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } -} diff --git a/libs/PEAR.1.9/PEAR.php b/libs/PEAR.1.9/PEAR.php deleted file mode 100644 index d48ee8282..000000000 --- a/libs/PEAR.1.9/PEAR.php +++ /dev/null @@ -1,1137 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: PEAR.php 286670 2009-08-02 14:16:06Z dufuz $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - // {{{ properties - - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - if ($error_class !== null) { - $this->_error_class = $error_class; - } - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - // }}} - // {{{ destructor - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - // }}} - // {{{ getStaticProperty() - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - - return $properties[$class][$var]; - } - - // }}} - // {{{ registerShutdownFunc() - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (!is_a($data, 'PEAR_Error')) { - return false; - } - - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } - - return $data->getCode() == $code; - } - - // }}} - // {{{ setErrorHandling() - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ expectError() - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return sizeof($this->_expected_errors); - } - - // }}} - // {{{ popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - // }}} - // {{{ _checkDelExpect() - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - - foreach ($this->_expected_errors AS $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - return $deleted; - } - - // }}} - // {{{ delExpect() - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; - // we walk through it trying to unset all - // values - foreach($error_code as $key => $error) { - if ($this->_checkDelExpect($error)) { - $deleted = true; - } else { - $deleted = false; - } - } - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } else { - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - } - - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp))) { - $mode = PEAR_ERROR_RETURN; - } - } - - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - - if (intval(PHP_VERSION) < 5) { - // little non-eval hack to fix bug #12147 - include 'PEAR/FixPHP5PEARWarnings.php'; - return $a; - } - - if ($skipmsg) { - $a = new $ec($code, $mode, $options, $userinfo); - } else { - $a = new $ec($message, $code, $mode, $options, $userinfo); - } - - return $a; - } - - // }}} - // {{{ throwError() - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param string $message - * - */ - function &throwError($message = null, - $code = null, - $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } - - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - - // }}} - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - // {{{ pushErrorHandling() - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - // }}} - // {{{ popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - // }}} - // {{{ loadExtension() - - /** - * OS independant PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (!extension_loaded($ext)) { - // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { - return false; - } - - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } - - return true; - } - - // }}} -} - -if (PEAR_ZE2) { - include_once 'PEAR5.php'; -} - -// {{{ _PEAR_call_destructors() - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR_ZE2) { - $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); - } else { - $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); - } - - if ($destructLifoExists) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if (isset($GLOBALS['_PEAR_shutdown_funcs']) AND is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -// }}} -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - - if (PEAR_ZE2) { - $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); - } else { - $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); - } - - if (!$skiptrace) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - - $this->level = $options; - $this->callback = null; - } - - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - - printf($format, $this->getMessage()); - } - - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - } - - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - // }}} - // {{{ getMode() - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() { - return $this->mode; - } - - // }}} - // {{{ getCallback() - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() { - return $this->callback; - } - - // }}} - // {{{ getMessage() - - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - // }}} - // {{{ getBacktrace() - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - // }}} - // {{{ addUserInfo() - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - // }}} - // {{{ toString() - function __toString() - { - return $this->getMessage(); - } - // }}} - // {{{ toString() - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } - - // }}} -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/libs/PEAR.1.9/PEAR/Exception.php b/libs/PEAR.1.9/PEAR/Exception.php deleted file mode 100644 index 5e8489703..000000000 --- a/libs/PEAR.1.9/PEAR/Exception.php +++ /dev/null @@ -1,391 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Exception.php 276383 2009-02-24 23:39:37Z dufuz $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.3.3 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category pear - * @package PEAR - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.3.3 - * - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * @param string exception message - * @param int|Exception|PEAR_Error|array|null exception cause - * @param int|null exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception('exception cause must be Exception, ' . - 'array, or PEAR_Error'); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - private function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * @access public - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * @param array - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message'], ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) $args[] = 'null'; - elseif (is_array($arg)) $args[] = 'Array'; - elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')'; - elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; - elseif (is_int($arg) || is_double($arg)) $args[] = $arg; - else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); - if (strlen($arg) > 16) $str .= '…'; - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ',$args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} - -?> diff --git a/libs/PEAR.1.9/PEAR5.php b/libs/PEAR.1.9/PEAR5.php deleted file mode 100644 index 428606780..000000000 --- a/libs/PEAR.1.9/PEAR5.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request.php,v 1.55 2007/05/18 19:20:12 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * PEAR and PEAR_Error classes (for error handling) - */ -require_once 'PEAR.php'; -/** - * Socket class - */ -require_once 'Net/Socket.php'; -/** - * URL handling class - */ -require_once 'Net/URL.php'; - -/**#@+ - * Constants for HTTP request methods - */ -define('HTTP_REQUEST_METHOD_GET', 'GET', true); -define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); -define('HTTP_REQUEST_METHOD_POST', 'POST', true); -define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); -define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); -define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); -define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); -/**#@-*/ - -/**#@+ - * Constants for HTTP protocol versions - */ -define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); -define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); -/**#@-*/ - -if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - /** - * Whether string functions are overloaded by their mbstring equivalents - */ - define('HTTP_REQUEST_MBSTRING', true); -} else { - /** - * @ignore - */ - define('HTTP_REQUEST_MBSTRING', false); -} - -/** - * Class for performing HTTP requests - * - * Simple example (fetches yahoo.com and displays it): - * - * $a = &new HTTP_Request('http://www.yahoo.com/'); - * $a->sendRequest(); - * echo $a->getResponseBody(); - * - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Request -{ - /**#@+ - * @access private - */ - /** - * Instance of Net_URL - * @var Net_URL - */ - var $_url; - - /** - * Type of request - * @var string - */ - var $_method; - - /** - * HTTP Version - * @var string - */ - var $_http; - - /** - * Request headers - * @var array - */ - var $_requestHeaders; - - /** - * Basic Auth Username - * @var string - */ - var $_user; - - /** - * Basic Auth Password - * @var string - */ - var $_pass; - - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Proxy server - * @var string - */ - var $_proxy_host; - - /** - * Proxy port - * @var integer - */ - var $_proxy_port; - - /** - * Proxy username - * @var string - */ - var $_proxy_user; - - /** - * Proxy password - * @var string - */ - var $_proxy_pass; - - /** - * Post data - * @var array - */ - var $_postData; - - /** - * Request body - * @var string - */ - var $_body; - - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - var $_bodyDisallowed = array('TRACE'); - - /** - * Files to post - * @var array - */ - var $_postFiles = array(); - - /** - * Connection timeout. - * @var float - */ - var $_timeout; - - /** - * HTTP_Response object - * @var HTTP_Response - */ - var $_response; - - /** - * Whether to allow redirects - * @var boolean - */ - var $_allowRedirects; - - /** - * Maximum redirects allowed - * @var integer - */ - var $_maxRedirects; - - /** - * Current number of redirects - * @var integer - */ - var $_redirects; - - /** - * Whether to append brackets [] to array variables - * @var bool - */ - var $_useBrackets = true; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Whether to save response body in response object property - * @var bool - */ - var $_saveBody = true; - - /** - * Timeout for reading from socket (array(seconds, microseconds)) - * @var array - */ - var $_readTimeout = null; - - /** - * Options to pass to Net_Socket::connect. See stream_context_create - * @var array - */ - var $_socketOptions = null; - /**#@-*/ - - /** - * Constructor - * - * Sets up the object - * @param string The url to fetch/access - * @param array Associative array of parameters which can have the following keys: - *
    - *
  • method - Method to use, GET, POST etc (string)
  • - *
  • http - HTTP Version to use, 1.0 or 1.1 (string)
  • - *
  • user - Basic Auth username (string)
  • - *
  • pass - Basic Auth password (string)
  • - *
  • proxy_host - Proxy server host (string)
  • - *
  • proxy_port - Proxy server port (integer)
  • - *
  • proxy_user - Proxy auth username (string)
  • - *
  • proxy_pass - Proxy auth password (string)
  • - *
  • timeout - Connection timeout in seconds (float)
  • - *
  • allowRedirects - Whether to follow redirects or not (bool)
  • - *
  • maxRedirects - Max number of redirects to follow (integer)
  • - *
  • useBrackets - Whether to append [] to array variable names (bool)
  • - *
  • saveBody - Whether to save response body in response object property (bool)
  • - *
  • readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))
  • - *
  • socketOptions - Options to pass to Net_Socket object (array)
  • - *
- * @access public - */ - function HTTP_Request($url = '', $params = array()) - { - $this->_method = HTTP_REQUEST_METHOD_GET; - $this->_http = HTTP_REQUEST_HTTP_VER_1_1; - $this->_requestHeaders = array(); - $this->_postData = array(); - $this->_body = null; - - $this->_user = null; - $this->_pass = null; - - $this->_proxy_host = null; - $this->_proxy_port = null; - $this->_proxy_user = null; - $this->_proxy_pass = null; - - $this->_allowRedirects = false; - $this->_maxRedirects = 3; - $this->_redirects = 0; - - $this->_timeout = null; - $this->_response = null; - - foreach ($params as $key => $value) { - $this->{'_' . $key} = $value; - } - - if (!empty($url)) { - $this->setURL($url); - } - - // Default useragent - $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); - - // We don't do keep-alives by default - $this->addHeader('Connection', 'close'); - - // Basic authentication - if (!empty($this->_user)) { - $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); - } - - // Proxy authentication (see bug #5913) - if (!empty($this->_proxy_user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); - } - - // Use gzip encoding if possible - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) { - $this->addHeader('Accept-Encoding', 'gzip'); - } - } - - /** - * Generates a Host header for HTTP/1.1 requests - * - * @access private - * @return string - */ - function _generateHostHeader() - { - if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { - $host = $this->_url->host . ':' . $this->_url->port; - - } else { - $host = $this->_url->host; - } - - return $host; - } - - /** - * Resets the object to its initial state (DEPRECATED). - * Takes the same parameters as the constructor. - * - * @param string $url The url to be requested - * @param array $params Associative array of parameters - * (see constructor for details) - * @access public - * @deprecated deprecated since 1.2, call the constructor if this is necessary - */ - function reset($url, $params = array()) - { - $this->HTTP_Request($url, $params); - } - - /** - * Sets the URL to be requested - * - * @param string The url to be requested - * @access public - */ - function setURL($url) - { - $this->_url = &new Net_URL($url, $this->_useBrackets); - - if (!empty($this->_url->user) || !empty($this->_url->pass)) { - $this->setBasicAuth($this->_url->user, $this->_url->pass); - } - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { - $this->addHeader('Host', $this->_generateHostHeader()); - } - - // set '/' instead of empty path rather than check later (see bug #8662) - if (empty($this->_url->path)) { - $this->_url->path = '/'; - } - } - - /** - * Returns the current request URL - * - * @return string Current request URL - * @access public - */ - function getUrl() - { - return empty($this->_url)? '': $this->_url->getUrl(); - } - - /** - * Sets a proxy to be used - * - * @param string Proxy host - * @param int Proxy port - * @param string Proxy username - * @param string Proxy password - * @access public - */ - function setProxy($host, $port = 8080, $user = null, $pass = null) - { - $this->_proxy_host = $host; - $this->_proxy_port = $port; - $this->_proxy_user = $user; - $this->_proxy_pass = $pass; - - if (!empty($user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - } - - /** - * Sets basic authentication parameters - * - * @param string Username - * @param string Password - */ - function setBasicAuth($user, $pass) - { - $this->_user = $user; - $this->_pass = $pass; - - $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - - /** - * Sets the method to be used, GET, POST etc. - * - * @param string Method to use. Use the defined constants for this - * @access public - */ - function setMethod($method) - { - $this->_method = $method; - } - - /** - * Sets the HTTP version to use, 1.0 or 1.1 - * - * @param string Version to use. Use the defined constants for this - * @access public - */ - function setHttpVer($http) - { - $this->_http = $http; - } - - /** - * Adds a request header - * - * @param string Header name - * @param string Header value - * @access public - */ - function addHeader($name, $value) - { - $this->_requestHeaders[strtolower($name)] = $value; - } - - /** - * Removes a request header - * - * @param string Header name to remove - * @access public - */ - function removeHeader($name) - { - if (isset($this->_requestHeaders[strtolower($name)])) { - unset($this->_requestHeaders[strtolower($name)]); - } - } - - /** - * Adds a querystring parameter - * - * @param string Querystring parameter name - * @param string Querystring parameter value - * @param bool Whether the value is already urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->_url->addQueryString($name, $value, $preencoded); - } - - /** - * Sets the querystring to literally what you supply - * - * @param string The querystring data. Should be of the format foo=bar&x=y etc - * @param bool Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $this->_url->addRawQueryString($querystring, $preencoded); - } - - /** - * Adds postdata items - * - * @param string Post data name - * @param string Post data value - * @param bool Whether data is already urlencoded or not, default = not - * @access public - */ - function addPostData($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->_postData[$name] = $value; - } else { - $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); - } - } - - /** - * Recursively applies the callback function to the value - * - * @param mixed Callback function - * @param mixed Value to process - * @access private - * @return mixed Processed value - */ - function _arrayMapRecursive($callback, $value) - { - if (!is_array($value)) { - return call_user_func($callback, $value); - } else { - $map = array(); - foreach ($value as $k => $v) { - $map[$k] = $this->_arrayMapRecursive($callback, $v); - } - return $map; - } - } - - /** - * Adds a file to upload - * - * This also changes content-type to 'multipart/form-data' for proper upload - * - * @access public - * @param string name of file-upload field - * @param mixed file name(s) - * @param mixed content-type(s) of file(s) being uploaded - * @return bool true on success - * @throws PEAR_Error - */ - function addFile($inputName, $fileName, $contentType = 'application/octet-stream') - { - if (!is_array($fileName) && !is_readable($fileName)) { - return PEAR::raiseError("File '{$fileName}' is not readable"); - } elseif (is_array($fileName)) { - foreach ($fileName as $name) { - if (!is_readable($name)) { - return PEAR::raiseError("File '{$name}' is not readable"); - } - } - } - $this->addHeader('Content-Type', 'multipart/form-data'); - $this->_postFiles[$inputName] = array( - 'name' => $fileName, - 'type' => $contentType - ); - return true; - } - - /** - * Adds raw postdata (DEPRECATED) - * - * @param string The data - * @param bool Whether data is preencoded or not, default = already encoded - * @access public - * @deprecated deprecated since 1.3.0, method setBody() should be used instead - */ - function addRawPostData($postdata, $preencoded = true) - { - $this->_body = $preencoded ? $postdata : urlencode($postdata); - } - - /** - * Sets the request body (for POST, PUT and similar requests) - * - * @param string Request body - * @access public - */ - function setBody($body) - { - $this->_body = $body; - } - - /** - * Clears any postdata that has been added (DEPRECATED). - * - * Useful for multiple request scenarios. - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearPostData() - { - $this->_postData = null; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string $name cookie name - * @param string $value cookie value - * @access public - */ - function addCookie($name, $value) - { - $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; - $this->addHeader('Cookie', $cookies . $name . '=' . $value); - } - - /** - * Clears any cookies that have been added (DEPRECATED). - * - * Useful for multiple request scenarios - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearCookies() - { - $this->removeHeader('Cookie'); - } - - /** - * Sends the request - * - * @access public - * @param bool Whether to store response body in Response object property, - * set this to false if downloading a LARGE file and using a Listener - * @return mixed PEAR error on error, true otherwise - */ - function sendRequest($saveBody = true) - { - if (!is_a($this->_url, 'Net_URL')) { - return PEAR::raiseError('No URL given.'); - } - - $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; - $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; - - // 4.3.0 supports SSL connections using OpenSSL. The function test determines - // we running on at least 4.3.0 - if (strcasecmp($this->_url->protocol, 'https') == 0 AND function_exists('file_get_contents') AND extension_loaded('openssl')) { - if (isset($this->_proxy_host)) { - return PEAR::raiseError('HTTPS proxies are not supported.'); - } - $host = 'ssl://' . $host; - } - - // magic quotes may fuck up file uploads and chunked response processing - $magicQuotes = ini_get('magic_quotes_runtime'); - ini_set('magic_quotes_runtime', false); - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && - 'Keep-Alive' == $this->_requestHeaders['connection']) - { - $this->removeHeader('connection'); - } - - $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || - (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); - $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); - $sockKey = $host . ':' . $port; - unset($this->_sock); - - // There is a connected socket in the "static" property? - if ($keepAlive && !empty($sockets[$sockKey]) && - !empty($sockets[$sockKey]->fp)) - { - $this->_sock =& $sockets[$sockKey]; - $err = null; - } else { - $this->_notify('connect'); - $this->_sock =& new Net_Socket(); - $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); - } - PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); - - if (!PEAR::isError($err)) { - if (!empty($this->_readTimeout)) { - $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); - } - - $this->_notify('sentRequest'); - - // Read the response - $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); - $err = $this->_response->process( - $this->_saveBody && $saveBody, - HTTP_REQUEST_METHOD_HEAD != $this->_method - ); - - if ($keepAlive) { - $keepAlive = (isset($this->_response->_headers['content-length']) - || (isset($this->_response->_headers['transfer-encoding']) - && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); - if ($keepAlive) { - if (isset($this->_response->_headers['connection'])) { - $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; - } else { - $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; - } - } - } - } - - ini_set('magic_quotes_runtime', $magicQuotes); - - if (PEAR::isError($err)) { - return $err; - } - - if (!$keepAlive) { - $this->disconnect(); - // Store the connected socket in "static" property - } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - $sockets[$sockKey] =& $this->_sock; - } - - // Check for redirection - if ( $this->_allowRedirects - AND $this->_redirects <= $this->_maxRedirects - AND $this->getResponseCode() > 300 - AND $this->getResponseCode() < 399 - AND !empty($this->_response->_headers['location'])) { - - - $redirect = $this->_response->_headers['location']; - - // Absolute URL - if (preg_match('/^https?:\/\//i', $redirect)) { - $this->_url = &new Net_URL($redirect); - $this->addHeader('Host', $this->_generateHostHeader()); - // Absolute path - } elseif ($redirect{0} == '/') { - $this->_url->path = $redirect; - - // Relative path - } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $redirect = Net_URL::resolvePath($redirect); - $this->_url->path = $redirect; - - // Filename, no path - } else { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $this->_url->path = $redirect; - } - - $this->_redirects++; - return $this->sendRequest($saveBody); - - // Too many redirects - } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { - return PEAR::raiseError('Too many redirects'); - } - - return true; - } - - /** - * Disconnect the socket, if connected. Only useful if using Keep-Alive. - * - * @access public - */ - function disconnect() - { - if (!empty($this->_sock) && !empty($this->_sock->fp)) { - $this->_notify('disconnect'); - $this->_sock->disconnect(); - } - } - - /** - * Returns the response code - * - * @access public - * @return mixed Response code, false if not set - */ - function getResponseCode() - { - return isset($this->_response->_code) ? $this->_response->_code : false; - } - - /** - * Returns either the named header or all if no name given - * - * @access public - * @param string The header name to return, do not set to get all headers - * @return mixed either the value of $headername (false if header is not present) - * or an array of all headers - */ - function getResponseHeader($headername = null) - { - if (!isset($headername)) { - return isset($this->_response->_headers)? $this->_response->_headers: array(); - } else { - $headername = strtolower($headername); - return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; - } - } - - /** - * Returns the body of the response - * - * @access public - * @return mixed response body, false if not set - */ - function getResponseBody() - { - return isset($this->_response->_body) ? $this->_response->_body : false; - } - - /** - * Returns cookies set in response - * - * @access public - * @return mixed array of response cookies, false if none are present - */ - function getResponseCookies() - { - return isset($this->_response->_cookies) ? $this->_response->_cookies : false; - } - - /** - * Builds the request string - * - * @access private - * @return string The request string - */ - function _buildRequest() - { - $separator = ini_get('arg_separator.output'); - ini_set('arg_separator.output', '&'); - $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; - ini_set('arg_separator.output', $separator); - - $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; - $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; - $path = $this->_url->path . $querystring; - $url = $host . $port . $path; - - $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; - - if (in_array($this->_method, $this->_bodyDisallowed) || - (empty($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || - (empty($this->_postData) && empty($this->_postFiles))))) - { - $this->removeHeader('Content-Type'); - } else { - if (empty($this->_requestHeaders['content-type'])) { - // Add default content-type - $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { - $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); - $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); - } - } - - // Request Headers - if (!empty($this->_requestHeaders)) { - foreach ($this->_requestHeaders as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $request .= $canonicalName . ': ' . $value . "\r\n"; - } - } - - // No post data or wrong method, so simply add a final CRLF - if (in_array($this->_method, $this->_bodyDisallowed) || - (HTTP_REQUEST_METHOD_POST != $this->_method && empty($this->_body))) { - - $request .= "\r\n"; - - // Post data if it's an array - } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && - (!empty($this->_postData) || !empty($this->_postFiles))) { - - // "normal" POST request - if (!isset($boundary)) { - $postdata = implode('&', array_map( - create_function('$a', 'return $a[0] . \'=\' . $a[1];'), - $this->_flattenArray('', $this->_postData) - )); - - // multipart request, probably with file uploads - } else { - $postdata = ''; - if (!empty($this->_postData)) { - $flatData = $this->_flattenArray('', $this->_postData); - foreach ($flatData as $item) { - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; - $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; - } - } - foreach ($this->_postFiles as $name => $value) { - if (is_array($value['name'])) { - $varname = $name . ($this->_useBrackets? '[]': ''); - } else { - $varname = $name; - $value['name'] = array($value['name']); - } - foreach ($value['name'] as $key => $filename) { - $fp = fopen($filename, 'r'); - $data = fread($fp, filesize($filename)); - fclose($fp); - $basename = basename($filename); - $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; - - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; - $postdata .= "\r\nContent-Type: " . $type; - $postdata .= "\r\n\r\n" . $data . "\r\n"; - } - } - $postdata .= '--' . $boundary . "--\r\n"; - } - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . - "\r\n\r\n"; - $request .= $postdata; - - // Explicitly set request body - } elseif (!empty($this->_body)) { - - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . - "\r\n\r\n"; - $request .= $this->_body; - } - - return $request; - } - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @return array array with the following items: array('item name', 'item value'); - * @access private - */ - function _flattenArray($name, $values) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($this->_useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, $this->_flattenArray($newName, $v)); - } - return $ret; - } - } - - - /** - * Adds a Listener to the list of listeners that are notified of - * the object's events - * - * Events sent by HTTP_Request object - * - 'connect': on connection to server - * - 'sentRequest': after the request was sent - * - 'disconnect': on disconnection from server - * - * Events sent by HTTP_Response object - * - 'gotHeaders': after receiving response headers (headers are passed in $data) - * - 'tick': on receiving a part of response body (the part is passed in $data) - * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) - * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) - * - * @param HTTP_Request_Listener listener to attach - * @return boolean whether the listener was successfully attached - * @access public - */ - function attach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener')) { - return false; - } - $this->_listeners[$listener->getId()] =& $listener; - return true; - } - - - /** - * Removes a Listener from the list of listeners - * - * @param HTTP_Request_Listener listener to detach - * @return boolean whether the listener was successfully detached - * @access public - */ - function detach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener') || - !isset($this->_listeners[$listener->getId()])) { - return false; - } - unset($this->_listeners[$listener->getId()]); - return true; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::attach() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } -} - - -/** - * Response class to complement the Request class - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Response -{ - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Protocol - * @var string - */ - var $_protocol; - - /** - * Return code - * @var string - */ - var $_code; - - /** - * Response headers - * @var array - */ - var $_headers; - - /** - * Cookies set in response - * @var array - */ - var $_cookies; - - /** - * Response body - * @var string - */ - var $_body = ''; - - /** - * Used by _readChunked(): remaining length of the current chunk - * @var string - */ - var $_chunkLength = 0; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Bytes left to read from message-body - * @var null|int - */ - var $_toRead; - - /** - * Constructor - * - * @param Net_Socket socket to read the response from - * @param array listeners attached to request - */ - function HTTP_Response(&$sock, &$listeners) - { - $this->_sock =& $sock; - $this->_listeners =& $listeners; - } - - - /** - * Processes a HTTP response - * - * This extracts response code, headers, cookies and decodes body if it - * was encoded in some way - * - * @access public - * @param bool Whether to store response body in object property, set - * this to false if downloading a LARGE file and using a Listener. - * This is assumed to be true if body is gzip-encoded. - * @param bool Whether the response can actually have a message-body. - * Will be set to false for HEAD requests. - * @throws PEAR_Error - * @return mixed true on success, PEAR_Error in case of malformed response - */ - function process($saveBody = true, $canHaveBody = true) - { - do { - $line = $this->_sock->readLine(); - if (sscanf($line, 'HTTP/%s %s', $http_version, $returncode) != 2) { - return PEAR::raiseError('Malformed response.'); - } else { - $this->_protocol = 'HTTP/' . $http_version; - $this->_code = intval($returncode); - } - while ('' !== ($header = $this->_sock->readLine())) { - $this->_processHeader($header); - } - } while (100 == $this->_code); - - $this->_notify('gotHeaders', $this->_headers); - - // RFC 2616, section 4.4: - // 1. Any response message which "MUST NOT" include a message-body ... - // is always terminated by the first empty line after the header fields - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $canHaveBody = $canHaveBody && $this->_code >= 200 && - $this->_code != 204 && $this->_code != 304; - - // If response body is present, read it and decode - $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']); - $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']); - $hasBody = false; - if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) || - 0 != $this->_headers['content-length'])) - { - if ($chunked || !isset($this->_headers['content-length'])) { - $this->_toRead = null; - } else { - $this->_toRead = $this->_headers['content-length']; - } - while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) { - if ($chunked) { - $data = $this->_readChunked(); - } elseif (is_null($this->_toRead)) { - $data = $this->_sock->read(4096); - } else { - $data = $this->_sock->read(min(4096, $this->_toRead)); - $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - } - if ('' == $data) { - break; - } else { - $hasBody = true; - if ($saveBody || $gzipped) { - $this->_body .= $data; - } - $this->_notify($gzipped? 'gzTick': 'tick', $data); - } - } - } - - if ($hasBody) { - // Uncompress the body if needed - if ($gzipped) { - $body = $this->_decodeGzip($this->_body); - if (PEAR::isError($body)) { - return $body; - } - $this->_body = $body; - $this->_notify('gotBody', $this->_body); - } else { - $this->_notify('gotBody'); - } - } - return true; - } - - - /** - * Processes the response header - * - * @access private - * @param string HTTP header - */ - function _processHeader($header) - { - if (false === strpos($header, ':')) { - return; - } - list($headername, $headervalue) = explode(':', $header, 2); - $headername = strtolower($headername); - $headervalue = ltrim($headervalue); - - if ('set-cookie' != $headername) { - if (isset($this->_headers[$headername])) { - $this->_headers[$headername] .= ',' . $headervalue; - } else { - $this->_headers[$headername] = $headervalue; - } - } else { - $this->_parseCookie($headervalue); - } - } - - - /** - * Parse a Set-Cookie header to fill $_cookies array - * - * @access private - * @param string value of Set-Cookie header - */ - function _parseCookie($headervalue) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($headervalue, ';')) { - $pos = strpos($headervalue, '='); - $cookie['name'] = trim(substr($headervalue, 0, $pos)); - $cookie['value'] = trim(substr($headervalue, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $headervalue); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->_cookies[] = $cookie; - } - - - /** - * Read a part of response body encoded with chunked Transfer-Encoding - * - * @access private - * @return string - */ - function _readChunked() - { - // at start of the next chunk? - if (0 == $this->_chunkLength) { - $line = $this->_sock->readLine(); - if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - $this->_chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // make this an eof() - return ''; - } - } else { - return ''; - } - } - $data = $this->_sock->read($this->_chunkLength); - $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // Trailing CRLF - } - return $data; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::_notify() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } - - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @access private - * @param string gzip-encoded data - * @return string decoded data - */ - function _decodeGzip($data) - { - if (HTTP_REQUEST_MBSTRING) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - return PEAR::raiseError('_decodeGzip(): unknown compression method'); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - return PEAR::raiseError('_decodeGzip(): reserved bits are set'); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 1) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - return PEAR::raiseError('_decodeGzip(): header CRC check failed'); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - $unpacked = @gzinflate(substr($data, $headerLength, -8), $dataSize); - if (false === $unpacked) { - return PEAR::raiseError('_decodeGzip(): gzinflate() call failed'); - } elseif ($dataSize != strlen($unpacked)) { - return PEAR::raiseError('_decodeGzip(): data size check failed'); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - return PEAR::raiseError('_decodeGzip(): data CRC check failed'); - } - if (HTTP_REQUEST_MBSTRING) { - mb_internal_encoding($oldEncoding); - } - return $unpacked; - } -} // End class HTTP_Response -?> diff --git a/libs/PEAR/HTTP/Request/Listener.php b/libs/PEAR/HTTP/Request/Listener.php deleted file mode 100644 index 928ac5e68..000000000 --- a/libs/PEAR/HTTP/Request/Listener.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Listener.php,v 1.3 2007/05/18 10:33:31 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * Listener for HTTP_Request and HTTP_Response objects - * - * This class implements the Observer part of a Subject-Observer - * design pattern. - * - * @category HTTP - * @package HTTP_Request - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Request_Listener -{ - /** - * A listener's identifier - * @var string - */ - var $_id; - - /** - * Constructor, sets the object's identifier - * - * @access public - */ - function HTTP_Request_Listener() - { - $this->_id = md5(uniqid('http_request_', 1)); - } - - - /** - * Returns the listener's identifier - * - * @access public - * @return string - */ - function getId() - { - return $this->_id; - } - - - /** - * This method is called when Listener is notified of an event - * - * @access public - * @param object an object the listener is attached to - * @param string Event name - * @param mixed Additional data - * @abstract - */ - function update(&$subject, $event, $data = null) - { - echo "Notified of event: '$event'\n"; - if (null !== $data) { - echo "Additional data: "; - var_dump($data); - } - } -} -?> diff --git a/libs/PEAR/Net/Socket.php b/libs/PEAR/Net/Socket.php deleted file mode 100644 index 7c4ff1d4e..000000000 --- a/libs/PEAR/Net/Socket.php +++ /dev/null @@ -1,528 +0,0 @@ - | -// | Chuck Hagenbuch | -// +----------------------------------------------------------------------+ -// -// $Id: Socket.php,v 1.24 2005/02/03 20:40:16 chagenbu Exp $ - -require_once 'PEAR.php'; - -define('NET_SOCKET_READ', 1); -define('NET_SOCKET_WRITE', 2); -define('NET_SOCKET_ERROR', 3); - -/** - * Generalized Socket class. - * - * @version 1.1 - * @author Stig Bakken - * @author Chuck Hagenbuch - */ -class Net_Socket extends PEAR { - - /** - * Socket file pointer. - * @var resource $fp - */ - var $fp = null; - - /** - * Whether the socket is blocking. Defaults to true. - * @var boolean $blocking - */ - var $blocking = true; - - /** - * Whether the socket is persistent. Defaults to false. - * @var boolean $persistent - */ - var $persistent = false; - - /** - * The IP address to connect to. - * @var string $addr - */ - var $addr = ''; - - /** - * The port number to connect to. - * @var integer $port - */ - var $port = 0; - - /** - * Number of seconds to wait on socket connections before assuming - * there's no more data. Defaults to no timeout. - * @var integer $timeout - */ - var $timeout = false; - - /** - * Number of bytes to read at a time in readLine() and - * readAll(). Defaults to 2048. - * @var integer $lineLength - */ - var $lineLength = 2048; - - /** - * Connect to the specified port. If called when the socket is - * already connected, it disconnects and connects again. - * - * @param string $addr IP address or host name. - * @param integer $port TCP port number. - * @param boolean $persistent (optional) Whether the connection is - * persistent (kept open between requests - * by the web server). - * @param integer $timeout (optional) How long to wait for data. - * @param array $options See options for stream_context_create. - * - * @access public - * - * @return boolean | PEAR_Error True on success or a PEAR_Error on failure. - */ - function connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null) - { - if (is_resource($this->fp)) { - @fclose($this->fp); - $this->fp = null; - } - - if (!$addr) { - return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || - strstr($addr, '/') !== false) { - $this->addr = $addr; - } else { - $this->addr = @gethostbyname($addr); - } - - $this->port = $port % 65536; - - if ($persistent !== null) { - $this->persistent = $persistent; - } - - if ($timeout !== null) { - $this->timeout = $timeout; - } - - $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen'; - $errno = 0; - $errstr = ''; - if ($options && function_exists('stream_context_create')) { - if ($this->timeout) { - $timeout = $this->timeout; - } else { - $timeout = 0; - } - $context = stream_context_create($options); - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); - } else { - if ($this->timeout) { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout); - } else { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr); - } - } - - if (!$fp) { - return $this->raiseError($errstr, $errno); - } - - $this->fp = $fp; - - return $this->setBlocking($this->blocking); - } - - /** - * Disconnects from the peer, closes the socket. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function disconnect() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - @fclose($this->fp); - $this->fp = null; - return true; - } - - /** - * Find out if the socket is in blocking mode. - * - * @access public - * @return boolean The current blocking mode. - */ - function isBlocking() - { - return $this->blocking; - } - - /** - * Sets whether the socket connection should be blocking or - * not. A read call to a non-blocking socket will return immediately - * if there is no data available, whereas it will block until there - * is data for blocking sockets. - * - * @param boolean $mode True for blocking sockets, false for nonblocking. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setBlocking($mode) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $this->blocking = $mode; - socket_set_blocking($this->fp, $this->blocking); - return true; - } - - /** - * Sets the timeout value on socket descriptor, - * expressed in the sum of seconds and microseconds - * - * @param integer $seconds Seconds. - * @param integer $microseconds Microseconds. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setTimeout($seconds, $microseconds) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_set_timeout($this->fp, $seconds, $microseconds); - } - - /** - * Returns information about an existing socket resource. - * Currently returns four entries in the result array: - * - *

- * timed_out (bool) - The socket timed out waiting for data
- * blocked (bool) - The socket was blocked
- * eof (bool) - Indicates EOF event
- * unread_bytes (int) - Number of bytes left in the socket buffer
- *

- * - * @access public - * @return mixed Array containing information about existing socket resource or an error object otherwise - */ - function getStatus() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_get_status($this->fp); - } - - /** - * Get a specified line of data - * - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function gets($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fgets($this->fp, $size); - } - - /** - * Read a specified amount of data. This is guaranteed to return, - * and has the added benefit of getting everything in one fread() - * chunk; if you know the size of the data you're getting - * beforehand, this is definitely the way to go. - * - * @param integer $size The number of bytes to read from the socket. - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function read($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fread($this->fp, $size); - } - - /** - * Write a specified amount of data. - * - * @param string $data Data to write. - * @param integer $blocksize Amount of data to write at once. - * NULL means all at once. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function write($data, $blocksize = null) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - if (is_null($blocksize) && !OS_WINDOWS) { - return fwrite($this->fp, $data); - } else { - if (is_null($blocksize)) { - $blocksize = 1024; - } - - $pos = 0; - $size = strlen($data); - while ($pos < $size) { - $written = @fwrite($this->fp, substr($data, $pos, $blocksize)); - if ($written === false) { - return false; - } - $pos += $written; - } - - return $pos; - } - } - - /** - * Write a line of data to the socket, followed by a trailing "\r\n". - * - * @access public - * @return mixed fputs result, or an error - */ - function writeLine($data) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return fwrite($this->fp, $data . "\r\n"); - } - - /** - * Tests for end-of-file on a socket descriptor. - * - * @access public - * @return bool - */ - function eof() - { - return (is_resource($this->fp) && feof($this->fp)); - } - - /** - * Reads a byte of data - * - * @access public - * @return 1 byte of data from the socket, or a PEAR_Error if - * not connected. - */ - function readByte() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return ord(@fread($this->fp, 1)); - } - - /** - * Reads a word of data - * - * @access public - * @return 1 word of data from the socket, or a PEAR_Error if - * not connected. - */ - function readWord() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 2); - return (ord($buf[0]) + (ord($buf[1]) << 8)); - } - - /** - * Reads an int of data - * - * @access public - * @return integer 1 int of data from the socket, or a PEAR_Error if - * not connected. - */ - function readInt() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return (ord($buf[0]) + (ord($buf[1]) << 8) + - (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); - } - - /** - * Reads a zero-terminated string of data - * - * @access public - * @return string, or a PEAR_Error if - * not connected. - */ - function readString() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $string = ''; - while (($char = @fread($this->fp, 1)) != "\x00") { - $string .= $char; - } - return $string; - } - - /** - * Reads an IP Address and returns it in a dot formated string - * - * @access public - * @return Dot formated string, or a PEAR_Error if - * not connected. - */ - function readIPAddress() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), - ord($buf[2]), ord($buf[3])); - } - - /** - * Read until either the end of the socket or a newline, whichever - * comes first. Strips the trailing newline from the returned data. - * - * @access public - * @return All available data up to a newline, without that - * newline, or until the end of the socket, or a PEAR_Error if - * not connected. - */ - function readLine() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $line = ''; - $timeout = time() + $this->timeout; - while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { - $line .= @fgets($this->fp, $this->lineLength); - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Read until the socket closes, or until there is no more data in - * the inner PHP buffer. If the inner buffer is empty, in blocking - * mode we wait for at least 1 byte of data. Therefore, in - * blocking mode, if there is no data at all to be read, this - * function will never exit (unless the socket is closed on the - * remote end). - * - * @access public - * - * @return string All data until the socket closes, or a PEAR_Error if - * not connected. - */ - function readAll() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $data = ''; - while (!feof($this->fp)) { - $data .= @fread($this->fp, $this->lineLength); - } - return $data; - } - - /** - * Runs the equivalent of the select() system call on the socket - * with a timeout specified by tv_sec and tv_usec. - * - * @param integer $state Which of read/write/error to check for. - * @param integer $tv_sec Number of seconds for timeout. - * @param integer $tv_usec Number of microseconds for timeout. - * - * @access public - * @return False if select fails, integer describing which of read/write/error - * are ready, or PEAR_Error if not connected. - */ - function select($state, $tv_sec, $tv_usec = 0) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $read = null; - $write = null; - $except = null; - if ($state & NET_SOCKET_READ) { - $read[] = $this->fp; - } - if ($state & NET_SOCKET_WRITE) { - $write[] = $this->fp; - } - if ($state & NET_SOCKET_ERROR) { - $except[] = $this->fp; - } - if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) { - return false; - } - - $result = 0; - if (count($read)) { - $result |= NET_SOCKET_READ; - } - if (count($write)) { - $result |= NET_SOCKET_WRITE; - } - if (count($except)) { - $result |= NET_SOCKET_ERROR; - } - return $result; - } - -} diff --git a/libs/PEAR/Net/URL.php b/libs/PEAR/Net/URL.php deleted file mode 100644 index 6331fc0ac..000000000 --- a/libs/PEAR/Net/URL.php +++ /dev/null @@ -1,410 +0,0 @@ - | -// +-----------------------------------------------------------------------+ -// -// $Id: URL.php,v 1.36 2004/06/19 18:58:50 richard Exp $ -// -// Net_URL Class - -class Net_URL -{ - /** - * Full url - * @var string - */ - var $url; - - /** - * Protocol - * @var string - */ - var $protocol; - - /** - * Username - * @var string - */ - var $username; - - /** - * Password - * @var string - */ - var $password; - - /** - * Host - * @var string - */ - var $host; - - /** - * Port - * @var integer - */ - var $port; - - /** - * Path - * @var string - */ - var $path; - - /** - * Query string - * @var array - */ - var $querystring; - - /** - * Anchor - * @var string - */ - var $anchor; - - /** - * Whether to use [] - * @var bool - */ - var $useBrackets; - - /** - * PHP4 Constructor - * - * @see __construct() - */ - function Net_URL($url = null, $useBrackets = true) - { - $this->__construct($url, $useBrackets); - } - - /** - * PHP5 Constructor - * - * Parses the given url and stores the various parts - * Defaults are used in certain cases - * - * @param string $url Optional URL - * @param bool $useBrackets Whether to use square brackets when - * multiple querystrings with the same name - * exist - */ - function __construct($url = null, $useBrackets = true) - { - $HTTP_SERVER_VARS = !empty($_SERVER) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; - - $this->useBrackets = $useBrackets; - $this->url = $url; - $this->user = ''; - $this->pass = ''; - $this->host = ''; - $this->port = 80; - $this->path = ''; - $this->querystring = array(); - $this->anchor = ''; - - // Only use defaults if not an absolute URL given - if (!preg_match('/^[a-z0-9]+:\/\//i', $url)) { - - $this->protocol = (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 'https' : 'http'); - - /** - * Figure out host/port - */ - if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) AND preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches)) { - $host = $matches[1]; - if (!empty($matches[3])) { - $port = $matches[3]; - } else { - $port = $this->getStandardPort($this->protocol); - } - } - - $this->user = ''; - $this->pass = ''; - $this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost'); - $this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $this->getStandardPort($this->protocol)); - $this->path = !empty($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : '/'; - $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null; - $this->anchor = ''; - } - - // Parse the url and store the various parts - if (!empty($url)) { - $urlinfo = parse_url($url); - - // Default querystring - $this->querystring = array(); - - foreach ($urlinfo as $key => $value) { - switch ($key) { - case 'scheme': - $this->protocol = $value; - $this->port = $this->getStandardPort($value); - break; - - case 'user': - case 'pass': - case 'host': - case 'port': - $this->$key = $value; - break; - - case 'path': - if ($value{0} == '/') { - $this->path = $value; - } else { - $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); - $this->path = sprintf('%s/%s', $path, $value); - } - break; - - case 'query': - $this->querystring = $this->_parseRawQueryString($value); - break; - - case 'fragment': - $this->anchor = $value; - break; - } - } - } - } - - /** - * Returns full url - * - * @return string Full url - * @access public - */ - function getURL() - { - $querystring = $this->getQueryString(); - - $this->url = $this->protocol . '://' - . $this->user . (!empty($this->pass) ? ':' : '') - . $this->pass . (!empty($this->user) ? '@' : '') - . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port) - . $this->path - . (!empty($querystring) ? '?' . $querystring : '') - . (!empty($this->anchor) ? '#' . $this->anchor : ''); - - return $this->url; - } - - /** - * Adds a querystring item - * - * @param string $name Name of item - * @param string $value Value of item - * @param bool $preencoded Whether value is urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->querystring[$name] = $value; - } else { - $this->querystring[$name] = is_array($value) ? array_map('rawurlencode', $value): rawurlencode($value); - } - } - - /** - * Removes a querystring item - * - * @param string $name Name of item - * @access public - */ - function removeQueryString($name) - { - if (isset($this->querystring[$name])) { - unset($this->querystring[$name]); - } - } - - /** - * Sets the querystring to literally what you supply - * - * @param string $querystring The querystring data. Should be of the format foo=bar&x=y etc - * @access public - */ - function addRawQueryString($querystring) - { - $this->querystring = $this->_parseRawQueryString($querystring); - } - - /** - * Returns flat querystring - * - * @return string Querystring - * @access public - */ - function getQueryString() - { - if (!empty($this->querystring)) { - foreach ($this->querystring as $name => $value) { - if (is_array($value)) { - foreach ($value as $k => $v) { - $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v); - } - } elseif (!is_null($value)) { - $querystring[] = $name . '=' . $value; - } else { - $querystring[] = $name; - } - } - $querystring = implode(ini_get('arg_separator.output'), $querystring); - } else { - $querystring = ''; - } - - return $querystring; - } - - /** - * Parses raw querystring and returns an array of it - * - * @param string $querystring The querystring to parse - * @return array An array of the querystring data - * @access private - */ - function _parseRawQuerystring($querystring) - { - $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY); - $return = array(); - - foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - $value = substr($part, strpos($part, '=') + 1); - $key = substr($part, 0, strpos($part, '=')); - } else { - $value = null; - $key = $part; - } - if (substr($key, -2) == '[]') { - $key = substr($key, 0, -2); - if (@!is_array($return[$key])) { - $return[$key] = array(); - $return[$key][] = $value; - } else { - $return[$key][] = $value; - } - } elseif (!$this->useBrackets AND !empty($return[$key])) { - $return[$key] = (array)$return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - - return $return; - } - - /** - * Resolves //, ../ and ./ from a path and returns - * the result. Eg: - * - * /foo/bar/../boo.php => /foo/boo.php - * /foo/bar/../../boo.php => /boo.php - * /foo/bar/.././/boo.php => /foo/boo.php - * - * This method can also be called statically. - * - * @param string $url URL path to resolve - * @return string The result - */ - function resolvePath($path) - { - $path = explode('/', str_replace('//', '/', $path)); - - for ($i=0; $i 1 OR ($i == 1 AND $path[0] != '') ) ) { - unset($path[$i]); - unset($path[$i-1]); - $path = array_values($path); - $i -= 2; - - } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { - unset($path[$i]); - $path = array_values($path); - $i--; - - } else { - continue; - } - } - - return implode('/', $path); - } - - /** - * Returns the standard port number for a protocol - * - * @param string $scheme The protocol to lookup - * @return integer Port number or NULL if no scheme matches - * - * @author Philippe Jausions - */ - function getStandardPort($scheme) - { - switch (strtolower($scheme)) { - case 'http': return 80; - case 'https': return 443; - case 'ftp': return 21; - case 'imap': return 143; - case 'imaps': return 993; - case 'pop3': return 110; - case 'pop3s': return 995; - default: return null; - } - } - - /** - * Forces the URL to a particular protocol - * - * @param string $protocol Protocol to force the URL to - * @param integer $port Optional port (standard port is used by default) - */ - function setProtocol($protocol, $port = null) - { - $this->protocol = $protocol; - $this->port = is_null($port) ? $this->getStandardPort() : $port; - } - -} -?> diff --git a/libs/PEAR/PEAR.php b/libs/PEAR/PEAR.php deleted file mode 100644 index d2d41b274..000000000 --- a/libs/PEAR/PEAR.php +++ /dev/null @@ -1,1108 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: PEAR.php,v 1.101 2006/04/25 02:41:03 cellog Exp $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -// instant backwards compatibility -if (!defined('PATH_SEPARATOR')) { - if (OS_WINDOWS) { - define('PATH_SEPARATOR', ';'); - } else { - define('PATH_SEPARATOR', ':'); - } -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: 1.5.0 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - // {{{ properties - - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - if ($error_class !== null) { - $this->_error_class = $error_class; - } - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - // }}} - // {{{ destructor - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - // }}} - // {{{ getStaticProperty() - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - return $properties[$class][$var]; - } - - // }}} - // {{{ registerShutdownFunc() - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (is_a($data, 'PEAR_Error')) { - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } else { - return $data->getCode() == $code; - } - } - return false; - } - - // }}} - // {{{ setErrorHandling() - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ expectError() - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return sizeof($this->_expected_errors); - } - - // }}} - // {{{ popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - // }}} - // {{{ _checkDelExpect() - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - - foreach ($this->_expected_errors AS $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - return $deleted; - } - - // }}} - // {{{ delExpect() - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; - // we walk through it trying to unset all - // values - foreach($error_code as $key => $error) { - if ($this->_checkDelExpect($error)) { - $deleted = true; - } else { - $deleted = false; - } - } - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } else { - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - } else { - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp))) { - $mode = PEAR_ERROR_RETURN; - } - } - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - if ($skipmsg) { - $a = &new $ec($code, $mode, $options, $userinfo); - return $a; - } else { - $a = &new $ec($message, $code, $mode, $options, $userinfo); - return $a; - } - } - - // }}} - // {{{ throwError() - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param string $message - * - */ - function &throwError($message = null, - $code = null, - $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } else { - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - } - - // }}} - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - // {{{ pushErrorHandling() - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - // }}} - // {{{ popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - // }}} - // {{{ loadExtension() - - /** - * OS independant PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (!extension_loaded($ext)) { - // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { - return false; - } - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } - return true; - } - - // }}} -} - -// {{{ _PEAR_call_destructors() - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR::getStaticProperty('PEAR', 'destructlifo')) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -// }}} -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: 1.5.0 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - $this->level = $options; - $this->callback = null; - } - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - printf($format, $this->getMessage()); - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - } - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - // }}} - // {{{ getMode() - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() { - return $this->mode; - } - - // }}} - // {{{ getCallback() - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() { - return $this->callback; - } - - // }}} - // {{{ getMessage() - - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - // }}} - // {{{ getBacktrace() - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - // }}} - // {{{ addUserInfo() - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - // }}} - // {{{ toString() - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } - - // }}} -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 2e26eea08..9a99b797a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -237,37 +237,6 @@ return array( 'HTMLPurifier_VarParser_Flexible' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php', 'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php', 'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php', - 'HTTP_Request2' => $vendorDir . '/pear/http_request2/HTTP/Request2.php', - 'HTTP_Request2Test' => $vendorDir . '/pear/http_request2/tests/Request2Test.php', - 'HTTP_Request2_Adapter' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter.php', - 'HTTP_Request2_Adapter_CommonNetworkTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php', - 'HTTP_Request2_Adapter_Curl' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Curl.php', - 'HTTP_Request2_Adapter_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CurlTest.php', - 'HTTP_Request2_Adapter_Mock' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Mock.php', - 'HTTP_Request2_Adapter_MockTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/MockTest.php', - 'HTTP_Request2_Adapter_Skip_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Skip_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Skip_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Socket' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Socket.php', - 'HTTP_Request2_Adapter_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php', - 'HTTP_Request2_Adapter_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketTest.php', - 'HTTP_Request2_AllTests' => $vendorDir . '/pear/http_request2/tests/AllTests.php', - 'HTTP_Request2_ConnectionException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_CookieJar' => $vendorDir . '/pear/http_request2/HTTP/Request2/CookieJar.php', - 'HTTP_Request2_CookieJarTest' => $vendorDir . '/pear/http_request2/tests/Request2/CookieJarTest.php', - 'HTTP_Request2_Exception' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_LogicException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_MessageException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_MockObserver' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', - 'HTTP_Request2_MultipartBody' => $vendorDir . '/pear/http_request2/HTTP/Request2/MultipartBody.php', - 'HTTP_Request2_MultipartBodyTest' => $vendorDir . '/pear/http_request2/tests/Request2/MultipartBodyTest.php', - 'HTTP_Request2_NotImplementedException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_ObserverTest' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', - 'HTTP_Request2_Observer_Log' => $vendorDir . '/pear/http_request2/HTTP/Request2/Observer/Log.php', - 'HTTP_Request2_Response' => $vendorDir . '/pear/http_request2/HTTP/Request2/Response.php', - 'HTTP_Request2_ResponseTest' => $vendorDir . '/pear/http_request2/tests/Request2/ResponseTest.php', - 'HTTP_Request2_SOCKS5' => $vendorDir . '/pear/http_request2/HTTP/Request2/SOCKS5.php', - 'HTTP_Request2_SocketWrapper' => $vendorDir . '/pear/http_request2/HTTP/Request2/SocketWrapper.php', 'MatthiasMullie\\Minify\\CSS' => $vendorDir . '/matthiasmullie/minify/src/CSS.php', 'MatthiasMullie\\Minify\\Exception' => $vendorDir . '/matthiasmullie/minify/src/Exception.php', 'MatthiasMullie\\Minify\\JS' => $vendorDir . '/matthiasmullie/minify/src/JS.php', @@ -276,9 +245,6 @@ return array( 'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', 'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php', 'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php', - 'Net_URL2' => $vendorDir . '/pear/net_url2/Net/URL2.php', - 'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php', - 'PEAR_ExceptionTest' => $vendorDir . '/pear/pear_exception/tests/PEAR/ExceptionTest.php', 'Requests' => $vendorDir . '/rmccue/requests/library/Requests.php', 'Requests_Auth' => $vendorDir . '/rmccue/requests/library/Requests/Auth.php', 'Requests_Auth_Basic' => $vendorDir . '/rmccue/requests/library/Requests/Auth/Basic.php', diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 44320b577..0ba8d72dc 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -8,8 +8,6 @@ $baseDir = dirname($vendorDir); return array( 'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'), 'Requests' => array($vendorDir . '/rmccue/requests/library'), - 'PEAR' => array($vendorDir . '/pear/pear_exception'), 'Michelf' => array($vendorDir . '/michelf/php-markdown'), - 'HTTP_Request2' => array($vendorDir . '/pear/http_request2'), 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 4ad2a5c88..d8899d992 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -23,10 +23,6 @@ class ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de', 'loadClassLoader')); - $includePaths = require __DIR__ . '/include_paths.php'; - array_push($includePaths, get_include_path()); - set_include_path(join(PATH_SEPARATOR, $includePaths)); - $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); diff --git a/vendor/composer/include_paths.php b/vendor/composer/include_paths.php deleted file mode 100644 index 98c3d1374..000000000 --- a/vendor/composer/include_paths.php +++ /dev/null @@ -1,10 +0,0 @@ -=4.4.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "time": "2015-02-10 20:07:52", - "type": "class", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "." - ], - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "description": "The PEAR Exception base class.", - "homepage": "https://github.com/pear/PEAR_Exception", - "keywords": [ - "exception" - ] - }, - { - "name": "pear/net_url2", - "version": "v2.2.0", - "version_normalized": "2.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/pear/Net_URL2.git", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "shasum": "" - }, - "require": { - "php": ">=5.1.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - }, - "time": "2015-04-18 17:36:57", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "classmap": [ - "Net/URL2.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "homepage": "https://github.com/pear/Net_URL2", - "keywords": [ - "PEAR", - "net", - "networking", - "rfc3986", - "uri", - "url" - ] - }, - { - "name": "pear/http_request2", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", - "source": { - "type": "git", - "url": "https://github.com/pear/HTTP_Request2.git", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de", - "shasum": "" - }, - "require": { - "pear/net_url2": ">=2.0.0", - "pear/pear_exception": "*", - "php": ">=5.2.0" - }, - "suggest": { - "ext-fileinfo": "Adds support for looking up mime-types using finfo.", - "ext-zlib": "Allows handling gzip compressed responses.", - "lib-curl": "Allows using cURL as a request backend.", - "lib-openssl": "Allows handling SSL requests when not using cURL." - }, - "time": "2014-01-16 17:27:21", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "HTTP_Request2": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Alexey Borzov", - "email": "avb@php.net", - "role": "Developer HTML_Common2" - } - ], - "description": "Provides an easy way to perform HTTP requests.", - "homepage": "http://pear.php.net/package/HTTP_Request2", - "keywords": [ - "PEAR", - "curl", - "http", - "request" - ] - }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.1", diff --git a/vendor/pear/http_request2/HTTP/Request2.php b/vendor/pear/http_request2/HTTP/Request2.php deleted file mode 100644 index 42156f1d6..000000000 --- a/vendor/pear/http_request2/HTTP/Request2.php +++ /dev/null @@ -1,1030 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - 'local_ip' => null, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - 'proxy_type' => 'http', - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - /** - * Cookie jar to persist cookies between requests - * @var HTTP_Request2_CookieJar - */ - protected $cookieJar = null; - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 $url Request URL - * @param string $method Request method - * @param array $config Configuration for this Request instance - */ - public function __construct( - $url = null, $method = self::METHOD_GET, array $config = array() - ) { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader( - 'user-agent', 'HTTP_Request2/@package_version@ ' . - '(http://pear.php.net/package/http_request2) PHP/' . phpversion() - ); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 $url Request URL - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a valid HTTP URL', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string $method one of the methods defined in RFC 2616 - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_LogicException( - "Invalid request method '{$method}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'local_ip' - Specifies the IP address that will be used for accessing - * the network (string)
  • - *
  • 'proxy_type' - Proxy type, 'http' or 'socks5' (string)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'proxy' - Shorthand for proxy_* parameters, proxy given as URL, - * e.g. 'socks5://localhost:1080/' (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array $nameOrConfig configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed $value parameter value if $nameOrConfig is not an array - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } elseif ('proxy' == $nameOrConfig) { - $url = new Net_URL2($value); - $this->setConfig(array( - 'proxy_type' => $url->getScheme(), - 'proxy_host' => $url->getHost(), - 'proxy_port' => $url->getPort(), - 'proxy_user' => rawurldecode($url->getUser()), - 'proxy_password' => rawurldecode($url->getPassword()) - )); - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$nameOrConfig}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string $name parameter name - * - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string $user user name - * @param string $password password - * @param string $scheme authentication scheme - * - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array $name header name, header string ('Header: value') - * or an array of headers - * @param string|array|null $value header value if $name is not an array, - * header will be removed if value is null - * @param bool $replace whether to replace previous header with the - * same name or append to its value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setHeader($name, $value = null, $replace = true) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v, $replace); - } else { - $this->setHeader($v, null, $replace); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_LogicException( - "Invalid header name '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - - } else { - if (is_array($value)) { - $value = implode(', ', array_map('trim', $value)); - } elseif (is_string($value)) { - $value = trim($value); - } - if (!isset($this->headers[$name]) || $replace) { - $this->headers[$name] = $value; - } else { - $this->headers[$name] .= ', ' . $value; - } - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Adds a cookie to the request - * - * If the request does not have a CookieJar object set, this method simply - * appends a cookie to "Cookie:" header. - * - * If a CookieJar object is available, the cookie is stored in that object. - * Data from request URL will be used for setting its 'domain' and 'path' - * parameters, 'expires' and 'secure' will be set to null and false, - * respectively. If you need further control, use CookieJar's methods. - * - * @param string $name cookie name - * @param string $value cookie value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - * @see setCookieJar() - */ - public function addCookie($name, $value) - { - if (!empty($this->cookieJar)) { - $this->cookieJar->store( - array('name' => $name, 'value' => $value), $this->url - ); - - } else { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_LogicException( - "Invalid cookie: '{$cookie}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - } - - return $this; - } - - /** - * Sets the request body - * - * If you provide file pointer rather than file name, it should support - * fstat() and rewind() operations. - * - * @param string|resource|HTTP_Request2_MultipartBody $body Either a - * string with the body or filename containing body or - * pointer to an open file or object with multipart body data - * @param bool $isFilename Whether - * first parameter is a filename - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename && !is_resource($body)) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - $fileData = $this->fopenWrapper($body, empty($this->headers['content-type'])); - $this->body = $fileData['fp']; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', $fileData['type']); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method - && (!empty($this->postParams) || !empty($this->uploads)) - ) { - if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * If you provide file pointers rather than file names, they should support - * fstat() and rewind() operations. - * - * @param string $fieldName name of file-upload field - * @param string|resource|array $filename full name of local file, - * pointer to open file or an array of files - * @param string $sendFilename filename to send in the request - * @param string $contentType content-type of file being uploaded - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function addUpload( - $fieldName, $filename, $sendFilename = null, $contentType = null - ) { - if (!is_array($filename)) { - $fileData = $this->fopenWrapper($filename, empty($contentType)); - $this->uploads[$fieldName] = array( - 'fp' => $fileData['fp'], - 'filename' => !empty($sendFilename)? $sendFilename - :(is_string($filename)? basename($filename): 'anonymous.blob') , - 'size' => $fileData['size'], - 'type' => empty($contentType)? $fileData['type']: $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - $fileData = $this->fopenWrapper($f[0], empty($f[2])); - $fps[] = $fileData['fp']; - $names[] = !empty($f[1])? $f[1] - :(is_string($f[0])? basename($f[0]): 'anonymous.blob'); - $sizes[] = $fileData['size']; - $types[] = empty($f[2])? $fileData['type']: $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) - || 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array $name parameter name or array ('name' => 'value') - * @param mixed $value parameter value (can be an array) - * - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string $name event name - * @param mixed $data event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'sentBody' - after sending the whole request body, - * data is request body length (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter $adapter Adapter to use - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (!class_exists($adapter, false) - && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter) - ) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_LogicException( - "Class {$adapter} not found", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a HTTP request adapter', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sets the cookie jar - * - * A cookie jar is used to maintain cookies across HTTP requests and - * responses. Cookies from jar will be automatically added to the request - * headers based on request URL. - * - * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to - * create a new one, false to remove - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setCookieJar($jar = true) - { - if (!class_exists('HTTP_Request2_CookieJar', false)) { - require_once 'HTTP/Request2/CookieJar.php'; - } - - if ($jar instanceof HTTP_Request2_CookieJar) { - $this->cookieJar = $jar; - } elseif (true === $jar) { - $this->cookieJar = new HTTP_Request2_CookieJar(); - } elseif (!$jar) { - $this->cookieJar = null; - } else { - throw new HTTP_Request2_LogicException( - 'Invalid parameter passed to setCookieJar()', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - - return $this; - } - - /** - * Returns current CookieJar object or null if none - * - * @return HTTP_Request2_CookieJar|null - */ - public function getCookieJar() - { - return $this->cookieJar; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2 - || !$this->url->isAbsolute() - || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) - ) { - throw new HTTP_Request2_LogicException( - 'HTTP_Request2 needs an absolute HTTP(S) request URL, ' - . ($this->url instanceof Net_URL2 - ? "'" . $this->url->__toString() . "'" : 'none') - . ' given', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Wrapper around fopen()/fstat() used by setBody() and addUpload() - * - * @param string|resource $file file name or pointer to open file - * @param bool $detectType whether to try autodetecting MIME - * type of file, will only work if $file is a - * filename, not pointer - * - * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) - * @throws HTTP_Request2_LogicException - */ - protected function fopenWrapper($file, $detectType = false) - { - if (!is_string($file) && !is_resource($file)) { - throw new HTTP_Request2_LogicException( - "Filename or file pointer resource expected", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $fileData = array( - 'fp' => is_string($file)? null: $file, - 'type' => 'application/octet-stream', - 'size' => 0 - ); - if (is_string($file)) { - if (!($fileData['fp'] = @fopen($file, 'rb'))) { - $error = error_get_last(); - throw new HTTP_Request2_LogicException( - $error['message'], HTTP_Request2_Exception::READ_ERROR - ); - } - if ($detectType) { - $fileData['type'] = self::detectMimeType($file); - } - } - if (!($stat = fstat($fileData['fp']))) { - throw new HTTP_Request2_LogicException( - "fstat() call failed", HTTP_Request2_Exception::READ_ERROR - ); - } - $fileData['size'] = $stat['size']; - - return $fileData; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string $filename file name - * - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter.php b/vendor/pear/http_request2/HTTP/Request2/Adapter.php deleted file mode 100644 index 01c796a06..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array &$headers associative array of request headers, this method - * will add proper 'Content-Length' and 'Content-Type' - * headers to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) - if (!isset($headers['transfer-encoding'])) { - $headers['content-length'] = $this->contentLength; - } - } - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index 777135921..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,567 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array - */ - protected static $errorMap = array( - CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), - // error returned from write callback - CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TIMEOUT), - CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), - CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS), - CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), - CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), - CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), - CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::INVALID_ARGUMENT), - CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), - CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), - CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Creates a subclass of HTTP_Request2_Exception from curl error data - * - * @param resource $ch curl handle - * - * @return HTTP_Request2_Exception - */ - protected static function wrapCurlError($ch) - { - $nativeCode = curl_errno($ch); - $message = 'Curl error: ' . curl_error($ch); - if (!isset(self::$errorMap[$nativeCode])) { - return new HTTP_Request2_Exception($message, 0, $nativeCode); - } else { - $class = self::$errorMap[$nativeCode][0]; - $code = empty(self::$errorMap[$nativeCode][1]) - ? 0 : self::$errorMap[$nativeCode][1]; - return new $class($message, $code, $nativeCode); - } - } - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_LogicException( - 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $e = self::wrapCurlError($ch); - } - } catch (Exception $e) { - } - if (isset($ch)) { - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - } - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_NotImplementedException - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) { - throw new HTTP_Request2_LogicException( - 'Redirect support in curl is unavailable due to open_basedir or safe_mode setting', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // set local IP via CURLOPT_INTERFACE (request #19515) - if ($ip = $this->request->getConfig('local_ip')) { - curl_setopt($ch, CURLOPT_INTERFACE, $ip); - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - case HTTP_Request2::METHOD_PUT: - curl_setopt($ch, CURLOPT_UPLOAD, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE - ); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt( - $ch, CURLOPT_PROXYUSERPWD, - $user . ':' . $this->request->getConfig('proxy_password') - ); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - if ($type = $this->request->getConfig('proxy_type')) { - switch ($type) { - case 'http': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - break; - case 'socks5': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); - break; - default: - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource $ch cURL handle - * @param array &$headers Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - } else { - // rewind may be needed, read the whole body into memory - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource $ch cURL handle - * @param resource $fd file descriptor (not used) - * @param integer $length maximum length of data to return - * - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource $ch cURL handle - * @param string $string response header (with trailing CRLF) - * - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders - || $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - if ($upload && (!$this->eventSentHeaders - || $this->response->getStatus() >= 200) - ) { - $this->request->setLastEvent('sentBody', $upload); - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response( - $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) - ); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - - if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - - // for versions lower than 5.2.10, check the redirection URL protocol - if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - - if ($jar = $this->request->getCookieJar()) { - $jar->addCookiesFromResponse($this->response, $this->request->getUrl()); - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $this->request->getUrl()->resolve($redirectUrl); - } - if ($cookies = $jar->getMatching($redirectUrl, true)) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource $ch cURL handle (not used) - * @param string $string part of the response body - * - * @return integer number of bytes saved - * @throws HTTP_Request2_MessageException - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$string}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index aeaf3eeb7..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * Only responses without explicit URLs or with URLs equal to request URL - * will be considered. If matching response is not found or the queue is - * empty then default empty response with status 400 will be returned, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $requestUrl = (string)$request->getUrl(); - $response = null; - foreach ($this->responses as $k => $v) { - if (!$v[1] || $requestUrl == $v[1]) { - $response = $v[0]; - array_splice($this->responses, $k, 1); - break; - } - } - if (!$response) { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - - } elseif ($response instanceof HTTP_Request2_Response) { - return $response; - - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } - - /** - * Adds response to the queue - * - * @param mixed $response either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @param string $url A request URL this response should be valid for - * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) - * - * @throws HTTP_Request2_Exception - */ - public function addResponse($response, $url = null) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = array($response, $url); - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string $str string containing HTTP response message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource $fp file pointer returned by fopen() - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index f18c4f5b3..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1121 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Base class for HTTP_Request2 adapters */ -require_once 'HTTP/Request2/Adapter.php'; - -/** Socket wrapper class */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Whether to wait for "100 Continue" response before sending request body - * @var bool - */ - protected $expect100Continue = false; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - $this->socket->write($headers); - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - - if (!$this->expect100Continue) { - $this->writeBody(); - $response = $this->readResponse(); - - } else { - $response = $this->readResponse(); - if (!$response || 100 == $response->getStatus()) { - $this->expect100Continue = false; - // either got "100 Continue" or timed out -> send body - $this->writeBody(); - $response = $this->readResponse(); - } - } - - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - $this->redirectCountdown = null; - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - $this->redirectCountdown = null; - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - $httpProxy = $socksProxy = false; - if (!($host = $this->request->getConfig('proxy_host'))) { - $host = $reqHost; - $port = $reqPort; - } else { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ('http' == ($type = $this->request->getConfig('proxy_type'))) { - $httpProxy = true; - } elseif ('socks5' == $type) { - $socksProxy = true; - } else { - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - - if ($tunnel && !$httpProxy) { - throw new HTTP_Request2_LogicException( - "Trying to perform CONNECT request without proxy", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_LogicException( - 'Need OpenSSL support for https:// requests', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($httpProxy && !$secure && !empty($headers['connection']) - && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - - $options = array(); - if ($ip = $this->request->getConfig('local_ip')) { - $options['socket'] = array( - 'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0' - ); - } - if ($secure || $tunnel) { - $options['ssl'] = array(); - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['ssl']['CN_match'] = $reqHost; - } - } else { - $options['ssl'][substr($name, 4)] = $value; - } - } - } - ksort($options['ssl']); - } - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $this->request->getConfig('timeout')) { - $deadline = time() + $timeout; - } else { - $deadline = null; - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = ((!$secure || $httpProxy || $socksProxy)? 'tcp://': 'ssl://') - . $host . ':' . $port; - $socketKey = $remote . ( - ($secure && $httpProxy || $socksProxy) - ? "->{$reqHost}:{$reqPort}" : '' - ) . (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) - && !self::$sockets[$socketKey]->eof() - ) { - $this->socket =& self::$sockets[$socketKey]; - - } else { - if ($socksProxy) { - require_once 'HTTP/Request2/SOCKS5.php'; - - $this->socket = new HTTP_Request2_SOCKS5( - $remote, $this->request->getConfig('connect_timeout'), - $options, $this->request->getConfig('proxy_user'), - $this->request->getConfig('proxy_password') - ); - // handle request timeouts ASAP - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - $this->socket->connect($reqHost, $reqPort); - if (!$secure) { - $conninfo = "tcp://{$reqHost}:{$reqPort} via {$remote}"; - } else { - $this->socket->enableCrypto(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - } - - } elseif ($secure && $httpProxy && !$tunnel) { - $this->establishTunnel(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - - } else { - $this->socket = new HTTP_Request2_SocketWrapper( - $remote, $this->request->getConfig('connect_timeout'), $options - ); - } - $this->request->setLastEvent('connect', empty($conninfo)? $remote: $conninfo); - self::$sockets[$socketKey] =& $this->socket; - } - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_ConnectionException( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - $this->socket->enableCrypto(); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean $requestKeepAlive whether connection could - * be persistent in the first place - * @param HTTP_Request2_Response $response response object to check - * - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) - || null !== $response->getHeader('content-length') - // no body possible for such responses, see also request #17031 - || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || in_array($response->getStatus(), array(204, 304)); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (!empty($this->socket)) { - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 $request Original request - * @param HTTP_Request2_Response $response Response containing redirect - * - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect( - HTTP_Request2 $request, HTTP_Request2_Response $response - ) { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - $this->redirectCountdown = null; - // Copying cURL behaviour - throw new HTTP_Request2_MessageException( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - $this->redirectCountdown = null; - throw new HTTP_Request2_MessageException( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), - HTTP_Request2_Exception::NON_HTTP_REDIRECT - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() - || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) - || (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header - * - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) - && !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_NotImplementedException( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_NotImplementedException( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array &$challenge challenge to update - * @param string $headerValue value of [Proxy-]Authentication-Info header - * - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string $user user name - * @param string $password password - * @param string $url request URL - * @param array &$challenge digest challenge parameters - * - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) - && $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5( - $a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2 - ); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestHost request host (needed for digest authentication) - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = 'Basic ' . base64_encode( - $auth['user'] . ':' . $auth['password'] - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') - || !($user = $this->request->getConfig('proxy_user')) - || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) - && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = 'Basic ' . base64_encode( - $user . ':' . $password - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') - || 'http' != $this->request->getConfig('proxy_type') - || 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') - && extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - if ('1.1' == $this->request->getConfig('protocol_version')) { - $this->updateExpectHeader($headers); - } else { - $this->expect100Continue = false; - } - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Adds or removes 'Expect: 100-continue' header from request headers - * - * Also sets the $expect100Continue property. Parsing of existing header - * is somewhat needed due to its complex structure and due to the - * requirement in section 8.2.3 of RFC 2616: - * > A client MUST NOT send an Expect request-header field (section - * > 14.20) with the "100-continue" expectation if it does not intend - * > to send a request body. - * - * @param array &$headers Array of headers prepared for the request - * - * @throws HTTP_Request2_LogicException - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 - */ - protected function updateExpectHeader(&$headers) - { - $this->expect100Continue = false; - $expectations = array(); - if (isset($headers['expect'])) { - if ('' === $headers['expect']) { - // empty 'Expect' header is technically invalid, so just get rid of it - unset($headers['expect']); - return; - } - // build regexp to parse the value of existing Expect header - $expectParam = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . '))?\s*'; - $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . ')\s*(?:' - . $expectParam . ')*)?'; - $expectItem = '!(100-continue|' . $expectExtension . ')!A'; - - $pos = 0; - $length = strlen($headers['expect']); - - while ($pos < $length) { - $pos += strspn($headers['expect'], " \t", $pos); - if (',' === substr($headers['expect'], $pos, 1)) { - $pos++; - continue; - - } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) { - throw new HTTP_Request2_LogicException( - "Cannot parse value '{$headers['expect']}' of Expect header", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - - } else { - $pos += strlen($m[0]); - if (strcasecmp('100-continue', $m[0])) { - $expectations[] = $m[0]; - } - } - } - } - - if (1024 < $this->contentLength) { - $expectations[] = '100-continue'; - $this->expect100Continue = true; - } - - if (empty($expectations)) { - unset($headers['expect']); - } else { - $headers['expect'] = implode(',', $expectations); - } - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_MessageException - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - $headers = $this->request->getHeaders(); - $chunked = isset($headers['transfer-encoding']); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (!$chunked) { - $this->socket->write($str); - } else { - $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n"); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - - // write zero-length chunk - if ($chunked) { - $this->socket->write("0\r\n\r\n"); - } - $this->request->setLastEvent('sentBody', $this->contentLength); - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - // http://tools.ietf.org/html/rfc2616#section-8.2.3 - // ...the client SHOULD NOT wait for an indefinite period before sending the request body - $timeout = $this->expect100Continue ? 1 : null; - - do { - try { - $response = new HTTP_Request2_Response( - $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl() - ); - do { - $headerLine = $this->socket->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - - } catch (HTTP_Request2_MessageException $e) { - if (HTTP_Request2_Exception::TIMEOUT === $e->getCode() - && $this->expect100Continue - ) { - return null; - } - throw $e; - } - if ($this->expect100Continue && 100 == $response->getStatus()) { - return $response; - } - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus()) - || in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!$this->socket->eof() && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->socket->read($bufferSize); - } else { - $data = $this->socket->read(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || $this->socket->eof())) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int $bufferSize buffer size to use for reading - * - * @return string - * @throws HTTP_Request2_MessageException - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->socket->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_MessageException( - "Cannot decode chunked response, invalid chunk length '{$line}'", - HTTP_Request2_Exception::DECODE_ERROR - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); - return ''; - } - } - } - $data = $this->socket->read(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/CookieJar.php b/vendor/pear/http_request2/HTTP/Request2/CookieJar.php deleted file mode 100644 index ed6352ebe..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/CookieJar.php +++ /dev/null @@ -1,494 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Class representing a HTTP request message */ -require_once 'HTTP/Request2.php'; - -/** - * Stores cookies and passes them between HTTP requests - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_CookieJar implements Serializable -{ - /** - * Array of stored cookies - * - * The array is indexed by domain, path and cookie name - * .example.com - * / - * some_cookie => cookie data - * /subdir - * other_cookie => cookie data - * .example.org - * ... - * - * @var array - */ - protected $cookies = array(); - - /** - * Whether session cookies should be serialized when serializing the jar - * @var bool - */ - protected $serializeSession = false; - - /** - * Whether Public Suffix List should be used for domain matching - * @var bool - */ - protected $useList = true; - - /** - * Array with Public Suffix List data - * @var array - * @link http://publicsuffix.org/ - */ - protected static $psl = array(); - - /** - * Class constructor, sets various options - * - * @param bool $serializeSessionCookies Controls serializing session cookies, - * see {@link serializeSessionCookies()} - * @param bool $usePublicSuffixList Controls using Public Suffix List, - * see {@link usePublicSuffixList()} - */ - public function __construct( - $serializeSessionCookies = false, $usePublicSuffixList = true - ) { - $this->serializeSessionCookies($serializeSessionCookies); - $this->usePublicSuffixList($usePublicSuffixList); - } - - /** - * Returns current time formatted in ISO-8601 at UTC timezone - * - * @return string - */ - protected function now() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - return $dt->format(DateTime::ISO8601); - } - - /** - * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields - * - * The checks are as follows: - * - cookie array should contain 'name' and 'value' fields; - * - name and value should not contain disallowed symbols; - * - 'expires' should be either empty parseable by DateTime; - * - 'domain' and 'path' should be either not empty or an URL where - * cookie was set should be provided. - * - if $setter is provided, then document at that URL should be allowed - * to set a cookie for that 'domain'. If $setter is not provided, - * then no domain checks will be made. - * - * 'expires' field will be converted to ISO8601 format from COOKIE format, - * 'domain' and 'path' will be set from setter URL if empty. - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @return array Updated cookie array - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - */ - protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) - { - if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { - throw new HTTP_Request2_LogicException( - "Cookie array should contain 'name' and 'value' fields", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie name: '{$cookie['name']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie value: '{$cookie['value']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); - - // Need ISO-8601 date @ UTC timezone - if (!empty($cookie['expires']) - && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires']) - ) { - try { - $dt = new DateTime($cookie['expires']); - $dt->setTimezone(new DateTimeZone('UTC')); - $cookie['expires'] = $dt->format(DateTime::ISO8601); - } catch (Exception $e) { - throw new HTTP_Request2_LogicException($e->getMessage()); - } - } - - if (empty($cookie['domain']) || empty($cookie['path'])) { - if (!$setter) { - throw new HTTP_Request2_LogicException( - 'Cookie misses domain and/or path component, cookie setter URL needed', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (empty($cookie['domain'])) { - if ($host = $setter->getHost()) { - $cookie['domain'] = $host; - } else { - throw new HTTP_Request2_LogicException( - 'Setter URL does not contain host part, can\'t set cookie domain', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - if (empty($cookie['path'])) { - $path = $setter->getPath(); - $cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); - } - } - - if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) { - throw new HTTP_Request2_MessageException( - "Domain " . $setter->getHost() . " cannot set cookies for " - . $cookie['domain'] - ); - } - - return $cookie; - } - - /** - * Stores a cookie in the jar - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @throws HTTP_Request2_Exception - */ - public function store(array $cookie, Net_URL2 $setter = null) - { - $cookie = $this->checkAndUpdateFields($cookie, $setter); - - if (strlen($cookie['value']) - && (is_null($cookie['expires']) || $cookie['expires'] > $this->now()) - ) { - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - - } elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) { - unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]); - } - } - - /** - * Adds cookies set in HTTP response to the jar - * - * @param HTTP_Request2_Response $response HTTP response message - * @param Net_URL2 $setter original request URL, needed for - * setting default domain/path - */ - public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter) - { - foreach ($response->getCookies() as $cookie) { - $this->store($cookie, $setter); - } - } - - /** - * Returns all cookies matching a given request URL - * - * The following checks are made: - * - cookie domain should match request host - * - cookie path should be a prefix for request path - * - 'secure' cookies will only be sent for HTTPS requests - * - * @param Net_URL2 $url Request url - * @param bool $asString Whether to return cookies as string for "Cookie: " header - * - * @return array|string Matching cookies - */ - public function getMatching(Net_URL2 $url, $asString = false) - { - $host = $url->getHost(); - $path = $url->getPath(); - $secure = 0 == strcasecmp($url->getScheme(), 'https'); - - $matched = $ret = array(); - foreach (array_keys($this->cookies) as $domain) { - if ($this->domainMatch($host, $domain)) { - foreach (array_keys($this->cookies[$domain]) as $cPath) { - if (0 === strpos($path, $cPath)) { - foreach ($this->cookies[$domain][$cPath] as $name => $cookie) { - if (!$cookie['secure'] || $secure) { - $matched[$name][strlen($cookie['path'])] = $cookie; - } - } - } - } - } - } - foreach ($matched as $cookies) { - krsort($cookies); - $ret = array_merge($ret, $cookies); - } - if (!$asString) { - return $ret; - } else { - $str = ''; - foreach ($ret as $c) { - $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value']; - } - return $str; - } - } - - /** - * Returns all cookies stored in a jar - * - * @return array - */ - public function getAll() - { - $cookies = array(); - foreach (array_keys($this->cookies) as $domain) { - foreach (array_keys($this->cookies[$domain]) as $path) { - foreach ($this->cookies[$domain][$path] as $name => $cookie) { - $cookies[] = $cookie; - } - } - } - return $cookies; - } - - /** - * Sets whether session cookies should be serialized when serializing the jar - * - * @param boolean $serialize serialize? - */ - public function serializeSessionCookies($serialize) - { - $this->serializeSession = (bool)$serialize; - } - - /** - * Sets whether Public Suffix List should be used for restricting cookie-setting - * - * Without PSL {@link domainMatch()} will only prevent setting cookies for - * top-level domains like '.com' or '.org'. However, it will not prevent - * setting a cookie for '.co.uk' even though only third-level registrations - * are possible in .uk domain. - * - * With the List it is possible to find the highest level at which a domain - * may be registered for a particular top-level domain and consequently - * prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by - * Firefox, Chrome and Opera browsers to restrict cookie setting. - * - * Note that PSL is licensed differently to HTTP_Request2 package (refer to - * the license information in public-suffix-list.php), so you can disable - * its use if this is an issue for you. - * - * @param boolean $useList use the list? - * - * @link http://publicsuffix.org/learn/ - */ - public function usePublicSuffixList($useList) - { - $this->useList = (bool)$useList; - } - - /** - * Returns string representation of object - * - * @return string - * - * @see Serializable::serialize() - */ - public function serialize() - { - $cookies = $this->getAll(); - if (!$this->serializeSession) { - for ($i = count($cookies) - 1; $i >= 0; $i--) { - if (empty($cookies[$i]['expires'])) { - unset($cookies[$i]); - } - } - } - return serialize(array( - 'cookies' => $cookies, - 'serializeSession' => $this->serializeSession, - 'useList' => $this->useList - )); - } - - /** - * Constructs the object from serialized string - * - * @param string $serialized string representation - * - * @see Serializable::unserialize() - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $now = $this->now(); - $this->serializeSessionCookies($data['serializeSession']); - $this->usePublicSuffixList($data['useList']); - foreach ($data['cookies'] as $cookie) { - if (!empty($cookie['expires']) && $cookie['expires'] <= $now) { - continue; - } - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - } - } - - /** - * Checks whether a cookie domain matches a request host. - * - * The method is used by {@link store()} to check for whether a document - * at given URL can set a cookie with a given domain attribute and by - * {@link getMatching()} to find cookies matching the request URL. - * - * @param string $requestHost request host - * @param string $cookieDomain cookie domain - * - * @return bool match success - */ - public function domainMatch($requestHost, $cookieDomain) - { - if ($requestHost == $cookieDomain) { - return true; - } - // IP address, we require exact match - if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) { - return false; - } - if ('.' != $cookieDomain[0]) { - $cookieDomain = '.' . $cookieDomain; - } - // prevents setting cookies for '.com' and similar domains - if (!$this->useList && substr_count($cookieDomain, '.') < 2 - || $this->useList && !self::getRegisteredDomain($cookieDomain) - ) { - return false; - } - return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain; - } - - /** - * Removes subdomains to get the registered domain (the first after top-level) - * - * The method will check Public Suffix List to find out where top-level - * domain ends and registered domain starts. It will remove domain parts - * to the left of registered one. - * - * @param string $domain domain name - * - * @return string|bool registered domain, will return false if $domain is - * either invalid or a TLD itself - */ - public static function getRegisteredDomain($domain) - { - $domainParts = explode('.', ltrim($domain, '.')); - - // load the list if needed - if (empty(self::$psl)) { - $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2'; - if (0 === strpos($path, '@' . 'data_dir@')) { - $path = realpath( - dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' - ); - } - self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php'; - } - - if (!($result = self::checkDomainsList($domainParts, self::$psl))) { - // known TLD, invalid domain name - return false; - } - - // unknown TLD - if (!strpos($result, '.')) { - // fallback to checking that domain "has at least two dots" - if (2 > ($count = count($domainParts))) { - return false; - } - return $domainParts[$count - 2] . '.' . $domainParts[$count - 1]; - } - return $result; - } - - /** - * Recursive helper method for {@link getRegisteredDomain()} - * - * @param array $domainParts remaining domain parts - * @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check - * - * @return string|null concatenated domain parts, null in case of error - */ - protected static function checkDomainsList(array $domainParts, $listNode) - { - $sub = array_pop($domainParts); - $result = null; - - if (!is_array($listNode) || is_null($sub) - || array_key_exists('!' . $sub, $listNode) - ) { - return $sub; - - } elseif (array_key_exists($sub, $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode[$sub]); - - } elseif (array_key_exists('*', $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode['*']); - - } else { - return $sub; - } - - return (strlen($result) > 0) ? ($result . '.' . $sub) : null; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Exception.php b/vendor/pear/http_request2/HTTP/Request2/Exception.php deleted file mode 100644 index d331372bf..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Exception.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Base exception class for HTTP_Request2 package - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ - /** An invalid argument was passed to a method */ - const INVALID_ARGUMENT = 1; - /** Some required value was not available */ - const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ - const MISCONFIGURATION = 3; - /** Error reading the local file */ - const READ_ERROR = 4; - - /** Server returned a response that does not conform to HTTP protocol */ - const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ - const DECODE_ERROR = 20; - /** Operation timed out */ - const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ - const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ - const NON_HTTP_REDIRECT = 50; - - /** - * Native error code - * @var int - */ - private $_nativeCode; - - /** - * Constructor, can set package error code and native error code - * - * @param string $message exception message - * @param int $code package error code, one of class constants - * @param int $nativeCode error code from underlying PHP extension - */ - public function __construct($message = null, $code = null, $nativeCode = null) - { - parent::__construct($message, $code); - $this->_nativeCode = $nativeCode; - } - - /** - * Returns error code produced by underlying PHP extension - * - * For Socket Adapter this may contain error number returned by - * stream_socket_client(), for Curl Adapter this will contain error number - * returned by curl_errno() - * - * @return integer - */ - public function getNativeCode() - { - return $this->_nativeCode; - } -} - -/** - * Exception thrown in case of missing features - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception -{ -} - -/** - * Exception that represents error in the program logic - * - * This exception usually implies a programmer's error, like passing invalid - * data to methods or trying to use PHP extensions that weren't installed or - * enabled. Usually exceptions of this kind will be thrown before request even - * starts. - * - * The exception will usually contain a package error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_LogicException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when connection to a web or proxy server fails - * - * The exception will not contain a package error code, but will contain - * native error code, as returned by stream_socket_client() or curl_errno(). - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when sending or receiving HTTP message fails - * - * The exception may contain both package error code and native error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_MessageException extends HTTP_Request2_Exception -{ -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php b/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php deleted file mode 100644 index 54d23ec1a..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception class for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array $params values of form fields set via - * {@link HTTP_Request2::addPostParameter()} - * @param array $uploads file uploads set via - * {@link HTTP_Request2::addUpload()} - * @param bool $useBrackets whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer $length Number of bytes to read - * - * @return string Up to $length bytes of data, empty string if at end - * @throws HTTP_Request2_LogicException - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf( - $this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0] - ) . $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf( - $this->_headerUpload, $boundary, $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type'] - ); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($filePos < $this->_uploads[$pos]['size']) { - while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) { - if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) { - throw new HTTP_Request2_LogicException( - 'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR - ); - } - $ret .= $chunk; - $length -= strlen($chunk); - } - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string $name name for item - * @param mixed $values item's values - * @param bool $useBrackets whether to append [] to array variables' names - * - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php b/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 2ba9f59df..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBody', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBody': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf( - '< HTTP/%s %s %s', $event['data']->getVersion(), - $event['data']->getStatus(), $event['data']->getReasonPhrase() - )); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Response.php b/vendor/pear/http_request2/HTTP/Request2/Response.php deleted file mode 100644 index 56ee6c689..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Response.php +++ /dev/null @@ -1,631 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Effective URL (may be different from original request URL in case of redirects) - * @var string - */ - protected $effectiveUrl; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Returns the default reason phrase for the given code or all reason phrases - * - * @param int $code Response code - * - * @return string|array|null Default reason phrase for $code if $code is given - * (null if no phrase is available), array of all - * reason phrases if $code is null - * @link http://pear.php.net/bugs/18716 - */ - public static function getDefaultReasonPhrase($code = null) - { - if (null === $code) { - return self::$phrases; - } else { - return isset(self::$phrases[$code]) ? self::$phrases[$code] : null; - } - } - - /** - * Constructor, parses the response status line - * - * @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding - * @param string $effectiveUrl Effective URL of the response - * - * @throws HTTP_Request2_MessageException if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$statusLine}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - $this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code); - $this->bodyEncoded = (bool)$bodyEncoded; - $this->effectiveUrl = (string)$effectiveUrl; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string $headerLine Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - if ('' == $headerLine) { - // empty string signals the end of headers, process the received ones - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - // string of the form header-name: header value - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - // continuation of a previous header - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string $cookieString value of Set-Cookie header - * - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - if (!strpos($cookieString, ';')) { - // Only a name=value pair - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - } else { - // Some optional parameters are supplied - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * - * @param string $bodyChunk part of response body - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the effective URL of the response - * - * This may be different from the request URL if redirects were followed. - * - * @return string - * @link http://pear.php.net/bugs/bug.php?id=18412 - */ - public function getEffectiveUrl() - { - return $this->effectiveUrl; - } - - /** - * Returns the status code - * - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string $headerName Name of header to return - * - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (0 == strlen($this->body) || !$this->bodyEncoded - || !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string $data gzip-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: unknown compression method', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: reserved bits are set', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_MessageException( - 'Header CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_MessageException( - 'gzinflate() call failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_MessageException( - 'Data size check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception( - 'Data CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string $data deflate-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php b/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php deleted file mode 100644 index a801c17e8..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Socket wrapper class used by Socket Adapter */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * SOCKS5 proxy connection class (used by Socket Adapter) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper -{ - /** - * Constructor, tries to connect and authenticate to a SOCKS5 proxy - * - * @param string $address Proxy address, e.g. 'tcp://localhost:1080' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Stream context options - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function __construct( - $address, $timeout = 10, array $contextOptions = array(), - $username = null, $password = null - ) { - parent::__construct($address, $timeout, $contextOptions); - - if (strlen($username)) { - $request = pack('C4', 5, 2, 0, 2); - } else { - $request = pack('C3', 5, 1, 0); - } - $this->write($request); - $response = unpack('Cversion/Cmethod', $this->read(3)); - if (5 != $response['version']) { - throw new HTTP_Request2_MessageException( - 'Invalid version received from SOCKS5 proxy: ' . $response['version'], - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - switch ($response['method']) { - case 2: - $this->performAuthentication($username, $password); - case 0: - break; - default: - throw new HTTP_Request2_ConnectionException( - "Connection rejected by proxy due to unsupported auth method" - ); - } - } - - /** - * Performs username/password authentication for SOCKS5 - * - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1929 - */ - protected function performAuthentication($username, $password) - { - $request = pack('C2', 1, strlen($username)) . $username - . pack('C', strlen($password)) . $password; - - $this->write($request); - $response = unpack('Cvn/Cstatus', $this->read(3)); - if (1 != $response['vn'] || 0 != $response['status']) { - throw new HTTP_Request2_ConnectionException( - 'Connection rejected by proxy due to invalid username and/or password' - ); - } - } - - /** - * Connects to a remote host via proxy - * - * @param string $remoteHost Remote host - * @param int $remotePort Remote port - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function connect($remoteHost, $remotePort) - { - $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) - . $remoteHost . pack('n', $remotePort); - - $this->write($request); - $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); - if (5 != $response['version'] || 0 != $response['reserved']) { - throw new HTTP_Request2_MessageException( - 'Invalid response received from SOCKS5 proxy', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } elseif (0 != $response['reply']) { - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", - 0, $response['reply'] - ); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php b/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php deleted file mode 100644 index 41497ba96..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception classes for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Socket wrapper class used by Socket Adapter - * - * Needed to properly handle connection errors, global timeout support and - * similar things. Loosely based on Net_Socket used by older HTTP_Request. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SocketWrapper -{ - /** - * PHP warning messages raised during stream_socket_client() call - * @var array - */ - protected $connectionWarnings = array(); - - /** - * Connected socket - * @var resource - */ - protected $socket; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline; - - /** - * Global timeout value, mostly for exception messages - * @var integer - */ - protected $timeout; - - /** - * Class constructor, tries to establish connection - * - * @param string $address Address for stream_socket_client() call, - * e.g. 'tcp://localhost:80' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Context options - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - */ - public function __construct($address, $timeout, array $contextOptions = array()) - { - if (!empty($contextOptions) - && !isset($contextOptions['socket']) && !isset($contextOptions['ssl']) - ) { - // Backwards compatibility with 2.1.0 and 2.1.1 releases - $contextOptions = array('ssl' => $contextOptions); - } - $context = stream_context_create(); - foreach ($contextOptions as $wrapper => $options) { - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, $wrapper, $name, $value)) { - throw new HTTP_Request2_LogicException( - "Error setting '{$wrapper}' wrapper context option '{$name}'" - ); - } - } - } - set_error_handler(array($this, 'connectionWarningsHandler')); - $this->socket = stream_socket_client( - $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context - ); - restore_error_handler(); - // if we fail to bind to a specified local address (see request #19515), - // connection still succeeds, albeit with a warning. Throw an Exception - // with the warning text in this case as that connection is unlikely - // to be what user wants and as Curl throws an error in similar case. - if ($this->connectionWarnings) { - if ($this->socket) { - fclose($this->socket); - } - $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings); - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$address}. Error: {$error}", 0, $errno - ); - } - } - - /** - * Destructor, disconnects socket - */ - public function __destruct() - { - fclose($this->socket); - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int $length Reads up to this number of bytes - * - * @return string Data read from socket - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function read($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $this->checkTimeout(); - return $data; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int $bufferSize buffer size to use for reading - * @param int $localTimeout timeout value to use just for this call - * (used when waiting for "100 Continue" response) - * - * @return string Available data up to the newline (not including newline) - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function readLine($bufferSize, $localTimeout = null) - { - $line = ''; - while (!feof($this->socket)) { - if (null !== $localTimeout) { - stream_set_timeout($this->socket, $localTimeout); - } elseif ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - - $line .= @fgets($this->socket, $bufferSize); - - if (null === $localTimeout) { - $this->checkTimeout(); - - } else { - $info = stream_get_meta_data($this->socket); - // reset socket timeout if we don't have request timeout specified, - // prevents further calls failing with a bogus Exception - if (!$this->deadline) { - $default = (int)@ini_get('default_socket_timeout'); - stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX); - } - if ($info['timed_out']) { - throw new HTTP_Request2_MessageException( - "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT - ); - } - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fwrite(), handles global request timeout - * - * @param string $data String to be written - * - * @return int - * @throws HTTP_Request2_MessageException - */ - public function write($data) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $written = fwrite($this->socket, $data); - $this->checkTimeout(); - // http://www.php.net/manual/en/function.fwrite.php#96951 - if ($written < strlen($data)) { - throw new HTTP_Request2_MessageException('Error writing request'); - } - return $written; - } - - /** - * Tests for end-of-file on a socket - * - * @return bool - */ - public function eof() - { - return feof($this->socket); - } - - /** - * Sets request deadline - * - * @param int $deadline Exception will be thrown if request continues - * past this time - * @param int $timeout Original request timeout value, to use in - * Exception message - */ - public function setDeadline($deadline, $timeout) - { - $this->deadline = $deadline; - $this->timeout = $timeout; - } - - /** - * Turns on encryption on a socket - * - * @throws HTTP_Request2_ConnectionException - */ - public function enableCrypto() - { - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_ConnectionException( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Throws an Exception if stream timed out - * - * @throws HTTP_Request2_MessageException - */ - protected function checkTimeout() - { - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? "after {$this->timeout} second(s)" - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_MessageException( - "Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT - ); - } - } - - /** - * Error handler to use during stream_socket_client() call - * - * One stream_socket_client() call may produce *multiple* PHP warnings - * (especially OpenSSL-related), we keep them in an array to later use for - * the message of HTTP_Request2_ConnectionException - * - * @param int $errno error level - * @param string $errstr error message - * - * @return bool - */ - protected function connectionWarningsHandler($errno, $errstr) - { - if ($errno & E_WARNING) { - array_unshift($this->connectionWarnings, $errstr); - } - return true; - } -} -?> diff --git a/vendor/pear/http_request2/README.md b/vendor/pear/http_request2/README.md deleted file mode 100644 index eef00606b..000000000 --- a/vendor/pear/http_request2/README.md +++ /dev/null @@ -1,80 +0,0 @@ - -# HTTP_Request2 - -Provides an easy way to perform HTTP requests, uses pluggable adapters - -* Socket: pure PHP implementation of HTTP protocol (does *not* use http stream wrapper), based on older [PEAR HTTP_Request] package -* Curl: wrapper around PHP's cURL extension -* Mock: used for testing packages depending on HTTP_Request2, returns predefined responses without network interaction - -Both Socket and Curl adapters support POST requests with data and file uploads, basic and digest -authentication, cookies, managing cookies across requests, HTTP and SOCKS5 proxies, gzip and -deflate encodings, redirects, monitoring the request progress with Observers... - -This package is [PEAR HTTP_Request2] and has been migrated from [PEAR SVN] - -Please report all issues via the [PEAR bug tracker]. - -Pull requests are welcome. - -[PEAR HTTP_Request]: http://pear.php.net/package/HTTP_Request/ -[PEAR HTTP_Request2]: http://pear.php.net/package/HTTP_Request2/ -[PEAR SVN]: https://svn.php.net/repository/pear/packages/HTTP_Request2 -[PEAR bug tracker]: http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2 - -## Basic usage - -```PHP -require_once 'HTTP/Request2.php'; - -$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET); -try { - $response = $request->send(); - if (200 == $response->getStatus()) { - echo $response->getBody(); - } else { - echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . - $response->getReasonPhrase(); - } -} catch (HTTP_Request2_Exception $e) { - echo 'Error: ' . $e->getMessage(); -} -``` - -## Documentation - -...is available on PEAR website - - * Numerous [configuration options](http://pear.php.net/manual/en/package.http.http-request2.config.php) - * How to populate [the request object](http://pear.php.net/manual/en/package.http.http-request2.request.php) - * Description of [available adapters](http://pear.php.net/manual/en/package.http.http-request2.adapters.php) - * Processing of [HTTP response](http://pear.php.net/manual/en/package.http.http-request2.response.php) - * Monitoring the progress of request with [observers](http://pear.php.net/manual/en/package.http.http-request2.observers.php) - * Possible [exceptions](http://pear.php.net/manual/en/package.http.http-request2.exceptions.php) - -[Generated API documentation](http://pear.php.net/package/HTTP_Request2/docs/latest/) for the current release is also there. - -## Testing, Packaging and Installing (Pear) - -To test, run either - - $ phpunit tests/ - -or - - $ pear run-tests -r - -You may need to set up the NetworkConfig.php file if you want to perform tests that interact with a web server. -Its template is NetworkConfig.php.dist file, consult it for the details. - -To build, simply - - $ pear package - -To install from scratch - - $ pear install package.xml - -To upgrade - - $ pear upgrade -f package.xml diff --git a/vendor/pear/http_request2/composer.json b/vendor/pear/http_request2/composer.json deleted file mode 100644 index 92c6ca0fc..000000000 --- a/vendor/pear/http_request2/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name" : "pear/http_request2", - "description" : "Provides an easy way to perform HTTP requests.", - "type" : "library", - "keywords" : [ "http", "request", "pear", "curl" ], - "homepage" : "http://pear.php.net/package/HTTP_Request2", - "license" : "BSD-3-Clause", - "authors" : [ - { - "name" : "Alexey Borzov", - "email" : "avb@php.net" - } - ], - "support": { - "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2", - "source": "https://github.com/pear/HTTP_Request2" - }, - "require" : { - "php" : ">=5.2.0", - "pear/net_url2" : ">=2.0.0", - "pear/pear_exception" : "*" - }, - "suggest" : { - "ext-fileinfo" : "Adds support for looking up mime-types using finfo.", - "ext-zlib" : "Allows handling gzip compressed responses.", - "lib-curl" : "Allows using cURL as a request backend.", - "lib-openssl" : "Allows handling SSL requests when not using cURL." - }, - "autoload": { - "psr-0": { - "HTTP_Request2" : "" - } - } -} diff --git a/vendor/pear/http_request2/data/generate-list.php b/vendor/pear/http_request2/data/generate-list.php deleted file mode 100644 index 895247f4e..000000000 --- a/vendor/pear/http_request2/data/generate-list.php +++ /dev/null @@ -1,96 +0,0 @@ - "); - } - - if (0 == ($count = count($valueTree))) { - fwrite($fp, 'true'); - } else { - fwrite($fp, "array(\n"); - for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { - writeNode($fp, $valueTree[$keys[$i]], $keys[$i], $indent + 1); - if ($i + 1 != $count) { - fwrite($fp, ",\n"); - } else { - fwrite($fp, "\n"); - } - } - fwrite($fp, str_repeat(' ', $indent) . ")"); - } -} - - -try { - $request = new HTTP_Request2(LIST_URL); - $response = $request->send(); - if (200 != $response->getStatus()) { - throw new Exception("List download URL returned status: " . - $response->getStatus() . ' ' . $response->getReasonPhrase()); - } - $list = $response->getBody(); - if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { - throw new Exception("List download URL does not contain expected phrase"); - } - if (!($fp = @fopen(OUTPUT_FILE, 'wt'))) { - throw new Exception("Unable to open " . OUTPUT_FILE); - } - -} catch (Exception $e) { - die($e->getMessage()); -} - -$tldTree = array(); -$license = true; - -fwrite($fp, ""); -fclose($fp); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/data/public-suffix-list.php b/vendor/pear/http_request2/data/public-suffix-list.php deleted file mode 100644 index af9273301..000000000 --- a/vendor/pear/http_request2/data/public-suffix-list.php +++ /dev/null @@ -1,6701 +0,0 @@ - array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'mil' => true, - 'org' => true - ), - 'ad' => array( - 'nom' => true - ), - 'ae' => array( - 'co' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'ac' => true, - 'gov' => true, - 'mil' => true - ), - 'aero' => array( - 'accident-investigation' => true, - 'accident-prevention' => true, - 'aerobatic' => true, - 'aeroclub' => true, - 'aerodrome' => true, - 'agents' => true, - 'aircraft' => true, - 'airline' => true, - 'airport' => true, - 'air-surveillance' => true, - 'airtraffic' => true, - 'air-traffic-control' => true, - 'ambulance' => true, - 'amusement' => true, - 'association' => true, - 'author' => true, - 'ballooning' => true, - 'broker' => true, - 'caa' => true, - 'cargo' => true, - 'catering' => true, - 'certification' => true, - 'championship' => true, - 'charter' => true, - 'civilaviation' => true, - 'club' => true, - 'conference' => true, - 'consultant' => true, - 'consulting' => true, - 'control' => true, - 'council' => true, - 'crew' => true, - 'design' => true, - 'dgca' => true, - 'educator' => true, - 'emergency' => true, - 'engine' => true, - 'engineer' => true, - 'entertainment' => true, - 'equipment' => true, - 'exchange' => true, - 'express' => true, - 'federation' => true, - 'flight' => true, - 'freight' => true, - 'fuel' => true, - 'gliding' => true, - 'government' => true, - 'groundhandling' => true, - 'group' => true, - 'hanggliding' => true, - 'homebuilt' => true, - 'insurance' => true, - 'journal' => true, - 'journalist' => true, - 'leasing' => true, - 'logistics' => true, - 'magazine' => true, - 'maintenance' => true, - 'marketplace' => true, - 'media' => true, - 'microlight' => true, - 'modelling' => true, - 'navigation' => true, - 'parachuting' => true, - 'paragliding' => true, - 'passenger-association' => true, - 'pilot' => true, - 'press' => true, - 'production' => true, - 'recreation' => true, - 'repbody' => true, - 'res' => true, - 'research' => true, - 'rotorcraft' => true, - 'safety' => true, - 'scientist' => true, - 'services' => true, - 'show' => true, - 'skydiving' => true, - 'software' => true, - 'student' => true, - 'taxi' => true, - 'trader' => true, - 'trading' => true, - 'trainer' => true, - 'union' => true, - 'workinggroup' => true, - 'works' => true - ), - 'af' => array( - 'gov' => true, - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true - ), - 'ag' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'co' => true, - 'nom' => true - ), - 'ai' => array( - 'off' => true, - 'com' => true, - 'net' => true, - 'org' => true - ), - 'al' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'am' => true, - 'an' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true - ), - 'ao' => array( - 'ed' => true, - 'gv' => true, - 'og' => true, - 'co' => true, - 'pb' => true, - 'it' => true - ), - 'aq' => true, - 'ar' => array( - 'com' => array( - 'blogspot' => true - ), - 'edu' => true, - 'gob' => true, - 'int' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'tur' => true - ), - 'arpa' => array( - 'e164' => true, - 'in-addr' => true, - 'ip6' => true, - 'iris' => true, - 'uri' => true, - 'urn' => true - ), - 'as' => array( - 'gov' => true - ), - 'asia' => true, - 'at' => array( - 'ac' => true, - 'co' => array( - 'blogspot' => true - ), - 'gv' => true, - 'or' => true, - 'biz' => true, - 'info' => true, - 'priv' => true - ), - 'au' => array( - 'com' => array( - 'blogspot' => true - ), - 'net' => true, - 'org' => true, - 'edu' => array( - 'act' => true, - 'nsw' => true, - 'nt' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'gov' => array( - 'act' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'asn' => true, - 'id' => true, - 'csiro' => true, - 'info' => true, - 'conf' => true, - 'oz' => true, - 'act' => true, - 'nsw' => true, - 'nt' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'aw' => array( - 'com' => true - ), - 'ax' => true, - 'az' => array( - 'com' => true, - 'net' => true, - 'int' => true, - 'gov' => true, - 'org' => true, - 'edu' => true, - 'info' => true, - 'pp' => true, - 'mil' => true, - 'name' => true, - 'pro' => true, - 'biz' => true - ), - 'ba' => array( - 'org' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'unsa' => true, - 'unbi' => true, - 'co' => true, - 'com' => true, - 'rs' => true - ), - 'bb' => array( - 'biz' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'net' => true, - 'org' => true, - 'store' => true - ), - 'bd' => array( - '*' => true - ), - 'be' => array( - 'ac' => true, - 'blogspot' => true - ), - 'bf' => array( - 'gov' => true - ), - 'bg' => array( - 'a' => true, - 'b' => true, - 'c' => true, - 'd' => true, - 'e' => true, - 'f' => true, - 'g' => true, - 'h' => true, - 'i' => true, - 'j' => true, - 'k' => true, - 'l' => true, - 'm' => true, - 'n' => true, - 'o' => true, - 'p' => true, - 'q' => true, - 'r' => true, - 's' => true, - 't' => true, - 'u' => true, - 'v' => true, - 'w' => true, - 'x' => true, - 'y' => true, - 'z' => true, - '0' => true, - '1' => true, - '2' => true, - '3' => true, - '4' => true, - '5' => true, - '6' => true, - '7' => true, - '8' => true, - '9' => true - ), - 'bh' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true, - 'gov' => true - ), - 'bi' => array( - 'co' => true, - 'com' => true, - 'edu' => true, - 'or' => true, - 'org' => true - ), - 'biz' => array( - 'dyndns' => true, - 'for-better' => true, - 'for-more' => true, - 'for-some' => true, - 'for-the' => true, - 'selfip' => true, - 'webhop' => true - ), - 'bj' => array( - 'asso' => true, - 'barreau' => true, - 'gouv' => true, - 'blogspot' => true - ), - 'bm' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'bn' => array( - '*' => true - ), - 'bo' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'gob' => true, - 'int' => true, - 'org' => true, - 'net' => true, - 'mil' => true, - 'tv' => true - ), - 'br' => array( - 'adm' => true, - 'adv' => true, - 'agr' => true, - 'am' => true, - 'arq' => true, - 'art' => true, - 'ato' => true, - 'b' => true, - 'bio' => true, - 'blog' => true, - 'bmd' => true, - 'cim' => true, - 'cng' => true, - 'cnt' => true, - 'com' => array( - 'blogspot' => true - ), - 'coop' => true, - 'ecn' => true, - 'eco' => true, - 'edu' => true, - 'emp' => true, - 'eng' => true, - 'esp' => true, - 'etc' => true, - 'eti' => true, - 'far' => true, - 'flog' => true, - 'fm' => true, - 'fnd' => true, - 'fot' => true, - 'fst' => true, - 'g12' => true, - 'ggf' => true, - 'gov' => true, - 'imb' => true, - 'ind' => true, - 'inf' => true, - 'jor' => true, - 'jus' => true, - 'leg' => true, - 'lel' => true, - 'mat' => true, - 'med' => true, - 'mil' => true, - 'mus' => true, - 'net' => true, - 'nom' => true, - 'not' => true, - 'ntr' => true, - 'odo' => true, - 'org' => true, - 'ppg' => true, - 'pro' => true, - 'psc' => true, - 'psi' => true, - 'qsl' => true, - 'radio' => true, - 'rec' => true, - 'slg' => true, - 'srv' => true, - 'taxi' => true, - 'teo' => true, - 'tmp' => true, - 'trd' => true, - 'tur' => true, - 'tv' => true, - 'vet' => true, - 'vlog' => true, - 'wiki' => true, - 'zlg' => true - ), - 'bs' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'bt' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'bv' => true, - 'bw' => array( - 'co' => true, - 'org' => true - ), - 'by' => array( - 'gov' => true, - 'mil' => true, - 'com' => true, - 'of' => true - ), - 'bz' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'ca' => array( - 'ab' => true, - 'bc' => true, - 'mb' => true, - 'nb' => true, - 'nf' => true, - 'nl' => true, - 'ns' => true, - 'nt' => true, - 'nu' => true, - 'on' => true, - 'pe' => true, - 'qc' => true, - 'sk' => true, - 'yk' => true, - 'gc' => true, - 'co' => true, - 'blogspot' => true - ), - 'cat' => true, - 'cc' => array( - 'ftpaccess' => true, - 'game-server' => true, - 'myphotos' => true, - 'scrapping' => true - ), - 'cd' => array( - 'gov' => true - ), - 'cf' => array( - 'blogspot' => true - ), - 'cg' => true, - 'ch' => array( - 'blogspot' => true - ), - 'ci' => array( - 'org' => true, - 'or' => true, - 'com' => true, - 'co' => true, - 'edu' => true, - 'ed' => true, - 'ac' => true, - 'net' => true, - 'go' => true, - 'asso' => true, - 'aéroport' => true, - 'int' => true, - 'presse' => true, - 'md' => true, - 'gouv' => true - ), - 'ck' => array( - '*' => true, - '!www' => true - ), - 'cl' => array( - 'gov' => true, - 'gob' => true, - 'co' => true, - 'mil' => true - ), - 'cm' => array( - 'gov' => true - ), - 'cn' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'mil' => true, - '公司' => true, - '网络' => true, - '網絡' => true, - 'ah' => true, - 'bj' => true, - 'cq' => true, - 'fj' => true, - 'gd' => true, - 'gs' => true, - 'gz' => true, - 'gx' => true, - 'ha' => true, - 'hb' => true, - 'he' => true, - 'hi' => true, - 'hl' => true, - 'hn' => true, - 'jl' => true, - 'js' => true, - 'jx' => true, - 'ln' => true, - 'nm' => true, - 'nx' => true, - 'qh' => true, - 'sc' => true, - 'sd' => true, - 'sh' => true, - 'sn' => true, - 'sx' => true, - 'tj' => true, - 'xj' => true, - 'xz' => true, - 'yn' => true, - 'zj' => true, - 'hk' => true, - 'mo' => true, - 'tw' => true - ), - 'co' => array( - 'arts' => true, - 'com' => true, - 'edu' => true, - 'firm' => true, - 'gov' => true, - 'info' => true, - 'int' => true, - 'mil' => true, - 'net' => true, - 'nom' => true, - 'org' => true, - 'rec' => true, - 'web' => true - ), - 'com' => array( - 'amazonaws' => array( - 'compute' => array( - 'ap-northeast-1' => true, - 'ap-southeast-1' => true, - 'ap-southeast-2' => true, - 'eu-west-1' => true, - 'sa-east-1' => true, - 'us-gov-west-1' => true, - 'us-west-1' => true, - 'us-west-2' => true - ), - 'us-east-1' => true, - 'compute-1' => array( - 'z-1' => true, - 'z-2' => true - ), - 'elb' => true, - 's3' => true, - 's3-us-west-2' => true, - 's3-us-west-1' => true, - 's3-eu-west-1' => true, - 's3-ap-southeast-1' => true, - 's3-ap-southeast-2' => true, - 's3-ap-northeast-1' => true, - 's3-sa-east-1' => true, - 's3-us-gov-west-1' => true, - 's3-fips-us-gov-west-1' => true, - 's3-website-us-east-1' => true, - 's3-website-us-west-2' => true, - 's3-website-us-west-1' => true, - 's3-website-eu-west-1' => true, - 's3-website-ap-southeast-1' => true, - 's3-website-ap-southeast-2' => true, - 's3-website-ap-northeast-1' => true, - 's3-website-sa-east-1' => true, - 's3-website-us-gov-west-1' => true - ), - 'elasticbeanstalk' => true, - 'betainabox' => true, - 'ar' => true, - 'br' => true, - 'cn' => true, - 'de' => true, - 'eu' => true, - 'gb' => true, - 'gr' => true, - 'hu' => true, - 'jpn' => true, - 'kr' => true, - 'no' => true, - 'qc' => true, - 'ru' => true, - 'sa' => true, - 'se' => true, - 'uk' => true, - 'us' => true, - 'uy' => true, - 'za' => true, - 'cloudcontrolled' => true, - 'cloudcontrolapp' => true, - 'dreamhosters' => true, - 'dyndns-at-home' => true, - 'dyndns-at-work' => true, - 'dyndns-blog' => true, - 'dyndns-free' => true, - 'dyndns-home' => true, - 'dyndns-ip' => true, - 'dyndns-mail' => true, - 'dyndns-office' => true, - 'dyndns-pics' => true, - 'dyndns-remote' => true, - 'dyndns-server' => true, - 'dyndns-web' => true, - 'dyndns-wiki' => true, - 'dyndns-work' => true, - 'blogdns' => true, - 'cechire' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'doesntexist' => true, - 'dontexist' => true, - 'doomdns' => true, - 'dyn-o-saur' => true, - 'dynalias' => true, - 'est-a-la-maison' => true, - 'est-a-la-masion' => true, - 'est-le-patron' => true, - 'est-mon-blogueur' => true, - 'from-ak' => true, - 'from-al' => true, - 'from-ar' => true, - 'from-ca' => true, - 'from-ct' => true, - 'from-dc' => true, - 'from-de' => true, - 'from-fl' => true, - 'from-ga' => true, - 'from-hi' => true, - 'from-ia' => true, - 'from-id' => true, - 'from-il' => true, - 'from-in' => true, - 'from-ks' => true, - 'from-ky' => true, - 'from-ma' => true, - 'from-md' => true, - 'from-mi' => true, - 'from-mn' => true, - 'from-mo' => true, - 'from-ms' => true, - 'from-mt' => true, - 'from-nc' => true, - 'from-nd' => true, - 'from-ne' => true, - 'from-nh' => true, - 'from-nj' => true, - 'from-nm' => true, - 'from-nv' => true, - 'from-oh' => true, - 'from-ok' => true, - 'from-or' => true, - 'from-pa' => true, - 'from-pr' => true, - 'from-ri' => true, - 'from-sc' => true, - 'from-sd' => true, - 'from-tn' => true, - 'from-tx' => true, - 'from-ut' => true, - 'from-va' => true, - 'from-vt' => true, - 'from-wa' => true, - 'from-wi' => true, - 'from-wv' => true, - 'from-wy' => true, - 'getmyip' => true, - 'gotdns' => true, - 'hobby-site' => true, - 'homelinux' => true, - 'homeunix' => true, - 'iamallama' => true, - 'is-a-anarchist' => true, - 'is-a-blogger' => true, - 'is-a-bookkeeper' => true, - 'is-a-bulls-fan' => true, - 'is-a-caterer' => true, - 'is-a-chef' => true, - 'is-a-conservative' => true, - 'is-a-cpa' => true, - 'is-a-cubicle-slave' => true, - 'is-a-democrat' => true, - 'is-a-designer' => true, - 'is-a-doctor' => true, - 'is-a-financialadvisor' => true, - 'is-a-geek' => true, - 'is-a-green' => true, - 'is-a-guru' => true, - 'is-a-hard-worker' => true, - 'is-a-hunter' => true, - 'is-a-landscaper' => true, - 'is-a-lawyer' => true, - 'is-a-liberal' => true, - 'is-a-libertarian' => true, - 'is-a-llama' => true, - 'is-a-musician' => true, - 'is-a-nascarfan' => true, - 'is-a-nurse' => true, - 'is-a-painter' => true, - 'is-a-personaltrainer' => true, - 'is-a-photographer' => true, - 'is-a-player' => true, - 'is-a-republican' => true, - 'is-a-rockstar' => true, - 'is-a-socialist' => true, - 'is-a-student' => true, - 'is-a-teacher' => true, - 'is-a-techie' => true, - 'is-a-therapist' => true, - 'is-an-accountant' => true, - 'is-an-actor' => true, - 'is-an-actress' => true, - 'is-an-anarchist' => true, - 'is-an-artist' => true, - 'is-an-engineer' => true, - 'is-an-entertainer' => true, - 'is-certified' => true, - 'is-gone' => true, - 'is-into-anime' => true, - 'is-into-cars' => true, - 'is-into-cartoons' => true, - 'is-into-games' => true, - 'is-leet' => true, - 'is-not-certified' => true, - 'is-slick' => true, - 'is-uberleet' => true, - 'is-with-theband' => true, - 'isa-geek' => true, - 'isa-hockeynut' => true, - 'issmarterthanyou' => true, - 'likes-pie' => true, - 'likescandy' => true, - 'neat-url' => true, - 'saves-the-whales' => true, - 'selfip' => true, - 'sells-for-less' => true, - 'sells-for-u' => true, - 'servebbs' => true, - 'simple-url' => true, - 'space-to-rent' => true, - 'teaches-yoga' => true, - 'writesthisblog' => true, - 'ro' => true, - 'appspot' => true, - 'blogspot' => true, - 'codespot' => true, - 'googleapis' => true, - 'googlecode' => true, - 'herokuapp' => true, - 'herokussl' => true, - 'operaunite' => true, - 'rhcloud' => true - ), - 'coop' => true, - 'cr' => array( - 'ac' => true, - 'co' => true, - 'ed' => true, - 'fi' => true, - 'go' => true, - 'or' => true, - 'sa' => true - ), - 'cu' => array( - 'com' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'gov' => true, - 'inf' => true - ), - 'cv' => array( - 'blogspot' => true - ), - 'cw' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true - ), - 'cx' => array( - 'gov' => true, - 'ath' => true - ), - 'cy' => array( - '*' => true - ), - 'cz' => array( - 'blogspot' => true - ), - 'de' => array( - 'com' => true, - 'fuettertdasnetz' => true, - 'isteingeek' => true, - 'istmein' => true, - 'lebtimnetz' => true, - 'leitungsen' => true, - 'traeumtgerade' => true, - 'blogspot' => true - ), - 'dj' => true, - 'dk' => array( - 'blogspot' => true - ), - 'dm' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'do' => array( - 'art' => true, - 'com' => true, - 'edu' => true, - 'gob' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'sld' => true, - 'web' => true - ), - 'dz' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'gov' => true, - 'edu' => true, - 'asso' => true, - 'pol' => true, - 'art' => true - ), - 'ec' => array( - 'com' => true, - 'info' => true, - 'net' => true, - 'fin' => true, - 'k12' => true, - 'med' => true, - 'pro' => true, - 'org' => true, - 'edu' => true, - 'gov' => true, - 'gob' => true, - 'mil' => true - ), - 'edu' => true, - 'ee' => array( - 'edu' => true, - 'gov' => true, - 'riik' => true, - 'lib' => true, - 'med' => true, - 'com' => true, - 'pri' => true, - 'aip' => true, - 'org' => true, - 'fie' => true - ), - 'eg' => array( - 'com' => true, - 'edu' => true, - 'eun' => true, - 'gov' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sci' => true - ), - 'er' => array( - '*' => true - ), - 'es' => array( - 'com' => array( - 'blogspot' => true - ), - 'nom' => true, - 'org' => true, - 'gob' => true, - 'edu' => true - ), - 'et' => array( - '*' => true - ), - 'eu' => true, - 'fi' => array( - 'aland' => true, - 'blogspot' => true, - 'iki' => true - ), - 'fj' => array( - '*' => true - ), - 'fk' => array( - '*' => true - ), - 'fm' => true, - 'fo' => true, - 'fr' => array( - 'com' => true, - 'asso' => true, - 'nom' => true, - 'prd' => true, - 'presse' => true, - 'tm' => true, - 'aeroport' => true, - 'assedic' => true, - 'avocat' => true, - 'avoues' => true, - 'cci' => true, - 'chambagri' => true, - 'chirurgiens-dentistes' => true, - 'experts-comptables' => true, - 'geometre-expert' => true, - 'gouv' => true, - 'greta' => true, - 'huissier-justice' => true, - 'medecin' => true, - 'notaires' => true, - 'pharmacien' => true, - 'port' => true, - 'veterinaire' => true, - 'blogspot' => true - ), - 'ga' => true, - 'gb' => true, - 'gd' => true, - 'ge' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true, - 'net' => true, - 'pvt' => true - ), - 'gf' => true, - 'gg' => array( - 'co' => true, - 'net' => true, - 'org' => true - ), - 'gh' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true - ), - 'gi' => array( - 'com' => true, - 'ltd' => true, - 'gov' => true, - 'mod' => true, - 'edu' => true, - 'org' => true - ), - 'gl' => true, - 'gm' => true, - 'gn' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'net' => true - ), - 'gov' => true, - 'gp' => array( - 'com' => true, - 'net' => true, - 'mobi' => true, - 'edu' => true, - 'org' => true, - 'asso' => true - ), - 'gq' => true, - 'gr' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'blogspot' => true - ), - 'gs' => true, - 'gt' => array( - 'com' => true, - 'edu' => true, - 'gob' => true, - 'ind' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'gu' => array( - '*' => true - ), - 'gw' => true, - 'gy' => array( - 'co' => true, - 'com' => true, - 'net' => true - ), - 'hk' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'idv' => true, - 'net' => true, - 'org' => true, - '公司' => true, - '教育' => true, - '敎育' => true, - '政府' => true, - '個人' => true, - '个人' => true, - '箇人' => true, - '網络' => true, - '网络' => true, - '组織' => true, - '網絡' => true, - '网絡' => true, - '组织' => true, - '組織' => true, - '組织' => true, - 'blogspot' => true - ), - 'hm' => true, - 'hn' => array( - 'com' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'mil' => true, - 'gob' => true - ), - 'hr' => array( - 'iz' => true, - 'from' => true, - 'name' => true, - 'com' => true - ), - 'ht' => array( - 'com' => true, - 'shop' => true, - 'firm' => true, - 'info' => true, - 'adult' => true, - 'net' => true, - 'pro' => true, - 'org' => true, - 'med' => true, - 'art' => true, - 'coop' => true, - 'pol' => true, - 'asso' => true, - 'edu' => true, - 'rel' => true, - 'gouv' => true, - 'perso' => true - ), - 'hu' => array( - 'co' => true, - 'info' => true, - 'org' => true, - 'priv' => true, - 'sport' => true, - 'tm' => true, - '2000' => true, - 'agrar' => true, - 'bolt' => true, - 'casino' => true, - 'city' => true, - 'erotica' => true, - 'erotika' => true, - 'film' => true, - 'forum' => true, - 'games' => true, - 'hotel' => true, - 'ingatlan' => true, - 'jogasz' => true, - 'konyvelo' => true, - 'lakas' => true, - 'media' => true, - 'news' => true, - 'reklam' => true, - 'sex' => true, - 'shop' => true, - 'suli' => true, - 'szex' => true, - 'tozsde' => true, - 'utazas' => true, - 'video' => true, - 'blogspot' => true - ), - 'id' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'go' => true, - 'mil' => true, - 'my' => true, - 'net' => true, - 'or' => true, - 'sch' => true, - 'web' => true - ), - 'ie' => array( - 'gov' => true, - 'blogspot' => true - ), - 'il' => array( - '*' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'im' => array( - 'ac' => true, - 'co' => array( - 'ltd' => true, - 'plc' => true - ), - 'com' => true, - 'net' => true, - 'org' => true, - 'tt' => true, - 'tv' => true - ), - 'in' => array( - 'co' => true, - 'firm' => true, - 'net' => true, - 'org' => true, - 'gen' => true, - 'ind' => true, - 'nic' => true, - 'ac' => true, - 'edu' => true, - 'res' => true, - 'gov' => true, - 'mil' => true, - 'blogspot' => true - ), - 'info' => array( - 'dyndns' => true, - 'barrel-of-knowledge' => true, - 'barrell-of-knowledge' => true, - 'for-our' => true, - 'groks-the' => true, - 'groks-this' => true, - 'here-for-more' => true, - 'knowsitall' => true, - 'selfip' => true, - 'webhop' => true - ), - 'int' => array( - 'eu' => true - ), - 'io' => array( - 'com' => true, - 'github' => true - ), - 'iq' => array( - 'gov' => true, - 'edu' => true, - 'mil' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'ir' => array( - 'ac' => true, - 'co' => true, - 'gov' => true, - 'id' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'ایران' => true, - 'ايران' => true - ), - 'is' => array( - 'net' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'int' => true, - 'cupcake' => true - ), - 'it' => array( - 'gov' => true, - 'edu' => true, - 'agrigento' => true, - 'ag' => true, - 'alessandria' => true, - 'al' => true, - 'ancona' => true, - 'an' => true, - 'aosta' => true, - 'aoste' => true, - 'ao' => true, - 'arezzo' => true, - 'ar' => true, - 'ascoli-piceno' => true, - 'ascolipiceno' => true, - 'ap' => true, - 'asti' => true, - 'at' => true, - 'avellino' => true, - 'av' => true, - 'bari' => true, - 'ba' => true, - 'andria-barletta-trani' => true, - 'andriabarlettatrani' => true, - 'trani-barletta-andria' => true, - 'tranibarlettaandria' => true, - 'barletta-trani-andria' => true, - 'barlettatraniandria' => true, - 'andria-trani-barletta' => true, - 'andriatranibarletta' => true, - 'trani-andria-barletta' => true, - 'traniandriabarletta' => true, - 'bt' => true, - 'belluno' => true, - 'bl' => true, - 'benevento' => true, - 'bn' => true, - 'bergamo' => true, - 'bg' => true, - 'biella' => true, - 'bi' => true, - 'bologna' => true, - 'bo' => true, - 'bolzano' => true, - 'bozen' => true, - 'balsan' => true, - 'alto-adige' => true, - 'altoadige' => true, - 'suedtirol' => true, - 'bz' => true, - 'brescia' => true, - 'bs' => true, - 'brindisi' => true, - 'br' => true, - 'cagliari' => true, - 'ca' => true, - 'caltanissetta' => true, - 'cl' => true, - 'campobasso' => true, - 'cb' => true, - 'carboniaiglesias' => true, - 'carbonia-iglesias' => true, - 'iglesias-carbonia' => true, - 'iglesiascarbonia' => true, - 'ci' => true, - 'caserta' => true, - 'ce' => true, - 'catania' => true, - 'ct' => true, - 'catanzaro' => true, - 'cz' => true, - 'chieti' => true, - 'ch' => true, - 'como' => true, - 'co' => true, - 'cosenza' => true, - 'cs' => true, - 'cremona' => true, - 'cr' => true, - 'crotone' => true, - 'kr' => true, - 'cuneo' => true, - 'cn' => true, - 'dell-ogliastra' => true, - 'dellogliastra' => true, - 'ogliastra' => true, - 'og' => true, - 'enna' => true, - 'en' => true, - 'ferrara' => true, - 'fe' => true, - 'fermo' => true, - 'fm' => true, - 'firenze' => true, - 'florence' => true, - 'fi' => true, - 'foggia' => true, - 'fg' => true, - 'forli-cesena' => true, - 'forlicesena' => true, - 'cesena-forli' => true, - 'cesenaforli' => true, - 'fc' => true, - 'frosinone' => true, - 'fr' => true, - 'genova' => true, - 'genoa' => true, - 'ge' => true, - 'gorizia' => true, - 'go' => true, - 'grosseto' => true, - 'gr' => true, - 'imperia' => true, - 'im' => true, - 'isernia' => true, - 'is' => true, - 'laquila' => true, - 'aquila' => true, - 'aq' => true, - 'la-spezia' => true, - 'laspezia' => true, - 'sp' => true, - 'latina' => true, - 'lt' => true, - 'lecce' => true, - 'le' => true, - 'lecco' => true, - 'lc' => true, - 'livorno' => true, - 'li' => true, - 'lodi' => true, - 'lo' => true, - 'lucca' => true, - 'lu' => true, - 'macerata' => true, - 'mc' => true, - 'mantova' => true, - 'mn' => true, - 'massa-carrara' => true, - 'massacarrara' => true, - 'carrara-massa' => true, - 'carraramassa' => true, - 'ms' => true, - 'matera' => true, - 'mt' => true, - 'medio-campidano' => true, - 'mediocampidano' => true, - 'campidano-medio' => true, - 'campidanomedio' => true, - 'vs' => true, - 'messina' => true, - 'me' => true, - 'milano' => true, - 'milan' => true, - 'mi' => true, - 'modena' => true, - 'mo' => true, - 'monza' => true, - 'monza-brianza' => true, - 'monzabrianza' => true, - 'monzaebrianza' => true, - 'monzaedellabrianza' => true, - 'monza-e-della-brianza' => true, - 'mb' => true, - 'napoli' => true, - 'naples' => true, - 'na' => true, - 'novara' => true, - 'no' => true, - 'nuoro' => true, - 'nu' => true, - 'oristano' => true, - 'or' => true, - 'padova' => true, - 'padua' => true, - 'pd' => true, - 'palermo' => true, - 'pa' => true, - 'parma' => true, - 'pr' => true, - 'pavia' => true, - 'pv' => true, - 'perugia' => true, - 'pg' => true, - 'pescara' => true, - 'pe' => true, - 'pesaro-urbino' => true, - 'pesarourbino' => true, - 'urbino-pesaro' => true, - 'urbinopesaro' => true, - 'pu' => true, - 'piacenza' => true, - 'pc' => true, - 'pisa' => true, - 'pi' => true, - 'pistoia' => true, - 'pt' => true, - 'pordenone' => true, - 'pn' => true, - 'potenza' => true, - 'pz' => true, - 'prato' => true, - 'po' => true, - 'ragusa' => true, - 'rg' => true, - 'ravenna' => true, - 'ra' => true, - 'reggio-calabria' => true, - 'reggiocalabria' => true, - 'rc' => true, - 'reggio-emilia' => true, - 'reggioemilia' => true, - 're' => true, - 'rieti' => true, - 'ri' => true, - 'rimini' => true, - 'rn' => true, - 'roma' => true, - 'rome' => true, - 'rm' => true, - 'rovigo' => true, - 'ro' => true, - 'salerno' => true, - 'sa' => true, - 'sassari' => true, - 'ss' => true, - 'savona' => true, - 'sv' => true, - 'siena' => true, - 'si' => true, - 'siracusa' => true, - 'sr' => true, - 'sondrio' => true, - 'so' => true, - 'taranto' => true, - 'ta' => true, - 'tempio-olbia' => true, - 'tempioolbia' => true, - 'olbia-tempio' => true, - 'olbiatempio' => true, - 'ot' => true, - 'teramo' => true, - 'te' => true, - 'terni' => true, - 'tr' => true, - 'torino' => true, - 'turin' => true, - 'to' => true, - 'trapani' => true, - 'tp' => true, - 'trento' => true, - 'trentino' => true, - 'tn' => true, - 'treviso' => true, - 'tv' => true, - 'trieste' => true, - 'ts' => true, - 'udine' => true, - 'ud' => true, - 'varese' => true, - 'va' => true, - 'venezia' => true, - 'venice' => true, - 've' => true, - 'verbania' => true, - 'vb' => true, - 'vercelli' => true, - 'vc' => true, - 'verona' => true, - 'vr' => true, - 'vibo-valentia' => true, - 'vibovalentia' => true, - 'vv' => true, - 'vicenza' => true, - 'vi' => true, - 'viterbo' => true, - 'vt' => true, - 'blogspot' => true - ), - 'je' => array( - 'co' => true, - 'net' => true, - 'org' => true - ), - 'jm' => array( - '*' => true - ), - 'jo' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true, - 'sch' => true, - 'gov' => true, - 'mil' => true, - 'name' => true - ), - 'jobs' => true, - 'jp' => array( - 'ac' => true, - 'ad' => true, - 'co' => true, - 'ed' => true, - 'go' => true, - 'gr' => true, - 'lg' => true, - 'ne' => true, - 'or' => true, - 'aichi' => array( - 'aisai' => true, - 'ama' => true, - 'anjo' => true, - 'asuke' => true, - 'chiryu' => true, - 'chita' => true, - 'fuso' => true, - 'gamagori' => true, - 'handa' => true, - 'hazu' => true, - 'hekinan' => true, - 'higashiura' => true, - 'ichinomiya' => true, - 'inazawa' => true, - 'inuyama' => true, - 'isshiki' => true, - 'iwakura' => true, - 'kanie' => true, - 'kariya' => true, - 'kasugai' => true, - 'kira' => true, - 'kiyosu' => true, - 'komaki' => true, - 'konan' => true, - 'kota' => true, - 'mihama' => true, - 'miyoshi' => true, - 'nagakute' => true, - 'nishio' => true, - 'nisshin' => true, - 'obu' => true, - 'oguchi' => true, - 'oharu' => true, - 'okazaki' => true, - 'owariasahi' => true, - 'seto' => true, - 'shikatsu' => true, - 'shinshiro' => true, - 'shitara' => true, - 'tahara' => true, - 'takahama' => true, - 'tobishima' => true, - 'toei' => true, - 'togo' => true, - 'tokai' => true, - 'tokoname' => true, - 'toyoake' => true, - 'toyohashi' => true, - 'toyokawa' => true, - 'toyone' => true, - 'toyota' => true, - 'tsushima' => true, - 'yatomi' => true - ), - 'akita' => array( - 'akita' => true, - 'daisen' => true, - 'fujisato' => true, - 'gojome' => true, - 'hachirogata' => true, - 'happou' => true, - 'higashinaruse' => true, - 'honjo' => true, - 'honjyo' => true, - 'ikawa' => true, - 'kamikoani' => true, - 'kamioka' => true, - 'katagami' => true, - 'kazuno' => true, - 'kitaakita' => true, - 'kosaka' => true, - 'kyowa' => true, - 'misato' => true, - 'mitane' => true, - 'moriyoshi' => true, - 'nikaho' => true, - 'noshiro' => true, - 'odate' => true, - 'oga' => true, - 'ogata' => true, - 'semboku' => true, - 'yokote' => true, - 'yurihonjo' => true - ), - 'aomori' => array( - 'aomori' => true, - 'gonohe' => true, - 'hachinohe' => true, - 'hashikami' => true, - 'hiranai' => true, - 'hirosaki' => true, - 'itayanagi' => true, - 'kuroishi' => true, - 'misawa' => true, - 'mutsu' => true, - 'nakadomari' => true, - 'noheji' => true, - 'oirase' => true, - 'owani' => true, - 'rokunohe' => true, - 'sannohe' => true, - 'shichinohe' => true, - 'shingo' => true, - 'takko' => true, - 'towada' => true, - 'tsugaru' => true, - 'tsuruta' => true - ), - 'chiba' => array( - 'abiko' => true, - 'asahi' => true, - 'chonan' => true, - 'chosei' => true, - 'choshi' => true, - 'chuo' => true, - 'funabashi' => true, - 'futtsu' => true, - 'hanamigawa' => true, - 'ichihara' => true, - 'ichikawa' => true, - 'ichinomiya' => true, - 'inzai' => true, - 'isumi' => true, - 'kamagaya' => true, - 'kamogawa' => true, - 'kashiwa' => true, - 'katori' => true, - 'katsuura' => true, - 'kimitsu' => true, - 'kisarazu' => true, - 'kozaki' => true, - 'kujukuri' => true, - 'kyonan' => true, - 'matsudo' => true, - 'midori' => true, - 'mihama' => true, - 'minamiboso' => true, - 'mobara' => true, - 'mutsuzawa' => true, - 'nagara' => true, - 'nagareyama' => true, - 'narashino' => true, - 'narita' => true, - 'noda' => true, - 'oamishirasato' => true, - 'omigawa' => true, - 'onjuku' => true, - 'otaki' => true, - 'sakae' => true, - 'sakura' => true, - 'shimofusa' => true, - 'shirako' => true, - 'shiroi' => true, - 'shisui' => true, - 'sodegaura' => true, - 'sosa' => true, - 'tako' => true, - 'tateyama' => true, - 'togane' => true, - 'tohnosho' => true, - 'tomisato' => true, - 'urayasu' => true, - 'yachimata' => true, - 'yachiyo' => true, - 'yokaichiba' => true, - 'yokoshibahikari' => true, - 'yotsukaido' => true - ), - 'ehime' => array( - 'ainan' => true, - 'honai' => true, - 'ikata' => true, - 'imabari' => true, - 'iyo' => true, - 'kamijima' => true, - 'kihoku' => true, - 'kumakogen' => true, - 'masaki' => true, - 'matsuno' => true, - 'matsuyama' => true, - 'namikata' => true, - 'niihama' => true, - 'ozu' => true, - 'saijo' => true, - 'seiyo' => true, - 'shikokuchuo' => true, - 'tobe' => true, - 'toon' => true, - 'uchiko' => true, - 'uwajima' => true, - 'yawatahama' => true - ), - 'fukui' => array( - 'echizen' => true, - 'eiheiji' => true, - 'fukui' => true, - 'ikeda' => true, - 'katsuyama' => true, - 'mihama' => true, - 'minamiechizen' => true, - 'obama' => true, - 'ohi' => true, - 'ono' => true, - 'sabae' => true, - 'sakai' => true, - 'takahama' => true, - 'tsuruga' => true, - 'wakasa' => true - ), - 'fukuoka' => array( - 'ashiya' => true, - 'buzen' => true, - 'chikugo' => true, - 'chikuho' => true, - 'chikujo' => true, - 'chikushino' => true, - 'chikuzen' => true, - 'chuo' => true, - 'dazaifu' => true, - 'fukuchi' => true, - 'hakata' => true, - 'higashi' => true, - 'hirokawa' => true, - 'hisayama' => true, - 'iizuka' => true, - 'inatsuki' => true, - 'kaho' => true, - 'kasuga' => true, - 'kasuya' => true, - 'kawara' => true, - 'keisen' => true, - 'koga' => true, - 'kurate' => true, - 'kurogi' => true, - 'kurume' => true, - 'minami' => true, - 'miyako' => true, - 'miyama' => true, - 'miyawaka' => true, - 'mizumaki' => true, - 'munakata' => true, - 'nakagawa' => true, - 'nakama' => true, - 'nishi' => true, - 'nogata' => true, - 'ogori' => true, - 'okagaki' => true, - 'okawa' => true, - 'oki' => true, - 'omuta' => true, - 'onga' => true, - 'onojo' => true, - 'oto' => true, - 'saigawa' => true, - 'sasaguri' => true, - 'shingu' => true, - 'shinyoshitomi' => true, - 'shonai' => true, - 'soeda' => true, - 'sue' => true, - 'tachiarai' => true, - 'tagawa' => true, - 'takata' => true, - 'toho' => true, - 'toyotsu' => true, - 'tsuiki' => true, - 'ukiha' => true, - 'umi' => true, - 'usui' => true, - 'yamada' => true, - 'yame' => true, - 'yanagawa' => true, - 'yukuhashi' => true - ), - 'fukushima' => array( - 'aizubange' => true, - 'aizumisato' => true, - 'aizuwakamatsu' => true, - 'asakawa' => true, - 'bandai' => true, - 'date' => true, - 'fukushima' => true, - 'furudono' => true, - 'futaba' => true, - 'hanawa' => true, - 'higashi' => true, - 'hirata' => true, - 'hirono' => true, - 'iitate' => true, - 'inawashiro' => true, - 'ishikawa' => true, - 'iwaki' => true, - 'izumizaki' => true, - 'kagamiishi' => true, - 'kaneyama' => true, - 'kawamata' => true, - 'kitakata' => true, - 'kitashiobara' => true, - 'koori' => true, - 'koriyama' => true, - 'kunimi' => true, - 'miharu' => true, - 'mishima' => true, - 'namie' => true, - 'nango' => true, - 'nishiaizu' => true, - 'nishigo' => true, - 'okuma' => true, - 'omotego' => true, - 'ono' => true, - 'otama' => true, - 'samegawa' => true, - 'shimogo' => true, - 'shirakawa' => true, - 'showa' => true, - 'soma' => true, - 'sukagawa' => true, - 'taishin' => true, - 'tamakawa' => true, - 'tanagura' => true, - 'tenei' => true, - 'yabuki' => true, - 'yamato' => true, - 'yamatsuri' => true, - 'yanaizu' => true, - 'yugawa' => true - ), - 'gifu' => array( - 'anpachi' => true, - 'ena' => true, - 'gifu' => true, - 'ginan' => true, - 'godo' => true, - 'gujo' => true, - 'hashima' => true, - 'hichiso' => true, - 'hida' => true, - 'higashishirakawa' => true, - 'ibigawa' => true, - 'ikeda' => true, - 'kakamigahara' => true, - 'kani' => true, - 'kasahara' => true, - 'kasamatsu' => true, - 'kawaue' => true, - 'kitagata' => true, - 'mino' => true, - 'minokamo' => true, - 'mitake' => true, - 'mizunami' => true, - 'motosu' => true, - 'nakatsugawa' => true, - 'ogaki' => true, - 'sakahogi' => true, - 'seki' => true, - 'sekigahara' => true, - 'shirakawa' => true, - 'tajimi' => true, - 'takayama' => true, - 'tarui' => true, - 'toki' => true, - 'tomika' => true, - 'wanouchi' => true, - 'yamagata' => true, - 'yaotsu' => true, - 'yoro' => true - ), - 'gunma' => array( - 'annaka' => true, - 'chiyoda' => true, - 'fujioka' => true, - 'higashiagatsuma' => true, - 'isesaki' => true, - 'itakura' => true, - 'kanna' => true, - 'kanra' => true, - 'katashina' => true, - 'kawaba' => true, - 'kiryu' => true, - 'kusatsu' => true, - 'maebashi' => true, - 'meiwa' => true, - 'midori' => true, - 'minakami' => true, - 'naganohara' => true, - 'nakanojo' => true, - 'nanmoku' => true, - 'numata' => true, - 'oizumi' => true, - 'ora' => true, - 'ota' => true, - 'shibukawa' => true, - 'shimonita' => true, - 'shinto' => true, - 'showa' => true, - 'takasaki' => true, - 'takayama' => true, - 'tamamura' => true, - 'tatebayashi' => true, - 'tomioka' => true, - 'tsukiyono' => true, - 'tsumagoi' => true, - 'ueno' => true, - 'yoshioka' => true - ), - 'hiroshima' => array( - 'asaminami' => true, - 'daiwa' => true, - 'etajima' => true, - 'fuchu' => true, - 'fukuyama' => true, - 'hatsukaichi' => true, - 'higashihiroshima' => true, - 'hongo' => true, - 'jinsekikogen' => true, - 'kaita' => true, - 'kui' => true, - 'kumano' => true, - 'kure' => true, - 'mihara' => true, - 'miyoshi' => true, - 'naka' => true, - 'onomichi' => true, - 'osakikamijima' => true, - 'otake' => true, - 'saka' => true, - 'sera' => true, - 'seranishi' => true, - 'shinichi' => true, - 'shobara' => true, - 'takehara' => true - ), - 'hokkaido' => array( - 'abashiri' => true, - 'abira' => true, - 'aibetsu' => true, - 'akabira' => true, - 'akkeshi' => true, - 'asahikawa' => true, - 'ashibetsu' => true, - 'ashoro' => true, - 'assabu' => true, - 'atsuma' => true, - 'bibai' => true, - 'biei' => true, - 'bifuka' => true, - 'bihoro' => true, - 'biratori' => true, - 'chippubetsu' => true, - 'chitose' => true, - 'date' => true, - 'ebetsu' => true, - 'embetsu' => true, - 'eniwa' => true, - 'erimo' => true, - 'esan' => true, - 'esashi' => true, - 'fukagawa' => true, - 'fukushima' => true, - 'furano' => true, - 'furubira' => true, - 'haboro' => true, - 'hakodate' => true, - 'hamatonbetsu' => true, - 'hidaka' => true, - 'higashikagura' => true, - 'higashikawa' => true, - 'hiroo' => true, - 'hokuryu' => true, - 'hokuto' => true, - 'honbetsu' => true, - 'horokanai' => true, - 'horonobe' => true, - 'ikeda' => true, - 'imakane' => true, - 'ishikari' => true, - 'iwamizawa' => true, - 'iwanai' => true, - 'kamifurano' => true, - 'kamikawa' => true, - 'kamishihoro' => true, - 'kamisunagawa' => true, - 'kamoenai' => true, - 'kayabe' => true, - 'kembuchi' => true, - 'kikonai' => true, - 'kimobetsu' => true, - 'kitahiroshima' => true, - 'kitami' => true, - 'kiyosato' => true, - 'koshimizu' => true, - 'kunneppu' => true, - 'kuriyama' => true, - 'kuromatsunai' => true, - 'kushiro' => true, - 'kutchan' => true, - 'kyowa' => true, - 'mashike' => true, - 'matsumae' => true, - 'mikasa' => true, - 'minamifurano' => true, - 'mombetsu' => true, - 'moseushi' => true, - 'mukawa' => true, - 'muroran' => true, - 'naie' => true, - 'nakagawa' => true, - 'nakasatsunai' => true, - 'nakatombetsu' => true, - 'nanae' => true, - 'nanporo' => true, - 'nayoro' => true, - 'nemuro' => true, - 'niikappu' => true, - 'niki' => true, - 'nishiokoppe' => true, - 'noboribetsu' => true, - 'numata' => true, - 'obihiro' => true, - 'obira' => true, - 'oketo' => true, - 'okoppe' => true, - 'otaru' => true, - 'otobe' => true, - 'otofuke' => true, - 'otoineppu' => true, - 'oumu' => true, - 'ozora' => true, - 'pippu' => true, - 'rankoshi' => true, - 'rebun' => true, - 'rikubetsu' => true, - 'rishiri' => true, - 'rishirifuji' => true, - 'saroma' => true, - 'sarufutsu' => true, - 'shakotan' => true, - 'shari' => true, - 'shibecha' => true, - 'shibetsu' => true, - 'shikabe' => true, - 'shikaoi' => true, - 'shimamaki' => true, - 'shimizu' => true, - 'shimokawa' => true, - 'shinshinotsu' => true, - 'shintoku' => true, - 'shiranuka' => true, - 'shiraoi' => true, - 'shiriuchi' => true, - 'sobetsu' => true, - 'sunagawa' => true, - 'taiki' => true, - 'takasu' => true, - 'takikawa' => true, - 'takinoue' => true, - 'teshikaga' => true, - 'tobetsu' => true, - 'tohma' => true, - 'tomakomai' => true, - 'tomari' => true, - 'toya' => true, - 'toyako' => true, - 'toyotomi' => true, - 'toyoura' => true, - 'tsubetsu' => true, - 'tsukigata' => true, - 'urakawa' => true, - 'urausu' => true, - 'uryu' => true, - 'utashinai' => true, - 'wakkanai' => true, - 'wassamu' => true, - 'yakumo' => true, - 'yoichi' => true - ), - 'hyogo' => array( - 'aioi' => true, - 'akashi' => true, - 'ako' => true, - 'amagasaki' => true, - 'aogaki' => true, - 'asago' => true, - 'ashiya' => true, - 'awaji' => true, - 'fukusaki' => true, - 'goshiki' => true, - 'harima' => true, - 'himeji' => true, - 'ichikawa' => true, - 'inagawa' => true, - 'itami' => true, - 'kakogawa' => true, - 'kamigori' => true, - 'kamikawa' => true, - 'kasai' => true, - 'kasuga' => true, - 'kawanishi' => true, - 'miki' => true, - 'minamiawaji' => true, - 'nishinomiya' => true, - 'nishiwaki' => true, - 'ono' => true, - 'sanda' => true, - 'sannan' => true, - 'sasayama' => true, - 'sayo' => true, - 'shingu' => true, - 'shinonsen' => true, - 'shiso' => true, - 'sumoto' => true, - 'taishi' => true, - 'taka' => true, - 'takarazuka' => true, - 'takasago' => true, - 'takino' => true, - 'tamba' => true, - 'tatsuno' => true, - 'toyooka' => true, - 'yabu' => true, - 'yashiro' => true, - 'yoka' => true, - 'yokawa' => true - ), - 'ibaraki' => array( - 'ami' => true, - 'asahi' => true, - 'bando' => true, - 'chikusei' => true, - 'daigo' => true, - 'fujishiro' => true, - 'hitachi' => true, - 'hitachinaka' => true, - 'hitachiomiya' => true, - 'hitachiota' => true, - 'ibaraki' => true, - 'ina' => true, - 'inashiki' => true, - 'itako' => true, - 'iwama' => true, - 'joso' => true, - 'kamisu' => true, - 'kasama' => true, - 'kashima' => true, - 'kasumigaura' => true, - 'koga' => true, - 'miho' => true, - 'mito' => true, - 'moriya' => true, - 'naka' => true, - 'namegata' => true, - 'oarai' => true, - 'ogawa' => true, - 'omitama' => true, - 'ryugasaki' => true, - 'sakai' => true, - 'sakuragawa' => true, - 'shimodate' => true, - 'shimotsuma' => true, - 'shirosato' => true, - 'sowa' => true, - 'suifu' => true, - 'takahagi' => true, - 'tamatsukuri' => true, - 'tokai' => true, - 'tomobe' => true, - 'tone' => true, - 'toride' => true, - 'tsuchiura' => true, - 'tsukuba' => true, - 'uchihara' => true, - 'ushiku' => true, - 'yachiyo' => true, - 'yamagata' => true, - 'yawara' => true, - 'yuki' => true - ), - 'ishikawa' => array( - 'anamizu' => true, - 'hakui' => true, - 'hakusan' => true, - 'kaga' => true, - 'kahoku' => true, - 'kanazawa' => true, - 'kawakita' => true, - 'komatsu' => true, - 'nakanoto' => true, - 'nanao' => true, - 'nomi' => true, - 'nonoichi' => true, - 'noto' => true, - 'shika' => true, - 'suzu' => true, - 'tsubata' => true, - 'tsurugi' => true, - 'uchinada' => true, - 'wajima' => true - ), - 'iwate' => array( - 'fudai' => true, - 'fujisawa' => true, - 'hanamaki' => true, - 'hiraizumi' => true, - 'hirono' => true, - 'ichinohe' => true, - 'ichinoseki' => true, - 'iwaizumi' => true, - 'iwate' => true, - 'joboji' => true, - 'kamaishi' => true, - 'kanegasaki' => true, - 'karumai' => true, - 'kawai' => true, - 'kitakami' => true, - 'kuji' => true, - 'kunohe' => true, - 'kuzumaki' => true, - 'miyako' => true, - 'mizusawa' => true, - 'morioka' => true, - 'ninohe' => true, - 'noda' => true, - 'ofunato' => true, - 'oshu' => true, - 'otsuchi' => true, - 'rikuzentakata' => true, - 'shiwa' => true, - 'shizukuishi' => true, - 'sumita' => true, - 'takizawa' => true, - 'tanohata' => true, - 'tono' => true, - 'yahaba' => true, - 'yamada' => true - ), - 'kagawa' => array( - 'ayagawa' => true, - 'higashikagawa' => true, - 'kanonji' => true, - 'kotohira' => true, - 'manno' => true, - 'marugame' => true, - 'mitoyo' => true, - 'naoshima' => true, - 'sanuki' => true, - 'tadotsu' => true, - 'takamatsu' => true, - 'tonosho' => true, - 'uchinomi' => true, - 'utazu' => true, - 'zentsuji' => true - ), - 'kagoshima' => array( - 'akune' => true, - 'amami' => true, - 'hioki' => true, - 'isa' => true, - 'isen' => true, - 'izumi' => true, - 'kagoshima' => true, - 'kanoya' => true, - 'kawanabe' => true, - 'kinko' => true, - 'kouyama' => true, - 'makurazaki' => true, - 'matsumoto' => true, - 'minamitane' => true, - 'nakatane' => true, - 'nishinoomote' => true, - 'satsumasendai' => true, - 'soo' => true, - 'tarumizu' => true, - 'yusui' => true - ), - 'kanagawa' => array( - 'aikawa' => true, - 'atsugi' => true, - 'ayase' => true, - 'chigasaki' => true, - 'ebina' => true, - 'fujisawa' => true, - 'hadano' => true, - 'hakone' => true, - 'hiratsuka' => true, - 'isehara' => true, - 'kaisei' => true, - 'kamakura' => true, - 'kiyokawa' => true, - 'matsuda' => true, - 'minamiashigara' => true, - 'miura' => true, - 'nakai' => true, - 'ninomiya' => true, - 'odawara' => true, - 'oi' => true, - 'oiso' => true, - 'sagamihara' => true, - 'samukawa' => true, - 'tsukui' => true, - 'yamakita' => true, - 'yamato' => true, - 'yokosuka' => true, - 'yugawara' => true, - 'zama' => true, - 'zushi' => true - ), - 'kochi' => array( - 'aki' => true, - 'geisei' => true, - 'hidaka' => true, - 'higashitsuno' => true, - 'ino' => true, - 'kagami' => true, - 'kami' => true, - 'kitagawa' => true, - 'kochi' => true, - 'mihara' => true, - 'motoyama' => true, - 'muroto' => true, - 'nahari' => true, - 'nakamura' => true, - 'nankoku' => true, - 'nishitosa' => true, - 'niyodogawa' => true, - 'ochi' => true, - 'okawa' => true, - 'otoyo' => true, - 'otsuki' => true, - 'sakawa' => true, - 'sukumo' => true, - 'susaki' => true, - 'tosa' => true, - 'tosashimizu' => true, - 'toyo' => true, - 'tsuno' => true, - 'umaji' => true, - 'yasuda' => true, - 'yusuhara' => true - ), - 'kumamoto' => array( - 'amakusa' => true, - 'arao' => true, - 'aso' => true, - 'choyo' => true, - 'gyokuto' => true, - 'hitoyoshi' => true, - 'kamiamakusa' => true, - 'kashima' => true, - 'kikuchi' => true, - 'kosa' => true, - 'kumamoto' => true, - 'mashiki' => true, - 'mifune' => true, - 'minamata' => true, - 'minamioguni' => true, - 'nagasu' => true, - 'nishihara' => true, - 'oguni' => true, - 'ozu' => true, - 'sumoto' => true, - 'takamori' => true, - 'uki' => true, - 'uto' => true, - 'yamaga' => true, - 'yamato' => true, - 'yatsushiro' => true - ), - 'kyoto' => array( - 'ayabe' => true, - 'fukuchiyama' => true, - 'higashiyama' => true, - 'ide' => true, - 'ine' => true, - 'joyo' => true, - 'kameoka' => true, - 'kamo' => true, - 'kita' => true, - 'kizu' => true, - 'kumiyama' => true, - 'kyotamba' => true, - 'kyotanabe' => true, - 'kyotango' => true, - 'maizuru' => true, - 'minami' => true, - 'minamiyamashiro' => true, - 'miyazu' => true, - 'muko' => true, - 'nagaokakyo' => true, - 'nakagyo' => true, - 'nantan' => true, - 'oyamazaki' => true, - 'sakyo' => true, - 'seika' => true, - 'tanabe' => true, - 'uji' => true, - 'ujitawara' => true, - 'wazuka' => true, - 'yamashina' => true, - 'yawata' => true - ), - 'mie' => array( - 'asahi' => true, - 'inabe' => true, - 'ise' => true, - 'kameyama' => true, - 'kawagoe' => true, - 'kiho' => true, - 'kisosaki' => true, - 'kiwa' => true, - 'komono' => true, - 'kumano' => true, - 'kuwana' => true, - 'matsusaka' => true, - 'meiwa' => true, - 'mihama' => true, - 'minamiise' => true, - 'misugi' => true, - 'miyama' => true, - 'nabari' => true, - 'shima' => true, - 'suzuka' => true, - 'tado' => true, - 'taiki' => true, - 'taki' => true, - 'tamaki' => true, - 'toba' => true, - 'tsu' => true, - 'udono' => true, - 'ureshino' => true, - 'watarai' => true, - 'yokkaichi' => true - ), - 'miyagi' => array( - 'furukawa' => true, - 'higashimatsushima' => true, - 'ishinomaki' => true, - 'iwanuma' => true, - 'kakuda' => true, - 'kami' => true, - 'kawasaki' => true, - 'kesennuma' => true, - 'marumori' => true, - 'matsushima' => true, - 'minamisanriku' => true, - 'misato' => true, - 'murata' => true, - 'natori' => true, - 'ogawara' => true, - 'ohira' => true, - 'onagawa' => true, - 'osaki' => true, - 'rifu' => true, - 'semine' => true, - 'shibata' => true, - 'shichikashuku' => true, - 'shikama' => true, - 'shiogama' => true, - 'shiroishi' => true, - 'tagajo' => true, - 'taiwa' => true, - 'tome' => true, - 'tomiya' => true, - 'wakuya' => true, - 'watari' => true, - 'yamamoto' => true, - 'zao' => true - ), - 'miyazaki' => array( - 'aya' => true, - 'ebino' => true, - 'gokase' => true, - 'hyuga' => true, - 'kadogawa' => true, - 'kawaminami' => true, - 'kijo' => true, - 'kitagawa' => true, - 'kitakata' => true, - 'kitaura' => true, - 'kobayashi' => true, - 'kunitomi' => true, - 'kushima' => true, - 'mimata' => true, - 'miyakonojo' => true, - 'miyazaki' => true, - 'morotsuka' => true, - 'nichinan' => true, - 'nishimera' => true, - 'nobeoka' => true, - 'saito' => true, - 'shiiba' => true, - 'shintomi' => true, - 'takaharu' => true, - 'takanabe' => true, - 'takazaki' => true, - 'tsuno' => true - ), - 'nagano' => array( - 'achi' => true, - 'agematsu' => true, - 'anan' => true, - 'aoki' => true, - 'asahi' => true, - 'azumino' => true, - 'chikuhoku' => true, - 'chikuma' => true, - 'chino' => true, - 'fujimi' => true, - 'hakuba' => true, - 'hara' => true, - 'hiraya' => true, - 'iida' => true, - 'iijima' => true, - 'iiyama' => true, - 'iizuna' => true, - 'ikeda' => true, - 'ikusaka' => true, - 'ina' => true, - 'karuizawa' => true, - 'kawakami' => true, - 'kiso' => true, - 'kisofukushima' => true, - 'kitaaiki' => true, - 'komagane' => true, - 'komoro' => true, - 'matsukawa' => true, - 'matsumoto' => true, - 'miasa' => true, - 'minamiaiki' => true, - 'minamimaki' => true, - 'minamiminowa' => true, - 'minowa' => true, - 'miyada' => true, - 'miyota' => true, - 'mochizuki' => true, - 'nagano' => true, - 'nagawa' => true, - 'nagiso' => true, - 'nakagawa' => true, - 'nakano' => true, - 'nozawaonsen' => true, - 'obuse' => true, - 'ogawa' => true, - 'okaya' => true, - 'omachi' => true, - 'omi' => true, - 'ookuwa' => true, - 'ooshika' => true, - 'otaki' => true, - 'otari' => true, - 'sakae' => true, - 'sakaki' => true, - 'saku' => true, - 'sakuho' => true, - 'shimosuwa' => true, - 'shinanomachi' => true, - 'shiojiri' => true, - 'suwa' => true, - 'suzaka' => true, - 'takagi' => true, - 'takamori' => true, - 'takayama' => true, - 'tateshina' => true, - 'tatsuno' => true, - 'togakushi' => true, - 'togura' => true, - 'tomi' => true, - 'ueda' => true, - 'wada' => true, - 'yamagata' => true, - 'yamanouchi' => true, - 'yasaka' => true, - 'yasuoka' => true - ), - 'nagasaki' => array( - 'chijiwa' => true, - 'futsu' => true, - 'goto' => true, - 'hasami' => true, - 'hirado' => true, - 'iki' => true, - 'isahaya' => true, - 'kawatana' => true, - 'kuchinotsu' => true, - 'matsuura' => true, - 'nagasaki' => true, - 'obama' => true, - 'omura' => true, - 'oseto' => true, - 'saikai' => true, - 'sasebo' => true, - 'seihi' => true, - 'shimabara' => true, - 'shinkamigoto' => true, - 'togitsu' => true, - 'tsushima' => true, - 'unzen' => true - ), - 'nara' => array( - 'ando' => true, - 'gose' => true, - 'heguri' => true, - 'higashiyoshino' => true, - 'ikaruga' => true, - 'ikoma' => true, - 'kamikitayama' => true, - 'kanmaki' => true, - 'kashiba' => true, - 'kashihara' => true, - 'katsuragi' => true, - 'kawai' => true, - 'kawakami' => true, - 'kawanishi' => true, - 'koryo' => true, - 'kurotaki' => true, - 'mitsue' => true, - 'miyake' => true, - 'nara' => true, - 'nosegawa' => true, - 'oji' => true, - 'ouda' => true, - 'oyodo' => true, - 'sakurai' => true, - 'sango' => true, - 'shimoichi' => true, - 'shimokitayama' => true, - 'shinjo' => true, - 'soni' => true, - 'takatori' => true, - 'tawaramoto' => true, - 'tenkawa' => true, - 'tenri' => true, - 'uda' => true, - 'yamatokoriyama' => true, - 'yamatotakada' => true, - 'yamazoe' => true, - 'yoshino' => true - ), - 'niigata' => array( - 'aga' => true, - 'agano' => true, - 'gosen' => true, - 'itoigawa' => true, - 'izumozaki' => true, - 'joetsu' => true, - 'kamo' => true, - 'kariwa' => true, - 'kashiwazaki' => true, - 'minamiuonuma' => true, - 'mitsuke' => true, - 'muika' => true, - 'murakami' => true, - 'myoko' => true, - 'nagaoka' => true, - 'niigata' => true, - 'ojiya' => true, - 'omi' => true, - 'sado' => true, - 'sanjo' => true, - 'seiro' => true, - 'seirou' => true, - 'sekikawa' => true, - 'shibata' => true, - 'tagami' => true, - 'tainai' => true, - 'tochio' => true, - 'tokamachi' => true, - 'tsubame' => true, - 'tsunan' => true, - 'uonuma' => true, - 'yahiko' => true, - 'yoita' => true, - 'yuzawa' => true - ), - 'oita' => array( - 'beppu' => true, - 'bungoono' => true, - 'bungotakada' => true, - 'hasama' => true, - 'hiji' => true, - 'himeshima' => true, - 'hita' => true, - 'kamitsue' => true, - 'kokonoe' => true, - 'kuju' => true, - 'kunisaki' => true, - 'kusu' => true, - 'oita' => true, - 'saiki' => true, - 'taketa' => true, - 'tsukumi' => true, - 'usa' => true, - 'usuki' => true, - 'yufu' => true - ), - 'okayama' => array( - 'akaiwa' => true, - 'asakuchi' => true, - 'bizen' => true, - 'hayashima' => true, - 'ibara' => true, - 'kagamino' => true, - 'kasaoka' => true, - 'kibichuo' => true, - 'kumenan' => true, - 'kurashiki' => true, - 'maniwa' => true, - 'misaki' => true, - 'nagi' => true, - 'niimi' => true, - 'nishiawakura' => true, - 'okayama' => true, - 'satosho' => true, - 'setouchi' => true, - 'shinjo' => true, - 'shoo' => true, - 'soja' => true, - 'takahashi' => true, - 'tamano' => true, - 'tsuyama' => true, - 'wake' => true, - 'yakage' => true - ), - 'okinawa' => array( - 'aguni' => true, - 'ginowan' => true, - 'ginoza' => true, - 'gushikami' => true, - 'haebaru' => true, - 'higashi' => true, - 'hirara' => true, - 'iheya' => true, - 'ishigaki' => true, - 'ishikawa' => true, - 'itoman' => true, - 'izena' => true, - 'kadena' => true, - 'kin' => true, - 'kitadaito' => true, - 'kitanakagusuku' => true, - 'kumejima' => true, - 'kunigami' => true, - 'minamidaito' => true, - 'motobu' => true, - 'nago' => true, - 'naha' => true, - 'nakagusuku' => true, - 'nakijin' => true, - 'nanjo' => true, - 'nishihara' => true, - 'ogimi' => true, - 'okinawa' => true, - 'onna' => true, - 'shimoji' => true, - 'taketomi' => true, - 'tarama' => true, - 'tokashiki' => true, - 'tomigusuku' => true, - 'tonaki' => true, - 'urasoe' => true, - 'uruma' => true, - 'yaese' => true, - 'yomitan' => true, - 'yonabaru' => true, - 'yonaguni' => true, - 'zamami' => true - ), - 'osaka' => array( - 'abeno' => true, - 'chihayaakasaka' => true, - 'chuo' => true, - 'daito' => true, - 'fujiidera' => true, - 'habikino' => true, - 'hannan' => true, - 'higashiosaka' => true, - 'higashisumiyoshi' => true, - 'higashiyodogawa' => true, - 'hirakata' => true, - 'ibaraki' => true, - 'ikeda' => true, - 'izumi' => true, - 'izumiotsu' => true, - 'izumisano' => true, - 'kadoma' => true, - 'kaizuka' => true, - 'kanan' => true, - 'kashiwara' => true, - 'katano' => true, - 'kawachinagano' => true, - 'kishiwada' => true, - 'kita' => true, - 'kumatori' => true, - 'matsubara' => true, - 'minato' => true, - 'minoh' => true, - 'misaki' => true, - 'moriguchi' => true, - 'neyagawa' => true, - 'nishi' => true, - 'nose' => true, - 'osakasayama' => true, - 'sakai' => true, - 'sayama' => true, - 'sennan' => true, - 'settsu' => true, - 'shijonawate' => true, - 'shimamoto' => true, - 'suita' => true, - 'tadaoka' => true, - 'taishi' => true, - 'tajiri' => true, - 'takaishi' => true, - 'takatsuki' => true, - 'tondabayashi' => true, - 'toyonaka' => true, - 'toyono' => true, - 'yao' => true - ), - 'saga' => array( - 'ariake' => true, - 'arita' => true, - 'fukudomi' => true, - 'genkai' => true, - 'hamatama' => true, - 'hizen' => true, - 'imari' => true, - 'kamimine' => true, - 'kanzaki' => true, - 'karatsu' => true, - 'kashima' => true, - 'kitagata' => true, - 'kitahata' => true, - 'kiyama' => true, - 'kouhoku' => true, - 'kyuragi' => true, - 'nishiarita' => true, - 'ogi' => true, - 'omachi' => true, - 'ouchi' => true, - 'saga' => true, - 'shiroishi' => true, - 'taku' => true, - 'tara' => true, - 'tosu' => true, - 'yoshinogari' => true - ), - 'saitama' => array( - 'arakawa' => true, - 'asaka' => true, - 'chichibu' => true, - 'fujimi' => true, - 'fujimino' => true, - 'fukaya' => true, - 'hanno' => true, - 'hanyu' => true, - 'hasuda' => true, - 'hatogaya' => true, - 'hatoyama' => true, - 'hidaka' => true, - 'higashichichibu' => true, - 'higashimatsuyama' => true, - 'honjo' => true, - 'ina' => true, - 'iruma' => true, - 'iwatsuki' => true, - 'kamiizumi' => true, - 'kamikawa' => true, - 'kamisato' => true, - 'kasukabe' => true, - 'kawagoe' => true, - 'kawaguchi' => true, - 'kawajima' => true, - 'kazo' => true, - 'kitamoto' => true, - 'koshigaya' => true, - 'kounosu' => true, - 'kuki' => true, - 'kumagaya' => true, - 'matsubushi' => true, - 'minano' => true, - 'misato' => true, - 'miyashiro' => true, - 'miyoshi' => true, - 'moroyama' => true, - 'nagatoro' => true, - 'namegawa' => true, - 'niiza' => true, - 'ogano' => true, - 'ogawa' => true, - 'ogose' => true, - 'okegawa' => true, - 'omiya' => true, - 'otaki' => true, - 'ranzan' => true, - 'ryokami' => true, - 'saitama' => true, - 'sakado' => true, - 'satte' => true, - 'sayama' => true, - 'shiki' => true, - 'shiraoka' => true, - 'soka' => true, - 'sugito' => true, - 'toda' => true, - 'tokigawa' => true, - 'tokorozawa' => true, - 'tsurugashima' => true, - 'urawa' => true, - 'warabi' => true, - 'yashio' => true, - 'yokoze' => true, - 'yono' => true, - 'yorii' => true, - 'yoshida' => true, - 'yoshikawa' => true, - 'yoshimi' => true - ), - 'shiga' => array( - 'aisho' => true, - 'gamo' => true, - 'higashiomi' => true, - 'hikone' => true, - 'koka' => true, - 'konan' => true, - 'kosei' => true, - 'koto' => true, - 'kusatsu' => true, - 'maibara' => true, - 'moriyama' => true, - 'nagahama' => true, - 'nishiazai' => true, - 'notogawa' => true, - 'omihachiman' => true, - 'otsu' => true, - 'ritto' => true, - 'ryuoh' => true, - 'takashima' => true, - 'takatsuki' => true, - 'torahime' => true, - 'toyosato' => true, - 'yasu' => true - ), - 'shimane' => array( - 'akagi' => true, - 'ama' => true, - 'gotsu' => true, - 'hamada' => true, - 'higashiizumo' => true, - 'hikawa' => true, - 'hikimi' => true, - 'izumo' => true, - 'kakinoki' => true, - 'masuda' => true, - 'matsue' => true, - 'misato' => true, - 'nishinoshima' => true, - 'ohda' => true, - 'okinoshima' => true, - 'okuizumo' => true, - 'shimane' => true, - 'tamayu' => true, - 'tsuwano' => true, - 'unnan' => true, - 'yakumo' => true, - 'yasugi' => true, - 'yatsuka' => true - ), - 'shizuoka' => array( - 'arai' => true, - 'atami' => true, - 'fuji' => true, - 'fujieda' => true, - 'fujikawa' => true, - 'fujinomiya' => true, - 'fukuroi' => true, - 'gotemba' => true, - 'haibara' => true, - 'hamamatsu' => true, - 'higashiizu' => true, - 'ito' => true, - 'iwata' => true, - 'izu' => true, - 'izunokuni' => true, - 'kakegawa' => true, - 'kannami' => true, - 'kawanehon' => true, - 'kawazu' => true, - 'kikugawa' => true, - 'kosai' => true, - 'makinohara' => true, - 'matsuzaki' => true, - 'minamiizu' => true, - 'mishima' => true, - 'morimachi' => true, - 'nishiizu' => true, - 'numazu' => true, - 'omaezaki' => true, - 'shimada' => true, - 'shimizu' => true, - 'shimoda' => true, - 'shizuoka' => true, - 'susono' => true, - 'yaizu' => true, - 'yoshida' => true - ), - 'tochigi' => array( - 'ashikaga' => true, - 'bato' => true, - 'haga' => true, - 'ichikai' => true, - 'iwafune' => true, - 'kaminokawa' => true, - 'kanuma' => true, - 'karasuyama' => true, - 'kuroiso' => true, - 'mashiko' => true, - 'mibu' => true, - 'moka' => true, - 'motegi' => true, - 'nasu' => true, - 'nasushiobara' => true, - 'nikko' => true, - 'nishikata' => true, - 'nogi' => true, - 'ohira' => true, - 'ohtawara' => true, - 'oyama' => true, - 'sakura' => true, - 'sano' => true, - 'shimotsuke' => true, - 'shioya' => true, - 'takanezawa' => true, - 'tochigi' => true, - 'tsuga' => true, - 'ujiie' => true, - 'utsunomiya' => true, - 'yaita' => true - ), - 'tokushima' => array( - 'aizumi' => true, - 'anan' => true, - 'ichiba' => true, - 'itano' => true, - 'kainan' => true, - 'komatsushima' => true, - 'matsushige' => true, - 'mima' => true, - 'minami' => true, - 'miyoshi' => true, - 'mugi' => true, - 'nakagawa' => true, - 'naruto' => true, - 'sanagochi' => true, - 'shishikui' => true, - 'tokushima' => true, - 'wajiki' => true - ), - 'tokyo' => array( - 'adachi' => true, - 'akiruno' => true, - 'akishima' => true, - 'aogashima' => true, - 'arakawa' => true, - 'bunkyo' => true, - 'chiyoda' => true, - 'chofu' => true, - 'chuo' => true, - 'edogawa' => true, - 'fuchu' => true, - 'fussa' => true, - 'hachijo' => true, - 'hachioji' => true, - 'hamura' => true, - 'higashikurume' => true, - 'higashimurayama' => true, - 'higashiyamato' => true, - 'hino' => true, - 'hinode' => true, - 'hinohara' => true, - 'inagi' => true, - 'itabashi' => true, - 'katsushika' => true, - 'kita' => true, - 'kiyose' => true, - 'kodaira' => true, - 'koganei' => true, - 'kokubunji' => true, - 'komae' => true, - 'koto' => true, - 'kouzushima' => true, - 'kunitachi' => true, - 'machida' => true, - 'meguro' => true, - 'minato' => true, - 'mitaka' => true, - 'mizuho' => true, - 'musashimurayama' => true, - 'musashino' => true, - 'nakano' => true, - 'nerima' => true, - 'ogasawara' => true, - 'okutama' => true, - 'ome' => true, - 'oshima' => true, - 'ota' => true, - 'setagaya' => true, - 'shibuya' => true, - 'shinagawa' => true, - 'shinjuku' => true, - 'suginami' => true, - 'sumida' => true, - 'tachikawa' => true, - 'taito' => true, - 'tama' => true, - 'toshima' => true - ), - 'tottori' => array( - 'chizu' => true, - 'hino' => true, - 'kawahara' => true, - 'koge' => true, - 'kotoura' => true, - 'misasa' => true, - 'nanbu' => true, - 'nichinan' => true, - 'sakaiminato' => true, - 'tottori' => true, - 'wakasa' => true, - 'yazu' => true, - 'yonago' => true - ), - 'toyama' => array( - 'asahi' => true, - 'fuchu' => true, - 'fukumitsu' => true, - 'funahashi' => true, - 'himi' => true, - 'imizu' => true, - 'inami' => true, - 'johana' => true, - 'kamiichi' => true, - 'kurobe' => true, - 'nakaniikawa' => true, - 'namerikawa' => true, - 'nanto' => true, - 'nyuzen' => true, - 'oyabe' => true, - 'taira' => true, - 'takaoka' => true, - 'tateyama' => true, - 'toga' => true, - 'tonami' => true, - 'toyama' => true, - 'unazuki' => true, - 'uozu' => true, - 'yamada' => true - ), - 'wakayama' => array( - 'arida' => true, - 'aridagawa' => true, - 'gobo' => true, - 'hashimoto' => true, - 'hidaka' => true, - 'hirogawa' => true, - 'inami' => true, - 'iwade' => true, - 'kainan' => true, - 'kamitonda' => true, - 'katsuragi' => true, - 'kimino' => true, - 'kinokawa' => true, - 'kitayama' => true, - 'koya' => true, - 'koza' => true, - 'kozagawa' => true, - 'kudoyama' => true, - 'kushimoto' => true, - 'mihama' => true, - 'misato' => true, - 'nachikatsuura' => true, - 'shingu' => true, - 'shirahama' => true, - 'taiji' => true, - 'tanabe' => true, - 'wakayama' => true, - 'yuasa' => true, - 'yura' => true - ), - 'yamagata' => array( - 'asahi' => true, - 'funagata' => true, - 'higashine' => true, - 'iide' => true, - 'kahoku' => true, - 'kaminoyama' => true, - 'kaneyama' => true, - 'kawanishi' => true, - 'mamurogawa' => true, - 'mikawa' => true, - 'murayama' => true, - 'nagai' => true, - 'nakayama' => true, - 'nanyo' => true, - 'nishikawa' => true, - 'obanazawa' => true, - 'oe' => true, - 'oguni' => true, - 'ohkura' => true, - 'oishida' => true, - 'sagae' => true, - 'sakata' => true, - 'sakegawa' => true, - 'shinjo' => true, - 'shirataka' => true, - 'shonai' => true, - 'takahata' => true, - 'tendo' => true, - 'tozawa' => true, - 'tsuruoka' => true, - 'yamagata' => true, - 'yamanobe' => true, - 'yonezawa' => true, - 'yuza' => true - ), - 'yamaguchi' => array( - 'abu' => true, - 'hagi' => true, - 'hikari' => true, - 'hofu' => true, - 'iwakuni' => true, - 'kudamatsu' => true, - 'mitou' => true, - 'nagato' => true, - 'oshima' => true, - 'shimonoseki' => true, - 'shunan' => true, - 'tabuse' => true, - 'tokuyama' => true, - 'toyota' => true, - 'ube' => true, - 'yuu' => true - ), - 'yamanashi' => array( - 'chuo' => true, - 'doshi' => true, - 'fuefuki' => true, - 'fujikawa' => true, - 'fujikawaguchiko' => true, - 'fujiyoshida' => true, - 'hayakawa' => true, - 'hokuto' => true, - 'ichikawamisato' => true, - 'kai' => true, - 'kofu' => true, - 'koshu' => true, - 'kosuge' => true, - 'minami-alps' => true, - 'minobu' => true, - 'nakamichi' => true, - 'nanbu' => true, - 'narusawa' => true, - 'nirasaki' => true, - 'nishikatsura' => true, - 'oshino' => true, - 'otsuki' => true, - 'showa' => true, - 'tabayama' => true, - 'tsuru' => true, - 'uenohara' => true, - 'yamanakako' => true, - 'yamanashi' => true - ), - 'kawasaki' => array( - '*' => true, - '!city' => true - ), - 'kitakyushu' => array( - '*' => true, - '!city' => true - ), - 'kobe' => array( - '*' => true, - '!city' => true - ), - 'nagoya' => array( - '*' => true, - '!city' => true - ), - 'sapporo' => array( - '*' => true, - '!city' => true - ), - 'sendai' => array( - '*' => true, - '!city' => true - ), - 'yokohama' => array( - '*' => true, - '!city' => true - ), - 'blogspot' => true - ), - 'ke' => array( - '*' => true - ), - 'kg' => array( - 'org' => true, - 'net' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true - ), - 'kh' => array( - '*' => true - ), - 'ki' => array( - 'edu' => true, - 'biz' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'info' => true, - 'com' => true - ), - 'km' => array( - 'org' => true, - 'nom' => true, - 'gov' => true, - 'prd' => true, - 'tm' => true, - 'edu' => true, - 'mil' => true, - 'ass' => true, - 'com' => true, - 'coop' => true, - 'asso' => true, - 'presse' => true, - 'medecin' => true, - 'notaires' => true, - 'pharmaciens' => true, - 'veterinaire' => true, - 'gouv' => true - ), - 'kn' => array( - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'kp' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'rep' => true, - 'tra' => true - ), - 'kr' => array( - 'ac' => true, - 'co' => true, - 'es' => true, - 'go' => true, - 'hs' => true, - 'kg' => true, - 'mil' => true, - 'ms' => true, - 'ne' => true, - 'or' => true, - 'pe' => true, - 're' => true, - 'sc' => true, - 'busan' => true, - 'chungbuk' => true, - 'chungnam' => true, - 'daegu' => true, - 'daejeon' => true, - 'gangwon' => true, - 'gwangju' => true, - 'gyeongbuk' => true, - 'gyeonggi' => true, - 'gyeongnam' => true, - 'incheon' => true, - 'jeju' => true, - 'jeonbuk' => true, - 'jeonnam' => true, - 'seoul' => true, - 'ulsan' => true, - 'blogspot' => true - ), - 'kw' => array( - '*' => true - ), - 'ky' => array( - 'edu' => true, - 'gov' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'kz' => array( - 'org' => true, - 'edu' => true, - 'net' => true, - 'gov' => true, - 'mil' => true, - 'com' => true - ), - 'la' => array( - 'int' => true, - 'net' => true, - 'info' => true, - 'edu' => true, - 'gov' => true, - 'per' => true, - 'com' => true, - 'org' => true, - 'c' => true - ), - 'lb' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'lc' => array( - 'com' => true, - 'net' => true, - 'co' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'li' => true, - 'lk' => array( - 'gov' => true, - 'sch' => true, - 'net' => true, - 'int' => true, - 'com' => true, - 'org' => true, - 'edu' => true, - 'ngo' => true, - 'soc' => true, - 'web' => true, - 'ltd' => true, - 'assn' => true, - 'grp' => true, - 'hotel' => true - ), - 'lr' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'net' => true - ), - 'ls' => array( - 'co' => true, - 'org' => true - ), - 'lt' => array( - 'gov' => true - ), - 'lu' => true, - 'lv' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true, - 'id' => true, - 'net' => true, - 'asn' => true, - 'conf' => true - ), - 'ly' => array( - 'com' => true, - 'net' => true, - 'gov' => true, - 'plc' => true, - 'edu' => true, - 'sch' => true, - 'med' => true, - 'org' => true, - 'id' => true - ), - 'ma' => array( - 'co' => true, - 'net' => true, - 'gov' => true, - 'org' => true, - 'ac' => true, - 'press' => true - ), - 'mc' => array( - 'tm' => true, - 'asso' => true - ), - 'md' => true, - 'me' => array( - 'co' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'ac' => true, - 'gov' => true, - 'its' => true, - 'priv' => true - ), - 'mg' => array( - 'org' => true, - 'nom' => true, - 'gov' => true, - 'prd' => true, - 'tm' => true, - 'edu' => true, - 'mil' => true, - 'com' => true - ), - 'mh' => true, - 'mil' => true, - 'mk' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'inf' => true, - 'name' => true - ), - 'ml' => array( - 'com' => true, - 'edu' => true, - 'gouv' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'presse' => true - ), - 'mm' => array( - '*' => true - ), - 'mn' => array( - 'gov' => true, - 'edu' => true, - 'org' => true, - 'nyc' => true - ), - 'mo' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'mobi' => true, - 'mp' => true, - 'mq' => true, - 'mr' => array( - 'gov' => true, - 'blogspot' => true - ), - 'ms' => true, - 'mt' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true - ), - 'mu' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'ac' => true, - 'co' => true, - 'or' => true - ), - 'museum' => array( - 'academy' => true, - 'agriculture' => true, - 'air' => true, - 'airguard' => true, - 'alabama' => true, - 'alaska' => true, - 'amber' => true, - 'ambulance' => true, - 'american' => true, - 'americana' => true, - 'americanantiques' => true, - 'americanart' => true, - 'amsterdam' => true, - 'and' => true, - 'annefrank' => true, - 'anthro' => true, - 'anthropology' => true, - 'antiques' => true, - 'aquarium' => true, - 'arboretum' => true, - 'archaeological' => true, - 'archaeology' => true, - 'architecture' => true, - 'art' => true, - 'artanddesign' => true, - 'artcenter' => true, - 'artdeco' => true, - 'arteducation' => true, - 'artgallery' => true, - 'arts' => true, - 'artsandcrafts' => true, - 'asmatart' => true, - 'assassination' => true, - 'assisi' => true, - 'association' => true, - 'astronomy' => true, - 'atlanta' => true, - 'austin' => true, - 'australia' => true, - 'automotive' => true, - 'aviation' => true, - 'axis' => true, - 'badajoz' => true, - 'baghdad' => true, - 'bahn' => true, - 'bale' => true, - 'baltimore' => true, - 'barcelona' => true, - 'baseball' => true, - 'basel' => true, - 'baths' => true, - 'bauern' => true, - 'beauxarts' => true, - 'beeldengeluid' => true, - 'bellevue' => true, - 'bergbau' => true, - 'berkeley' => true, - 'berlin' => true, - 'bern' => true, - 'bible' => true, - 'bilbao' => true, - 'bill' => true, - 'birdart' => true, - 'birthplace' => true, - 'bonn' => true, - 'boston' => true, - 'botanical' => true, - 'botanicalgarden' => true, - 'botanicgarden' => true, - 'botany' => true, - 'brandywinevalley' => true, - 'brasil' => true, - 'bristol' => true, - 'british' => true, - 'britishcolumbia' => true, - 'broadcast' => true, - 'brunel' => true, - 'brussel' => true, - 'brussels' => true, - 'bruxelles' => true, - 'building' => true, - 'burghof' => true, - 'bus' => true, - 'bushey' => true, - 'cadaques' => true, - 'california' => true, - 'cambridge' => true, - 'can' => true, - 'canada' => true, - 'capebreton' => true, - 'carrier' => true, - 'cartoonart' => true, - 'casadelamoneda' => true, - 'castle' => true, - 'castres' => true, - 'celtic' => true, - 'center' => true, - 'chattanooga' => true, - 'cheltenham' => true, - 'chesapeakebay' => true, - 'chicago' => true, - 'children' => true, - 'childrens' => true, - 'childrensgarden' => true, - 'chiropractic' => true, - 'chocolate' => true, - 'christiansburg' => true, - 'cincinnati' => true, - 'cinema' => true, - 'circus' => true, - 'civilisation' => true, - 'civilization' => true, - 'civilwar' => true, - 'clinton' => true, - 'clock' => true, - 'coal' => true, - 'coastaldefence' => true, - 'cody' => true, - 'coldwar' => true, - 'collection' => true, - 'colonialwilliamsburg' => true, - 'coloradoplateau' => true, - 'columbia' => true, - 'columbus' => true, - 'communication' => true, - 'communications' => true, - 'community' => true, - 'computer' => true, - 'computerhistory' => true, - 'comunicações' => true, - 'contemporary' => true, - 'contemporaryart' => true, - 'convent' => true, - 'copenhagen' => true, - 'corporation' => true, - 'correios-e-telecomunicações' => true, - 'corvette' => true, - 'costume' => true, - 'countryestate' => true, - 'county' => true, - 'crafts' => true, - 'cranbrook' => true, - 'creation' => true, - 'cultural' => true, - 'culturalcenter' => true, - 'culture' => true, - 'cyber' => true, - 'cymru' => true, - 'dali' => true, - 'dallas' => true, - 'database' => true, - 'ddr' => true, - 'decorativearts' => true, - 'delaware' => true, - 'delmenhorst' => true, - 'denmark' => true, - 'depot' => true, - 'design' => true, - 'detroit' => true, - 'dinosaur' => true, - 'discovery' => true, - 'dolls' => true, - 'donostia' => true, - 'durham' => true, - 'eastafrica' => true, - 'eastcoast' => true, - 'education' => true, - 'educational' => true, - 'egyptian' => true, - 'eisenbahn' => true, - 'elburg' => true, - 'elvendrell' => true, - 'embroidery' => true, - 'encyclopedic' => true, - 'england' => true, - 'entomology' => true, - 'environment' => true, - 'environmentalconservation' => true, - 'epilepsy' => true, - 'essex' => true, - 'estate' => true, - 'ethnology' => true, - 'exeter' => true, - 'exhibition' => true, - 'family' => true, - 'farm' => true, - 'farmequipment' => true, - 'farmers' => true, - 'farmstead' => true, - 'field' => true, - 'figueres' => true, - 'filatelia' => true, - 'film' => true, - 'fineart' => true, - 'finearts' => true, - 'finland' => true, - 'flanders' => true, - 'florida' => true, - 'force' => true, - 'fortmissoula' => true, - 'fortworth' => true, - 'foundation' => true, - 'francaise' => true, - 'frankfurt' => true, - 'franziskaner' => true, - 'freemasonry' => true, - 'freiburg' => true, - 'fribourg' => true, - 'frog' => true, - 'fundacio' => true, - 'furniture' => true, - 'gallery' => true, - 'garden' => true, - 'gateway' => true, - 'geelvinck' => true, - 'gemological' => true, - 'geology' => true, - 'georgia' => true, - 'giessen' => true, - 'glas' => true, - 'glass' => true, - 'gorge' => true, - 'grandrapids' => true, - 'graz' => true, - 'guernsey' => true, - 'halloffame' => true, - 'hamburg' => true, - 'handson' => true, - 'harvestcelebration' => true, - 'hawaii' => true, - 'health' => true, - 'heimatunduhren' => true, - 'hellas' => true, - 'helsinki' => true, - 'hembygdsforbund' => true, - 'heritage' => true, - 'histoire' => true, - 'historical' => true, - 'historicalsociety' => true, - 'historichouses' => true, - 'historisch' => true, - 'historisches' => true, - 'history' => true, - 'historyofscience' => true, - 'horology' => true, - 'house' => true, - 'humanities' => true, - 'illustration' => true, - 'imageandsound' => true, - 'indian' => true, - 'indiana' => true, - 'indianapolis' => true, - 'indianmarket' => true, - 'intelligence' => true, - 'interactive' => true, - 'iraq' => true, - 'iron' => true, - 'isleofman' => true, - 'jamison' => true, - 'jefferson' => true, - 'jerusalem' => true, - 'jewelry' => true, - 'jewish' => true, - 'jewishart' => true, - 'jfk' => true, - 'journalism' => true, - 'judaica' => true, - 'judygarland' => true, - 'juedisches' => true, - 'juif' => true, - 'karate' => true, - 'karikatur' => true, - 'kids' => true, - 'koebenhavn' => true, - 'koeln' => true, - 'kunst' => true, - 'kunstsammlung' => true, - 'kunstunddesign' => true, - 'labor' => true, - 'labour' => true, - 'lajolla' => true, - 'lancashire' => true, - 'landes' => true, - 'lans' => true, - 'läns' => true, - 'larsson' => true, - 'lewismiller' => true, - 'lincoln' => true, - 'linz' => true, - 'living' => true, - 'livinghistory' => true, - 'localhistory' => true, - 'london' => true, - 'losangeles' => true, - 'louvre' => true, - 'loyalist' => true, - 'lucerne' => true, - 'luxembourg' => true, - 'luzern' => true, - 'mad' => true, - 'madrid' => true, - 'mallorca' => true, - 'manchester' => true, - 'mansion' => true, - 'mansions' => true, - 'manx' => true, - 'marburg' => true, - 'maritime' => true, - 'maritimo' => true, - 'maryland' => true, - 'marylhurst' => true, - 'media' => true, - 'medical' => true, - 'medizinhistorisches' => true, - 'meeres' => true, - 'memorial' => true, - 'mesaverde' => true, - 'michigan' => true, - 'midatlantic' => true, - 'military' => true, - 'mill' => true, - 'miners' => true, - 'mining' => true, - 'minnesota' => true, - 'missile' => true, - 'missoula' => true, - 'modern' => true, - 'moma' => true, - 'money' => true, - 'monmouth' => true, - 'monticello' => true, - 'montreal' => true, - 'moscow' => true, - 'motorcycle' => true, - 'muenchen' => true, - 'muenster' => true, - 'mulhouse' => true, - 'muncie' => true, - 'museet' => true, - 'museumcenter' => true, - 'museumvereniging' => true, - 'music' => true, - 'national' => true, - 'nationalfirearms' => true, - 'nationalheritage' => true, - 'nativeamerican' => true, - 'naturalhistory' => true, - 'naturalhistorymuseum' => true, - 'naturalsciences' => true, - 'nature' => true, - 'naturhistorisches' => true, - 'natuurwetenschappen' => true, - 'naumburg' => true, - 'naval' => true, - 'nebraska' => true, - 'neues' => true, - 'newhampshire' => true, - 'newjersey' => true, - 'newmexico' => true, - 'newport' => true, - 'newspaper' => true, - 'newyork' => true, - 'niepce' => true, - 'norfolk' => true, - 'north' => true, - 'nrw' => true, - 'nuernberg' => true, - 'nuremberg' => true, - 'nyc' => true, - 'nyny' => true, - 'oceanographic' => true, - 'oceanographique' => true, - 'omaha' => true, - 'online' => true, - 'ontario' => true, - 'openair' => true, - 'oregon' => true, - 'oregontrail' => true, - 'otago' => true, - 'oxford' => true, - 'pacific' => true, - 'paderborn' => true, - 'palace' => true, - 'paleo' => true, - 'palmsprings' => true, - 'panama' => true, - 'paris' => true, - 'pasadena' => true, - 'pharmacy' => true, - 'philadelphia' => true, - 'philadelphiaarea' => true, - 'philately' => true, - 'phoenix' => true, - 'photography' => true, - 'pilots' => true, - 'pittsburgh' => true, - 'planetarium' => true, - 'plantation' => true, - 'plants' => true, - 'plaza' => true, - 'portal' => true, - 'portland' => true, - 'portlligat' => true, - 'posts-and-telecommunications' => true, - 'preservation' => true, - 'presidio' => true, - 'press' => true, - 'project' => true, - 'public' => true, - 'pubol' => true, - 'quebec' => true, - 'railroad' => true, - 'railway' => true, - 'research' => true, - 'resistance' => true, - 'riodejaneiro' => true, - 'rochester' => true, - 'rockart' => true, - 'roma' => true, - 'russia' => true, - 'saintlouis' => true, - 'salem' => true, - 'salvadordali' => true, - 'salzburg' => true, - 'sandiego' => true, - 'sanfrancisco' => true, - 'santabarbara' => true, - 'santacruz' => true, - 'santafe' => true, - 'saskatchewan' => true, - 'satx' => true, - 'savannahga' => true, - 'schlesisches' => true, - 'schoenbrunn' => true, - 'schokoladen' => true, - 'school' => true, - 'schweiz' => true, - 'science' => true, - 'scienceandhistory' => true, - 'scienceandindustry' => true, - 'sciencecenter' => true, - 'sciencecenters' => true, - 'science-fiction' => true, - 'sciencehistory' => true, - 'sciences' => true, - 'sciencesnaturelles' => true, - 'scotland' => true, - 'seaport' => true, - 'settlement' => true, - 'settlers' => true, - 'shell' => true, - 'sherbrooke' => true, - 'sibenik' => true, - 'silk' => true, - 'ski' => true, - 'skole' => true, - 'society' => true, - 'sologne' => true, - 'soundandvision' => true, - 'southcarolina' => true, - 'southwest' => true, - 'space' => true, - 'spy' => true, - 'square' => true, - 'stadt' => true, - 'stalbans' => true, - 'starnberg' => true, - 'state' => true, - 'stateofdelaware' => true, - 'station' => true, - 'steam' => true, - 'steiermark' => true, - 'stjohn' => true, - 'stockholm' => true, - 'stpetersburg' => true, - 'stuttgart' => true, - 'suisse' => true, - 'surgeonshall' => true, - 'surrey' => true, - 'svizzera' => true, - 'sweden' => true, - 'sydney' => true, - 'tank' => true, - 'tcm' => true, - 'technology' => true, - 'telekommunikation' => true, - 'television' => true, - 'texas' => true, - 'textile' => true, - 'theater' => true, - 'time' => true, - 'timekeeping' => true, - 'topology' => true, - 'torino' => true, - 'touch' => true, - 'town' => true, - 'transport' => true, - 'tree' => true, - 'trolley' => true, - 'trust' => true, - 'trustee' => true, - 'uhren' => true, - 'ulm' => true, - 'undersea' => true, - 'university' => true, - 'usa' => true, - 'usantiques' => true, - 'usarts' => true, - 'uscountryestate' => true, - 'usculture' => true, - 'usdecorativearts' => true, - 'usgarden' => true, - 'ushistory' => true, - 'ushuaia' => true, - 'uslivinghistory' => true, - 'utah' => true, - 'uvic' => true, - 'valley' => true, - 'vantaa' => true, - 'versailles' => true, - 'viking' => true, - 'village' => true, - 'virginia' => true, - 'virtual' => true, - 'virtuel' => true, - 'vlaanderen' => true, - 'volkenkunde' => true, - 'wales' => true, - 'wallonie' => true, - 'war' => true, - 'washingtondc' => true, - 'watchandclock' => true, - 'watch-and-clock' => true, - 'western' => true, - 'westfalen' => true, - 'whaling' => true, - 'wildlife' => true, - 'williamsburg' => true, - 'windmill' => true, - 'workshop' => true, - 'york' => true, - 'yorkshire' => true, - 'yosemite' => true, - 'youth' => true, - 'zoological' => true, - 'zoology' => true, - 'ירושלים' => true, - 'иком' => true - ), - 'mv' => array( - 'aero' => true, - 'biz' => true, - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'int' => true, - 'mil' => true, - 'museum' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'pro' => true - ), - 'mw' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'int' => true, - 'museum' => true, - 'net' => true, - 'org' => true - ), - 'mx' => array( - 'com' => true, - 'org' => true, - 'gob' => true, - 'edu' => true, - 'net' => true, - 'blogspot' => true - ), - 'my' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'mil' => true, - 'name' => true - ), - 'mz' => array( - '*' => true, - '!teledata' => true - ), - 'na' => array( - 'info' => true, - 'pro' => true, - 'name' => true, - 'school' => true, - 'or' => true, - 'dr' => true, - 'us' => true, - 'mx' => true, - 'ca' => true, - 'in' => true, - 'cc' => true, - 'tv' => true, - 'ws' => true, - 'mobi' => true, - 'co' => true, - 'com' => true, - 'org' => true - ), - 'name' => array( - 'her' => array( - 'forgot' => true - ), - 'his' => array( - 'forgot' => true - ) - ), - 'nc' => array( - 'asso' => true - ), - 'ne' => true, - 'net' => array( - 'cloudfront' => true, - 'gb' => true, - 'hu' => true, - 'jp' => true, - 'se' => true, - 'uk' => true, - 'at-band-camp' => true, - 'blogdns' => true, - 'broke-it' => true, - 'buyshouses' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'does-it' => true, - 'dontexist' => true, - 'dynalias' => true, - 'dynathome' => true, - 'endofinternet' => true, - 'from-az' => true, - 'from-co' => true, - 'from-la' => true, - 'from-ny' => true, - 'gets-it' => true, - 'ham-radio-op' => true, - 'homeftp' => true, - 'homeip' => true, - 'homelinux' => true, - 'homeunix' => true, - 'in-the-band' => true, - 'is-a-chef' => true, - 'is-a-geek' => true, - 'isa-geek' => true, - 'kicks-ass' => true, - 'office-on-the' => true, - 'podzone' => true, - 'scrapper-site' => true, - 'selfip' => true, - 'sells-it' => true, - 'servebbs' => true, - 'serveftp' => true, - 'thruhere' => true, - 'webhop' => true, - 'fastly' => array( - 'ssl' => array( - 'a' => true, - 'b' => true, - 'global' => true - ), - 'prod' => array( - 'a' => true, - 'global' => true - ) - ), - 'za' => true - ), - 'nf' => array( - 'com' => true, - 'net' => true, - 'per' => true, - 'rec' => true, - 'web' => true, - 'arts' => true, - 'firm' => true, - 'info' => true, - 'other' => true, - 'store' => true - ), - 'ng' => array( - 'com' => true, - 'edu' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'gov' => true, - 'mil' => true, - 'mobi' => true - ), - 'ni' => array( - '*' => true - ), - 'nl' => array( - 'bv' => true, - 'co' => true, - 'blogspot' => true - ), - 'no' => array( - 'fhs' => true, - 'vgs' => true, - 'fylkesbibl' => true, - 'folkebibl' => true, - 'museum' => true, - 'idrett' => true, - 'priv' => true, - 'mil' => true, - 'stat' => true, - 'dep' => true, - 'kommune' => true, - 'herad' => true, - 'aa' => array( - 'gs' => true - ), - 'ah' => array( - 'gs' => true - ), - 'bu' => array( - 'gs' => true - ), - 'fm' => array( - 'gs' => true - ), - 'hl' => array( - 'gs' => true - ), - 'hm' => array( - 'gs' => true - ), - 'jan-mayen' => array( - 'gs' => true - ), - 'mr' => array( - 'gs' => true - ), - 'nl' => array( - 'gs' => true - ), - 'nt' => array( - 'gs' => true - ), - 'of' => array( - 'gs' => true - ), - 'ol' => array( - 'gs' => true - ), - 'oslo' => array( - 'gs' => true - ), - 'rl' => array( - 'gs' => true - ), - 'sf' => array( - 'gs' => true - ), - 'st' => array( - 'gs' => true - ), - 'svalbard' => array( - 'gs' => true - ), - 'tm' => array( - 'gs' => true - ), - 'tr' => array( - 'gs' => true - ), - 'va' => array( - 'gs' => true - ), - 'vf' => array( - 'gs' => true - ), - 'akrehamn' => true, - 'åkrehamn' => true, - 'algard' => true, - 'ålgård' => true, - 'arna' => true, - 'brumunddal' => true, - 'bryne' => true, - 'bronnoysund' => true, - 'brønnøysund' => true, - 'drobak' => true, - 'drøbak' => true, - 'egersund' => true, - 'fetsund' => true, - 'floro' => true, - 'florø' => true, - 'fredrikstad' => true, - 'hokksund' => true, - 'honefoss' => true, - 'hønefoss' => true, - 'jessheim' => true, - 'jorpeland' => true, - 'jørpeland' => true, - 'kirkenes' => true, - 'kopervik' => true, - 'krokstadelva' => true, - 'langevag' => true, - 'langevåg' => true, - 'leirvik' => true, - 'mjondalen' => true, - 'mjøndalen' => true, - 'mo-i-rana' => true, - 'mosjoen' => true, - 'mosjøen' => true, - 'nesoddtangen' => true, - 'orkanger' => true, - 'osoyro' => true, - 'osøyro' => true, - 'raholt' => true, - 'råholt' => true, - 'sandnessjoen' => true, - 'sandnessjøen' => true, - 'skedsmokorset' => true, - 'slattum' => true, - 'spjelkavik' => true, - 'stathelle' => true, - 'stavern' => true, - 'stjordalshalsen' => true, - 'stjørdalshalsen' => true, - 'tananger' => true, - 'tranby' => true, - 'vossevangen' => true, - 'afjord' => true, - 'åfjord' => true, - 'agdenes' => true, - 'al' => true, - 'ål' => true, - 'alesund' => true, - 'ålesund' => true, - 'alstahaug' => true, - 'alta' => true, - 'áltá' => true, - 'alaheadju' => true, - 'álaheadju' => true, - 'alvdal' => true, - 'amli' => true, - 'åmli' => true, - 'amot' => true, - 'åmot' => true, - 'andebu' => true, - 'andoy' => true, - 'andøy' => true, - 'andasuolo' => true, - 'ardal' => true, - 'årdal' => true, - 'aremark' => true, - 'arendal' => true, - 'ås' => true, - 'aseral' => true, - 'åseral' => true, - 'asker' => true, - 'askim' => true, - 'askvoll' => true, - 'askoy' => true, - 'askøy' => true, - 'asnes' => true, - 'åsnes' => true, - 'audnedaln' => true, - 'aukra' => true, - 'aure' => true, - 'aurland' => true, - 'aurskog-holand' => true, - 'aurskog-høland' => true, - 'austevoll' => true, - 'austrheim' => true, - 'averoy' => true, - 'averøy' => true, - 'balestrand' => true, - 'ballangen' => true, - 'balat' => true, - 'bálát' => true, - 'balsfjord' => true, - 'bahccavuotna' => true, - 'báhccavuotna' => true, - 'bamble' => true, - 'bardu' => true, - 'beardu' => true, - 'beiarn' => true, - 'bajddar' => true, - 'bájddar' => true, - 'baidar' => true, - 'báidár' => true, - 'berg' => true, - 'bergen' => true, - 'berlevag' => true, - 'berlevåg' => true, - 'bearalvahki' => true, - 'bearalváhki' => true, - 'bindal' => true, - 'birkenes' => true, - 'bjarkoy' => true, - 'bjarkøy' => true, - 'bjerkreim' => true, - 'bjugn' => true, - 'bodo' => true, - 'bodø' => true, - 'badaddja' => true, - 'bådåddjå' => true, - 'budejju' => true, - 'bokn' => true, - 'bremanger' => true, - 'bronnoy' => true, - 'brønnøy' => true, - 'bygland' => true, - 'bykle' => true, - 'barum' => true, - 'bærum' => true, - 'telemark' => array( - 'bo' => true, - 'bø' => true - ), - 'nordland' => array( - 'bo' => true, - 'bø' => true, - 'heroy' => true, - 'herøy' => true - ), - 'bievat' => true, - 'bievát' => true, - 'bomlo' => true, - 'bømlo' => true, - 'batsfjord' => true, - 'båtsfjord' => true, - 'bahcavuotna' => true, - 'báhcavuotna' => true, - 'dovre' => true, - 'drammen' => true, - 'drangedal' => true, - 'dyroy' => true, - 'dyrøy' => true, - 'donna' => true, - 'dønna' => true, - 'eid' => true, - 'eidfjord' => true, - 'eidsberg' => true, - 'eidskog' => true, - 'eidsvoll' => true, - 'eigersund' => true, - 'elverum' => true, - 'enebakk' => true, - 'engerdal' => true, - 'etne' => true, - 'etnedal' => true, - 'evenes' => true, - 'evenassi' => true, - 'evenášši' => true, - 'evje-og-hornnes' => true, - 'farsund' => true, - 'fauske' => true, - 'fuossko' => true, - 'fuoisku' => true, - 'fedje' => true, - 'fet' => true, - 'finnoy' => true, - 'finnøy' => true, - 'fitjar' => true, - 'fjaler' => true, - 'fjell' => true, - 'flakstad' => true, - 'flatanger' => true, - 'flekkefjord' => true, - 'flesberg' => true, - 'flora' => true, - 'fla' => true, - 'flå' => true, - 'folldal' => true, - 'forsand' => true, - 'fosnes' => true, - 'frei' => true, - 'frogn' => true, - 'froland' => true, - 'frosta' => true, - 'frana' => true, - 'fræna' => true, - 'froya' => true, - 'frøya' => true, - 'fusa' => true, - 'fyresdal' => true, - 'forde' => true, - 'førde' => true, - 'gamvik' => true, - 'gangaviika' => true, - 'gáŋgaviika' => true, - 'gaular' => true, - 'gausdal' => true, - 'gildeskal' => true, - 'gildeskål' => true, - 'giske' => true, - 'gjemnes' => true, - 'gjerdrum' => true, - 'gjerstad' => true, - 'gjesdal' => true, - 'gjovik' => true, - 'gjøvik' => true, - 'gloppen' => true, - 'gol' => true, - 'gran' => true, - 'grane' => true, - 'granvin' => true, - 'gratangen' => true, - 'grimstad' => true, - 'grong' => true, - 'kraanghke' => true, - 'kråanghke' => true, - 'grue' => true, - 'gulen' => true, - 'hadsel' => true, - 'halden' => true, - 'halsa' => true, - 'hamar' => true, - 'hamaroy' => true, - 'habmer' => true, - 'hábmer' => true, - 'hapmir' => true, - 'hápmir' => true, - 'hammerfest' => true, - 'hammarfeasta' => true, - 'hámmárfeasta' => true, - 'haram' => true, - 'hareid' => true, - 'harstad' => true, - 'hasvik' => true, - 'aknoluokta' => true, - 'ákŋoluokta' => true, - 'hattfjelldal' => true, - 'aarborte' => true, - 'haugesund' => true, - 'hemne' => true, - 'hemnes' => true, - 'hemsedal' => true, - 'more-og-romsdal' => array( - 'heroy' => true, - 'sande' => true - ), - 'møre-og-romsdal' => array( - 'herøy' => true, - 'sande' => true - ), - 'hitra' => true, - 'hjartdal' => true, - 'hjelmeland' => true, - 'hobol' => true, - 'hobøl' => true, - 'hof' => true, - 'hol' => true, - 'hole' => true, - 'holmestrand' => true, - 'holtalen' => true, - 'holtålen' => true, - 'hornindal' => true, - 'horten' => true, - 'hurdal' => true, - 'hurum' => true, - 'hvaler' => true, - 'hyllestad' => true, - 'hagebostad' => true, - 'hægebostad' => true, - 'hoyanger' => true, - 'høyanger' => true, - 'hoylandet' => true, - 'høylandet' => true, - 'ha' => true, - 'hå' => true, - 'ibestad' => true, - 'inderoy' => true, - 'inderøy' => true, - 'iveland' => true, - 'jevnaker' => true, - 'jondal' => true, - 'jolster' => true, - 'jølster' => true, - 'karasjok' => true, - 'karasjohka' => true, - 'kárášjohka' => true, - 'karlsoy' => true, - 'galsa' => true, - 'gálsá' => true, - 'karmoy' => true, - 'karmøy' => true, - 'kautokeino' => true, - 'guovdageaidnu' => true, - 'klepp' => true, - 'klabu' => true, - 'klæbu' => true, - 'kongsberg' => true, - 'kongsvinger' => true, - 'kragero' => true, - 'kragerø' => true, - 'kristiansand' => true, - 'kristiansund' => true, - 'krodsherad' => true, - 'krødsherad' => true, - 'kvalsund' => true, - 'rahkkeravju' => true, - 'ráhkkerávju' => true, - 'kvam' => true, - 'kvinesdal' => true, - 'kvinnherad' => true, - 'kviteseid' => true, - 'kvitsoy' => true, - 'kvitsøy' => true, - 'kvafjord' => true, - 'kvæfjord' => true, - 'giehtavuoatna' => true, - 'kvanangen' => true, - 'kvænangen' => true, - 'navuotna' => true, - 'návuotna' => true, - 'kafjord' => true, - 'kåfjord' => true, - 'gaivuotna' => true, - 'gáivuotna' => true, - 'larvik' => true, - 'lavangen' => true, - 'lavagis' => true, - 'loabat' => true, - 'loabát' => true, - 'lebesby' => true, - 'davvesiida' => true, - 'leikanger' => true, - 'leirfjord' => true, - 'leka' => true, - 'leksvik' => true, - 'lenvik' => true, - 'leangaviika' => true, - 'leaŋgaviika' => true, - 'lesja' => true, - 'levanger' => true, - 'lier' => true, - 'lierne' => true, - 'lillehammer' => true, - 'lillesand' => true, - 'lindesnes' => true, - 'lindas' => true, - 'lindås' => true, - 'lom' => true, - 'loppa' => true, - 'lahppi' => true, - 'láhppi' => true, - 'lund' => true, - 'lunner' => true, - 'luroy' => true, - 'lurøy' => true, - 'luster' => true, - 'lyngdal' => true, - 'lyngen' => true, - 'ivgu' => true, - 'lardal' => true, - 'lerdal' => true, - 'lærdal' => true, - 'lodingen' => true, - 'lødingen' => true, - 'lorenskog' => true, - 'lørenskog' => true, - 'loten' => true, - 'løten' => true, - 'malvik' => true, - 'masoy' => true, - 'måsøy' => true, - 'muosat' => true, - 'muosát' => true, - 'mandal' => true, - 'marker' => true, - 'marnardal' => true, - 'masfjorden' => true, - 'meland' => true, - 'meldal' => true, - 'melhus' => true, - 'meloy' => true, - 'meløy' => true, - 'meraker' => true, - 'meråker' => true, - 'moareke' => true, - 'moåreke' => true, - 'midsund' => true, - 'midtre-gauldal' => true, - 'modalen' => true, - 'modum' => true, - 'molde' => true, - 'moskenes' => true, - 'moss' => true, - 'mosvik' => true, - 'malselv' => true, - 'målselv' => true, - 'malatvuopmi' => true, - 'málatvuopmi' => true, - 'namdalseid' => true, - 'aejrie' => true, - 'namsos' => true, - 'namsskogan' => true, - 'naamesjevuemie' => true, - 'nååmesjevuemie' => true, - 'laakesvuemie' => true, - 'nannestad' => true, - 'narvik' => true, - 'narviika' => true, - 'naustdal' => true, - 'nedre-eiker' => true, - 'akershus' => array( - 'nes' => true - ), - 'buskerud' => array( - 'nes' => true - ), - 'nesna' => true, - 'nesodden' => true, - 'nesseby' => true, - 'unjarga' => true, - 'unjárga' => true, - 'nesset' => true, - 'nissedal' => true, - 'nittedal' => true, - 'nord-aurdal' => true, - 'nord-fron' => true, - 'nord-odal' => true, - 'norddal' => true, - 'nordkapp' => true, - 'davvenjarga' => true, - 'davvenjárga' => true, - 'nordre-land' => true, - 'nordreisa' => true, - 'raisa' => true, - 'ráisa' => true, - 'nore-og-uvdal' => true, - 'notodden' => true, - 'naroy' => true, - 'nærøy' => true, - 'notteroy' => true, - 'nøtterøy' => true, - 'odda' => true, - 'oksnes' => true, - 'øksnes' => true, - 'oppdal' => true, - 'oppegard' => true, - 'oppegård' => true, - 'orkdal' => true, - 'orland' => true, - 'ørland' => true, - 'orskog' => true, - 'ørskog' => true, - 'orsta' => true, - 'ørsta' => true, - 'hedmark' => array( - 'os' => true, - 'valer' => true, - 'våler' => true - ), - 'hordaland' => array( - 'os' => true - ), - 'osen' => true, - 'osteroy' => true, - 'osterøy' => true, - 'ostre-toten' => true, - 'østre-toten' => true, - 'overhalla' => true, - 'ovre-eiker' => true, - 'øvre-eiker' => true, - 'oyer' => true, - 'øyer' => true, - 'oygarden' => true, - 'øygarden' => true, - 'oystre-slidre' => true, - 'øystre-slidre' => true, - 'porsanger' => true, - 'porsangu' => true, - 'porsáŋgu' => true, - 'porsgrunn' => true, - 'radoy' => true, - 'radøy' => true, - 'rakkestad' => true, - 'rana' => true, - 'ruovat' => true, - 'randaberg' => true, - 'rauma' => true, - 'rendalen' => true, - 'rennebu' => true, - 'rennesoy' => true, - 'rennesøy' => true, - 'rindal' => true, - 'ringebu' => true, - 'ringerike' => true, - 'ringsaker' => true, - 'rissa' => true, - 'risor' => true, - 'risør' => true, - 'roan' => true, - 'rollag' => true, - 'rygge' => true, - 'ralingen' => true, - 'rælingen' => true, - 'rodoy' => true, - 'rødøy' => true, - 'romskog' => true, - 'rømskog' => true, - 'roros' => true, - 'røros' => true, - 'rost' => true, - 'røst' => true, - 'royken' => true, - 'røyken' => true, - 'royrvik' => true, - 'røyrvik' => true, - 'rade' => true, - 'råde' => true, - 'salangen' => true, - 'siellak' => true, - 'saltdal' => true, - 'salat' => true, - 'sálát' => true, - 'sálat' => true, - 'samnanger' => true, - 'vestfold' => array( - 'sande' => true - ), - 'sandefjord' => true, - 'sandnes' => true, - 'sandoy' => true, - 'sandøy' => true, - 'sarpsborg' => true, - 'sauda' => true, - 'sauherad' => true, - 'sel' => true, - 'selbu' => true, - 'selje' => true, - 'seljord' => true, - 'sigdal' => true, - 'siljan' => true, - 'sirdal' => true, - 'skaun' => true, - 'skedsmo' => true, - 'ski' => true, - 'skien' => true, - 'skiptvet' => true, - 'skjervoy' => true, - 'skjervøy' => true, - 'skierva' => true, - 'skiervá' => true, - 'skjak' => true, - 'skjåk' => true, - 'skodje' => true, - 'skanland' => true, - 'skånland' => true, - 'skanit' => true, - 'skánit' => true, - 'smola' => true, - 'smøla' => true, - 'snillfjord' => true, - 'snasa' => true, - 'snåsa' => true, - 'snoasa' => true, - 'snaase' => true, - 'snåase' => true, - 'sogndal' => true, - 'sokndal' => true, - 'sola' => true, - 'solund' => true, - 'songdalen' => true, - 'sortland' => true, - 'spydeberg' => true, - 'stange' => true, - 'stavanger' => true, - 'steigen' => true, - 'steinkjer' => true, - 'stjordal' => true, - 'stjørdal' => true, - 'stokke' => true, - 'stor-elvdal' => true, - 'stord' => true, - 'stordal' => true, - 'storfjord' => true, - 'omasvuotna' => true, - 'strand' => true, - 'stranda' => true, - 'stryn' => true, - 'sula' => true, - 'suldal' => true, - 'sund' => true, - 'sunndal' => true, - 'surnadal' => true, - 'sveio' => true, - 'svelvik' => true, - 'sykkylven' => true, - 'sogne' => true, - 'søgne' => true, - 'somna' => true, - 'sømna' => true, - 'sondre-land' => true, - 'søndre-land' => true, - 'sor-aurdal' => true, - 'sør-aurdal' => true, - 'sor-fron' => true, - 'sør-fron' => true, - 'sor-odal' => true, - 'sør-odal' => true, - 'sor-varanger' => true, - 'sør-varanger' => true, - 'matta-varjjat' => true, - 'mátta-várjjat' => true, - 'sorfold' => true, - 'sørfold' => true, - 'sorreisa' => true, - 'sørreisa' => true, - 'sorum' => true, - 'sørum' => true, - 'tana' => true, - 'deatnu' => true, - 'time' => true, - 'tingvoll' => true, - 'tinn' => true, - 'tjeldsund' => true, - 'dielddanuorri' => true, - 'tjome' => true, - 'tjøme' => true, - 'tokke' => true, - 'tolga' => true, - 'torsken' => true, - 'tranoy' => true, - 'tranøy' => true, - 'tromso' => true, - 'tromsø' => true, - 'tromsa' => true, - 'romsa' => true, - 'trondheim' => true, - 'troandin' => true, - 'trysil' => true, - 'trana' => true, - 'træna' => true, - 'trogstad' => true, - 'trøgstad' => true, - 'tvedestrand' => true, - 'tydal' => true, - 'tynset' => true, - 'tysfjord' => true, - 'divtasvuodna' => true, - 'divttasvuotna' => true, - 'tysnes' => true, - 'tysvar' => true, - 'tysvær' => true, - 'tonsberg' => true, - 'tønsberg' => true, - 'ullensaker' => true, - 'ullensvang' => true, - 'ulvik' => true, - 'utsira' => true, - 'vadso' => true, - 'vadsø' => true, - 'cahcesuolo' => true, - 'čáhcesuolo' => true, - 'vaksdal' => true, - 'valle' => true, - 'vang' => true, - 'vanylven' => true, - 'vardo' => true, - 'vardø' => true, - 'varggat' => true, - 'várggát' => true, - 'vefsn' => true, - 'vaapste' => true, - 'vega' => true, - 'vegarshei' => true, - 'vegårshei' => true, - 'vennesla' => true, - 'verdal' => true, - 'verran' => true, - 'vestby' => true, - 'vestnes' => true, - 'vestre-slidre' => true, - 'vestre-toten' => true, - 'vestvagoy' => true, - 'vestvågøy' => true, - 'vevelstad' => true, - 'vik' => true, - 'vikna' => true, - 'vindafjord' => true, - 'volda' => true, - 'voss' => true, - 'varoy' => true, - 'værøy' => true, - 'vagan' => true, - 'vågan' => true, - 'voagat' => true, - 'vagsoy' => true, - 'vågsøy' => true, - 'vaga' => true, - 'vågå' => true, - 'ostfold' => array( - 'valer' => true - ), - 'østfold' => array( - 'våler' => true - ), - 'co' => true, - 'blogspot' => true - ), - 'np' => array( - '*' => true - ), - 'nr' => array( - 'biz' => true, - 'info' => true, - 'gov' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'com' => true - ), - 'nu' => array( - 'merseine' => true, - 'mine' => true, - 'shacknet' => true - ), - 'nz' => array( - '*' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'om' => array( - 'co' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'med' => true, - 'museum' => true, - 'net' => true, - 'org' => true, - 'pro' => true - ), - 'org' => array( - 'ae' => true, - 'us' => true, - 'dyndns' => array( - 'go' => true, - 'home' => true - ), - 'blogdns' => true, - 'blogsite' => true, - 'boldlygoingnowhere' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'doesntexist' => true, - 'dontexist' => true, - 'doomdns' => true, - 'dvrdns' => true, - 'dynalias' => true, - 'endofinternet' => true, - 'endoftheinternet' => true, - 'from-me' => true, - 'game-host' => true, - 'gotdns' => true, - 'hobby-site' => true, - 'homedns' => true, - 'homeftp' => true, - 'homelinux' => true, - 'homeunix' => true, - 'is-a-bruinsfan' => true, - 'is-a-candidate' => true, - 'is-a-celticsfan' => true, - 'is-a-chef' => true, - 'is-a-geek' => true, - 'is-a-knight' => true, - 'is-a-linux-user' => true, - 'is-a-patsfan' => true, - 'is-a-soxfan' => true, - 'is-found' => true, - 'is-lost' => true, - 'is-saved' => true, - 'is-very-bad' => true, - 'is-very-evil' => true, - 'is-very-good' => true, - 'is-very-nice' => true, - 'is-very-sweet' => true, - 'isa-geek' => true, - 'kicks-ass' => true, - 'misconfused' => true, - 'podzone' => true, - 'readmyblog' => true, - 'selfip' => true, - 'sellsyourhome' => true, - 'servebbs' => true, - 'serveftp' => true, - 'servegame' => true, - 'stuff-4-sale' => true, - 'webhop' => true, - 'za' => true - ), - 'pa' => array( - 'ac' => true, - 'gob' => true, - 'com' => true, - 'org' => true, - 'sld' => true, - 'edu' => true, - 'net' => true, - 'ing' => true, - 'abo' => true, - 'med' => true, - 'nom' => true - ), - 'pe' => array( - 'edu' => true, - 'gob' => true, - 'nom' => true, - 'mil' => true, - 'org' => true, - 'com' => true, - 'net' => true - ), - 'pf' => array( - 'com' => true, - 'org' => true, - 'edu' => true - ), - 'pg' => array( - '*' => true - ), - 'ph' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'ngo' => true, - 'mil' => true, - 'i' => true - ), - 'pk' => array( - 'com' => true, - 'net' => true, - 'edu' => true, - 'org' => true, - 'fam' => true, - 'biz' => true, - 'web' => true, - 'gov' => true, - 'gob' => true, - 'gok' => true, - 'gon' => true, - 'gop' => true, - 'gos' => true, - 'info' => true - ), - 'pl' => array( - 'aid' => true, - 'agro' => true, - 'atm' => true, - 'auto' => true, - 'biz' => true, - 'com' => true, - 'edu' => true, - 'gmina' => true, - 'gsm' => true, - 'info' => true, - 'mail' => true, - 'miasta' => true, - 'media' => true, - 'mil' => true, - 'net' => true, - 'nieruchomosci' => true, - 'nom' => true, - 'org' => true, - 'pc' => true, - 'powiat' => true, - 'priv' => true, - 'realestate' => true, - 'rel' => true, - 'sex' => true, - 'shop' => true, - 'sklep' => true, - 'sos' => true, - 'szkola' => true, - 'targi' => true, - 'tm' => true, - 'tourism' => true, - 'travel' => true, - 'turystyka' => true, - '6bone' => true, - 'art' => true, - 'mbone' => true, - 'gov' => array( - 'uw' => true, - 'um' => true, - 'ug' => true, - 'upow' => true, - 'starostwo' => true, - 'so' => true, - 'sr' => true, - 'po' => true, - 'pa' => true - ), - 'ngo' => true, - 'irc' => true, - 'usenet' => true, - 'augustow' => true, - 'babia-gora' => true, - 'bedzin' => true, - 'beskidy' => true, - 'bialowieza' => true, - 'bialystok' => true, - 'bielawa' => true, - 'bieszczady' => true, - 'boleslawiec' => true, - 'bydgoszcz' => true, - 'bytom' => true, - 'cieszyn' => true, - 'czeladz' => true, - 'czest' => true, - 'dlugoleka' => true, - 'elblag' => true, - 'elk' => true, - 'glogow' => true, - 'gniezno' => true, - 'gorlice' => true, - 'grajewo' => true, - 'ilawa' => true, - 'jaworzno' => true, - 'jelenia-gora' => true, - 'jgora' => true, - 'kalisz' => true, - 'kazimierz-dolny' => true, - 'karpacz' => true, - 'kartuzy' => true, - 'kaszuby' => true, - 'katowice' => true, - 'kepno' => true, - 'ketrzyn' => true, - 'klodzko' => true, - 'kobierzyce' => true, - 'kolobrzeg' => true, - 'konin' => true, - 'konskowola' => true, - 'kutno' => true, - 'lapy' => true, - 'lebork' => true, - 'legnica' => true, - 'lezajsk' => true, - 'limanowa' => true, - 'lomza' => true, - 'lowicz' => true, - 'lubin' => true, - 'lukow' => true, - 'malbork' => true, - 'malopolska' => true, - 'mazowsze' => true, - 'mazury' => true, - 'mielec' => true, - 'mielno' => true, - 'mragowo' => true, - 'naklo' => true, - 'nowaruda' => true, - 'nysa' => true, - 'olawa' => true, - 'olecko' => true, - 'olkusz' => true, - 'olsztyn' => true, - 'opoczno' => true, - 'opole' => true, - 'ostroda' => true, - 'ostroleka' => true, - 'ostrowiec' => true, - 'ostrowwlkp' => true, - 'pila' => true, - 'pisz' => true, - 'podhale' => true, - 'podlasie' => true, - 'polkowice' => true, - 'pomorze' => true, - 'pomorskie' => true, - 'prochowice' => true, - 'pruszkow' => true, - 'przeworsk' => true, - 'pulawy' => true, - 'radom' => true, - 'rawa-maz' => true, - 'rybnik' => true, - 'rzeszow' => true, - 'sanok' => true, - 'sejny' => true, - 'siedlce' => true, - 'slask' => true, - 'slupsk' => true, - 'sosnowiec' => true, - 'stalowa-wola' => true, - 'skoczow' => true, - 'starachowice' => true, - 'stargard' => true, - 'suwalki' => true, - 'swidnica' => true, - 'swiebodzin' => true, - 'swinoujscie' => true, - 'szczecin' => true, - 'szczytno' => true, - 'tarnobrzeg' => true, - 'tgory' => true, - 'turek' => true, - 'tychy' => true, - 'ustka' => true, - 'walbrzych' => true, - 'warmia' => true, - 'warszawa' => true, - 'waw' => true, - 'wegrow' => true, - 'wielun' => true, - 'wlocl' => true, - 'wloclawek' => true, - 'wodzislaw' => true, - 'wolomin' => true, - 'wroclaw' => true, - 'zachpomor' => true, - 'zagan' => true, - 'zarow' => true, - 'zgora' => true, - 'zgorzelec' => true, - 'gda' => true, - 'gdansk' => true, - 'gdynia' => true, - 'med' => true, - 'sopot' => true, - 'gliwice' => true, - 'krakow' => true, - 'poznan' => true, - 'wroc' => true, - 'zakopane' => true, - 'co' => true - ), - 'pm' => true, - 'pn' => array( - 'gov' => true, - 'co' => true, - 'org' => true, - 'edu' => true, - 'net' => true - ), - 'post' => true, - 'pr' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'isla' => true, - 'pro' => true, - 'biz' => true, - 'info' => true, - 'name' => true, - 'est' => true, - 'prof' => true, - 'ac' => true - ), - 'pro' => array( - 'aca' => true, - 'bar' => true, - 'cpa' => true, - 'jur' => true, - 'law' => true, - 'med' => true, - 'eng' => true - ), - 'ps' => array( - 'edu' => true, - 'gov' => true, - 'sec' => true, - 'plo' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'pt' => array( - 'net' => true, - 'gov' => true, - 'org' => true, - 'edu' => true, - 'int' => true, - 'publ' => true, - 'com' => true, - 'nome' => true, - 'blogspot' => true - ), - 'pw' => array( - 'co' => true, - 'ne' => true, - 'or' => true, - 'ed' => true, - 'go' => true, - 'belau' => true - ), - 'py' => array( - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'qa' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sch' => true - ), - 're' => array( - 'com' => true, - 'asso' => true, - 'nom' => true, - 'blogspot' => true - ), - 'ro' => array( - 'com' => true, - 'org' => true, - 'tm' => true, - 'nt' => true, - 'nom' => true, - 'info' => true, - 'rec' => true, - 'arts' => true, - 'firm' => true, - 'store' => true, - 'www' => true, - 'blogspot' => true - ), - 'rs' => array( - 'co' => true, - 'org' => true, - 'edu' => true, - 'ac' => true, - 'gov' => true, - 'in' => true - ), - 'ru' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'int' => true, - 'net' => true, - 'org' => true, - 'pp' => true, - 'adygeya' => true, - 'altai' => true, - 'amur' => true, - 'arkhangelsk' => true, - 'astrakhan' => true, - 'bashkiria' => true, - 'belgorod' => true, - 'bir' => true, - 'bryansk' => true, - 'buryatia' => true, - 'cbg' => true, - 'chel' => true, - 'chelyabinsk' => true, - 'chita' => true, - 'chukotka' => true, - 'chuvashia' => true, - 'dagestan' => true, - 'dudinka' => true, - 'e-burg' => true, - 'grozny' => true, - 'irkutsk' => true, - 'ivanovo' => true, - 'izhevsk' => true, - 'jar' => true, - 'joshkar-ola' => true, - 'kalmykia' => true, - 'kaluga' => true, - 'kamchatka' => true, - 'karelia' => true, - 'kazan' => true, - 'kchr' => true, - 'kemerovo' => true, - 'khabarovsk' => true, - 'khakassia' => true, - 'khv' => true, - 'kirov' => true, - 'koenig' => true, - 'komi' => true, - 'kostroma' => true, - 'krasnoyarsk' => true, - 'kuban' => true, - 'kurgan' => true, - 'kursk' => true, - 'lipetsk' => true, - 'magadan' => true, - 'mari' => true, - 'mari-el' => true, - 'marine' => true, - 'mordovia' => true, - 'mosreg' => true, - 'msk' => true, - 'murmansk' => true, - 'nalchik' => true, - 'nnov' => true, - 'nov' => true, - 'novosibirsk' => true, - 'nsk' => true, - 'omsk' => true, - 'orenburg' => true, - 'oryol' => true, - 'palana' => true, - 'penza' => true, - 'perm' => true, - 'pskov' => true, - 'ptz' => true, - 'rnd' => true, - 'ryazan' => true, - 'sakhalin' => true, - 'samara' => true, - 'saratov' => true, - 'simbirsk' => true, - 'smolensk' => true, - 'spb' => true, - 'stavropol' => true, - 'stv' => true, - 'surgut' => true, - 'tambov' => true, - 'tatarstan' => true, - 'tom' => true, - 'tomsk' => true, - 'tsaritsyn' => true, - 'tsk' => true, - 'tula' => true, - 'tuva' => true, - 'tver' => true, - 'tyumen' => true, - 'udm' => true, - 'udmurtia' => true, - 'ulan-ude' => true, - 'vladikavkaz' => true, - 'vladimir' => true, - 'vladivostok' => true, - 'volgograd' => true, - 'vologda' => true, - 'voronezh' => true, - 'vrn' => true, - 'vyatka' => true, - 'yakutia' => true, - 'yamal' => true, - 'yaroslavl' => true, - 'yekaterinburg' => true, - 'yuzhno-sakhalinsk' => true, - 'amursk' => true, - 'baikal' => true, - 'cmw' => true, - 'fareast' => true, - 'jamal' => true, - 'kms' => true, - 'k-uralsk' => true, - 'kustanai' => true, - 'kuzbass' => true, - 'magnitka' => true, - 'mytis' => true, - 'nakhodka' => true, - 'nkz' => true, - 'norilsk' => true, - 'oskol' => true, - 'pyatigorsk' => true, - 'rubtsovsk' => true, - 'snz' => true, - 'syzran' => true, - 'vdonsk' => true, - 'zgrad' => true, - 'gov' => true, - 'mil' => true, - 'test' => true - ), - 'rw' => array( - 'gov' => true, - 'net' => true, - 'edu' => true, - 'ac' => true, - 'com' => true, - 'co' => true, - 'int' => true, - 'mil' => true, - 'gouv' => true - ), - 'sa' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'med' => true, - 'pub' => true, - 'edu' => true, - 'sch' => true - ), - 'sb' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'sc' => array( - 'com' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'edu' => true - ), - 'sd' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'med' => true, - 'tv' => true, - 'gov' => true, - 'info' => true - ), - 'se' => array( - 'a' => true, - 'ac' => true, - 'b' => true, - 'bd' => true, - 'brand' => true, - 'c' => true, - 'd' => true, - 'e' => true, - 'f' => true, - 'fh' => true, - 'fhsk' => true, - 'fhv' => true, - 'g' => true, - 'h' => true, - 'i' => true, - 'k' => true, - 'komforb' => true, - 'kommunalforbund' => true, - 'komvux' => true, - 'l' => true, - 'lanbib' => true, - 'm' => true, - 'n' => true, - 'naturbruksgymn' => true, - 'o' => true, - 'org' => true, - 'p' => true, - 'parti' => true, - 'pp' => true, - 'press' => true, - 'r' => true, - 's' => true, - 'sshn' => true, - 't' => true, - 'tm' => true, - 'u' => true, - 'w' => true, - 'x' => true, - 'y' => true, - 'z' => true, - 'blogspot' => true - ), - 'sg' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'per' => true, - 'blogspot' => true - ), - 'sh' => array( - 'com' => true, - 'net' => true, - 'gov' => true, - 'org' => true, - 'mil' => true - ), - 'si' => true, - 'sj' => true, - 'sk' => array( - 'blogspot' => true - ), - 'sl' => array( - 'com' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'org' => true - ), - 'sm' => true, - 'sn' => array( - 'art' => true, - 'com' => true, - 'edu' => true, - 'gouv' => true, - 'org' => true, - 'perso' => true, - 'univ' => true - ), - 'so' => array( - 'com' => true, - 'net' => true, - 'org' => true - ), - 'sr' => true, - 'st' => array( - 'co' => true, - 'com' => true, - 'consulado' => true, - 'edu' => true, - 'embaixada' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'principe' => true, - 'saotome' => true, - 'store' => true - ), - 'su' => true, - 'sv' => array( - 'com' => true, - 'edu' => true, - 'gob' => true, - 'org' => true, - 'red' => true - ), - 'sx' => array( - 'gov' => true - ), - 'sy' => array( - 'edu' => true, - 'gov' => true, - 'net' => true, - 'mil' => true, - 'com' => true, - 'org' => true - ), - 'sz' => array( - 'co' => true, - 'ac' => true, - 'org' => true - ), - 'tc' => true, - 'td' => array( - 'blogspot' => true - ), - 'tel' => true, - 'tf' => true, - 'tg' => true, - 'th' => array( - 'ac' => true, - 'co' => true, - 'go' => true, - 'in' => true, - 'mi' => true, - 'net' => true, - 'or' => true - ), - 'tj' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'com' => true, - 'edu' => true, - 'go' => true, - 'gov' => true, - 'int' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'nic' => true, - 'org' => true, - 'test' => true, - 'web' => true - ), - 'tk' => true, - 'tl' => array( - 'gov' => true - ), - 'tm' => array( - 'com' => true, - 'co' => true, - 'org' => true, - 'net' => true, - 'nom' => true, - 'gov' => true, - 'mil' => true, - 'edu' => true - ), - 'tn' => array( - 'com' => true, - 'ens' => true, - 'fin' => true, - 'gov' => true, - 'ind' => true, - 'intl' => true, - 'nat' => true, - 'net' => true, - 'org' => true, - 'info' => true, - 'perso' => true, - 'tourism' => true, - 'edunet' => true, - 'rnrt' => true, - 'rns' => true, - 'rnu' => true, - 'mincom' => true, - 'agrinet' => true, - 'defense' => true, - 'turen' => true - ), - 'to' => array( - 'com' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'mil' => true - ), - 'tp' => true, - 'tr' => array( - '*' => true, - '!nic' => true, - 'nc' => array( - 'gov' => true - ) - ), - 'travel' => true, - 'tt' => array( - 'co' => true, - 'com' => true, - 'org' => true, - 'net' => true, - 'biz' => true, - 'info' => true, - 'pro' => true, - 'int' => true, - 'coop' => true, - 'jobs' => true, - 'mobi' => true, - 'travel' => true, - 'museum' => true, - 'aero' => true, - 'name' => true, - 'gov' => true, - 'edu' => true - ), - 'tv' => array( - 'dyndns' => true, - 'better-than' => true, - 'on-the-web' => true, - 'worse-than' => true - ), - 'tw' => array( - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'com' => true, - 'net' => true, - 'org' => true, - 'idv' => true, - 'game' => true, - 'ebiz' => true, - 'club' => true, - '網路' => true, - '組織' => true, - '商業' => true, - 'blogspot' => true - ), - 'tz' => array( - 'ac' => true, - 'co' => true, - 'go' => true, - 'hotel' => true, - 'info' => true, - 'me' => true, - 'mil' => true, - 'mobi' => true, - 'ne' => true, - 'or' => true, - 'sc' => true, - 'tv' => true - ), - 'ua' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'in' => true, - 'net' => true, - 'org' => true, - 'cherkassy' => true, - 'cherkasy' => true, - 'chernigov' => true, - 'chernihiv' => true, - 'chernivtsi' => true, - 'chernovtsy' => true, - 'ck' => true, - 'cn' => true, - 'cr' => true, - 'crimea' => true, - 'cv' => true, - 'dn' => true, - 'dnepropetrovsk' => true, - 'dnipropetrovsk' => true, - 'dominic' => true, - 'donetsk' => true, - 'dp' => true, - 'if' => true, - 'ivano-frankivsk' => true, - 'kh' => true, - 'kharkiv' => true, - 'kharkov' => true, - 'kherson' => true, - 'khmelnitskiy' => true, - 'khmelnytskyi' => true, - 'kiev' => true, - 'kirovograd' => true, - 'km' => true, - 'kr' => true, - 'krym' => true, - 'ks' => true, - 'kv' => true, - 'kyiv' => true, - 'lg' => true, - 'lt' => true, - 'lugansk' => true, - 'lutsk' => true, - 'lv' => true, - 'lviv' => true, - 'mk' => true, - 'mykolaiv' => true, - 'nikolaev' => true, - 'od' => true, - 'odesa' => true, - 'odessa' => true, - 'pl' => true, - 'poltava' => true, - 'rivne' => true, - 'rovno' => true, - 'rv' => true, - 'sb' => true, - 'sebastopol' => true, - 'sevastopol' => true, - 'sm' => true, - 'sumy' => true, - 'te' => true, - 'ternopil' => true, - 'uz' => true, - 'uzhgorod' => true, - 'vinnica' => true, - 'vinnytsia' => true, - 'vn' => true, - 'volyn' => true, - 'yalta' => true, - 'zaporizhzhe' => true, - 'zaporizhzhia' => true, - 'zhitomir' => true, - 'zhytomyr' => true, - 'zp' => true, - 'zt' => true, - 'co' => true, - 'pp' => true - ), - 'ug' => array( - 'co' => true, - 'or' => true, - 'ac' => true, - 'sc' => true, - 'go' => true, - 'ne' => true, - 'com' => true, - 'org' => true - ), - 'uk' => array( - '*' => true, - 'sch' => array( - '*' => true - ), - '!bl' => true, - '!british-library' => true, - '!jet' => true, - '!mod' => true, - '!national-library-scotland' => true, - '!nel' => true, - '!nic' => true, - '!nls' => true, - '!parliament' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'us' => array( - 'dni' => true, - 'fed' => true, - 'isa' => true, - 'kids' => true, - 'nsn' => true, - 'ak' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'al' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ar' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'as' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'az' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ca' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'co' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ct' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'dc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'de' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'fl' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ga' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'gu' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'hi' => array( - 'cc' => true, - 'lib' => true - ), - 'ia' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'id' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'il' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'in' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ks' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ky' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'la' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ma' => array( - 'k12' => array( - 'pvt' => true, - 'chtr' => true, - 'paroch' => true - ), - 'cc' => true, - 'lib' => true - ), - 'md' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'me' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mn' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mo' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ms' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mt' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nd' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ne' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nh' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nj' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nm' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nv' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ny' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'oh' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ok' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'or' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'pa' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'pr' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ri' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'sc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'sd' => array( - 'cc' => true, - 'lib' => true - ), - 'tn' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'tx' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ut' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'vi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'vt' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'va' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wa' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wv' => array( - 'cc' => true - ), - 'wy' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'is-by' => true, - 'land-4-sale' => true, - 'stuff-4-sale' => true - ), - 'uy' => array( - 'com' => true, - 'edu' => true, - 'gub' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'uz' => array( - 'co' => true, - 'com' => true, - 'net' => true, - 'org' => true - ), - 'va' => true, - 'vc' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'mil' => true, - 'edu' => true - ), - 've' => array( - 'co' => true, - 'com' => true, - 'e12' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'web' => true - ), - 'vg' => true, - 'vi' => array( - 'co' => true, - 'com' => true, - 'k12' => true, - 'net' => true, - 'org' => true - ), - 'vn' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true, - 'int' => true, - 'ac' => true, - 'biz' => true, - 'info' => true, - 'name' => true, - 'pro' => true, - 'health' => true - ), - 'vu' => true, - 'wf' => true, - 'ws' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'dyndns' => true, - 'mypets' => true - ), - 'yt' => true, - 'امارات' => true, - 'বাংলা' => true, - '中国' => true, - '中國' => true, - 'الجزائر' => true, - 'مصر' => true, - 'გე' => true, - '香港' => true, - 'भारत' => true, - 'بھارت' => true, - 'భారత్' => true, - 'ભારત' => true, - 'ਭਾਰਤ' => true, - 'ভারত' => true, - 'இந்தியா' => true, - 'ایران' => true, - 'ايران' => true, - 'الاردن' => true, - '한국' => true, - 'қаз' => true, - 'ලංකා' => true, - 'இலங்கை' => true, - 'المغرب' => true, - 'мон' => true, - 'مليسيا' => true, - 'عمان' => true, - 'فلسطين' => true, - 'срб' => true, - 'рф' => true, - 'قطر' => true, - 'السعودية' => true, - 'السعودیة' => true, - 'السعودیۃ' => true, - 'السعوديه' => true, - 'سورية' => true, - 'سوريا' => true, - '新加坡' => true, - 'சிங்கப்பூர்' => true, - 'ไทย' => true, - 'تونس' => true, - '台灣' => true, - '台湾' => true, - '臺灣' => true, - 'укр' => true, - 'اليمن' => true, - 'xxx' => true, - 'ye' => array( - '*' => true - ), - 'za' => array( - '*' => true - ), - 'zm' => array( - '*' => true - ), - 'zw' => array( - '*' => true - ), - 'онлайн' => true, - 'сайт' => true, - 'شبكة' => true, - '游戏' => true, - '企业' => true, - 'camera' => true, - 'clothing' => true, - 'lighting' => true, - 'singles' => true, - 'ventures' => true, - 'voyage' => true, - 'guru' => true, - 'holdings' => true, - 'equipment' => true, - 'bike' => true, - 'estate' => true, - 'tattoo' => true, - '在线' => true, - '中文网' => true, - 'land' => true, - 'plumbing' => true, - 'contractors' => true, - 'sexy' => true, - 'menu' => true, - '世界' => true, - 'uno' => true, - 'gallery' => true, - 'technology' => true, - '集团' => true, - 'reviews' => true, - 'guide' => true, - '我爱你' => true, - 'graphics' => true, - 'construction' => true, - 'onl' => true, - 'みんな' => true, - 'diamonds' => true, - 'kiwi' => true, - 'enterprises' => true, - 'today' => true, - 'futbol' => true, - 'photography' => true, - 'tips' => true, - 'directory' => true, - 'kitchen' => true, - '移动' => true, - 'kim' => true, - '삼성' => true, - 'monash' => true, - 'wed' => true, - 'pink' => true, - 'ruhr' => true, - 'buzz' => true, - 'careers' => true, - 'shoes' => true, - 'موقع' => true, - 'career' => true, - 'otsuka' => true, - '中信' => true, - 'gift' => true, - 'recipes' => true, - 'coffee' => true, - 'luxury' => true, - 'domains' => true, - 'photos' => true, - 'limo' => true, - 'viajes' => true, - 'wang' => true, - 'democrat' => true, - 'mango' => true, - 'cab' => true, - 'support' => true, - 'dance' => true, - 'nagoya' => true, - 'computer' => true, - 'wien' => true, - 'berlin' => true, - 'codes' => true, - 'email' => true, - 'بازار' => true, - 'repair' => true, - 'holiday' => true, - 'center' => true, - 'systems' => true, - 'wiki' => true, - 'ceo' => true, - 'international' => true, - 'solar' => true, - 'company' => true, - 'education' => true, - 'training' => true, - 'academy' => true, - 'marketing' => true, - 'florist' => true, - 'solutions' => true, - 'build' => true, - 'institute' => true, - 'builders' => true, - 'red' => true, - 'blue' => true, - 'ninja' => true, - 'business' => true, - 'gal' => true, - 'social' => true, - 'house' => true, - 'camp' => true, - 'immobilien' => true, - 'moda' => true, - 'glass' => true, - 'management' => true, - 'kaufen' => true, - 'farm' => true, - '公益' => true, - '政务' => true, - 'club' => true, - 'voting' => true, - 'TOKYO' => true, - 'moe' => true -); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/docs/LICENSE b/vendor/pear/http_request2/docs/LICENSE deleted file mode 100644 index fe4ae1a47..000000000 --- a/vendor/pear/http_request2/docs/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -HTTP_Request2 - -Copyright (c) 2008-2014, Alexey Borzov -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Alexey Borzov nor the names of his contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/http_request2/docs/examples/upload-rapidshare.php b/vendor/pear/http_request2/docs/examples/upload-rapidshare.php deleted file mode 100644 index 8773d1597..000000000 --- a/vendor/pear/http_request2/docs/examples/upload-rapidshare.php +++ /dev/null @@ -1,58 +0,0 @@ -send()->getBody(); - if (!preg_match('/^(\\d+)$/', $server)) { - throw new Exception("Invalid upload server: {$server}"); - } - - // Calculate file hash, we'll use it later to check upload - if (false === ($hash = @md5_file($filename))) { - throw new Exception("Cannot calculate MD5 hash of '{$filename}'"); - } - - // Second step: upload a file to the available server - $uploader = new HTTP_Request2( - "http://rs{$server}l3.rapidshare.com/cgi-bin/upload.cgi", - HTTP_Request2::METHOD_POST - ); - // Adding the file - $uploader->addUpload('filecontent', $filename); - // This will tell server to return program-friendly output - $uploader->addPostParameter('rsapi_v1', '1'); - - $response = $uploader->send()->getBody(); - if (!preg_match_all('/^(File[^=]+)=(.+)$/m', $response, $m, PREG_SET_ORDER)) { - throw new Exception("Invalid response: {$response}"); - } - $rspAry = array(); - foreach ($m as $item) { - $rspAry[$item[1]] = $item[2]; - } - // Check that uploaded file has the same hash - if (empty($rspAry['File1.4'])) { - throw new Exception("MD5 hash data not found in response"); - } elseif ($hash != strtolower($rspAry['File1.4'])) { - throw new Exception("Upload failed, local MD5 is {$hash}, uploaded MD5 is {$rspAry['File1.4']}"); - } - echo "Upload succeeded\nDownload link: {$rspAry['File1.1']}\nDelete link: {$rspAry['File1.2']}\n"; - -} catch (Exception $e) { - echo "Error: " . $e->getMessage(); -} -?> diff --git a/vendor/pear/http_request2/package.xml b/vendor/pear/http_request2/package.xml deleted file mode 100644 index b648a16f8..000000000 --- a/vendor/pear/http_request2/package.xml +++ /dev/null @@ -1,646 +0,0 @@ - - - - HTTP_Request2 - pear.php.net - HTTP_Request - Provides an easy way to perform HTTP requests. - -PHP5 rewrite of HTTP_Request package (with parts of HTTP_Client). Provides -cleaner API and pluggable Adapters: - * Socket adapter, based on old HTTP_Request code, - * Curl adapter, wraps around PHP's cURL extension, - * Mock adapter, to use for testing packages dependent on HTTP_Request2. -Supports POST requests with data and file uploads, basic and digest -authentication, cookies, managing cookies across requests, proxies, gzip and -deflate encodings, redirects, monitoring the request progress with Observers... - - - Alexey Borzov - avb - avb@php.net - yes - - 2014-01-16 - - 2.2.1 - 2.2.0 - - - stable - stable - - BSD 3-Clause License - - * Fixed a bogus timeout Exception in Socket adapter after waiting for - "100 Continue" response: the same one second timeout was used - for further socket operations if explicit 'timeout' parameter was not set. - Thanks to Andrea Brancatelli (abrancatelli as schema31 dot it) for the report. - * Bundled a separate LICENSE file (request #20175). Updated phrasing and links - to mention 3-Clause BSD license the package actually uses. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.2.0 - - - 1.9.2 - - - Net_URL2 - pear.php.net - 2.0.0 - - - PEAR - pear.php.net - 1.9.2 - - - - - curl - - - fileinfo - - - zlib - - - openssl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2014-01-12 - - 2.2.0 - 2.2.0 - - - stable - stable - - BSD License - -New features - * Socket adapter will send "Expect: 100-continue" header and wait for - "100 Continue" response by default before sending large request body - (request #19233). This can be disabled by setting an empty "Expect" - header, the same way as done with Curl adapter (see bug #15937) - * It is possible to specify a local IP address to bind to using 'local_ip' - configuration parameter (request #19515) - -Other changes and fixes - * An infinite loop was possible when using a stream wrapper instead of - a regular file with MultipartBody (bug #19934) - * Socket adapter will properly send chunked request body if - "Transfer-Encoding: chunked" header is set for the request (bug #20125) - * Updated Public Suffix List to the latest version and updated its download script - * Unit tests fixes - - - - 2012-04-08 - - 2.1.1 - 2.1.0 - - - stable - stable - - BSD License - -Fixes for SOCKS5 proxies support in Socket adapter - - - - 2012-04-07 - - 2.1.0 - 2.1.0 - - - stable - stable - - BSD License - -New features: - * Mock adapter can return responses based on request URL (request #19276) - * Support for SOCKS5 proxies, added 'proxy_type' configuration parameter - (request #19332) - * Proxy configuration may be given as an URL, e.g. - $request->setConfig('proxy', 'socks5://localhost:1080'); - -Other changes and fixes: - * Coding standards fixes (request #14990) - * Unit tests now run from SVN checkout and under PHPUnit 3.6.x - * Explicit dependency on PEAR (until PEAR_Exception is a separate package) - * Get rid of track_errors, use a more robust solution (bug #19337) - * Additional class_exists() check in setAdapter() (request #19344) - * Public suffix list updated to current version - - - - 2011-10-20 - - 2.0.0 - 2.0.0 - - - stable - stable - - BSD License - -2.0.0RC2 repackaged as stable and depending on stable Net_URL2. No code changes. - - - - 2011-10-01 - - 2.0.0RC2 - 2.0.0 - - - beta - stable - - BSD License - - * Added an accessor method for HTTP_Request2_Response::$phrases (request #18716) - * HTTP_Request2::send() throws an exception if URL is not provided - rather than dies with a fatal error (bug #18755) - * Public Suffix List updated to current version - - - - 2011-05-06 - - 2.0.0RC1 - 2.0.0 - - - beta - stable - - BSD License - -SSL options for Curl Adapter are always set, this prevents errors when -redirecting from HTTP to HTTPS (bug #18443) - - - - - 2.0.0beta3 - 2.0.0 - - - beta - beta - - 2011-04-03 - BSD License - - * Added getEffectiveUrl() method to Response object, it returns the URL - response was received from, possibly after redirects (request #18412) - * Curl Adapter didn't send body for PUT requests sometimes (bug #18421) - - - - - 2.0.0beta2 - 2.0.0 - - - beta - beta - - 2011-03-25 - BSD License - - * Unit tests can now be run under recent PHPUnit versions (3.5+) - * Public Suffix List updated to current version - * PHP warning produced by stream_socket_client() in Socket adapter is now - added to Exception message (bug #18331) - - - - - 2.0.0beta1 - 2.0.0 - - - beta - beta - - 2011-02-27 - BSD License - -Additions and changes: - * Implemented cookie jar that allows to store and pass cookies across HTTP - requests (see request #18225) - * Added several specialized subclasses of HTTP_Request2_Exception, they are - now thrown instead of the parent. Also added error codes and possibility - to get native error code (as returned by stream_socket_client() and - curl_errno()) (request #16762) - * An additional 'sentBody' event is now sent to Observers (request #16828) - * setBody() and addUpload() can now accept file pointers (request #16863) - -Bugfixes: - * Incorrect check in Socket Adapter prevented Keep-alive from working in - some cases (bug #17031) - - - - - 0.6.0 - 0.6.0 - - - alpha - alpha - - 2011-02-14 - BSD License - -Additions and changes: - * Added test suite that interacts with a webserver. Please refer to - tests/NetworkConfig.php.dist for instructions. - * Packaging changes: docs/ and tests/ contents are installed without - redundant subdirectories. - * Added a $replace parameter to HTTP_Request2::setHeader() that controls - whether new header value will overwrite previous one or be appended - to it (request #17507) - -Bugfixes: - * Fixed a typo in Curl Adapter that prevented 'strict_redirects' from working - * Curl Adapter will throw an exception if CURLOPT_FOLLOWLOCATION can not be - enabled due to PHP setup (bug #17450) - * Allow parameters in manually set Content-Type headers (bug #17460) - * Properly reset redirect limit if multiple requests are performed with the - same instance of Socket Adapter (bug #17826) - * Response::getBody() no longer tries to decode empty strings (bug #18169) - - - - - 0.5.2 - 0.5.0 - - - alpha - alpha - - 2010-04-21 - BSD License - - * magic_quotes_runtime PHP setting could be incorrectly enabled after - performing the request (bug #16440) - * Unit tests fixes (bugs #17079, #17106, #17326) - * Observer_Log now appends to the log file rather than rewrites it (thanks to - troelskn at gmail dot com for reporting) - - - - - 0.5.1 - 0.5.0 - - - alpha - alpha - - 2009-11-21 - BSD License - - * Content-Type request header is no longer removed for POST and PUT requests - with empty request body (request #16799). - * CURLOPT_NOBODY option is now set when doing HEAD requests with Curl adapter. - - - - - 0.5.0 - 0.5.0 - - - alpha - alpha - - 2009-11-18 - BSD License - - * Redirect support added, new configuration parameters 'follow_redirects', - 'max_redirects' and 'strict_redirects' available - - * Implemented workaround for PHP bug #47204, Curl Adapter can now handle - Digest authentication and redirects when doing POST requests, unfortunately - this requires loading the entire request body into memory. - * Config parameter 'use_brackets' is propagated to created instances of Net_URL2 - * Prevent memory leaks due to circular references (request #16646) - * Fixed a misleading error message when timing out due to default_socket_timeout - * HTTP_Request2::setBody() can now accept an instance of HTTP_Request2_MultipartBody - without trying to convert it to string - * Calling HTTP_Request2::setBody() now clears post parameters and uploads - - - - - 0.4.1 - 0.4.0 - - - alpha - alpha - - 2009-09-14 - BSD License - - * Decoding of gzipped responses failed if mbstring.func_overload was enabled - (bug #16555) - * Changed boundary generation in multipart bodies to work correctly with - rapidshare.com, added first usage example: file uploading to rapidshare.com - * Added forgotten optional dependency on OpenSSL PHP extension - - - - - 0.4.0 - 0.4.0 - - - alpha - alpha - - 2009-05-03 - BSD License - - * Added 'store_body' config parameter, if set to false it will prevent storing - the response body in Response object (request #15881) - * HTTP_Request2::setHeader() method now works as documented, setHeader('name') - will remove the 'name' header, while setHeader('name', '') will set 'name' - header to empty value (bug #15937) - * Custom 'Host' header will not be overwritten by generated one (bug #16146) - * When trying to reuse the connected socket in Socket adapter, make sure that - it is still connected (bug #16149) - - - - - 0.3.0 - 0.3.0 - - - alpha - alpha - - 2009-01-28 - BSD License - - API changes: - * Removed HTTP_Request2::getConfigValue() method - - Feature additions: - * Added digest authentication (RFC 2617) support to Socket adapter. Thanks - to Tom Snyder (tomsn at inetoffice dot com) who sent me a prototype - implementation for HTTP_Request a couple of years ago. - * Added HTTPS proxy support to Socket adapter, this works through CONNECT - request described in RFC 2817. - * Mock adapter can now throw an Exception instead of returning a response - if Exception object is added via its addResponse() method (request #15629) - - Other changes and fixes: - * Support RFC 3986 by not encoding '~' in POST body (request #15368) - * Prevent an error with particular versions of PHP and Curl (bug #15617) - * Regular expressions used in HTTP_Request2 are now class constants - (request #15630) - * Curl adapter now throws an exception in case of malformed (non-HTTP) - response rather than dies with a fatal error (bug #15716) - * Curl handle wasn't closed in Curl adapter in case of error (bug #15721) - * Curl adapter sent an extra 'sentHeaders' event and returned bogus - response status when server returned 100-Continue response (bug #15785) - - - - - 0.2.0 - 0.2.0 - - - alpha - alpha - - 2009-01-07 - BSD License - - API changes: - * HTTP_Request2::getConfigValue() is deprecated and will be removed in next - release. Use HTTP_Request2::getConfig(). - * Changed HTTP_Request2::setConfig() to accept a pair of parameter name and - parameter value in addition to array('parameter name' => 'value') - * Added HTTP_Request2::getConfig() method that can return a single - configuration parameter or the whole configuration array - -Other additions and changes: - * Added a debug Observer that can log request progress to a file or an - instance of PEAR::Log (thanks to David Jean Louis, request #15424) - * Added a new 'timeout' parameter that limits total number of seconds - a request can take (see requests #5735 and #8964) - * Added various SSL protocol options: 'ssl_verify_peer', 'ssl_verify_host', - 'ssl_cafile', 'ssl_capath', 'ssl_local_cert', 'ssl_passphrase'. Note that - 'ssl_verify_host' option behaves differently in Socket and Curl Adapters: - http://bugs.php.net/bug.php?id=47030 - -Fixes: - * Fixed 'data error' when processing response encoded by 'deflate' - encoding (bug #15305) - * Curl Adapter now passes full request headers in 'sentHeaders' event - - - - - 0.1.0 - 0.1.0 - - - alpha - alpha - - 2008-11-17 - BSD License - -Initial release. The features supported are mostly the same as those of -HTTP_Request, with the following additional feature requests implemented: - * cURL extension support (request #5463) - * It is now possible to monitor the file upload progress with Observers - (request #7630) - * Added 'sentHeaders' notification providing the request headers to the - Observers (request #7633) - * Added support for 'deflate' encoding (request #11246) - - - - \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/AllTests.php b/vendor/pear/http_request2/tests/AllTests.php deleted file mode 100644 index a311ca2f9..000000000 --- a/vendor/pear/http_request2/tests/AllTests.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'HTTP_Request2_AllTests::main'); -} - -require_once dirname(__FILE__) . '/Request2Test.php'; -require_once dirname(__FILE__) . '/ObserverTest.php'; -require_once dirname(__FILE__) . '/Request2/AllTests.php'; - -class HTTP_Request2_AllTests -{ - public static function main() - { - if (!function_exists('phpunit_autoload')) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package'); - - $suite->addTest(Request2_AllTests::suite()); - $suite->addTestSuite('HTTP_Request2Test'); - $suite->addTestSuite('HTTP_Request2_ObserverTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'HTTP_Request2_AllTests::main') { - HTTP_Request2_AllTests::main(); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/NetworkConfig.php.dist b/vendor/pear/http_request2/tests/NetworkConfig.php.dist deleted file mode 100644 index c50609bb7..000000000 --- a/vendor/pear/http_request2/tests/NetworkConfig.php.dist +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * This file contains configuration needed for running HTTP_Request2 tests - * that interact with the network. Do not edit this file, copy it to - * NetworkConfig.php and edit the copy instead. - */ - -/** - * Base URL for HTTP_Request2 Adapters tests - * - * To enable the tests that actually perform network interaction, you should - * copy the contents of _network directory to a directory under your web - * server's document root or create a symbolic link to _network directory - * there. Set this constant to point to the URL of that directory. - */ -define('HTTP_REQUEST2_TESTS_BASE_URL', null); - -/** - * URL that is protected by server digest authentication - * - * This is needed for testing of 100 Continue handling, we can't implement - * digest in PHP since it will kick in a bit later - */ -define('HTTP_REQUEST2_TESTS_DIGEST_URL', null); - -/**#@+ - * Proxy setup for Socket Adapter tests - * - * Set these constants to run additional tests for Socket Adapter using a HTTP - * proxy. If proxy host is not set then the tests will not be run. - */ -define('HTTP_REQUEST2_TESTS_PROXY_HOST', null); -define('HTTP_REQUEST2_TESTS_PROXY_PORT', 8080); -define('HTTP_REQUEST2_TESTS_PROXY_USER', ''); -define('HTTP_REQUEST2_TESTS_PROXY_PASSWORD', ''); -define('HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME', 'basic'); -define('HTTP_REQUEST2_TESTS_PROXY_TYPE', 'http'); -/**#@-*/ -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/ObserverTest.php b/vendor/pear/http_request2/tests/ObserverTest.php deleted file mode 100644 index 9361e8f66..000000000 --- a/vendor/pear/http_request2/tests/ObserverTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock observer - */ -class HTTP_Request2_MockObserver implements SplObserver -{ - public $calls = 0; - - public $event; - - public function update (SplSubject $subject) - { - $this->calls++; - $this->event = $subject->getLastEvent(); - } -} - -/** - * Unit test for subject-observer pattern implementation in HTTP_Request2 - */ -class HTTP_Request2_ObserverTest extends PHPUnit_Framework_TestCase -{ - public function testSetLastEvent() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $request->attach($observer); - - $request->setLastEvent('foo', 'bar'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'foo', 'data' => 'bar'), $observer->event); - - $request->setLastEvent('baz'); - $this->assertEquals(2, $observer->calls); - $this->assertEquals(array('name' => 'baz', 'data' => null), $observer->event); - } - - public function testAttachOnlyOnce() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - $request->attach($observer); - $request->attach($observer2); - $request->attach($observer); - - $request->setLastEvent('event', 'data'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(1, $observer2->calls); - } - - public function testDetach() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - - $request->attach($observer); - $request->detach($observer2); // should not be a error - $request->setLastEvent('first'); - - $request->detach($observer); - $request->setLastEvent('second'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php deleted file mode 100644 index 491d9c7f9..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Request2_Adapter_AllTests::main'); -} - -require_once dirname(__FILE__) . '/MockTest.php'; -require_once dirname(__FILE__) . '/SkippedTests.php'; -require_once dirname(__FILE__) . '/SocketTest.php'; -require_once dirname(__FILE__) . '/SocketProxyTest.php'; -require_once dirname(__FILE__) . '/CurlTest.php'; - -class Request2_Adapter_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2 - Adapter'); - - $suite->addTestSuite('HTTP_Request2_Adapter_MockTest'); - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketTest'); - } - if (defined('HTTP_REQUEST2_TESTS_PROXY_HOST') && HTTP_REQUEST2_TESTS_PROXY_HOST - && defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketProxyTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketProxyTest'); - } - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - && extension_loaded('curl') - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_CurlTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_CurlTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_Adapter_AllTests::main') { - Request2_Adapter_AllTests::main(); -} -?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php deleted file mode 100644 index 2e20a8156..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php +++ /dev/null @@ -1,387 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** Class representing a HTTP request */ -require_once 'HTTP/Request2.php'; -/** Class for building multipart/form-data request body */ -require_once 'HTTP/Request2/MultipartBody.php'; - -class SlowpokeBody extends HTTP_Request2_MultipartBody -{ - protected $doSleep; - - public function rewind() - { - $this->doSleep = true; - parent::rewind(); - } - - public function read($length) - { - if ($this->doSleep) { - sleep(3); - $this->doSleep = false; - } - return parent::read($length); - } -} - -class HeaderObserver implements SplObserver -{ - public $headers; - - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - - // force a timeout when writing request body - if ('sentHeaders' == $event['name']) { - $this->headers = $event['data']; - } - } -} - -/** - * Tests for HTTP_Request2 package that require a working webserver - * - * The class contains some common tests that should be run for all Adapters, - * it is extended by their unit tests. - * - * You need to properly set up this test suite, refer to NetworkConfig.php.dist - */ -abstract class HTTP_Request2_Adapter_CommonNetworkTest extends PHPUnit_Framework_TestCase -{ - /** - * HTTP Request object - * @var HTTP_Request2 - */ - protected $request; - - /** - * Base URL for remote test files - * @var string - */ - protected $baseUrl; - - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array(); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') || !HTTP_REQUEST2_TESTS_BASE_URL) { - $this->markTestSkipped('Base URL is not configured'); - - } else { - $this->baseUrl = rtrim(HTTP_REQUEST2_TESTS_BASE_URL, '/') . '/'; - $name = strtolower(preg_replace('/^test/i', '', $this->getName())) . '.php'; - - $this->request = new HTTP_Request2( - $this->baseUrl . $name, HTTP_Request2::METHOD_GET, $this->config - ); - } - } - - /** - * Tests possibility to send GET parameters - * - * NB: Currently there are problems with Net_URL2::setQueryVariables(), thus - * array structure is simple: http://pear.php.net/bugs/bug.php?id=18267 - */ - public function testGetParameters() - { - $data = array( - 'bar' => array( - 'key' => 'value' - ), - 'foo' => 'some value', - 'numbered' => array('first', 'second') - ); - - $this->request->getUrl()->setQueryVariables($data); - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - public function testPostParameters() - { - $data = array( - 'bar' => array( - 'key' => 'some other value' - ), - 'baz' => array( - 'key1' => array( - 'key2' => 'yet another value' - ) - ), - 'foo' => 'some value', - 'indexed' => array('first', 'second') - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter($data); - - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - public function testUploads() - { - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->addUpload('foo', dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', 'picture.gif', 'image/gif') - ->addUpload('bar', array( - array(dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', null, 'image/gif'), - array(dirname(dirname(dirname(__FILE__))) . '/_files/plaintext.txt', 'secret.txt', 'text/x-whatever') - )); - - $response = $this->request->send(); - $this->assertContains("foo picture.gif image/gif 43", $response->getBody()); - $this->assertContains("bar[0] empty.gif image/gif 43", $response->getBody()); - $this->assertContains("bar[1] secret.txt text/x-whatever 15", $response->getBody()); - } - - public function testRawPostData() - { - $data = 'Nothing to see here, move along'; - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setBody($data); - $response = $this->request->send(); - $this->assertEquals($data, $response->getBody()); - } - - public function testCookies() - { - $cookies = array( - 'CUSTOMER' => 'WILE_E_COYOTE', - 'PART_NUMBER' => 'ROCKET_LAUNCHER_0001' - ); - - foreach ($cookies as $k => $v) { - $this->request->addCookie($k, $v); - } - $response = $this->request->send(); - $this->assertEquals(serialize($cookies), $response->getBody()); - } - - public function testTimeout() - { - $this->request->setConfig('timeout', 2); - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); - } - } - - public function testTimeoutInRequest() - { - $this->request->setConfig('timeout', 2) - ->setUrl($this->baseUrl . 'postparameters.php') - ->setBody(new SlowpokeBody(array('foo' => 'some value'), array())); - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_MessageException was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); - } - } - - public function testBasicAuth() - { - $this->request->getUrl()->setQueryVariables(array( - 'user' => 'luser', - 'pass' => 'qwerty' - )); - $wrong = clone $this->request; - - $this->request->setAuth('luser', 'qwerty'); - $response = $this->request->send(); - $this->assertEquals(200, $response->getStatus()); - - $wrong->setAuth('luser', 'password'); - $response = $wrong->send(); - $this->assertEquals(401, $response->getStatus()); - } - - public function testDigestAuth() - { - $this->request->getUrl()->setQueryVariables(array( - 'user' => 'luser', - 'pass' => 'qwerty' - )); - $wrong = clone $this->request; - - $this->request->setAuth('luser', 'qwerty', HTTP_Request2::AUTH_DIGEST); - $response = $this->request->send(); - $this->assertEquals(200, $response->getStatus()); - - $wrong->setAuth('luser', 'password', HTTP_Request2::AUTH_DIGEST); - $response = $wrong->send(); - $this->assertEquals(401, $response->getStatus()); - } - - public function testRedirectsDefault() - { - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true, 'strict_redirects' => false)) - ->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter('foo', 'foo value'); - - $response = $this->request->send(); - $this->assertContains('Method=GET', $response->getBody()); - $this->assertNotContains('foo', $response->getBody()); - $this->assertEquals($this->baseUrl . 'redirects.php?redirects=0', $response->getEffectiveUrl()); - } - - public function testRedirectsStrict() - { - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true, 'strict_redirects' => true)) - ->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter('foo', 'foo value'); - - $response = $this->request->send(); - $this->assertContains('Method=POST', $response->getBody()); - $this->assertContains('foo', $response->getBody()); - } - - public function testRedirectsLimit() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?redirects=4') - ->setConfig(array('follow_redirects' => true, 'max_redirects' => 2)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TOO_MANY_REDIRECTS, $e->getCode()); - } - } - - public function testRedirectsRelative() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=relative') - ->setConfig(array('follow_redirects' => true)); - - $response = $this->request->send(); - $this->assertContains('did relative', $response->getBody()); - } - - public function testRedirectsNonHTTP() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=ftp') - ->setConfig(array('follow_redirects' => true)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::NON_HTTP_REDIRECT, $e->getCode()); - } - } - - public function testCookieJar() - { - $this->request->setUrl($this->baseUrl . 'setcookie.php?name=cookie_name&value=cookie_value'); - $req2 = clone $this->request; - - $this->request->setCookieJar()->send(); - $jar = $this->request->getCookieJar(); - $jar->store( - array('name' => 'foo', 'value' => 'bar'), - $this->request->getUrl() - ); - - $response = $req2->setUrl($this->baseUrl . 'cookies.php')->setCookieJar($jar)->send(); - $this->assertEquals( - serialize(array('cookie_name' => 'cookie_value', 'foo' => 'bar')), - $response->getBody() - ); - } - - public function testCookieJarAndRedirect() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=cookie') - ->setConfig('follow_redirects', true) - ->setCookieJar(); - - $response = $this->request->send(); - $this->assertEquals(serialize(array('cookie_on_redirect' => 'success')), $response->getBody()); - } - - /** - * @link http://pear.php.net/bugs/bug.php?id=20125 - */ - public function testChunkedRequest() - { - $data = array( - 'long' => str_repeat('a', 1000), - 'very_long' => str_repeat('b', 2000) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'postparameters.php') - ->setConfig('buffer_size', 512) - ->setHeader('Transfer-Encoding', 'chunked') - ->addPostParameter($data); - - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - /** - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://pear.php.net/bugs/bug.php?id=15937 - */ - public function testPreventExpectHeader() - { - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $observer = new HeaderObserver(); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php') - ->setHeader('Expect', '') - ->setBody($body) - ->attach($observer); - - $response = $this->request->send(); - $this->assertNotContains('Expect:', $observer->headers); - $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php deleted file mode 100644 index 28722e739..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** Adapter for HTTP_Request2 wrapping around cURL extension */ - -/** - * Unit test for Curl Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_CurlTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Curl' - ); - - /** - * Checks whether redirect support in cURL is disabled by safe_mode or open_basedir - * @return bool - */ - protected function isRedirectSupportDisabled() - { - return ini_get('safe_mode') || ini_get('open_basedir'); - } - - public function testRedirectsDefault() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsDefault(); - } - } - - public function testRedirectsStrict() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsStrict(); - } - } - - public function testRedirectsLimit() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsLimit(); - } - } - - public function testRedirectsRelative() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsRelative(); - } - } - - public function testRedirectsNonHTTP() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsNonHTTP(); - } - } - - public function testCookieJarAndRedirect() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testCookieJarAndRedirect(); - } - } - - public function testBug17450() - { - if (!$this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Neither safe_mode nor open_basedir is enabled'); - } - - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - - } catch (HTTP_Request2_LogicException $e) { - $this->assertEquals(HTTP_Request2_Exception::MISCONFIGURATION, $e->getCode()); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php deleted file mode 100644 index 3a27e0c25..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock adapter intended for testing - */ -require_once 'HTTP/Request2/Adapter/Mock.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_Adapter_MockTest extends PHPUnit_Framework_TestCase -{ - public function testDefaultResponse() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, - array('adapter' => 'mock')); - $response = $req->send(); - $this->assertEquals(400, $response->getStatus()); - $this->assertEquals(0, count($response->getHeader())); - $this->assertEquals('', $response->getBody()); - } - - public function testResponseFromString() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(1, count($response->getHeader())); - $this->assertEquals('This is a string', $response->getBody()); - } - - public function testResponseFromFile() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse(fopen(dirname(dirname(dirname(__FILE__))) . - '/_files/response_headers', 'rb')); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('Nothing to see here, move along.', $response->getBody()); - } - - public function testResponsesQueue() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 301 Over there\r\n" . - "Location: http://www.example.com/newpage.html\r\n" . - "\r\n" . - "The document is over there" - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - $this->assertEquals(301, $req->send()->getStatus()); - $this->assertEquals(200, $req->send()->getStatus()); - $this->assertEquals(400, $req->send()->getStatus()); - } - - /** - * Returning URL-specific responses - * @link http://pear.php.net/bugs/bug.php?id=19276 - */ - public function testRequest19276() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.org", - 'http://example.org/' - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.com", - 'http://example.com/' - ); - - $req1 = new HTTP_Request2('http://localhost/'); - $req1->setAdapter($mock); - $this->assertEquals(400, $req1->send()->getStatus()); - - $req2 = new HTTP_Request2('http://example.com/'); - $req2->setAdapter($mock); - $this->assertContains('example.com', $req2->send()->getBody()); - - $req3 = new HTTP_Request2('http://example.org'); - $req3->setAdapter($mock); - $this->assertContains('example.org', $req3->send()->getBody()); - } - - public function testResponseException() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - new HTTP_Request2_Exception('Shit happens') - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - try { - $req->send(); - } catch (Exception $e) { - $this->assertEquals('Shit happens', $e->getMessage()); - return; - } - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } -} -?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php deleted file mode 100644 index a998f67dd..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Shows a skipped test if networked tests are not configured - */ -class HTTP_Request2_Adapter_Skip_SocketTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapter() - { - $this->markTestSkipped('Socket Adapter tests need base URL configured.'); - } -} - -/** - * Shows a skipped test if proxy is not configured - */ -class HTTP_Request2_Adapter_Skip_SocketProxyTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapterWithProxy() - { - $this->markTestSkipped('Socket Adapter proxy tests need base URL and proxy configured'); - } -} - -/** - * Shows a skipped test if networked tests are not configured or cURL extension is unavailable - */ -class HTTP_Request2_Adapter_Skip_CurlTest extends PHPUnit_Framework_TestCase -{ - public function testCurlAdapter() - { - $this->markTestSkipped('Curl Adapter tests need base URL configured and curl extension available'); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php deleted file mode 100644 index 78c4d4f3a..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 working through proxy - */ -class HTTP_Request2_Adapter_SocketProxyTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_PROXY_HOST') || !HTTP_REQUEST2_TESTS_PROXY_HOST) { - $this->markTestSkipped('Proxy is not configured'); - - } else { - $this->config += array( - 'proxy_host' => HTTP_REQUEST2_TESTS_PROXY_HOST, - 'proxy_port' => HTTP_REQUEST2_TESTS_PROXY_PORT, - 'proxy_user' => HTTP_REQUEST2_TESTS_PROXY_USER, - 'proxy_password' => HTTP_REQUEST2_TESTS_PROXY_PASSWORD, - 'proxy_auth_scheme' => HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME, - 'proxy_type' => HTTP_REQUEST2_TESTS_PROXY_TYPE - ); - parent::setUp(); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php deleted file mode 100644 index 1400238ce..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** Socket-based adapter for HTTP_Request2 */ -require_once 'HTTP/Request2/Adapter/Socket.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_SocketTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - public function testBug17826() - { - $adapter = new HTTP_Request2_Adapter_Socket(); - - $request1 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request1->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - - $request2 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request2->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - } - - - /** - * Infinite loop with stream wrapper passed as upload - * - * Dunno how the original reporter managed to pass a file pointer - * that doesn't support fstat() to MultipartBody, maybe he didn't use - * addUpload(). So we don't use it, either. - * - * @link http://pear.php.net/bugs/bug.php?id=19934 - */ - public function testBug19934() - { - if (!in_array('http', stream_get_wrappers())) { - $this->markTestSkipped("This test requires an HTTP fopen wrapper enabled"); - } - - $fp = fopen($this->baseUrl . '/bug19934.php', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'foo.txt', - 'type' => 'text/plain', - 'size' => 20000 - ) - ) - ); - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php') - ->setBody($body); - - set_error_handler(array($this, 'rewindWarningsHandler')); - $response = $this->request->send(); - restore_error_handler(); - - $this->assertContains("upload foo.txt text/plain 20000", $response->getBody()); - } - - public function rewindWarningsHandler($errno, $errstr) - { - if (($errno & E_WARNING) && false !== strpos($errstr, 'rewind')) { - return true; - } - return false; - } - - /** - * Do not send request body twice to URLs protected by digest auth - * - * @link http://pear.php.net/bugs/bug.php?id=19233 - */ - public function test100ContinueHandling() - { - if (!defined('HTTP_REQUEST2_TESTS_DIGEST_URL') || !HTTP_REQUEST2_TESTS_DIGEST_URL) { - $this->markTestSkipped('This test requires an URL protected by server digest auth'); - } - - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = $this->getMock( - 'HTTP_Request2_MultipartBody', array('read'), array( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ) - ); - $body->expects($this->never())->method('read'); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl(HTTP_REQUEST2_TESTS_DIGEST_URL) - ->setBody($body); - - $this->assertEquals(401, $this->request->send()->getStatus()); - } - - public function test100ContinueTimeoutBug() - { - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php?slowpoke') - ->setBody($body); - - $response = $this->request->send(); - $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/AllTests.php b/vendor/pear/http_request2/tests/Request2/AllTests.php deleted file mode 100644 index 1b8bc6bb9..000000000 --- a/vendor/pear/http_request2/tests/Request2/AllTests.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Request2_AllTests::main'); -} - -require_once dirname(__FILE__) . '/CookieJarTest.php'; -require_once dirname(__FILE__) . '/MultipartBodyTest.php'; -require_once dirname(__FILE__) . '/ResponseTest.php'; -require_once dirname(__FILE__) . '/Adapter/AllTests.php'; - -class Request2_AllTests -{ - public static function main() - { - if (!function_exists('phpunit_autoload')) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2'); - - $suite->addTestSuite('HTTP_Request2_CookieJarTest'); - $suite->addTestSuite('HTTP_Request2_MultipartBodyTest'); - $suite->addTestSuite('HTTP_Request2_ResponseTest'); - $suite->addTest(Request2_Adapter_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_AllTests::main') { - Request2_AllTests::main(); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/CookieJarTest.php b/vendor/pear/http_request2/tests/Request2/CookieJarTest.php deleted file mode 100644 index 5f1de4290..000000000 --- a/vendor/pear/http_request2/tests/Request2/CookieJarTest.php +++ /dev/null @@ -1,370 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; -/** Stores cookies and passes them between HTTP requests */ -require_once 'HTTP/Request2/CookieJar.php'; - -/** - * Unit test for HTTP_Request2_CookieJar class - */ -class HTTP_Request2_CookieJarTest extends PHPUnit_Framework_TestCase -{ - /** - * Cookie jar instance being tested - * @var HTTP_Request2_CookieJar - */ - protected $jar; - - protected function setUp() - { - $this->jar = new HTTP_Request2_CookieJar(); - } - - /** - * Test that we can't store junk "cookies" in jar - * - * @dataProvider invalidCookieProvider - * @expectedException HTTP_Request2_LogicException - */ - public function testStoreInvalid($cookie) - { - $this->jar->store($cookie); - } - - /** - * - * @dataProvider noPSLDomainsProvider - */ - public function testDomainMatchNoPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(false); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - /** - * - * @dataProvider PSLDomainsProvider - */ - public function testDomainMatchPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(true); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - public function testConvertExpiresToISO8601() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+1 day'); - - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => $dt->format(DateTime::COOKIE), - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals($cookies[0]['expires'], $dt->format(DateTime::ISO8601)); - } - - public function testProblem2038() - { - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => 'Sun, 01 Jan 2040 03:04:05 GMT', - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals(array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => '2040-01-01T03:04:05+0000', - 'secure' => false - )), $cookies); - } - - public function testStoreExpired() - { - $base = array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'secure' => false - ); - - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('-1 day'); - $yesterday = $dt->format(DateTime::COOKIE); - - $dt->modify('+2 days'); - $tomorrow = $dt->format(DateTime::COOKIE); - - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - - $this->jar->store($base + array('expires' => $tomorrow)); - $this->assertEquals(1, count($this->jar->getAll())); - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - } - - /** - * - * @dataProvider cookieAndSetterProvider - */ - public function testGetDomainAndPathFromSetter($cookie, $setter, $expected) - { - $this->jar->store($cookie, $setter); - $expected = array_merge($cookie, $expected); - $cookies = $this->jar->getAll(); - $this->assertEquals($expected, $cookies[0]); - } - - /** - * - * @dataProvider cookieMatchProvider - */ - public function testGetMatchingCookies($url, $expectedCount) - { - $cookies = array( - array('domain' => '.example.com', 'path' => '/', 'secure' => false), - array('domain' => '.example.com', 'path' => '/', 'secure' => true), - array('domain' => '.example.com', 'path' => '/path', 'secure' => false), - array('domain' => '.example.com', 'path' => '/other', 'secure' => false), - array('domain' => 'example.com', 'path' => '/', 'secure' => false), - array('domain' => 'www.example.com', 'path' => '/', 'secure' => false), - array('domain' => 'specific.example.com', 'path' => '/path', 'secure' => false), - array('domain' => 'nowww.example.com', 'path' => '/', 'secure' => false), - ); - - for ($i = 0; $i < count($cookies); $i++) { - $this->jar->store($cookies[$i] + array('expires' => null, 'name' => "cookie{$i}", 'value' => "cookie_{$i}_value")); - } - - $this->assertEquals($expectedCount, count($this->jar->getMatching(new Net_URL2($url)))); - } - - public function testLongestPathFirst() - { - $cookie = array( - 'name' => 'foo', - 'domain' => '.example.com', - ); - foreach (array('/', '/specific/path/', '/specific/') as $path) { - $this->jar->store($cookie + array('path' => $path, 'value' => str_replace('/', '_', $path))); - } - $this->assertEquals( - 'foo=_specific_path_; foo=_specific_; foo=_', - $this->jar->getMatching(new Net_URL2('http://example.com/specific/path/file.php'), true) - ); - } - - public function testSerializable() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+1 day'); - $cookie = array('domain' => '.example.com', 'path' => '/', 'secure' => false, 'value' => 'foo'); - - $this->jar->store($cookie + array('name' => 'session', 'expires' => null)); - $this->jar->store($cookie + array('name' => 'long', 'expires' => $dt->format(DateTime::COOKIE))); - - $newJar = unserialize(serialize($this->jar)); - $cookies = $newJar->getAll(); - $this->assertEquals(1, count($cookies)); - $this->assertEquals('long', $cookies[0]['name']); - - $this->jar->serializeSessionCookies(true); - $newJar = unserialize(serialize($this->jar)); - $this->assertEquals($this->jar->getAll(), $newJar->getAll()); - } - - public function testRemoveExpiredOnUnserialize() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+2 seconds'); - - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => $dt->format(DateTime::COOKIE), - )); - - $serialized = serialize($this->jar); - sleep(2); - $newJar = unserialize($serialized); - $this->assertEquals(array(), $newJar->getAll()); - } - - public static function invalidCookieProvider() - { - return array( - array(array()), - array(array('name' => 'foo')), - array(array( - 'name' => 'a name', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'a value', - 'domain' => '.example.com', - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => null, - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => 'invalid date', - )), - ); - } - - public static function noPSLdomainsProvider() - { - return array( - array('localhost', 'localhost', true), - array('www.example.com', 'www.example.com', true), - array('127.0.0.1', '127.0.0.1', true), - array('127.0.0.1', '.0.0.1', false), - array('www.example.com', '.example.com', true), - array('deep.within.example.com', '.example.com', true), - array('example.com', '.com', false), - array('anotherexample.com', 'example.com', false), - array('whatever.msk.ru', '.msk.ru', true), - array('whatever.co.uk', '.co.uk', true), - array('whatever.uk', '.whatever.uk', true), - array('whatever.tokyo.jp', '.whatever.tokyo.jp', true), - array('metro.tokyo.jp', '.metro.tokyo.jp', true), - array('foo.bar', '.foo.bar', true) - ); - } - - public static function PSLdomainsProvider() - { - return array( - array('localhost', 'localhost', true), - array('www.example.com', 'www.example.com', true), - array('127.0.0.1', '127.0.0.1', true), - array('127.0.0.1', '.0.0.1', false), - array('www.example.com', '.example.com', true), - array('deep.within.example.com', '.example.com', true), - array('example.com', '.com', false), - array('anotherexample.com', 'example.com', false), - array('whatever.msk.ru', '.msk.ru', false), - array('whatever.co.uk', '.co.uk', false), - array('whatever.uk', '.whatever.uk', false), - array('whatever.tr', '.whatever.tr', false), - array('nic.tr', '.nic.tr', true), - array('foo.bar', '.foo.bar', true) - ); - } - - public static function cookieAndSetterProvider() - { - return array( - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => null, - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/directory/file.php'), - array( - 'domain' => 'example.com', - 'path' => '/directory/' - ) - ), - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => null, - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/path/to/file.php'), - array( - 'path' => '/path/to/' - ) - ), - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => '/', - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/another/file.php'), - array( - 'domain' => 'example.com' - ) - ) - ); - } - - public static function cookieMatchProvider() - { - return array( - array('http://www.example.com/path/file.php', 4), - array('https://www.example.com/path/file.php', 5), - array('http://example.com/path/file.php', 3), - array('http://specific.example.com/path/file.php', 4), - array('http://specific.example.com/other/file.php', 3), - array('http://another.example.com/another', 2) - ); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php b/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php deleted file mode 100644 index 8543b9e56..000000000 --- a/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2_MultipartBody class - */ -class HTTP_Request2_MultipartBodyTest extends PHPUnit_Framework_TestCase -{ - public function testUploadSimple() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - - $this->assertTrue($body instanceof HTTP_Request2_MultipartBody); - $asString = $body->__toString(); - $boundary = $body->getBoundary(); - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - $this->assertRegexp("!--{$boundary}--\r\n$!", $asString); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testRequest16863() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'rb'); - $body = $req->addUpload('upload', $fp) - ->getBody(); - - $asString = $body->__toString(); - $this->assertContains('name="upload"; filename="anonymous.blob"', $asString); - $this->assertContains('This is a test.', $asString); - - $req->addUpload('bad_upload', fopen('php://input', 'rb')); - } - - public function testStreaming() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - $asString = ''; - while ($part = $body->read(10)) { - $asString .= $part; - } - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - } - - public function testUploadArray() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addUpload('upload', array( - array(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'bio.txt', 'text/plain'), - array(fopen(dirname(dirname(__FILE__)) . '/_files/empty.gif', 'rb'), 'photo.gif', 'image/gif') - )) - ->getBody(); - $asString = $body->__toString(); - $this->assertContains(file_get_contents(dirname(dirname(__FILE__)) . '/_files/empty.gif'), $asString); - $this->assertContains('name="upload[0]"; filename="bio.txt"', $asString); - $this->assertContains('name="upload[1]"; filename="photo.gif"', $asString); - - $body2 = $req->setConfig(array('use_brackets' => false))->getBody(); - $asString = $body2->__toString(); - $this->assertContains('name="upload"; filename="bio.txt"', $asString); - $this->assertContains('name="upload"; filename="photo.gif"', $asString); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/ResponseTest.php b/vendor/pear/http_request2/tests/Request2/ResponseTest.php deleted file mode 100644 index c757d7327..000000000 --- a/vendor/pear/http_request2/tests/Request2/ResponseTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_ResponseTest extends PHPUnit_Framework_TestCase -{ - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testParseStatusLine() - { - $response = new HTTP_Request2_Response('HTTP/1.1 200 OK'); - $this->assertEquals('1.1', $response->getVersion()); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('OK', $response->getReasonPhrase()); - - $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!'); - $this->assertEquals('1.2', $response2->getVersion()); - $this->assertEquals(222, $response2->getStatus()); - $this->assertEquals('Nishtyak!', $response2->getReasonPhrase()); - - $response3 = new HTTP_Request2_Response('Invalid status line'); - } - - public function testParseHeaders() - { - $response = $this->readResponseFromFile('response_headers'); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('PHP/6.2.2', $response->getHeader('X-POWERED-BY')); - $this->assertEquals('text/html; charset=windows-1251', $response->getHeader('cOnTeNt-TyPe')); - $this->assertEquals('accept-charset, user-agent', $response->getHeader('vary')); - } - - public function testParseCookies() - { - $response = $this->readResponseFromFile('response_cookies'); - $cookies = $response->getCookies(); - $this->assertEquals(4, count($cookies)); - $expected = array( - array('name' => 'foo', 'value' => 'bar', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'PHPSESSID', 'value' => '1234567890abcdef1234567890abcdef', - 'expires' => null, 'domain' => null, 'path' => '/', 'secure' => true), - array('name' => 'A', 'value' => 'B=C', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'baz', 'value' => '%20a%20value', 'expires' => 'Sun, 03 Jan 2010 03:04:05 GMT', - 'domain' => 'pear.php.net', 'path' => null, 'secure' => false), - ); - foreach ($cookies as $k => $cookie) { - $this->assertEquals($expected[$k], $cookie); - } - } - - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testGzipEncoding() - { - $response = $this->readResponseFromFile('response_gzip'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - - $response = $this->readResponseFromFile('response_gzip_broken'); - $body = $response->getBody(); - } - - public function testDeflateEncoding() - { - $response = $this->readResponseFromFile('response_deflate'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - } - - public function testBug15305() - { - $response = $this->readResponseFromFile('bug_15305'); - $this->assertEquals('c8c5088fc8a7652afef380f086c010a6', md5($response->getBody())); - } - - public function testBug18169() - { - $response = $this->readResponseFromFile('bug_18169'); - $this->assertEquals('', $response->getBody()); - } - - protected function readResponseFromFile($filename) - { - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/' . $filename, 'rb'); - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 1024)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2Test.php b/vendor/pear/http_request2/tests/Request2Test.php deleted file mode 100644 index 70516d647..000000000 --- a/vendor/pear/http_request2/tests/Request2Test.php +++ /dev/null @@ -1,391 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2 class - */ -class HTTP_Request2Test extends PHPUnit_Framework_TestCase -{ - public function testConstructorSetsDefaults() - { - $url = new Net_URL2('http://www.example.com/foo'); - $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST, array('connect_timeout' => 666)); - - $this->assertSame($url, $req->getUrl()); - $this->assertEquals(HTTP_Request2::METHOD_POST, $req->getMethod()); - $this->assertEquals(666, $req->getConfig('connect_timeout')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetUrl() - { - $urlString = 'http://www.example.com/foo/bar.php'; - $url = new Net_URL2($urlString); - - $req1 = new HTTP_Request2(); - $req1->setUrl($url); - $this->assertSame($url, $req1->getUrl()); - - $req2 = new HTTP_Request2(); - $req2->setUrl($urlString); - $this->assertInstanceOf('Net_URL2', $req2->getUrl()); - $this->assertEquals($urlString, $req2->getUrl()->getUrl()); - - $req3 = new HTTP_Request2(); - $req3->setUrl(array('This will cause an error')); - } - - public function testConvertUserinfoToAuth() - { - $req = new HTTP_Request2(); - $req->setUrl('http://foo:b%40r@www.example.com/'); - - $this->assertEquals('', (string)$req->getUrl()->getUserinfo()); - $this->assertEquals( - array('user' => 'foo', 'password' => 'b@r', 'scheme' => HTTP_Request2::AUTH_BASIC), - $req->getAuth() - ); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetMethod() - { - $req = new HTTP_Request2(); - $req->setMethod(HTTP_Request2::METHOD_PUT); - $this->assertEquals(HTTP_Request2::METHOD_PUT, $req->getMethod()); - - $req->setMethod('Invalid method'); - } - - public function testSetAndGetConfig() - { - $req = new HTTP_Request2(); - $this->assertArrayHasKey('connect_timeout', $req->getConfig()); - - $req->setConfig(array('connect_timeout' => 123)); - $this->assertEquals(123, $req->getConfig('connect_timeout')); - try { - $req->setConfig(array('foo' => 'unknown parameter')); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - - try { - $req->getConfig('bar'); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - } - - public function testSetProxyAsUrl() - { - $req = new HTTP_Request2(); - $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/'); - - $this->assertEquals('socks5', $req->getConfig('proxy_type')); - $this->assertEquals('localhost', $req->getConfig('proxy_host')); - $this->assertEquals(1080, $req->getConfig('proxy_port')); - $this->assertEquals('foo', $req->getConfig('proxy_user')); - $this->assertEquals('bar%baz', $req->getConfig('proxy_password')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testHeaders() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Foo', 'Bar'); - $req->setHeader('Foo-Bar: value'); - $req->setHeader(array('Another-Header' => 'another value', 'Yet-Another: other_value')); - $this->assertEquals( - array('foo-bar' => 'value', 'another-header' => 'another value', - 'yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('FOO-BAR'); - $req->setHeader(array('aNOTHER-hEADER')); - $this->assertEquals( - array('yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('Invalid header', 'value'); - } - - public function testBug15937() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Expect: '); - $req->setHeader('Foo', ''); - $this->assertEquals( - array('expect' => '', 'foo' => '') + $autoHeaders, - $req->getHeaders() - ); - } - - public function testRequest17507() - { - $req = new HTTP_Request2(); - - $req->setHeader('accept-charset', 'iso-8859-1'); - $req->setHeader('accept-charset', array('windows-1251', 'utf-8'), false); - - $req->setHeader(array('accept' => 'text/html')); - $req->setHeader(array('accept' => 'image/gif'), null, false); - - $headers = $req->getHeaders(); - - $this->assertEquals('iso-8859-1, windows-1251, utf-8', $headers['accept-charset']); - $this->assertEquals('text/html, image/gif', $headers['accept']); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testCookies() - { - $req = new HTTP_Request2(); - $req->addCookie('name', 'value'); - $req->addCookie('foo', 'bar'); - $headers = $req->getHeaders(); - $this->assertEquals('name=value; foo=bar', $headers['cookie']); - - $req->addCookie('invalid cookie', 'value'); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testPlainBody() - { - $req = new HTTP_Request2(); - $req->setBody('A string'); - $this->assertEquals('A string', $req->getBody()); - - $req->setBody(dirname(__FILE__) . '/_files/plaintext.txt', true); - $headers = $req->getHeaders(); - $this->assertRegexp( - '!^(text/plain|application/octet-stream)!', - $headers['content-type'] - ); - $this->assertEquals('This is a test.', fread($req->getBody(), 1024)); - - $req->setBody('missing file', true); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testRequest16863() - { - $req = new HTTP_Request2(); - $req->setBody(fopen(dirname(__FILE__) . '/_files/plaintext.txt', 'rb')); - $headers = $req->getHeaders(); - $this->assertEquals('application/octet-stream', $headers['content-type']); - - $req->setBody(fopen('php://input', 'rb')); - } - - public function testUrlencodedBody() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar'); - $req->addPostParameter(array('baz' => 'quux')); - $req->addPostParameter('foobar', array('one', 'two')); - $this->assertEquals( - 'foo=bar&baz=quux&foobar%5B0%5D=one&foobar%5B1%5D=two', - $req->getBody() - ); - - $req->setConfig(array('use_brackets' => false)); - $this->assertEquals( - 'foo=bar&baz=quux&foobar=one&foobar=two', - $req->getBody() - ); - } - - public function testRequest15368() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'te~st'); - $this->assertContains('~', $req->getBody()); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage missing file - */ - public function testUpload() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addUpload('upload', dirname(__FILE__) . '/_files/plaintext.txt'); - - $headers = $req->getHeaders(); - $this->assertEquals('multipart/form-data', $headers['content-type']); - - $req->addUpload('upload_2', 'missing file'); - } - - public function testPropagateUseBracketsToNetURL2() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, - array('use_brackets' => false)); - $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); - $this->assertEquals('http://www.example.com/?foo=bar&foo=baz', $req->getUrl()->__toString()); - - $req->setConfig('use_brackets', true)->setUrl('http://php.example.com/'); - $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); - $this->assertEquals('http://php.example.com/?foo[0]=bar&foo[1]=baz', $req->getUrl()->__toString()); - } - - public function testSetBodyRemovesPostParameters() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar'); - $req->setBody(''); - $this->assertEquals('', $req->getBody()); - } - - public function testPostParametersPrecedeSetBodyForPost() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->setBody('Request body'); - $req->addPostParameter('foo', 'bar'); - - $this->assertEquals('foo=bar', $req->getBody()); - - $req->setMethod(HTTP_Request2::METHOD_PUT); - $this->assertEquals('Request body', $req->getBody()); - } - - public function testSetMultipartBody() - { - require_once 'HTTP/Request2/MultipartBody.php'; - - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $body = new HTTP_Request2_MultipartBody(array('foo' => 'bar'), array()); - $req->setBody($body); - $this->assertSame($body, $req->getBody()); - } - - public function testBug17460() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar') - ->setHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8'); - - $this->assertEquals('foo=bar', $req->getBody()); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testCookieJar() - { - $req = new HTTP_Request2(); - $this->assertNull($req->getCookieJar()); - - $req->setCookieJar(); - $jar = $req->getCookieJar(); - $this->assertInstanceOf('HTTP_Request2_CookieJar', $jar); - - $req2 = new HTTP_Request2(); - $req2->setCookieJar($jar); - $this->assertSame($jar, $req2->getCookieJar()); - - $req2->setCookieJar(null); - $this->assertNull($req2->getCookieJar()); - - $req2->setCookieJar('foo'); - } - - public function testAddCookieToJar() - { - $req = new HTTP_Request2(); - $req->setCookieJar(); - - try { - $req->addCookie('foo', 'bar'); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_LogicException $e) { } - - $req->setUrl('http://example.com/path/file.php'); - $req->addCookie('foo', 'bar'); - - $this->assertArrayNotHasKey('cookie', $req->getHeaders()); - $cookies = $req->getCookieJar()->getAll(); - $this->assertEquals( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => 'example.com', - 'path' => '/path/', - 'expires' => null, - 'secure' => false - ), - $cookies[0] - ); - } - - /** - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage none - */ - public function testDisallowEmptyUrls() - { - $req = new HTTP_Request2(); - $req->send(); - } - - /** - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage '/foo/bar.php' - */ - public function testDisallowRelativeUrls() - { - $req = new HTTP_Request2('/foo/bar.php'); - $req->send(); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/TestHelper.php b/vendor/pear/http_request2/tests/TestHelper.php deleted file mode 100644 index 512f6a9e6..000000000 --- a/vendor/pear/http_request2/tests/TestHelper.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Include PHPUnit dependencies based on version */ -require_once 'PHPUnit/Runner/Version.php'; - -// If running from SVN checkout, update include_path -if ('@' . 'package_version@' == '@package_version@') { - $classPath = realpath(dirname(dirname(__FILE__))); - $includePath = array_map('realpath', explode(PATH_SEPARATOR, get_include_path())); - if (0 !== ($key = array_search($classPath, $includePath))) { - if (false !== $key) { - unset($includePath[$key]); - } - set_include_path($classPath . PATH_SEPARATOR . implode(PATH_SEPARATOR, $includePath)); - } -} - -$phpunitVersion = PHPUnit_Runner_Version::id(); -if ($phpunitVersion == '@' . 'package_version@' || !version_compare($phpunitVersion, '3.8', '<=')) { - echo "This version of PHPUnit is not supported."; - exit(1); -} elseif (version_compare($phpunitVersion, '3.5.0', '>=')) { - require_once 'PHPUnit/Autoload.php'; -} else { - require_once 'PHPUnit/Framework.php'; -} - -if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') - && is_readable(dirname(__FILE__) . '/NetworkConfig.php') -) { - require_once dirname(__FILE__) . '/NetworkConfig.php'; -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_files/bug_15305 b/vendor/pear/http_request2/tests/_files/bug_15305 deleted file mode 100644 index bbf6c70006b8062fd656063ee9cbbff16edf7f04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16338 zcmV;@KP|vWR8&weF)lG6GB7Y8PiqYdL}7GgIv`YaWh@{tHXur2ZXhx+FgYMHFgi6e zIx;dKM@>`>3R7irc4cxpAWdmwa&L2QW^^q{NmDO2E-(!WP&05kAVW|+B0^PDAVXDB zAVW`1Zy-iVP9RBEL~kHZPD~(ARZ<{ONLe6LK}~NUR7Fg0A`J>tIv`X_GEh`ZQbkTe zFfk1ZSS?U*cV%*AWGzB@Iv_z)P%chIR1FGPEkSc|Ze?^WR%LQ?X>V>iATlm6E;TSW zGB*thP;y~sZDBefZf`APVPj}z4GKeHV`yb9LvL<$a&K%pAZ~9hV_{=xWeo~LZ*FvD zZgeeFd2nSqAarGTbT4RhZEQOrV`yP=b7gcrb#!JeI1LIzZ*FvDZgee0Zewp`X>Mma zAY^4`Y+-a|4GKeVZggdCbS+F}ZfA68Iv_DMIXO5D3JnVFz3Fz_NVX>WDv`|2lvLsX zfHP%EmxE*}k7cVYIbC^NZm$3kBw>L75&$JDoxZCd;{LfW&}*Ha{R(~FY!2?-VE8_ z&TlSXFukm?>o|0*xKcTNSzv`p90#3B<^KM@d|xg5;ka`1y7Gyj=u|DaEJdWagjbqH1-5X5w_em;16^;o+X^TF65Kw1HWe`k-f>V8zs{VyZeiei zvGC&3%|jpx%u;vVLM%ST6{>l}tO*Yz5qD?tsMIR3${HYlE4}HJ2L3eQv17V_!Mxjs2o$YrlWG~$h;JIyE)f~p{M*;sfi4rhXm z{BX7UH1f)pKTS%9Y~T8g>CB}ckA8gmxx>%F7C?UpkSI2vg3VS))*sWaDE{~qKnrz= zxM9St#j(-9X>2^Eu?YX}@Xux1!4pPg_o{2hVY&KKssE(v*>;6mGY0 zeg5k8&EU-qyBNHJN|}UWlu7<1Na0n+u5WU;V&U1Hu2n|-&Vh_UhWrAHA?e+MGv#AZ z`Bb9ka{=}E6z^WY>c6_V&WYvASFeUwOPEB0ht?zo$AiFiER4SIRs2AB>a8szD|7;S zdI&9r!cOd>^b6-su8}6D2v$U8p)x2dHs?(5xa!i@FRZ| z??o)|!RtMtcqp2~o44wFajr}Ncf+D*YJf4UU04IJBP%GTC+0+jO8;5w8VpwE6LSfgXzi%DS z_U|Jm=@N+$qa`91&8!K%J@?}&cTf<3E=3dxZ!E&HB!i^qF>oe&J*%kOXNn%l$Vg58 zk>7Fkv~XPc%d_v^4Tim&-n+k4E+en|`3kJi`F!n+Jz-yXoxL;eMq;n{Q`Ff@h9$l= z%EYfxDdjLT1aDPzy&{cJuZ&mSMySZ1iI(x6*?0qQ?c|c%O zF5`BjXK-D|40-rav3URt3RL#B7N{=RO89f;UPaTyJk5Qfy*ti?}>W`Y)(G~`-Q*%{d3`vAL8$qLa{I|92B$a z@A&(Jqfo@N&|~J8qqC&l97f!>FGW1@?Kx6r(NcJEiPyaFku%!=j=wYCAJ9+NN+DCJ z^}wS!RHyhc?d`o}>!RptMP3{gt)g8VcbyZb96?#c`-O7hp!4p1anc>9-ABWdQt9Bc zB#(GD`SHhn-W|Ua=-uI=IKXRu@R_hPsmJuw{ru$!1jE%ARr1J^cSj@nr~C1QNJyA> z=!aUc4hX!>9FJK9lDgoJ*yx@8zS}L#JX?$$NJ8O2KC$rg*IQ6$=zW*YijTk|BCZX6RkwCEy1=`IcXG$Cv zK^&S2)1{)iENVl6$3haBm?mGKYkpD9Q0K%PF!gFq*mnkQ)3F+1g!Z$MP{SZ38bzlI zWdZiLeM?q^7Wn+7Xb~ARe##B&PuIC26~&K5UqN#ev;ZPA7V)VoBoh6H8$NysbG2VM zKkW?*2k*4^ME67zr(F}5^uXSq9zePvq|;1aIA6XHaaB>bOX4!w|5$X;Bvs)gee|OS z);&0)@%T(ny6@cgk{c|bW07?e2}a;cWo-_QtTIW+svW`$-$NbyA&OBEQ3lLf*OQM$ z82VwCu3Vqn-CI12LaQr|f-)Qp;n{#p(%}UcLRq89Yid#w3`&IBg9iEice;U*2?%!K z063j zg3($~@R0mOsHkD{;4@E5!_hs)QS6VNnLqw$gK!}JyV2p{`}YS2M=7EB7g2sL;#Ve6 zpZ5p&7Xioyv?VoUrA_g}!vhOKjUoWiv+W^<|MU*rxuC0oQDOjStkO4y155Ec&r=aN z9(+#qa#HELyvaaA1Ma#e{GXi~;b4d_2QVM|1$biRUi9EukeOv2!l5QW#jHp|5U3AL z@xsub4iYZQvqXZb^+lBe4d!nJtnsKgRt;D*Fk|onj3-pV0eWv@gh1p`%1??MpXqT& z6eHnwZ1O*%4wT*ki2#y-!LE#t2=)jK!39XhT1gv5PDvfC^u8_Il1w>*a!Oh*qluzj zrX~)Kxa27KLxL9J8|cB&>Z8@zt2eepsHtd+#CUi)DAdvkuHeAoH++!%x>>i*!`xg91tw$Dlb; z(1J`H%&RFb!Y?likDIRO4f-gr5phDOM6^rerRoz?Q4_@iyxPlgSSV(ACt{qaaez!1 z69vJ_X>$dMxRTN`UV-om?tG+C;B#ut%J&F@#Qxs)(1Vc@FYLjG-76eFtLz;nR^qs@ zAO)Z-1|#vQb2br7Kk)rqC-3d3fik7ln)}IS;gCp6u5$F3F8%Dk`|n5Z|8fAo*&)9f z9=05~41Y@k&TJz8@kgHMkz@UYzti7$3I%BFRiv)hAT^e*uAp&Dq?fQM7P^JvSlZ=8 zV=A;s^&XjEccpvHxfVXO{?cmHWUxb{ECsM|Bt8XBD55TClsq%bvH#{~ppe@?I3Rlt zS1GGu`-mUCTm@SefxXF!1c+L51%xaxI>_Ef!kUG!V1Ttiu`Vxv^c`=%fFWEIAjN@m zwxgJE@zGDwL8bEkJvbp@gJ)6v;KCW3GmjNTh2#InnNo1hW}&;EMsO;qgrV6KRHCMg zNXrD`;OMJi_;(0R>j@NKN*EqL`>s@a=Zx6JDX{;8k#@v~)=G2lAmGmEeW{c+?Z#-G zHUEtE8y^}wBhdIW5U77xC3p^jc@B!Zu?RiL&$={J7)1+7r=A=640`MGdO2~H&oZD^ zg`=eJ(Gwm8pO*4oPipf@_%O;8X~q*FGfj^)9s5B&Np*c|+ZPeLh}lgz6DRDERxhH9 zmyE_B(~|b>3{4&BB)=0T{y+5P;{Q5FV2_t%Weo zLufR3(}0UCA^0Je5MG58qisRL&x5erP2H#`AVT=t1md-@x6}{w_04M4s2WLq_@lD^ z+X-BkEfDVW5QIIdk)JOi1db;mTuIK^2q4G<7-=(66&3m}jN=vvw|NNg1`1!^ ze>qyRofS2~XZrR7vs@m*L4cEGJ9m<0{i){^*ke4m#@i&$leU}u9ymL*VE=RAbqa5; z+4C74>HIiZ$fvoJ0^V^!4+)V-OB z$mS14_7nGJJbYkUqsR-$6Bv4+!E<#ZoYZfiDDxmxa*{EQZg?gmgl(>Ip;4T z=!C-YDF))-|CjG7JX|LaD`|EK6pY?l_AMO0zP_G=sm$Efj-_0+z;!u3Y9xH5CDf+! zXv_7-bH-cYs2s&0G^9!LW?YWLdQ6fTw#g!lz~v9XFJCyNt@{A=fjd8f=01Kl^1~_P zQq6S>-{ZmR0FgMY4h}JY`b=V4IKFlrThLVBJ&OV%>{LQh;(wp@$rh9#jc9E|(rM2M z84S2BNH7SLe=o-&hq`=Coyt7}j%awbn-lmmgwg`dR`H-_7w{m&@_3wqee!Gto#q9S zezG|HGz&7ML|WdMKK!RU4qu{M(3E3CH0aG@zceB8V6@m1e2ByFXL*EFe-=j* z&mQn(S?(3JGJ$n{i@Q=>PwP`nhbP;;fxD4(olzXp{pOWMz=h-3OCDXS#>atXrS4F(NRt1A`T(FMR z6H8;VWXVGjL4~T2<>c(u>r1j%=eqJ5e(e^H-wJb4jMl@;7CS5ej4U5~hqffR4E&Wc zhXfwCyMRy8mCHTg4X?#I19~A#Jqc~OI^r?7KU1M6f%On7FG3}uT7*jBbRK9n#A^-U zln2oq{u*$XC@=??GlVJcL1-qUaJpm(!7_yUIP_-$vD&1%(lnXztmVA%ont{B+zS** zB4>pMfm*Ou>&G@vrUIL)S^mP9qSXY)$f3D`hH`9@ZYW6s-Dn9O=~ajTkWlS+Km>Z8 zYDKDtw>eL)kgUG>6$Eg8!$q@>w)rQOH0>6QI&1;AED=Sw;sH7n?NubO6sCd&3tb2lvI zz2rrX_j2ZT0}DFS`M6Khg=ctLnSipDlgOWimLT7s=IfgF&LiKv|7K`KRd-} z)rOi;J+0RaLu=`$+76v~P#Ni!9?0k0(0@d517SJbokxA#4JOd(Y1p?@|C+5zb8uR3 zwrbUOtu@3b>DAL_yJw)!r+R&`L-*j74;?t|u^-MI#d$CDuQzvg$r>+;Evf4KQ-l}H z^5Qxk?;6@I(Jl_*;ky~-7USif6S5n}x)pI$xse68@)SoLv?=ta7-_q^WkH#VFsolU z9;gRN`0@Y>f#eL&7N3+2NHca9!){$~=#8qx ztj|49g!HUdt=4r`I36Nq@x}?>SLlN8fjgIm_$$YYkh2AfE9?-&`o5hsb(${QMeAEh zC71iosq~y~w^yL-cdmj=hQo<_tRXm%Zk)Mqu#56OLHEpwJ?O682L=yA--5+MyeO|- zf1If?qD*Bdg81AIeHm1!L3=w9URR|)d!ufN*0IW)pW&uuMgOS5q1DucV2Btt#mn&! z$3f<$DN#5%7R-k%`~h$2IRX+{>@kA6&IqL*T#jwG1B3-P{oV<>h9uBk z@;8iw?*A*VvS>#|5Xmqqokl_W_BPkiCM5{~((Bz>Vd~#Ga~6geT*?Q3&@j#-C(ED% zG~I6PTavsq=V|xVkZq+>2wA{b@i-gH!trZ7W2f?A-zT!OoqZQ^5HV5tzpAr@R01jKy&F6gp4Jw+l3oS_QNNi?GgFp1X`QRQ-be_0 z7Q)$I9Jk!00Znx~qV+-McL_kE5f$wutQ2#~$ieBFCx#c|s3xL(Z|n+fA%9QxY?%*E z>MRCQOum~Jja)?YNlA&(y2*fG;>SJ-LnPL{QFN4-6Yf&RVuf#4^p0a!j8Bl zX%&o?>4t}Trq|v6Q2S&q><{58us0_ z;s#3A+Vw`WR>`+M@Le$lx7^XjGMC>+GbbkMT{`g0BR}RT-A2T&k1A8*D<#9mq6`B^ z3f9tRkSRD)iEzy#pb&Hm-$(d^daJ_r*jlhkOd;m?TLiRvT4~lGoPC7by+N-zY#NP5 zb6D3}wc(&%9kdrDwAxrJp>JsYEEtHr_2m_VU?#RE=7?INduJLkPw$Am?5NdBjhenaQ9g|1N)fZrtj zu*CV*70#!3$)iW?7MsF*E{+AN=och`mfCvb((=7IBZn`2tSH;uX4<}8 z+KfS^+U)h}jn-+i+0d%3W~+5-^lHuFS${A%)B6k3X6PWZEU2eT@7HiXxt3?D_}tk0b>xD?SW(dQAfN7SZ_ero&@a>G7dzIuJiUcFSgHL_Rh z>;#HFY9LmFPWWVMUKZRK!BE7G<%-Z$cEJit>C$Nu*@mIFjk*du#I|xIN6e;MsQo1{eTugK3aG%g-kC*!)p*;OwA;>rP!xoNP9ye z$y%hK(~NdoYtOOL5qq-2aSuKVR2Gzg2Zxvi-0^m|_)CkE=-v}C#DLb4QPWWcrXH?^ zsGKAic87>^22kw6OS~$!r7vixdK3Ir zuc$rBILU>5OO#9x4ao#KNkijBP&o-=FO=4=CTT*qHjjC?s?`h~{ig=?DP>u zfQhky9m%Df)K2OEBb8ji;P1R-cV25@&FL0)`5Ck+t7if3JPQR!6dj{(|Wu^aL(USGA~RHT4G~} z?z}6HB%R>Ts||VURdjt(MU%2yCdKk%i0lD5VkDZ`-oUjAb2nALY9i)}b_J!ap++P= z&A1EKj2>3t2PcSM_GS*B{h| zwT50t*uNO$uXTgq?XYMnTo8axz+%4I=S9v>&y6v5w$IdR)5>!Z!^u@Q%VGW32Iv1E z;wI*&nH=>s@_jp^urKiM!TA#>Vy0Bqi@A(HSzHP%TOZS3@a)SWK+x$BCvOU!(~d%vD(qP zCJ|C=)YQ%^NlJ>+3dc82fDj(4PlV8V;Guh^JrD~AB8J7JAmvfwMJ^PWVroQyhSscV z4M~h@OA_On-gg)+OoSgkHbGcMne?owOxf#43igeb#UEn|jkQ z>b1sj(ANjmMq|*^n~PI~YqjN>;|iwI#E84E`INoJctIeQoW5{8JK_)Qg-_Feq(iR+ z3B$jHd@909@9K|Io4ZqH0i_PxdkYuKvDwR4H_QZs-LhHm-Ch!WY!T44jaBP7dF*PPL8H7b(OxhAi89Fn5EzUL3W2_}!U zM4w2R_c`MFkh8ZKx-2KOq0yxkIqJ5OrFKfD6UGypKSZj(MoX`1h2wtuRH~m4u`bPv zT*u-by0nN3DD{Lj`u@GM;KpVHzg9WTmw({0@&F%(UL z7BTgn){+5?D!6nYCRJlpZQFY8Rl&|ON2KnSH##hlPpw5)Pb=GYI*{nf_HvsWB0M|; z*D?jPNNvHDmD|g38PbAb4CczV2h>}$?IEJsGP&=8R=wu-J-|80kU@-s3dzQVN88SJ zF2D($uUaJ9qBrZdPHf)@@tmUhEqfmpH9S{}l;}&CBp{cx{I4@^>l#$;Mn9XE2u?O& zaIEEnWLHZX<33fzZ%HC9HMp>951xkVk&I<-AhREx9}MlPjGuGJGl;dDh9A}{gQ0PD zc4`d!{aQ^oprd+yLp#%I+F5V-xPDh{v#T;w?IwP(i6QpcX&LIw4xRB#{It+*r|OOV z{()FC(d-c^}0XV=7;MOB+9dj}B=mzVF6dwlem+tF2KnmKMvm zmksz@o4E^pUkmuy7C(ILPo0msj>;VNB`slK0Qd8O{r4T~kL69!?i!xT zphGrh*Ll55#@l{;%|<^YL7SFxs@`!O9ih0aT~ z7ni3lrwHmWxz%K6wcN)ncb_CnxEJlt4@UFl;Nlv8&^;a=+D_!(d%`|6A27Pn;YhAv zUg-42#f_X(vLh94=4wM^YXbD4d563qJlb8}ofMsJsUKINCKu1p{z5muEC9o^O z%$0ueXQdvxNTW;yk_&^A008e4Qh$Ejyg0>-n9M~e!(D6U%A+q8W;;1ly;fzY_0MWr zyKfjhy?u73*Xu0=8r617Yo9Hxs$J_+J(piNU~=M)_K}*>r;?5nyOtXhD+9`@{9!4@ z-FlxmP=n-!pxv$^Lr?;@hcayBm?gXXO5@ z6QQ^7MrRDo@*isr=SvW&G|ZdX7W1lEp7{w596v81yE6Dg`6i zoXU-9#3x3qwbZ^ei^nk5at{f`w2)2^g20|6F^Y6Uxm*a6HIm0GW1hA8czLnTuQTVj z4~U>EBR=(K(Fgj@hoC>sZ}I~vbleKPKxjoT@W=TLB!Zh8afgmIdun#E7= z-7&Y}i%vNXL6N6mxuy4;kE z;}c7t0D5$P9=kVx`v@1yX0+jh)|BMb*@iwZ4Rm697SY*eA`(YE7%P`?cX|{q%8D_R8c_ z-eE6ko+y+%9HQ8n&RnPk({Ww4|6GI|T|XBgWeol^^1Z76k03?}u;1BkKmo8;uW6OL zpeq}wR+UHpeR{XcDKQ)H1+g2|X5siv`DMAosv4z)6}F*sE7aQY=lnMg12=)){uaFT zR#i=JOT6iBSG-AJ?uEEbA?q;6v^;_Mot}5t0CBe@IfF5VO=jn~j*9Fe_R@ zwPvji%@IJ$Giw${%(CpFw%7^M zXKGo(H)u3!bM5}m%a^e7ul~laT=W2}CD46vP zlJ6^*NwylbT7|&EeV*CT$r)HrMdh;Tv*%rK(T6K15J~H@*jBx;+TzqT=PklewJQH2 z9!gi>KUyu|Iy8Y(dJUcr{ZceT;DJ!vF4eV?JRKqBX!KuJp>3$LN)g^OdGItbj~kPF zv|+EVsc)z~5ywTU7>!ot8a{p;?Uninb)wQef{D_r(MWg^QR_;c{8;iwC0Y)cLy;D+ zX2qB)M)Ru_gHcfiEd7~h(XowRPsDn=+Nh|AGwPIjd-PFD#O%)I*;*DB;EaCNg;*S?npyC9WhGC2pW-qnLX-!}z3)YG+84&F=enh9Fu)w!Cu(yblWFs9d;!c`Kt3bo zW6E7_KiM{`RacswnIqC62nebCdNoh4b~>@)&)4y$>yJ0=t%>~rq_S?K%E>73x^xK5 z4~FJ=_6$zZ11`s*e;-e9!DIY@F>U;Tw4;?>bbrgJ4E5Ssy*KFB&U&@lsnI_j_M5%o zuzJ=qPIvHnd+hloy8=Ht++ufPLTiLzXW@+`X%ZJ+1AQ=uJr^E1!0Zyd8Afd2hu{gh z(@HL55g~23lBT0i?()?P#N?j;rz|Y{b4X6-0739oNv6utk_IY6TZgvlr;RR{UTZfH zR>8i~HV{Tk3Iz>XquhQjh;ztY2JH#M@Q-_evqLdjB~71eiLL(f9NBj1Z~ zbw8o*TOrt(dJdhYo`*9!nnqLCD5$iCzK7`PKmN!6 zPx+<*+~WKO3WOqdLK)qI7<_RpS;iV`HSE(!aqovPj5N~RgjH3z&K&&3It7zs;}43$ARYE*<}p| zI!RV$b@|1bKH4JYj#R|ft;%OTbtMK$sd_Rq_*c3Fs>|yxvQleSUtB*-P2b(L0;2{M zlOUm1VC0UW{B^!Q0&S-asC5_g1ZEO8SmH$Kp+A1v#oB2;>hCO);`#H3qEsDV;WK!XtNsQ$@ zdUD`0q8v*d*F5!QK^l98(U9REKQxo4FWmuDzV z-$aN*x=eBAVF;EmO>iPE{d<+Lj3@GNmv|zJs@E4Z&y>CfC(HY+Ogc`p5blJ9fm4-U zkkUx%K(Ofcu__3I(8IJ6MqE8m)hdKNu2fIx^A6OZ6jW-aVjC8g_7ve6btQf8%mPLo zCJJ6h+)`+O|XkR`jnkLT` zA@y>tx}K0JQ2hSi!?B?0wY0BSPh#3?wOp%xJxS~3cAF^LHk##HowyVa_UVV{sh*~M z*{H80XC=`D6{%|RcY|rqCgl?V>QAoRhPfL_Nx4*PYuI)P8t12Ol4=VxHa6?j2vBP6A+*eN~XLzY2 z>a?4RUauL|T7B&qb;-MwsMqILH-A$^r4_nWwX@^K52SlU=ew|Eri9zoZrO+?JfOO zd!@Frh)l^{Q+WC`cKAg#U)MG_Usp#gY!)4no~^KJqyL&Ts&8pj-EVA^_N6|lQN*(f z@cM%+lXu%2?FFPmpYYwF6(sZoiRu<4)LM&;NF-ZZ*K+GF%OHVe?&%XI^1)dfXYv=@ zShtw%E3EJngWvP$24})Y>59jwHHj!FHwIl9u zJ$6`hwSrnTL2ZkPuIEkkb#GWWej~RG{Wlmn;9>eSRg@&Sq~RH)JAs~tN-aTUi&3uU zjj}|A=3-eyXH>($6<%}1)xu@3>6o69B3K;4;yn$MdV8OUs@ z9Azn4==)Pj4A9?iP*sftxh)2`o;Sd2kh=oQlqk)Vx(2Ynw6K~y8Q1seNTM}LY+1KR zXLc5@_hTFB?n(40r%_gX%}uH*+d=h27as`S$ytu4x%f%71sDJN&1-o_EU5&a;j4ILH9*pZNa?{Mc_WDuSEV}oZ;Z5>CYj8M~uNss|u;hr2MQqijf zBf*n9-cunWwD_&~1yXr_MXMFT3-k>cJfDjy)yUzyJfM#aT8g_b6L$0E7mMh#fK`KOof1!T+9i ze*o7IR!GI5Yhw!3izk%Qkm9QnfOI6AA7;V-N`(o1qw?i!YN~l{$~vIW@Shiw`RWsg zN}a3Eo24L7{{yLn<7bNgX$~6%)1Ot;v*mZtQpTotaLlTk-qi}nwN393!`C;xgB#J< z^sZSrZf<(lDjc^qy=xba5pu47r-LnZZT_~RNS2JtX?|Pg(!i{vF1Y2N)XlxyPF-l0 zYys$_q>TcaX;}jQPts;@7fE~Of65l1JxbcC+$6dL{-31H-Y#)1#dcksUL>D+J@dW!2HnLSA?=n1BBuq}2qoo&>K2bSHP`p# zS8dA5W@{z!P@ZwOCOu0o(nNicj1ZQa71ig-sO>cCN=;3s)191}?O6ahD>?P;nM)R2 z*b(~)F79>W`1;JGT{)CVw<$Q19)%hD_Yv)VU7Imjq=)g6_JRn-~D_(X5Zy8qI zv`bdgsFiBEFiK|CYL!~H-EQ%^W?Po>o9Tk*}tyFDmc8NCV1DiG~Xw}-N*)WARQi1uLyz(~YW_Mau5h2BVHH7I^6(C7k0dWv$ zr{z#*6+<4u-#QyM`t53KFw|@H)|t^7v|5e9U~xkmnwe)_5L6_om$#skoY#hMh3v00 z?y-R%Aq-B|EZ&GuJYp|=Z#?noOm~c{O!k9+>9z1|_8TQTXeHFppN(l{EeWFtE6=wq zh01XZ4Hxlg?VoJ1!WPG84%~Q7C$6}xCw=QgB0()l$bXV-nPhY2rHiSaKxrKjUXo#)(j zMflK}-gahDCmMB#1MUQ^c8!O0h}d1!QQcodnMlzrN0=KB;#FkA&d_cQwQP&*&?BE@ zdbHC`vtfuf2M;w(vs7!;&}m)Q!40Oawd$g7*(w{ijipBQy4kjBqGXyiy;N(O;F_9f zmMmQ~o0e!aY`qFz(d$icsa-7@BMt0pS4SvTw@dA+R?{`xY*jf&F%6v9(0RMm99eCk zq!CML?Gm?|t&yl}x)>>x*0GeXx7rQ8Uai;LMy+t%gHcr{cDsB$gRzEkG?NAQUr#j1 zhyiXeN^QFZRyTDJt!>vzx>+;OZ=s2iIzW9J(OS)s-fU>CQd=8A4o8+&YU_qsYB%g= z+ithpqbd>2Fio(ZIV#mHP_)(@nI%4Im?g7W*9{HA31LJryHRh{8m3;-+f4!5js!-u zUMmTRHaF_}sMg#c!=g=5(z+%rsdAun3Tzf;fe-G?> z;@|IWMMRz~PdF?s`E2N|TC1&B?gCo;3ck_Wv`0%``BPDL3_!KZ01aH{@yNjY_Ax&9Xj)&$nA~*CV8Q~8=wm=K@JaTF0A6*id0vxFWhx++x!EN#!B{K`YE^5u zs`XZd)-hY$&F%NyAnSGGy@$V_FU$lXN zONIn6Q>Jk}aKjEflOLH4arhHP=n28+KQtbPY~(&lxS2ZZiSh)7`>#R}1dRTM&8<5S zY&2AKt_i9<8cObPvJZn(H{hX(Cex#RXku=z`d5Hr1j6|_ zFfZkHHSU(43x6E)VB%P%D@wqXr1g&C(p&m0W0)S9gYqcJWD%CU+S=R*L?!;oX1wL` zXgpwNN&LOF_R4D6#Na^dxenZI`p894g1^`*1@H(<*<)I*S3x9flcQZpx0e$8b(3pa zk=oe>j8qPrz9B%`Lu(X{uc+F&s`2w>Grl$aPwPQkfuRMWo?OY)Zayl73XL3It`%&Zsz*{#7GWKq%A+Z^gPi({ zCu~prd;0D{1cWZ>6}zFkJc#Y;Vr43lyTOE;BGnj|loa`o|M5TP5Vxv{>=Z2-uqxVZ zRu{XdiZM{hs7^_(NRG_nvM^{0yrDBKWQ$uVI5(QQ1^+LK-S7jtLtllb=zNH)(hPQ( z7Fgaqy1G4ev6OIbh(ub+s{J$ z`ORw~p1;PRpTX0dAB4C8*xEdf<5`tnjGz-7jW(og({u#X{Z$ByM+wrWk@tS`aPPRZ zLY2M}i(o#r=;RbFku}fYe()eCU;tG*VE_Byqq z?*_x(P4C@bD*L0EC$-)_Kltp7==T!DIln3^VJ@5S(e?}9t8DQxfyY0YDA(D{EfhaT zqmEu2nfM`%cSD*W>J;R3#P5_W{QZ&#QQ^zMQ3Ce{`1Jix=MLOd1zhT0sWHm(hz3=3 z&0I%;o~QnE`3%)4cb~+Tq*ZaR(PHzYDPoK=jb_>l7`#a0Z|T6?@@>&6To#J6(CrlX zNB*gDjuMJJi%_KUY#j0nyB5I)MF%v`wWiN0g5Q+wVWX>!;M8q zAmbsnUw_^|D5{xLjKhqg)FK@^>cWG916?i@C#Dla@$gwZ=}>!Dv}J)dP6+$L1LwN@ z0k7q3Vn@rVAlQ;inFmd=O2XmdXHsmPcb^@*lgz3V1NbFDY;+3OT@(nZ;8doFFR9Rd6&m6164G<84Vo!ULJC>yFY zf${(fo(ES|P+M9l*u&4-mqIc6X4r|-D=WD+J(fPPgl;=gK=hn&4=N6HVe+vBP8f|k zS}~xhTB$FJ6gPrHpg{0nG4Np$E{jItOHqVztHRyCsKS#Fm~Qn6HlGkd5Rwk4DHPd(*GnD9W;4>V=`?{X{dTEzlJXx6 zV1^>g2{PPrpVl$M$|R`hdJ_9tQB=9tE5N24c;mvC_r+WB&?&shsYsH8S3zoDQ-KG2 zkDN}yhuqAjslLaUOIp!GP)0qR8?4C;7D7FoTbl_6HhGwti=5Sw`*X^x3J2{IJ^WnR zr28-VU0ODw7U@Ge29Pwd8qqFQ>7x)l6Pm?DS*4~Eb9Qh9_hnxEV1D^ddtX)w)7THX z1+9>_{#x8!1OONRs}l?$!UOu2rr7spt}CH^w-1-~;`Hy)Vf|hCy{1* zjOBE|ED~Xlz6^12kieAZ(>d0SW8J!Q6@DM`ARr$29D`X09lcZ4ejmeWs+Zs`=|*W3 zcJwL;^X1Dy`KRlB0w$H&Pf;;tl|{&fVpfK-GN8C3>XO?;7yJ4_rSkqgyhG&z9@A+f z@0<~HV|H=Mns~F_W1KsQ2cH#wDVM6{uOD;EUzeEmV^nd()bXT|_+XSjf(x`&)N`o4 UqXW}M?@J}%n;dIGhvOgrAChp`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EcWoB$)bY%?+LvLy2Ixyzc-Rn7vppbKBJUqHP$M zs+QDRO?gGuv~{N4n?+u!dPfhYF0D`7yjhW{-Cxr-UTK#3L!K#4;8SjCt?M#x8oi`- zZ8rH556wz7_(vm0QJ8IBJyK?>WzKu7r)o{5Zr*#)@b!SsF6 zU$CHNmxKeBCTmMwHEQ3hOSHjYrKVCfy3SQ$kD9waVX@nP%A_OscHjoBQl+K~jN3&= z2xw`cc?y8akgk@d#zdeJGMA>&)DdoMpBQy9k@SGoj-oXW&6a!GPY5>TJTEm5Mb(Xm z<#RBgYg2bwo-X>dF0`_&CKzW8J@RSzZM|9#D&2qrbNFFEvmVX2fRt*t=as3VK#(Ks z<7Ho;BRUb(daV`f&f4X*)5rf;DqR*=`Wz?Gy=h(g91X`Q(cNL#VWLlzGWDPK&}%UM z+*XxIAbP;F>-~>| zbCYoZ*X;t+xxz?qa_)XVV3pqPjmw?I!$=jKt@VOqT6tdh?|_8LRtLA+<}ffw|A_Wr zY>)E@tSt&Mr+sYImJ4?R`4?60%wr8`+}U3#i%hJ1hZXPJ3XLa4YgOZzwFP?DC+m`Q zi1%Q97T&Q{#a8XCo36ZS9d_q@O`nlB;Y^kGBn|r3=N=r|iZf>@TNz^yIcy8|r?|Tm zU*zSKszO)Wh1GwxIM)Xi&M|kpkBl)1&G{E1G-N8>TLEBJ=K(C+(M7s%4xl>Y-kku# z=%b`s6pqQ6@L8=fy32DSIAZ;$ZNS$3(^svVDLT8{LOyHshTZB53qLqtmtSRnR%VN1 z`p9ngzI%C*a=qSrF!fo{F12+e_s7V`C~94xCmWR)jt9?XxBu5w)2!cLUT(MBL4PC;Xf_pLN~s8@^yyQOAo$rc z3c?Y2L3mH%<17|Qf{js3aypwxJR)fvgsBvXPcj@%<|7&2_;fW-DU4E@$f-;bmPWqE zwVrOH=$fV?9**(f;7U$pdhbeJ%QQqax<;{pyjc*ZayXv^G0o=jEJ_41osmq2lR!?z z2$m#6)FdzgiDVp1CVP6`6MD=bO=uW}X)FOYiW9mLfE!#*L{}4xM=}<})F)4d`$uqu zc7QtZDVd3(h-Jb7vMYNRpyu3h=5_&9_joe3zH2JUYYIlU$T9NzV9Y@x`=N1~ z4adFU82s;amrT#TxiD4>FK`~PF-41yI4(|Xw?}&@6|4nzR>CAa{yyU7(()w+9=Ome zRXpsi@Mv~i=hWLWRk`nacT0d@ZE{7TgaMFxa%u2z;ehYee8Xi^>TXizOTXOT$oLH$ z=d;cl%yxetv08u4OgLR8&weF)lG6GB7Y8PfHC7L}7GgIv_@JX)GWxF(67|ZXhx+F)$!7GCD9b zIxsXKM@>`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EfdTDSC3PW#hZe?S1X>V>iAY*KAb7c(*4GJHN z2nc&(dPe{QGhZ+_>yFXk@L}ZnzWNCEx{IMBvK_QJMJkE z1zSu>LM2FP)L-AXAoUez(nC`nVuo1kzV~+Vh?g(_`;R<&@=I5mX5$%6@=RA&`?S%u z%}qsb2d`dxL$lu1`Qxgg=h+K-{qEg6dP#3yz54mE@1{2GdO$%@kPEa_Ypd&xUJktP z02!FQSTA$i)cK-q7?`S-)LKn>Mb@-+rrn!GUa5LV52h}yPusj%k*VEZ(>7jdmia@T zDNf*1ZfULSGH)8aq;+jJ`4SJ!N;UXLBS%q~ZC*W6W~yb*d#tBwO{H$$d(iOpfX*>l zG7oz&nOP#TwGD)56hLxHwJ;lA>ecM}P?-jz`v?G_0_ix*v81DQjt4cfLgl5d2Oc-` z%~K#Kcp}9f2uLnlfcsytpk|kZ1C}OhOIXZs!C5HRbh{syFOvD+keWW zBlvdU2CY)1rVEVQMMnr|X`y)vfXa}rmZru;pb|2drqR?9Zfu_zbup3jfYpwoH4n{} zd)iM3Hsm}nH4jDAjfdrPFraHwcUhh;`m`>zvaBW;XAM2_Y4~luS`RASfC6*)VL-DU z&9{J*YPaW=siHuTBkbd4U!Nm75!8CE73 zVc21!Pn0tCpZ3seF#g&ISKEcvf3-N*2NljSce{^_F$vB27a}xdD&1QFU{>b= zEZfmVx^E7kI^*7*0K({_q*@e?$(it3tueaGb0Rom{ikif*8S60t(z%2yWB!PYxIWQ z>I(}$IA51vWq(#?i(~r8Zuh=>d69Cx-g_|hSK{}QRCDCvp0XB*gx)OjJTunq* z6O2bP7Q@shPlo$PaD;Y%I`Ju)iJ{~N@lk+R5a0Wp7)cZH`y4@7q){*pZa~v}{%v`< zEyH;%97br8%&(GErt?(LO%#n1&g>;3zLi6f{6do`anj8b;iEI<^oiitjlo%iucU)7@C$eazZAu>y$TB@k_x zo`#_wG)(D8l0tDakvAe73SNyk%biTb3onRe!U3`?dl#VQ+;Qf10af>SGPS;ID#>dK zMz_c@^7>%RK_dI1aheUsz2F%9?{t?;&%U`ZRtqn19IQszs)+~3If4IJmQ&Kk^ie;=`0f6YujAUnq&oQV_sf$I~A>M^grW=^W{P80o& S;6Y|eWcmj?o~>Y#3;+OD2L>Ae diff --git a/vendor/pear/http_request2/tests/_files/response_gzip_broken b/vendor/pear/http_request2/tests/_files/response_gzip_broken deleted file mode 100644 index 0df0d1522f8a377ac905b20db95eb29dc1428493..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 221 zcmYL?%}N6?6h;efN+8eRT~;ueWJaY%T=?6flnywGJBjI~4V0T9bJ1yi1fR$Eb8zGK zJBRblo2D+Twon=a%SS10J)?vB9FM_Rcbtr`thu`Dz*ZY1pI;h@^)!g&w=VkE=MxZ~{ diff --git a/vendor/pear/http_request2/tests/_files/response_headers b/vendor/pear/http_request2/tests/_files/response_headers deleted file mode 100644 index f60787bd5..000000000 --- a/vendor/pear/http_request2/tests/_files/response_headers +++ /dev/null @@ -1,12 +0,0 @@ -HTTP/1.1 200 OK -Date: Fri, 01 Jan 2010 02:03:04 GMT -Vary: accept-charset -Server: Apache/3.0.1 (Unix) -X-Powered-By: PHP/6.2.2 -Vary: user-agent -Content-Type: text/html; - charset=windows-1251 -Content-Length: 32 -Connection: close - -Nothing to see here, move along. \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/basicauth.php b/vendor/pear/http_request2/tests/_network/basicauth.php deleted file mode 100644 index 740df638c..000000000 --- a/vendor/pear/http_request2/tests/_network/basicauth.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null; -$pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null; -$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; -$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; - -if (!$user || !$pass || $user != $wantedUser || $pass != $wantedPass) { - header('WWW-Authenticate: Basic realm="HTTP_Request2 tests"', true, 401); - echo "Login required"; -} else { - echo "Username={$user};Password={$pass}"; -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/bug19934.php b/vendor/pear/http_request2/tests/_network/bug19934.php deleted file mode 100644 index 059387107..000000000 --- a/vendor/pear/http_request2/tests/_network/bug19934.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 10; $j++) { - echo str_repeat((string)$j, 98) . "\r\n"; - } - flush(); - usleep(50000); -} \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/cookies.php b/vendor/pear/http_request2/tests/_network/cookies.php deleted file mode 100644 index 821b1b19f..000000000 --- a/vendor/pear/http_request2/tests/_network/cookies.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_COOKIE); -echo serialize($_COOKIE); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/digestauth.php b/vendor/pear/http_request2/tests/_network/digestauth.php deleted file mode 100644 index 30c4e0d81..000000000 --- a/vendor/pear/http_request2/tests/_network/digestauth.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Mostly borrowed from PHP manual and Socket Adapter implementation - * - * @link http://php.net/manual/en/features.http-auth.php - */ - -/** - * Parses the Digest auth header - * - * @param string $txt - */ -function http_digest_parse($txt) -{ - $token = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - $quoted = '"(?:\\\\.|[^\\\\"])*"'; - - // protect against missing data - $needed_parts = array_flip(array('nonce', 'nc', 'cnonce', 'qop', 'username', 'uri', 'response')); - $data = array(); - - preg_match_all("!({$token})\\s*=\\s*({$token}|{$quoted})!", $txt, $matches); - for ($i = 0; $i < count($matches[0]); $i++) { - // ignore unneeded parameters - if (isset($needed_parts[$matches[1][$i]])) { - unset($needed_parts[$matches[1][$i]]); - if ('"' == substr($matches[2][$i], 0, 1)) { - $data[$matches[1][$i]] = substr($matches[2][$i], 1, -1); - } else { - $data[$matches[1][$i]] = $matches[2][$i]; - } - } - } - - return !empty($needed_parts) ? false : $data; -} - -$realm = 'HTTP_Request2 tests'; -$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; -$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; -$validAuth = false; - -if (!empty($_SERVER['PHP_AUTH_DIGEST']) - && ($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) - && $wantedUser == $data['username'] -) { - // generate the valid response - $a1 = md5($data['username'] . ':' . $realm . ':' . $wantedPass); - $a2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); - $response = md5($a1. ':' . $data['nonce'] . ':' . $data['nc'] . ':' - . $data['cnonce'] . ':' . $data['qop'] . ':' . $a2); - - // check valid response against existing one - $validAuth = ($data['response'] == $response); -} - -if (!$validAuth || empty($_SERVER['PHP_AUTH_DIGEST'])) { - header('WWW-Authenticate: Digest realm="' . $realm . - '",qop="auth",nonce="' . uniqid() . '"', true, 401); - echo "Login required"; -} else { - echo "Username={$user}"; -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/getparameters.php b/vendor/pear/http_request2/tests/_network/getparameters.php deleted file mode 100644 index 7c92f7036..000000000 --- a/vendor/pear/http_request2/tests/_network/getparameters.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_GET); -echo serialize($_GET); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/postparameters.php b/vendor/pear/http_request2/tests/_network/postparameters.php deleted file mode 100644 index ce67cbc4c..000000000 --- a/vendor/pear/http_request2/tests/_network/postparameters.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_POST); -echo serialize($_POST); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/rawpostdata.php b/vendor/pear/http_request2/tests/_network/rawpostdata.php deleted file mode 100644 index 8a39c2f57..000000000 --- a/vendor/pear/http_request2/tests/_network/rawpostdata.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -readfile('php://input'); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/redirects.php b/vendor/pear/http_request2/tests/_network/redirects.php deleted file mode 100644 index 4af8c0841..000000000 --- a/vendor/pear/http_request2/tests/_network/redirects.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$redirects = isset($_GET['redirects'])? $_GET['redirects']: 1; -$https = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS'])); -$special = isset($_GET['special'])? $_GET['special']: null; - -if ('ftp' == $special) { - header('Location: ftp://localhost/pub/exploit.exe', true, 301); - -} elseif ('relative' == $special) { - header('Location: ./getparameters.php?msg=did%20relative%20redirect', true, 302); - -} elseif ('cookie' == $special) { - setcookie('cookie_on_redirect', 'success'); - header('Location: ./cookies.php', true, 302); - -} elseif ($redirects > 0) { - $url = ($https? 'https': 'http') . '://' . $_SERVER['SERVER_NAME'] - . (($https && 443 == $_SERVER['SERVER_PORT'] || !$https && 80 == $_SERVER['SERVER_PORT']) - ? '' : ':' . $_SERVER['SERVER_PORT']) - . $_SERVER['PHP_SELF'] . '?redirects=' . (--$redirects); - header('Location: ' . $url, true, 302); - -} else { - echo "Method=" . $_SERVER['REQUEST_METHOD'] . ';'; - var_dump($_POST); - var_dump($_GET); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/setcookie.php b/vendor/pear/http_request2/tests/_network/setcookie.php deleted file mode 100644 index 0af79dfb6..000000000 --- a/vendor/pear/http_request2/tests/_network/setcookie.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$name = empty($_GET['name'])? 'foo': $_GET['name']; -$value = empty($_GET['value'])? 'bar': $_GET['value']; - -setcookie($name, $value); - -echo "Cookie set!"; -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/timeout.php b/vendor/pear/http_request2/tests/_network/timeout.php deleted file mode 100644 index 03bba7415..000000000 --- a/vendor/pear/http_request2/tests/_network/timeout.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -sleep(5); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/uploads.php b/vendor/pear/http_request2/tests/_network/uploads.php deleted file mode 100644 index 28c0f299c..000000000 --- a/vendor/pear/http_request2/tests/_network/uploads.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (isset($_GET['slowpoke'])) { - sleep(3); -} - -if (!empty($_FILES)) { - foreach ($_FILES as $name => $file) { - if (is_array($file['name'])) { - foreach($file['name'] as $k => $v) { - echo "{$name}[{$k}] {$v} {$file['type'][$k]} {$file['size'][$k]}\n"; - } - } else { - echo "{$name} {$file['name']} {$file['type']} {$file['size']}\n"; - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/net_url2/.gitignore b/vendor/pear/net_url2/.gitignore deleted file mode 100644 index 0e7f38ac3..000000000 --- a/vendor/pear/net_url2/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# pear related -/Net_URL2-*.tgz - -# composer related -vendor/ -/composer.lock -/composer.phar diff --git a/vendor/pear/net_url2/.scrutinizer.yml b/vendor/pear/net_url2/.scrutinizer.yml deleted file mode 100644 index bfdb37388..000000000 --- a/vendor/pear/net_url2/.scrutinizer.yml +++ /dev/null @@ -1,38 +0,0 @@ -filter: - excluded_paths: - - 'docs/*' -tools: - php_code_coverage: - enabled: true - test_command: phpunit - php_cpd: - excluded_dirs: - - tests - filter: - excluded_paths: [] - php_pdepend: - excluded_dirs: - - tests - php_hhvm: - filter: - excluded_paths: [] - php_mess_detector: - filter: - excluded_paths: [] - php_analyzer: - enabled: true - filter: - excluded_paths: ['docs/*'] - php_code_sniffer: - enabled: true - filter: - excluded_paths: ['docs/*'] - config: - tab_width: 4 - encoding: utf8 - ruleset: ~ - standard: PEAR - php_loc: - excluded_dirs: - - tests - - docs diff --git a/vendor/pear/net_url2/.travis.yml b/vendor/pear/net_url2/.travis.yml deleted file mode 100644 index a3e7bdc49..000000000 --- a/vendor/pear/net_url2/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php - -php: - - 5.2 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm - - hhvm-nightly - -matrix: - allow_failures: - - php: hhvm-nightly - -script: phpunit --coverage-text tests/Net diff --git a/vendor/pear/net_url2/Net/URL2.php b/vendor/pear/net_url2/Net/URL2.php deleted file mode 100755 index dba48ce04..000000000 --- a/vendor/pear/net_url2/Net/URL2.php +++ /dev/null @@ -1,1219 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version CVS: $Id$ - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * Drop zero-based integer sequences in query using PHP's [] notation. Default - * is true. - */ - const OPTION_DROP_SEQUENCE = 'drop_sequence'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_DROP_SEQUENCE => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - * - * @uses self::parseUrl() - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - $this->parseUrl($url); - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return $this - * @see getScheme - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - return $this; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('(:.*$)', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return $this - */ - public function setUserinfo($userinfo, $password = false) - { - if ($password !== false) { - $userinfo .= ':' . $password; - } - - if ($userinfo !== false) { - $userinfo = $this->_encodeData($userinfo); - } - - $this->_userinfo = $userinfo; - return $this; - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return $this - */ - public function setHost($host) - { - $this->_host = $host; - return $this; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return $this - */ - public function setPort($port) - { - $this->_port = $port; - return $this; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (false === $this->_host) { - return false; - } - - $authority = ''; - - if (strlen($this->_userinfo)) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|bool $authority a hostname or an IP address, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return $this - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - - if ('' === $authority) { - $this->_host = $authority; - return $this; - } - - if (!preg_match('(^(([^\@]*)\@)?(.+?)(:(\d*))?$)', $authority, $matches)) { - return $this; - } - - if ($matches[1]) { - $this->_userinfo = $this->_encodeData($matches[2]); - } - - $this->_host = $matches[3]; - - if (isset($matches[5]) && strlen($matches[5])) { - $this->_port = $matches[5]; - } - return $this; - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return $this - */ - public function setPath($path) - { - $this->_path = $path; - return $this; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see getQueryVariables - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return $this - * @see setQueryVariables - */ - public function setQuery($query) - { - $this->_query = $query; - return $this; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return $this - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - return $this; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $separator = $this->getOption(self::OPTION_SEPARATOR_INPUT); - $encodeKeys = $this->getOption(self::OPTION_ENCODE_KEYS); - $useBrackets = $this->getOption(self::OPTION_USE_BRACKETS); - - $return = array(); - - for ($part = strtok($this->_query, $separator); - strlen($part); - $part = strtok($separator) - ) { - list($key, $value) = explode('=', $part, 2) + array(1 => ''); - - if ($encodeKeys) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($useBrackets) { - $return = $this->_queryArrayByKey($key, $value, $return); - } else { - if (isset($return[$key])) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - } - - return $return; - } - - /** - * Parse a single query key=value pair into an existing php array - * - * @param string $key query-key - * @param string $value query-value - * @param array $array of existing query variables (if any) - * - * @return mixed - */ - private function _queryArrayByKey($key, $value, array $array = array()) - { - if (!strlen($key)) { - return $array; - } - - $offset = $this->_queryKeyBracketOffset($key); - if ($offset === false) { - $name = $key; - } else { - $name = substr($key, 0, $offset); - } - - if (!strlen($name)) { - return $array; - } - - if (!$offset) { - // named value - $array[$name] = $value; - } else { - // array - $brackets = substr($key, $offset); - if (!isset($array[$name])) { - $array[$name] = null; - } - $array[$name] = $this->_queryArrayByBrackets( - $brackets, $value, $array[$name] - ); - } - - return $array; - } - - /** - * Parse a key-buffer to place value in array - * - * @param string $buffer to consume all keys from - * @param string $value to be set/add - * @param array $array to traverse and set/add value in - * - * @throws Exception - * @return array - */ - private function _queryArrayByBrackets($buffer, $value, array $array = null) - { - $entry = &$array; - - for ($iteration = 0; strlen($buffer); $iteration++) { - $open = $this->_queryKeyBracketOffset($buffer); - if ($open !== 0) { - // Opening bracket [ must exist at offset 0, if not, there is - // no bracket to parse and the value dropped. - // if this happens in the first iteration, this is flawed, see - // as well the second exception below. - if ($iteration) { - break; - } - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Opening bracket [ must exist at offset 0' - ); - // @codeCoverageIgnoreEnd - } - - $close = strpos($buffer, ']', 1); - if (!$close) { - // this error condition should never be reached as this is a - // private method and bracket pairs are checked beforehand. - // See as well the first exception for the opening bracket. - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Closing bracket ] must exist, not found' - ); - // @codeCoverageIgnoreEnd - } - - $index = substr($buffer, 1, $close - 1); - if (strlen($index)) { - $entry = &$entry[$index]; - } else { - if (!is_array($entry)) { - $entry = array(); - } - $entry[] = &$new; - $entry = &$new; - unset($new); - } - $buffer = substr($buffer, $close + 1); - } - - $entry = $value; - - return $array; - } - - /** - * Query-key has brackets ("...[]") - * - * @param string $key query-key - * - * @return bool|int offset of opening bracket, false if no brackets - */ - private function _queryKeyBracketOffset($key) - { - if (false !== $open = strpos($key, '[') - and false === strpos($key, ']', $open + 1) - ) { - $open = false; - } - - return $open; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return $this - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - $this->_query = $this->buildQuery( - $array, - $this->getOption(self::OPTION_SEPARATOR_OUTPUT) - ); - } - return $this; - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return $this - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - return $this; - } - - /** - * Removes the specified variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ''; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority === false && strtolower($this->_scheme) === 'file') { - $authority = ''; - } - - $url .= $this->_buildAuthorityAndPath($authority, $this->_path); - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Put authority and path together, wrapping authority - * into proper separators/terminators. - * - * @param string|bool $authority authority - * @param string $path path - * - * @return string - */ - private function _buildAuthorityAndPath($authority, $path) - { - if ($authority === false) { - return $path; - } - - $terminator = ($path !== '' && $path[0] !== '/') ? '/' : ''; - - return '//' . $authority . $terminator . $path; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @link https://php.net/language.oop5.magic#object.tostring - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Normalizes the URL - * - * See RFC 3986, Section 6. Normalization and Comparison - * - * @link https://tools.ietf.org/html/rfc3986#section-6 - * - * @return void - */ - public function normalize() - { - // See RFC 3986, section 6 - - // Scheme is case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostname is case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ('' === $this->_port - || $this->_port - && $this->_scheme - && $this->_port == getservbyname($this->_scheme, 'tcp') - ) { - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - // Normalize percentage-encoded unreserved characters (section 6.2.2.2) - $fields = array(&$this->_userinfo, &$this->_host, &$this->_path, - &$this->_query, &$this->_fragment); - foreach ($fields as &$field) { - if ($field !== false) { - $field = $this->_normalize("$field"); - } - } - unset($field); - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if (false !== $this->_host && '' === $this->_path) { - $this->_path = '/'; - } - - // path should start with '/' if there is authority (section 3.3.) - if (strlen($this->getAuthority()) - && strlen($this->_path) - && $this->_path[0] !== '/' - ) { - $this->_path = '/' . $this->_path; - } - } - - /** - * Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - * Normalize percentage-encoded unreserved characters (section 6.2.2.2) - * - * @param string|array $mixed string or array of strings to normalize - * - * @return string|array - * @see normalize - * @see _normalizeCallback() - */ - private function _normalize($mixed) - { - return preg_replace_callback( - '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), - $mixed - ); - } - - /** - * Callback for _normalize() of %XX percentage-encodings - * - * @param array $matches as by preg_replace_callback - * - * @return string - * @see normalize - * @see _normalize - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _normalizeCallback($matches) - { - return self::urlencode(urldecode($matches[0])); - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @throws Exception - * @return $this - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { - throw new Exception( - 'Base-URL must be absolute if reference is not fragment-only' - ); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) - && $reference->_scheme == $this->_scheme - ) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $reference->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * URL is fragment-only - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @return bool - */ - private function _isFragmentOnly() - { - return ( - $this->_fragment !== false - && $this->_query === false - && $this->_path === '' - && $this->_port === false - && $this->_host === false - && $this->_userinfo === false - && $this->_scheme === false - ); - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $path = (string) $path; - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $loopLimit = 256; - $j = 0; - while ('' !== $path && $j++ < $loopLimit) { - if (substr($path, 0, 2) === './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) === '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) === '/./' || $path === '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) === '/../' || $path === '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path === '.' || $path === '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/', $path[0] === '/'); - if ($i === false) { - $output .= $path; - $path = ''; - break; - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - if ($path !== '') { - $message = sprintf( - 'Unable to remove dot segments; hit loop limit %d (left: %s)', - $j, var_export($path, true) - ); - trigger_error($message, E_USER_WARNING); - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param string $string string to encode - * - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @throws Exception - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 - || $url->_scheme == 'https' && $port != 443 - ) { - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @throws Exception - * @return $this - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - public function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } - - /** - * A simple version of http_build_query in userland. The encoded string is - * percentage encoded according to RFC 3986. - * - * @param array $data An array, which has to be converted into - * QUERY_STRING. Anything is possible. - * @param string $separator Separator {@link self::OPTION_SEPARATOR_OUTPUT} - * @param string $key For stacked values (arrays in an array). - * - * @return string - */ - protected function buildQuery(array $data, $separator, $key = null) - { - $query = array(); - $drop_names = ( - $this->_options[self::OPTION_DROP_SEQUENCE] === true - && array_keys($data) === array_keys(array_values($data)) - ); - foreach ($data as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { - $name = rawurlencode($name); - } - if ($key !== null) { - if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { - $drop_names && $name = ''; - $name = $key . '[' . $name . ']'; - } else { - $name = $key; - } - } - if (is_array($value)) { - $query[] = $this->buildQuery($value, $separator, $name); - } else { - $query[] = $name . '=' . rawurlencode($value); - } - } - return implode($separator, $query); - } - - /** - * This method uses a regex to parse the url into the designated parts. - * - * @param string $url URL - * - * @return void - * @uses self::$_scheme, self::setAuthority(), self::$_path, self::$_query, - * self::$_fragment - * @see __construct - */ - protected function parseUrl($url) - { - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match( - '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', - $url, $matches - ); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $this->_encodeData($matches[5]); - $this->_query = !empty($matches[6]) - ? $this->_encodeData($matches[7]) - : false - ; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Encode characters that might have been forgotten to encode when passing - * in an URL. Applied onto Userinfo, Path and Query. - * - * @param string $url URL - * - * @return string - * @see parseUrl - * @see setAuthority - * @link https://pear.php.net/bugs/bug.php?id=20425 - */ - private function _encodeData($url) - { - return preg_replace_callback( - '([\x-\x20\x22\x3C\x3E\x7F-\xFF]+)', - array($this, '_encodeCallback'), $url - ); - } - - /** - * callback for encoding character data - * - * @param array $matches Matches - * - * @return string - * @see _encodeData - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _encodeCallback(array $matches) - { - return rawurlencode($matches[0]); - } -} diff --git a/vendor/pear/net_url2/README.md b/vendor/pear/net_url2/README.md deleted file mode 100644 index bc98d3aec..000000000 --- a/vendor/pear/net_url2/README.md +++ /dev/null @@ -1,43 +0,0 @@ -[![Net_URL2 on Packagist](https://poser.pugx.org/pear/net_url2/v/stable.png)][pear/net_url2] -[![Build Status](https://travis-ci.org/pear/Net_URL2.png)][Travis CI] -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/quality-score.png?s=23b0d3f0ed58ee865317c500ee2cbe94517438ec)](https://scrutinizer-ci.com/g/pear/Net_URL2/) -[![Code Coverage](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/coverage.png?s=44d3682d7cdef471570d80dd8a7290a1e23fdfee)](https://scrutinizer-ci.com/g/pear/Net_URL2/) - -# Net_URL2 - -Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), -URL generation, and resolving of relative URLs. - -This package is [Pear Net_URL2] and has been migrated from [Pear SVN] - -Please report all new issues via the [PEAR bug tracker]. - -On Packagist as [pear/net_url2]. - -[Pear Net_URL2]: https://pear.php.net/package/Net_URL2 -[Pear SVN]: https://svn.php.net/repository/pear/packages/Net_URL2 -[PEAR bug tracker]: https://pear.php.net/bugs/search.php?cmd=display&package_name%5B%5D=Net_URL2 -[pear/net_url2]: https://packagist.org/packages/pear/net_url2 -[Travis CI]: https://travis-ci.org/pear/Net_URL2 - -## Testing, Packaging and Installing (Pear) - -To test, run either - - $ phpunit tests/ - - or - - $ pear run-tests -r - -To build, simply - - $ pear package - -To install from scratch - - $ pear install package.xml - -To upgrade - - $ pear upgrade -f package.xml diff --git a/vendor/pear/net_url2/composer.json b/vendor/pear/net_url2/composer.json deleted file mode 100644 index b33698e5d..000000000 --- a/vendor/pear/net_url2/composer.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "pear/net_url2", - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "type": "library", - "keywords": [ - "pear", - "net", - "url", - "uri", - "networking", - "rfc3986" - ], - "homepage": "https://github.com/pear/Net_URL2", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "support": { - "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", - "source": "https://github.com/pear/Net_URL2" - }, - "require": { - "php": ">=5.1.4" - }, - "autoload": { - "classmap": ["Net/URL2.php"] - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - } -} diff --git a/vendor/pear/net_url2/docs/6470.php b/vendor/pear/net_url2/docs/6470.php deleted file mode 100755 index 8ef0ff046..000000000 --- a/vendor/pear/net_url2/docs/6470.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** -* This example will decode the url given and display its -* constituent parts. -*/ - error_reporting(E_ALL | E_STRICT); - - require_once 'Net/URL2.php'; - - $url = new Net_URL2('https://www.example.com/foo/bar/index.php?foo=bar'); - -?> - - - -
-Protocol...: protocol; ?>
-
-Username...: user; ?>
-
-Password...: pass; ?>
-
-Server.....: host; ?>
-
-Port.......: port; ?>
-
-File/path..: path; ?>
-
-Querystring: querystring); ?>
-
-Anchor.....: anchor;?>
-
-Full URL...: getUrl(); ?>
-
-Resolve path (/.././/foo/bar/joe/./././../jabba): resolve('/.././/foo/bar/joe/./././../jabba'); ?>
-
- - - diff --git a/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes b/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes deleted file mode 100644 index b45ca8e94..000000000 --- a/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2002-2003, Richard Heyes -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3) Neither the name of the Richard Heyes nor the names of his - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/net_url2/docs/example.php b/vendor/pear/net_url2/docs/example.php deleted file mode 100755 index 351be68b8..000000000 --- a/vendor/pear/net_url2/docs/example.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** -* This example will decode the url given and display its -* constituent parts. -*/ - -error_reporting(E_ALL | E_STRICT); - -require 'Net/URL2.php'; - -$url = new Net_URL2( - 'https://example.com/pls/portal30/PORTAL30.wwpob_page.changetabs?' - .'p_back_url=http%3A%2F%2Fexample.com%2Fservlet%2Fpage%3F_pageid%3D360' - .'%2C366%2C368%2C382%26_dad%3Dportal30%26_schema%3DPORTAL30&foo=bar' -); - -?> - - - -
-Protocol...: protocol; ?>
-
-Username...: user; ?>
-
-Password...: pass; ?>
-
-Server.....: host; ?>
-
-Port.......: port; ?>
-
-File/path..: path; ?>
-
-Querystring: querystring); ?>
-
-Anchor.....: anchor;?>
-
-Full URL...: getUrl(); ?>
-
-
-Resolve path (.././/foo/bar/joe/./././../jabba): resolve('.././/foo/bar/joe/./././../jabba'); ?>
-
- - - diff --git a/vendor/pear/net_url2/package.xml b/vendor/pear/net_url2/package.xml deleted file mode 100644 index 7f0b42ae4..000000000 --- a/vendor/pear/net_url2/package.xml +++ /dev/null @@ -1,469 +0,0 @@ - - - Net_URL2 - pear.php.net - Net_URL - Class for parsing and handling URL. - - Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of - relative URLs. - - - Tom Klingenberg - tkli - tkli@php.net - yes - - - David Coallier - davidc - davidc@php.net - no - - - Christian Schmidt - schmidt - schmidt@php.net - no - - - 2015-04-18 - - - 2.2.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Changed composer autoloader to classmap, fixes include path pollution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.1.4 - - - 1.4.0b1 - - - - - - - 2015-04-18 - - - 2.2.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Changed composer autoloader to classmap, fixes include path pollution - - - - 2014-12-27 - - - 2.1.1 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20473: Normalize query and fragment broken - - - - 2014-10-21 - - - 2.1.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * New: OPTION_DROP_SEQUENCE - - - - 2014-10-21 - - - 2.0.12 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Removed: OPTION_DROP_SEQUENCE - - - - - 2014-10-18 - - - 2.0.11 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * New: OPTION_DROP_SEQUENCE - - - - - 2014-10-09 - - - 2.0.10 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Imp: composer for pear - * Fix: Documentation problem - - - - - 2014-10-08 - - - 2.0.9 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20418: Incorrect normalization of URI with missing authority - * Upd: Test for RFC 3986 Section 1.1.2 Examples - * Upd: Travis CI - PHP 5.6 added - - - - - 2014-10-07 - - - 2.0.8 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20420: Inconsistent setAuthority and getAuthority - * Fixed #20423: URI with IPv6 or IPvFuture not parsed - * Imp: Test for RFC 3986 Section 1.1.2 Examples - - - - - 2014-09-07 - - - 2.0.7 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20385: Incorrect normalization of userinfo - * Fixed #20399: Setting userinfo to FALSE not transparent - - - - - 2014-07-21 - - - 2.0.6 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20304: file:// URI gets crippled - - - - - 2014-01-01 - - - 2.0.5 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #17036: Brackets broken for query variables - * Fixed diverse coding style violations and misc. minor issues - * Increased code coverage - - - - - 2013-12-31 - - - 2.0.4 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20161: URLs with "0" as host fail to normalize with empty path - * A flaw in NetURL2::removeDotSegments() introduced in 2.0.1 has been fixed - * New: NetURL2::removeDotSegments() emits a warning on loop limit reach - * Url-segment maximum count raised from 100 to 256 (loop limit) - - - - - 2013-12-30 - - - 2.0.3 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20156: setAuthority() flaw with "0" as host - * Fixed #20157: normalize() flaw with "0" as path - * Fixed #20158: Fragment-only references are not resolved to non-absolute base URI - * Fixed #20159: Authority not terminated by slash - * Fixed diverse coding style violations and misc. minor issues - * Increased code coverage - * Added support for Scrutinizer CI - - - - - 2013-12-27 - - - 2.0.2 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #19684: Redirects containing spaces do not work - * Fixed diverse coding style violations and misc. minor issues - * Improved source package distribution - * Added support for Travis CI - - - - - 2013-12-24 - - - 2.0.1 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed Bug #20013: getNormalizedURL() adds leading "@" chars in the Authority - * Fixed Bug #20016: Wrong data in 6d4f4dd "Package.xml preparation." - * Fixed Bug #19176: resolve() does not merge the path if the base path is empty - * Fixed Bug #19315: removeDotSegments("0") not working - - - - - 2011-10-20 - - - 2.0.0 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed the version of the release. Follow the convention for Package2. - * Fixed Bug #18917: URL2.php moved to ./Net/Net (davidc) - - - - - - 1.0.0 - 1.0.0 - - - stable - stable - - 2011-10-20 - BSD-3-Clause - - * Fixed Bug #17036: Problem with parsed query string - * Fixed Bug #17087: setOption() function is gone - * Fixed #17166: Fluent Interface - * Fixed #17167: Refactor __construct - * Fixed Bug #18267: setQueryVariables() fails to encode array values - * Fixed Bug #14399: Fixed multiple bugs in Net_URL2 (Missing setOption value, unused properties, etc.) - - - - - - 0.3.1 - 0.3.0 - - - beta - beta - - 2011-02-22 - BSD-3-Clause - - * BC break: Removed setOption() to avoid undefined behaviour (bug #16674) - * Fixed Bug #16854: Invalid package.xml making it impossible to install with Pyrus - * Fixed Bug #16651: Port may be an empty string - * Fixed Bug #16653: Don't make OPTION_SEPARATOR_(IN|OUT)PUT default to arg_separator.(in|out)put - - - - - 0.3.0 - 0.3.0 - - - beta - beta - - 2009-09-05 - BSD-3-Clause - - * Fixed #14399 (Errors in URL parsing (items #1 and #3)) - * Fixed #14735 (Encode query string values) - * Fixed #15546 (Add adding __toString()) - * Fixed #15367 (Use RFC 3986-compliant version of rawurlencode() in PHP < 5.2) - * Fixed #14289 (Add __get() and __set()) - - - - - 0.2.0 - 0.2.0 - - - beta - beta - - 2008-06-18 - BSD-3-Clause - - * Major rewrite to comply with RFC3986 (bug #11574). - * Much better support for resolving relative URLs. - * WARNING: Method and property names has changed to reflect the terminology used in the RFC - THIS RELEASE IS - NOT BACKWARDS COMPATIBLE WITH VERSION 0.1.0. - - - - - 0.1.0 - 0.1.0 - - - beta - beta - - 2007-05-08 - BSD-3-Clause - Convert to PHP5 only. PHP4 users should continue with version 1.0.15 - - - diff --git a/vendor/pear/net_url2/phpunit.xml.dist b/vendor/pear/net_url2/phpunit.xml.dist deleted file mode 100644 index 2fee31891..000000000 --- a/vendor/pear/net_url2/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - tests - - - - - Net/URL2.php - - - diff --git a/vendor/pear/net_url2/tests/AllTests.php b/vendor/pear/net_url2/tests/AllTests.php deleted file mode 100644 index 65492fe36..000000000 --- a/vendor/pear/net_url2/tests/AllTests.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -require_once 'PHPUnit/Autoload.php'; - -chdir(dirname(__FILE__) . '/../'); - -require_once 'Net/URL2Test.php'; -require_once 'Net/URL2.php'; - -/** - * Test class for Net_URL2. - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2_AllTests -{ - /** - * main() - * - * @return void - */ - public static function main() - { - - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * suite() - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Net_URL2 tests'); - /** Add testsuites, if there is. */ - $suite->addTestSuite('Net_URL2Test'); - - return $suite; - } -} - -Net_URL2_AllTests::main(); diff --git a/vendor/pear/net_url2/tests/Net/URL2Test.php b/vendor/pear/net_url2/tests/Net/URL2Test.php deleted file mode 100644 index a17d0c5f6..000000000 --- a/vendor/pear/net_url2/tests/Net/URL2Test.php +++ /dev/null @@ -1,1088 +0,0 @@ - - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Test class for Net_URL2. - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2Test extends PHPUnit_Framework_TestCase -{ - /** - * Tests setting a zero-length string and false as authority - * Also: Regression test for Bug #20420 - * - * @covers Net_URL2::setAuthority - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20420 - */ - public function testSetEmptyAuthority() - { - $url = new Net_URL2('http://www.example.com/'); - $url->setAuthority(''); - $this->assertSame('', $url->getAuthority()); - $this->assertSame('', $url->getHost()); - $this->assertSame(false, $url->getPort()); - $this->assertSame(false, $url->getUserinfo()); - $this->assertSame(false, $url->getUser()); - - $url->setAuthority(false); - $this->assertSame(false, $url->getAuthority()); - } - - /** - * Tests setting an empty userinfo part - * Also: Regression test for Bug #20013 and Bug #20399 - * - * @covers Net_URL2::setUserinfo - * @covers Net_URL2::getUserinfo - * @covers Net_URL2::getURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20013 - * @link https://pear.php.net/bugs/bug.php?id=20399 - */ - public function testSetEmptyUserinfo() - { - $url = new Net_URL2('http://@www.example.com/'); - $this->assertSame('http://www.example.com/', $url->getURL()); - - $url = new Net_URL2('http://www.example.com/'); - $this->assertSame('http://www.example.com/', $url->getURL()); - $url->setUserinfo(''); - $this->assertSame('http://www.example.com/', $url->getURL()); - $this->assertSame('', $url->getUserinfo()); - $url->setUserinfo(false); - $this->assertSame('http://www.example.com/', $url->getURL()); - $this->assertFalse($url->getUserinfo()); - } - - /** - * Tests an URL with no userinfo and normalization - * - * Also: Regression test for Bug #20385 - * - * @covers Net_URL2::getUserinfo - * @covers Net_URL2::normalize - * @covers Net_URL2::getNormalizedURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20385 - */ - public function testNoUserinfoAndNormalize() - { - $testUrl = 'http://www.example.com/'; - - $url = new Net_URL2($testUrl); - $this->assertFalse($url->getUserinfo()); - - $url->normalize(); - $this->assertFalse($url->getUserinfo()); - - $this->assertEquals($testUrl, $url->getURL()); - $this->assertEquals($testUrl, $url->getNormalizedURL()); - } - - /** - * Tests setQueryVariable(). - * - * @return void - */ - public function testSetQueryVariable() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQueryVariable('pear', 'fun'); - $this->assertEquals($url->getURL(), 'http://www.example.com/?pear=fun'); - } - - /** - * Tests setQueryVariables(). - * - * @return void - */ - public function testSetQueryVariables() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQueryVariables(array('pear' => 'fun')); - $this->assertEquals('http://www.example.com/?pear=fun', $url->getURL()); - $url->setQueryVariables(array('pear' => 'fun for sure')); - $this->assertEquals( - 'http://www.example.com/?pear=fun%20for%20sure', $url->getURL() - ); - } - - /** - * Tests unsetQueryVariable() - * - * @return void - */ - public function testUnsetQueryVariable() - { - $url = new Net_URL2( - 'http://www.example.com/?name=david&pear=fun&fish=slippery' - ); - - $removes = array( - 'pear' => 'http://www.example.com/?name=david&fish=slippery', - 'name' => 'http://www.example.com/?fish=slippery', - 'fish' => 'http://www.example.com/', - ); - - foreach ($removes as $name => $expected) { - $url->unsetQueryVariable($name); - $this->assertEquals($expected, $url); - } - } - - /** - * Tests setQuery(). - * - * @return void - */ - public function testSetQuery() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQuery('flapdoodle&dilly%20all%20day'); - $this->assertEquals( - $url->getURL(), 'http://www.example.com/?flapdoodle&dilly%20all%20day' - ); - } - - /** - * Tests getQuery(). - * - * @return void - */ - public function testGetQuery() - { - - $url = new Net_URL2('http://www.example.com/?foo'); - $this->assertEquals($url->getQuery(), 'foo'); - $url = new Net_URL2('http://www.example.com/?pear=fun&fruit=fruity'); - $this->assertEquals($url->getQuery(), 'pear=fun&fruit=fruity'); - } - - /** - * Tests setScheme(). - * - * @return void - */ - public function testSetScheme() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setScheme('ftp'); - $this->assertEquals($url->getURL(), 'ftp://www.example.com/'); - $url->setScheme('gopher'); - $this->assertEquals($url->getURL(), 'gopher://www.example.com/'); - } - - /** - * Tests setting the fragment. - * - * @return void - */ - public function testSetFragment() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setFragment('pear'); - $this->assertEquals('http://www.example.com/#pear', $url->getURL()); - } - - /** - * A dataProvider for paths that are solved to a base URI. - * - * @see testResolveUrls - * @return array - */ - public function provideResolveUrls() - { - return array( - array( - // Examples from RFC 3986, section 5.4. - // relative base-URI, (URL => absolute URL), [(options)] - 'http://a/b/c/d;p?q', - array( - 'g:h' => 'g:h', - 'g' => 'http://a/b/c/g', - './g' => 'http://a/b/c/g', - 'g/' => 'http://a/b/c/g/', - '/g' => 'http://a/g', - '//g' => 'http://g', - '?y' => 'http://a/b/c/d;p?y', - 'g?y' => 'http://a/b/c/g?y', - '#s' => 'http://a/b/c/d;p?q#s', - 'g#s' => 'http://a/b/c/g#s', - 'g?y#s' => 'http://a/b/c/g?y#s', - ';x' => 'http://a/b/c/;x', - 'g;x' => 'http://a/b/c/g;x', - 'g;x?y#s' => 'http://a/b/c/g;x?y#s', - '' => 'http://a/b/c/d;p?q', - '.' => 'http://a/b/c/', - './' => 'http://a/b/c/', - '..' => 'http://a/b/', - '../' => 'http://a/b/', - '../g' => 'http://a/b/g', - '../..' => 'http://a/', - '../../' => 'http://a/', - '../../g' => 'http://a/g', - '../../../g' => 'http://a/g', - '../../../../g' => 'http://a/g', - '/./g' => 'http://a/g', - '/../g' => 'http://a/g', - 'g.' => 'http://a/b/c/g.', - '.g' => 'http://a/b/c/.g', - 'g..' => 'http://a/b/c/g..', - '..g' => 'http://a/b/c/..g', - './../g' => 'http://a/b/g', - './g/.' => 'http://a/b/c/g/', - 'g/./h' => 'http://a/b/c/g/h', - 'g/../h' => 'http://a/b/c/h', - 'g;x=1/./y' => 'http://a/b/c/g;x=1/y', - 'g;x=1/../y' => 'http://a/b/c/y', - 'g?y/./x' => 'http://a/b/c/g?y/./x', - 'g?y/../x' => 'http://a/b/c/g?y/../x', - 'g#s/./x' => 'http://a/b/c/g#s/./x', - 'g#s/../x' => 'http://a/b/c/g#s/../x', - 'http:g' => 'http:g', - ), - ), - array( - 'http://a/b/c/d;p?q', - array('http:g' => 'http://a/b/c/g'), - array('::OPTION_STRICT' => false) - ), - ); - } - - /** - * Test the resolve() function to resolve URLs to each other. - * - * @param string $baseURL base-URI - * @param array $relativeAbsolutePairs url-pairs, relative => resolved - * @param array $options Net_URL2 options - * - * @dataProvider provideResolveUrls - * @covers Net_URL2::resolve - * @return void - */ - public function testResolveUrls($baseURL, array $relativeAbsolutePairs, - array $options = array() - ) { - $options = $this->_translateOptionData($options); - $base = new Net_URL2($baseURL, $options); - $count = count($relativeAbsolutePairs); - $this->assertGreaterThan(0, $count, 'relative-absolute-pairs data is empty'); - foreach ($relativeAbsolutePairs as $relativeURL => $absoluteURL) { - $this->assertSame($absoluteURL, (string) $base->resolve($relativeURL)); - } - } - - /** - * Helper method to turn options with strings as the constant names - * (to allow to externalize the fixtures) into a concrete options - * array that uses the values from the Net_URL2 class constants. - * - * @param array $options options - * - * @return array - */ - private function _translateOptionData(array $options) - { - // translate string option-names to class constant starting with a colon. - foreach ($options as $name => $value) { - if ($name[0] === ':') { - unset($options[$name]); - $options[constant("Net_URL2$name")] = $value; - } - } - return $options; - } - - /** - * Test the resolve() function throwing an exception with invalid data. - * - * @covers Net_URL2::resolve - * @return void - */ - public function testResolveException() - { - // resolving a relative to a relative URL throws an exception - $base = new Net_URL2('news.html?category=arts'); - $this->addToAssertionCount(1); - try { - $base->resolve('../arts.html#section-2.4'); - } catch (Exception $e) { - $expected = 'Base-URL must be absolute if reference is not fragment-onl'; - $this->assertStringStartsWith($expected, $e->getMessage()); - return; - } - $this->fail('Expected exception not thrown.'); - } - - /** - * Assert that there is a last error message and it contains needle. - * - * @param string $needle needle - * - * @return void - */ - private function _assertLastErrorContains($needle) - { - $error = error_get_last(); - $this->assertArrayHasKey('message', $error, 'there was an error previously'); - $pos = strpos($error['message'], $needle); - - $this->assertTrue( - false !== $pos, - sprintf( - 'Last error message "%s" contains "%s"', $error['message'], $needle - ) - ); - } - - /** - * Test UrlEncoding - * - * @return void - * @link https://pear.php.net/bugs/bug.php?id=18267 - */ - public function testUrlEncoding() - { - $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); - $url = new Net_URL2('http://localhost/bug.php', $options); - $url->setQueryVariables( - array( - 'indexed' => array( - 'first value', 'second value', array('foo', 'bar'), - ) - ) - ); - $this->assertEquals( - 'http://localhost/bug.php?indexed[0]=first%20value&indexed[1]' . - '=second%20value&indexed[2][0]=foo&indexed[2][1]=bar', - strval($url) - ); - } - - /** - * A test to verify that keys in QUERY_STRING are encoded by default. - * - * @return void - * @see Net_URL2::OPTION_ENCODE_KEYS - * @see Net_URL2::buildQuery() - */ - public function testEncodeKeys() - { - $url = new Net_URL2('http://example.org'); - $url->setQueryVariables(array('helgi rulez' => 'till too')); - $this->assertEquals( - 'http://example.org?helgi%20rulez=till%20too', - strval($url) - ); - } - - /** - * A test to verify that keys in QUERY_STRING are not encoded when we supply - * 'false' via {@link Net_URL2::__construct()}. - * - * @return void - * @see Net_URL2::OPTION_ENCODE_KEYS - * @see Net_URL2::buildQuery() - */ - public function testDontEncodeKeys() - { - $url = new Net_URL2( - 'http://example.org', - array(Net_URL2::OPTION_ENCODE_KEYS => false) - ); - $url->setQueryVariables(array('till rulez' => 'helgi too')); - $this->assertEquals( - 'http://example.org?till rulez=helgi%20too', - strval($url) - ); - } - - /** - * Brackets for array query variables - * - * Also text to not encode zero based integer sequence into brackets - * - * @return void - * - * @link https://pear.php.net/bugs/bug.php?id=20427 - */ - public function testUseBrackets() - { - $url = new Net_URL2('http://example.org/'); - $url->setQueryVariables(array('foo' => array('bar', 'baz'))); - $expected = 'http://example.org/?foo[]=bar&foo[]=baz'; - $this->assertEquals($expected, $url->getURL()); - - $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); - $url = new Net_URL2('http://example.org/', $options); - $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); - $expected = 'http://example.org/?foo[0]=bar&foo[1]=foobar'; - $this->assertEquals($expected, $url->getURL()); - } - - /** - * Do not use brackets for query variables passed as array - * - * @return void - */ - public function testDontUseBrackets() - { - $url = new Net_URL2( - 'http://example.org/', - array(Net_URL2::OPTION_USE_BRACKETS => false) - ); - $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); - $this->assertEquals( - 'http://example.org/?foo=bar&foo=foobar', - strval($url) - ); - } - - /** - * A dataProvider for example URIs from RFC 3986 Section 1.1.2 - * - * @return array - * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 - * @see testExampleUri - */ - public function provideExampleUri() - { - return array( - array('ftp://ftp.is.co.za/rfc/rfc1808.txt'), - array('http://www.ietf.org/rfc/rfc2396.txt'), - array('ldap://[2001:db8::7]/c=GB?objectClass?one'), - array('mailto:John.Doe@example.com'), - array('news:comp.infosystems.www.servers.unix'), - array('tel:+1-816-555-1212'), - array('telnet://192.0.2.16:80/'), - array('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'), - ); - } - - /** - * test that Net_URL2 works with the example URIs from RFC 3986 Section 1.1.2 - * - * @param string $uri example URI - * - * @return void - * @dataProvider provideExampleUri - * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 - * @see testComponentRecompositionAndNormalization - */ - public function testExampleUri($uri) - { - $url = new Net_URL2($uri); - $this->assertSame($uri, $url->__toString()); - $url->normalize(); - $this->assertSame($uri, $url->__toString()); - } - - /** - * A dataProvider for pairs of paths with dot segments and - * their form when removed. - * - * @see testRemoveDotSegments - * @return array - */ - public function providePath() - { - // The numbers behind are in reference to sections - // in RFC 3986 5.2.4. Remove Dot Segments - return array( - array('../', ''), // 2. A. - array('./', ''), // 2. A. - array('/./', '/'), // 2. B. - array('/.', '/'), // 2. B. - array('/../', '/'), // 2. C. - array('/..', '/'), // 2. C. - array('..', ''), // 2. D. - array('.', ''), // 2. D. - array('a', 'a'), // 2. E. - array('/a', '/a'), // 2. E. - array('/a/b/c/./../../g', '/a/g'), // 3. - array('mid/content=5/../6', 'mid/6'), // 3. - array('../foo/bar.php', 'foo/bar.php'), - array('/foo/../bar/boo.php', '/bar/boo.php'), - array('/boo/..//foo//bar.php', '//foo//bar.php'), - array('/./foo/././bar.php', '/foo/bar.php'), - array('./.', ''), - ); - } - - /** - * Test removal of dot segments - * - * @param string $path Path - * @param string $assertion Assertion - * - * @dataProvider providePath - * @covers Net_URL2::removeDotSegments - * @return void - */ - public function testRemoveDotSegments($path, $assertion) - { - $this->assertEquals($assertion, Net_URL2::removeDotSegments($path)); - } - - /** - * Test removeDotSegments() loop limit warning - * - * @covers Net_URL2::removeDotSegments - * @return void - */ - public function testRemoveDotSegmentsLoopLimit() - { - $loopLimit = 256; - $segments = str_repeat('a/', $loopLimit); - - @Net_URL2::removeDotSegments($segments . 'b/'); - - $this->_assertLastErrorContains(sprintf(' loop limit %d ', $loopLimit + 1)); - $this->_assertLastErrorContains(" (left: '/b/')"); - } - - /** - * A dataProvider for query strings and their array representation - * - * @see testGetQueryVariables - * @return array - */ - public function provideQueryStrings() - { - // If the second (expected) value is set or not null, parse_str() differs. - // Notes on PHP differences with each entry/block - return array( - // Net_URL2::getQueryVariables() non-bracket mode - array('test=1&t%65st=%41&extra=', - array('test' => array('1', 'A'), 'extra' => ''), - array('::OPTION_USE_BRACKETS' => false)), - array(''), - array('='), - array('key'), - array('key='), - array('=value'), - array('k=v'), - // no space as var-name in PHP (array()): - array(' ', array(' ' => '' )), - array(' =v', array(' ' => 'v')), - array('key=value'), - // PHP replaces ".", " " and "[" in name replaced by "_": - array('key.=value' , array('key.' => 'value')), - array('key =value' , array('key ' => 'value')), - array('key[=value' , array('key[' => 'value')), - array("key\0=value", array("key\0" => 'value')), - array('key]=value'), - array('key[]=value'), - array('[]=value'), - array(']=value'), - array(']]=value'), - // PHP drops variables that are an open bracket only - array('[=value', array('[' => 'value')), - // PHP drops spaces in brackets: - array('key[ ]=value', array('key' => array(' ' => 'value'))), - // PHP replaces space " " in name by "_" - array('key []=1' , array('key ' => array('1' ))) , - // PHP does not support "\0" in var-names: - array("key[\0]=value" , array('key' => array("\0" => 'value' ))), - array("key[a\0]=value" , array('key' => array("a\0" => 'value' ))), - array("key[a\0b]=value" , array('key' => array("a\0b" => 'value'))), - array('var[]=1&var[0][]=2'), - array('key[] []=1'), - array('key[] [] []=1'), - array('key[] [] []'), - array('key[] [] []=[] []'), - array('[] [] []=[] []'), - ); - } - - /** - * Test parsing of query variables - * - * @param string $query string - * @param mixed $expected null to test against parse_str() behavior - * @param array $options Net_URL2 options - * - * @dataProvider provideQueryStrings - * @covers Net_URL2::getQueryVariables - * @covers Net_URL2::_queryArrayByKey - * @covers Net_URL2::_queryArrayByBrackets - * @covers Net_URL2::_queryKeyBracketOffset - * @return void - */ - public function testGetQueryVariables($query, $expected = null, - array $options = array() - ) { - $options = $this->_translateOptionData($options); - - $url = new Net_URL2('', $options); - - if ($expected === null) { - // parse_str() is in PHP before copy on write, therefore - // it uses pass-by-reference for $expected to return - // the array - parse_str($query, $expected); - } - - // Xdebug: If breakpoints are ignored, see Xdebug Issue 0000924 - $url->setQuery($query); - $actual = $url->getQueryVariables(); - - // Do two assertions, because the first one shows a more nice diff in case - // it fails and the second one is actually strict which is what has to be - // tested. - $this->assertEquals($expected, $actual); - $this->assertSame($expected, $actual); - } - - /** - * data provider of host and port - * - * @return array - * @see testHostAndPort - */ - public function provideHostAndPort() - { - return array( - array('[::1]', '[::1]', false), - array('[::1]:', '[::1]', false), - array('[::1]:128', '[::1]', '128'), - array('127.0.0.1', '127.0.0.1', false), - array('127.0.0.1:', '127.0.0.1', false), - array('127.0.0.1:128', '127.0.0.1', '128'), - array('localhost', 'localhost', false), - array('localhost:', 'localhost', false), - array('localhost:128', 'localhost', '128'), - ); - } - - /** - * test that an authority containing host and port maps to expected host and port - * - * This is also a regression test to test that using ip-literals works along- - * side ipv4 and reg-name hosts incl. port numbers - * - * It was reported as Bug #20423 on 2014-10-06 18:25 UTC that - * http://[::1]// URI drops the host - * - * @param string $authority string - * @param string $expectedHost string - * @param string|bool $expectedPort string or FALSE - * - * @return void - * @dataProvider provideHostAndPort - * @covers Net_URL2::setAuthority() - * @link https://pear.php.net/bugs/bug.php?id=20423 - * @link http://tools.ietf.org/html/rfc3986#section-3.2.2 - * @link http://tools.ietf.org/html/rfc3986#section-3.2 - * @link http://tools.ietf.org/html/rfc3986#section-3.2.3 - */ - public function testHostAndPort($authority, $expectedHost, $expectedPort) - { - $uri = "http://{$authority}"; - $url = new Net_URL2($uri); - $this->assertSame($expectedHost, $url->getHost()); - $this->assertSame($expectedPort, $url->getPort()); - } - - /** - * This is a regression test to test that Net_URL2::getQueryVariables() does - * not have a problem with nested array values in form of stacked brackets and - * was reported as Bug #17036 on 2010-01-26 15:48 UTC that there would be - * a problem with parsed query string. - * - * @link https://pear.php.net/bugs/bug.php?id=17036 - * @covers Net_URL2::getQueryVariables - * @return void - */ - public function test17036() - { - $queryString = 'start=10&test[0][first][1.1][20]=coucou'; - $url = new Net_URL2('?' . $queryString); - $vars = $url->getQueryVariables(); - - $expected = array(); - $expected['start'] = '10'; - $expected['test'][0]['first']['1.1'][20] = 'coucou'; - - $this->assertEquals($expected, $vars); // give nice diff in case of failuer - $this->assertSame($expected, $vars); // strictly assert the premise - } - - /** - * This is a regression test to test that resolve() does - * merge the path if the base path is empty as the opposite - * was reported as Bug #19176 on 2011-12-31 02:07 UTC - * - * @return void - */ - public function test19176() - { - $foo = new Net_URL2('http://www.example.com'); - $test = $foo->resolve('test.html')->getURL(); - $this->assertEquals('http://www.example.com/test.html', $test); - } - - /** - * This is a regression test that removeDotSegments('0') is - * working as it was reported as not-working in Bug #19315 - * on 2012-03-04 04:18 UTC. - * - * @return void - */ - public function test19315() - { - $actual = Net_URL2::removeDotSegments('0'); - $this->assertSame('0', $actual); - - $nonStringObject = (object)array(); - try { - Net_URL2::removeDotSegments($nonStringObject); - } catch (PHPUnit_Framework_Error $error) { - $this->addToAssertionCount(1); - } - - if (!isset($error)) { - $this->fail('Failed to verify that error was given.'); - } - unset($error); - } - - /** - * This is a regression test to test that recovering from - * a wrongly encoded URL is possible. - * - * It was requested as Request #19684 on 2011-12-31 02:07 UTC - * that redirects containing spaces should work. - * - * @return void - */ - public function test19684() - { - // Location: URL obtained Thu, 25 Apr 2013 20:51:31 GMT - $urlWithSpace = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS N' - . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' - . '48+219853269+219853286'; - - $urlCorrect = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS%20N' - . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' - . '48+219853269+219853286'; - - $url = new Net_URL2($urlWithSpace); - - $this->assertTrue($url->isAbsolute()); - - $urlPart = parse_url($urlCorrect, PHP_URL_PATH); - $this->assertSame($urlPart, $url->getPath()); - - $urlPart = parse_url($urlCorrect, PHP_URL_QUERY); - $this->assertSame($urlPart, $url->getQuery()); - - $this->assertSame($urlCorrect, (string)$url); - - $input = 'http://example.com/get + + to my nose/'; - $expected = 'http://example.com/get%20+%20+%20to%20my%20nose/'; - $actual = new Net_URL2($input); - $this->assertEquals($expected, $actual); - $actual->normalize(); - } - - /** - * data provider of list of equivalent URLs. - * - * @see testNormalize - * @see testConstructSelf - * @return array - */ - public function provideEquivalentUrlLists() - { - return array( - // String equivalence: - array('http://example.com/', 'http://example.com/'), - - // Originally first dataset: - array('http://www.example.com/%9a', 'http://www.example.com/%9A'), - - // Example from RFC 3986 6.2.2.: - array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'), - - // Example from RFC 3986 6.2.2.1.: - array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/'), - - // Example from RFC 3986 6.2.3.: - array( - 'http://example.com', 'http://example.com/', - 'http://example.com:/', 'http://example.com:80/' - ), - - // Bug #20161: URLs with "0" as host fail to normalize with empty path - array('http://0/', 'http://0'), - - // Bug #20473: Normalize query and fragment broken - array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar'), - ); - } - - /** - * This is a coverage test to invoke the normalize() - * method. - * - * @return void - * - * @dataProvider provideEquivalentUrlLists - */ - public function testNormalize() - { - $urls = func_get_args(); - - $this->assertGreaterThanOrEqual(2, count($urls)); - - $last = null; - - foreach ($urls as $index => $url) { - $url = new Net_Url2($url); - $url->normalize(); - if ($index) { - $this->assertSame((string)$last, (string)$url); - } - $last = $url; - } - } - - /** - * This is a coverage test to invoke __get and __set - * - * @covers Net_URL2::__get - * @covers Net_URL2::__set - * @return void - */ - public function testMagicSetGet() - { - $url = new Net_URL2(''); - - $property = 'authority'; - $url->$property = $value = 'value'; - $this->assertEquals($value, $url->$property); - - $property = 'unsetProperty'; - $url->$property = $value; - $this->assertEquals(false, $url->$property); - } - - /** - * data provider of uri and normal URIs - * - * @return array - * @see testComponentRecompositionAndNormalization - */ - public function provideComposedAndNormalized() - { - return array( - array(''), - array('http:g'), - array('user@host'), - array('mailto:user@host'), - ); - } - - /** - * Tests Net_URL2 RFC 3986 5.3. Component Recomposition in the light - * of normalization - * - * This is also a regression test to test that a missing authority works well - * with normalization - * - * It was reported as Bug #20418 on 2014-10-02 22:10 UTC that there is an - * Incorrect normalization of URI with missing authority - * - * @param string $uri URI - * - * @return void - * @covers Net_URL2::getUrl() - * @covers Net_URL2::normalize() - * @dataProvider provideComposedAndNormalized - * @link https://pear.php.net/bugs/bug.php?id=20418 - * @see testExampleUri - */ - public function testComponentRecompositionAndNormalization($uri) - { - $url = new Net_URL2($uri); - $this->assertSame($uri, $url->getURL()); - $url->normalize(); - $this->assertSame($uri, $url->getURL()); - } - - /** - * Tests Net_URL2 ctors URL parameter works with objects implementing - * __toString(). - * - * @dataProvider provideEquivalentUrlLists - * @coversNothing - * @return void - */ - public function testConstructSelf() - { - $urls = func_get_args(); - foreach ($urls as $url) { - $urlA = new Net_URL2($url); - $urlB = new Net_URL2($urlA); - $this->assertSame((string)$urlA, (string)$urlB); - } - } - - /** - * This is a feature test to see that the userinfo's data is getting - * encoded as outlined in #19684. - * - * @covers Net_URL2::setAuthority - * @covers Net_URL2::setUserinfo - * @return void - */ - public function testEncodeDataUserinfoAuthority() - { - $url = new Net_URL2('http://john doe:secret@example.com/'); - $this->assertSame('http://john%20doe:secret@example.com/', (string)$url); - - $url->setUserinfo('john doe'); - $this->assertSame('http://john%20doe@example.com/', (string)$url); - - $url->setUserinfo('john doe', 'pa wd'); - $this->assertSame('http://john%20doe:pa%20wd@example.com/', (string)$url); - } - - /** - * This is a regression test to test that using the - * host-name "0" does work with getAuthority() - * - * It was reported as Bug #20156 on 2013-12-27 22:56 UTC - * that setAuthority() with "0" as host would not work - * - * @covers Net_URL2::setAuthority - * @covers Net_URL2::getAuthority - * @covers Net_URL2::setHost - * @return void - */ - public function test20156() - { - $url = new Net_URL2('http://user:pass@example.com:127/'); - $host = '0'; - $url->setHost($host); - $this->assertSame('user:pass@0:127', $url->getAuthority()); - - $url->setHost(false); - $this->assertSame(false, $url->getAuthority()); - - $url->setAuthority($host); - $this->assertSame($host, $url->getAuthority()); - } - - /** - * This is a regression test to test that setting "0" as path - * does not break normalize(). - * - * It was reported as Bug #20157 on 2013-12-27 23:42 UTC that - * normalize() with "0" as path would not work. - * - * @covers Net_URL2::normalize - * @return void - */ - public function test20157() - { - $subject = 'http://example.com'; - $url = new Net_URL2($subject); - $url->setPath('0'); - $url->normalize(); - $this->assertSame("$subject/0", (string)$url); - } - - /** - * This is a regression test to ensure that fragment-only references can be - * resolved to a non-absolute Base-URI. - * - * It was reported as Bug #20158 2013-12-28 14:49 UTC that fragment-only - * references would not be resolved to non-absolute base URI - * - * @covers Net_URL2::resolve - * @covers Net_URL2::_isFragmentOnly - * @return void - */ - public function test20158() - { - $base = new Net_URL2('myfile.html'); - $resolved = $base->resolve('#world'); - $this->assertSame('myfile.html#world', (string)$resolved); - } - - /** - * This is a regression test to ensure that authority and path are properly - * combined when the path does not start with a slash which is the separator - * character between authority and path. - * - * It was reported as Bug #20159 2013-12-28 17:18 UTC that authority - * would not be terminated by slash - * - * @covers Net_URL2::getUrl - * @return void - */ - public function test20159() - { - $url = new Net_URL2('index.html'); - $url->setHost('example.com'); - $this->assertSame('//example.com/index.html', (string)$url); - } - - /** - * This is a regression test to test that using the file:// URI scheme with - * an empty (default) hostname has the empty authority preserved when the - * full URL is build. - * - * It was reported as Bug #20304 on 2014-06-21 00:06 UTC - * that file:// URI are crippled. - * - * Tests with a default authority for the "file" URI scheme - * - * @covers Net_URL2::getURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20304 - */ - public function test20304() - { - $file = 'file:///path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'file://localhost/path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'file://user@/path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'FILE:///path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - } -} diff --git a/vendor/pear/pear_exception/.gitignore b/vendor/pear/pear_exception/.gitignore deleted file mode 100644 index 479265b07..000000000 --- a/vendor/pear/pear_exception/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -PEAR_Exception*.tgz - -# composer related -composer.lock -composer.phar -vendor diff --git a/vendor/pear/pear_exception/.travis.yml b/vendor/pear/pear_exception/.travis.yml deleted file mode 100644 index 18875d993..000000000 --- a/vendor/pear/pear_exception/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: php -php: - - 5.6 - - 5.5 - - 5.4 -script: - - cd tests && phpunit --coverage-text . diff --git a/vendor/pear/pear_exception/LICENSE b/vendor/pear/pear_exception/LICENSE deleted file mode 100644 index a00a2421f..000000000 --- a/vendor/pear/pear_exception/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 1997-2009, - Stig Bakken , - Gregory Beaver , - Helgi Þormar Þorbjörnsson , - Tomas V.V.Cox , - Martin Jansen . -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/pear_exception/PEAR/Exception.php b/vendor/pear/pear_exception/PEAR/Exception.php deleted file mode 100644 index 5abf4f84a..000000000 --- a/vendor/pear/pear_exception/PEAR/Exception.php +++ /dev/null @@ -1,456 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @link http://pear.php.net/package/PEAR_Exception - * @since File available since Release 1.0.0 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category PEAR - * @package PEAR_Exception - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PEAR_Exception - * @since Class available since Release 1.0.0 - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * - * @param string $message exception message - * @param int|Exception|PEAR_Error|array|null $p2 exception cause - * @param int|null $p3 exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception( - 'exception cause must be Exception, ' . - 'array, or PEAR_Error' - ); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * Add an exception observer - * - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - * - * @return void - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - /** - * Remove an exception observer - * - * @param string $label Name of the observer - * - * @return void - */ - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * Generate a unique ID for an observer - * - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - /** - * Send a signal to all observers - * - * @return void - */ - protected function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * - * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * - * @param array $causes Array that gets filled. - * - * @return void - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') - && $cause instanceof PEAR_Error - ) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - /** - * Build a backtrace and return it - * - * @return array Backtrace - */ - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - /** - * Gets the first class of the backtrace - * - * @return string Class name - */ - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - /** - * Gets the first method of the backtrace - * - * @return string Method/function name - */ - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - /** - * Converts the exception to a string (HTML or plain text) - * - * @return string String representation - * - * @see toHtml() - * @see toText() - */ - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - /** - * Generates a HTML representation of the exception - * - * @return string HTML code - */ - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message']) - . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) { - $args[] = 'null'; - } else if (is_array($arg)) { - $args[] = 'Array'; - } else if (is_object($arg)) { - $args[] = 'Object('.get_class($arg).')'; - } else if (is_bool($arg)) { - $args[] = $arg ? 'true' : 'false'; - } else if (is_int($arg) || is_double($arg)) { - $args[] = $arg; - } else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16)); - if (strlen($arg) > 16) { - $str .= '…'; - } - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ', $args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - /** - * Generates text representation of the exception and stack trace - * - * @return string - */ - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} -?> diff --git a/vendor/pear/pear_exception/composer.json b/vendor/pear/pear_exception/composer.json deleted file mode 100644 index ce33ed1c8..000000000 --- a/vendor/pear/pear_exception/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "pear/pear_exception", - "description": "The PEAR Exception base class.", - "type": "class", - "keywords": [ - "exception" - ], - "homepage": "https://github.com/pear/PEAR_Exception", - "license": "BSD-2-Clause", - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "require": { - "php": ">=4.4.0" - }, - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "include-path": [ - "." - ], - "support": { - "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", - "source": "https://github.com/pear/PEAR_Exception" - }, - "require-dev": { - "phpunit/phpunit": "*" - } -} diff --git a/vendor/pear/pear_exception/package.xml b/vendor/pear/pear_exception/package.xml deleted file mode 100644 index 98290c6a8..000000000 --- a/vendor/pear/pear_exception/package.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - PEAR_Exception - pear.php.net - The PEAR Exception base class - PEAR_Exception PHP5 error handling mechanism - - - Christian Weiske - cweiske - cweiske@php.net - yes - - - Helgi Thormar - dufuz - dufuz@php.net - no - - - Greg Beaver - cellog - cellog@php.net - no - - - 2015-02-10 - - - 1.0.0 - 1.0.0 - - - stable - stable - - New BSD License - - This package was split out from the PEAR package. - If you use PEAR_Exception in your package and use nothing from the PEAR package - then it's better to depend on just PEAR_Exception. - - - - - - - - - - - - - - - - - - 5.4.0 - - - 1.9.5 - - - - - - - - - - 1.0.0 - 1.0.0 - - - stable - stable - - 2015-02-10 - New BSD License - Release stable version - - - - - 1.0.0beta2 - 1.0.0 - - - beta - stable - - 2014-02-21 - New BSD License - Bump up PEAR dependency. - - - - - 1.0.0beta1 - 1.0.0 - - - beta - stable - - 2012-05-10 - New BSD License - -This packge was split out from the PEAR package. If you use PEAR_Exception in your package -and use nothing from the PEAR package then it's better to depend on just PEAR_Exception. - - - - diff --git a/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php b/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php deleted file mode 100644 index 61d2df4f1..000000000 --- a/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php +++ /dev/null @@ -1,78 +0,0 @@ -assertNull($e->getCause()); - } - - public function testGetCauseException() - { - $cause = new Exception('foo bar'); - $e = new PEAR_Exception('I caught an exception', $cause); - $this->assertNotNull($e->getCause()); - $this->assertInstanceOf('Exception', $e->getCause()); - $this->assertEquals($cause, $e->getCause()); - } - - public function testGetCauseMessage() - { - $cause = new Exception('foo bar'); - $e = new PEAR_Exception('I caught an exception', $cause); - - $e->getCauseMessage($causes); - $this->assertEquals('I caught an exception', $causes[0]['message']); - $this->assertEquals('foo bar', $causes[1]['message']); - } - - public function testGetTraceSafe() - { - $e = new PEAR_Exception('oops'); - $this->assertInternalType('array', $e->getTraceSafe()); - } - - public function testGetErrorClass() - { - $e = new PEAR_Exception('oops'); - $this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass()); - } - - public function testGetErrorMethod() - { - $e = new PEAR_Exception('oops'); - $this->assertEquals('testGetErrorMethod', $e->getErrorMethod()); - } - - public function test__toString() - { - $e = new PEAR_Exception('oops'); - $this->assertInternalType('string', (string) $e); - $this->assertContains('oops', (string) $e); - } - - public function testToHtml() - { - $e = new PEAR_Exception('oops'); - $html = $e->toHtml(); - $this->assertInternalType('string', $html); - $this->assertContains('oops', $html); - } -} -?> From 9da3653fcdd0270b55aca652cd26f849c32a19da Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 15:46:41 +0900 Subject: [PATCH 4/8] Replace idna_convert with PHP native functions and true/punycode --- classes/context/Context.class.php | 38 +- config/func.inc.php | 4 +- libs/idna_convert/LICENCE | 502 --- libs/idna_convert/ReadMe.txt | 198 - libs/idna_convert/example.php | 133 - libs/idna_convert/idna_convert.class.php | 3461 ------------------ libs/idna_convert/transcode_wrapper.php | 137 - libs/idna_convert/uctc.php | 300 -- modules/install/install.admin.controller.php | 4 +- 9 files changed, 34 insertions(+), 4743 deletions(-) delete mode 100644 libs/idna_convert/LICENCE delete mode 100644 libs/idna_convert/ReadMe.txt delete mode 100644 libs/idna_convert/example.php delete mode 100644 libs/idna_convert/idna_convert.class.php delete mode 100644 libs/idna_convert/transcode_wrapper.php delete mode 100644 libs/idna_convert/uctc.php diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 4e8d72591..67893612d 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1199,16 +1199,42 @@ class Context return $obj->str; } + /** + * Encode UTF-8 domain into IDNA (punycode) + * + * @param string $domain Domain to convert + * @return string Converted string + */ + public static function encodeIdna($domain) + { + if(function_exists('idn_to_ascii')) + { + return idn_to_ascii($domain); + } + else + { + $encoder = new TrueBV\Punycode(); + return $encoder->encode($domain); + } + } + + /** + * Convert IDNA (punycode) domain into UTF-8 + * + * @param string $domain Domain to convert + * @return string Converted string + */ public static function decodeIdna($domain) { - if(strpos($domain, 'xn--') !== FALSE) + if(function_exists('idn_to_utf8')) { - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); - $IDN = new idna_convert(array('idn_version' => 2008)); - $domain = $IDN->decode($domain); + return idn_to_utf8($domain); + } + else + { + $decoder = new TrueBV\Punycode(); + return $decoder->decode($domain); } - - return $domain; } /** diff --git a/config/func.inc.php b/config/func.inc.php index c35f9b562..e3992f9b6 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -1468,9 +1468,7 @@ function checkCSRF() if(strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) { - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); - $IDN = new idna_convert(array('idn_version' => 2008)); - $referer = $IDN->encode($referer); + $referer = Context::encodeIdna($referer); } $default_url = parse_url($default_url); diff --git a/libs/idna_convert/LICENCE b/libs/idna_convert/LICENCE deleted file mode 100644 index 02edb77b7..000000000 --- a/libs/idna_convert/LICENCE +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Boston, MA 02110, United States - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/libs/idna_convert/ReadMe.txt b/libs/idna_convert/ReadMe.txt deleted file mode 100644 index 6439a8ff1..000000000 --- a/libs/idna_convert/ReadMe.txt +++ /dev/null @@ -1,198 +0,0 @@ -******************************************************************************* -* * -* IDNA Convert (idna_convert.class.php) * -* * -* http://idnaconv.phlymail.de mailto:phlymail@phlylabs.de * -******************************************************************************* -* (c) 2004-2014 phlyLabs, Berlin * -* This file is encoded in UTF-8 * -******************************************************************************* - -Introduction ------------- - -The class idna_convert allows to convert internationalized domain names -(see RFC 3490, 3491, 3492 and 3454 for detials) as they can be used with various -registries worldwide to be translated between their original (localized) form -and their encoded form as it will be used in the DNS (Domain Name System). - -The class provides two public methods, encode() and decode(), which do exactly -what you would expect them to do. You are allowed to use complete domain names, -simple strings and complete email addresses as well. That means, that you might -use any of the following notations: - -- www.nörgler.com -- xn--nrgler-wxa -- xn--brse-5qa.xn--knrz-1ra.info - -Errors, incorrectly encoded or invalid strings will lead to either a FALSE -response (when in strict mode) or to only partially converted strings. -You can query the occured error by calling the method get_last_error(). - -Unicode strings are expected to be either UTF-8 strings, UCS-4 strings or UCS-4 -arrays. The default format is UTF-8. For setting different encodings, you can -call the method setParams() - please see the inline documentation for details. -ACE strings (the Punycode form) are always 7bit ASCII strings. - -ATTENTION: As of version 0.6.0 this class is written in the OOP style of PHP5. -Since PHP4 is no longer actively maintained, you should switch to PHP5 as fast as -possible. -We expect to see no compatibility issues with the upcoming PHP6, too. - -ATTENTION: BC break! As of version 0.6.4 the class per default allows the German -ligature ß to be encoded as the DeNIC, the registry for .DE allows domains -containing ß. -In older builds "ß" was mapped to "ss". Should you still need this behaviour, -see example 5 below. - -ATTENTION: As of version 0.8.0 the class fully supports IDNA 2008. Thus the -aforementioned parameter is deprecated and replaced by a parameter to switch -between the standards. See the updated example 5 below. - -Files ------ -idna_convert.class.php - The actual class -example.php - An example web page for converting -transcode_wrapper.php - Convert various encodings, see below -uctc.php - phlyLabs' Unicode Transcoder, see below -ReadMe.txt - This file -LICENCE - The LGPL licence file - -The class is contained in idna_convert.class.php. - - -Examples --------- -1. Say we wish to encode the domain name nörgler.com: - -// Include the class -require_once('idna_convert.class.php'); -// Instantiate it -$IDN = new idna_convert(); -// The input string, if input is not UTF-8 or UCS-4, it must be converted before -$input = utf8_encode('nörgler.com'); -// Encode it to its punycode presentation -$output = $IDN->encode($input); -// Output, what we got now -echo $output; // This will read: xn--nrgler-wxa.com - - -2. We received an email from a punycoded domain and are willing to learn, how - the domain name reads originally - -// Include the class -require_once('idna_convert.class.php'); -// Instantiate it -$IDN = new idna_convert(); -// The input string -$input = 'andre@xn--brse-5qa.xn--knrz-1ra.info'; -// Encode it to its punycode presentation -$output = $IDN->decode($input); -// Output, what we got now, if output should be in a format different to UTF-8 -// or UCS-4, you will have to convert it before outputting it -echo utf8_decode($output); // This will read: andre@börse.knörz.info - - -3. The input is read from a UCS-4 coded file and encoded line by line. By - appending the optional second parameter we tell enode() about the input - format to be used - -// Include the class -require_once('idna_convert.class.php'); -// Instantiate it -$IDN = new dinca_convert(); -// Iterate through the input file line by line -foreach (file('ucs4-domains.txt') as $line) { - echo $IDN->encode(trim($line), 'ucs4_string'); - echo "\n"; -} - - -4. We wish to convert a whole URI into the IDNA form, but leave the path or - query string component of it alone. Just using encode() would lead to mangled - paths or query strings. Here the public method encode_uri() comes into play: - -// Include the class -require_once('idna_convert.class.php'); -// Instantiate it -$IDN = new idna_convert(); -// The input string, a whole URI in UTF-8 (!) -$input = 'http://nörgler:secret@nörgler.com/my_päth_is_not_ÄSCII/'); -// Encode it to its punycode presentation -$output = $IDN->encode_uri($input); -// Output, what we got now -echo $output; // http://nörgler:secret@xn--nrgler-wxa.com/my_päth_is_not_ÄSCII/ - - -5. To support IDNA 2008, the class needs to be invoked with an additional - parameter. This can also be achieved on an instance. - -// Include the class -require_once('idna_convert.class.php'); -// Instantiate it -$IDN = new idna_convert(array('idn_version' => 2008)); -// Sth. containing the German letter ß -$input = 'meine-straße.de'); -// Encode it to its punycode presentation -$output = $IDN->encode_uri($input); -// Output, what we got now -echo $output; // xn--meine-strae-46a.de -// Switch back to old IDNA 2003, the original standard -$IDN->set_parameter('idn_version', 2003); -// Sth. containing the German letter ß -$input = 'meine-straße.de'); -// Encode it to its punycode presentation -$output = $IDN->encode_uri($input); -// Output, what we got now -echo $output; // meine-strasse.de - - -Transcode wrapper ------------------ -In case you have strings in different encoding than ISO-8859-1 and UTF-8 you might need to -translate these strings to UTF-8 before feeding the IDNA converter with it. -PHP's built in functions utf8_encode() and utf8_decode() can only deal with ISO-8859-1. -Use the file transcode_wrapper.php for the conversion. It requires either iconv, libiconv -or mbstring installed together with one of the relevant PHP extensions. -The functions you will find useful are -encode_utf8() as a replacement for utf8_encode() and -decode_utf8() as a replacement for utf8_decode(). - -Example usage: -encode($mystring); -?> - - -UCTC - Unicode Transcoder -------------------------- -Another class you might find useful when dealing with one or more of the Unicode encoding -flavours. The class is static, it requires PHP5. It can transcode into each other: -- UCS-4 string / array -- UTF-8 -- UTF-7 -- UTF-7 IMAP (modified UTF-7) -All encodings expect / return a string in the given format, with one major exception: -UCS-4 array is jsut an array, where each value represents one codepoint in the string, i.e. -every value is a 32bit integer value. - -Example usage: - - - -Contact us ----------- -In case of errors, bugs, questions, wishes, please don't hesitate to contact us -under the email address above. - -The team of phlyLabs -http://phlylabs.de -mailto:phlymail@phlylabs.de \ No newline at end of file diff --git a/libs/idna_convert/example.php b/libs/idna_convert/example.php deleted file mode 100644 index 0ee314f50..000000000 --- a/libs/idna_convert/example.php +++ /dev/null @@ -1,133 +0,0 @@ - $idn_version)); - -$version_select = ''."\n"; - } -} -?> - - - -phlyLabs Punycode Converter - - - - - -
-
phlyLabs' pure PHP IDNA Converter

- - See the RFCs 3490, - 3491, - 3492 and - 3454 as well as - 5890, - 5891, - 5892, - 5893 and - RFC5894.
-
-
-
- Dieser Konverter erlaubt die Übersetzung von Domainnamen zwischen der Punycode- und der - Unicode-Schreibweise.
- Geben Sie einfach den Domainnamen im entsprechend bezeichneten Feld ein und klicken Sie dann auf den darunter - liegenden Button. Sie können einfache Domainnamen, komplette URLs (wie http://jürgen-müller.de) - oder Emailadressen eingeben.
-
- Stellen Sie aber sicher, dass Ihr Browser den Zeichensatz UTF-8 unterstützt.
-
- Wenn Sie Interesse an der zugrundeliegenden PHP-Klasse haben, können Sie diese - hier herunterladen.
-
- Diese Klasse wird ohne Garantie ihrer Funktionstüchtigkeit bereit gestellt. Nutzung auf eigene Gefahr.
- Um sicher zu stellen, dass eine Zeichenkette korrekt umgewandelt wurde, sollten Sie diese immer zurückwandeln - und das Ergebnis mit Ihrer ursprünglichen Eingabe vergleichen.
-
- Fehler und Probleme können Sie gern an team@phlymail.de senden.
- - This converter allows you to transfer domain names between the encoded (Punycode) notation - and the decoded (UTF-8) notation.
- Just enter the domain name in the respective field and click on the button right below it to have - it converted. Please note, that you might even enter complete domain names (like jürgen-müller.de) - or a email addresses.
-
- Make sure, that your browser is capable of the UTF-8 character encoding.
-
- For those of you interested in the PHP source of the underlying class, you might - download it here.
-
- Please be aware, that this class is provided as is and without any liability. Use at your own risk.
- To ensure, that a certain string has been converted correctly, you should convert it both ways and compare the - results.
-
- Please feel free to report bugs and problems to: team@phlymail.com.
- -
-
- - - - - - - - - - - - - -
Original (Unicode)Punycode (ACE)
-
-
- - -
-
-
-
- -
-
-
- Version used: 0.9.0; © 2004-2014 phlyLabs Berlin; part of phlyMail -
- - \ No newline at end of file diff --git a/libs/idna_convert/idna_convert.class.php b/libs/idna_convert/idna_convert.class.php deleted file mode 100644 index ed32dc807..000000000 --- a/libs/idna_convert/idna_convert.class.php +++ /dev/null @@ -1,3461 +0,0 @@ - - * @copyright 2004-2014 phlyLabs Berlin, http://phlylabs.de - * @version 0.9.0 2014-12-12 - */ -class idna_convert { - - private $version = '0.9.0'; - protected $sub_version = 'main'; - - // NP See below - // Internal settings, do not mess with them - protected $_punycode_prefix = 'xn--'; - protected $_invalid_ucs = 0x80000000; - protected $_max_ucs = 0x10FFFF; - protected $_base = 36; - protected $_tmin = 1; - protected $_tmax = 26; - protected $_skew = 38; - protected $_damp = 700; - protected $_initial_bias = 72; - protected $_initial_n = 0x80; - protected $_sbase = 0xAC00; - protected $_lbase = 0x1100; - protected $_vbase = 0x1161; - protected $_tbase = 0x11A7; - protected $_lcount = 19; - protected $_vcount = 21; - protected $_tcount = 28; - protected $_ncount = 588; // _vcount * _tcount - protected $_scount = 11172; // _lcount * _tcount * _vcount - protected $_error = false; - protected static $_mb_string_overload = null; - // See {@link set_paramter()} for details of how to change the following - // settings from within your script / application - protected $_api_encoding = 'utf8'; // Default input charset is UTF-8 - protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden - protected $_strict_mode = false; // Behave strict or not - protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008 - - /** - * the constructor - * - * @param array $options - * @return boolean - * @since 0.5.2 - */ - public function __construct($options = false) - { - $this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount; - // If parameters are given, pass these to the respective method - if (is_array($options)) { - $this->set_parameter($options); - } - - // populate mbstring overloading cache if not set - if (self::$_mb_string_overload === null) { - self::$_mb_string_overload = (extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02); - } - } - - public function get_version() - { - return $this->version.'-'.$this->sub_version; - } - - /** - * Sets a new option value. Available options and values: - * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8, - * 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8] - * [overlong - Unicode does not allow unnecessarily long encodings of chars, - * to allow this, set this parameter to true, else to false; - * default is false.] - * [strict - true: strict mode, good for registration purposes - Causes errors - * on failures; false: loose mode, ideal for "wildlife" applications - * by silently ignoring errors and returning the original input instead - * - * @param mixed Parameter to set (string: single parameter; array of Parameter => Value pairs) - * @param string Value to use (if parameter 1 is a string) - * @return boolean true on success, false otherwise - */ - public function set_parameter($option, $value = false) - { - if (!is_array($option)) { - $option = array($option => $value); - } - foreach ($option as $k => $v) { - switch ($k) { - case 'encoding': - switch ($v) { - case 'utf8': - case 'ucs4_string': - case 'ucs4_array': - $this->_api_encoding = $v; - break; - default: - $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); - return false; - } - break; - case 'overlong': - $this->_allow_overlong = ($v) ? true : false; - break; - case 'strict': - $this->_strict_mode = ($v) ? true : false; - break; - case 'idn_version': - if (in_array($v, array('2003', '2008'))) { - $this->_idn_version = $v; - } else { - $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); - } - break; - case 'encode_german_sz': // Deprecated - if (!$v) { - self::$NP['replacemaps'][0xDF] = array(0x73, 0x73); - } else { - unset(self::$NP['replacemaps'][0xDF]); - } - break; - default: - $this->_error('Set Parameter: Unknown option ' . $k); - return false; - } - } - return true; - } - - /** - * Decode a given ACE domain name - * @param string Domain name (ACE string) - * [@param string Desired output encoding, see {@link set_parameter}] - * @return string Decoded Domain name (UTF-8 or UCS-4) - */ - public function decode($input, $one_time_encoding = false) - { - // Optionally set - if ($one_time_encoding) { - switch ($one_time_encoding) { - case 'utf8': - case 'ucs4_string': - case 'ucs4_array': - break; - default: - $this->_error('Unknown encoding ' . $one_time_encoding); - return false; - } - } - // Make sure to drop any newline characters around - $input = trim($input); - - // Negotiate input and try to determine, whether it is a plain string, - // an email address or something like a complete URL - if (strpos($input, '@')) { // Maybe it is an email address - // No no in strict mode - if ($this->_strict_mode) { - $this->_error('Only simple domain name parts can be handled in strict mode'); - return false; - } - list ($email_pref, $input) = explode('@', $input, 2); - $arr = explode('.', $input); - foreach ($arr as $k => $v) { - if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) { - $conv = $this->_decode($v); - if ($conv) { - $arr[$k] = $conv; - } - } - } - $input = join('.', $arr); - $arr = explode('.', $email_pref); - foreach ($arr as $k => $v) { - if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) { - $conv = $this->_decode($v); - if ($conv) { - $arr[$k] = $conv; - } - } - } - $email_pref = join('.', $arr); - $return = $email_pref . '@' . $input; - } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters) - // No no in strict mode - if ($this->_strict_mode) { - $this->_error('Only simple domain name parts can be handled in strict mode'); - return false; - } - $parsed = parse_url($input); - if (isset($parsed['host'])) { - $arr = explode('.', $parsed['host']); - foreach ($arr as $k => $v) { - $conv = $this->_decode($v); - if ($conv) { - $arr[$k] = $conv; - } - } - $parsed['host'] = join('.', $arr); - $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')). - (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@'). - $parsed['host']. - (empty($parsed['port']) ? '' : ':' . $parsed['port']). - (empty($parsed['path']) ? '' : $parsed['path']). - (empty($parsed['query']) ? '' : '?' . $parsed['query']). - (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); - } else { // parse_url seems to have failed, try without it - $arr = explode('.', $input); - foreach ($arr as $k => $v) { - $conv = $this->_decode($v); - $arr[$k] = ($conv) ? $conv : $v; - } - $return = join('.', $arr); - } - } else { // Otherwise we consider it being a pure domain name string - $return = $this->_decode($input); - if (!$return) { - $return = $input; - } - } - // The output is UTF-8 by default, other output formats need conversion here - // If one time encoding is given, use this, else the objects property - switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { - case 'utf8': return $return; // break; - case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); // break; - case 'ucs4_array': return $this->_utf8_to_ucs4($return); // break; - default: $this->_error('Unsupported output format'); return false; - } - } - - /** - * Encode a given UTF-8 domain name - * @param string Domain name (UTF-8 or UCS-4) - * [@param string Desired input encoding, see {@link set_parameter}] - * @return string Encoded Domain name (ACE string) - */ - public function encode($decoded, $one_time_encoding = false) - { - // Forcing conversion of input to UCS4 array - // If one time encoding is given, use this, else the objects property - switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) { - case 'utf8': - $decoded = $this->_utf8_to_ucs4($decoded); - break; - case 'ucs4_string': - $decoded = $this->_ucs4_string_to_ucs4($decoded); - case 'ucs4_array': - break; - default: - $this->_error('Unsupported input format: ' . ($one_time_encoding ? $one_time_encoding : $this->_api_encoding)); - return false; - } - - // No input, no output, what else did you expect? - if (empty($decoded)) { - return ''; - } - - // Anchors for iteration - $last_begin = 0; - // Output string - $output = ''; - foreach ($decoded as $k => $v) { - // Make sure to use just the plain dot - switch ($v) { - case 0x3002: - case 0xFF0E: - case 0xFF61: - $decoded[$k] = 0x2E; - // Right, no break here, the above are converted to dots anyway - // Stumbling across an anchoring character - case 0x2E: - case 0x2F: - case 0x3A: - case 0x3F: - case 0x40: - // Neither email addresses nor URLs allowed in strict mode - if ($this->_strict_mode) { - $this->_error('Neither email addresses nor URLs are allowed in strict mode.'); - return false; - } else { - // Skip first char - if ($k) { - $encoded = ''; - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k) - $last_begin))); - if ($encoded) { - $output .= $encoded; - } else { - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k) - $last_begin))); - } - $output .= chr($decoded[$k]); - } - $last_begin = $k + 1; - } - } - } - // Catch the rest of the string - if ($last_begin) { - $inp_len = sizeof($decoded); - $encoded = ''; - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len) - $last_begin))); - if ($encoded) { - $output .= $encoded; - } else { - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len) - $last_begin))); - } - return $output; - } else { - if (false !== ($output = $this->_encode($decoded))) { - return $output; - } else { - return $this->_ucs4_to_utf8($decoded); - } - } - } - - /** - * Removes a weakness of encode(), which cannot properly handle URIs but instead encodes their - * path or query components, too. - * @param string $uri Expects the URI as a UTF-8 (or ASCII) string - * @return string The URI encoded to Punycode, everything but the host component is left alone - * @since 0.6.4 - */ - public function encode_uri($uri) - { - $parsed = parse_url($uri); - if (!isset($parsed['host'])) { - $this->_error('The given string does not look like a URI'); - return false; - } - $arr = explode('.', $parsed['host']); - foreach ($arr as $k => $v) { - $conv = $this->encode($v, 'utf8'); - if ($conv) { - $arr[$k] = $conv; - } - } - $parsed['host'] = join('.', $arr); - $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')). - (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@'). - $parsed['host']. - (empty($parsed['port']) ? '' : ':' . $parsed['port']). - (empty($parsed['path']) ? '' : $parsed['path']). - (empty($parsed['query']) ? '' : '?' . $parsed['query']). - (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); - return $return; - } - - /** - * Use this method to get the last error ocurred - * @param void - * @return string The last error, that occured - */ - public function get_last_error() - { - return $this->_error; - } - - /** - * The actual decoding algorithm - * @param string - * @return mixed - */ - protected function _decode($encoded) - { - $decoded = array(); - // find the Punycode prefix - if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) { - $this->_error('This is not a punycode string'); - return false; - } - $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded); - // If nothing left after removing the prefix, it is hopeless - if (!$encode_test) { - $this->_error('The given encoded string was empty'); - return false; - } - // Find last occurence of the delimiter - $delim_pos = strrpos($encoded, '-'); - if ($delim_pos > self::byteLength($this->_punycode_prefix)) { - for ($k = self::byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) { - $decoded[] = ord($encoded{$k}); - } - } - $deco_len = count($decoded); - $enco_len = self::byteLength($encoded); - - // Wandering through the strings; init - $is_first = true; - $bias = $this->_initial_bias; - $idx = 0; - $char = $this->_initial_n; - - for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) { - for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) { - $digit = $this->_decode_digit($encoded{$enco_idx++}); - $idx += $digit * $w; - $t = ($k <= $bias) ? $this->_tmin : - (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); - if ($digit < $t) { - break; - } - $w = (int) ($w * ($this->_base - $t)); - } - $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first); - $is_first = false; - $char += (int) ($idx / ($deco_len + 1)); - $idx %= ($deco_len + 1); - if ($deco_len > 0) { - // Make room for the decoded char - for ($i = $deco_len; $i > $idx; $i--) { - $decoded[$i] = $decoded[($i - 1)]; - } - } - $decoded[$idx++] = $char; - } - return $this->_ucs4_to_utf8($decoded); - } - - /** - * The actual encoding algorithm - * @param string - * @return mixed - */ - protected function _encode($decoded) - { - // We cannot encode a domain name containing the Punycode prefix - $extract = self::byteLength($this->_punycode_prefix); - $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix); - $check_deco = array_slice($decoded, 0, $extract); - - if ($check_pref == $check_deco) { - $this->_error('This is already a punycode string'); - return false; - } - // We will not try to encode strings consisting of basic code points only - $encodable = false; - foreach ($decoded as $k => $v) { - if ($v > 0x7a) { - $encodable = true; - break; - } - } - if (!$encodable) { - $this->_error('The given string does not contain encodable chars'); - return false; - } - // Do NAMEPREP - $decoded = $this->_nameprep($decoded); - if (!$decoded || !is_array($decoded)) { - return false; // NAMEPREP failed - } - $deco_len = count($decoded); - if (!$deco_len) { - return false; // Empty array - } - $codecount = 0; // How many chars have been consumed - $encoded = ''; - // Copy all basic code points to output - for ($i = 0; $i < $deco_len; ++$i) { - $test = $decoded[$i]; - // Will match [-0-9a-zA-Z] - if ((0x2F < $test && $test < 0x40) || (0x40 < $test && $test < 0x5B) || (0x60 < $test && $test <= 0x7B) || (0x2D == $test)) { - $encoded .= chr($decoded[$i]); - $codecount++; - } - } - if ($codecount == $deco_len) { - return $encoded; // All codepoints were basic ones - } - // Start with the prefix; copy it to output - $encoded = $this->_punycode_prefix . $encoded; - // If we have basic code points in output, add an hyphen to the end - if ($codecount) { - $encoded .= '-'; - } - // Now find and encode all non-basic code points - $is_first = true; - $cur_code = $this->_initial_n; - $bias = $this->_initial_bias; - $delta = 0; - while ($codecount < $deco_len) { - // Find the smallest code point >= the current code point and - // remember the last ouccrence of it in the input - for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) { - if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) { - $next_code = $decoded[$i]; - } - } - $delta += ($next_code - $cur_code) * ($codecount + 1); - $cur_code = $next_code; - - // Scan input again and encode all characters whose code point is $cur_code - for ($i = 0; $i < $deco_len; $i++) { - if ($decoded[$i] < $cur_code) { - $delta++; - } elseif ($decoded[$i] == $cur_code) { - for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) { - $t = ($k <= $bias) ? $this->_tmin : - (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); - if ($q < $t) { - break; - } - $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval() - $q = (int) (($q - $t) / ($this->_base - $t)); - } - $encoded .= $this->_encode_digit($q); - $bias = $this->_adapt($delta, $codecount + 1, $is_first); - $codecount++; - $delta = 0; - $is_first = false; - } - } - $delta++; - $cur_code++; - } - return $encoded; - } - - /** - * Adapt the bias according to the current code point and position - * @param int $delta - * @param int $npoints - * @param int $is_first - * @return int - */ - protected function _adapt($delta, $npoints, $is_first) - { - $delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2)); - $delta += intval($delta / $npoints); - for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) { - $delta = intval($delta / ($this->_base - $this->_tmin)); - } - return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew)); - } - - /** - * Encoding a certain digit - * @param int $d - * @return string - */ - protected function _encode_digit($d) - { - return chr($d + 22 + 75 * ($d < 26)); - } - - /** - * Decode a certain digit - * @param int $cp - * @return int - */ - protected function _decode_digit($cp) - { - $cp = ord($cp); - return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base)); - } - - /** - * Internal error handling method - * @param string $error - */ - protected function _error($error = '') - { - $this->_error = $error; - } - - /** - * Do Nameprep according to RFC3491 and RFC3454 - * @param array Unicode Characters - * @return string Unicode Characters, Nameprep'd - */ - protected function _nameprep($input) - { - $output = array(); - // - // Mapping - // Walking through the input array, performing the required steps on each of - // the input chars and putting the result into the output array - // While mapping required chars we apply the cannonical ordering - foreach ($input as $v) { - // Map to nothing == skip that code point - if (in_array($v, self::$NP['map_nothing'])) { - continue; - } - // Try to find prohibited input - if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) { - $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v)); - return false; - } - foreach (self::$NP['prohibit_ranges'] as $range) { - if ($range[0] <= $v && $v <= $range[1]) { - $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v)); - return false; - } - } - - if (0xAC00 <= $v && $v <= 0xD7AF) { - // Hangul syllable decomposition - foreach ($this->_hangul_decompose($v) as $out) { - $output[] = (int) $out; - } - } elseif (($this->_idn_version == '2003') && isset(self::$NP['replacemaps_2003'][$v])) { - foreach ($this->_apply_cannonical_ordering(self::$NP['replacemaps_2003'][$v]) as $out) { - $output[] = (int) $out; - } - } elseif (($this->_idn_version == '2008') && isset(self::$NP['replacemaps'][$v])) { - foreach ($this->_apply_cannonical_ordering(self::$NP['replacemaps'][$v]) as $out) { - $output[] = (int) $out; - } - } else { - $output[] = (int) $v; - } - } - // Before applying any Combining, try to rearrange any Hangul syllables - $output = $this->_hangul_compose($output); - // - // Combine code points - // - $last_class = 0; - $last_starter = 0; - $out_len = count($output); - for ($i = 0; $i < $out_len; ++$i) { - $class = $this->_get_combining_class($output[$i]); - if ((!$last_class || $last_class > $class) && $class) { - // Try to match - $seq_len = $i - $last_starter; - $out = $this->_combine(array_slice($output, $last_starter, $seq_len)); - // On match: Replace the last starter with the composed character and remove - // the now redundant non-starter(s) - if ($out) { - $output[$last_starter] = $out; - if (count($out) != $seq_len) { - for ($j = $i + 1; $j < $out_len; ++$j) { - $output[$j - 1] = $output[$j]; - } - unset($output[$out_len]); - } - // Rewind the for loop by one, since there can be more possible compositions - $i--; - $out_len--; - $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i - 1]); - continue; - } - } - // The current class is 0 - if (!$class) { - $last_starter = $i; - } - $last_class = $class; - } - return $output; - } - - /** - * Decomposes a Hangul syllable - * (see http://www.unicode.org/unicode/reports/tr15/#Hangul - * @param integer 32bit UCS4 code point - * @return array Either Hangul Syllable decomposed or original 32bit value as one value array - */ - protected function _hangul_decompose($char) - { - $sindex = (int) $char - $this->_sbase; - if ($sindex < 0 || $sindex >= $this->_scount) { - return array($char); - } - $result = array(); - $result[] = (int) $this->_lbase + $sindex / $this->_ncount; - $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount; - $T = intval($this->_tbase + $sindex % $this->_tcount); - if ($T != $this->_tbase) { - $result[] = $T; - } - return $result; - } - - /** - * Ccomposes a Hangul syllable - * (see http://www.unicode.org/unicode/reports/tr15/#Hangul - * @param array Decomposed UCS4 sequence - * @return array UCS4 sequence with syllables composed - */ - protected function _hangul_compose($input) - { - $inp_len = count($input); - if (!$inp_len) { - return array(); - } - $result = array(); - $last = (int) $input[0]; - $result[] = $last; // copy first char from input to output - - for ($i = 1; $i < $inp_len; ++$i) { - $char = (int) $input[$i]; - $sindex = $last - $this->_sbase; - $lindex = $last - $this->_lbase; - $vindex = $char - $this->_vbase; - $tindex = $char - $this->_tbase; - // Find out, whether two current characters are LV and T - if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0) && 0 <= $tindex && $tindex <= $this->_tcount) { - // create syllable of form LVT - $last += $tindex; - $result[(count($result) - 1)] = $last; // reset last - continue; // discard char - } - // Find out, whether two current characters form L and V - if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) { - // create syllable of form LV - $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount; - $result[(count($result) - 1)] = $last; // reset last - continue; // discard char - } - // if neither case was true, just add the character - $last = $char; - $result[] = $char; - } - return $result; - } - - /** - * Returns the combining class of a certain wide char - * @param integer Wide char to check (32bit integer) - * @return integer Combining class if found, else 0 - */ - protected function _get_combining_class($char) - { - return isset(self::$NP['norm_combcls'][$char]) ? self::$NP['norm_combcls'][$char] : 0; - } - - /** - * Applies the cannonical ordering of a decomposed UCS4 sequence - * @param array Decomposed UCS4 sequence - * @return array Ordered USC4 sequence - */ - protected function _apply_cannonical_ordering($input) - { - $swap = true; - $size = count($input); - while ($swap) { - $swap = false; - $last = $this->_get_combining_class(intval($input[0])); - for ($i = 0; $i < $size - 1; ++$i) { - $next = $this->_get_combining_class(intval($input[$i + 1])); - if ($next != 0 && $last > $next) { - // Move item leftward until it fits - for ($j = $i + 1; $j > 0; --$j) { - if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) { - break; - } - $t = intval($input[$j]); - $input[$j] = intval($input[$j - 1]); - $input[$j - 1] = $t; - $swap = true; - } - // Reentering the loop looking at the old character again - $next = $last; - } - $last = $next; - } - } - return $input; - } - - /** - * Do composition of a sequence of starter and non-starter - * @param array UCS4 Decomposed sequence - * @return array Ordered USC4 sequence - */ - protected function _combine($input) - { - $inp_len = count($input); - if (0 == $inp_len) { - return false; - } - foreach (self::$NP['replacemaps'] as $np_src => $np_target) { - if ($np_target[0] != $input[0]) { - continue; - } - if (count($np_target) != $inp_len) { - continue; - } - $hit = false; - foreach ($input as $k2 => $v2) { - if ($v2 == $np_target[$k2]) { - $hit = true; - } else { - $hit = false; - break; - } - } - if ($hit) { - return $np_src; - } - } - return false; - } - - /** - * This converts an UTF-8 encoded string to its UCS-4 representation - * By talking about UCS-4 "strings" we mean arrays of 32bit integers representing - * each of the "chars". This is due to PHP not being able to handle strings with - * bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too. - * The following UTF-8 encodings are supported: - * bytes bits representation - * 1 7 0xxxxxxx - * 2 11 110xxxxx 10xxxxxx - * 3 16 1110xxxx 10xxxxxx 10xxxxxx - * 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - * 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - * 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - * Each x represents a bit that can be used to store character data. - * The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000 - * @param string $input - * @return string - */ - protected function _utf8_to_ucs4($input) - { - $output = array(); - $out_len = 0; - $inp_len = self::byteLength($input); - $mode = 'next'; - $test = 'none'; - for ($k = 0; $k < $inp_len; ++$k) { - $v = ord($input{$k}); // Extract byte from input string - if ($v < 128) { // We found an ASCII char - put into stirng as is - $output[$out_len] = $v; - ++$out_len; - if ('add' == $mode) { - $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); - return false; - } - continue; - } - if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char - $start_byte = $v; - $mode = 'add'; - $test = 'range'; - if ($v >> 5 == 6) { // &110xxxxx 10xxxxx - $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left - $v = ($v - 192) << 6; - } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx - $next_byte = 1; - $v = ($v - 224) << 12; - } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - $next_byte = 2; - $v = ($v - 240) << 18; - } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - $next_byte = 3; - $v = ($v - 248) << 24; - } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - $next_byte = 4; - $v = ($v - 252) << 30; - } else { - $this->_error('This might be UTF-8, but I don\'t understand it at byte ' . $k); - return false; - } - if ('add' == $mode) { - $output[$out_len] = (int) $v; - ++$out_len; - continue; - } - } - if ('add' == $mode) { - if (!$this->_allow_overlong && $test == 'range') { - $test = 'none'; - if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) { - $this->_error('Bogus UTF-8 character detected (out of legal range) at byte ' . $k); - return false; - } - } - if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx - $v = ($v - 128) << ($next_byte * 6); - $output[($out_len - 1)] += $v; - --$next_byte; - } else { - $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); - return false; - } - if ($next_byte < 0) { - $mode = 'next'; - } - } - } // for - return $output; - } - - /** - * Convert UCS-4 string into UTF-8 string - * See _utf8_to_ucs4() for details - * @param string $input - * @return string - */ - protected function _ucs4_to_utf8($input) - { - $output = ''; - foreach ($input as $k => $v) { - if ($v < 128) { // 7bit are transferred literally - $output .= chr($v); - } elseif ($v < (1 << 11)) { // 2 bytes - $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); - } elseif ($v < (1 << 16)) { // 3 bytes - $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); - } elseif ($v < (1 << 21)) { // 4 bytes - $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); - } else { - $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k); - return false; - } - } - return $output; - } - - /** - * Convert UCS-4 array into UCS-4 string - * - * @param array $input - * @return string - */ - protected function _ucs4_to_ucs4_string($input) - { - $output = ''; - // Take array values and split output to 4 bytes per value - // The bit mask is 255, which reads &11111111 - foreach ($input as $v) { - $output .= chr(($v >> 24) & 255) . chr(($v >> 16) & 255) . chr(($v >> 8) & 255) . chr($v & 255); - } - return $output; - } - - /** - * Convert UCS-4 strin into UCS-4 garray - * - * @param string $input - * @return array - */ - protected function _ucs4_string_to_ucs4($input) - { - $output = array(); - $inp_len = self::byteLength($input); - // Input length must be dividable by 4 - if ($inp_len % 4) { - $this->_error('Input UCS4 string is broken'); - return false; - } - // Empty input - return empty output - if (!$inp_len) { - return $output; - } - for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) { - // Increment output position every 4 input bytes - if (!($i % 4)) { - $out_len++; - $output[$out_len] = 0; - } - $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) ); - } - return $output; - } - - /** - * Gets the length of a string in bytes even if mbstring function - * overloading is turned on - * - * @param string $string the string for which to get the length. - * @return integer the length of the string in bytes. - */ - protected static function byteLength($string) - { - if (self::$_mb_string_overload) { - return mb_strlen($string, '8bit'); - } - return strlen((binary) $string); - } - - /** - * Attempts to return a concrete IDNA instance. - * - * @param array $params Set of paramaters - * @return idna_convert - * @access public - */ - public function getInstance($params = array()) - { - return new idna_convert($params); - } - - /** - * Attempts to return a concrete IDNA instance for either php4 or php5, - * only creating a new instance if no IDNA instance with the same - * parameters currently exists. - * - * @param array $params Set of paramaters - * - * @return object idna_convert - * @access public - */ - public function singleton($params = array()) - { - static $instances = array(); - - $signature = serialize($params); - if (!isset($instances[$signature])) { - $instances[$signature] = idna_convert::getInstance($params); - } - return $instances[$signature]; - } - - /** - * Holds all relevant mapping tables - * See RFC3454 for details - * - * @private array - * @since 0.5.2 - */ - protected static $NP = array( - 'map_nothing' => array(0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C, - 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, - 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF - ), - 'general_prohibited' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 47, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 127, 0x3002 - ), - 'prohibit' => array(0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, - 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x200E, 0x200F, - 0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E, 0x202F, 0x205F, 0x206A, 0x206B, 0x206C, - 0x206D, 0x206E, 0x206F, 0x3000, 0x33C2, 0xFEFF, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF, - 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, - 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, - 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF - ), - 'prohibit_ranges' => array(array(0x80, 0x9F), array(0x2060, 0x206F), array(0x1D173, 0x1D17A), - array(0xE000, 0xF8FF), array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD), - array(0xFDD0, 0xFDEF), array(0xD800, 0xDFFF), array(0x2FF0, 0x2FFB), array(0xE0020, 0xE007F) - ), - 'replacemaps_2003' => array(0x41 => array(0x61), 0x42 => array(0x62), 0x43 => array(0x63), - 0x44 => array(0x64), 0x45 => array(0x65), 0x46 => array(0x66), 0x47 => array(0x67), - 0x48 => array(0x68), 0x49 => array(0x69), 0x4A => array(0x6A), 0x4B => array(0x6B), - 0x4C => array(0x6C), 0x4D => array(0x6D), 0x4E => array(0x6E), 0x4F => array(0x6F), - 0x50 => array(0x70), 0x51 => array(0x71), 0x52 => array(0x72), 0x53 => array(0x73), - 0x54 => array(0x74), 0x55 => array(0x75), 0x56 => array(0x76), 0x57 => array(0x77), - 0x58 => array(0x78), 0x59 => array(0x79), 0x5A => array(0x7A), 0xB5 => array(0x3BC), - 0xC0 => array(0xE0), 0xC1 => array(0xE1), 0xC2 => array(0xE2), 0xC3 => array(0xE3), - 0xC4 => array(0xE4), 0xC5 => array(0xE5), 0xC6 => array(0xE6), 0xC7 => array(0xE7), - 0xC8 => array(0xE8), 0xC9 => array(0xE9), 0xCA => array(0xEA), 0xCB => array(0xEB), - 0xCC => array(0xEC), 0xCD => array(0xED), 0xCE => array(0xEE), 0xCF => array(0xEF), - 0xD0 => array(0xF0), 0xD1 => array(0xF1), 0xD2 => array(0xF2), 0xD3 => array(0xF3), - 0xD4 => array(0xF4), 0xD5 => array(0xF5), 0xD6 => array(0xF6), 0xD8 => array(0xF8), - 0xD9 => array(0xF9), 0xDA => array(0xFA), 0xDB => array(0xFB), 0xDC => array(0xFC), - 0xDD => array(0xFD), 0xDE => array(0xFE), 0xDF => array(0x73, 0x73), - 0x100 => array(0x101), 0x102 => array(0x103), 0x104 => array(0x105), - 0x106 => array(0x107), 0x108 => array(0x109), 0x10A => array(0x10B), - 0x10C => array(0x10D), 0x10E => array(0x10F), 0x110 => array(0x111), - 0x112 => array(0x113), 0x114 => array(0x115), 0x116 => array(0x117), - 0x118 => array(0x119), 0x11A => array(0x11B), 0x11C => array(0x11D), - 0x11E => array(0x11F), 0x120 => array(0x121), 0x122 => array(0x123), - 0x124 => array(0x125), 0x126 => array(0x127), 0x128 => array(0x129), - 0x12A => array(0x12B), 0x12C => array(0x12D), 0x12E => array(0x12F), - 0x130 => array(0x69, 0x307), 0x132 => array(0x133), 0x134 => array(0x135), - 0x136 => array(0x137), 0x139 => array(0x13A), 0x13B => array(0x13C), - 0x13D => array(0x13E), 0x13F => array(0x140), 0x141 => array(0x142), - 0x143 => array(0x144), 0x145 => array(0x146), 0x147 => array(0x148), - 0x149 => array(0x2BC, 0x6E), 0x14A => array(0x14B), 0x14C => array(0x14D), - 0x14E => array(0x14F), 0x150 => array(0x151), 0x152 => array(0x153), - 0x154 => array(0x155), 0x156 => array(0x157), 0x158 => array(0x159), - 0x15A => array(0x15B), 0x15C => array(0x15D), 0x15E => array(0x15F), - 0x160 => array(0x161), 0x162 => array(0x163), 0x164 => array(0x165), - 0x166 => array(0x167), 0x168 => array(0x169), 0x16A => array(0x16B), - 0x16C => array(0x16D), 0x16E => array(0x16F), 0x170 => array(0x171), - 0x172 => array(0x173), 0x174 => array(0x175), 0x176 => array(0x177), - 0x178 => array(0xFF), 0x179 => array(0x17A), 0x17B => array(0x17C), - 0x17D => array(0x17E), 0x17F => array(0x73), 0x181 => array(0x253), - 0x182 => array(0x183), 0x184 => array(0x185), 0x186 => array(0x254), - 0x187 => array(0x188), 0x189 => array(0x256), 0x18A => array(0x257), - 0x18B => array(0x18C), 0x18E => array(0x1DD), 0x18F => array(0x259), - 0x190 => array(0x25B), 0x191 => array(0x192), 0x193 => array(0x260), - 0x194 => array(0x263), 0x196 => array(0x269), 0x197 => array(0x268), - 0x198 => array(0x199), 0x19C => array(0x26F), 0x19D => array(0x272), - 0x19F => array(0x275), 0x1A0 => array(0x1A1), 0x1A2 => array(0x1A3), - 0x1A4 => array(0x1A5), 0x1A6 => array(0x280), 0x1A7 => array(0x1A8), - 0x1A9 => array(0x283), 0x1AC => array(0x1AD), 0x1AE => array(0x288), - 0x1AF => array(0x1B0), 0x1B1 => array(0x28A), 0x1B2 => array(0x28B), - 0x1B3 => array(0x1B4), 0x1B5 => array(0x1B6), 0x1B7 => array(0x292), - 0x1B8 => array(0x1B9), 0x1BC => array(0x1BD), 0x1C4 => array(0x1C6), - 0x1C5 => array(0x1C6), 0x1C7 => array(0x1C9), 0x1C8 => array(0x1C9), - 0x1CA => array(0x1CC), 0x1CB => array(0x1CC), 0x1CD => array(0x1CE), - 0x1CF => array(0x1D0), 0x1D1 => array(0x1D2), 0x1D3 => array(0x1D4), - 0x1D5 => array(0x1D6), 0x1D7 => array(0x1D8), 0x1D9 => array(0x1DA), - 0x1DB => array(0x1DC), 0x1DE => array(0x1DF), 0x1E0 => array(0x1E1), - 0x1E2 => array(0x1E3), 0x1E4 => array(0x1E5), 0x1E6 => array(0x1E7), - 0x1E8 => array(0x1E9), 0x1EA => array(0x1EB), 0x1EC => array(0x1ED), - 0x1EE => array(0x1EF), 0x1F0 => array(0x6A, 0x30C), 0x1F1 => array(0x1F3), - 0x1F2 => array(0x1F3), 0x1F4 => array(0x1F5), 0x1F6 => array(0x195), - 0x1F7 => array(0x1BF), 0x1F8 => array(0x1F9), 0x1FA => array(0x1FB), - 0x1FC => array(0x1FD), 0x1FE => array(0x1FF), 0x200 => array(0x201), - 0x202 => array(0x203), 0x204 => array(0x205), 0x206 => array(0x207), - 0x208 => array(0x209), 0x20A => array(0x20B), 0x20C => array(0x20D), - 0x20E => array(0x20F), 0x210 => array(0x211), 0x212 => array(0x213), - 0x214 => array(0x215), 0x216 => array(0x217), 0x218 => array(0x219), - 0x21A => array(0x21B), 0x21C => array(0x21D), 0x21E => array(0x21F), - 0x220 => array(0x19E), 0x222 => array(0x223), 0x224 => array(0x225), - 0x226 => array(0x227), 0x228 => array(0x229), 0x22A => array(0x22B), - 0x22C => array(0x22D), 0x22E => array(0x22F), 0x230 => array(0x231), - 0x232 => array(0x233), 0x345 => array(0x3B9), 0x37A => array(0x20, 0x3B9), - 0x386 => array(0x3AC), 0x388 => array(0x3AD), 0x389 => array(0x3AE), - 0x38A => array(0x3AF), 0x38C => array(0x3CC), 0x38E => array(0x3CD), - 0x38F => array(0x3CE), 0x390 => array(0x3B9, 0x308, 0x301), - 0x391 => array(0x3B1), 0x392 => array(0x3B2), 0x393 => array(0x3B3), - 0x394 => array(0x3B4), 0x395 => array(0x3B5), 0x396 => array(0x3B6), - 0x397 => array(0x3B7), 0x398 => array(0x3B8), 0x399 => array(0x3B9), - 0x39A => array(0x3BA), 0x39B => array(0x3BB), 0x39C => array(0x3BC), - 0x39D => array(0x3BD), 0x39E => array(0x3BE), 0x39F => array(0x3BF), - 0x3A0 => array(0x3C0), 0x3A1 => array(0x3C1), 0x3A3 => array(0x3C3), - 0x3A4 => array(0x3C4), 0x3A5 => array(0x3C5), 0x3A6 => array(0x3C6), - 0x3A7 => array(0x3C7), 0x3A8 => array(0x3C8), 0x3A9 => array(0x3C9), - 0x3AA => array(0x3CA), 0x3AB => array(0x3CB), 0x3B0 => array(0x3C5, 0x308, 0x301), - 0x3C2 => array(0x3C3), 0x3D0 => array(0x3B2), 0x3D1 => array(0x3B8), - 0x3D2 => array(0x3C5), 0x3D3 => array(0x3CD), 0x3D4 => array(0x3CB), - 0x3D5 => array(0x3C6), 0x3D6 => array(0x3C0), 0x3D8 => array(0x3D9), - 0x3DA => array(0x3DB), 0x3DC => array(0x3DD), 0x3DE => array(0x3DF), - 0x3E0 => array(0x3E1), 0x3E2 => array(0x3E3), 0x3E4 => array(0x3E5), - 0x3E6 => array(0x3E7), 0x3E8 => array(0x3E9), 0x3EA => array(0x3EB), - 0x3EC => array(0x3ED), 0x3EE => array(0x3EF), 0x3F0 => array(0x3BA), - 0x3F1 => array(0x3C1), 0x3F2 => array(0x3C3), 0x3F4 => array(0x3B8), - 0x3F5 => array(0x3B5), 0x400 => array(0x450), 0x401 => array(0x451), - 0x402 => array(0x452), 0x403 => array(0x453), 0x404 => array(0x454), - 0x405 => array(0x455), 0x406 => array(0x456), 0x407 => array(0x457), - 0x408 => array(0x458), 0x409 => array(0x459), 0x40A => array(0x45A), - 0x40B => array(0x45B), 0x40C => array(0x45C), 0x40D => array(0x45D), - 0x40E => array(0x45E), 0x40F => array(0x45F), 0x410 => array(0x430), - 0x411 => array(0x431), 0x412 => array(0x432), 0x413 => array(0x433), - 0x414 => array(0x434), 0x415 => array(0x435), 0x416 => array(0x436), - 0x417 => array(0x437), 0x418 => array(0x438), 0x419 => array(0x439), - 0x41A => array(0x43A), 0x41B => array(0x43B), 0x41C => array(0x43C), - 0x41D => array(0x43D), 0x41E => array(0x43E), 0x41F => array(0x43F), - 0x420 => array(0x440), 0x421 => array(0x441), 0x422 => array(0x442), - 0x423 => array(0x443), 0x424 => array(0x444), 0x425 => array(0x445), - 0x426 => array(0x446), 0x427 => array(0x447), 0x428 => array(0x448), - 0x429 => array(0x449), 0x42A => array(0x44A), 0x42B => array(0x44B), - 0x42C => array(0x44C), 0x42D => array(0x44D), 0x42E => array(0x44E), - 0x42F => array(0x44F), 0x460 => array(0x461), 0x462 => array(0x463), - 0x464 => array(0x465), 0x466 => array(0x467), 0x468 => array(0x469), - 0x46A => array(0x46B), 0x46C => array(0x46D), 0x46E => array(0x46F), - 0x470 => array(0x471), 0x472 => array(0x473), 0x474 => array(0x475), - 0x476 => array(0x477), 0x478 => array(0x479), 0x47A => array(0x47B), - 0x47C => array(0x47D), 0x47E => array(0x47F), 0x480 => array(0x481), - 0x48A => array(0x48B), 0x48C => array(0x48D), 0x48E => array(0x48F), - 0x490 => array(0x491), 0x492 => array(0x493), 0x494 => array(0x495), - 0x496 => array(0x497), 0x498 => array(0x499), 0x49A => array(0x49B), - 0x49C => array(0x49D), 0x49E => array(0x49F), 0x4A0 => array(0x4A1), - 0x4A2 => array(0x4A3), 0x4A4 => array(0x4A5), 0x4A6 => array(0x4A7), - 0x4A8 => array(0x4A9), 0x4AA => array(0x4AB), 0x4AC => array(0x4AD), - 0x4AE => array(0x4AF), 0x4B0 => array(0x4B1), 0x4B2 => array(0x4B3), - 0x4B4 => array(0x4B5), 0x4B6 => array(0x4B7), 0x4B8 => array(0x4B9), - 0x4BA => array(0x4BB), 0x4BC => array(0x4BD), 0x4BE => array(0x4BF), - 0x4C1 => array(0x4C2), 0x4C3 => array(0x4C4), 0x4C5 => array(0x4C6), - 0x4C7 => array(0x4C8), 0x4C9 => array(0x4CA), 0x4CB => array(0x4CC), - 0x4CD => array(0x4CE), 0x4D0 => array(0x4D1), 0x4D2 => array(0x4D3), - 0x4D4 => array(0x4D5), 0x4D6 => array(0x4D7), 0x4D8 => array(0x4D9), - 0x4DA => array(0x4DB), 0x4DC => array(0x4DD), 0x4DE => array(0x4DF), - 0x4E0 => array(0x4E1), 0x4E2 => array(0x4E3), 0x4E4 => array(0x4E5), - 0x4E6 => array(0x4E7), 0x4E8 => array(0x4E9), 0x4EA => array(0x4EB), - 0x4EC => array(0x4ED), 0x4EE => array(0x4EF), 0x4F0 => array(0x4F1), - 0x4F2 => array(0x4F3), 0x4F4 => array(0x4F5), 0x4F8 => array(0x4F9), - 0x500 => array(0x501), 0x502 => array(0x503), 0x504 => array(0x505), - 0x506 => array(0x507), 0x508 => array(0x509), 0x50A => array(0x50B), - 0x50C => array(0x50D), 0x50E => array(0x50F), 0x531 => array(0x561), - 0x532 => array(0x562), 0x533 => array(0x563), 0x534 => array(0x564), - 0x535 => array(0x565), 0x536 => array(0x566), 0x537 => array(0x567), - 0x538 => array(0x568), 0x539 => array(0x569), 0x53A => array(0x56A), - 0x53B => array(0x56B), 0x53C => array(0x56C), 0x53D => array(0x56D), - 0x53E => array(0x56E), 0x53F => array(0x56F), 0x540 => array(0x570), - 0x541 => array(0x571), 0x542 => array(0x572), 0x543 => array(0x573), - 0x544 => array(0x574), 0x545 => array(0x575), 0x546 => array(0x576), - 0x547 => array(0x577), 0x548 => array(0x578), 0x549 => array(0x579), - 0x54A => array(0x57A), 0x54B => array(0x57B), 0x54C => array(0x57C), - 0x54D => array(0x57D), 0x54E => array(0x57E), 0x54F => array(0x57F), - 0x550 => array(0x580), 0x551 => array(0x581), 0x552 => array(0x582), - 0x553 => array(0x583), 0x554 => array(0x584), 0x555 => array(0x585), - 0x556 => array(0x586), 0x587 => array(0x565, 0x582), 0xE33 => array(0xE4D, 0xE32), - 0x1E00 => array(0x1E01), 0x1E02 => array(0x1E03), 0x1E04 => array(0x1E05), - 0x1E06 => array(0x1E07), 0x1E08 => array(0x1E09), 0x1E0A => array(0x1E0B), - 0x1E0C => array(0x1E0D), 0x1E0E => array(0x1E0F), 0x1E10 => array(0x1E11), - 0x1E12 => array(0x1E13), 0x1E14 => array(0x1E15), 0x1E16 => array(0x1E17), - 0x1E18 => array(0x1E19), 0x1E1A => array(0x1E1B), 0x1E1C => array(0x1E1D), - 0x1E1E => array(0x1E1F), 0x1E20 => array(0x1E21), 0x1E22 => array(0x1E23), - 0x1E24 => array(0x1E25), 0x1E26 => array(0x1E27), 0x1E28 => array(0x1E29), - 0x1E2A => array(0x1E2B), 0x1E2C => array(0x1E2D), 0x1E2E => array(0x1E2F), - 0x1E30 => array(0x1E31), 0x1E32 => array(0x1E33), 0x1E34 => array(0x1E35), - 0x1E36 => array(0x1E37), 0x1E38 => array(0x1E39), 0x1E3A => array(0x1E3B), - 0x1E3C => array(0x1E3D), 0x1E3E => array(0x1E3F), 0x1E40 => array(0x1E41), - 0x1E42 => array(0x1E43), 0x1E44 => array(0x1E45), 0x1E46 => array(0x1E47), - 0x1E48 => array(0x1E49), 0x1E4A => array(0x1E4B), 0x1E4C => array(0x1E4D), - 0x1E4E => array(0x1E4F), 0x1E50 => array(0x1E51), 0x1E52 => array(0x1E53), - 0x1E54 => array(0x1E55), 0x1E56 => array(0x1E57), 0x1E58 => array(0x1E59), - 0x1E5A => array(0x1E5B), 0x1E5C => array(0x1E5D), 0x1E5E => array(0x1E5F), - 0x1E60 => array(0x1E61), 0x1E62 => array(0x1E63), 0x1E64 => array(0x1E65), - 0x1E66 => array(0x1E67), 0x1E68 => array(0x1E69), 0x1E6A => array(0x1E6B), - 0x1E6C => array(0x1E6D), 0x1E6E => array(0x1E6F), 0x1E70 => array(0x1E71), - 0x1E72 => array(0x1E73), 0x1E74 => array(0x1E75), 0x1E76 => array(0x1E77), - 0x1E78 => array(0x1E79), 0x1E7A => array(0x1E7B), 0x1E7C => array(0x1E7D), - 0x1E7E => array(0x1E7F), 0x1E80 => array(0x1E81), 0x1E82 => array(0x1E83), - 0x1E84 => array(0x1E85), 0x1E86 => array(0x1E87), 0x1E88 => array(0x1E89), - 0x1E8A => array(0x1E8B), 0x1E8C => array(0x1E8D), 0x1E8E => array(0x1E8F), - 0x1E90 => array(0x1E91), 0x1E92 => array(0x1E93), 0x1E94 => array(0x1E95), - 0x1E96 => array(0x68, 0x331), 0x1E97 => array(0x74, 0x308), 0x1E98 => array(0x77, 0x30A), - 0x1E99 => array(0x79, 0x30A), 0x1E9A => array(0x61, 0x2BE), 0x1E9B => array(0x1E61), - 0x1EA0 => array(0x1EA1), 0x1EA2 => array(0x1EA3), 0x1EA4 => array(0x1EA5), - 0x1EA6 => array(0x1EA7), 0x1EA8 => array(0x1EA9), 0x1EAA => array(0x1EAB), - 0x1EAC => array(0x1EAD), 0x1EAE => array(0x1EAF), 0x1EB0 => array(0x1EB1), - 0x1EB2 => array(0x1EB3), 0x1EB4 => array(0x1EB5), 0x1EB6 => array(0x1EB7), - 0x1EB8 => array(0x1EB9), 0x1EBA => array(0x1EBB), 0x1EBC => array(0x1EBD), - 0x1EBE => array(0x1EBF), 0x1EC0 => array(0x1EC1), 0x1EC2 => array(0x1EC3), - 0x1EC4 => array(0x1EC5), 0x1EC6 => array(0x1EC7), 0x1EC8 => array(0x1EC9), - 0x1ECA => array(0x1ECB), 0x1ECC => array(0x1ECD), 0x1ECE => array(0x1ECF), - 0x1ED0 => array(0x1ED1), 0x1ED2 => array(0x1ED3), 0x1ED4 => array(0x1ED5), - 0x1ED6 => array(0x1ED7), 0x1ED8 => array(0x1ED9), 0x1EDA => array(0x1EDB), - 0x1EDC => array(0x1EDD), 0x1EDE => array(0x1EDF), 0x1EE0 => array(0x1EE1), - 0x1EE2 => array(0x1EE3), 0x1EE4 => array(0x1EE5), 0x1EE6 => array(0x1EE7), - 0x1EE8 => array(0x1EE9), 0x1EEA => array(0x1EEB), 0x1EEC => array(0x1EED), - 0x1EEE => array(0x1EEF), 0x1EF0 => array(0x1EF1), 0x1EF2 => array(0x1EF3), - 0x1EF4 => array(0x1EF5), 0x1EF6 => array(0x1EF7), 0x1EF8 => array(0x1EF9), - 0x1F08 => array(0x1F00), 0x1F09 => array(0x1F01), 0x1F0A => array(0x1F02), - 0x1F0B => array(0x1F03), 0x1F0C => array(0x1F04), 0x1F0D => array(0x1F05), - 0x1F0E => array(0x1F06), 0x1F0F => array(0x1F07), 0x1F18 => array(0x1F10), - 0x1F19 => array(0x1F11), 0x1F1A => array(0x1F12), 0x1F1B => array(0x1F13), - 0x1F1C => array(0x1F14), 0x1F1D => array(0x1F15), 0x1F28 => array(0x1F20), - 0x1F29 => array(0x1F21), 0x1F2A => array(0x1F22), 0x1F2B => array(0x1F23), - 0x1F2C => array(0x1F24), 0x1F2D => array(0x1F25), 0x1F2E => array(0x1F26), - 0x1F2F => array(0x1F27), 0x1F38 => array(0x1F30), 0x1F39 => array(0x1F31), - 0x1F3A => array(0x1F32), 0x1F3B => array(0x1F33), 0x1F3C => array(0x1F34), - 0x1F3D => array(0x1F35), 0x1F3E => array(0x1F36), 0x1F3F => array(0x1F37), - 0x1F48 => array(0x1F40), 0x1F49 => array(0x1F41), 0x1F4A => array(0x1F42), - 0x1F4B => array(0x1F43), 0x1F4C => array(0x1F44), 0x1F4D => array(0x1F45), - 0x1F50 => array(0x3C5, 0x313), 0x1F52 => array(0x3C5, 0x313, 0x300), - 0x1F54 => array(0x3C5, 0x313, 0x301), 0x1F56 => array(0x3C5, 0x313, 0x342), - 0x1F59 => array(0x1F51), 0x1F5B => array(0x1F53), 0x1F5D => array(0x1F55), - 0x1F5F => array(0x1F57), 0x1F68 => array(0x1F60), 0x1F69 => array(0x1F61), - 0x1F6A => array(0x1F62), 0x1F6B => array(0x1F63), 0x1F6C => array(0x1F64), - 0x1F6D => array(0x1F65), 0x1F6E => array(0x1F66), 0x1F6F => array(0x1F67), - 0x1F80 => array(0x1F00, 0x3B9), 0x1F81 => array(0x1F01, 0x3B9), - 0x1F82 => array(0x1F02, 0x3B9), 0x1F83 => array(0x1F03, 0x3B9), - 0x1F84 => array(0x1F04, 0x3B9), 0x1F85 => array(0x1F05, 0x3B9), - 0x1F86 => array(0x1F06, 0x3B9), 0x1F87 => array(0x1F07, 0x3B9), - 0x1F88 => array(0x1F00, 0x3B9), 0x1F89 => array(0x1F01, 0x3B9), - 0x1F8A => array(0x1F02, 0x3B9), 0x1F8B => array(0x1F03, 0x3B9), - 0x1F8C => array(0x1F04, 0x3B9), 0x1F8D => array(0x1F05, 0x3B9), - 0x1F8E => array(0x1F06, 0x3B9), 0x1F8F => array(0x1F07, 0x3B9), - 0x1F90 => array(0x1F20, 0x3B9), 0x1F91 => array(0x1F21, 0x3B9), - 0x1F92 => array(0x1F22, 0x3B9), 0x1F93 => array(0x1F23, 0x3B9), - 0x1F94 => array(0x1F24, 0x3B9), 0x1F95 => array(0x1F25, 0x3B9), - 0x1F96 => array(0x1F26, 0x3B9), 0x1F97 => array(0x1F27, 0x3B9), - 0x1F98 => array(0x1F20, 0x3B9), 0x1F99 => array(0x1F21, 0x3B9), - 0x1F9A => array(0x1F22, 0x3B9), 0x1F9B => array(0x1F23, 0x3B9), - 0x1F9C => array(0x1F24, 0x3B9), 0x1F9D => array(0x1F25, 0x3B9), - 0x1F9E => array(0x1F26, 0x3B9), 0x1F9F => array(0x1F27, 0x3B9), - 0x1FA0 => array(0x1F60, 0x3B9), 0x1FA1 => array(0x1F61, 0x3B9), - 0x1FA2 => array(0x1F62, 0x3B9), 0x1FA3 => array(0x1F63, 0x3B9), - 0x1FA4 => array(0x1F64, 0x3B9), 0x1FA5 => array(0x1F65, 0x3B9), - 0x1FA6 => array(0x1F66, 0x3B9), 0x1FA7 => array(0x1F67, 0x3B9), - 0x1FA8 => array(0x1F60, 0x3B9), 0x1FA9 => array(0x1F61, 0x3B9), - 0x1FAA => array(0x1F62, 0x3B9), 0x1FAB => array(0x1F63, 0x3B9), - 0x1FAC => array(0x1F64, 0x3B9), 0x1FAD => array(0x1F65, 0x3B9), - 0x1FAE => array(0x1F66, 0x3B9), 0x1FAF => array(0x1F67, 0x3B9), - 0x1FB2 => array(0x1F70, 0x3B9), 0x1FB3 => array(0x3B1, 0x3B9), - 0x1FB4 => array(0x3AC, 0x3B9), 0x1FB6 => array(0x3B1, 0x342), - 0x1FB7 => array(0x3B1, 0x342, 0x3B9), 0x1FB8 => array(0x1FB0), - 0x1FB9 => array(0x1FB1), 0x1FBA => array(0x1F70), 0x1FBB => array(0x1F71), - 0x1FBC => array(0x3B1, 0x3B9), 0x1FBE => array(0x3B9), - 0x1FC2 => array(0x1F74, 0x3B9), 0x1FC3 => array(0x3B7, 0x3B9), - 0x1FC4 => array(0x3AE, 0x3B9), 0x1FC6 => array(0x3B7, 0x342), - 0x1FC7 => array(0x3B7, 0x342, 0x3B9), 0x1FC8 => array(0x1F72), - 0x1FC9 => array(0x1F73), 0x1FCA => array(0x1F74), 0x1FCB => array(0x1F75), - 0x1FCC => array(0x3B7, 0x3B9), 0x1FD2 => array(0x3B9, 0x308, 0x300), - 0x1FD3 => array(0x3B9, 0x308, 0x301), 0x1FD6 => array(0x3B9, 0x342), - 0x1FD7 => array(0x3B9, 0x308, 0x342), 0x1FD8 => array(0x1FD0), - 0x1FD9 => array(0x1FD1), 0x1FDA => array(0x1F76), - 0x1FDB => array(0x1F77), 0x1FE2 => array(0x3C5, 0x308, 0x300), - 0x1FE3 => array(0x3C5, 0x308, 0x301), 0x1FE4 => array(0x3C1, 0x313), - 0x1FE6 => array(0x3C5, 0x342), 0x1FE7 => array(0x3C5, 0x308, 0x342), - 0x1FE8 => array(0x1FE0), 0x1FE9 => array(0x1FE1), - 0x1FEA => array(0x1F7A), 0x1FEB => array(0x1F7B), - 0x1FEC => array(0x1FE5), 0x1FF2 => array(0x1F7C, 0x3B9), - 0x1FF3 => array(0x3C9, 0x3B9), 0x1FF4 => array(0x3CE, 0x3B9), - 0x1FF6 => array(0x3C9, 0x342), 0x1FF7 => array(0x3C9, 0x342, 0x3B9), - 0x1FF8 => array(0x1F78), 0x1FF9 => array(0x1F79), 0x1FFA => array(0x1F7C), - 0x1FFB => array(0x1F7D), 0x1FFC => array(0x3C9, 0x3B9), - 0x20A8 => array(0x72, 0x73), 0x2102 => array(0x63), 0x2103 => array(0xB0, 0x63), - 0x2107 => array(0x25B), 0x2109 => array(0xB0, 0x66), 0x210B => array(0x68), - 0x210C => array(0x68), 0x210D => array(0x68), 0x2110 => array(0x69), - 0x2111 => array(0x69), 0x2112 => array(0x6C), 0x2115 => array(0x6E), - 0x2116 => array(0x6E, 0x6F), 0x2119 => array(0x70), 0x211A => array(0x71), - 0x211B => array(0x72), 0x211C => array(0x72), 0x211D => array(0x72), - 0x2120 => array(0x73, 0x6D), 0x2121 => array(0x74, 0x65, 0x6C), - 0x2122 => array(0x74, 0x6D), 0x2124 => array(0x7A), 0x2126 => array(0x3C9), - 0x2128 => array(0x7A), 0x212A => array(0x6B), 0x212B => array(0xE5), - 0x212C => array(0x62), 0x212D => array(0x63), 0x2130 => array(0x65), - 0x2131 => array(0x66), 0x2133 => array(0x6D), 0x213E => array(0x3B3), - 0x213F => array(0x3C0), 0x2145 => array(0x64), 0x2160 => array(0x2170), - 0x2161 => array(0x2171), 0x2162 => array(0x2172), 0x2163 => array(0x2173), - 0x2164 => array(0x2174), 0x2165 => array(0x2175), 0x2166 => array(0x2176), - 0x2167 => array(0x2177), 0x2168 => array(0x2178), 0x2169 => array(0x2179), - 0x216A => array(0x217A), 0x216B => array(0x217B), 0x216C => array(0x217C), - 0x216D => array(0x217D), 0x216E => array(0x217E), 0x216F => array(0x217F), - 0x24B6 => array(0x24D0), 0x24B7 => array(0x24D1), 0x24B8 => array(0x24D2), - 0x24B9 => array(0x24D3), 0x24BA => array(0x24D4), 0x24BB => array(0x24D5), - 0x24BC => array(0x24D6), 0x24BD => array(0x24D7), 0x24BE => array(0x24D8), - 0x24BF => array(0x24D9), 0x24C0 => array(0x24DA), 0x24C1 => array(0x24DB), - 0x24C2 => array(0x24DC), 0x24C3 => array(0x24DD), 0x24C4 => array(0x24DE), - 0x24C5 => array(0x24DF), 0x24C6 => array(0x24E0), 0x24C7 => array(0x24E1), - 0x24C8 => array(0x24E2), 0x24C9 => array(0x24E3), 0x24CA => array(0x24E4), - 0x24CB => array(0x24E5), 0x24CC => array(0x24E6), 0x24CD => array(0x24E7), - 0x24CE => array(0x24E8), 0x24CF => array(0x24E9), 0x3371 => array(0x68, 0x70, 0x61), - 0x3373 => array(0x61, 0x75), 0x3375 => array(0x6F, 0x76), - 0x3380 => array(0x70, 0x61), 0x3381 => array(0x6E, 0x61), - 0x3382 => array(0x3BC, 0x61), 0x3383 => array(0x6D, 0x61), - 0x3384 => array(0x6B, 0x61), 0x3385 => array(0x6B, 0x62), - 0x3386 => array(0x6D, 0x62), 0x3387 => array(0x67, 0x62), - 0x338A => array(0x70, 0x66), 0x338B => array(0x6E, 0x66), - 0x338C => array(0x3BC, 0x66), 0x3390 => array(0x68, 0x7A), - 0x3391 => array(0x6B, 0x68, 0x7A), 0x3392 => array(0x6D, 0x68, 0x7A), - 0x3393 => array(0x67, 0x68, 0x7A), 0x3394 => array(0x74, 0x68, 0x7A), - 0x33A9 => array(0x70, 0x61), 0x33AA => array(0x6B, 0x70, 0x61), - 0x33AB => array(0x6D, 0x70, 0x61), 0x33AC => array(0x67, 0x70, 0x61), - 0x33B4 => array(0x70, 0x76), 0x33B5 => array(0x6E, 0x76), - 0x33B6 => array(0x3BC, 0x76), 0x33B7 => array(0x6D, 0x76), - 0x33B8 => array(0x6B, 0x76), 0x33B9 => array(0x6D, 0x76), - 0x33BA => array(0x70, 0x77), 0x33BB => array(0x6E, 0x77), - 0x33BC => array(0x3BC, 0x77), 0x33BD => array(0x6D, 0x77), - 0x33BE => array(0x6B, 0x77), 0x33BF => array(0x6D, 0x77), - 0x33C0 => array(0x6B, 0x3C9), 0x33C1 => array(0x6D, 0x3C9), /* - 0x33C2 => array(0x61, 0x2E, 0x6D, 0x2E), */ - 0x33C3 => array(0x62, 0x71), 0x33C6 => array(0x63, 0x2215, 0x6B, 0x67), - 0x33C7 => array(0x63, 0x6F, 0x2E), 0x33C8 => array(0x64, 0x62), - 0x33C9 => array(0x67, 0x79), 0x33CB => array(0x68, 0x70), - 0x33CD => array(0x6B, 0x6B), 0x33CE => array(0x6B, 0x6D), - 0x33D7 => array(0x70, 0x68), 0x33D9 => array(0x70, 0x70, 0x6D), - 0x33DA => array(0x70, 0x72), 0x33DC => array(0x73, 0x76), - 0x33DD => array(0x77, 0x62), 0xFB00 => array(0x66, 0x66), - 0xFB01 => array(0x66, 0x69), 0xFB02 => array(0x66, 0x6C), - 0xFB03 => array(0x66, 0x66, 0x69), 0xFB04 => array(0x66, 0x66, 0x6C), - 0xFB05 => array(0x73, 0x74), 0xFB06 => array(0x73, 0x74), - 0xFB13 => array(0x574, 0x576), 0xFB14 => array(0x574, 0x565), - 0xFB15 => array(0x574, 0x56B), 0xFB16 => array(0x57E, 0x576), - 0xFB17 => array(0x574, 0x56D), 0xFF21 => array(0xFF41), - 0xFF22 => array(0xFF42), 0xFF23 => array(0xFF43), 0xFF24 => array(0xFF44), - 0xFF25 => array(0xFF45), 0xFF26 => array(0xFF46), 0xFF27 => array(0xFF47), - 0xFF28 => array(0xFF48), 0xFF29 => array(0xFF49), 0xFF2A => array(0xFF4A), - 0xFF2B => array(0xFF4B), 0xFF2C => array(0xFF4C), 0xFF2D => array(0xFF4D), - 0xFF2E => array(0xFF4E), 0xFF2F => array(0xFF4F), 0xFF30 => array(0xFF50), - 0xFF31 => array(0xFF51), 0xFF32 => array(0xFF52), 0xFF33 => array(0xFF53), - 0xFF34 => array(0xFF54), 0xFF35 => array(0xFF55), 0xFF36 => array(0xFF56), - 0xFF37 => array(0xFF57), 0xFF38 => array(0xFF58), 0xFF39 => array(0xFF59), - 0xFF3A => array(0xFF5A), 0x10400 => array(0x10428), 0x10401 => array(0x10429), - 0x10402 => array(0x1042A), 0x10403 => array(0x1042B), 0x10404 => array(0x1042C), - 0x10405 => array(0x1042D), 0x10406 => array(0x1042E), 0x10407 => array(0x1042F), - 0x10408 => array(0x10430), 0x10409 => array(0x10431), 0x1040A => array(0x10432), - 0x1040B => array(0x10433), 0x1040C => array(0x10434), 0x1040D => array(0x10435), - 0x1040E => array(0x10436), 0x1040F => array(0x10437), 0x10410 => array(0x10438), - 0x10411 => array(0x10439), 0x10412 => array(0x1043A), 0x10413 => array(0x1043B), - 0x10414 => array(0x1043C), 0x10415 => array(0x1043D), 0x10416 => array(0x1043E), - 0x10417 => array(0x1043F), 0x10418 => array(0x10440), 0x10419 => array(0x10441), - 0x1041A => array(0x10442), 0x1041B => array(0x10443), 0x1041C => array(0x10444), - 0x1041D => array(0x10445), 0x1041E => array(0x10446), 0x1041F => array(0x10447), - 0x10420 => array(0x10448), 0x10421 => array(0x10449), 0x10422 => array(0x1044A), - 0x10423 => array(0x1044B), 0x10424 => array(0x1044C), 0x10425 => array(0x1044D), - 0x1D400 => array(0x61), 0x1D401 => array(0x62), 0x1D402 => array(0x63), - 0x1D403 => array(0x64), 0x1D404 => array(0x65), 0x1D405 => array(0x66), - 0x1D406 => array(0x67), 0x1D407 => array(0x68), 0x1D408 => array(0x69), - 0x1D409 => array(0x6A), 0x1D40A => array(0x6B), 0x1D40B => array(0x6C), - 0x1D40C => array(0x6D), 0x1D40D => array(0x6E), 0x1D40E => array(0x6F), - 0x1D40F => array(0x70), 0x1D410 => array(0x71), 0x1D411 => array(0x72), - 0x1D412 => array(0x73), 0x1D413 => array(0x74), 0x1D414 => array(0x75), - 0x1D415 => array(0x76), 0x1D416 => array(0x77), 0x1D417 => array(0x78), - 0x1D418 => array(0x79), 0x1D419 => array(0x7A), 0x1D434 => array(0x61), - 0x1D435 => array(0x62), 0x1D436 => array(0x63), 0x1D437 => array(0x64), - 0x1D438 => array(0x65), 0x1D439 => array(0x66), 0x1D43A => array(0x67), - 0x1D43B => array(0x68), 0x1D43C => array(0x69), 0x1D43D => array(0x6A), - 0x1D43E => array(0x6B), 0x1D43F => array(0x6C), 0x1D440 => array(0x6D), - 0x1D441 => array(0x6E), 0x1D442 => array(0x6F), 0x1D443 => array(0x70), - 0x1D444 => array(0x71), 0x1D445 => array(0x72), 0x1D446 => array(0x73), - 0x1D447 => array(0x74), 0x1D448 => array(0x75), 0x1D449 => array(0x76), - 0x1D44A => array(0x77), 0x1D44B => array(0x78), 0x1D44C => array(0x79), - 0x1D44D => array(0x7A), 0x1D468 => array(0x61), 0x1D469 => array(0x62), - 0x1D46A => array(0x63), 0x1D46B => array(0x64), 0x1D46C => array(0x65), - 0x1D46D => array(0x66), 0x1D46E => array(0x67), 0x1D46F => array(0x68), - 0x1D470 => array(0x69), 0x1D471 => array(0x6A), 0x1D472 => array(0x6B), - 0x1D473 => array(0x6C), 0x1D474 => array(0x6D), 0x1D475 => array(0x6E), - 0x1D476 => array(0x6F), 0x1D477 => array(0x70), 0x1D478 => array(0x71), - 0x1D479 => array(0x72), 0x1D47A => array(0x73), 0x1D47B => array(0x74), - 0x1D47C => array(0x75), 0x1D47D => array(0x76), 0x1D47E => array(0x77), - 0x1D47F => array(0x78), 0x1D480 => array(0x79), 0x1D481 => array(0x7A), - 0x1D49C => array(0x61), 0x1D49E => array(0x63), 0x1D49F => array(0x64), - 0x1D4A2 => array(0x67), 0x1D4A5 => array(0x6A), 0x1D4A6 => array(0x6B), - 0x1D4A9 => array(0x6E), 0x1D4AA => array(0x6F), 0x1D4AB => array(0x70), - 0x1D4AC => array(0x71), 0x1D4AE => array(0x73), 0x1D4AF => array(0x74), - 0x1D4B0 => array(0x75), 0x1D4B1 => array(0x76), 0x1D4B2 => array(0x77), - 0x1D4B3 => array(0x78), 0x1D4B4 => array(0x79), 0x1D4B5 => array(0x7A), - 0x1D4D0 => array(0x61), 0x1D4D1 => array(0x62), 0x1D4D2 => array(0x63), - 0x1D4D3 => array(0x64), 0x1D4D4 => array(0x65), 0x1D4D5 => array(0x66), - 0x1D4D6 => array(0x67), 0x1D4D7 => array(0x68), 0x1D4D8 => array(0x69), - 0x1D4D9 => array(0x6A), 0x1D4DA => array(0x6B), 0x1D4DB => array(0x6C), - 0x1D4DC => array(0x6D), 0x1D4DD => array(0x6E), 0x1D4DE => array(0x6F), - 0x1D4DF => array(0x70), 0x1D4E0 => array(0x71), 0x1D4E1 => array(0x72), - 0x1D4E2 => array(0x73), 0x1D4E3 => array(0x74), 0x1D4E4 => array(0x75), - 0x1D4E5 => array(0x76), 0x1D4E6 => array(0x77), 0x1D4E7 => array(0x78), - 0x1D4E8 => array(0x79), 0x1D4E9 => array(0x7A), 0x1D504 => array(0x61), - 0x1D505 => array(0x62), 0x1D507 => array(0x64), 0x1D508 => array(0x65), - 0x1D509 => array(0x66), 0x1D50A => array(0x67), 0x1D50D => array(0x6A), - 0x1D50E => array(0x6B), 0x1D50F => array(0x6C), 0x1D510 => array(0x6D), - 0x1D511 => array(0x6E), 0x1D512 => array(0x6F), 0x1D513 => array(0x70), - 0x1D514 => array(0x71), 0x1D516 => array(0x73), 0x1D517 => array(0x74), - 0x1D518 => array(0x75), 0x1D519 => array(0x76), 0x1D51A => array(0x77), - 0x1D51B => array(0x78), 0x1D51C => array(0x79), 0x1D538 => array(0x61), - 0x1D539 => array(0x62), 0x1D53B => array(0x64), 0x1D53C => array(0x65), - 0x1D53D => array(0x66), 0x1D53E => array(0x67), 0x1D540 => array(0x69), - 0x1D541 => array(0x6A), 0x1D542 => array(0x6B), 0x1D543 => array(0x6C), - 0x1D544 => array(0x6D), 0x1D546 => array(0x6F), 0x1D54A => array(0x73), - 0x1D54B => array(0x74), 0x1D54C => array(0x75), 0x1D54D => array(0x76), - 0x1D54E => array(0x77), 0x1D54F => array(0x78), 0x1D550 => array(0x79), - 0x1D56C => array(0x61), 0x1D56D => array(0x62), 0x1D56E => array(0x63), - 0x1D56F => array(0x64), 0x1D570 => array(0x65), 0x1D571 => array(0x66), - 0x1D572 => array(0x67), 0x1D573 => array(0x68), 0x1D574 => array(0x69), - 0x1D575 => array(0x6A), 0x1D576 => array(0x6B), 0x1D577 => array(0x6C), - 0x1D578 => array(0x6D), 0x1D579 => array(0x6E), 0x1D57A => array(0x6F), - 0x1D57B => array(0x70), 0x1D57C => array(0x71), 0x1D57D => array(0x72), - 0x1D57E => array(0x73), 0x1D57F => array(0x74), 0x1D580 => array(0x75), - 0x1D581 => array(0x76), 0x1D582 => array(0x77), 0x1D583 => array(0x78), - 0x1D584 => array(0x79), 0x1D585 => array(0x7A), 0x1D5A0 => array(0x61), - 0x1D5A1 => array(0x62), 0x1D5A2 => array(0x63), 0x1D5A3 => array(0x64), - 0x1D5A4 => array(0x65), 0x1D5A5 => array(0x66), 0x1D5A6 => array(0x67), - 0x1D5A7 => array(0x68), 0x1D5A8 => array(0x69), 0x1D5A9 => array(0x6A), - 0x1D5AA => array(0x6B), 0x1D5AB => array(0x6C), 0x1D5AC => array(0x6D), - 0x1D5AD => array(0x6E), 0x1D5AE => array(0x6F), 0x1D5AF => array(0x70), - 0x1D5B0 => array(0x71), 0x1D5B1 => array(0x72), 0x1D5B2 => array(0x73), - 0x1D5B3 => array(0x74), 0x1D5B4 => array(0x75), 0x1D5B5 => array(0x76), - 0x1D5B6 => array(0x77), 0x1D5B7 => array(0x78), 0x1D5B8 => array(0x79), - 0x1D5B9 => array(0x7A), 0x1D5D4 => array(0x61), 0x1D5D5 => array(0x62), - 0x1D5D6 => array(0x63), 0x1D5D7 => array(0x64), 0x1D5D8 => array(0x65), - 0x1D5D9 => array(0x66), 0x1D5DA => array(0x67), 0x1D5DB => array(0x68), - 0x1D5DC => array(0x69), 0x1D5DD => array(0x6A), 0x1D5DE => array(0x6B), - 0x1D5DF => array(0x6C), 0x1D5E0 => array(0x6D), 0x1D5E1 => array(0x6E), - 0x1D5E2 => array(0x6F), 0x1D5E3 => array(0x70), 0x1D5E4 => array(0x71), - 0x1D5E5 => array(0x72), 0x1D5E6 => array(0x73), 0x1D5E7 => array(0x74), - 0x1D5E8 => array(0x75), 0x1D5E9 => array(0x76), 0x1D5EA => array(0x77), - 0x1D5EB => array(0x78), 0x1D5EC => array(0x79), 0x1D5ED => array(0x7A), - 0x1D608 => array(0x61), 0x1D609 => array(0x62), 0x1D60A => array(0x63), - 0x1D60B => array(0x64), 0x1D60C => array(0x65), 0x1D60D => array(0x66), - 0x1D60E => array(0x67), 0x1D60F => array(0x68), 0x1D610 => array(0x69), - 0x1D611 => array(0x6A), 0x1D612 => array(0x6B), 0x1D613 => array(0x6C), - 0x1D614 => array(0x6D), 0x1D615 => array(0x6E), 0x1D616 => array(0x6F), - 0x1D617 => array(0x70), 0x1D618 => array(0x71), 0x1D619 => array(0x72), - 0x1D61A => array(0x73), 0x1D61B => array(0x74), 0x1D61C => array(0x75), - 0x1D61D => array(0x76), 0x1D61E => array(0x77), 0x1D61F => array(0x78), - 0x1D620 => array(0x79), 0x1D621 => array(0x7A), 0x1D63C => array(0x61), - 0x1D63D => array(0x62), 0x1D63E => array(0x63), 0x1D63F => array(0x64), - 0x1D640 => array(0x65), 0x1D641 => array(0x66), 0x1D642 => array(0x67), - 0x1D643 => array(0x68), 0x1D644 => array(0x69), 0x1D645 => array(0x6A), - 0x1D646 => array(0x6B), 0x1D647 => array(0x6C), 0x1D648 => array(0x6D), - 0x1D649 => array(0x6E), 0x1D64A => array(0x6F), 0x1D64B => array(0x70), - 0x1D64C => array(0x71), 0x1D64D => array(0x72), 0x1D64E => array(0x73), - 0x1D64F => array(0x74), 0x1D650 => array(0x75), 0x1D651 => array(0x76), - 0x1D652 => array(0x77), 0x1D653 => array(0x78), 0x1D654 => array(0x79), - 0x1D655 => array(0x7A), 0x1D670 => array(0x61), 0x1D671 => array(0x62), - 0x1D672 => array(0x63), 0x1D673 => array(0x64), 0x1D674 => array(0x65), - 0x1D675 => array(0x66), 0x1D676 => array(0x67), 0x1D677 => array(0x68), - 0x1D678 => array(0x69), 0x1D679 => array(0x6A), 0x1D67A => array(0x6B), - 0x1D67B => array(0x6C), 0x1D67C => array(0x6D), 0x1D67D => array(0x6E), - 0x1D67E => array(0x6F), 0x1D67F => array(0x70), 0x1D680 => array(0x71), - 0x1D681 => array(0x72), 0x1D682 => array(0x73), 0x1D683 => array(0x74), - 0x1D684 => array(0x75), 0x1D685 => array(0x76), 0x1D686 => array(0x77), - 0x1D687 => array(0x78), 0x1D688 => array(0x79), 0x1D689 => array(0x7A), - 0x1D6A8 => array(0x3B1), 0x1D6A9 => array(0x3B2), 0x1D6AA => array(0x3B3), - 0x1D6AB => array(0x3B4), 0x1D6AC => array(0x3B5), 0x1D6AD => array(0x3B6), - 0x1D6AE => array(0x3B7), 0x1D6AF => array(0x3B8), 0x1D6B0 => array(0x3B9), - 0x1D6B1 => array(0x3BA), 0x1D6B2 => array(0x3BB), 0x1D6B3 => array(0x3BC), - 0x1D6B4 => array(0x3BD), 0x1D6B5 => array(0x3BE), 0x1D6B6 => array(0x3BF), - 0x1D6B7 => array(0x3C0), 0x1D6B8 => array(0x3C1), 0x1D6B9 => array(0x3B8), - 0x1D6BA => array(0x3C3), 0x1D6BB => array(0x3C4), 0x1D6BC => array(0x3C5), - 0x1D6BD => array(0x3C6), 0x1D6BE => array(0x3C7), 0x1D6BF => array(0x3C8), - 0x1D6C0 => array(0x3C9), 0x1D6D3 => array(0x3C3), 0x1D6E2 => array(0x3B1), - 0x1D6E3 => array(0x3B2), 0x1D6E4 => array(0x3B3), 0x1D6E5 => array(0x3B4), - 0x1D6E6 => array(0x3B5), 0x1D6E7 => array(0x3B6), 0x1D6E8 => array(0x3B7), - 0x1D6E9 => array(0x3B8), 0x1D6EA => array(0x3B9), 0x1D6EB => array(0x3BA), - 0x1D6EC => array(0x3BB), 0x1D6ED => array(0x3BC), 0x1D6EE => array(0x3BD), - 0x1D6EF => array(0x3BE), 0x1D6F0 => array(0x3BF), 0x1D6F1 => array(0x3C0), - 0x1D6F2 => array(0x3C1), 0x1D6F3 => array(0x3B8), 0x1D6F4 => array(0x3C3), - 0x1D6F5 => array(0x3C4), 0x1D6F6 => array(0x3C5), 0x1D6F7 => array(0x3C6), - 0x1D6F8 => array(0x3C7), 0x1D6F9 => array(0x3C8), 0x1D6FA => array(0x3C9), - 0x1D70D => array(0x3C3), 0x1D71C => array(0x3B1), 0x1D71D => array(0x3B2), - 0x1D71E => array(0x3B3), 0x1D71F => array(0x3B4), 0x1D720 => array(0x3B5), - 0x1D721 => array(0x3B6), 0x1D722 => array(0x3B7), 0x1D723 => array(0x3B8), - 0x1D724 => array(0x3B9), 0x1D725 => array(0x3BA), 0x1D726 => array(0x3BB), - 0x1D727 => array(0x3BC), 0x1D728 => array(0x3BD), 0x1D729 => array(0x3BE), - 0x1D72A => array(0x3BF), 0x1D72B => array(0x3C0), 0x1D72C => array(0x3C1), - 0x1D72D => array(0x3B8), 0x1D72E => array(0x3C3), 0x1D72F => array(0x3C4), - 0x1D730 => array(0x3C5), 0x1D731 => array(0x3C6), 0x1D732 => array(0x3C7), - 0x1D733 => array(0x3C8), 0x1D734 => array(0x3C9), 0x1D747 => array(0x3C3), - 0x1D756 => array(0x3B1), 0x1D757 => array(0x3B2), 0x1D758 => array(0x3B3), - 0x1D759 => array(0x3B4), 0x1D75A => array(0x3B5), 0x1D75B => array(0x3B6), - 0x1D75C => array(0x3B7), 0x1D75D => array(0x3B8), 0x1D75E => array(0x3B9), - 0x1D75F => array(0x3BA), 0x1D760 => array(0x3BB), 0x1D761 => array(0x3BC), - 0x1D762 => array(0x3BD), 0x1D763 => array(0x3BE), 0x1D764 => array(0x3BF), - 0x1D765 => array(0x3C0), 0x1D766 => array(0x3C1), 0x1D767 => array(0x3B8), - 0x1D768 => array(0x3C3), 0x1D769 => array(0x3C4), 0x1D76A => array(0x3C5), - 0x1D76B => array(0x3C6), 0x1D76C => array(0x3C7), 0x1D76D => array(0x3C8), - 0x1D76E => array(0x3C9), 0x1D781 => array(0x3C3), 0x1D790 => array(0x3B1), - 0x1D791 => array(0x3B2), 0x1D792 => array(0x3B3), 0x1D793 => array(0x3B4), - 0x1D794 => array(0x3B5), 0x1D795 => array(0x3B6), 0x1D796 => array(0x3B7), - 0x1D797 => array(0x3B8), 0x1D798 => array(0x3B9), 0x1D799 => array(0x3BA), - 0x1D79A => array(0x3BB), 0x1D79B => array(0x3BC), 0x1D79C => array(0x3BD), - 0x1D79D => array(0x3BE), 0x1D79E => array(0x3BF), 0x1D79F => array(0x3C0), - 0x1D7A0 => array(0x3C1), 0x1D7A1 => array(0x3B8), 0x1D7A2 => array(0x3C3), - 0x1D7A3 => array(0x3C4), 0x1D7A4 => array(0x3C5), 0x1D7A5 => array(0x3C6), - 0x1D7A6 => array(0x3C7), 0x1D7A7 => array(0x3C8), 0x1D7A8 => array(0x3C9), - 0x1D7BB => array(0x3C3), 0x3F9 => array(0x3C3), 0x1D2C => array(0x61), - 0x1D2D => array(0xE6), 0x1D2E => array(0x62), 0x1D30 => array(0x64), - 0x1D31 => array(0x65), 0x1D32 => array(0x1DD), 0x1D33 => array(0x67), - 0x1D34 => array(0x68), 0x1D35 => array(0x69), 0x1D36 => array(0x6A), - 0x1D37 => array(0x6B), 0x1D38 => array(0x6C), 0x1D39 => array(0x6D), - 0x1D3A => array(0x6E), 0x1D3C => array(0x6F), 0x1D3D => array(0x223), - 0x1D3E => array(0x70), 0x1D3F => array(0x72), 0x1D40 => array(0x74), - 0x1D41 => array(0x75), 0x1D42 => array(0x77), 0x213B => array(0x66, 0x61, 0x78), - 0x3250 => array(0x70, 0x74, 0x65), 0x32CC => array(0x68, 0x67), - 0x32CE => array(0x65, 0x76), 0x32CF => array(0x6C, 0x74, 0x64), - 0x337A => array(0x69, 0x75), 0x33DE => array(0x76, 0x2215, 0x6D), - 0x33DF => array(0x61, 0x2215, 0x6D) - ), - 'replacemaps' => array(0x41 => array(0x61), 0x42 => array(0x62), 0x43 => array(0x63), - 0x44 => array(0x64), 0x45 => array(0x65), 0x46 => array(0x66), - 0x47 => array(0x67), 0x48 => array(0x68), 0x49 => array(0x69), - 0x4A => array(0x6A), 0x4B => array(0x6B), 0x4C => array(0x6C), - 0x4D => array(0x6D), 0x4E => array(0x6E), 0x4F => array(0x6F), - 0x50 => array(0x70), 0x51 => array(0x71), 0x52 => array(0x72), - 0x53 => array(0x73), 0x54 => array(0x74), 0x55 => array(0x75), - 0x56 => array(0x76), 0x57 => array(0x77), 0x58 => array(0x78), - 0x59 => array(0x79), 0x5A => array(0x7A), 0xAA => array(0x61), - 0xB2 => array(0x32), 0xB3 => array(0x33), 0xB5 => array(0x3BC), - 0xB9 => array(0x31), 0xBA => array(0x6F), 0xBC => array(0x31, 0x2044, 0x34), - 0xBD => array(0x31, 0x2044, 0x32), 0xBE => array(0x33, 0x2044, 0x34), 0xC0 => array(0xE0), - 0xC1 => array(0xE1), 0xC2 => array(0xE2), 0xC3 => array(0xE3), - 0xC4 => array(0xE4), 0xC5 => array(0xE5), 0xC6 => array(0xE6), - 0xC7 => array(0xE7), 0xC8 => array(0xE8), 0xC9 => array(0xE9), - 0xCA => array(0xEA), 0xCB => array(0xEB), 0xCC => array(0xEC), - 0xCD => array(0xED), 0xCE => array(0xEE), 0xCF => array(0xEF), - 0xD0 => array(0xF0), 0xD1 => array(0xF1), 0xD2 => array(0xF2), - 0xD3 => array(0xF3), 0xD4 => array(0xF4), 0xD5 => array(0xF5), - 0xD6 => array(0xF6), 0xD8 => array(0xF8), 0xD9 => array(0xF9), - 0xDA => array(0xFA), 0xDB => array(0xFB), 0xDC => array(0xFC), - 0xDD => array(0xFD), 0xDE => array(0xFE), 0x100 => array(0x101), - 0x102 => array(0x103), 0x104 => array(0x105), 0x106 => array(0x107), - 0x108 => array(0x109), 0x10A => array(0x10B), 0x10C => array(0x10D), - 0x10E => array(0x10F), 0x110 => array(0x111), 0x112 => array(0x113), - 0x114 => array(0x115), 0x116 => array(0x117), 0x118 => array(0x119), - 0x11A => array(0x11B), 0x11C => array(0x11D), 0x11E => array(0x11F), - 0x120 => array(0x121), 0x122 => array(0x123), 0x124 => array(0x125), - 0x126 => array(0x127), 0x128 => array(0x129), 0x12A => array(0x12B), - 0x12C => array(0x12D), 0x12E => array(0x12F), 0x130 => array(0x69, 0x307), - 0x132 => array(0x69, 0x6A), 0x133 => array(0x69, 0x6A), 0x134 => array(0x135), - 0x136 => array(0x137), 0x139 => array(0x13A), 0x13B => array(0x13C), - 0x13D => array(0x13E), 0x13F => array(0x6C, 0xB7), 0x140 => array(0x6C, 0xB7), - 0x141 => array(0x142), 0x143 => array(0x144), 0x145 => array(0x146), - 0x147 => array(0x148), 0x149 => array(0x2BC, 0x6E), 0x14A => array(0x14B), - 0x14C => array(0x14D), 0x14E => array(0x14F), 0x150 => array(0x151), - 0x152 => array(0x153), 0x154 => array(0x155), 0x156 => array(0x157), - 0x158 => array(0x159), 0x15A => array(0x15B), 0x15C => array(0x15D), - 0x15E => array(0x15F), 0x160 => array(0x161), 0x162 => array(0x163), - 0x164 => array(0x165), 0x166 => array(0x167), 0x168 => array(0x169), - 0x16A => array(0x16B), 0x16C => array(0x16D), 0x16E => array(0x16F), - 0x170 => array(0x171), 0x172 => array(0x173), 0x174 => array(0x175), - 0x176 => array(0x177), 0x178 => array(0xFF), 0x179 => array(0x17A), - 0x17B => array(0x17C), 0x17D => array(0x17E), 0x17F => array(0x73), - 0x181 => array(0x253), 0x182 => array(0x183), 0x184 => array(0x185), - 0x186 => array(0x254), 0x187 => array(0x188), 0x189 => array(0x256), - 0x18A => array(0x257), 0x18B => array(0x18C), 0x18E => array(0x1DD), - 0x18F => array(0x259), 0x190 => array(0x25B), 0x191 => array(0x192), - 0x193 => array(0x260), 0x194 => array(0x263), 0x196 => array(0x269), - 0x197 => array(0x268), 0x198 => array(0x199), 0x19C => array(0x26F), - 0x19D => array(0x272), 0x19F => array(0x275), 0x1A0 => array(0x1A1), - 0x1A2 => array(0x1A3), 0x1A4 => array(0x1A5), 0x1A6 => array(0x280), - 0x1A7 => array(0x1A8), 0x1A9 => array(0x283), 0x1AC => array(0x1AD), - 0x1AE => array(0x288), 0x1AF => array(0x1B0), 0x1B1 => array(0x28A), - 0x1B2 => array(0x28B), 0x1B3 => array(0x1B4), 0x1B5 => array(0x1B6), - 0x1B7 => array(0x292), 0x1B8 => array(0x1B9), 0x1BC => array(0x1BD), - 0x1C4 => array(0x64, 0x17E), 0x1C5 => array(0x64, 0x17E), 0x1C6 => array(0x64, 0x17E), - 0x1C7 => array(0x6C, 0x6A), 0x1C8 => array(0x6C, 0x6A), 0x1C9 => array(0x6C, 0x6A), - 0x1CA => array(0x6E, 0x6A), 0x1CB => array(0x6E, 0x6A), 0x1CC => array(0x6E, 0x6A), - 0x1CD => array(0x1CE), 0x1CF => array(0x1D0), 0x1D1 => array(0x1D2), - 0x1D3 => array(0x1D4), 0x1D5 => array(0x1D6), 0x1D7 => array(0x1D8), - 0x1D9 => array(0x1DA), 0x1DB => array(0x1DC), 0x1DE => array(0x1DF), - 0x1E0 => array(0x1E1), 0x1E2 => array(0x1E3), 0x1E4 => array(0x1E5), - 0x1E6 => array(0x1E7), 0x1E8 => array(0x1E9), 0x1EA => array(0x1EB), - 0x1EC => array(0x1ED), 0x1EE => array(0x1EF), 0x1F1 => array(0x64, 0x7A), - 0x1F2 => array(0x64, 0x7A), 0x1F3 => array(0x64, 0x7A), 0x1F4 => array(0x1F5), - 0x1F6 => array(0x195), 0x1F7 => array(0x1BF), 0x1F8 => array(0x1F9), - 0x1FA => array(0x1FB), 0x1FC => array(0x1FD), 0x1FE => array(0x1FF), - 0x200 => array(0x201), 0x202 => array(0x203), 0x204 => array(0x205), - 0x206 => array(0x207), 0x208 => array(0x209), 0x20A => array(0x20B), - 0x20C => array(0x20D), 0x20E => array(0x20F), 0x210 => array(0x211), - 0x212 => array(0x213), 0x214 => array(0x215), 0x216 => array(0x217), - 0x218 => array(0x219), 0x21A => array(0x21B), 0x21C => array(0x21D), - 0x21E => array(0x21F), 0x220 => array(0x19E), 0x222 => array(0x223), - 0x224 => array(0x225), 0x226 => array(0x227), 0x228 => array(0x229), - 0x22A => array(0x22B), 0x22C => array(0x22D), 0x22E => array(0x22F), - 0x230 => array(0x231), 0x232 => array(0x233), 0x23A => array(0x2C65), - 0x23B => array(0x23C), 0x23D => array(0x19A), 0x23E => array(0x2C66), - 0x241 => array(0x242), 0x243 => array(0x180), 0x244 => array(0x289), - 0x245 => array(0x28C), 0x246 => array(0x247), 0x248 => array(0x249), - 0x24A => array(0x24B), 0x24C => array(0x24D), 0x24E => array(0x24F), - 0x2B0 => array(0x68), 0x2B1 => array(0x266), 0x2B2 => array(0x6A), - 0x2B3 => array(0x72), 0x2B4 => array(0x279), 0x2B5 => array(0x27B), - 0x2B6 => array(0x281), 0x2B7 => array(0x77), 0x2B8 => array(0x79), - 0x2E0 => array(0x263), 0x2E1 => array(0x6C), 0x2E2 => array(0x73), - 0x2E3 => array(0x78), 0x2E4 => array(0x295), 0x340 => array(0x300), - 0x341 => array(0x301), 0x343 => array(0x313), 0x344 => array(0x308, 0x301), - 0x345 => array(0x3B9), 0x370 => array(0x371), 0x372 => array(0x373), - 0x374 => array(0x2B9), 0x376 => array(0x377), 0x37F => array(0x3F3), - 0x386 => array(0x3AC), 0x387 => array(0xB7), 0x388 => array(0x3AD), - 0x389 => array(0x3AE), 0x38A => array(0x3AF), 0x38C => array(0x3CC), - 0x38E => array(0x3CD), 0x38F => array(0x3CE), 0x391 => array(0x3B1), - 0x392 => array(0x3B2), 0x393 => array(0x3B3), 0x394 => array(0x3B4), - 0x395 => array(0x3B5), 0x396 => array(0x3B6), 0x397 => array(0x3B7), - 0x398 => array(0x3B8), 0x399 => array(0x3B9), 0x39A => array(0x3BA), - 0x39B => array(0x3BB), 0x39C => array(0x3BC), 0x39D => array(0x3BD), - 0x39E => array(0x3BE), 0x39F => array(0x3BF), 0x3A0 => array(0x3C0), - 0x3A1 => array(0x3C1), 0x3A3 => array(0x3C3), 0x3A4 => array(0x3C4), - 0x3A5 => array(0x3C5), 0x3A6 => array(0x3C6), 0x3A7 => array(0x3C7), - 0x3A8 => array(0x3C8), 0x3A9 => array(0x3C9), 0x3AA => array(0x3CA), - 0x3AB => array(0x3CB), 0x3CF => array(0x3D7), 0x3D0 => array(0x3B2), - 0x3D1 => array(0x3B8), 0x3D2 => array(0x3C5), 0x3D3 => array(0x3CD), - 0x3D4 => array(0x3CB), 0x3D5 => array(0x3C6), 0x3D6 => array(0x3C0), - 0x3D8 => array(0x3D9), 0x3DA => array(0x3DB), 0x3DC => array(0x3DD), - 0x3DE => array(0x3DF), 0x3E0 => array(0x3E1), 0x3E2 => array(0x3E3), - 0x3E4 => array(0x3E5), 0x3E6 => array(0x3E7), 0x3E8 => array(0x3E9), - 0x3EA => array(0x3EB), 0x3EC => array(0x3ED), 0x3EE => array(0x3EF), - 0x3F0 => array(0x3BA), 0x3F1 => array(0x3C1), 0x3F2 => array(0x3C3), - 0x3F4 => array(0x3B8), 0x3F5 => array(0x3B5), 0x3F7 => array(0x3F8), - 0x3F9 => array(0x3C3), 0x3FA => array(0x3FB), 0x3FD => array(0x37B), - 0x3FE => array(0x37C), 0x3FF => array(0x37D), 0x400 => array(0x450), - 0x401 => array(0x451), 0x402 => array(0x452), 0x403 => array(0x453), - 0x404 => array(0x454), 0x405 => array(0x455), 0x406 => array(0x456), - 0x407 => array(0x457), 0x408 => array(0x458), 0x409 => array(0x459), - 0x40A => array(0x45A), 0x40B => array(0x45B), 0x40C => array(0x45C), - 0x40D => array(0x45D), 0x40E => array(0x45E), 0x40F => array(0x45F), - 0x410 => array(0x430), 0x411 => array(0x431), 0x412 => array(0x432), - 0x413 => array(0x433), 0x414 => array(0x434), 0x415 => array(0x435), - 0x416 => array(0x436), 0x417 => array(0x437), 0x418 => array(0x438), - 0x419 => array(0x439), 0x41A => array(0x43A), 0x41B => array(0x43B), - 0x41C => array(0x43C), 0x41D => array(0x43D), 0x41E => array(0x43E), - 0x41F => array(0x43F), 0x420 => array(0x440), 0x421 => array(0x441), - 0x422 => array(0x442), 0x423 => array(0x443), 0x424 => array(0x444), - 0x425 => array(0x445), 0x426 => array(0x446), 0x427 => array(0x447), - 0x428 => array(0x448), 0x429 => array(0x449), 0x42A => array(0x44A), - 0x42B => array(0x44B), 0x42C => array(0x44C), 0x42D => array(0x44D), - 0x42E => array(0x44E), 0x42F => array(0x44F), 0x460 => array(0x461), - 0x462 => array(0x463), 0x464 => array(0x465), 0x466 => array(0x467), - 0x468 => array(0x469), 0x46A => array(0x46B), 0x46C => array(0x46D), - 0x46E => array(0x46F), 0x470 => array(0x471), 0x472 => array(0x473), - 0x474 => array(0x475), 0x476 => array(0x477), 0x478 => array(0x479), - 0x47A => array(0x47B), 0x47C => array(0x47D), 0x47E => array(0x47F), - 0x480 => array(0x481), 0x48A => array(0x48B), 0x48C => array(0x48D), - 0x48E => array(0x48F), 0x490 => array(0x491), 0x492 => array(0x493), - 0x494 => array(0x495), 0x496 => array(0x497), 0x498 => array(0x499), - 0x49A => array(0x49B), 0x49C => array(0x49D), 0x49E => array(0x49F), - 0x4A0 => array(0x4A1), 0x4A2 => array(0x4A3), 0x4A4 => array(0x4A5), - 0x4A6 => array(0x4A7), 0x4A8 => array(0x4A9), 0x4AA => array(0x4AB), - 0x4AC => array(0x4AD), 0x4AE => array(0x4AF), 0x4B0 => array(0x4B1), - 0x4B2 => array(0x4B3), 0x4B4 => array(0x4B5), 0x4B6 => array(0x4B7), - 0x4B8 => array(0x4B9), 0x4BA => array(0x4BB), 0x4BC => array(0x4BD), - 0x4BE => array(0x4BF), 0x4C1 => array(0x4C2), 0x4C3 => array(0x4C4), - 0x4C5 => array(0x4C6), 0x4C7 => array(0x4C8), 0x4C9 => array(0x4CA), - 0x4CB => array(0x4CC), 0x4CD => array(0x4CE), 0x4D0 => array(0x4D1), - 0x4D2 => array(0x4D3), 0x4D4 => array(0x4D5), 0x4D6 => array(0x4D7), - 0x4D8 => array(0x4D9), 0x4DA => array(0x4DB), 0x4DC => array(0x4DD), - 0x4DE => array(0x4DF), 0x4E0 => array(0x4E1), 0x4E2 => array(0x4E3), - 0x4E4 => array(0x4E5), 0x4E6 => array(0x4E7), 0x4E8 => array(0x4E9), - 0x4EA => array(0x4EB), 0x4EC => array(0x4ED), 0x4EE => array(0x4EF), - 0x4F0 => array(0x4F1), 0x4F2 => array(0x4F3), 0x4F4 => array(0x4F5), - 0x4F6 => array(0x4F7), 0x4F8 => array(0x4F9), 0x4FA => array(0x4FB), - 0x4FC => array(0x4FD), 0x4FE => array(0x4FF), 0x500 => array(0x501), - 0x502 => array(0x503), 0x504 => array(0x505), 0x506 => array(0x507), - 0x508 => array(0x509), 0x50A => array(0x50B), 0x50C => array(0x50D), - 0x50E => array(0x50F), 0x510 => array(0x511), 0x512 => array(0x513), - 0x514 => array(0x515), 0x516 => array(0x517), 0x518 => array(0x519), - 0x51A => array(0x51B), 0x51C => array(0x51D), 0x51E => array(0x51F), - 0x520 => array(0x521), 0x522 => array(0x523), 0x524 => array(0x525), - 0x526 => array(0x527), 0x528 => array(0x529), 0x52A => array(0x52B), - 0x52C => array(0x52D), 0x52E => array(0x52F), 0x531 => array(0x561), - 0x532 => array(0x562), 0x533 => array(0x563), 0x534 => array(0x564), - 0x535 => array(0x565), 0x536 => array(0x566), 0x537 => array(0x567), - 0x538 => array(0x568), 0x539 => array(0x569), 0x53A => array(0x56A), - 0x53B => array(0x56B), 0x53C => array(0x56C), 0x53D => array(0x56D), - 0x53E => array(0x56E), 0x53F => array(0x56F), 0x540 => array(0x570), - 0x541 => array(0x571), 0x542 => array(0x572), 0x543 => array(0x573), - 0x544 => array(0x574), 0x545 => array(0x575), 0x546 => array(0x576), - 0x547 => array(0x577), 0x548 => array(0x578), 0x549 => array(0x579), - 0x54A => array(0x57A), 0x54B => array(0x57B), 0x54C => array(0x57C), - 0x54D => array(0x57D), 0x54E => array(0x57E), 0x54F => array(0x57F), - 0x550 => array(0x580), 0x551 => array(0x581), 0x552 => array(0x582), - 0x553 => array(0x583), 0x554 => array(0x584), 0x555 => array(0x585), - 0x556 => array(0x586), 0x587 => array(0x565, 0x582), 0x675 => array(0x627, 0x674), - 0x676 => array(0x648, 0x674), 0x677 => array(0x6C7, 0x674), 0x678 => array(0x64A, 0x674), - 0x958 => array(0x915, 0x93C), 0x959 => array(0x916, 0x93C), 0x95A => array(0x917, 0x93C), - 0x95B => array(0x91C, 0x93C), 0x95C => array(0x921, 0x93C), 0x95D => array(0x922, 0x93C), - 0x95E => array(0x92B, 0x93C), 0x95F => array(0x92F, 0x93C), 0x9DC => array(0x9A1, 0x9BC), - 0x9DD => array(0x9A2, 0x9BC), 0x9DF => array(0x9AF, 0x9BC), 0xA33 => array(0xA32, 0xA3C), - 0xA36 => array(0xA38, 0xA3C), 0xA59 => array(0xA16, 0xA3C), 0xA5A => array(0xA17, 0xA3C), - 0xA5B => array(0xA1C, 0xA3C), 0xA5E => array(0xA2B, 0xA3C), 0xB5C => array(0xB21, 0xB3C), - 0xB5D => array(0xB22, 0xB3C), 0xE33 => array(0xE4D, 0xE32), 0xEB3 => array(0xECD, 0xEB2), - 0xEDC => array(0xEAB, 0xE99), 0xEDD => array(0xEAB, 0xEA1), 0xF0C => array(0xF0B), - 0xF43 => array(0xF42, 0xFB7), 0xF4D => array(0xF4C, 0xFB7), 0xF52 => array(0xF51, 0xFB7), - 0xF57 => array(0xF56, 0xFB7), 0xF5C => array(0xF5B, 0xFB7), 0xF69 => array(0xF40, 0xFB5), - 0xF73 => array(0xF71, 0xF72), 0xF75 => array(0xF71, 0xF74), 0xF76 => array(0xFB2, 0xF80), - 0xF77 => array(0xFB2, 0xF71, 0xF80), 0xF78 => array(0xFB3, 0xF80), 0xF79 => array(0xFB3, 0xF71, 0xF80), - 0xF81 => array(0xF71, 0xF80), 0xF93 => array(0xF92, 0xFB7), 0xF9D => array(0xF9C, 0xFB7), - 0xFA2 => array(0xFA1, 0xFB7), 0xFA7 => array(0xFA6, 0xFB7), 0xFAC => array(0xFAB, 0xFB7), - 0xFB9 => array(0xF90, 0xFB5), 0x10C7 => array(0x2D27), 0x10CD => array(0x2D2D), - 0x10FC => array(0x10DC), 0x1D2C => array(0x61), 0x1D2D => array(0xE6), - 0x1D2E => array(0x62), 0x1D30 => array(0x64), 0x1D31 => array(0x65), - 0x1D32 => array(0x1DD), 0x1D33 => array(0x67), 0x1D34 => array(0x68), - 0x1D35 => array(0x69), 0x1D36 => array(0x6A), 0x1D37 => array(0x6B), - 0x1D38 => array(0x6C), 0x1D39 => array(0x6D), 0x1D3A => array(0x6E), - 0x1D3C => array(0x6F), 0x1D3D => array(0x223), 0x1D3E => array(0x70), - 0x1D3F => array(0x72), 0x1D40 => array(0x74), 0x1D41 => array(0x75), - 0x1D42 => array(0x77), 0x1D43 => array(0x61), 0x1D44 => array(0x250), - 0x1D45 => array(0x251), 0x1D46 => array(0x1D02), 0x1D47 => array(0x62), - 0x1D48 => array(0x64), 0x1D49 => array(0x65), 0x1D4A => array(0x259), - 0x1D4B => array(0x25B), 0x1D4C => array(0x25C), 0x1D4D => array(0x67), - 0x1D4F => array(0x6B), 0x1D50 => array(0x6D), 0x1D51 => array(0x14B), - 0x1D52 => array(0x6F), 0x1D53 => array(0x254), 0x1D54 => array(0x1D16), - 0x1D55 => array(0x1D17), 0x1D56 => array(0x70), 0x1D57 => array(0x74), - 0x1D58 => array(0x75), 0x1D59 => array(0x1D1D), 0x1D5A => array(0x26F), - 0x1D5B => array(0x76), 0x1D5C => array(0x1D25), 0x1D5D => array(0x3B2), - 0x1D5E => array(0x3B3), 0x1D5F => array(0x3B4), 0x1D60 => array(0x3C6), - 0x1D61 => array(0x3C7), 0x1D62 => array(0x69), 0x1D63 => array(0x72), - 0x1D64 => array(0x75), 0x1D65 => array(0x76), 0x1D66 => array(0x3B2), - 0x1D67 => array(0x3B3), 0x1D68 => array(0x3C1), 0x1D69 => array(0x3C6), - 0x1D6A => array(0x3C7), 0x1D78 => array(0x43D), 0x1D9B => array(0x252), - 0x1D9C => array(0x63), 0x1D9D => array(0x255), 0x1D9E => array(0xF0), - 0x1D9F => array(0x25C), 0x1DA0 => array(0x66), 0x1DA1 => array(0x25F), - 0x1DA2 => array(0x261), 0x1DA3 => array(0x265), 0x1DA4 => array(0x268), - 0x1DA5 => array(0x269), 0x1DA6 => array(0x26A), 0x1DA7 => array(0x1D7B), - 0x1DA8 => array(0x29D), 0x1DA9 => array(0x26D), 0x1DAA => array(0x1D85), - 0x1DAB => array(0x29F), 0x1DAC => array(0x271), 0x1DAD => array(0x270), - 0x1DAE => array(0x272), 0x1DAF => array(0x273), 0x1DB0 => array(0x274), - 0x1DB1 => array(0x275), 0x1DB2 => array(0x278), 0x1DB3 => array(0x282), - 0x1DB4 => array(0x283), 0x1DB5 => array(0x1AB), 0x1DB6 => array(0x289), - 0x1DB7 => array(0x28A), 0x1DB8 => array(0x1D1C), 0x1DB9 => array(0x28B), - 0x1DBA => array(0x28C), 0x1DBB => array(0x7A), 0x1DBC => array(0x290), - 0x1DBD => array(0x291), 0x1DBE => array(0x292), 0x1DBF => array(0x3B8), - 0x1E00 => array(0x1E01), 0x1E02 => array(0x1E03), 0x1E04 => array(0x1E05), - 0x1E06 => array(0x1E07), 0x1E08 => array(0x1E09), 0x1E0A => array(0x1E0B), - 0x1E0C => array(0x1E0D), 0x1E0E => array(0x1E0F), 0x1E10 => array(0x1E11), - 0x1E12 => array(0x1E13), 0x1E14 => array(0x1E15), 0x1E16 => array(0x1E17), - 0x1E18 => array(0x1E19), 0x1E1A => array(0x1E1B), 0x1E1C => array(0x1E1D), - 0x1E1E => array(0x1E1F), 0x1E20 => array(0x1E21), 0x1E22 => array(0x1E23), - 0x1E24 => array(0x1E25), 0x1E26 => array(0x1E27), 0x1E28 => array(0x1E29), - 0x1E2A => array(0x1E2B), 0x1E2C => array(0x1E2D), 0x1E2E => array(0x1E2F), - 0x1E30 => array(0x1E31), 0x1E32 => array(0x1E33), 0x1E34 => array(0x1E35), - 0x1E36 => array(0x1E37), 0x1E38 => array(0x1E39), 0x1E3A => array(0x1E3B), - 0x1E3C => array(0x1E3D), 0x1E3E => array(0x1E3F), 0x1E40 => array(0x1E41), - 0x1E42 => array(0x1E43), 0x1E44 => array(0x1E45), 0x1E46 => array(0x1E47), - 0x1E48 => array(0x1E49), 0x1E4A => array(0x1E4B), 0x1E4C => array(0x1E4D), - 0x1E4E => array(0x1E4F), 0x1E50 => array(0x1E51), 0x1E52 => array(0x1E53), - 0x1E54 => array(0x1E55), 0x1E56 => array(0x1E57), 0x1E58 => array(0x1E59), - 0x1E5A => array(0x1E5B), 0x1E5C => array(0x1E5D), 0x1E5E => array(0x1E5F), - 0x1E60 => array(0x1E61), 0x1E62 => array(0x1E63), 0x1E64 => array(0x1E65), - 0x1E66 => array(0x1E67), 0x1E68 => array(0x1E69), 0x1E6A => array(0x1E6B), - 0x1E6C => array(0x1E6D), 0x1E6E => array(0x1E6F), 0x1E70 => array(0x1E71), - 0x1E72 => array(0x1E73), 0x1E74 => array(0x1E75), 0x1E76 => array(0x1E77), - 0x1E78 => array(0x1E79), 0x1E7A => array(0x1E7B), 0x1E7C => array(0x1E7D), - 0x1E7E => array(0x1E7F), 0x1E80 => array(0x1E81), 0x1E82 => array(0x1E83), - 0x1E84 => array(0x1E85), 0x1E86 => array(0x1E87), 0x1E88 => array(0x1E89), - 0x1E8A => array(0x1E8B), 0x1E8C => array(0x1E8D), 0x1E8E => array(0x1E8F), - 0x1E90 => array(0x1E91), 0x1E92 => array(0x1E93), 0x1E94 => array(0x1E95), - 0x1E9A => array(0x61, 0x2BE), 0x1E9B => array(0x1E61), 0x1E9E => array(0x73, 0x73), - 0x1EA0 => array(0x1EA1), 0x1EA2 => array(0x1EA3), 0x1EA4 => array(0x1EA5), - 0x1EA6 => array(0x1EA7), 0x1EA8 => array(0x1EA9), 0x1EAA => array(0x1EAB), - 0x1EAC => array(0x1EAD), 0x1EAE => array(0x1EAF), 0x1EB0 => array(0x1EB1), - 0x1EB2 => array(0x1EB3), 0x1EB4 => array(0x1EB5), 0x1EB6 => array(0x1EB7), - 0x1EB8 => array(0x1EB9), 0x1EBA => array(0x1EBB), 0x1EBC => array(0x1EBD), - 0x1EBE => array(0x1EBF), 0x1EC0 => array(0x1EC1), 0x1EC2 => array(0x1EC3), - 0x1EC4 => array(0x1EC5), 0x1EC6 => array(0x1EC7), 0x1EC8 => array(0x1EC9), - 0x1ECA => array(0x1ECB), 0x1ECC => array(0x1ECD), 0x1ECE => array(0x1ECF), - 0x1ED0 => array(0x1ED1), 0x1ED2 => array(0x1ED3), 0x1ED4 => array(0x1ED5), - 0x1ED6 => array(0x1ED7), 0x1ED8 => array(0x1ED9), 0x1EDA => array(0x1EDB), - 0x1EDC => array(0x1EDD), 0x1EDE => array(0x1EDF), 0x1EE0 => array(0x1EE1), - 0x1EE2 => array(0x1EE3), 0x1EE4 => array(0x1EE5), 0x1EE6 => array(0x1EE7), - 0x1EE8 => array(0x1EE9), 0x1EEA => array(0x1EEB), 0x1EEC => array(0x1EED), - 0x1EEE => array(0x1EEF), 0x1EF0 => array(0x1EF1), 0x1EF2 => array(0x1EF3), - 0x1EF4 => array(0x1EF5), 0x1EF6 => array(0x1EF7), 0x1EF8 => array(0x1EF9), - 0x1EFA => array(0x1EFB), 0x1EFC => array(0x1EFD), 0x1EFE => array(0x1EFF), - 0x1F08 => array(0x1F00), 0x1F09 => array(0x1F01), 0x1F0A => array(0x1F02), - 0x1F0B => array(0x1F03), 0x1F0C => array(0x1F04), 0x1F0D => array(0x1F05), - 0x1F0E => array(0x1F06), 0x1F0F => array(0x1F07), 0x1F18 => array(0x1F10), - 0x1F19 => array(0x1F11), 0x1F1A => array(0x1F12), 0x1F1B => array(0x1F13), - 0x1F1C => array(0x1F14), 0x1F1D => array(0x1F15), 0x1F28 => array(0x1F20), - 0x1F29 => array(0x1F21), 0x1F2A => array(0x1F22), 0x1F2B => array(0x1F23), - 0x1F2C => array(0x1F24), 0x1F2D => array(0x1F25), 0x1F2E => array(0x1F26), - 0x1F2F => array(0x1F27), 0x1F38 => array(0x1F30), 0x1F39 => array(0x1F31), - 0x1F3A => array(0x1F32), 0x1F3B => array(0x1F33), 0x1F3C => array(0x1F34), - 0x1F3D => array(0x1F35), 0x1F3E => array(0x1F36), 0x1F3F => array(0x1F37), - 0x1F48 => array(0x1F40), 0x1F49 => array(0x1F41), 0x1F4A => array(0x1F42), - 0x1F4B => array(0x1F43), 0x1F4C => array(0x1F44), 0x1F4D => array(0x1F45), - 0x1F59 => array(0x1F51), 0x1F5B => array(0x1F53), 0x1F5D => array(0x1F55), - 0x1F5F => array(0x1F57), 0x1F68 => array(0x1F60), 0x1F69 => array(0x1F61), - 0x1F6A => array(0x1F62), 0x1F6B => array(0x1F63), 0x1F6C => array(0x1F64), - 0x1F6D => array(0x1F65), 0x1F6E => array(0x1F66), 0x1F6F => array(0x1F67), - 0x1F71 => array(0x3AC), 0x1F73 => array(0x3AD), 0x1F75 => array(0x3AE), - 0x1F77 => array(0x3AF), 0x1F79 => array(0x3CC), 0x1F7B => array(0x3CD), - 0x1F7D => array(0x3CE), 0x1F80 => array(0x1F00, 0x3B9), 0x1F81 => array(0x1F01, 0x3B9), - 0x1F82 => array(0x1F02, 0x3B9), 0x1F83 => array(0x1F03, 0x3B9), 0x1F84 => array(0x1F04, 0x3B9), - 0x1F85 => array(0x1F05, 0x3B9), 0x1F86 => array(0x1F06, 0x3B9), 0x1F87 => array(0x1F07, 0x3B9), - 0x1F88 => array(0x1F00, 0x3B9), 0x1F89 => array(0x1F01, 0x3B9), 0x1F8A => array(0x1F02, 0x3B9), - 0x1F8B => array(0x1F03, 0x3B9), 0x1F8C => array(0x1F04, 0x3B9), 0x1F8D => array(0x1F05, 0x3B9), - 0x1F8E => array(0x1F06, 0x3B9), 0x1F8F => array(0x1F07, 0x3B9), 0x1F90 => array(0x1F20, 0x3B9), - 0x1F91 => array(0x1F21, 0x3B9), 0x1F92 => array(0x1F22, 0x3B9), 0x1F93 => array(0x1F23, 0x3B9), - 0x1F94 => array(0x1F24, 0x3B9), 0x1F95 => array(0x1F25, 0x3B9), 0x1F96 => array(0x1F26, 0x3B9), - 0x1F97 => array(0x1F27, 0x3B9), 0x1F98 => array(0x1F20, 0x3B9), 0x1F99 => array(0x1F21, 0x3B9), - 0x1F9A => array(0x1F22, 0x3B9), 0x1F9B => array(0x1F23, 0x3B9), 0x1F9C => array(0x1F24, 0x3B9), - 0x1F9D => array(0x1F25, 0x3B9), 0x1F9E => array(0x1F26, 0x3B9), 0x1F9F => array(0x1F27, 0x3B9), - 0x1FA0 => array(0x1F60, 0x3B9), 0x1FA1 => array(0x1F61, 0x3B9), 0x1FA2 => array(0x1F62, 0x3B9), - 0x1FA3 => array(0x1F63, 0x3B9), 0x1FA4 => array(0x1F64, 0x3B9), 0x1FA5 => array(0x1F65, 0x3B9), - 0x1FA6 => array(0x1F66, 0x3B9), 0x1FA7 => array(0x1F67, 0x3B9), 0x1FA8 => array(0x1F60, 0x3B9), - 0x1FA9 => array(0x1F61, 0x3B9), 0x1FAA => array(0x1F62, 0x3B9), 0x1FAB => array(0x1F63, 0x3B9), - 0x1FAC => array(0x1F64, 0x3B9), 0x1FAD => array(0x1F65, 0x3B9), 0x1FAE => array(0x1F66, 0x3B9), - 0x1FAF => array(0x1F67, 0x3B9), 0x1FB2 => array(0x1F70, 0x3B9), 0x1FB3 => array(0x3B1, 0x3B9), - 0x1FB4 => array(0x3AC, 0x3B9), 0x1FB7 => array(0x1FB6, 0x3B9), 0x1FB8 => array(0x1FB0), - 0x1FB9 => array(0x1FB1), 0x1FBA => array(0x1F70), 0x1FBB => array(0x3AC), - 0x1FBC => array(0x3B1, 0x3B9), 0x1FBE => array(0x3B9), 0x1FC2 => array(0x1F74, 0x3B9), - 0x1FC3 => array(0x3B7, 0x3B9), 0x1FC4 => array(0x3AE, 0x3B9), 0x1FC7 => array(0x1FC6, 0x3B9), - 0x1FC8 => array(0x1F72), 0x1FC9 => array(0x3AD), 0x1FCA => array(0x1F74), - 0x1FCB => array(0x3AE), 0x1FCC => array(0x3B7, 0x3B9), 0x1FD3 => array(0x390), - 0x1FD8 => array(0x1FD0), 0x1FD9 => array(0x1FD1), 0x1FDA => array(0x1F76), - 0x1FDB => array(0x3AF), 0x1FE3 => array(0x3B0), 0x1FE8 => array(0x1FE0), - 0x1FE9 => array(0x1FE1), 0x1FEA => array(0x1F7A), 0x1FEB => array(0x3CD), - 0x1FEC => array(0x1FE5), 0x1FF2 => array(0x1F7C, 0x3B9), 0x1FF3 => array(0x3C9, 0x3B9), - 0x1FF4 => array(0x3CE, 0x3B9), 0x1FF7 => array(0x1FF6, 0x3B9), 0x1FF8 => array(0x1F78), - 0x1FF9 => array(0x3CC), 0x1FFA => array(0x1F7C), 0x1FFB => array(0x3CE), - 0x1FFC => array(0x3C9, 0x3B9), 0x2011 => array(0x2010), 0x2033 => array(0x2032, 0x2032), - 0x2034 => array(0x2032, 0x2032, 0x2032), 0x2036 => array(0x2035, 0x2035), 0x2037 => array(0x2035, 0x2035, 0x2035), - 0x2057 => array(0x2032, 0x2032, 0x2032, 0x2032), 0x2070 => array(0x30), 0x2071 => array(0x69), - 0x2074 => array(0x34), 0x2075 => array(0x35), 0x2076 => array(0x36), - 0x2077 => array(0x37), 0x2078 => array(0x38), 0x2079 => array(0x39), - 0x207B => array(0x2212), 0x207F => array(0x6E), 0x2080 => array(0x30), - 0x2081 => array(0x31), 0x2082 => array(0x32), 0x2083 => array(0x33), - 0x2084 => array(0x34), 0x2085 => array(0x35), 0x2086 => array(0x36), - 0x2087 => array(0x37), 0x2088 => array(0x38), 0x2089 => array(0x39), - 0x208B => array(0x2212), 0x2090 => array(0x61), 0x2091 => array(0x65), - 0x2092 => array(0x6F), 0x2093 => array(0x78), 0x2094 => array(0x259), - 0x2095 => array(0x68), 0x2096 => array(0x6B), 0x2097 => array(0x6C), - 0x2098 => array(0x6D), 0x2099 => array(0x6E), 0x209A => array(0x70), - 0x209B => array(0x73), 0x209C => array(0x74), 0x20A8 => array(0x72, 0x73), - 0x2102 => array(0x63), 0x2103 => array(0xB0, 0x63), 0x2107 => array(0x25B), - 0x2109 => array(0xB0, 0x66), 0x210A => array(0x67), 0x210B => array(0x68), - 0x210C => array(0x68), 0x210D => array(0x68), 0x210E => array(0x68), - 0x210F => array(0x127), 0x2110 => array(0x69), 0x2111 => array(0x69), - 0x2112 => array(0x6C), 0x2113 => array(0x6C), 0x2115 => array(0x6E), - 0x2116 => array(0x6E, 0x6F), 0x2119 => array(0x70), 0x211A => array(0x71), - 0x211B => array(0x72), 0x211C => array(0x72), 0x211D => array(0x72), - 0x2120 => array(0x73, 0x6D), 0x2121 => array(0x74, 0x65, 0x6C), 0x2122 => array(0x74, 0x6D), - 0x2124 => array(0x7A), 0x2126 => array(0x3C9), 0x2128 => array(0x7A), - 0x212A => array(0x6B), 0x212B => array(0xE5), 0x212C => array(0x62), - 0x212D => array(0x63), 0x212F => array(0x65), 0x2130 => array(0x65), - 0x2131 => array(0x66), 0x2133 => array(0x6D), 0x2134 => array(0x6F), - 0x2135 => array(0x5D0), 0x2136 => array(0x5D1), 0x2137 => array(0x5D2), - 0x2138 => array(0x5D3), 0x2139 => array(0x69), 0x213B => array(0x66, 0x61, 0x78), - 0x213C => array(0x3C0), 0x213D => array(0x3B3), 0x213E => array(0x3B3), - 0x213F => array(0x3C0), 0x2140 => array(0x2211), 0x2145 => array(0x64), - 0x2146 => array(0x64), 0x2147 => array(0x65), 0x2148 => array(0x69), - 0x2149 => array(0x6A), 0x2150 => array(0x31, 0x2044, 0x37), 0x2151 => array(0x31, 0x2044, 0x39), - 0x2152 => array(0x31, 0x2044, 0x31, 0x30), 0x2153 => array(0x31, 0x2044, 0x33), 0x2154 => array(0x32, 0x2044, 0x33), - 0x2155 => array(0x31, 0x2044, 0x35), 0x2156 => array(0x32, 0x2044, 0x35), 0x2157 => array(0x33, 0x2044, 0x35), - 0x2158 => array(0x34, 0x2044, 0x35), 0x2159 => array(0x31, 0x2044, 0x36), 0x215A => array(0x35, 0x2044, 0x36), - 0x215B => array(0x31, 0x2044, 0x38), 0x215C => array(0x33, 0x2044, 0x38), 0x215D => array(0x35, 0x2044, 0x38), - 0x215E => array(0x37, 0x2044, 0x38), 0x215F => array(0x31, 0x2044), 0x2160 => array(0x69), - 0x2161 => array(0x69, 0x69), 0x2162 => array(0x69, 0x69, 0x69), 0x2163 => array(0x69, 0x76), - 0x2164 => array(0x76), 0x2165 => array(0x76, 0x69), 0x2166 => array(0x76, 0x69, 0x69), - 0x2167 => array(0x76, 0x69, 0x69, 0x69), 0x2168 => array(0x69, 0x78), 0x2169 => array(0x78), - 0x216A => array(0x78, 0x69), 0x216B => array(0x78, 0x69, 0x69), 0x216C => array(0x6C), - 0x216D => array(0x63), 0x216E => array(0x64), 0x216F => array(0x6D), - 0x2170 => array(0x69), 0x2171 => array(0x69, 0x69), 0x2172 => array(0x69, 0x69, 0x69), - 0x2173 => array(0x69, 0x76), 0x2174 => array(0x76), 0x2175 => array(0x76, 0x69), - 0x2176 => array(0x76, 0x69, 0x69), 0x2177 => array(0x76, 0x69, 0x69, 0x69), 0x2178 => array(0x69, 0x78), - 0x2179 => array(0x78), 0x217A => array(0x78, 0x69), 0x217B => array(0x78, 0x69, 0x69), - 0x217C => array(0x6C), 0x217D => array(0x63), 0x217E => array(0x64), - 0x217F => array(0x6D), 0x2189 => array(0x30, 0x2044, 0x33), 0x222C => array(0x222B, 0x222B), - 0x222D => array(0x222B, 0x222B, 0x222B), 0x222F => array(0x222E, 0x222E), 0x2230 => array(0x222E, 0x222E, 0x222E), - 0x2329 => array(0x3008), 0x232A => array(0x3009), 0x2460 => array(0x31), - 0x2461 => array(0x32), 0x2462 => array(0x33), 0x2463 => array(0x34), - 0x2464 => array(0x35), 0x2465 => array(0x36), 0x2466 => array(0x37), - 0x2467 => array(0x38), 0x2468 => array(0x39), 0x2469 => array(0x31, 0x30), - 0x246A => array(0x31, 0x31), 0x246B => array(0x31, 0x32), 0x246C => array(0x31, 0x33), - 0x246D => array(0x31, 0x34), 0x246E => array(0x31, 0x35), 0x246F => array(0x31, 0x36), - 0x2470 => array(0x31, 0x37), 0x2471 => array(0x31, 0x38), 0x2472 => array(0x31, 0x39), - 0x2473 => array(0x32, 0x30), 0x24B6 => array(0x61), 0x24B7 => array(0x62), - 0x24B8 => array(0x63), 0x24B9 => array(0x64), 0x24BA => array(0x65), - 0x24BB => array(0x66), 0x24BC => array(0x67), 0x24BD => array(0x68), - 0x24BE => array(0x69), 0x24BF => array(0x6A), 0x24C0 => array(0x6B), - 0x24C1 => array(0x6C), 0x24C2 => array(0x6D), 0x24C3 => array(0x6E), - 0x24C4 => array(0x6F), 0x24C5 => array(0x70), 0x24C6 => array(0x71), - 0x24C7 => array(0x72), 0x24C8 => array(0x73), 0x24C9 => array(0x74), - 0x24CA => array(0x75), 0x24CB => array(0x76), 0x24CC => array(0x77), - 0x24CD => array(0x78), 0x24CE => array(0x79), 0x24CF => array(0x7A), - 0x24D0 => array(0x61), 0x24D1 => array(0x62), 0x24D2 => array(0x63), - 0x24D3 => array(0x64), 0x24D4 => array(0x65), 0x24D5 => array(0x66), - 0x24D6 => array(0x67), 0x24D7 => array(0x68), 0x24D8 => array(0x69), - 0x24D9 => array(0x6A), 0x24DA => array(0x6B), 0x24DB => array(0x6C), - 0x24DC => array(0x6D), 0x24DD => array(0x6E), 0x24DE => array(0x6F), - 0x24DF => array(0x70), 0x24E0 => array(0x71), 0x24E1 => array(0x72), - 0x24E2 => array(0x73), 0x24E3 => array(0x74), 0x24E4 => array(0x75), - 0x24E5 => array(0x76), 0x24E6 => array(0x77), 0x24E7 => array(0x78), - 0x24E8 => array(0x79), 0x24E9 => array(0x7A), 0x24EA => array(0x30), - 0x2A0C => array(0x222B, 0x222B, 0x222B, 0x222B), 0x2ADC => array(0x2ADD, 0x338), 0x2C00 => array(0x2C30), - 0x2C01 => array(0x2C31), 0x2C02 => array(0x2C32), 0x2C03 => array(0x2C33), - 0x2C04 => array(0x2C34), 0x2C05 => array(0x2C35), 0x2C06 => array(0x2C36), - 0x2C07 => array(0x2C37), 0x2C08 => array(0x2C38), 0x2C09 => array(0x2C39), - 0x2C0A => array(0x2C3A), 0x2C0B => array(0x2C3B), 0x2C0C => array(0x2C3C), - 0x2C0D => array(0x2C3D), 0x2C0E => array(0x2C3E), 0x2C0F => array(0x2C3F), - 0x2C10 => array(0x2C40), 0x2C11 => array(0x2C41), 0x2C12 => array(0x2C42), - 0x2C13 => array(0x2C43), 0x2C14 => array(0x2C44), 0x2C15 => array(0x2C45), - 0x2C16 => array(0x2C46), 0x2C17 => array(0x2C47), 0x2C18 => array(0x2C48), - 0x2C19 => array(0x2C49), 0x2C1A => array(0x2C4A), 0x2C1B => array(0x2C4B), - 0x2C1C => array(0x2C4C), 0x2C1D => array(0x2C4D), 0x2C1E => array(0x2C4E), - 0x2C1F => array(0x2C4F), 0x2C20 => array(0x2C50), 0x2C21 => array(0x2C51), - 0x2C22 => array(0x2C52), 0x2C23 => array(0x2C53), 0x2C24 => array(0x2C54), - 0x2C25 => array(0x2C55), 0x2C26 => array(0x2C56), 0x2C27 => array(0x2C57), - 0x2C28 => array(0x2C58), 0x2C29 => array(0x2C59), 0x2C2A => array(0x2C5A), - 0x2C2B => array(0x2C5B), 0x2C2C => array(0x2C5C), 0x2C2D => array(0x2C5D), - 0x2C2E => array(0x2C5E), 0x2C60 => array(0x2C61), 0x2C62 => array(0x26B), - 0x2C63 => array(0x1D7D), 0x2C64 => array(0x27D), 0x2C67 => array(0x2C68), - 0x2C69 => array(0x2C6A), 0x2C6B => array(0x2C6C), 0x2C6D => array(0x251), - 0x2C6E => array(0x271), 0x2C6F => array(0x250), 0x2C70 => array(0x252), - 0x2C72 => array(0x2C73), 0x2C75 => array(0x2C76), 0x2C7C => array(0x6A), - 0x2C7D => array(0x76), 0x2C7E => array(0x23F), 0x2C7F => array(0x240), - 0x2C80 => array(0x2C81), 0x2C82 => array(0x2C83), 0x2C84 => array(0x2C85), - 0x2C86 => array(0x2C87), 0x2C88 => array(0x2C89), 0x2C8A => array(0x2C8B), - 0x2C8C => array(0x2C8D), 0x2C8E => array(0x2C8F), 0x2C90 => array(0x2C91), - 0x2C92 => array(0x2C93), 0x2C94 => array(0x2C95), 0x2C96 => array(0x2C97), - 0x2C98 => array(0x2C99), 0x2C9A => array(0x2C9B), 0x2C9C => array(0x2C9D), - 0x2C9E => array(0x2C9F), 0x2CA0 => array(0x2CA1), 0x2CA2 => array(0x2CA3), - 0x2CA4 => array(0x2CA5), 0x2CA6 => array(0x2CA7), 0x2CA8 => array(0x2CA9), - 0x2CAA => array(0x2CAB), 0x2CAC => array(0x2CAD), 0x2CAE => array(0x2CAF), - 0x2CB0 => array(0x2CB1), 0x2CB2 => array(0x2CB3), 0x2CB4 => array(0x2CB5), - 0x2CB6 => array(0x2CB7), 0x2CB8 => array(0x2CB9), 0x2CBA => array(0x2CBB), - 0x2CBC => array(0x2CBD), 0x2CBE => array(0x2CBF), 0x2CC0 => array(0x2CC1), - 0x2CC2 => array(0x2CC3), 0x2CC4 => array(0x2CC5), 0x2CC6 => array(0x2CC7), - 0x2CC8 => array(0x2CC9), 0x2CCA => array(0x2CCB), 0x2CCC => array(0x2CCD), - 0x2CCE => array(0x2CCF), 0x2CD0 => array(0x2CD1), 0x2CD2 => array(0x2CD3), - 0x2CD4 => array(0x2CD5), 0x2CD6 => array(0x2CD7), 0x2CD8 => array(0x2CD9), - 0x2CDA => array(0x2CDB), 0x2CDC => array(0x2CDD), 0x2CDE => array(0x2CDF), - 0x2CE0 => array(0x2CE1), 0x2CE2 => array(0x2CE3), 0x2CEB => array(0x2CEC), - 0x2CED => array(0x2CEE), 0x2CF2 => array(0x2CF3), 0x2D6F => array(0x2D61), - 0x2E9F => array(0x6BCD), 0x2EF3 => array(0x9F9F), 0x2F00 => array(0x4E00), - 0x2F01 => array(0x4E28), 0x2F02 => array(0x4E36), 0x2F03 => array(0x4E3F), - 0x2F04 => array(0x4E59), 0x2F05 => array(0x4E85), 0x2F06 => array(0x4E8C), - 0x2F07 => array(0x4EA0), 0x2F08 => array(0x4EBA), 0x2F09 => array(0x513F), - 0x2F0A => array(0x5165), 0x2F0B => array(0x516B), 0x2F0C => array(0x5182), - 0x2F0D => array(0x5196), 0x2F0E => array(0x51AB), 0x2F0F => array(0x51E0), - 0x2F10 => array(0x51F5), 0x2F11 => array(0x5200), 0x2F12 => array(0x529B), - 0x2F13 => array(0x52F9), 0x2F14 => array(0x5315), 0x2F15 => array(0x531A), - 0x2F16 => array(0x5338), 0x2F17 => array(0x5341), 0x2F18 => array(0x535C), - 0x2F19 => array(0x5369), 0x2F1A => array(0x5382), 0x2F1B => array(0x53B6), - 0x2F1C => array(0x53C8), 0x2F1D => array(0x53E3), 0x2F1E => array(0x56D7), - 0x2F1F => array(0x571F), 0x2F20 => array(0x58EB), 0x2F21 => array(0x5902), - 0x2F22 => array(0x590A), 0x2F23 => array(0x5915), 0x2F24 => array(0x5927), - 0x2F25 => array(0x5973), 0x2F26 => array(0x5B50), 0x2F27 => array(0x5B80), - 0x2F28 => array(0x5BF8), 0x2F29 => array(0x5C0F), 0x2F2A => array(0x5C22), - 0x2F2B => array(0x5C38), 0x2F2C => array(0x5C6E), 0x2F2D => array(0x5C71), - 0x2F2E => array(0x5DDB), 0x2F2F => array(0x5DE5), 0x2F30 => array(0x5DF1), - 0x2F31 => array(0x5DFE), 0x2F32 => array(0x5E72), 0x2F33 => array(0x5E7A), - 0x2F34 => array(0x5E7F), 0x2F35 => array(0x5EF4), 0x2F36 => array(0x5EFE), - 0x2F37 => array(0x5F0B), 0x2F38 => array(0x5F13), 0x2F39 => array(0x5F50), - 0x2F3A => array(0x5F61), 0x2F3B => array(0x5F73), 0x2F3C => array(0x5FC3), - 0x2F3D => array(0x6208), 0x2F3E => array(0x6236), 0x2F3F => array(0x624B), - 0x2F40 => array(0x652F), 0x2F41 => array(0x6534), 0x2F42 => array(0x6587), - 0x2F43 => array(0x6597), 0x2F44 => array(0x65A4), 0x2F45 => array(0x65B9), - 0x2F46 => array(0x65E0), 0x2F47 => array(0x65E5), 0x2F48 => array(0x66F0), - 0x2F49 => array(0x6708), 0x2F4A => array(0x6728), 0x2F4B => array(0x6B20), - 0x2F4C => array(0x6B62), 0x2F4D => array(0x6B79), 0x2F4E => array(0x6BB3), - 0x2F4F => array(0x6BCB), 0x2F50 => array(0x6BD4), 0x2F51 => array(0x6BDB), - 0x2F52 => array(0x6C0F), 0x2F53 => array(0x6C14), 0x2F54 => array(0x6C34), - 0x2F55 => array(0x706B), 0x2F56 => array(0x722A), 0x2F57 => array(0x7236), - 0x2F58 => array(0x723B), 0x2F59 => array(0x723F), 0x2F5A => array(0x7247), - 0x2F5B => array(0x7259), 0x2F5C => array(0x725B), 0x2F5D => array(0x72AC), - 0x2F5E => array(0x7384), 0x2F5F => array(0x7389), 0x2F60 => array(0x74DC), - 0x2F61 => array(0x74E6), 0x2F62 => array(0x7518), 0x2F63 => array(0x751F), - 0x2F64 => array(0x7528), 0x2F65 => array(0x7530), 0x2F66 => array(0x758B), - 0x2F67 => array(0x7592), 0x2F68 => array(0x7676), 0x2F69 => array(0x767D), - 0x2F6A => array(0x76AE), 0x2F6B => array(0x76BF), 0x2F6C => array(0x76EE), - 0x2F6D => array(0x77DB), 0x2F6E => array(0x77E2), 0x2F6F => array(0x77F3), - 0x2F70 => array(0x793A), 0x2F71 => array(0x79B8), 0x2F72 => array(0x79BE), - 0x2F73 => array(0x7A74), 0x2F74 => array(0x7ACB), 0x2F75 => array(0x7AF9), - 0x2F76 => array(0x7C73), 0x2F77 => array(0x7CF8), 0x2F78 => array(0x7F36), - 0x2F79 => array(0x7F51), 0x2F7A => array(0x7F8A), 0x2F7B => array(0x7FBD), - 0x2F7C => array(0x8001), 0x2F7D => array(0x800C), 0x2F7E => array(0x8012), - 0x2F7F => array(0x8033), 0x2F80 => array(0x807F), 0x2F81 => array(0x8089), - 0x2F82 => array(0x81E3), 0x2F83 => array(0x81EA), 0x2F84 => array(0x81F3), - 0x2F85 => array(0x81FC), 0x2F86 => array(0x820C), 0x2F87 => array(0x821B), - 0x2F88 => array(0x821F), 0x2F89 => array(0x826E), 0x2F8A => array(0x8272), - 0x2F8B => array(0x8278), 0x2F8C => array(0x864D), 0x2F8D => array(0x866B), - 0x2F8E => array(0x8840), 0x2F8F => array(0x884C), 0x2F90 => array(0x8863), - 0x2F91 => array(0x897E), 0x2F92 => array(0x898B), 0x2F93 => array(0x89D2), - 0x2F94 => array(0x8A00), 0x2F95 => array(0x8C37), 0x2F96 => array(0x8C46), - 0x2F97 => array(0x8C55), 0x2F98 => array(0x8C78), 0x2F99 => array(0x8C9D), - 0x2F9A => array(0x8D64), 0x2F9B => array(0x8D70), 0x2F9C => array(0x8DB3), - 0x2F9D => array(0x8EAB), 0x2F9E => array(0x8ECA), 0x2F9F => array(0x8F9B), - 0x2FA0 => array(0x8FB0), 0x2FA1 => array(0x8FB5), 0x2FA2 => array(0x9091), - 0x2FA3 => array(0x9149), 0x2FA4 => array(0x91C6), 0x2FA5 => array(0x91CC), - 0x2FA6 => array(0x91D1), 0x2FA7 => array(0x9577), 0x2FA8 => array(0x9580), - 0x2FA9 => array(0x961C), 0x2FAA => array(0x96B6), 0x2FAB => array(0x96B9), - 0x2FAC => array(0x96E8), 0x2FAD => array(0x9751), 0x2FAE => array(0x975E), - 0x2FAF => array(0x9762), 0x2FB0 => array(0x9769), 0x2FB1 => array(0x97CB), - 0x2FB2 => array(0x97ED), 0x2FB3 => array(0x97F3), 0x2FB4 => array(0x9801), - 0x2FB5 => array(0x98A8), 0x2FB6 => array(0x98DB), 0x2FB7 => array(0x98DF), - 0x2FB8 => array(0x9996), 0x2FB9 => array(0x9999), 0x2FBA => array(0x99AC), - 0x2FBB => array(0x9AA8), 0x2FBC => array(0x9AD8), 0x2FBD => array(0x9ADF), - 0x2FBE => array(0x9B25), 0x2FBF => array(0x9B2F), 0x2FC0 => array(0x9B32), - 0x2FC1 => array(0x9B3C), 0x2FC2 => array(0x9B5A), 0x2FC3 => array(0x9CE5), - 0x2FC4 => array(0x9E75), 0x2FC5 => array(0x9E7F), 0x2FC6 => array(0x9EA5), - 0x2FC7 => array(0x9EBB), 0x2FC8 => array(0x9EC3), 0x2FC9 => array(0x9ECD), - 0x2FCA => array(0x9ED1), 0x2FCB => array(0x9EF9), 0x2FCC => array(0x9EFD), - 0x2FCD => array(0x9F0E), 0x2FCE => array(0x9F13), 0x2FCF => array(0x9F20), - 0x2FD0 => array(0x9F3B), 0x2FD1 => array(0x9F4A), 0x2FD2 => array(0x9F52), - 0x2FD3 => array(0x9F8D), 0x2FD4 => array(0x9F9C), 0x2FD5 => array(0x9FA0), - 0x3002 => array(0x2E), 0x3036 => array(0x3012), 0x3038 => array(0x5341), - 0x3039 => array(0x5344), 0x303A => array(0x5345), 0x309F => array(0x3088, 0x308A), - 0x30FF => array(0x30B3, 0x30C8), 0x3131 => array(0x1100), 0x3132 => array(0x1101), - 0x3133 => array(0x11AA), 0x3134 => array(0x1102), 0x3135 => array(0x11AC), - 0x3136 => array(0x11AD), 0x3137 => array(0x1103), 0x3138 => array(0x1104), - 0x3139 => array(0x1105), 0x313A => array(0x11B0), 0x313B => array(0x11B1), - 0x313C => array(0x11B2), 0x313D => array(0x11B3), 0x313E => array(0x11B4), - 0x313F => array(0x11B5), 0x3140 => array(0x111A), 0x3141 => array(0x1106), - 0x3142 => array(0x1107), 0x3143 => array(0x1108), 0x3144 => array(0x1121), - 0x3145 => array(0x1109), 0x3146 => array(0x110A), 0x3147 => array(0x110B), - 0x3148 => array(0x110C), 0x3149 => array(0x110D), 0x314A => array(0x110E), - 0x314B => array(0x110F), 0x314C => array(0x1110), 0x314D => array(0x1111), - 0x314E => array(0x1112), 0x314F => array(0x1161), 0x3150 => array(0x1162), - 0x3151 => array(0x1163), 0x3152 => array(0x1164), 0x3153 => array(0x1165), - 0x3154 => array(0x1166), 0x3155 => array(0x1167), 0x3156 => array(0x1168), - 0x3157 => array(0x1169), 0x3158 => array(0x116A), 0x3159 => array(0x116B), - 0x315A => array(0x116C), 0x315B => array(0x116D), 0x315C => array(0x116E), - 0x315D => array(0x116F), 0x315E => array(0x1170), 0x315F => array(0x1171), - 0x3160 => array(0x1172), 0x3161 => array(0x1173), 0x3162 => array(0x1174), - 0x3163 => array(0x1175), 0x3165 => array(0x1114), 0x3166 => array(0x1115), - 0x3167 => array(0x11C7), 0x3168 => array(0x11C8), 0x3169 => array(0x11CC), - 0x316A => array(0x11CE), 0x316B => array(0x11D3), 0x316C => array(0x11D7), - 0x316D => array(0x11D9), 0x316E => array(0x111C), 0x316F => array(0x11DD), - 0x3170 => array(0x11DF), 0x3171 => array(0x111D), 0x3172 => array(0x111E), - 0x3173 => array(0x1120), 0x3174 => array(0x1122), 0x3175 => array(0x1123), - 0x3176 => array(0x1127), 0x3177 => array(0x1129), 0x3178 => array(0x112B), - 0x3179 => array(0x112C), 0x317A => array(0x112D), 0x317B => array(0x112E), - 0x317C => array(0x112F), 0x317D => array(0x1132), 0x317E => array(0x1136), - 0x317F => array(0x1140), 0x3180 => array(0x1147), 0x3181 => array(0x114C), - 0x3182 => array(0x11F1), 0x3183 => array(0x11F2), 0x3184 => array(0x1157), - 0x3185 => array(0x1158), 0x3186 => array(0x1159), 0x3187 => array(0x1184), - 0x3188 => array(0x1185), 0x3189 => array(0x1188), 0x318A => array(0x1191), - 0x318B => array(0x1192), 0x318C => array(0x1194), 0x318D => array(0x119E), - 0x318E => array(0x11A1), 0x3192 => array(0x4E00), 0x3193 => array(0x4E8C), - 0x3194 => array(0x4E09), 0x3195 => array(0x56DB), 0x3196 => array(0x4E0A), - 0x3197 => array(0x4E2D), 0x3198 => array(0x4E0B), 0x3199 => array(0x7532), - 0x319A => array(0x4E59), 0x319B => array(0x4E19), 0x319C => array(0x4E01), - 0x319D => array(0x5929), 0x319E => array(0x5730), 0x319F => array(0x4EBA), - 0x3244 => array(0x554F), 0x3245 => array(0x5E7C), 0x3246 => array(0x6587), - 0x3247 => array(0x7B8F), 0x3250 => array(0x70, 0x74, 0x65), 0x3251 => array(0x32, 0x31), - 0x3252 => array(0x32, 0x32), 0x3253 => array(0x32, 0x33), 0x3254 => array(0x32, 0x34), - 0x3255 => array(0x32, 0x35), 0x3256 => array(0x32, 0x36), 0x3257 => array(0x32, 0x37), - 0x3258 => array(0x32, 0x38), 0x3259 => array(0x32, 0x39), 0x325A => array(0x33, 0x30), - 0x325B => array(0x33, 0x31), 0x325C => array(0x33, 0x32), 0x325D => array(0x33, 0x33), - 0x325E => array(0x33, 0x34), 0x325F => array(0x33, 0x35), 0x3260 => array(0x1100), - 0x3261 => array(0x1102), 0x3262 => array(0x1103), 0x3263 => array(0x1105), - 0x3264 => array(0x1106), 0x3265 => array(0x1107), 0x3266 => array(0x1109), - 0x3267 => array(0x110B), 0x3268 => array(0x110C), 0x3269 => array(0x110E), - 0x326A => array(0x110F), 0x326B => array(0x1110), 0x326C => array(0x1111), - 0x326D => array(0x1112), 0x326E => array(0xAC00), 0x326F => array(0xB098), - 0x3270 => array(0xB2E4), 0x3271 => array(0xB77C), 0x3272 => array(0xB9C8), - 0x3273 => array(0xBC14), 0x3274 => array(0xC0AC), 0x3275 => array(0xC544), - 0x3276 => array(0xC790), 0x3277 => array(0xCC28), 0x3278 => array(0xCE74), - 0x3279 => array(0xD0C0), 0x327A => array(0xD30C), 0x327B => array(0xD558), - 0x327C => array(0xCC38, 0xACE0), 0x327D => array(0xC8FC, 0xC758), 0x327E => array(0xC6B0), - 0x3280 => array(0x4E00), 0x3281 => array(0x4E8C), 0x3282 => array(0x4E09), - 0x3283 => array(0x56DB), 0x3284 => array(0x4E94), 0x3285 => array(0x516D), - 0x3286 => array(0x4E03), 0x3287 => array(0x516B), 0x3288 => array(0x4E5D), - 0x3289 => array(0x5341), 0x328A => array(0x6708), 0x328B => array(0x706B), - 0x328C => array(0x6C34), 0x328D => array(0x6728), 0x328E => array(0x91D1), - 0x328F => array(0x571F), 0x3290 => array(0x65E5), 0x3291 => array(0x682A), - 0x3292 => array(0x6709), 0x3293 => array(0x793E), 0x3294 => array(0x540D), - 0x3295 => array(0x7279), 0x3296 => array(0x8CA1), 0x3297 => array(0x795D), - 0x3298 => array(0x52B4), 0x3299 => array(0x79D8), 0x329A => array(0x7537), - 0x329B => array(0x5973), 0x329C => array(0x9069), 0x329D => array(0x512A), - 0x329E => array(0x5370), 0x329F => array(0x6CE8), 0x32A0 => array(0x9805), - 0x32A1 => array(0x4F11), 0x32A2 => array(0x5199), 0x32A3 => array(0x6B63), - 0x32A4 => array(0x4E0A), 0x32A5 => array(0x4E2D), 0x32A6 => array(0x4E0B), - 0x32A7 => array(0x5DE6), 0x32A8 => array(0x53F3), 0x32A9 => array(0x533B), - 0x32AA => array(0x5B97), 0x32AB => array(0x5B66), 0x32AC => array(0x76E3), - 0x32AD => array(0x4F01), 0x32AE => array(0x8CC7), 0x32AF => array(0x5354), - 0x32B0 => array(0x591C), 0x32B1 => array(0x33, 0x36), 0x32B2 => array(0x33, 0x37), - 0x32B3 => array(0x33, 0x38), 0x32B4 => array(0x33, 0x39), 0x32B5 => array(0x34, 0x30), - 0x32B6 => array(0x34, 0x31), 0x32B7 => array(0x34, 0x32), 0x32B8 => array(0x34, 0x33), - 0x32B9 => array(0x34, 0x34), 0x32BA => array(0x34, 0x35), 0x32BB => array(0x34, 0x36), - 0x32BC => array(0x34, 0x37), 0x32BD => array(0x34, 0x38), 0x32BE => array(0x34, 0x39), - 0x32BF => array(0x35, 0x30), 0x32C0 => array(0x31, 0x6708), 0x32C1 => array(0x32, 0x6708), - 0x32C2 => array(0x33, 0x6708), 0x32C3 => array(0x34, 0x6708), 0x32C4 => array(0x35, 0x6708), - 0x32C5 => array(0x36, 0x6708), 0x32C6 => array(0x37, 0x6708), 0x32C7 => array(0x38, 0x6708), - 0x32C8 => array(0x39, 0x6708), 0x32C9 => array(0x31, 0x30, 0x6708), 0x32CA => array(0x31, 0x31, 0x6708), - 0x32CB => array(0x31, 0x32, 0x6708), 0x32CC => array(0x68, 0x67), 0x32CD => array(0x65, 0x72, 0x67), - 0x32CE => array(0x65, 0x76), 0x32CF => array(0x6C, 0x74, 0x64), 0x32D0 => array(0x30A2), - 0x32D1 => array(0x30A4), 0x32D2 => array(0x30A6), 0x32D3 => array(0x30A8), - 0x32D4 => array(0x30AA), 0x32D5 => array(0x30AB), 0x32D6 => array(0x30AD), - 0x32D7 => array(0x30AF), 0x32D8 => array(0x30B1), 0x32D9 => array(0x30B3), - 0x32DA => array(0x30B5), 0x32DB => array(0x30B7), 0x32DC => array(0x30B9), - 0x32DD => array(0x30BB), 0x32DE => array(0x30BD), 0x32DF => array(0x30BF), - 0x32E0 => array(0x30C1), 0x32E1 => array(0x30C4), 0x32E2 => array(0x30C6), - 0x32E3 => array(0x30C8), 0x32E4 => array(0x30CA), 0x32E5 => array(0x30CB), - 0x32E6 => array(0x30CC), 0x32E7 => array(0x30CD), 0x32E8 => array(0x30CE), - 0x32E9 => array(0x30CF), 0x32EA => array(0x30D2), 0x32EB => array(0x30D5), - 0x32EC => array(0x30D8), 0x32ED => array(0x30DB), 0x32EE => array(0x30DE), - 0x32EF => array(0x30DF), 0x32F0 => array(0x30E0), 0x32F1 => array(0x30E1), - 0x32F2 => array(0x30E2), 0x32F3 => array(0x30E4), 0x32F4 => array(0x30E6), - 0x32F5 => array(0x30E8), 0x32F6 => array(0x30E9), 0x32F7 => array(0x30EA), - 0x32F8 => array(0x30EB), 0x32F9 => array(0x30EC), 0x32FA => array(0x30ED), - 0x32FB => array(0x30EF), 0x32FC => array(0x30F0), 0x32FD => array(0x30F1), - 0x32FE => array(0x30F2), 0x3300 => array(0x30A2, 0x30D1, 0x30FC, 0x30C8), 0x3301 => array(0x30A2, 0x30EB, 0x30D5, 0x30A1), - 0x3302 => array(0x30A2, 0x30F3, 0x30DA, 0x30A2), 0x3303 => array(0x30A2, 0x30FC, 0x30EB), 0x3304 => array(0x30A4, 0x30CB, 0x30F3, 0x30B0), - 0x3305 => array(0x30A4, 0x30F3, 0x30C1), 0x3306 => array(0x30A6, 0x30A9, 0x30F3), 0x3307 => array(0x30A8, 0x30B9, 0x30AF, 0x30FC, 0x30C9), - 0x3308 => array(0x30A8, 0x30FC, 0x30AB, 0x30FC), 0x3309 => array(0x30AA, 0x30F3, 0x30B9), 0x330A => array(0x30AA, 0x30FC, 0x30E0), - 0x330B => array(0x30AB, 0x30A4, 0x30EA), 0x330C => array(0x30AB, 0x30E9, 0x30C3, 0x30C8), 0x330D => array(0x30AB, 0x30ED, 0x30EA, 0x30FC), - 0x330E => array(0x30AC, 0x30ED, 0x30F3), 0x330F => array(0x30AC, 0x30F3, 0x30DE), 0x3310 => array(0x30AE, 0x30AC), - 0x3311 => array(0x30AE, 0x30CB, 0x30FC), 0x3312 => array(0x30AD, 0x30E5, 0x30EA, 0x30FC), 0x3313 => array(0x30AE, 0x30EB, 0x30C0, 0x30FC), - 0x3314 => array(0x30AD, 0x30ED), 0x3315 => array(0x30AD, 0x30ED, 0x30B0, 0x30E9, 0x30E0), 0x3316 => array(0x30AD, 0x30ED, 0x30E1, 0x30FC, 0x30C8, 0x30EB), - 0x3317 => array(0x30AD, 0x30ED, 0x30EF, 0x30C3, 0x30C8), 0x3318 => array(0x30B0, 0x30E9, 0x30E0), 0x3319 => array(0x30B0, 0x30E9, 0x30E0, 0x30C8, 0x30F3), - 0x331A => array(0x30AF, 0x30EB, 0x30BC, 0x30A4, 0x30ED), 0x331B => array(0x30AF, 0x30ED, 0x30FC, 0x30CD), 0x331C => array(0x30B1, 0x30FC, 0x30B9), - 0x331D => array(0x30B3, 0x30EB, 0x30CA), 0x331E => array(0x30B3, 0x30FC, 0x30DD), 0x331F => array(0x30B5, 0x30A4, 0x30AF, 0x30EB), - 0x3320 => array(0x30B5, 0x30F3, 0x30C1, 0x30FC, 0x30E0), 0x3321 => array(0x30B7, 0x30EA, 0x30F3, 0x30B0), 0x3322 => array(0x30BB, 0x30F3, 0x30C1), - 0x3323 => array(0x30BB, 0x30F3, 0x30C8), 0x3324 => array(0x30C0, 0x30FC, 0x30B9), 0x3325 => array(0x30C7, 0x30B7), - 0x3326 => array(0x30C9, 0x30EB), 0x3327 => array(0x30C8, 0x30F3), 0x3328 => array(0x30CA, 0x30CE), - 0x3329 => array(0x30CE, 0x30C3, 0x30C8), 0x332A => array(0x30CF, 0x30A4, 0x30C4), 0x332B => array(0x30D1, 0x30FC, 0x30BB, 0x30F3, 0x30C8), - 0x332C => array(0x30D1, 0x30FC, 0x30C4), 0x332D => array(0x30D0, 0x30FC, 0x30EC, 0x30EB), 0x332E => array(0x30D4, 0x30A2, 0x30B9, 0x30C8, 0x30EB), - 0x332F => array(0x30D4, 0x30AF, 0x30EB), 0x3330 => array(0x30D4, 0x30B3), 0x3331 => array(0x30D3, 0x30EB), - 0x3332 => array(0x30D5, 0x30A1, 0x30E9, 0x30C3, 0x30C9), 0x3333 => array(0x30D5, 0x30A3, 0x30FC, 0x30C8), 0x3334 => array(0x30D6, 0x30C3, 0x30B7, 0x30A7, 0x30EB), - 0x3335 => array(0x30D5, 0x30E9, 0x30F3), 0x3336 => array(0x30D8, 0x30AF, 0x30BF, 0x30FC, 0x30EB), 0x3337 => array(0x30DA, 0x30BD), - 0x3338 => array(0x30DA, 0x30CB, 0x30D2), 0x3339 => array(0x30D8, 0x30EB, 0x30C4), 0x333A => array(0x30DA, 0x30F3, 0x30B9), - 0x333B => array(0x30DA, 0x30FC, 0x30B8), 0x333C => array(0x30D9, 0x30FC, 0x30BF), 0x333D => array(0x30DD, 0x30A4, 0x30F3, 0x30C8), - 0x333E => array(0x30DC, 0x30EB, 0x30C8), 0x333F => array(0x30DB, 0x30F3), 0x3340 => array(0x30DD, 0x30F3, 0x30C9), - 0x3341 => array(0x30DB, 0x30FC, 0x30EB), 0x3342 => array(0x30DB, 0x30FC, 0x30F3), 0x3343 => array(0x30DE, 0x30A4, 0x30AF, 0x30ED), - 0x3344 => array(0x30DE, 0x30A4, 0x30EB), 0x3345 => array(0x30DE, 0x30C3, 0x30CF), 0x3346 => array(0x30DE, 0x30EB, 0x30AF), - 0x3347 => array(0x30DE, 0x30F3, 0x30B7, 0x30E7, 0x30F3), 0x3348 => array(0x30DF, 0x30AF, 0x30ED, 0x30F3), 0x3349 => array(0x30DF, 0x30EA), - 0x334A => array(0x30DF, 0x30EA, 0x30D0, 0x30FC, 0x30EB), 0x334B => array(0x30E1, 0x30AC), 0x334C => array(0x30E1, 0x30AC, 0x30C8, 0x30F3), - 0x334D => array(0x30E1, 0x30FC, 0x30C8, 0x30EB), 0x334E => array(0x30E4, 0x30FC, 0x30C9), 0x334F => array(0x30E4, 0x30FC, 0x30EB), - 0x3350 => array(0x30E6, 0x30A2, 0x30F3), 0x3351 => array(0x30EA, 0x30C3, 0x30C8, 0x30EB), 0x3352 => array(0x30EA, 0x30E9), - 0x3353 => array(0x30EB, 0x30D4, 0x30FC), 0x3354 => array(0x30EB, 0x30FC, 0x30D6, 0x30EB), 0x3355 => array(0x30EC, 0x30E0), - 0x3356 => array(0x30EC, 0x30F3, 0x30C8, 0x30B2, 0x30F3), 0x3357 => array(0x30EF, 0x30C3, 0x30C8), 0x3358 => array(0x30, 0x70B9), - 0x3359 => array(0x31, 0x70B9), 0x335A => array(0x32, 0x70B9), 0x335B => array(0x33, 0x70B9), - 0x335C => array(0x34, 0x70B9), 0x335D => array(0x35, 0x70B9), 0x335E => array(0x36, 0x70B9), - 0x335F => array(0x37, 0x70B9), 0x3360 => array(0x38, 0x70B9), 0x3361 => array(0x39, 0x70B9), - 0x3362 => array(0x31, 0x30, 0x70B9), 0x3363 => array(0x31, 0x31, 0x70B9), 0x3364 => array(0x31, 0x32, 0x70B9), - 0x3365 => array(0x31, 0x33, 0x70B9), 0x3366 => array(0x31, 0x34, 0x70B9), 0x3367 => array(0x31, 0x35, 0x70B9), - 0x3368 => array(0x31, 0x36, 0x70B9), 0x3369 => array(0x31, 0x37, 0x70B9), 0x336A => array(0x31, 0x38, 0x70B9), - 0x336B => array(0x31, 0x39, 0x70B9), 0x336C => array(0x32, 0x30, 0x70B9), 0x336D => array(0x32, 0x31, 0x70B9), - 0x336E => array(0x32, 0x32, 0x70B9), 0x336F => array(0x32, 0x33, 0x70B9), 0x3370 => array(0x32, 0x34, 0x70B9), - 0x3371 => array(0x68, 0x70, 0x61), 0x3372 => array(0x64, 0x61), 0x3373 => array(0x61, 0x75), - 0x3374 => array(0x62, 0x61, 0x72), 0x3375 => array(0x6F, 0x76), 0x3376 => array(0x70, 0x63), - 0x3377 => array(0x64, 0x6D), 0x3378 => array(0x64, 0x6D, 0x32), 0x3379 => array(0x64, 0x6D, 0x33), - 0x337A => array(0x69, 0x75), 0x337B => array(0x5E73, 0x6210), 0x337C => array(0x662D, 0x548C), - 0x337D => array(0x5927, 0x6B63), 0x337E => array(0x660E, 0x6CBB), 0x337F => array(0x682A, 0x5F0F, 0x4F1A, 0x793E), - 0x3380 => array(0x70, 0x61), 0x3381 => array(0x6E, 0x61), 0x3382 => array(0x3BC, 0x61), - 0x3383 => array(0x6D, 0x61), 0x3384 => array(0x6B, 0x61), 0x3385 => array(0x6B, 0x62), - 0x3386 => array(0x6D, 0x62), 0x3387 => array(0x67, 0x62), 0x3388 => array(0x63, 0x61, 0x6C), - 0x3389 => array(0x6B, 0x63, 0x61, 0x6C), 0x338A => array(0x70, 0x66), 0x338B => array(0x6E, 0x66), - 0x338C => array(0x3BC, 0x66), 0x338D => array(0x3BC, 0x67), 0x338E => array(0x6D, 0x67), - 0x338F => array(0x6B, 0x67), 0x3390 => array(0x68, 0x7A), 0x3391 => array(0x6B, 0x68, 0x7A), - 0x3392 => array(0x6D, 0x68, 0x7A), 0x3393 => array(0x67, 0x68, 0x7A), 0x3394 => array(0x74, 0x68, 0x7A), - 0x3395 => array(0x3BC, 0x6C), 0x3396 => array(0x6D, 0x6C), 0x3397 => array(0x64, 0x6C), - 0x3398 => array(0x6B, 0x6C), 0x3399 => array(0x66, 0x6D), 0x339A => array(0x6E, 0x6D), - 0x339B => array(0x3BC, 0x6D), 0x339C => array(0x6D, 0x6D), 0x339D => array(0x63, 0x6D), - 0x339E => array(0x6B, 0x6D), 0x339F => array(0x6D, 0x6D, 0x32), 0x33A0 => array(0x63, 0x6D, 0x32), - 0x33A1 => array(0x6D, 0x32), 0x33A2 => array(0x6B, 0x6D, 0x32), 0x33A3 => array(0x6D, 0x6D, 0x33), - 0x33A4 => array(0x63, 0x6D, 0x33), 0x33A5 => array(0x6D, 0x33), 0x33A6 => array(0x6B, 0x6D, 0x33), - 0x33A7 => array(0x6D, 0x2215, 0x73), 0x33A8 => array(0x6D, 0x2215, 0x73, 0x32), 0x33A9 => array(0x70, 0x61), - 0x33AA => array(0x6B, 0x70, 0x61), 0x33AB => array(0x6D, 0x70, 0x61), 0x33AC => array(0x67, 0x70, 0x61), - 0x33AD => array(0x72, 0x61, 0x64), 0x33AE => array(0x72, 0x61, 0x64, 0x2215, 0x73), 0x33AF => array(0x72, 0x61, 0x64, 0x2215, 0x73, 0x32), - 0x33B0 => array(0x70, 0x73), 0x33B1 => array(0x6E, 0x73), 0x33B2 => array(0x3BC, 0x73), - 0x33B3 => array(0x6D, 0x73), 0x33B4 => array(0x70, 0x76), 0x33B5 => array(0x6E, 0x76), - 0x33B6 => array(0x3BC, 0x76), 0x33B7 => array(0x6D, 0x76), 0x33B8 => array(0x6B, 0x76), - 0x33B9 => array(0x6D, 0x76), 0x33BA => array(0x70, 0x77), 0x33BB => array(0x6E, 0x77), - 0x33BC => array(0x3BC, 0x77), 0x33BD => array(0x6D, 0x77), 0x33BE => array(0x6B, 0x77), - 0x33BF => array(0x6D, 0x77), 0x33C0 => array(0x6B, 0x3C9), 0x33C1 => array(0x6D, 0x3C9), - 0x33C3 => array(0x62, 0x71), 0x33C4 => array(0x63, 0x63), 0x33C5 => array(0x63, 0x64), - 0x33C6 => array(0x63, 0x2215, 0x6B, 0x67), 0x33C8 => array(0x64, 0x62), 0x33C9 => array(0x67, 0x79), - 0x33CA => array(0x68, 0x61), 0x33CB => array(0x68, 0x70), 0x33CC => array(0x69, 0x6E), - 0x33CD => array(0x6B, 0x6B), 0x33CE => array(0x6B, 0x6D), 0x33CF => array(0x6B, 0x74), - 0x33D0 => array(0x6C, 0x6D), 0x33D1 => array(0x6C, 0x6E), 0x33D2 => array(0x6C, 0x6F, 0x67), - 0x33D3 => array(0x6C, 0x78), 0x33D4 => array(0x6D, 0x62), 0x33D5 => array(0x6D, 0x69, 0x6C), - 0x33D6 => array(0x6D, 0x6F, 0x6C), 0x33D7 => array(0x70, 0x68), 0x33D9 => array(0x70, 0x70, 0x6D), - 0x33DA => array(0x70, 0x72), 0x33DB => array(0x73, 0x72), 0x33DC => array(0x73, 0x76), - 0x33DD => array(0x77, 0x62), 0x33DE => array(0x76, 0x2215, 0x6D), 0x33DF => array(0x61, 0x2215, 0x6D), - 0x33E0 => array(0x31, 0x65E5), 0x33E1 => array(0x32, 0x65E5), 0x33E2 => array(0x33, 0x65E5), - 0x33E3 => array(0x34, 0x65E5), 0x33E4 => array(0x35, 0x65E5), 0x33E5 => array(0x36, 0x65E5), - 0x33E6 => array(0x37, 0x65E5), 0x33E7 => array(0x38, 0x65E5), 0x33E8 => array(0x39, 0x65E5), - 0x33E9 => array(0x31, 0x30, 0x65E5), 0x33EA => array(0x31, 0x31, 0x65E5), 0x33EB => array(0x31, 0x32, 0x65E5), - 0x33EC => array(0x31, 0x33, 0x65E5), 0x33ED => array(0x31, 0x34, 0x65E5), 0x33EE => array(0x31, 0x35, 0x65E5), - 0x33EF => array(0x31, 0x36, 0x65E5), 0x33F0 => array(0x31, 0x37, 0x65E5), 0x33F1 => array(0x31, 0x38, 0x65E5), - 0x33F2 => array(0x31, 0x39, 0x65E5), 0x33F3 => array(0x32, 0x30, 0x65E5), 0x33F4 => array(0x32, 0x31, 0x65E5), - 0x33F5 => array(0x32, 0x32, 0x65E5), 0x33F6 => array(0x32, 0x33, 0x65E5), 0x33F7 => array(0x32, 0x34, 0x65E5), - 0x33F8 => array(0x32, 0x35, 0x65E5), 0x33F9 => array(0x32, 0x36, 0x65E5), 0x33FA => array(0x32, 0x37, 0x65E5), - 0x33FB => array(0x32, 0x38, 0x65E5), 0x33FC => array(0x32, 0x39, 0x65E5), 0x33FD => array(0x33, 0x30, 0x65E5), - 0x33FE => array(0x33, 0x31, 0x65E5), 0x33FF => array(0x67, 0x61, 0x6C), 0xA640 => array(0xA641), - 0xA642 => array(0xA643), 0xA644 => array(0xA645), 0xA646 => array(0xA647), - 0xA648 => array(0xA649), 0xA64A => array(0xA64B), 0xA64C => array(0xA64D), - 0xA64E => array(0xA64F), 0xA650 => array(0xA651), 0xA652 => array(0xA653), - 0xA654 => array(0xA655), 0xA656 => array(0xA657), 0xA658 => array(0xA659), - 0xA65A => array(0xA65B), 0xA65C => array(0xA65D), 0xA65E => array(0xA65F), - 0xA660 => array(0xA661), 0xA662 => array(0xA663), 0xA664 => array(0xA665), - 0xA666 => array(0xA667), 0xA668 => array(0xA669), 0xA66A => array(0xA66B), - 0xA66C => array(0xA66D), 0xA680 => array(0xA681), 0xA682 => array(0xA683), - 0xA684 => array(0xA685), 0xA686 => array(0xA687), 0xA688 => array(0xA689), - 0xA68A => array(0xA68B), 0xA68C => array(0xA68D), 0xA68E => array(0xA68F), - 0xA690 => array(0xA691), 0xA692 => array(0xA693), 0xA694 => array(0xA695), - 0xA696 => array(0xA697), 0xA698 => array(0xA699), 0xA69A => array(0xA69B), - 0xA69C => array(0x44A), 0xA69D => array(0x44C), 0xA722 => array(0xA723), - 0xA724 => array(0xA725), 0xA726 => array(0xA727), 0xA728 => array(0xA729), - 0xA72A => array(0xA72B), 0xA72C => array(0xA72D), 0xA72E => array(0xA72F), - 0xA732 => array(0xA733), 0xA734 => array(0xA735), 0xA736 => array(0xA737), - 0xA738 => array(0xA739), 0xA73A => array(0xA73B), 0xA73C => array(0xA73D), - 0xA73E => array(0xA73F), 0xA740 => array(0xA741), 0xA742 => array(0xA743), - 0xA744 => array(0xA745), 0xA746 => array(0xA747), 0xA748 => array(0xA749), - 0xA74A => array(0xA74B), 0xA74C => array(0xA74D), 0xA74E => array(0xA74F), - 0xA750 => array(0xA751), 0xA752 => array(0xA753), 0xA754 => array(0xA755), - 0xA756 => array(0xA757), 0xA758 => array(0xA759), 0xA75A => array(0xA75B), - 0xA75C => array(0xA75D), 0xA75E => array(0xA75F), 0xA760 => array(0xA761), - 0xA762 => array(0xA763), 0xA764 => array(0xA765), 0xA766 => array(0xA767), - 0xA768 => array(0xA769), 0xA76A => array(0xA76B), 0xA76C => array(0xA76D), - 0xA76E => array(0xA76F), 0xA770 => array(0xA76F), 0xA779 => array(0xA77A), - 0xA77B => array(0xA77C), 0xA77D => array(0x1D79), 0xA77E => array(0xA77F), - 0xA780 => array(0xA781), 0xA782 => array(0xA783), 0xA784 => array(0xA785), - 0xA786 => array(0xA787), 0xA78B => array(0xA78C), 0xA78D => array(0x265), - 0xA790 => array(0xA791), 0xA792 => array(0xA793), 0xA796 => array(0xA797), - 0xA798 => array(0xA799), 0xA79A => array(0xA79B), 0xA79C => array(0xA79D), - 0xA79E => array(0xA79F), 0xA7A0 => array(0xA7A1), 0xA7A2 => array(0xA7A3), - 0xA7A4 => array(0xA7A5), 0xA7A6 => array(0xA7A7), 0xA7A8 => array(0xA7A9), - 0xA7AA => array(0x266), 0xA7AB => array(0x25C), 0xA7AC => array(0x261), - 0xA7AD => array(0x26C), 0xA7B0 => array(0x29E), 0xA7B1 => array(0x287), - 0xA7F8 => array(0x127), 0xA7F9 => array(0x153), 0xAB5C => array(0xA727), - 0xAB5D => array(0xAB37), 0xAB5E => array(0x26B), 0xAB5F => array(0xAB52), - 0xF900 => array(0x8C48), 0xF901 => array(0x66F4), 0xF902 => array(0x8ECA), - 0xF903 => array(0x8CC8), 0xF904 => array(0x6ED1), 0xF905 => array(0x4E32), - 0xF906 => array(0x53E5), 0xF907 => array(0x9F9C), 0xF908 => array(0x9F9C), - 0xF909 => array(0x5951), 0xF90A => array(0x91D1), 0xF90B => array(0x5587), - 0xF90C => array(0x5948), 0xF90D => array(0x61F6), 0xF90E => array(0x7669), - 0xF90F => array(0x7F85), 0xF910 => array(0x863F), 0xF911 => array(0x87BA), - 0xF912 => array(0x88F8), 0xF913 => array(0x908F), 0xF914 => array(0x6A02), - 0xF915 => array(0x6D1B), 0xF916 => array(0x70D9), 0xF917 => array(0x73DE), - 0xF918 => array(0x843D), 0xF919 => array(0x916A), 0xF91A => array(0x99F1), - 0xF91B => array(0x4E82), 0xF91C => array(0x5375), 0xF91D => array(0x6B04), - 0xF91E => array(0x721B), 0xF91F => array(0x862D), 0xF920 => array(0x9E1E), - 0xF921 => array(0x5D50), 0xF922 => array(0x6FEB), 0xF923 => array(0x85CD), - 0xF924 => array(0x8964), 0xF925 => array(0x62C9), 0xF926 => array(0x81D8), - 0xF927 => array(0x881F), 0xF928 => array(0x5ECA), 0xF929 => array(0x6717), - 0xF92A => array(0x6D6A), 0xF92B => array(0x72FC), 0xF92C => array(0x90CE), - 0xF92D => array(0x4F86), 0xF92E => array(0x51B7), 0xF92F => array(0x52DE), - 0xF930 => array(0x64C4), 0xF931 => array(0x6AD3), 0xF932 => array(0x7210), - 0xF933 => array(0x76E7), 0xF934 => array(0x8001), 0xF935 => array(0x8606), - 0xF936 => array(0x865C), 0xF937 => array(0x8DEF), 0xF938 => array(0x9732), - 0xF939 => array(0x9B6F), 0xF93A => array(0x9DFA), 0xF93B => array(0x788C), - 0xF93C => array(0x797F), 0xF93D => array(0x7DA0), 0xF93E => array(0x83C9), - 0xF93F => array(0x9304), 0xF940 => array(0x9E7F), 0xF941 => array(0x8AD6), - 0xF942 => array(0x58DF), 0xF943 => array(0x5F04), 0xF944 => array(0x7C60), - 0xF945 => array(0x807E), 0xF946 => array(0x7262), 0xF947 => array(0x78CA), - 0xF948 => array(0x8CC2), 0xF949 => array(0x96F7), 0xF94A => array(0x58D8), - 0xF94B => array(0x5C62), 0xF94C => array(0x6A13), 0xF94D => array(0x6DDA), - 0xF94E => array(0x6F0F), 0xF94F => array(0x7D2F), 0xF950 => array(0x7E37), - 0xF951 => array(0x964B), 0xF952 => array(0x52D2), 0xF953 => array(0x808B), - 0xF954 => array(0x51DC), 0xF955 => array(0x51CC), 0xF956 => array(0x7A1C), - 0xF957 => array(0x7DBE), 0xF958 => array(0x83F1), 0xF959 => array(0x9675), - 0xF95A => array(0x8B80), 0xF95B => array(0x62CF), 0xF95C => array(0x6A02), - 0xF95D => array(0x8AFE), 0xF95E => array(0x4E39), 0xF95F => array(0x5BE7), - 0xF960 => array(0x6012), 0xF961 => array(0x7387), 0xF962 => array(0x7570), - 0xF963 => array(0x5317), 0xF964 => array(0x78FB), 0xF965 => array(0x4FBF), - 0xF966 => array(0x5FA9), 0xF967 => array(0x4E0D), 0xF968 => array(0x6CCC), - 0xF969 => array(0x6578), 0xF96A => array(0x7D22), 0xF96B => array(0x53C3), - 0xF96C => array(0x585E), 0xF96D => array(0x7701), 0xF96E => array(0x8449), - 0xF96F => array(0x8AAA), 0xF970 => array(0x6BBA), 0xF971 => array(0x8FB0), - 0xF972 => array(0x6C88), 0xF973 => array(0x62FE), 0xF974 => array(0x82E5), - 0xF975 => array(0x63A0), 0xF976 => array(0x7565), 0xF977 => array(0x4EAE), - 0xF978 => array(0x5169), 0xF979 => array(0x51C9), 0xF97A => array(0x6881), - 0xF97B => array(0x7CE7), 0xF97C => array(0x826F), 0xF97D => array(0x8AD2), - 0xF97E => array(0x91CF), 0xF97F => array(0x52F5), 0xF980 => array(0x5442), - 0xF981 => array(0x5973), 0xF982 => array(0x5EEC), 0xF983 => array(0x65C5), - 0xF984 => array(0x6FFE), 0xF985 => array(0x792A), 0xF986 => array(0x95AD), - 0xF987 => array(0x9A6A), 0xF988 => array(0x9E97), 0xF989 => array(0x9ECE), - 0xF98A => array(0x529B), 0xF98B => array(0x66C6), 0xF98C => array(0x6B77), - 0xF98D => array(0x8F62), 0xF98E => array(0x5E74), 0xF98F => array(0x6190), - 0xF990 => array(0x6200), 0xF991 => array(0x649A), 0xF992 => array(0x6F23), - 0xF993 => array(0x7149), 0xF994 => array(0x7489), 0xF995 => array(0x79CA), - 0xF996 => array(0x7DF4), 0xF997 => array(0x806F), 0xF998 => array(0x8F26), - 0xF999 => array(0x84EE), 0xF99A => array(0x9023), 0xF99B => array(0x934A), - 0xF99C => array(0x5217), 0xF99D => array(0x52A3), 0xF99E => array(0x54BD), - 0xF99F => array(0x70C8), 0xF9A0 => array(0x88C2), 0xF9A1 => array(0x8AAA), - 0xF9A2 => array(0x5EC9), 0xF9A3 => array(0x5FF5), 0xF9A4 => array(0x637B), - 0xF9A5 => array(0x6BAE), 0xF9A6 => array(0x7C3E), 0xF9A7 => array(0x7375), - 0xF9A8 => array(0x4EE4), 0xF9A9 => array(0x56F9), 0xF9AA => array(0x5BE7), - 0xF9AB => array(0x5DBA), 0xF9AC => array(0x601C), 0xF9AD => array(0x73B2), - 0xF9AE => array(0x7469), 0xF9AF => array(0x7F9A), 0xF9B0 => array(0x8046), - 0xF9B1 => array(0x9234), 0xF9B2 => array(0x96F6), 0xF9B3 => array(0x9748), - 0xF9B4 => array(0x9818), 0xF9B5 => array(0x4F8B), 0xF9B6 => array(0x79AE), - 0xF9B7 => array(0x91B4), 0xF9B8 => array(0x96B8), 0xF9B9 => array(0x60E1), - 0xF9BA => array(0x4E86), 0xF9BB => array(0x50DA), 0xF9BC => array(0x5BEE), - 0xF9BD => array(0x5C3F), 0xF9BE => array(0x6599), 0xF9BF => array(0x6A02), - 0xF9C0 => array(0x71CE), 0xF9C1 => array(0x7642), 0xF9C2 => array(0x84FC), - 0xF9C3 => array(0x907C), 0xF9C4 => array(0x9F8D), 0xF9C5 => array(0x6688), - 0xF9C6 => array(0x962E), 0xF9C7 => array(0x5289), 0xF9C8 => array(0x677B), - 0xF9C9 => array(0x67F3), 0xF9CA => array(0x6D41), 0xF9CB => array(0x6E9C), - 0xF9CC => array(0x7409), 0xF9CD => array(0x7559), 0xF9CE => array(0x786B), - 0xF9CF => array(0x7D10), 0xF9D0 => array(0x985E), 0xF9D1 => array(0x516D), - 0xF9D2 => array(0x622E), 0xF9D3 => array(0x9678), 0xF9D4 => array(0x502B), - 0xF9D5 => array(0x5D19), 0xF9D6 => array(0x6DEA), 0xF9D7 => array(0x8F2A), - 0xF9D8 => array(0x5F8B), 0xF9D9 => array(0x6144), 0xF9DA => array(0x6817), - 0xF9DB => array(0x7387), 0xF9DC => array(0x9686), 0xF9DD => array(0x5229), - 0xF9DE => array(0x540F), 0xF9DF => array(0x5C65), 0xF9E0 => array(0x6613), - 0xF9E1 => array(0x674E), 0xF9E2 => array(0x68A8), 0xF9E3 => array(0x6CE5), - 0xF9E4 => array(0x7406), 0xF9E5 => array(0x75E2), 0xF9E6 => array(0x7F79), - 0xF9E7 => array(0x88CF), 0xF9E8 => array(0x88E1), 0xF9E9 => array(0x91CC), - 0xF9EA => array(0x96E2), 0xF9EB => array(0x533F), 0xF9EC => array(0x6EBA), - 0xF9ED => array(0x541D), 0xF9EE => array(0x71D0), 0xF9EF => array(0x7498), - 0xF9F0 => array(0x85FA), 0xF9F1 => array(0x96A3), 0xF9F2 => array(0x9C57), - 0xF9F3 => array(0x9E9F), 0xF9F4 => array(0x6797), 0xF9F5 => array(0x6DCB), - 0xF9F6 => array(0x81E8), 0xF9F7 => array(0x7ACB), 0xF9F8 => array(0x7B20), - 0xF9F9 => array(0x7C92), 0xF9FA => array(0x72C0), 0xF9FB => array(0x7099), - 0xF9FC => array(0x8B58), 0xF9FD => array(0x4EC0), 0xF9FE => array(0x8336), - 0xF9FF => array(0x523A), 0xFA00 => array(0x5207), 0xFA01 => array(0x5EA6), - 0xFA02 => array(0x62D3), 0xFA03 => array(0x7CD6), 0xFA04 => array(0x5B85), - 0xFA05 => array(0x6D1E), 0xFA06 => array(0x66B4), 0xFA07 => array(0x8F3B), - 0xFA08 => array(0x884C), 0xFA09 => array(0x964D), 0xFA0A => array(0x898B), - 0xFA0B => array(0x5ED3), 0xFA0C => array(0x5140), 0xFA0D => array(0x55C0), - 0xFA10 => array(0x585A), 0xFA12 => array(0x6674), 0xFA15 => array(0x51DE), - 0xFA16 => array(0x732A), 0xFA17 => array(0x76CA), 0xFA18 => array(0x793C), - 0xFA19 => array(0x795E), 0xFA1A => array(0x7965), 0xFA1B => array(0x798F), - 0xFA1C => array(0x9756), 0xFA1D => array(0x7CBE), 0xFA1E => array(0x7FBD), - 0xFA20 => array(0x8612), 0xFA22 => array(0x8AF8), 0xFA25 => array(0x9038), - 0xFA26 => array(0x90FD), 0xFA2A => array(0x98EF), 0xFA2B => array(0x98FC), - 0xFA2C => array(0x9928), 0xFA2D => array(0x9DB4), 0xFA2E => array(0x90DE), - 0xFA2F => array(0x96B7), 0xFA30 => array(0x4FAE), 0xFA31 => array(0x50E7), - 0xFA32 => array(0x514D), 0xFA33 => array(0x52C9), 0xFA34 => array(0x52E4), - 0xFA35 => array(0x5351), 0xFA36 => array(0x559D), 0xFA37 => array(0x5606), - 0xFA38 => array(0x5668), 0xFA39 => array(0x5840), 0xFA3A => array(0x58A8), - 0xFA3B => array(0x5C64), 0xFA3C => array(0x5C6E), 0xFA3D => array(0x6094), - 0xFA3E => array(0x6168), 0xFA3F => array(0x618E), 0xFA40 => array(0x61F2), - 0xFA41 => array(0x654F), 0xFA42 => array(0x65E2), 0xFA43 => array(0x6691), - 0xFA44 => array(0x6885), 0xFA45 => array(0x6D77), 0xFA46 => array(0x6E1A), - 0xFA47 => array(0x6F22), 0xFA48 => array(0x716E), 0xFA49 => array(0x722B), - 0xFA4A => array(0x7422), 0xFA4B => array(0x7891), 0xFA4C => array(0x793E), - 0xFA4D => array(0x7949), 0xFA4E => array(0x7948), 0xFA4F => array(0x7950), - 0xFA50 => array(0x7956), 0xFA51 => array(0x795D), 0xFA52 => array(0x798D), - 0xFA53 => array(0x798E), 0xFA54 => array(0x7A40), 0xFA55 => array(0x7A81), - 0xFA56 => array(0x7BC0), 0xFA57 => array(0x7DF4), 0xFA58 => array(0x7E09), - 0xFA59 => array(0x7E41), 0xFA5A => array(0x7F72), 0xFA5B => array(0x8005), - 0xFA5C => array(0x81ED), 0xFA5D => array(0x8279), 0xFA5E => array(0x8279), - 0xFA5F => array(0x8457), 0xFA60 => array(0x8910), 0xFA61 => array(0x8996), - 0xFA62 => array(0x8B01), 0xFA63 => array(0x8B39), 0xFA64 => array(0x8CD3), - 0xFA65 => array(0x8D08), 0xFA66 => array(0x8FB6), 0xFA67 => array(0x9038), - 0xFA68 => array(0x96E3), 0xFA69 => array(0x97FF), 0xFA6A => array(0x983B), - 0xFA6B => array(0x6075), 0xFA6C => array(0x242EE), 0xFA6D => array(0x8218), - 0xFA70 => array(0x4E26), 0xFA71 => array(0x51B5), 0xFA72 => array(0x5168), - 0xFA73 => array(0x4F80), 0xFA74 => array(0x5145), 0xFA75 => array(0x5180), - 0xFA76 => array(0x52C7), 0xFA77 => array(0x52FA), 0xFA78 => array(0x559D), - 0xFA79 => array(0x5555), 0xFA7A => array(0x5599), 0xFA7B => array(0x55E2), - 0xFA7C => array(0x585A), 0xFA7D => array(0x58B3), 0xFA7E => array(0x5944), - 0xFA7F => array(0x5954), 0xFA80 => array(0x5A62), 0xFA81 => array(0x5B28), - 0xFA82 => array(0x5ED2), 0xFA83 => array(0x5ED9), 0xFA84 => array(0x5F69), - 0xFA85 => array(0x5FAD), 0xFA86 => array(0x60D8), 0xFA87 => array(0x614E), - 0xFA88 => array(0x6108), 0xFA89 => array(0x618E), 0xFA8A => array(0x6160), - 0xFA8B => array(0x61F2), 0xFA8C => array(0x6234), 0xFA8D => array(0x63C4), - 0xFA8E => array(0x641C), 0xFA8F => array(0x6452), 0xFA90 => array(0x6556), - 0xFA91 => array(0x6674), 0xFA92 => array(0x6717), 0xFA93 => array(0x671B), - 0xFA94 => array(0x6756), 0xFA95 => array(0x6B79), 0xFA96 => array(0x6BBA), - 0xFA97 => array(0x6D41), 0xFA98 => array(0x6EDB), 0xFA99 => array(0x6ECB), - 0xFA9A => array(0x6F22), 0xFA9B => array(0x701E), 0xFA9C => array(0x716E), - 0xFA9D => array(0x77A7), 0xFA9E => array(0x7235), 0xFA9F => array(0x72AF), - 0xFAA0 => array(0x732A), 0xFAA1 => array(0x7471), 0xFAA2 => array(0x7506), - 0xFAA3 => array(0x753B), 0xFAA4 => array(0x761D), 0xFAA5 => array(0x761F), - 0xFAA6 => array(0x76CA), 0xFAA7 => array(0x76DB), 0xFAA8 => array(0x76F4), - 0xFAA9 => array(0x774A), 0xFAAA => array(0x7740), 0xFAAB => array(0x78CC), - 0xFAAC => array(0x7AB1), 0xFAAD => array(0x7BC0), 0xFAAE => array(0x7C7B), - 0xFAAF => array(0x7D5B), 0xFAB0 => array(0x7DF4), 0xFAB1 => array(0x7F3E), - 0xFAB2 => array(0x8005), 0xFAB3 => array(0x8352), 0xFAB4 => array(0x83EF), - 0xFAB5 => array(0x8779), 0xFAB6 => array(0x8941), 0xFAB7 => array(0x8986), - 0xFAB8 => array(0x8996), 0xFAB9 => array(0x8ABF), 0xFABA => array(0x8AF8), - 0xFABB => array(0x8ACB), 0xFABC => array(0x8B01), 0xFABD => array(0x8AFE), - 0xFABE => array(0x8AED), 0xFABF => array(0x8B39), 0xFAC0 => array(0x8B8A), - 0xFAC1 => array(0x8D08), 0xFAC2 => array(0x8F38), 0xFAC3 => array(0x9072), - 0xFAC4 => array(0x9199), 0xFAC5 => array(0x9276), 0xFAC6 => array(0x967C), - 0xFAC7 => array(0x96E3), 0xFAC8 => array(0x9756), 0xFAC9 => array(0x97DB), - 0xFACA => array(0x97FF), 0xFACB => array(0x980B), 0xFACC => array(0x983B), - 0xFACD => array(0x9B12), 0xFACE => array(0x9F9C), 0xFACF => array(0x2284A), - 0xFAD0 => array(0x22844), 0xFAD1 => array(0x233D5), 0xFAD2 => array(0x3B9D), - 0xFAD3 => array(0x4018), 0xFAD4 => array(0x4039), 0xFAD5 => array(0x25249), - 0xFAD6 => array(0x25CD0), 0xFAD7 => array(0x27ED3), 0xFAD8 => array(0x9F43), - 0xFAD9 => array(0x9F8E), 0xFB00 => array(0x66, 0x66), 0xFB01 => array(0x66, 0x69), - 0xFB02 => array(0x66, 0x6C), 0xFB03 => array(0x66, 0x66, 0x69), 0xFB04 => array(0x66, 0x66, 0x6C), - 0xFB05 => array(0x73, 0x74), 0xFB06 => array(0x73, 0x74), 0xFB13 => array(0x574, 0x576), - 0xFB14 => array(0x574, 0x565), 0xFB15 => array(0x574, 0x56B), 0xFB16 => array(0x57E, 0x576), - 0xFB17 => array(0x574, 0x56D), 0xFB1D => array(0x5D9, 0x5B4), 0xFB1F => array(0x5F2, 0x5B7), - 0xFB20 => array(0x5E2), 0xFB21 => array(0x5D0), 0xFB22 => array(0x5D3), - 0xFB23 => array(0x5D4), 0xFB24 => array(0x5DB), 0xFB25 => array(0x5DC), - 0xFB26 => array(0x5DD), 0xFB27 => array(0x5E8), 0xFB28 => array(0x5EA), - 0xFB2A => array(0x5E9, 0x5C1), 0xFB2B => array(0x5E9, 0x5C2), 0xFB2C => array(0x5E9, 0x5BC, 0x5C1), - 0xFB2D => array(0x5E9, 0x5BC, 0x5C2), 0xFB2E => array(0x5D0, 0x5B7), 0xFB2F => array(0x5D0, 0x5B8), - 0xFB30 => array(0x5D0, 0x5BC), 0xFB31 => array(0x5D1, 0x5BC), 0xFB32 => array(0x5D2, 0x5BC), - 0xFB33 => array(0x5D3, 0x5BC), 0xFB34 => array(0x5D4, 0x5BC), 0xFB35 => array(0x5D5, 0x5BC), - 0xFB36 => array(0x5D6, 0x5BC), 0xFB38 => array(0x5D8, 0x5BC), 0xFB39 => array(0x5D9, 0x5BC), - 0xFB3A => array(0x5DA, 0x5BC), 0xFB3B => array(0x5DB, 0x5BC), 0xFB3C => array(0x5DC, 0x5BC), - 0xFB3E => array(0x5DE, 0x5BC), 0xFB40 => array(0x5E0, 0x5BC), 0xFB41 => array(0x5E1, 0x5BC), - 0xFB43 => array(0x5E3, 0x5BC), 0xFB44 => array(0x5E4, 0x5BC), 0xFB46 => array(0x5E6, 0x5BC), - 0xFB47 => array(0x5E7, 0x5BC), 0xFB48 => array(0x5E8, 0x5BC), 0xFB49 => array(0x5E9, 0x5BC), - 0xFB4A => array(0x5EA, 0x5BC), 0xFB4B => array(0x5D5, 0x5B9), 0xFB4C => array(0x5D1, 0x5BF), - 0xFB4D => array(0x5DB, 0x5BF), 0xFB4E => array(0x5E4, 0x5BF), 0xFB4F => array(0x5D0, 0x5DC), - 0xFB50 => array(0x671), 0xFB51 => array(0x671), 0xFB52 => array(0x67B), - 0xFB53 => array(0x67B), 0xFB54 => array(0x67B), 0xFB55 => array(0x67B), - 0xFB56 => array(0x67E), 0xFB57 => array(0x67E), 0xFB58 => array(0x67E), - 0xFB59 => array(0x67E), 0xFB5A => array(0x680), 0xFB5B => array(0x680), - 0xFB5C => array(0x680), 0xFB5D => array(0x680), 0xFB5E => array(0x67A), - 0xFB5F => array(0x67A), 0xFB60 => array(0x67A), 0xFB61 => array(0x67A), - 0xFB62 => array(0x67F), 0xFB63 => array(0x67F), 0xFB64 => array(0x67F), - 0xFB65 => array(0x67F), 0xFB66 => array(0x679), 0xFB67 => array(0x679), - 0xFB68 => array(0x679), 0xFB69 => array(0x679), 0xFB6A => array(0x6A4), - 0xFB6B => array(0x6A4), 0xFB6C => array(0x6A4), 0xFB6D => array(0x6A4), - 0xFB6E => array(0x6A6), 0xFB6F => array(0x6A6), 0xFB70 => array(0x6A6), - 0xFB71 => array(0x6A6), 0xFB72 => array(0x684), 0xFB73 => array(0x684), - 0xFB74 => array(0x684), 0xFB75 => array(0x684), 0xFB76 => array(0x683), - 0xFB77 => array(0x683), 0xFB78 => array(0x683), 0xFB79 => array(0x683), - 0xFB7A => array(0x686), 0xFB7B => array(0x686), 0xFB7C => array(0x686), - 0xFB7D => array(0x686), 0xFB7E => array(0x687), 0xFB7F => array(0x687), - 0xFB80 => array(0x687), 0xFB81 => array(0x687), 0xFB82 => array(0x68D), - 0xFB83 => array(0x68D), 0xFB84 => array(0x68C), 0xFB85 => array(0x68C), - 0xFB86 => array(0x68E), 0xFB87 => array(0x68E), 0xFB88 => array(0x688), - 0xFB89 => array(0x688), 0xFB8A => array(0x698), 0xFB8B => array(0x698), - 0xFB8C => array(0x691), 0xFB8D => array(0x691), 0xFB8E => array(0x6A9), - 0xFB8F => array(0x6A9), 0xFB90 => array(0x6A9), 0xFB91 => array(0x6A9), - 0xFB92 => array(0x6AF), 0xFB93 => array(0x6AF), 0xFB94 => array(0x6AF), - 0xFB95 => array(0x6AF), 0xFB96 => array(0x6B3), 0xFB97 => array(0x6B3), - 0xFB98 => array(0x6B3), 0xFB99 => array(0x6B3), 0xFB9A => array(0x6B1), - 0xFB9B => array(0x6B1), 0xFB9C => array(0x6B1), 0xFB9D => array(0x6B1), - 0xFB9E => array(0x6BA), 0xFB9F => array(0x6BA), 0xFBA0 => array(0x6BB), - 0xFBA1 => array(0x6BB), 0xFBA2 => array(0x6BB), 0xFBA3 => array(0x6BB), - 0xFBA4 => array(0x6C0), 0xFBA5 => array(0x6C0), 0xFBA6 => array(0x6C1), - 0xFBA7 => array(0x6C1), 0xFBA8 => array(0x6C1), 0xFBA9 => array(0x6C1), - 0xFBAA => array(0x6BE), 0xFBAB => array(0x6BE), 0xFBAC => array(0x6BE), - 0xFBAD => array(0x6BE), 0xFBAE => array(0x6D2), 0xFBAF => array(0x6D2), - 0xFBB0 => array(0x6D3), 0xFBB1 => array(0x6D3), 0xFBD3 => array(0x6AD), - 0xFBD4 => array(0x6AD), 0xFBD5 => array(0x6AD), 0xFBD6 => array(0x6AD), - 0xFBD7 => array(0x6C7), 0xFBD8 => array(0x6C7), 0xFBD9 => array(0x6C6), - 0xFBDA => array(0x6C6), 0xFBDB => array(0x6C8), 0xFBDC => array(0x6C8), - 0xFBDD => array(0x6C7, 0x674), 0xFBDE => array(0x6CB), 0xFBDF => array(0x6CB), - 0xFBE0 => array(0x6C5), 0xFBE1 => array(0x6C5), 0xFBE2 => array(0x6C9), - 0xFBE3 => array(0x6C9), 0xFBE4 => array(0x6D0), 0xFBE5 => array(0x6D0), - 0xFBE6 => array(0x6D0), 0xFBE7 => array(0x6D0), 0xFBE8 => array(0x649), - 0xFBE9 => array(0x649), 0xFBEA => array(0x626, 0x627), 0xFBEB => array(0x626, 0x627), - 0xFBEC => array(0x626, 0x6D5), 0xFBED => array(0x626, 0x6D5), 0xFBEE => array(0x626, 0x648), - 0xFBEF => array(0x626, 0x648), 0xFBF0 => array(0x626, 0x6C7), 0xFBF1 => array(0x626, 0x6C7), - 0xFBF2 => array(0x626, 0x6C6), 0xFBF3 => array(0x626, 0x6C6), 0xFBF4 => array(0x626, 0x6C8), - 0xFBF5 => array(0x626, 0x6C8), 0xFBF6 => array(0x626, 0x6D0), 0xFBF7 => array(0x626, 0x6D0), - 0xFBF8 => array(0x626, 0x6D0), 0xFBF9 => array(0x626, 0x649), 0xFBFA => array(0x626, 0x649), - 0xFBFB => array(0x626, 0x649), 0xFBFC => array(0x6CC), 0xFBFD => array(0x6CC), - 0xFBFE => array(0x6CC), 0xFBFF => array(0x6CC), 0xFC00 => array(0x626, 0x62C), - 0xFC01 => array(0x626, 0x62D), 0xFC02 => array(0x626, 0x645), 0xFC03 => array(0x626, 0x649), - 0xFC04 => array(0x626, 0x64A), 0xFC05 => array(0x628, 0x62C), 0xFC06 => array(0x628, 0x62D), - 0xFC07 => array(0x628, 0x62E), 0xFC08 => array(0x628, 0x645), 0xFC09 => array(0x628, 0x649), - 0xFC0A => array(0x628, 0x64A), 0xFC0B => array(0x62A, 0x62C), 0xFC0C => array(0x62A, 0x62D), - 0xFC0D => array(0x62A, 0x62E), 0xFC0E => array(0x62A, 0x645), 0xFC0F => array(0x62A, 0x649), - 0xFC10 => array(0x62A, 0x64A), 0xFC11 => array(0x62B, 0x62C), 0xFC12 => array(0x62B, 0x645), - 0xFC13 => array(0x62B, 0x649), 0xFC14 => array(0x62B, 0x64A), 0xFC15 => array(0x62C, 0x62D), - 0xFC16 => array(0x62C, 0x645), 0xFC17 => array(0x62D, 0x62C), 0xFC18 => array(0x62D, 0x645), - 0xFC19 => array(0x62E, 0x62C), 0xFC1A => array(0x62E, 0x62D), 0xFC1B => array(0x62E, 0x645), - 0xFC1C => array(0x633, 0x62C), 0xFC1D => array(0x633, 0x62D), 0xFC1E => array(0x633, 0x62E), - 0xFC1F => array(0x633, 0x645), 0xFC20 => array(0x635, 0x62D), 0xFC21 => array(0x635, 0x645), - 0xFC22 => array(0x636, 0x62C), 0xFC23 => array(0x636, 0x62D), 0xFC24 => array(0x636, 0x62E), - 0xFC25 => array(0x636, 0x645), 0xFC26 => array(0x637, 0x62D), 0xFC27 => array(0x637, 0x645), - 0xFC28 => array(0x638, 0x645), 0xFC29 => array(0x639, 0x62C), 0xFC2A => array(0x639, 0x645), - 0xFC2B => array(0x63A, 0x62C), 0xFC2C => array(0x63A, 0x645), 0xFC2D => array(0x641, 0x62C), - 0xFC2E => array(0x641, 0x62D), 0xFC2F => array(0x641, 0x62E), 0xFC30 => array(0x641, 0x645), - 0xFC31 => array(0x641, 0x649), 0xFC32 => array(0x641, 0x64A), 0xFC33 => array(0x642, 0x62D), - 0xFC34 => array(0x642, 0x645), 0xFC35 => array(0x642, 0x649), 0xFC36 => array(0x642, 0x64A), - 0xFC37 => array(0x643, 0x627), 0xFC38 => array(0x643, 0x62C), 0xFC39 => array(0x643, 0x62D), - 0xFC3A => array(0x643, 0x62E), 0xFC3B => array(0x643, 0x644), 0xFC3C => array(0x643, 0x645), - 0xFC3D => array(0x643, 0x649), 0xFC3E => array(0x643, 0x64A), 0xFC3F => array(0x644, 0x62C), - 0xFC40 => array(0x644, 0x62D), 0xFC41 => array(0x644, 0x62E), 0xFC42 => array(0x644, 0x645), - 0xFC43 => array(0x644, 0x649), 0xFC44 => array(0x644, 0x64A), 0xFC45 => array(0x645, 0x62C), - 0xFC46 => array(0x645, 0x62D), 0xFC47 => array(0x645, 0x62E), 0xFC48 => array(0x645, 0x645), - 0xFC49 => array(0x645, 0x649), 0xFC4A => array(0x645, 0x64A), 0xFC4B => array(0x646, 0x62C), - 0xFC4C => array(0x646, 0x62D), 0xFC4D => array(0x646, 0x62E), 0xFC4E => array(0x646, 0x645), - 0xFC4F => array(0x646, 0x649), 0xFC50 => array(0x646, 0x64A), 0xFC51 => array(0x647, 0x62C), - 0xFC52 => array(0x647, 0x645), 0xFC53 => array(0x647, 0x649), 0xFC54 => array(0x647, 0x64A), - 0xFC55 => array(0x64A, 0x62C), 0xFC56 => array(0x64A, 0x62D), 0xFC57 => array(0x64A, 0x62E), - 0xFC58 => array(0x64A, 0x645), 0xFC59 => array(0x64A, 0x649), 0xFC5A => array(0x64A, 0x64A), - 0xFC5B => array(0x630, 0x670), 0xFC5C => array(0x631, 0x670), 0xFC5D => array(0x649, 0x670), - 0xFC64 => array(0x626, 0x631), 0xFC65 => array(0x626, 0x632), 0xFC66 => array(0x626, 0x645), - 0xFC67 => array(0x626, 0x646), 0xFC68 => array(0x626, 0x649), 0xFC69 => array(0x626, 0x64A), - 0xFC6A => array(0x628, 0x631), 0xFC6B => array(0x628, 0x632), 0xFC6C => array(0x628, 0x645), - 0xFC6D => array(0x628, 0x646), 0xFC6E => array(0x628, 0x649), 0xFC6F => array(0x628, 0x64A), - 0xFC70 => array(0x62A, 0x631), 0xFC71 => array(0x62A, 0x632), 0xFC72 => array(0x62A, 0x645), - 0xFC73 => array(0x62A, 0x646), 0xFC74 => array(0x62A, 0x649), 0xFC75 => array(0x62A, 0x64A), - 0xFC76 => array(0x62B, 0x631), 0xFC77 => array(0x62B, 0x632), 0xFC78 => array(0x62B, 0x645), - 0xFC79 => array(0x62B, 0x646), 0xFC7A => array(0x62B, 0x649), 0xFC7B => array(0x62B, 0x64A), - 0xFC7C => array(0x641, 0x649), 0xFC7D => array(0x641, 0x64A), 0xFC7E => array(0x642, 0x649), - 0xFC7F => array(0x642, 0x64A), 0xFC80 => array(0x643, 0x627), 0xFC81 => array(0x643, 0x644), - 0xFC82 => array(0x643, 0x645), 0xFC83 => array(0x643, 0x649), 0xFC84 => array(0x643, 0x64A), - 0xFC85 => array(0x644, 0x645), 0xFC86 => array(0x644, 0x649), 0xFC87 => array(0x644, 0x64A), - 0xFC88 => array(0x645, 0x627), 0xFC89 => array(0x645, 0x645), 0xFC8A => array(0x646, 0x631), - 0xFC8B => array(0x646, 0x632), 0xFC8C => array(0x646, 0x645), 0xFC8D => array(0x646, 0x646), - 0xFC8E => array(0x646, 0x649), 0xFC8F => array(0x646, 0x64A), 0xFC90 => array(0x649, 0x670), - 0xFC91 => array(0x64A, 0x631), 0xFC92 => array(0x64A, 0x632), 0xFC93 => array(0x64A, 0x645), - 0xFC94 => array(0x64A, 0x646), 0xFC95 => array(0x64A, 0x649), 0xFC96 => array(0x64A, 0x64A), - 0xFC97 => array(0x626, 0x62C), 0xFC98 => array(0x626, 0x62D), 0xFC99 => array(0x626, 0x62E), - 0xFC9A => array(0x626, 0x645), 0xFC9B => array(0x626, 0x647), 0xFC9C => array(0x628, 0x62C), - 0xFC9D => array(0x628, 0x62D), 0xFC9E => array(0x628, 0x62E), 0xFC9F => array(0x628, 0x645), - 0xFCA0 => array(0x628, 0x647), 0xFCA1 => array(0x62A, 0x62C), 0xFCA2 => array(0x62A, 0x62D), - 0xFCA3 => array(0x62A, 0x62E), 0xFCA4 => array(0x62A, 0x645), 0xFCA5 => array(0x62A, 0x647), - 0xFCA6 => array(0x62B, 0x645), 0xFCA7 => array(0x62C, 0x62D), 0xFCA8 => array(0x62C, 0x645), - 0xFCA9 => array(0x62D, 0x62C), 0xFCAA => array(0x62D, 0x645), 0xFCAB => array(0x62E, 0x62C), - 0xFCAC => array(0x62E, 0x645), 0xFCAD => array(0x633, 0x62C), 0xFCAE => array(0x633, 0x62D), - 0xFCAF => array(0x633, 0x62E), 0xFCB0 => array(0x633, 0x645), 0xFCB1 => array(0x635, 0x62D), - 0xFCB2 => array(0x635, 0x62E), 0xFCB3 => array(0x635, 0x645), 0xFCB4 => array(0x636, 0x62C), - 0xFCB5 => array(0x636, 0x62D), 0xFCB6 => array(0x636, 0x62E), 0xFCB7 => array(0x636, 0x645), - 0xFCB8 => array(0x637, 0x62D), 0xFCB9 => array(0x638, 0x645), 0xFCBA => array(0x639, 0x62C), - 0xFCBB => array(0x639, 0x645), 0xFCBC => array(0x63A, 0x62C), 0xFCBD => array(0x63A, 0x645), - 0xFCBE => array(0x641, 0x62C), 0xFCBF => array(0x641, 0x62D), 0xFCC0 => array(0x641, 0x62E), - 0xFCC1 => array(0x641, 0x645), 0xFCC2 => array(0x642, 0x62D), 0xFCC3 => array(0x642, 0x645), - 0xFCC4 => array(0x643, 0x62C), 0xFCC5 => array(0x643, 0x62D), 0xFCC6 => array(0x643, 0x62E), - 0xFCC7 => array(0x643, 0x644), 0xFCC8 => array(0x643, 0x645), 0xFCC9 => array(0x644, 0x62C), - 0xFCCA => array(0x644, 0x62D), 0xFCCB => array(0x644, 0x62E), 0xFCCC => array(0x644, 0x645), - 0xFCCD => array(0x644, 0x647), 0xFCCE => array(0x645, 0x62C), 0xFCCF => array(0x645, 0x62D), - 0xFCD0 => array(0x645, 0x62E), 0xFCD1 => array(0x645, 0x645), 0xFCD2 => array(0x646, 0x62C), - 0xFCD3 => array(0x646, 0x62D), 0xFCD4 => array(0x646, 0x62E), 0xFCD5 => array(0x646, 0x645), - 0xFCD6 => array(0x646, 0x647), 0xFCD7 => array(0x647, 0x62C), 0xFCD8 => array(0x647, 0x645), - 0xFCD9 => array(0x647, 0x670), 0xFCDA => array(0x64A, 0x62C), 0xFCDB => array(0x64A, 0x62D), - 0xFCDC => array(0x64A, 0x62E), 0xFCDD => array(0x64A, 0x645), 0xFCDE => array(0x64A, 0x647), - 0xFCDF => array(0x626, 0x645), 0xFCE0 => array(0x626, 0x647), 0xFCE1 => array(0x628, 0x645), - 0xFCE2 => array(0x628, 0x647), 0xFCE3 => array(0x62A, 0x645), 0xFCE4 => array(0x62A, 0x647), - 0xFCE5 => array(0x62B, 0x645), 0xFCE6 => array(0x62B, 0x647), 0xFCE7 => array(0x633, 0x645), - 0xFCE8 => array(0x633, 0x647), 0xFCE9 => array(0x634, 0x645), 0xFCEA => array(0x634, 0x647), - 0xFCEB => array(0x643, 0x644), 0xFCEC => array(0x643, 0x645), 0xFCED => array(0x644, 0x645), - 0xFCEE => array(0x646, 0x645), 0xFCEF => array(0x646, 0x647), 0xFCF0 => array(0x64A, 0x645), - 0xFCF1 => array(0x64A, 0x647), 0xFCF2 => array(0x640, 0x64E, 0x651), 0xFCF3 => array(0x640, 0x64F, 0x651), - 0xFCF4 => array(0x640, 0x650, 0x651), 0xFCF5 => array(0x637, 0x649), 0xFCF6 => array(0x637, 0x64A), - 0xFCF7 => array(0x639, 0x649), 0xFCF8 => array(0x639, 0x64A), 0xFCF9 => array(0x63A, 0x649), - 0xFCFA => array(0x63A, 0x64A), 0xFCFB => array(0x633, 0x649), 0xFCFC => array(0x633, 0x64A), - 0xFCFD => array(0x634, 0x649), 0xFCFE => array(0x634, 0x64A), 0xFCFF => array(0x62D, 0x649), - 0xFD00 => array(0x62D, 0x64A), 0xFD01 => array(0x62C, 0x649), 0xFD02 => array(0x62C, 0x64A), - 0xFD03 => array(0x62E, 0x649), 0xFD04 => array(0x62E, 0x64A), 0xFD05 => array(0x635, 0x649), - 0xFD06 => array(0x635, 0x64A), 0xFD07 => array(0x636, 0x649), 0xFD08 => array(0x636, 0x64A), - 0xFD09 => array(0x634, 0x62C), 0xFD0A => array(0x634, 0x62D), 0xFD0B => array(0x634, 0x62E), - 0xFD0C => array(0x634, 0x645), 0xFD0D => array(0x634, 0x631), 0xFD0E => array(0x633, 0x631), - 0xFD0F => array(0x635, 0x631), 0xFD10 => array(0x636, 0x631), 0xFD11 => array(0x637, 0x649), - 0xFD12 => array(0x637, 0x64A), 0xFD13 => array(0x639, 0x649), 0xFD14 => array(0x639, 0x64A), - 0xFD15 => array(0x63A, 0x649), 0xFD16 => array(0x63A, 0x64A), 0xFD17 => array(0x633, 0x649), - 0xFD18 => array(0x633, 0x64A), 0xFD19 => array(0x634, 0x649), 0xFD1A => array(0x634, 0x64A), - 0xFD1B => array(0x62D, 0x649), 0xFD1C => array(0x62D, 0x64A), 0xFD1D => array(0x62C, 0x649), - 0xFD1E => array(0x62C, 0x64A), 0xFD1F => array(0x62E, 0x649), 0xFD20 => array(0x62E, 0x64A), - 0xFD21 => array(0x635, 0x649), 0xFD22 => array(0x635, 0x64A), 0xFD23 => array(0x636, 0x649), - 0xFD24 => array(0x636, 0x64A), 0xFD25 => array(0x634, 0x62C), 0xFD26 => array(0x634, 0x62D), - 0xFD27 => array(0x634, 0x62E), 0xFD28 => array(0x634, 0x645), 0xFD29 => array(0x634, 0x631), - 0xFD2A => array(0x633, 0x631), 0xFD2B => array(0x635, 0x631), 0xFD2C => array(0x636, 0x631), - 0xFD2D => array(0x634, 0x62C), 0xFD2E => array(0x634, 0x62D), 0xFD2F => array(0x634, 0x62E), - 0xFD30 => array(0x634, 0x645), 0xFD31 => array(0x633, 0x647), 0xFD32 => array(0x634, 0x647), - 0xFD33 => array(0x637, 0x645), 0xFD34 => array(0x633, 0x62C), 0xFD35 => array(0x633, 0x62D), - 0xFD36 => array(0x633, 0x62E), 0xFD37 => array(0x634, 0x62C), 0xFD38 => array(0x634, 0x62D), - 0xFD39 => array(0x634, 0x62E), 0xFD3A => array(0x637, 0x645), 0xFD3B => array(0x638, 0x645), - 0xFD3C => array(0x627, 0x64B), 0xFD3D => array(0x627, 0x64B), 0xFD50 => array(0x62A, 0x62C, 0x645), - 0xFD51 => array(0x62A, 0x62D, 0x62C), 0xFD52 => array(0x62A, 0x62D, 0x62C), 0xFD53 => array(0x62A, 0x62D, 0x645), - 0xFD54 => array(0x62A, 0x62E, 0x645), 0xFD55 => array(0x62A, 0x645, 0x62C), 0xFD56 => array(0x62A, 0x645, 0x62D), - 0xFD57 => array(0x62A, 0x645, 0x62E), 0xFD58 => array(0x62C, 0x645, 0x62D), 0xFD59 => array(0x62C, 0x645, 0x62D), - 0xFD5A => array(0x62D, 0x645, 0x64A), 0xFD5B => array(0x62D, 0x645, 0x649), 0xFD5C => array(0x633, 0x62D, 0x62C), - 0xFD5D => array(0x633, 0x62C, 0x62D), 0xFD5E => array(0x633, 0x62C, 0x649), 0xFD5F => array(0x633, 0x645, 0x62D), - 0xFD60 => array(0x633, 0x645, 0x62D), 0xFD61 => array(0x633, 0x645, 0x62C), 0xFD62 => array(0x633, 0x645, 0x645), - 0xFD63 => array(0x633, 0x645, 0x645), 0xFD64 => array(0x635, 0x62D, 0x62D), 0xFD65 => array(0x635, 0x62D, 0x62D), - 0xFD66 => array(0x635, 0x645, 0x645), 0xFD67 => array(0x634, 0x62D, 0x645), 0xFD68 => array(0x634, 0x62D, 0x645), - 0xFD69 => array(0x634, 0x62C, 0x64A), 0xFD6A => array(0x634, 0x645, 0x62E), 0xFD6B => array(0x634, 0x645, 0x62E), - 0xFD6C => array(0x634, 0x645, 0x645), 0xFD6D => array(0x634, 0x645, 0x645), 0xFD6E => array(0x636, 0x62D, 0x649), - 0xFD6F => array(0x636, 0x62E, 0x645), 0xFD70 => array(0x636, 0x62E, 0x645), 0xFD71 => array(0x637, 0x645, 0x62D), - 0xFD72 => array(0x637, 0x645, 0x62D), 0xFD73 => array(0x637, 0x645, 0x645), 0xFD74 => array(0x637, 0x645, 0x64A), - 0xFD75 => array(0x639, 0x62C, 0x645), 0xFD76 => array(0x639, 0x645, 0x645), 0xFD77 => array(0x639, 0x645, 0x645), - 0xFD78 => array(0x639, 0x645, 0x649), 0xFD79 => array(0x63A, 0x645, 0x645), 0xFD7A => array(0x63A, 0x645, 0x64A), - 0xFD7B => array(0x63A, 0x645, 0x649), 0xFD7C => array(0x641, 0x62E, 0x645), 0xFD7D => array(0x641, 0x62E, 0x645), - 0xFD7E => array(0x642, 0x645, 0x62D), 0xFD7F => array(0x642, 0x645, 0x645), 0xFD80 => array(0x644, 0x62D, 0x645), - 0xFD81 => array(0x644, 0x62D, 0x64A), 0xFD82 => array(0x644, 0x62D, 0x649), 0xFD83 => array(0x644, 0x62C, 0x62C), - 0xFD84 => array(0x644, 0x62C, 0x62C), 0xFD85 => array(0x644, 0x62E, 0x645), 0xFD86 => array(0x644, 0x62E, 0x645), - 0xFD87 => array(0x644, 0x645, 0x62D), 0xFD88 => array(0x644, 0x645, 0x62D), 0xFD89 => array(0x645, 0x62D, 0x62C), - 0xFD8A => array(0x645, 0x62D, 0x645), 0xFD8B => array(0x645, 0x62D, 0x64A), 0xFD8C => array(0x645, 0x62C, 0x62D), - 0xFD8D => array(0x645, 0x62C, 0x645), 0xFD8E => array(0x645, 0x62E, 0x62C), 0xFD8F => array(0x645, 0x62E, 0x645), - 0xFD92 => array(0x645, 0x62C, 0x62E), 0xFD93 => array(0x647, 0x645, 0x62C), 0xFD94 => array(0x647, 0x645, 0x645), - 0xFD95 => array(0x646, 0x62D, 0x645), 0xFD96 => array(0x646, 0x62D, 0x649), 0xFD97 => array(0x646, 0x62C, 0x645), - 0xFD98 => array(0x646, 0x62C, 0x645), 0xFD99 => array(0x646, 0x62C, 0x649), 0xFD9A => array(0x646, 0x645, 0x64A), - 0xFD9B => array(0x646, 0x645, 0x649), 0xFD9C => array(0x64A, 0x645, 0x645), 0xFD9D => array(0x64A, 0x645, 0x645), - 0xFD9E => array(0x628, 0x62E, 0x64A), 0xFD9F => array(0x62A, 0x62C, 0x64A), 0xFDA0 => array(0x62A, 0x62C, 0x649), - 0xFDA1 => array(0x62A, 0x62E, 0x64A), 0xFDA2 => array(0x62A, 0x62E, 0x649), 0xFDA3 => array(0x62A, 0x645, 0x64A), - 0xFDA4 => array(0x62A, 0x645, 0x649), 0xFDA5 => array(0x62C, 0x645, 0x64A), 0xFDA6 => array(0x62C, 0x62D, 0x649), - 0xFDA7 => array(0x62C, 0x645, 0x649), 0xFDA8 => array(0x633, 0x62E, 0x649), 0xFDA9 => array(0x635, 0x62D, 0x64A), - 0xFDAA => array(0x634, 0x62D, 0x64A), 0xFDAB => array(0x636, 0x62D, 0x64A), 0xFDAC => array(0x644, 0x62C, 0x64A), - 0xFDAD => array(0x644, 0x645, 0x64A), 0xFDAE => array(0x64A, 0x62D, 0x64A), 0xFDAF => array(0x64A, 0x62C, 0x64A), - 0xFDB0 => array(0x64A, 0x645, 0x64A), 0xFDB1 => array(0x645, 0x645, 0x64A), 0xFDB2 => array(0x642, 0x645, 0x64A), - 0xFDB3 => array(0x646, 0x62D, 0x64A), 0xFDB4 => array(0x642, 0x645, 0x62D), 0xFDB5 => array(0x644, 0x62D, 0x645), - 0xFDB6 => array(0x639, 0x645, 0x64A), 0xFDB7 => array(0x643, 0x645, 0x64A), 0xFDB8 => array(0x646, 0x62C, 0x62D), - 0xFDB9 => array(0x645, 0x62E, 0x64A), 0xFDBA => array(0x644, 0x62C, 0x645), 0xFDBB => array(0x643, 0x645, 0x645), - 0xFDBC => array(0x644, 0x62C, 0x645), 0xFDBD => array(0x646, 0x62C, 0x62D), 0xFDBE => array(0x62C, 0x62D, 0x64A), - 0xFDBF => array(0x62D, 0x62C, 0x64A), 0xFDC0 => array(0x645, 0x62C, 0x64A), 0xFDC1 => array(0x641, 0x645, 0x64A), - 0xFDC2 => array(0x628, 0x62D, 0x64A), 0xFDC3 => array(0x643, 0x645, 0x645), 0xFDC4 => array(0x639, 0x62C, 0x645), - 0xFDC5 => array(0x635, 0x645, 0x645), 0xFDC6 => array(0x633, 0x62E, 0x64A), 0xFDC7 => array(0x646, 0x62C, 0x64A), - 0xFDF0 => array(0x635, 0x644, 0x6D2), 0xFDF1 => array(0x642, 0x644, 0x6D2), 0xFDF2 => array(0x627, 0x644, 0x644, 0x647), - 0xFDF3 => array(0x627, 0x643, 0x628, 0x631), 0xFDF4 => array(0x645, 0x62D, 0x645, 0x62F), 0xFDF5 => array(0x635, 0x644, 0x639, 0x645), - 0xFDF6 => array(0x631, 0x633, 0x648, 0x644), 0xFDF7 => array(0x639, 0x644, 0x64A, 0x647), 0xFDF8 => array(0x648, 0x633, 0x644, 0x645), - 0xFDF9 => array(0x635, 0x644, 0x649), 0xFDFC => array(0x631, 0x6CC, 0x627, 0x644), 0xFE11 => array(0x3001), - 0xFE17 => array(0x3016), 0xFE18 => array(0x3017), 0xFE31 => array(0x2014), - 0xFE32 => array(0x2013), 0xFE39 => array(0x3014), 0xFE3A => array(0x3015), - 0xFE3B => array(0x3010), 0xFE3C => array(0x3011), 0xFE3D => array(0x300A), - 0xFE3E => array(0x300B), 0xFE3F => array(0x3008), 0xFE40 => array(0x3009), - 0xFE41 => array(0x300C), 0xFE42 => array(0x300D), 0xFE43 => array(0x300E), - 0xFE44 => array(0x300F), 0xFE51 => array(0x3001), 0xFE58 => array(0x2014), - 0xFE5D => array(0x3014), 0xFE5E => array(0x3015), 0xFE63 => array(0x2D), - 0xFE71 => array(0x640, 0x64B), 0xFE77 => array(0x640, 0x64E), 0xFE79 => array(0x640, 0x64F), - 0xFE7B => array(0x640, 0x650), 0xFE7D => array(0x640, 0x651), 0xFE7F => array(0x640, 0x652), - 0xFE80 => array(0x621), 0xFE81 => array(0x622), 0xFE82 => array(0x622), - 0xFE83 => array(0x623), 0xFE84 => array(0x623), 0xFE85 => array(0x624), - 0xFE86 => array(0x624), 0xFE87 => array(0x625), 0xFE88 => array(0x625), - 0xFE89 => array(0x626), 0xFE8A => array(0x626), 0xFE8B => array(0x626), - 0xFE8C => array(0x626), 0xFE8D => array(0x627), 0xFE8E => array(0x627), - 0xFE8F => array(0x628), 0xFE90 => array(0x628), 0xFE91 => array(0x628), - 0xFE92 => array(0x628), 0xFE93 => array(0x629), 0xFE94 => array(0x629), - 0xFE95 => array(0x62A), 0xFE96 => array(0x62A), 0xFE97 => array(0x62A), - 0xFE98 => array(0x62A), 0xFE99 => array(0x62B), 0xFE9A => array(0x62B), - 0xFE9B => array(0x62B), 0xFE9C => array(0x62B), 0xFE9D => array(0x62C), - 0xFE9E => array(0x62C), 0xFE9F => array(0x62C), 0xFEA0 => array(0x62C), - 0xFEA1 => array(0x62D), 0xFEA2 => array(0x62D), 0xFEA3 => array(0x62D), - 0xFEA4 => array(0x62D), 0xFEA5 => array(0x62E), 0xFEA6 => array(0x62E), - 0xFEA7 => array(0x62E), 0xFEA8 => array(0x62E), 0xFEA9 => array(0x62F), - 0xFEAA => array(0x62F), 0xFEAB => array(0x630), 0xFEAC => array(0x630), - 0xFEAD => array(0x631), 0xFEAE => array(0x631), 0xFEAF => array(0x632), - 0xFEB0 => array(0x632), 0xFEB1 => array(0x633), 0xFEB2 => array(0x633), - 0xFEB3 => array(0x633), 0xFEB4 => array(0x633), 0xFEB5 => array(0x634), - 0xFEB6 => array(0x634), 0xFEB7 => array(0x634), 0xFEB8 => array(0x634), - 0xFEB9 => array(0x635), 0xFEBA => array(0x635), 0xFEBB => array(0x635), - 0xFEBC => array(0x635), 0xFEBD => array(0x636), 0xFEBE => array(0x636), - 0xFEBF => array(0x636), 0xFEC0 => array(0x636), 0xFEC1 => array(0x637), - 0xFEC2 => array(0x637), 0xFEC3 => array(0x637), 0xFEC4 => array(0x637), - 0xFEC5 => array(0x638), 0xFEC6 => array(0x638), 0xFEC7 => array(0x638), - 0xFEC8 => array(0x638), 0xFEC9 => array(0x639), 0xFECA => array(0x639), - 0xFECB => array(0x639), 0xFECC => array(0x639), 0xFECD => array(0x63A), - 0xFECE => array(0x63A), 0xFECF => array(0x63A), 0xFED0 => array(0x63A), - 0xFED1 => array(0x641), 0xFED2 => array(0x641), 0xFED3 => array(0x641), - 0xFED4 => array(0x641), 0xFED5 => array(0x642), 0xFED6 => array(0x642), - 0xFED7 => array(0x642), 0xFED8 => array(0x642), 0xFED9 => array(0x643), - 0xFEDA => array(0x643), 0xFEDB => array(0x643), 0xFEDC => array(0x643), - 0xFEDD => array(0x644), 0xFEDE => array(0x644), 0xFEDF => array(0x644), - 0xFEE0 => array(0x644), 0xFEE1 => array(0x645), 0xFEE2 => array(0x645), - 0xFEE3 => array(0x645), 0xFEE4 => array(0x645), 0xFEE5 => array(0x646), - 0xFEE6 => array(0x646), 0xFEE7 => array(0x646), 0xFEE8 => array(0x646), - 0xFEE9 => array(0x647), 0xFEEA => array(0x647), 0xFEEB => array(0x647), - 0xFEEC => array(0x647), 0xFEED => array(0x648), 0xFEEE => array(0x648), - 0xFEEF => array(0x649), 0xFEF0 => array(0x649), 0xFEF1 => array(0x64A), - 0xFEF2 => array(0x64A), 0xFEF3 => array(0x64A), 0xFEF4 => array(0x64A), - 0xFEF5 => array(0x644, 0x622), 0xFEF6 => array(0x644, 0x622), 0xFEF7 => array(0x644, 0x623), - 0xFEF8 => array(0x644, 0x623), 0xFEF9 => array(0x644, 0x625), 0xFEFA => array(0x644, 0x625), - 0xFEFB => array(0x644, 0x627), 0xFEFC => array(0x644, 0x627), 0xFF0D => array(0x2D), - 0xFF0E => array(0x2E), 0xFF10 => array(0x30), 0xFF11 => array(0x31), - 0xFF12 => array(0x32), 0xFF13 => array(0x33), 0xFF14 => array(0x34), - 0xFF15 => array(0x35), 0xFF16 => array(0x36), 0xFF17 => array(0x37), - 0xFF18 => array(0x38), 0xFF19 => array(0x39), 0xFF21 => array(0x61), - 0xFF22 => array(0x62), 0xFF23 => array(0x63), 0xFF24 => array(0x64), - 0xFF25 => array(0x65), 0xFF26 => array(0x66), 0xFF27 => array(0x67), - 0xFF28 => array(0x68), 0xFF29 => array(0x69), 0xFF2A => array(0x6A), - 0xFF2B => array(0x6B), 0xFF2C => array(0x6C), 0xFF2D => array(0x6D), - 0xFF2E => array(0x6E), 0xFF2F => array(0x6F), 0xFF30 => array(0x70), - 0xFF31 => array(0x71), 0xFF32 => array(0x72), 0xFF33 => array(0x73), - 0xFF34 => array(0x74), 0xFF35 => array(0x75), 0xFF36 => array(0x76), - 0xFF37 => array(0x77), 0xFF38 => array(0x78), 0xFF39 => array(0x79), - 0xFF3A => array(0x7A), 0xFF41 => array(0x61), 0xFF42 => array(0x62), - 0xFF43 => array(0x63), 0xFF44 => array(0x64), 0xFF45 => array(0x65), - 0xFF46 => array(0x66), 0xFF47 => array(0x67), 0xFF48 => array(0x68), - 0xFF49 => array(0x69), 0xFF4A => array(0x6A), 0xFF4B => array(0x6B), - 0xFF4C => array(0x6C), 0xFF4D => array(0x6D), 0xFF4E => array(0x6E), - 0xFF4F => array(0x6F), 0xFF50 => array(0x70), 0xFF51 => array(0x71), - 0xFF52 => array(0x72), 0xFF53 => array(0x73), 0xFF54 => array(0x74), - 0xFF55 => array(0x75), 0xFF56 => array(0x76), 0xFF57 => array(0x77), - 0xFF58 => array(0x78), 0xFF59 => array(0x79), 0xFF5A => array(0x7A), - 0xFF5F => array(0x2985), 0xFF60 => array(0x2986), 0xFF61 => array(0x2E), - 0xFF62 => array(0x300C), 0xFF63 => array(0x300D), 0xFF64 => array(0x3001), - 0xFF65 => array(0x30FB), 0xFF66 => array(0x30F2), 0xFF67 => array(0x30A1), - 0xFF68 => array(0x30A3), 0xFF69 => array(0x30A5), 0xFF6A => array(0x30A7), - 0xFF6B => array(0x30A9), 0xFF6C => array(0x30E3), 0xFF6D => array(0x30E5), - 0xFF6E => array(0x30E7), 0xFF6F => array(0x30C3), 0xFF70 => array(0x30FC), - 0xFF71 => array(0x30A2), 0xFF72 => array(0x30A4), 0xFF73 => array(0x30A6), - 0xFF74 => array(0x30A8), 0xFF75 => array(0x30AA), 0xFF76 => array(0x30AB), - 0xFF77 => array(0x30AD), 0xFF78 => array(0x30AF), 0xFF79 => array(0x30B1), - 0xFF7A => array(0x30B3), 0xFF7B => array(0x30B5), 0xFF7C => array(0x30B7), - 0xFF7D => array(0x30B9), 0xFF7E => array(0x30BB), 0xFF7F => array(0x30BD), - 0xFF80 => array(0x30BF), 0xFF81 => array(0x30C1), 0xFF82 => array(0x30C4), - 0xFF83 => array(0x30C6), 0xFF84 => array(0x30C8), 0xFF85 => array(0x30CA), - 0xFF86 => array(0x30CB), 0xFF87 => array(0x30CC), 0xFF88 => array(0x30CD), - 0xFF89 => array(0x30CE), 0xFF8A => array(0x30CF), 0xFF8B => array(0x30D2), - 0xFF8C => array(0x30D5), 0xFF8D => array(0x30D8), 0xFF8E => array(0x30DB), - 0xFF8F => array(0x30DE), 0xFF90 => array(0x30DF), 0xFF91 => array(0x30E0), - 0xFF92 => array(0x30E1), 0xFF93 => array(0x30E2), 0xFF94 => array(0x30E4), - 0xFF95 => array(0x30E6), 0xFF96 => array(0x30E8), 0xFF97 => array(0x30E9), - 0xFF98 => array(0x30EA), 0xFF99 => array(0x30EB), 0xFF9A => array(0x30EC), - 0xFF9B => array(0x30ED), 0xFF9C => array(0x30EF), 0xFF9D => array(0x30F3), - 0xFF9E => array(0x3099), 0xFF9F => array(0x309A), 0xFFA1 => array(0x1100), - 0xFFA2 => array(0x1101), 0xFFA3 => array(0x11AA), 0xFFA4 => array(0x1102), - 0xFFA5 => array(0x11AC), 0xFFA6 => array(0x11AD), 0xFFA7 => array(0x1103), - 0xFFA8 => array(0x1104), 0xFFA9 => array(0x1105), 0xFFAA => array(0x11B0), - 0xFFAB => array(0x11B1), 0xFFAC => array(0x11B2), 0xFFAD => array(0x11B3), - 0xFFAE => array(0x11B4), 0xFFAF => array(0x11B5), 0xFFB0 => array(0x111A), - 0xFFB1 => array(0x1106), 0xFFB2 => array(0x1107), 0xFFB3 => array(0x1108), - 0xFFB4 => array(0x1121), 0xFFB5 => array(0x1109), 0xFFB6 => array(0x110A), - 0xFFB7 => array(0x110B), 0xFFB8 => array(0x110C), 0xFFB9 => array(0x110D), - 0xFFBA => array(0x110E), 0xFFBB => array(0x110F), 0xFFBC => array(0x1110), - 0xFFBD => array(0x1111), 0xFFBE => array(0x1112), 0xFFC2 => array(0x1161), - 0xFFC3 => array(0x1162), 0xFFC4 => array(0x1163), 0xFFC5 => array(0x1164), - 0xFFC6 => array(0x1165), 0xFFC7 => array(0x1166), 0xFFCA => array(0x1167), - 0xFFCB => array(0x1168), 0xFFCC => array(0x1169), 0xFFCD => array(0x116A), - 0xFFCE => array(0x116B), 0xFFCF => array(0x116C), 0xFFD2 => array(0x116D), - 0xFFD3 => array(0x116E), 0xFFD4 => array(0x116F), 0xFFD5 => array(0x1170), - 0xFFD6 => array(0x1171), 0xFFD7 => array(0x1172), 0xFFDA => array(0x1173), - 0xFFDB => array(0x1174), 0xFFDC => array(0x1175), 0xFFE0 => array(0xA2), - 0xFFE1 => array(0xA3), 0xFFE2 => array(0xAC), 0xFFE4 => array(0xA6), - 0xFFE5 => array(0xA5), 0xFFE6 => array(0x20A9), 0xFFE8 => array(0x2502), - 0xFFE9 => array(0x2190), 0xFFEA => array(0x2191), 0xFFEB => array(0x2192), - 0xFFEC => array(0x2193), 0xFFED => array(0x25A0), 0xFFEE => array(0x25CB), - 0x10400 => array(0x10428), 0x10401 => array(0x10429), 0x10402 => array(0x1042A), - 0x10403 => array(0x1042B), 0x10404 => array(0x1042C), 0x10405 => array(0x1042D), - 0x10406 => array(0x1042E), 0x10407 => array(0x1042F), 0x10408 => array(0x10430), - 0x10409 => array(0x10431), 0x1040A => array(0x10432), 0x1040B => array(0x10433), - 0x1040C => array(0x10434), 0x1040D => array(0x10435), 0x1040E => array(0x10436), - 0x1040F => array(0x10437), 0x10410 => array(0x10438), 0x10411 => array(0x10439), - 0x10412 => array(0x1043A), 0x10413 => array(0x1043B), 0x10414 => array(0x1043C), - 0x10415 => array(0x1043D), 0x10416 => array(0x1043E), 0x10417 => array(0x1043F), - 0x10418 => array(0x10440), 0x10419 => array(0x10441), 0x1041A => array(0x10442), - 0x1041B => array(0x10443), 0x1041C => array(0x10444), 0x1041D => array(0x10445), - 0x1041E => array(0x10446), 0x1041F => array(0x10447), 0x10420 => array(0x10448), - 0x10421 => array(0x10449), 0x10422 => array(0x1044A), 0x10423 => array(0x1044B), - 0x10424 => array(0x1044C), 0x10425 => array(0x1044D), 0x10426 => array(0x1044E), - 0x10427 => array(0x1044F), 0x118A0 => array(0x118C0), 0x118A1 => array(0x118C1), - 0x118A2 => array(0x118C2), 0x118A3 => array(0x118C3), 0x118A4 => array(0x118C4), - 0x118A5 => array(0x118C5), 0x118A6 => array(0x118C6), 0x118A7 => array(0x118C7), - 0x118A8 => array(0x118C8), 0x118A9 => array(0x118C9), 0x118AA => array(0x118CA), - 0x118AB => array(0x118CB), 0x118AC => array(0x118CC), 0x118AD => array(0x118CD), - 0x118AE => array(0x118CE), 0x118AF => array(0x118CF), 0x118B0 => array(0x118D0), - 0x118B1 => array(0x118D1), 0x118B2 => array(0x118D2), 0x118B3 => array(0x118D3), - 0x118B4 => array(0x118D4), 0x118B5 => array(0x118D5), 0x118B6 => array(0x118D6), - 0x118B7 => array(0x118D7), 0x118B8 => array(0x118D8), 0x118B9 => array(0x118D9), - 0x118BA => array(0x118DA), 0x118BB => array(0x118DB), 0x118BC => array(0x118DC), - 0x118BD => array(0x118DD), 0x118BE => array(0x118DE), 0x118BF => array(0x118DF), - 0x1D15E => array(0x1D157, 0x1D165), 0x1D15F => array(0x1D158, 0x1D165), 0x1D160 => array(0x1D158, 0x1D165, 0x1D16E), - 0x1D161 => array(0x1D158, 0x1D165, 0x1D16F), 0x1D162 => array(0x1D158, 0x1D165, 0x1D170), 0x1D163 => array(0x1D158, 0x1D165, 0x1D171), - 0x1D164 => array(0x1D158, 0x1D165, 0x1D172), 0x1D1BB => array(0x1D1B9, 0x1D165), 0x1D1BC => array(0x1D1BA, 0x1D165), - 0x1D1BD => array(0x1D1B9, 0x1D165, 0x1D16E), 0x1D1BE => array(0x1D1BA, 0x1D165, 0x1D16E), 0x1D1BF => array(0x1D1B9, 0x1D165, 0x1D16F), - 0x1D1C0 => array(0x1D1BA, 0x1D165, 0x1D16F), 0x1D400 => array(0x61), 0x1D401 => array(0x62), - 0x1D402 => array(0x63), 0x1D403 => array(0x64), 0x1D404 => array(0x65), - 0x1D405 => array(0x66), 0x1D406 => array(0x67), 0x1D407 => array(0x68), - 0x1D408 => array(0x69), 0x1D409 => array(0x6A), 0x1D40A => array(0x6B), - 0x1D40B => array(0x6C), 0x1D40C => array(0x6D), 0x1D40D => array(0x6E), - 0x1D40E => array(0x6F), 0x1D40F => array(0x70), 0x1D410 => array(0x71), - 0x1D411 => array(0x72), 0x1D412 => array(0x73), 0x1D413 => array(0x74), - 0x1D414 => array(0x75), 0x1D415 => array(0x76), 0x1D416 => array(0x77), - 0x1D417 => array(0x78), 0x1D418 => array(0x79), 0x1D419 => array(0x7A), - 0x1D41A => array(0x61), 0x1D41B => array(0x62), 0x1D41C => array(0x63), - 0x1D41D => array(0x64), 0x1D41E => array(0x65), 0x1D41F => array(0x66), - 0x1D420 => array(0x67), 0x1D421 => array(0x68), 0x1D422 => array(0x69), - 0x1D423 => array(0x6A), 0x1D424 => array(0x6B), 0x1D425 => array(0x6C), - 0x1D426 => array(0x6D), 0x1D427 => array(0x6E), 0x1D428 => array(0x6F), - 0x1D429 => array(0x70), 0x1D42A => array(0x71), 0x1D42B => array(0x72), - 0x1D42C => array(0x73), 0x1D42D => array(0x74), 0x1D42E => array(0x75), - 0x1D42F => array(0x76), 0x1D430 => array(0x77), 0x1D431 => array(0x78), - 0x1D432 => array(0x79), 0x1D433 => array(0x7A), 0x1D434 => array(0x61), - 0x1D435 => array(0x62), 0x1D436 => array(0x63), 0x1D437 => array(0x64), - 0x1D438 => array(0x65), 0x1D439 => array(0x66), 0x1D43A => array(0x67), - 0x1D43B => array(0x68), 0x1D43C => array(0x69), 0x1D43D => array(0x6A), - 0x1D43E => array(0x6B), 0x1D43F => array(0x6C), 0x1D440 => array(0x6D), - 0x1D441 => array(0x6E), 0x1D442 => array(0x6F), 0x1D443 => array(0x70), - 0x1D444 => array(0x71), 0x1D445 => array(0x72), 0x1D446 => array(0x73), - 0x1D447 => array(0x74), 0x1D448 => array(0x75), 0x1D449 => array(0x76), - 0x1D44A => array(0x77), 0x1D44B => array(0x78), 0x1D44C => array(0x79), - 0x1D44D => array(0x7A), 0x1D44E => array(0x61), 0x1D44F => array(0x62), - 0x1D450 => array(0x63), 0x1D451 => array(0x64), 0x1D452 => array(0x65), - 0x1D453 => array(0x66), 0x1D454 => array(0x67), 0x1D456 => array(0x69), - 0x1D457 => array(0x6A), 0x1D458 => array(0x6B), 0x1D459 => array(0x6C), - 0x1D45A => array(0x6D), 0x1D45B => array(0x6E), 0x1D45C => array(0x6F), - 0x1D45D => array(0x70), 0x1D45E => array(0x71), 0x1D45F => array(0x72), - 0x1D460 => array(0x73), 0x1D461 => array(0x74), 0x1D462 => array(0x75), - 0x1D463 => array(0x76), 0x1D464 => array(0x77), 0x1D465 => array(0x78), - 0x1D466 => array(0x79), 0x1D467 => array(0x7A), 0x1D468 => array(0x61), - 0x1D469 => array(0x62), 0x1D46A => array(0x63), 0x1D46B => array(0x64), - 0x1D46C => array(0x65), 0x1D46D => array(0x66), 0x1D46E => array(0x67), - 0x1D46F => array(0x68), 0x1D470 => array(0x69), 0x1D471 => array(0x6A), - 0x1D472 => array(0x6B), 0x1D473 => array(0x6C), 0x1D474 => array(0x6D), - 0x1D475 => array(0x6E), 0x1D476 => array(0x6F), 0x1D477 => array(0x70), - 0x1D478 => array(0x71), 0x1D479 => array(0x72), 0x1D47A => array(0x73), - 0x1D47B => array(0x74), 0x1D47C => array(0x75), 0x1D47D => array(0x76), - 0x1D47E => array(0x77), 0x1D47F => array(0x78), 0x1D480 => array(0x79), - 0x1D481 => array(0x7A), 0x1D482 => array(0x61), 0x1D483 => array(0x62), - 0x1D484 => array(0x63), 0x1D485 => array(0x64), 0x1D486 => array(0x65), - 0x1D487 => array(0x66), 0x1D488 => array(0x67), 0x1D489 => array(0x68), - 0x1D48A => array(0x69), 0x1D48B => array(0x6A), 0x1D48C => array(0x6B), - 0x1D48D => array(0x6C), 0x1D48E => array(0x6D), 0x1D48F => array(0x6E), - 0x1D490 => array(0x6F), 0x1D491 => array(0x70), 0x1D492 => array(0x71), - 0x1D493 => array(0x72), 0x1D494 => array(0x73), 0x1D495 => array(0x74), - 0x1D496 => array(0x75), 0x1D497 => array(0x76), 0x1D498 => array(0x77), - 0x1D499 => array(0x78), 0x1D49A => array(0x79), 0x1D49B => array(0x7A), - 0x1D49C => array(0x61), 0x1D49E => array(0x63), 0x1D49F => array(0x64), - 0x1D4A2 => array(0x67), 0x1D4A5 => array(0x6A), 0x1D4A6 => array(0x6B), - 0x1D4A9 => array(0x6E), 0x1D4AA => array(0x6F), 0x1D4AB => array(0x70), - 0x1D4AC => array(0x71), 0x1D4AE => array(0x73), 0x1D4AF => array(0x74), - 0x1D4B0 => array(0x75), 0x1D4B1 => array(0x76), 0x1D4B2 => array(0x77), - 0x1D4B3 => array(0x78), 0x1D4B4 => array(0x79), 0x1D4B5 => array(0x7A), - 0x1D4B6 => array(0x61), 0x1D4B7 => array(0x62), 0x1D4B8 => array(0x63), - 0x1D4B9 => array(0x64), 0x1D4BB => array(0x66), 0x1D4BD => array(0x68), - 0x1D4BE => array(0x69), 0x1D4BF => array(0x6A), 0x1D4C0 => array(0x6B), - 0x1D4C1 => array(0x6C), 0x1D4C2 => array(0x6D), 0x1D4C3 => array(0x6E), - 0x1D4C5 => array(0x70), 0x1D4C6 => array(0x71), 0x1D4C7 => array(0x72), - 0x1D4C8 => array(0x73), 0x1D4C9 => array(0x74), 0x1D4CA => array(0x75), - 0x1D4CB => array(0x76), 0x1D4CC => array(0x77), 0x1D4CD => array(0x78), - 0x1D4CE => array(0x79), 0x1D4CF => array(0x7A), 0x1D4D0 => array(0x61), - 0x1D4D1 => array(0x62), 0x1D4D2 => array(0x63), 0x1D4D3 => array(0x64), - 0x1D4D4 => array(0x65), 0x1D4D5 => array(0x66), 0x1D4D6 => array(0x67), - 0x1D4D7 => array(0x68), 0x1D4D8 => array(0x69), 0x1D4D9 => array(0x6A), - 0x1D4DA => array(0x6B), 0x1D4DB => array(0x6C), 0x1D4DC => array(0x6D), - 0x1D4DD => array(0x6E), 0x1D4DE => array(0x6F), 0x1D4DF => array(0x70), - 0x1D4E0 => array(0x71), 0x1D4E1 => array(0x72), 0x1D4E2 => array(0x73), - 0x1D4E3 => array(0x74), 0x1D4E4 => array(0x75), 0x1D4E5 => array(0x76), - 0x1D4E6 => array(0x77), 0x1D4E7 => array(0x78), 0x1D4E8 => array(0x79), - 0x1D4E9 => array(0x7A), 0x1D4EA => array(0x61), 0x1D4EB => array(0x62), - 0x1D4EC => array(0x63), 0x1D4ED => array(0x64), 0x1D4EE => array(0x65), - 0x1D4EF => array(0x66), 0x1D4F0 => array(0x67), 0x1D4F1 => array(0x68), - 0x1D4F2 => array(0x69), 0x1D4F3 => array(0x6A), 0x1D4F4 => array(0x6B), - 0x1D4F5 => array(0x6C), 0x1D4F6 => array(0x6D), 0x1D4F7 => array(0x6E), - 0x1D4F8 => array(0x6F), 0x1D4F9 => array(0x70), 0x1D4FA => array(0x71), - 0x1D4FB => array(0x72), 0x1D4FC => array(0x73), 0x1D4FD => array(0x74), - 0x1D4FE => array(0x75), 0x1D4FF => array(0x76), 0x1D500 => array(0x77), - 0x1D501 => array(0x78), 0x1D502 => array(0x79), 0x1D503 => array(0x7A), - 0x1D504 => array(0x61), 0x1D505 => array(0x62), 0x1D507 => array(0x64), - 0x1D508 => array(0x65), 0x1D509 => array(0x66), 0x1D50A => array(0x67), - 0x1D50D => array(0x6A), 0x1D50E => array(0x6B), 0x1D50F => array(0x6C), - 0x1D510 => array(0x6D), 0x1D511 => array(0x6E), 0x1D512 => array(0x6F), - 0x1D513 => array(0x70), 0x1D514 => array(0x71), 0x1D516 => array(0x73), - 0x1D517 => array(0x74), 0x1D518 => array(0x75), 0x1D519 => array(0x76), - 0x1D51A => array(0x77), 0x1D51B => array(0x78), 0x1D51C => array(0x79), - 0x1D51E => array(0x61), 0x1D51F => array(0x62), 0x1D520 => array(0x63), - 0x1D521 => array(0x64), 0x1D522 => array(0x65), 0x1D523 => array(0x66), - 0x1D524 => array(0x67), 0x1D525 => array(0x68), 0x1D526 => array(0x69), - 0x1D527 => array(0x6A), 0x1D528 => array(0x6B), 0x1D529 => array(0x6C), - 0x1D52A => array(0x6D), 0x1D52B => array(0x6E), 0x1D52C => array(0x6F), - 0x1D52D => array(0x70), 0x1D52E => array(0x71), 0x1D52F => array(0x72), - 0x1D530 => array(0x73), 0x1D531 => array(0x74), 0x1D532 => array(0x75), - 0x1D533 => array(0x76), 0x1D534 => array(0x77), 0x1D535 => array(0x78), - 0x1D536 => array(0x79), 0x1D537 => array(0x7A), 0x1D538 => array(0x61), - 0x1D539 => array(0x62), 0x1D53B => array(0x64), 0x1D53C => array(0x65), - 0x1D53D => array(0x66), 0x1D53E => array(0x67), 0x1D540 => array(0x69), - 0x1D541 => array(0x6A), 0x1D542 => array(0x6B), 0x1D543 => array(0x6C), - 0x1D544 => array(0x6D), 0x1D546 => array(0x6F), 0x1D54A => array(0x73), - 0x1D54B => array(0x74), 0x1D54C => array(0x75), 0x1D54D => array(0x76), - 0x1D54E => array(0x77), 0x1D54F => array(0x78), 0x1D550 => array(0x79), - 0x1D552 => array(0x61), 0x1D553 => array(0x62), 0x1D554 => array(0x63), - 0x1D555 => array(0x64), 0x1D556 => array(0x65), 0x1D557 => array(0x66), - 0x1D558 => array(0x67), 0x1D559 => array(0x68), 0x1D55A => array(0x69), - 0x1D55B => array(0x6A), 0x1D55C => array(0x6B), 0x1D55D => array(0x6C), - 0x1D55E => array(0x6D), 0x1D55F => array(0x6E), 0x1D560 => array(0x6F), - 0x1D561 => array(0x70), 0x1D562 => array(0x71), 0x1D563 => array(0x72), - 0x1D564 => array(0x73), 0x1D565 => array(0x74), 0x1D566 => array(0x75), - 0x1D567 => array(0x76), 0x1D568 => array(0x77), 0x1D569 => array(0x78), - 0x1D56A => array(0x79), 0x1D56B => array(0x7A), 0x1D56C => array(0x61), - 0x1D56D => array(0x62), 0x1D56E => array(0x63), 0x1D56F => array(0x64), - 0x1D570 => array(0x65), 0x1D571 => array(0x66), 0x1D572 => array(0x67), - 0x1D573 => array(0x68), 0x1D574 => array(0x69), 0x1D575 => array(0x6A), - 0x1D576 => array(0x6B), 0x1D577 => array(0x6C), 0x1D578 => array(0x6D), - 0x1D579 => array(0x6E), 0x1D57A => array(0x6F), 0x1D57B => array(0x70), - 0x1D57C => array(0x71), 0x1D57D => array(0x72), 0x1D57E => array(0x73), - 0x1D57F => array(0x74), 0x1D580 => array(0x75), 0x1D581 => array(0x76), - 0x1D582 => array(0x77), 0x1D583 => array(0x78), 0x1D584 => array(0x79), - 0x1D585 => array(0x7A), 0x1D586 => array(0x61), 0x1D587 => array(0x62), - 0x1D588 => array(0x63), 0x1D589 => array(0x64), 0x1D58A => array(0x65), - 0x1D58B => array(0x66), 0x1D58C => array(0x67), 0x1D58D => array(0x68), - 0x1D58E => array(0x69), 0x1D58F => array(0x6A), 0x1D590 => array(0x6B), - 0x1D591 => array(0x6C), 0x1D592 => array(0x6D), 0x1D593 => array(0x6E), - 0x1D594 => array(0x6F), 0x1D595 => array(0x70), 0x1D596 => array(0x71), - 0x1D597 => array(0x72), 0x1D598 => array(0x73), 0x1D599 => array(0x74), - 0x1D59A => array(0x75), 0x1D59B => array(0x76), 0x1D59C => array(0x77), - 0x1D59D => array(0x78), 0x1D59E => array(0x79), 0x1D59F => array(0x7A), - 0x1D5A0 => array(0x61), 0x1D5A1 => array(0x62), 0x1D5A2 => array(0x63), - 0x1D5A3 => array(0x64), 0x1D5A4 => array(0x65), 0x1D5A5 => array(0x66), - 0x1D5A6 => array(0x67), 0x1D5A7 => array(0x68), 0x1D5A8 => array(0x69), - 0x1D5A9 => array(0x6A), 0x1D5AA => array(0x6B), 0x1D5AB => array(0x6C), - 0x1D5AC => array(0x6D), 0x1D5AD => array(0x6E), 0x1D5AE => array(0x6F), - 0x1D5AF => array(0x70), 0x1D5B0 => array(0x71), 0x1D5B1 => array(0x72), - 0x1D5B2 => array(0x73), 0x1D5B3 => array(0x74), 0x1D5B4 => array(0x75), - 0x1D5B5 => array(0x76), 0x1D5B6 => array(0x77), 0x1D5B7 => array(0x78), - 0x1D5B8 => array(0x79), 0x1D5B9 => array(0x7A), 0x1D5BA => array(0x61), - 0x1D5BB => array(0x62), 0x1D5BC => array(0x63), 0x1D5BD => array(0x64), - 0x1D5BE => array(0x65), 0x1D5BF => array(0x66), 0x1D5C0 => array(0x67), - 0x1D5C1 => array(0x68), 0x1D5C2 => array(0x69), 0x1D5C3 => array(0x6A), - 0x1D5C4 => array(0x6B), 0x1D5C5 => array(0x6C), 0x1D5C6 => array(0x6D), - 0x1D5C7 => array(0x6E), 0x1D5C8 => array(0x6F), 0x1D5C9 => array(0x70), - 0x1D5CA => array(0x71), 0x1D5CB => array(0x72), 0x1D5CC => array(0x73), - 0x1D5CD => array(0x74), 0x1D5CE => array(0x75), 0x1D5CF => array(0x76), - 0x1D5D0 => array(0x77), 0x1D5D1 => array(0x78), 0x1D5D2 => array(0x79), - 0x1D5D3 => array(0x7A), 0x1D5D4 => array(0x61), 0x1D5D5 => array(0x62), - 0x1D5D6 => array(0x63), 0x1D5D7 => array(0x64), 0x1D5D8 => array(0x65), - 0x1D5D9 => array(0x66), 0x1D5DA => array(0x67), 0x1D5DB => array(0x68), - 0x1D5DC => array(0x69), 0x1D5DD => array(0x6A), 0x1D5DE => array(0x6B), - 0x1D5DF => array(0x6C), 0x1D5E0 => array(0x6D), 0x1D5E1 => array(0x6E), - 0x1D5E2 => array(0x6F), 0x1D5E3 => array(0x70), 0x1D5E4 => array(0x71), - 0x1D5E5 => array(0x72), 0x1D5E6 => array(0x73), 0x1D5E7 => array(0x74), - 0x1D5E8 => array(0x75), 0x1D5E9 => array(0x76), 0x1D5EA => array(0x77), - 0x1D5EB => array(0x78), 0x1D5EC => array(0x79), 0x1D5ED => array(0x7A), - 0x1D5EE => array(0x61), 0x1D5EF => array(0x62), 0x1D5F0 => array(0x63), - 0x1D5F1 => array(0x64), 0x1D5F2 => array(0x65), 0x1D5F3 => array(0x66), - 0x1D5F4 => array(0x67), 0x1D5F5 => array(0x68), 0x1D5F6 => array(0x69), - 0x1D5F7 => array(0x6A), 0x1D5F8 => array(0x6B), 0x1D5F9 => array(0x6C), - 0x1D5FA => array(0x6D), 0x1D5FB => array(0x6E), 0x1D5FC => array(0x6F), - 0x1D5FD => array(0x70), 0x1D5FE => array(0x71), 0x1D5FF => array(0x72), - 0x1D600 => array(0x73), 0x1D601 => array(0x74), 0x1D602 => array(0x75), - 0x1D603 => array(0x76), 0x1D604 => array(0x77), 0x1D605 => array(0x78), - 0x1D606 => array(0x79), 0x1D607 => array(0x7A), 0x1D608 => array(0x61), - 0x1D609 => array(0x62), 0x1D60A => array(0x63), 0x1D60B => array(0x64), - 0x1D60C => array(0x65), 0x1D60D => array(0x66), 0x1D60E => array(0x67), - 0x1D60F => array(0x68), 0x1D610 => array(0x69), 0x1D611 => array(0x6A), - 0x1D612 => array(0x6B), 0x1D613 => array(0x6C), 0x1D614 => array(0x6D), - 0x1D615 => array(0x6E), 0x1D616 => array(0x6F), 0x1D617 => array(0x70), - 0x1D618 => array(0x71), 0x1D619 => array(0x72), 0x1D61A => array(0x73), - 0x1D61B => array(0x74), 0x1D61C => array(0x75), 0x1D61D => array(0x76), - 0x1D61E => array(0x77), 0x1D61F => array(0x78), 0x1D620 => array(0x79), - 0x1D621 => array(0x7A), 0x1D622 => array(0x61), 0x1D623 => array(0x62), - 0x1D624 => array(0x63), 0x1D625 => array(0x64), 0x1D626 => array(0x65), - 0x1D627 => array(0x66), 0x1D628 => array(0x67), 0x1D629 => array(0x68), - 0x1D62A => array(0x69), 0x1D62B => array(0x6A), 0x1D62C => array(0x6B), - 0x1D62D => array(0x6C), 0x1D62E => array(0x6D), 0x1D62F => array(0x6E), - 0x1D630 => array(0x6F), 0x1D631 => array(0x70), 0x1D632 => array(0x71), - 0x1D633 => array(0x72), 0x1D634 => array(0x73), 0x1D635 => array(0x74), - 0x1D636 => array(0x75), 0x1D637 => array(0x76), 0x1D638 => array(0x77), - 0x1D639 => array(0x78), 0x1D63A => array(0x79), 0x1D63B => array(0x7A), - 0x1D63C => array(0x61), 0x1D63D => array(0x62), 0x1D63E => array(0x63), - 0x1D63F => array(0x64), 0x1D640 => array(0x65), 0x1D641 => array(0x66), - 0x1D642 => array(0x67), 0x1D643 => array(0x68), 0x1D644 => array(0x69), - 0x1D645 => array(0x6A), 0x1D646 => array(0x6B), 0x1D647 => array(0x6C), - 0x1D648 => array(0x6D), 0x1D649 => array(0x6E), 0x1D64A => array(0x6F), - 0x1D64B => array(0x70), 0x1D64C => array(0x71), 0x1D64D => array(0x72), - 0x1D64E => array(0x73), 0x1D64F => array(0x74), 0x1D650 => array(0x75), - 0x1D651 => array(0x76), 0x1D652 => array(0x77), 0x1D653 => array(0x78), - 0x1D654 => array(0x79), 0x1D655 => array(0x7A), 0x1D656 => array(0x61), - 0x1D657 => array(0x62), 0x1D658 => array(0x63), 0x1D659 => array(0x64), - 0x1D65A => array(0x65), 0x1D65B => array(0x66), 0x1D65C => array(0x67), - 0x1D65D => array(0x68), 0x1D65E => array(0x69), 0x1D65F => array(0x6A), - 0x1D660 => array(0x6B), 0x1D661 => array(0x6C), 0x1D662 => array(0x6D), - 0x1D663 => array(0x6E), 0x1D664 => array(0x6F), 0x1D665 => array(0x70), - 0x1D666 => array(0x71), 0x1D667 => array(0x72), 0x1D668 => array(0x73), - 0x1D669 => array(0x74), 0x1D66A => array(0x75), 0x1D66B => array(0x76), - 0x1D66C => array(0x77), 0x1D66D => array(0x78), 0x1D66E => array(0x79), - 0x1D66F => array(0x7A), 0x1D670 => array(0x61), 0x1D671 => array(0x62), - 0x1D672 => array(0x63), 0x1D673 => array(0x64), 0x1D674 => array(0x65), - 0x1D675 => array(0x66), 0x1D676 => array(0x67), 0x1D677 => array(0x68), - 0x1D678 => array(0x69), 0x1D679 => array(0x6A), 0x1D67A => array(0x6B), - 0x1D67B => array(0x6C), 0x1D67C => array(0x6D), 0x1D67D => array(0x6E), - 0x1D67E => array(0x6F), 0x1D67F => array(0x70), 0x1D680 => array(0x71), - 0x1D681 => array(0x72), 0x1D682 => array(0x73), 0x1D683 => array(0x74), - 0x1D684 => array(0x75), 0x1D685 => array(0x76), 0x1D686 => array(0x77), - 0x1D687 => array(0x78), 0x1D688 => array(0x79), 0x1D689 => array(0x7A), - 0x1D68A => array(0x61), 0x1D68B => array(0x62), 0x1D68C => array(0x63), - 0x1D68D => array(0x64), 0x1D68E => array(0x65), 0x1D68F => array(0x66), - 0x1D690 => array(0x67), 0x1D691 => array(0x68), 0x1D692 => array(0x69), - 0x1D693 => array(0x6A), 0x1D694 => array(0x6B), 0x1D695 => array(0x6C), - 0x1D696 => array(0x6D), 0x1D697 => array(0x6E), 0x1D698 => array(0x6F), - 0x1D699 => array(0x70), 0x1D69A => array(0x71), 0x1D69B => array(0x72), - 0x1D69C => array(0x73), 0x1D69D => array(0x74), 0x1D69E => array(0x75), - 0x1D69F => array(0x76), 0x1D6A0 => array(0x77), 0x1D6A1 => array(0x78), - 0x1D6A2 => array(0x79), 0x1D6A3 => array(0x7A), 0x1D6A4 => array(0x131), - 0x1D6A5 => array(0x237), 0x1D6A8 => array(0x3B1), 0x1D6A9 => array(0x3B2), - 0x1D6AA => array(0x3B3), 0x1D6AB => array(0x3B4), 0x1D6AC => array(0x3B5), - 0x1D6AD => array(0x3B6), 0x1D6AE => array(0x3B7), 0x1D6AF => array(0x3B8), - 0x1D6B0 => array(0x3B9), 0x1D6B1 => array(0x3BA), 0x1D6B2 => array(0x3BB), - 0x1D6B3 => array(0x3BC), 0x1D6B4 => array(0x3BD), 0x1D6B5 => array(0x3BE), - 0x1D6B6 => array(0x3BF), 0x1D6B7 => array(0x3C0), 0x1D6B8 => array(0x3C1), - 0x1D6B9 => array(0x3B8), 0x1D6BA => array(0x3C3), 0x1D6BB => array(0x3C4), - 0x1D6BC => array(0x3C5), 0x1D6BD => array(0x3C6), 0x1D6BE => array(0x3C7), - 0x1D6BF => array(0x3C8), 0x1D6C0 => array(0x3C9), 0x1D6C1 => array(0x2207), - 0x1D6C2 => array(0x3B1), 0x1D6C3 => array(0x3B2), 0x1D6C4 => array(0x3B3), - 0x1D6C5 => array(0x3B4), 0x1D6C6 => array(0x3B5), 0x1D6C7 => array(0x3B6), - 0x1D6C8 => array(0x3B7), 0x1D6C9 => array(0x3B8), 0x1D6CA => array(0x3B9), - 0x1D6CB => array(0x3BA), 0x1D6CC => array(0x3BB), 0x1D6CD => array(0x3BC), - 0x1D6CE => array(0x3BD), 0x1D6CF => array(0x3BE), 0x1D6D0 => array(0x3BF), - 0x1D6D1 => array(0x3C0), 0x1D6D2 => array(0x3C1), 0x1D6D3 => array(0x3C3), - 0x1D6D4 => array(0x3C3), 0x1D6D5 => array(0x3C4), 0x1D6D6 => array(0x3C5), - 0x1D6D7 => array(0x3C6), 0x1D6D8 => array(0x3C7), 0x1D6D9 => array(0x3C8), - 0x1D6DA => array(0x3C9), 0x1D6DB => array(0x2202), 0x1D6DC => array(0x3B5), - 0x1D6DD => array(0x3B8), 0x1D6DE => array(0x3BA), 0x1D6DF => array(0x3C6), - 0x1D6E0 => array(0x3C1), 0x1D6E1 => array(0x3C0), 0x1D6E2 => array(0x3B1), - 0x1D6E3 => array(0x3B2), 0x1D6E4 => array(0x3B3), 0x1D6E5 => array(0x3B4), - 0x1D6E6 => array(0x3B5), 0x1D6E7 => array(0x3B6), 0x1D6E8 => array(0x3B7), - 0x1D6E9 => array(0x3B8), 0x1D6EA => array(0x3B9), 0x1D6EB => array(0x3BA), - 0x1D6EC => array(0x3BB), 0x1D6ED => array(0x3BC), 0x1D6EE => array(0x3BD), - 0x1D6EF => array(0x3BE), 0x1D6F0 => array(0x3BF), 0x1D6F1 => array(0x3C0), - 0x1D6F2 => array(0x3C1), 0x1D6F3 => array(0x3B8), 0x1D6F4 => array(0x3C3), - 0x1D6F5 => array(0x3C4), 0x1D6F6 => array(0x3C5), 0x1D6F7 => array(0x3C6), - 0x1D6F8 => array(0x3C7), 0x1D6F9 => array(0x3C8), 0x1D6FA => array(0x3C9), - 0x1D6FB => array(0x2207), 0x1D6FC => array(0x3B1), 0x1D6FD => array(0x3B2), - 0x1D6FE => array(0x3B3), 0x1D6FF => array(0x3B4), 0x1D700 => array(0x3B5), - 0x1D701 => array(0x3B6), 0x1D702 => array(0x3B7), 0x1D703 => array(0x3B8), - 0x1D704 => array(0x3B9), 0x1D705 => array(0x3BA), 0x1D706 => array(0x3BB), - 0x1D707 => array(0x3BC), 0x1D708 => array(0x3BD), 0x1D709 => array(0x3BE), - 0x1D70A => array(0x3BF), 0x1D70B => array(0x3C0), 0x1D70C => array(0x3C1), - 0x1D70D => array(0x3C3), 0x1D70E => array(0x3C3), 0x1D70F => array(0x3C4), - 0x1D710 => array(0x3C5), 0x1D711 => array(0x3C6), 0x1D712 => array(0x3C7), - 0x1D713 => array(0x3C8), 0x1D714 => array(0x3C9), 0x1D715 => array(0x2202), - 0x1D716 => array(0x3B5), 0x1D717 => array(0x3B8), 0x1D718 => array(0x3BA), - 0x1D719 => array(0x3C6), 0x1D71A => array(0x3C1), 0x1D71B => array(0x3C0), - 0x1D71C => array(0x3B1), 0x1D71D => array(0x3B2), 0x1D71E => array(0x3B3), - 0x1D71F => array(0x3B4), 0x1D720 => array(0x3B5), 0x1D721 => array(0x3B6), - 0x1D722 => array(0x3B7), 0x1D723 => array(0x3B8), 0x1D724 => array(0x3B9), - 0x1D725 => array(0x3BA), 0x1D726 => array(0x3BB), 0x1D727 => array(0x3BC), - 0x1D728 => array(0x3BD), 0x1D729 => array(0x3BE), 0x1D72A => array(0x3BF), - 0x1D72B => array(0x3C0), 0x1D72C => array(0x3C1), 0x1D72D => array(0x3B8), - 0x1D72E => array(0x3C3), 0x1D72F => array(0x3C4), 0x1D730 => array(0x3C5), - 0x1D731 => array(0x3C6), 0x1D732 => array(0x3C7), 0x1D733 => array(0x3C8), - 0x1D734 => array(0x3C9), 0x1D735 => array(0x2207), 0x1D736 => array(0x3B1), - 0x1D737 => array(0x3B2), 0x1D738 => array(0x3B3), 0x1D739 => array(0x3B4), - 0x1D73A => array(0x3B5), 0x1D73B => array(0x3B6), 0x1D73C => array(0x3B7), - 0x1D73D => array(0x3B8), 0x1D73E => array(0x3B9), 0x1D73F => array(0x3BA), - 0x1D740 => array(0x3BB), 0x1D741 => array(0x3BC), 0x1D742 => array(0x3BD), - 0x1D743 => array(0x3BE), 0x1D744 => array(0x3BF), 0x1D745 => array(0x3C0), - 0x1D746 => array(0x3C1), 0x1D747 => array(0x3C3), 0x1D748 => array(0x3C3), - 0x1D749 => array(0x3C4), 0x1D74A => array(0x3C5), 0x1D74B => array(0x3C6), - 0x1D74C => array(0x3C7), 0x1D74D => array(0x3C8), 0x1D74E => array(0x3C9), - 0x1D74F => array(0x2202), 0x1D750 => array(0x3B5), 0x1D751 => array(0x3B8), - 0x1D752 => array(0x3BA), 0x1D753 => array(0x3C6), 0x1D754 => array(0x3C1), - 0x1D755 => array(0x3C0), 0x1D756 => array(0x3B1), 0x1D757 => array(0x3B2), - 0x1D758 => array(0x3B3), 0x1D759 => array(0x3B4), 0x1D75A => array(0x3B5), - 0x1D75B => array(0x3B6), 0x1D75C => array(0x3B7), 0x1D75D => array(0x3B8), - 0x1D75E => array(0x3B9), 0x1D75F => array(0x3BA), 0x1D760 => array(0x3BB), - 0x1D761 => array(0x3BC), 0x1D762 => array(0x3BD), 0x1D763 => array(0x3BE), - 0x1D764 => array(0x3BF), 0x1D765 => array(0x3C0), 0x1D766 => array(0x3C1), - 0x1D767 => array(0x3B8), 0x1D768 => array(0x3C3), 0x1D769 => array(0x3C4), - 0x1D76A => array(0x3C5), 0x1D76B => array(0x3C6), 0x1D76C => array(0x3C7), - 0x1D76D => array(0x3C8), 0x1D76E => array(0x3C9), 0x1D76F => array(0x2207), - 0x1D770 => array(0x3B1), 0x1D771 => array(0x3B2), 0x1D772 => array(0x3B3), - 0x1D773 => array(0x3B4), 0x1D774 => array(0x3B5), 0x1D775 => array(0x3B6), - 0x1D776 => array(0x3B7), 0x1D777 => array(0x3B8), 0x1D778 => array(0x3B9), - 0x1D779 => array(0x3BA), 0x1D77A => array(0x3BB), 0x1D77B => array(0x3BC), - 0x1D77C => array(0x3BD), 0x1D77D => array(0x3BE), 0x1D77E => array(0x3BF), - 0x1D77F => array(0x3C0), 0x1D780 => array(0x3C1), 0x1D781 => array(0x3C3), - 0x1D782 => array(0x3C3), 0x1D783 => array(0x3C4), 0x1D784 => array(0x3C5), - 0x1D785 => array(0x3C6), 0x1D786 => array(0x3C7), 0x1D787 => array(0x3C8), - 0x1D788 => array(0x3C9), 0x1D789 => array(0x2202), 0x1D78A => array(0x3B5), - 0x1D78B => array(0x3B8), 0x1D78C => array(0x3BA), 0x1D78D => array(0x3C6), - 0x1D78E => array(0x3C1), 0x1D78F => array(0x3C0), 0x1D790 => array(0x3B1), - 0x1D791 => array(0x3B2), 0x1D792 => array(0x3B3), 0x1D793 => array(0x3B4), - 0x1D794 => array(0x3B5), 0x1D795 => array(0x3B6), 0x1D796 => array(0x3B7), - 0x1D797 => array(0x3B8), 0x1D798 => array(0x3B9), 0x1D799 => array(0x3BA), - 0x1D79A => array(0x3BB), 0x1D79B => array(0x3BC), 0x1D79C => array(0x3BD), - 0x1D79D => array(0x3BE), 0x1D79E => array(0x3BF), 0x1D79F => array(0x3C0), - 0x1D7A0 => array(0x3C1), 0x1D7A1 => array(0x3B8), 0x1D7A2 => array(0x3C3), - 0x1D7A3 => array(0x3C4), 0x1D7A4 => array(0x3C5), 0x1D7A5 => array(0x3C6), - 0x1D7A6 => array(0x3C7), 0x1D7A7 => array(0x3C8), 0x1D7A8 => array(0x3C9), - 0x1D7A9 => array(0x2207), 0x1D7AA => array(0x3B1), 0x1D7AB => array(0x3B2), - 0x1D7AC => array(0x3B3), 0x1D7AD => array(0x3B4), 0x1D7AE => array(0x3B5), - 0x1D7AF => array(0x3B6), 0x1D7B0 => array(0x3B7), 0x1D7B1 => array(0x3B8), - 0x1D7B2 => array(0x3B9), 0x1D7B3 => array(0x3BA), 0x1D7B4 => array(0x3BB), - 0x1D7B5 => array(0x3BC), 0x1D7B6 => array(0x3BD), 0x1D7B7 => array(0x3BE), - 0x1D7B8 => array(0x3BF), 0x1D7B9 => array(0x3C0), 0x1D7BA => array(0x3C1), - 0x1D7BB => array(0x3C3), 0x1D7BC => array(0x3C3), 0x1D7BD => array(0x3C4), - 0x1D7BE => array(0x3C5), 0x1D7BF => array(0x3C6), 0x1D7C0 => array(0x3C7), - 0x1D7C1 => array(0x3C8), 0x1D7C2 => array(0x3C9), 0x1D7C3 => array(0x2202), - 0x1D7C4 => array(0x3B5), 0x1D7C5 => array(0x3B8), 0x1D7C6 => array(0x3BA), - 0x1D7C7 => array(0x3C6), 0x1D7C8 => array(0x3C1), 0x1D7C9 => array(0x3C0), - 0x1D7CA => array(0x3DD), 0x1D7CB => array(0x3DD), 0x1D7CE => array(0x30), - 0x1D7CF => array(0x31), 0x1D7D0 => array(0x32), 0x1D7D1 => array(0x33), - 0x1D7D2 => array(0x34), 0x1D7D3 => array(0x35), 0x1D7D4 => array(0x36), - 0x1D7D5 => array(0x37), 0x1D7D6 => array(0x38), 0x1D7D7 => array(0x39), - 0x1D7D8 => array(0x30), 0x1D7D9 => array(0x31), 0x1D7DA => array(0x32), - 0x1D7DB => array(0x33), 0x1D7DC => array(0x34), 0x1D7DD => array(0x35), - 0x1D7DE => array(0x36), 0x1D7DF => array(0x37), 0x1D7E0 => array(0x38), - 0x1D7E1 => array(0x39), 0x1D7E2 => array(0x30), 0x1D7E3 => array(0x31), - 0x1D7E4 => array(0x32), 0x1D7E5 => array(0x33), 0x1D7E6 => array(0x34), - 0x1D7E7 => array(0x35), 0x1D7E8 => array(0x36), 0x1D7E9 => array(0x37), - 0x1D7EA => array(0x38), 0x1D7EB => array(0x39), 0x1D7EC => array(0x30), - 0x1D7ED => array(0x31), 0x1D7EE => array(0x32), 0x1D7EF => array(0x33), - 0x1D7F0 => array(0x34), 0x1D7F1 => array(0x35), 0x1D7F2 => array(0x36), - 0x1D7F3 => array(0x37), 0x1D7F4 => array(0x38), 0x1D7F5 => array(0x39), - 0x1D7F6 => array(0x30), 0x1D7F7 => array(0x31), 0x1D7F8 => array(0x32), - 0x1D7F9 => array(0x33), 0x1D7FA => array(0x34), 0x1D7FB => array(0x35), - 0x1D7FC => array(0x36), 0x1D7FD => array(0x37), 0x1D7FE => array(0x38), - 0x1D7FF => array(0x39), 0x1EE00 => array(0x627), 0x1EE01 => array(0x628), - 0x1EE02 => array(0x62C), 0x1EE03 => array(0x62F), 0x1EE05 => array(0x648), - 0x1EE06 => array(0x632), 0x1EE07 => array(0x62D), 0x1EE08 => array(0x637), - 0x1EE09 => array(0x64A), 0x1EE0A => array(0x643), 0x1EE0B => array(0x644), - 0x1EE0C => array(0x645), 0x1EE0D => array(0x646), 0x1EE0E => array(0x633), - 0x1EE0F => array(0x639), 0x1EE10 => array(0x641), 0x1EE11 => array(0x635), - 0x1EE12 => array(0x642), 0x1EE13 => array(0x631), 0x1EE14 => array(0x634), - 0x1EE15 => array(0x62A), 0x1EE16 => array(0x62B), 0x1EE17 => array(0x62E), - 0x1EE18 => array(0x630), 0x1EE19 => array(0x636), 0x1EE1A => array(0x638), - 0x1EE1B => array(0x63A), 0x1EE1C => array(0x66E), 0x1EE1D => array(0x6BA), - 0x1EE1E => array(0x6A1), 0x1EE1F => array(0x66F), 0x1EE21 => array(0x628), - 0x1EE22 => array(0x62C), 0x1EE24 => array(0x647), 0x1EE27 => array(0x62D), - 0x1EE29 => array(0x64A), 0x1EE2A => array(0x643), 0x1EE2B => array(0x644), - 0x1EE2C => array(0x645), 0x1EE2D => array(0x646), 0x1EE2E => array(0x633), - 0x1EE2F => array(0x639), 0x1EE30 => array(0x641), 0x1EE31 => array(0x635), - 0x1EE32 => array(0x642), 0x1EE34 => array(0x634), 0x1EE35 => array(0x62A), - 0x1EE36 => array(0x62B), 0x1EE37 => array(0x62E), 0x1EE39 => array(0x636), - 0x1EE3B => array(0x63A), 0x1EE42 => array(0x62C), 0x1EE47 => array(0x62D), - 0x1EE49 => array(0x64A), 0x1EE4B => array(0x644), 0x1EE4D => array(0x646), - 0x1EE4E => array(0x633), 0x1EE4F => array(0x639), 0x1EE51 => array(0x635), - 0x1EE52 => array(0x642), 0x1EE54 => array(0x634), 0x1EE57 => array(0x62E), - 0x1EE59 => array(0x636), 0x1EE5B => array(0x63A), 0x1EE5D => array(0x6BA), - 0x1EE5F => array(0x66F), 0x1EE61 => array(0x628), 0x1EE62 => array(0x62C), - 0x1EE64 => array(0x647), 0x1EE67 => array(0x62D), 0x1EE68 => array(0x637), - 0x1EE69 => array(0x64A), 0x1EE6A => array(0x643), 0x1EE6C => array(0x645), - 0x1EE6D => array(0x646), 0x1EE6E => array(0x633), 0x1EE6F => array(0x639), - 0x1EE70 => array(0x641), 0x1EE71 => array(0x635), 0x1EE72 => array(0x642), - 0x1EE74 => array(0x634), 0x1EE75 => array(0x62A), 0x1EE76 => array(0x62B), - 0x1EE77 => array(0x62E), 0x1EE79 => array(0x636), 0x1EE7A => array(0x638), - 0x1EE7B => array(0x63A), 0x1EE7C => array(0x66E), 0x1EE7E => array(0x6A1), - 0x1EE80 => array(0x627), 0x1EE81 => array(0x628), 0x1EE82 => array(0x62C), - 0x1EE83 => array(0x62F), 0x1EE84 => array(0x647), 0x1EE85 => array(0x648), - 0x1EE86 => array(0x632), 0x1EE87 => array(0x62D), 0x1EE88 => array(0x637), - 0x1EE89 => array(0x64A), 0x1EE8B => array(0x644), 0x1EE8C => array(0x645), - 0x1EE8D => array(0x646), 0x1EE8E => array(0x633), 0x1EE8F => array(0x639), - 0x1EE90 => array(0x641), 0x1EE91 => array(0x635), 0x1EE92 => array(0x642), - 0x1EE93 => array(0x631), 0x1EE94 => array(0x634), 0x1EE95 => array(0x62A), - 0x1EE96 => array(0x62B), 0x1EE97 => array(0x62E), 0x1EE98 => array(0x630), - 0x1EE99 => array(0x636), 0x1EE9A => array(0x638), 0x1EE9B => array(0x63A), - 0x1EEA1 => array(0x628), 0x1EEA2 => array(0x62C), 0x1EEA3 => array(0x62F), - 0x1EEA5 => array(0x648), 0x1EEA6 => array(0x632), 0x1EEA7 => array(0x62D), - 0x1EEA8 => array(0x637), 0x1EEA9 => array(0x64A), 0x1EEAB => array(0x644), - 0x1EEAC => array(0x645), 0x1EEAD => array(0x646), 0x1EEAE => array(0x633), - 0x1EEAF => array(0x639), 0x1EEB0 => array(0x641), 0x1EEB1 => array(0x635), - 0x1EEB2 => array(0x642), 0x1EEB3 => array(0x631), 0x1EEB4 => array(0x634), - 0x1EEB5 => array(0x62A), 0x1EEB6 => array(0x62B), 0x1EEB7 => array(0x62E), - 0x1EEB8 => array(0x630), 0x1EEB9 => array(0x636), 0x1EEBA => array(0x638), - 0x1EEBB => array(0x63A), 0x1F12A => array(0x3014, 0x73, 0x3015), 0x1F12B => array(0x63), - 0x1F12C => array(0x72), 0x1F12D => array(0x63, 0x64), 0x1F12E => array(0x77, 0x7A), - 0x1F130 => array(0x61), 0x1F131 => array(0x62), 0x1F132 => array(0x63), - 0x1F133 => array(0x64), 0x1F134 => array(0x65), 0x1F135 => array(0x66), - 0x1F136 => array(0x67), 0x1F137 => array(0x68), 0x1F138 => array(0x69), - 0x1F139 => array(0x6A), 0x1F13A => array(0x6B), 0x1F13B => array(0x6C), - 0x1F13C => array(0x6D), 0x1F13D => array(0x6E), 0x1F13E => array(0x6F), - 0x1F13F => array(0x70), 0x1F140 => array(0x71), 0x1F141 => array(0x72), - 0x1F142 => array(0x73), 0x1F143 => array(0x74), 0x1F144 => array(0x75), - 0x1F145 => array(0x76), 0x1F146 => array(0x77), 0x1F147 => array(0x78), - 0x1F148 => array(0x79), 0x1F149 => array(0x7A), 0x1F14A => array(0x68, 0x76), - 0x1F14B => array(0x6D, 0x76), 0x1F14C => array(0x73, 0x64), 0x1F14D => array(0x73, 0x73), - 0x1F14E => array(0x70, 0x70, 0x76), 0x1F14F => array(0x77, 0x63), 0x1F16A => array(0x6D, 0x63), - 0x1F16B => array(0x6D, 0x64), 0x1F190 => array(0x64, 0x6A), 0x1F200 => array(0x307B, 0x304B), - 0x1F201 => array(0x30B3, 0x30B3), 0x1F202 => array(0x30B5), 0x1F210 => array(0x624B), - 0x1F211 => array(0x5B57), 0x1F212 => array(0x53CC), 0x1F213 => array(0x30C7), - 0x1F214 => array(0x4E8C), 0x1F215 => array(0x591A), 0x1F216 => array(0x89E3), - 0x1F217 => array(0x5929), 0x1F218 => array(0x4EA4), 0x1F219 => array(0x6620), - 0x1F21A => array(0x7121), 0x1F21B => array(0x6599), 0x1F21C => array(0x524D), - 0x1F21D => array(0x5F8C), 0x1F21E => array(0x518D), 0x1F21F => array(0x65B0), - 0x1F220 => array(0x521D), 0x1F221 => array(0x7D42), 0x1F222 => array(0x751F), - 0x1F223 => array(0x8CA9), 0x1F224 => array(0x58F0), 0x1F225 => array(0x5439), - 0x1F226 => array(0x6F14), 0x1F227 => array(0x6295), 0x1F228 => array(0x6355), - 0x1F229 => array(0x4E00), 0x1F22A => array(0x4E09), 0x1F22B => array(0x904A), - 0x1F22C => array(0x5DE6), 0x1F22D => array(0x4E2D), 0x1F22E => array(0x53F3), - 0x1F22F => array(0x6307), 0x1F230 => array(0x8D70), 0x1F231 => array(0x6253), - 0x1F232 => array(0x7981), 0x1F233 => array(0x7A7A), 0x1F234 => array(0x5408), - 0x1F235 => array(0x6E80), 0x1F236 => array(0x6709), 0x1F237 => array(0x6708), - 0x1F238 => array(0x7533), 0x1F239 => array(0x5272), 0x1F23A => array(0x55B6), - 0x1F240 => array(0x3014, 0x672C, 0x3015), 0x1F241 => array(0x3014, 0x4E09, 0x3015), 0x1F242 => array(0x3014, 0x4E8C, 0x3015), - 0x1F243 => array(0x3014, 0x5B89, 0x3015), 0x1F244 => array(0x3014, 0x70B9, 0x3015), 0x1F245 => array(0x3014, 0x6253, 0x3015), - 0x1F246 => array(0x3014, 0x76D7, 0x3015), 0x1F247 => array(0x3014, 0x52DD, 0x3015), 0x1F248 => array(0x3014, 0x6557, 0x3015), - 0x1F250 => array(0x5F97), 0x1F251 => array(0x53EF), 0x2F800 => array(0x4E3D), - 0x2F801 => array(0x4E38), 0x2F802 => array(0x4E41), 0x2F803 => array(0x20122), - 0x2F804 => array(0x4F60), 0x2F805 => array(0x4FAE), 0x2F806 => array(0x4FBB), - 0x2F807 => array(0x5002), 0x2F808 => array(0x507A), 0x2F809 => array(0x5099), - 0x2F80A => array(0x50E7), 0x2F80B => array(0x50CF), 0x2F80C => array(0x349E), - 0x2F80D => array(0x2063A), 0x2F80E => array(0x514D), 0x2F80F => array(0x5154), - 0x2F810 => array(0x5164), 0x2F811 => array(0x5177), 0x2F812 => array(0x2051C), - 0x2F813 => array(0x34B9), 0x2F814 => array(0x5167), 0x2F815 => array(0x518D), - 0x2F816 => array(0x2054B), 0x2F817 => array(0x5197), 0x2F818 => array(0x51A4), - 0x2F819 => array(0x4ECC), 0x2F81A => array(0x51AC), 0x2F81B => array(0x51B5), - 0x2F81C => array(0x291DF), 0x2F81D => array(0x51F5), 0x2F81E => array(0x5203), - 0x2F81F => array(0x34DF), 0x2F820 => array(0x523B), 0x2F821 => array(0x5246), - 0x2F822 => array(0x5272), 0x2F823 => array(0x5277), 0x2F824 => array(0x3515), - 0x2F825 => array(0x52C7), 0x2F826 => array(0x52C9), 0x2F827 => array(0x52E4), - 0x2F828 => array(0x52FA), 0x2F829 => array(0x5305), 0x2F82A => array(0x5306), - 0x2F82B => array(0x5317), 0x2F82C => array(0x5349), 0x2F82D => array(0x5351), - 0x2F82E => array(0x535A), 0x2F82F => array(0x5373), 0x2F830 => array(0x537D), - 0x2F831 => array(0x537F), 0x2F832 => array(0x537F), 0x2F833 => array(0x537F), - 0x2F834 => array(0x20A2C), 0x2F835 => array(0x7070), 0x2F836 => array(0x53CA), - 0x2F837 => array(0x53DF), 0x2F838 => array(0x20B63), 0x2F839 => array(0x53EB), - 0x2F83A => array(0x53F1), 0x2F83B => array(0x5406), 0x2F83C => array(0x549E), - 0x2F83D => array(0x5438), 0x2F83E => array(0x5448), 0x2F83F => array(0x5468), - 0x2F840 => array(0x54A2), 0x2F841 => array(0x54F6), 0x2F842 => array(0x5510), - 0x2F843 => array(0x5553), 0x2F844 => array(0x5563), 0x2F845 => array(0x5584), - 0x2F846 => array(0x5584), 0x2F847 => array(0x5599), 0x2F848 => array(0x55AB), - 0x2F849 => array(0x55B3), 0x2F84A => array(0x55C2), 0x2F84B => array(0x5716), - 0x2F84C => array(0x5606), 0x2F84D => array(0x5717), 0x2F84E => array(0x5651), - 0x2F84F => array(0x5674), 0x2F850 => array(0x5207), 0x2F851 => array(0x58EE), - 0x2F852 => array(0x57CE), 0x2F853 => array(0x57F4), 0x2F854 => array(0x580D), - 0x2F855 => array(0x578B), 0x2F856 => array(0x5832), 0x2F857 => array(0x5831), - 0x2F858 => array(0x58AC), 0x2F859 => array(0x214E4), 0x2F85A => array(0x58F2), - 0x2F85B => array(0x58F7), 0x2F85C => array(0x5906), 0x2F85D => array(0x591A), - 0x2F85E => array(0x5922), 0x2F85F => array(0x5962), 0x2F860 => array(0x216A8), - 0x2F861 => array(0x216EA), 0x2F862 => array(0x59EC), 0x2F863 => array(0x5A1B), - 0x2F864 => array(0x5A27), 0x2F865 => array(0x59D8), 0x2F866 => array(0x5A66), - 0x2F867 => array(0x36EE), 0x2F869 => array(0x5B08), 0x2F86A => array(0x5B3E), - 0x2F86B => array(0x5B3E), 0x2F86C => array(0x219C8), 0x2F86D => array(0x5BC3), - 0x2F86E => array(0x5BD8), 0x2F86F => array(0x5BE7), 0x2F870 => array(0x5BF3), - 0x2F871 => array(0x21B18), 0x2F872 => array(0x5BFF), 0x2F873 => array(0x5C06), - 0x2F875 => array(0x5C22), 0x2F876 => array(0x3781), 0x2F877 => array(0x5C60), - 0x2F878 => array(0x5C6E), 0x2F879 => array(0x5CC0), 0x2F87A => array(0x5C8D), - 0x2F87B => array(0x21DE4), 0x2F87C => array(0x5D43), 0x2F87D => array(0x21DE6), - 0x2F87E => array(0x5D6E), 0x2F87F => array(0x5D6B), 0x2F880 => array(0x5D7C), - 0x2F881 => array(0x5DE1), 0x2F882 => array(0x5DE2), 0x2F883 => array(0x382F), - 0x2F884 => array(0x5DFD), 0x2F885 => array(0x5E28), 0x2F886 => array(0x5E3D), - 0x2F887 => array(0x5E69), 0x2F888 => array(0x3862), 0x2F889 => array(0x22183), - 0x2F88A => array(0x387C), 0x2F88B => array(0x5EB0), 0x2F88C => array(0x5EB3), - 0x2F88D => array(0x5EB6), 0x2F88E => array(0x5ECA), 0x2F88F => array(0x2A392), - 0x2F890 => array(0x5EFE), 0x2F891 => array(0x22331), 0x2F892 => array(0x22331), - 0x2F893 => array(0x8201), 0x2F894 => array(0x5F22), 0x2F895 => array(0x5F22), - 0x2F896 => array(0x38C7), 0x2F897 => array(0x232B8), 0x2F898 => array(0x261DA), - 0x2F899 => array(0x5F62), 0x2F89A => array(0x5F6B), 0x2F89B => array(0x38E3), - 0x2F89C => array(0x5F9A), 0x2F89D => array(0x5FCD), 0x2F89E => array(0x5FD7), - 0x2F89F => array(0x5FF9), 0x2F8A0 => array(0x6081), 0x2F8A1 => array(0x393A), - 0x2F8A2 => array(0x391C), 0x2F8A3 => array(0x6094), 0x2F8A4 => array(0x226D4), - 0x2F8A5 => array(0x60C7), 0x2F8A6 => array(0x6148), 0x2F8A7 => array(0x614C), - 0x2F8A8 => array(0x614E), 0x2F8A9 => array(0x614C), 0x2F8AA => array(0x617A), - 0x2F8AB => array(0x618E), 0x2F8AC => array(0x61B2), 0x2F8AD => array(0x61A4), - 0x2F8AE => array(0x61AF), 0x2F8AF => array(0x61DE), 0x2F8B0 => array(0x61F2), - 0x2F8B1 => array(0x61F6), 0x2F8B2 => array(0x6210), 0x2F8B3 => array(0x621B), - 0x2F8B4 => array(0x625D), 0x2F8B5 => array(0x62B1), 0x2F8B6 => array(0x62D4), - 0x2F8B7 => array(0x6350), 0x2F8B8 => array(0x22B0C), 0x2F8B9 => array(0x633D), - 0x2F8BA => array(0x62FC), 0x2F8BB => array(0x6368), 0x2F8BC => array(0x6383), - 0x2F8BD => array(0x63E4), 0x2F8BE => array(0x22BF1), 0x2F8BF => array(0x6422), - 0x2F8C0 => array(0x63C5), 0x2F8C1 => array(0x63A9), 0x2F8C2 => array(0x3A2E), - 0x2F8C3 => array(0x6469), 0x2F8C4 => array(0x647E), 0x2F8C5 => array(0x649D), - 0x2F8C6 => array(0x6477), 0x2F8C7 => array(0x3A6C), 0x2F8C8 => array(0x654F), - 0x2F8C9 => array(0x656C), 0x2F8CA => array(0x2300A), 0x2F8CB => array(0x65E3), - 0x2F8CC => array(0x66F8), 0x2F8CD => array(0x6649), 0x2F8CE => array(0x3B19), - 0x2F8CF => array(0x6691), 0x2F8D0 => array(0x3B08), 0x2F8D1 => array(0x3AE4), - 0x2F8D2 => array(0x5192), 0x2F8D3 => array(0x5195), 0x2F8D4 => array(0x6700), - 0x2F8D5 => array(0x669C), 0x2F8D6 => array(0x80AD), 0x2F8D7 => array(0x43D9), - 0x2F8D8 => array(0x6717), 0x2F8D9 => array(0x671B), 0x2F8DA => array(0x6721), - 0x2F8DB => array(0x675E), 0x2F8DC => array(0x6753), 0x2F8DD => array(0x233C3), - 0x2F8DE => array(0x3B49), 0x2F8DF => array(0x67FA), 0x2F8E0 => array(0x6785), - 0x2F8E1 => array(0x6852), 0x2F8E2 => array(0x6885), 0x2F8E3 => array(0x2346D), - 0x2F8E4 => array(0x688E), 0x2F8E5 => array(0x681F), 0x2F8E6 => array(0x6914), - 0x2F8E7 => array(0x3B9D), 0x2F8E8 => array(0x6942), 0x2F8E9 => array(0x69A3), - 0x2F8EA => array(0x69EA), 0x2F8EB => array(0x6AA8), 0x2F8EC => array(0x236A3), - 0x2F8ED => array(0x6ADB), 0x2F8EE => array(0x3C18), 0x2F8EF => array(0x6B21), - 0x2F8F0 => array(0x238A7), 0x2F8F1 => array(0x6B54), 0x2F8F2 => array(0x3C4E), - 0x2F8F3 => array(0x6B72), 0x2F8F4 => array(0x6B9F), 0x2F8F5 => array(0x6BBA), - 0x2F8F6 => array(0x6BBB), 0x2F8F7 => array(0x23A8D), 0x2F8F8 => array(0x21D0B), - 0x2F8F9 => array(0x23AFA), 0x2F8FA => array(0x6C4E), 0x2F8FB => array(0x23CBC), - 0x2F8FC => array(0x6CBF), 0x2F8FD => array(0x6CCD), 0x2F8FE => array(0x6C67), - 0x2F8FF => array(0x6D16), 0x2F900 => array(0x6D3E), 0x2F901 => array(0x6D77), - 0x2F902 => array(0x6D41), 0x2F903 => array(0x6D69), 0x2F904 => array(0x6D78), - 0x2F905 => array(0x6D85), 0x2F906 => array(0x23D1E), 0x2F907 => array(0x6D34), - 0x2F908 => array(0x6E2F), 0x2F909 => array(0x6E6E), 0x2F90A => array(0x3D33), - 0x2F90B => array(0x6ECB), 0x2F90C => array(0x6EC7), 0x2F90D => array(0x23ED1), - 0x2F90E => array(0x6DF9), 0x2F90F => array(0x6F6E), 0x2F910 => array(0x23F5E), - 0x2F911 => array(0x23F8E), 0x2F912 => array(0x6FC6), 0x2F913 => array(0x7039), - 0x2F914 => array(0x701E), 0x2F915 => array(0x701B), 0x2F916 => array(0x3D96), - 0x2F917 => array(0x704A), 0x2F918 => array(0x707D), 0x2F919 => array(0x7077), - 0x2F91A => array(0x70AD), 0x2F91B => array(0x20525), 0x2F91C => array(0x7145), - 0x2F91D => array(0x24263), 0x2F91E => array(0x719C), 0x2F920 => array(0x7228), - 0x2F921 => array(0x7235), 0x2F922 => array(0x7250), 0x2F923 => array(0x24608), - 0x2F924 => array(0x7280), 0x2F925 => array(0x7295), 0x2F926 => array(0x24735), - 0x2F927 => array(0x24814), 0x2F928 => array(0x737A), 0x2F929 => array(0x738B), - 0x2F92A => array(0x3EAC), 0x2F92B => array(0x73A5), 0x2F92C => array(0x3EB8), - 0x2F92D => array(0x3EB8), 0x2F92E => array(0x7447), 0x2F92F => array(0x745C), - 0x2F930 => array(0x7471), 0x2F931 => array(0x7485), 0x2F932 => array(0x74CA), - 0x2F933 => array(0x3F1B), 0x2F934 => array(0x7524), 0x2F935 => array(0x24C36), - 0x2F936 => array(0x753E), 0x2F937 => array(0x24C92), 0x2F938 => array(0x7570), - 0x2F939 => array(0x2219F), 0x2F93A => array(0x7610), 0x2F93B => array(0x24FA1), - 0x2F93C => array(0x24FB8), 0x2F93D => array(0x25044), 0x2F93E => array(0x3FFC), - 0x2F93F => array(0x4008), 0x2F940 => array(0x76F4), 0x2F941 => array(0x250F3), - 0x2F942 => array(0x250F2), 0x2F943 => array(0x25119), 0x2F944 => array(0x25133), - 0x2F945 => array(0x771E), 0x2F946 => array(0x771F), 0x2F947 => array(0x771F), - 0x2F948 => array(0x774A), 0x2F949 => array(0x4039), 0x2F94A => array(0x778B), - 0x2F94B => array(0x4046), 0x2F94C => array(0x4096), 0x2F94D => array(0x2541D), - 0x2F94E => array(0x784E), 0x2F94F => array(0x788C), 0x2F950 => array(0x78CC), - 0x2F951 => array(0x40E3), 0x2F952 => array(0x25626), 0x2F953 => array(0x7956), - 0x2F954 => array(0x2569A), 0x2F955 => array(0x256C5), 0x2F956 => array(0x798F), - 0x2F957 => array(0x79EB), 0x2F958 => array(0x412F), 0x2F959 => array(0x7A40), - 0x2F95A => array(0x7A4A), 0x2F95B => array(0x7A4F), 0x2F95C => array(0x2597C), - 0x2F95D => array(0x25AA7), 0x2F95E => array(0x25AA7), 0x2F960 => array(0x4202), - 0x2F961 => array(0x25BAB), 0x2F962 => array(0x7BC6), 0x2F963 => array(0x7BC9), - 0x2F964 => array(0x4227), 0x2F965 => array(0x25C80), 0x2F966 => array(0x7CD2), - 0x2F967 => array(0x42A0), 0x2F968 => array(0x7CE8), 0x2F969 => array(0x7CE3), - 0x2F96A => array(0x7D00), 0x2F96B => array(0x25F86), 0x2F96C => array(0x7D63), - 0x2F96D => array(0x4301), 0x2F96E => array(0x7DC7), 0x2F96F => array(0x7E02), - 0x2F970 => array(0x7E45), 0x2F971 => array(0x4334), 0x2F972 => array(0x26228), - 0x2F973 => array(0x26247), 0x2F974 => array(0x4359), 0x2F975 => array(0x262D9), - 0x2F976 => array(0x7F7A), 0x2F977 => array(0x2633E), 0x2F978 => array(0x7F95), - 0x2F979 => array(0x7FFA), 0x2F97A => array(0x8005), 0x2F97B => array(0x264DA), - 0x2F97C => array(0x26523), 0x2F97D => array(0x8060), 0x2F97E => array(0x265A8), - 0x2F97F => array(0x8070), 0x2F980 => array(0x2335F), 0x2F981 => array(0x43D5), - 0x2F982 => array(0x80B2), 0x2F983 => array(0x8103), 0x2F984 => array(0x440B), - 0x2F985 => array(0x813E), 0x2F986 => array(0x5AB5), 0x2F987 => array(0x267A7), - 0x2F988 => array(0x267B5), 0x2F989 => array(0x23393), 0x2F98A => array(0x2339C), - 0x2F98B => array(0x8201), 0x2F98C => array(0x8204), 0x2F98D => array(0x8F9E), - 0x2F98E => array(0x446B), 0x2F98F => array(0x8291), 0x2F990 => array(0x828B), - 0x2F991 => array(0x829D), 0x2F992 => array(0x52B3), 0x2F993 => array(0x82B1), - 0x2F994 => array(0x82B3), 0x2F995 => array(0x82BD), 0x2F996 => array(0x82E6), - 0x2F997 => array(0x26B3C), 0x2F998 => array(0x82E5), 0x2F999 => array(0x831D), - 0x2F99A => array(0x8363), 0x2F99B => array(0x83AD), 0x2F99C => array(0x8323), - 0x2F99D => array(0x83BD), 0x2F99E => array(0x83E7), 0x2F99F => array(0x8457), - 0x2F9A0 => array(0x8353), 0x2F9A1 => array(0x83CA), 0x2F9A2 => array(0x83CC), - 0x2F9A3 => array(0x83DC), 0x2F9A4 => array(0x26C36), 0x2F9A5 => array(0x26D6B), - 0x2F9A6 => array(0x26CD5), 0x2F9A7 => array(0x452B), 0x2F9A8 => array(0x84F1), - 0x2F9A9 => array(0x84F3), 0x2F9AA => array(0x8516), 0x2F9AB => array(0x273CA), - 0x2F9AC => array(0x8564), 0x2F9AD => array(0x26F2C), 0x2F9AE => array(0x455D), - 0x2F9AF => array(0x4561), 0x2F9B0 => array(0x26FB1), 0x2F9B1 => array(0x270D2), - 0x2F9B2 => array(0x456B), 0x2F9B3 => array(0x8650), 0x2F9B4 => array(0x865C), - 0x2F9B5 => array(0x8667), 0x2F9B6 => array(0x8669), 0x2F9B7 => array(0x86A9), - 0x2F9B8 => array(0x8688), 0x2F9B9 => array(0x870E), 0x2F9BA => array(0x86E2), - 0x2F9BB => array(0x8779), 0x2F9BC => array(0x8728), 0x2F9BD => array(0x876B), - 0x2F9BE => array(0x8786), 0x2F9C0 => array(0x87E1), 0x2F9C1 => array(0x8801), - 0x2F9C2 => array(0x45F9), 0x2F9C3 => array(0x8860), 0x2F9C4 => array(0x8863), - 0x2F9C5 => array(0x27667), 0x2F9C6 => array(0x88D7), 0x2F9C7 => array(0x88DE), - 0x2F9C8 => array(0x4635), 0x2F9C9 => array(0x88FA), 0x2F9CA => array(0x34BB), - 0x2F9CB => array(0x278AE), 0x2F9CC => array(0x27966), 0x2F9CD => array(0x46BE), - 0x2F9CE => array(0x46C7), 0x2F9CF => array(0x8AA0), 0x2F9D0 => array(0x8AED), - 0x2F9D1 => array(0x8B8A), 0x2F9D2 => array(0x8C55), 0x2F9D3 => array(0x27CA8), - 0x2F9D4 => array(0x8CAB), 0x2F9D5 => array(0x8CC1), 0x2F9D6 => array(0x8D1B), - 0x2F9D7 => array(0x8D77), 0x2F9D8 => array(0x27F2F), 0x2F9D9 => array(0x20804), - 0x2F9DA => array(0x8DCB), 0x2F9DB => array(0x8DBC), 0x2F9DC => array(0x8DF0), - 0x2F9DD => array(0x208DE), 0x2F9DE => array(0x8ED4), 0x2F9DF => array(0x8F38), - 0x2F9E0 => array(0x285D2), 0x2F9E1 => array(0x285ED), 0x2F9E2 => array(0x9094), - 0x2F9E3 => array(0x90F1), 0x2F9E4 => array(0x9111), 0x2F9E5 => array(0x2872E), - 0x2F9E6 => array(0x911B), 0x2F9E7 => array(0x9238), 0x2F9E8 => array(0x92D7), - 0x2F9E9 => array(0x92D8), 0x2F9EA => array(0x927C), 0x2F9EB => array(0x93F9), - 0x2F9EC => array(0x9415), 0x2F9ED => array(0x28BFA), 0x2F9EE => array(0x958B), - 0x2F9EF => array(0x4995), 0x2F9F0 => array(0x95B7), 0x2F9F1 => array(0x28D77), - 0x2F9F2 => array(0x49E6), 0x2F9F3 => array(0x96C3), 0x2F9F4 => array(0x5DB2), - 0x2F9F5 => array(0x9723), 0x2F9F6 => array(0x29145), 0x2F9F7 => array(0x2921A), - 0x2F9F8 => array(0x4A6E), 0x2F9F9 => array(0x4A76), 0x2F9FA => array(0x97E0), - 0x2F9FB => array(0x2940A), 0x2F9FC => array(0x4AB2), 0x2F9FD => array(0x29496), - 0x2F9FE => array(0x980B), 0x2F9FF => array(0x980B), 0x2FA00 => array(0x9829), - 0x2FA01 => array(0x295B6), 0x2FA02 => array(0x98E2), 0x2FA03 => array(0x4B33), - 0x2FA04 => array(0x9929), 0x2FA05 => array(0x99A7), 0x2FA06 => array(0x99C2), - 0x2FA07 => array(0x99FE), 0x2FA08 => array(0x4BCE), 0x2FA09 => array(0x29B30), - 0x2FA0A => array(0x9B12), 0x2FA0B => array(0x9C40), 0x2FA0C => array(0x9CFD), - 0x2FA0D => array(0x4CCE), 0x2FA0E => array(0x4CED), 0x2FA0F => array(0x9D67), - 0x2FA10 => array(0x2A0CE), 0x2FA11 => array(0x4CF8), 0x2FA12 => array(0x2A105), - 0x2FA13 => array(0x2A20E), 0x2FA14 => array(0x2A291), 0x2FA15 => array(0x9EBB), - 0x2FA16 => array(0x4D56), 0x2FA17 => array(0x9EF9), 0x2FA18 => array(0x9EFE), - 0x2FA19 => array(0x9F05), 0x2FA1A => array(0x9F0F), 0x2FA1B => array(0x9F16), - 0x2FA1C => array(0x9F3B), 0x2FA1D => array(0x2A600) - ), - 'norm_combcls' => array(0x334 => 1, 0x335 => 1, 0x336 => 1, 0x337 => 1, - 0x338 => 1, 0x93C => 7, 0x9BC => 7, 0xA3C => 7, 0xABC => 7, - 0xB3C => 7, 0xCBC => 7, 0x1037 => 7, 0x3099 => 8, 0x309A => 8, - 0x94D => 9, 0x9CD => 9, 0xA4D => 9, 0xACD => 9, 0xB4D => 9, - 0xBCD => 9, 0xC4D => 9, 0xCCD => 9, 0xD4D => 9, 0xDCA => 9, - 0xE3A => 9, 0xF84 => 9, 0x1039 => 9, 0x1714 => 9, 0x1734 => 9, - 0x17D2 => 9, 0x5B0 => 10, 0x5B1 => 11, 0x5B2 => 12, 0x5B3 => 13, - 0x5B4 => 14, 0x5B5 => 15, 0x5B6 => 16, 0x5B7 => 17, 0x5B8 => 18, - 0x5B9 => 19, 0x5BB => 20, 0x5Bc => 21, 0x5BD => 22, 0x5BF => 23, - 0x5C1 => 24, 0x5C2 => 25, 0xFB1E => 26, 0x64B => 27, 0x64C => 28, - 0x64D => 29, 0x64E => 30, 0x64F => 31, 0x650 => 32, 0x651 => 33, - 0x652 => 34, 0x670 => 35, 0x711 => 36, 0xC55 => 84, 0xC56 => 91, - 0xE38 => 103, 0xE39 => 103, 0xE48 => 107, 0xE49 => 107, 0xE4A => 107, - 0xE4B => 107, 0xEB8 => 118, 0xEB9 => 118, 0xEC8 => 122, 0xEC9 => 122, - 0xECA => 122, 0xECB => 122, 0xF71 => 129, 0xF72 => 130, 0xF7A => 130, - 0xF7B => 130, 0xF7C => 130, 0xF7D => 130, 0xF80 => 130, 0xF74 => 132, - 0x321 => 202, 0x322 => 202, 0x327 => 202, 0x328 => 202, 0x31B => 216, - 0xF39 => 216, 0x1D165 => 216, 0x1D166 => 216, 0x1D16E => 216, 0x1D16F => 216, - 0x1D170 => 216, 0x1D171 => 216, 0x1D172 => 216, 0x302A => 218, 0x316 => 220, - 0x317 => 220, 0x318 => 220, 0x319 => 220, 0x31C => 220, 0x31D => 220, - 0x31E => 220, 0x31F => 220, 0x320 => 220, 0x323 => 220, 0x324 => 220, - 0x325 => 220, 0x326 => 220, 0x329 => 220, 0x32A => 220, 0x32B => 220, - 0x32C => 220, 0x32D => 220, 0x32E => 220, 0x32F => 220, 0x330 => 220, - 0x331 => 220, 0x332 => 220, 0x333 => 220, 0x339 => 220, 0x33A => 220, - 0x33B => 220, 0x33C => 220, 0x347 => 220, 0x348 => 220, 0x349 => 220, - 0x34D => 220, 0x34E => 220, 0x353 => 220, 0x354 => 220, 0x355 => 220, - 0x356 => 220, 0x591 => 220, 0x596 => 220, 0x59B => 220, 0x5A3 => 220, - 0x5A4 => 220, 0x5A5 => 220, 0x5A6 => 220, 0x5A7 => 220, 0x5AA => 220, - 0x655 => 220, 0x656 => 220, 0x6E3 => 220, 0x6EA => 220, 0x6ED => 220, - 0x731 => 220, 0x734 => 220, 0x737 => 220, 0x738 => 220, 0x739 => 220, - 0x73B => 220, 0x73C => 220, 0x73E => 220, 0x742 => 220, 0x744 => 220, - 0x746 => 220, 0x748 => 220, 0x952 => 220, 0xF18 => 220, 0xF19 => 220, - 0xF35 => 220, 0xF37 => 220, 0xFC6 => 220, 0x193B => 220, 0x20E8 => 220, - 0x1D17B => 220, 0x1D17C => 220, 0x1D17D => 220, 0x1D17E => 220, 0x1D17F => 220, - 0x1D180 => 220, 0x1D181 => 220, 0x1D182 => 220, 0x1D18A => 220, 0x1D18B => 220, - 0x59A => 222, 0x5AD => 222, 0x1929 => 222, 0x302D => 222, 0x302E => 224, - 0x302F => 224, 0x1D16D => 226, 0x5AE => 228, 0x18A9 => 228, 0x302B => 228, - 0x300 => 230, 0x301 => 230, 0x302 => 230, 0x303 => 230, 0x304 => 230, - 0x305 => 230, 0x306 => 230, 0x307 => 230, 0x308 => 230, 0x309 => 230, - 0x30A => 230, 0x30B => 230, 0x30C => 230, 0x30D => 230, 0x30E => 230, - 0x30F => 230, 0x310 => 230, 0x311 => 230, 0x312 => 230, 0x313 => 230, - 0x314 => 230, 0x33D => 230, 0x33E => 230, 0x33F => 230, 0x340 => 230, - 0x341 => 230, 0x342 => 230, 0x343 => 230, 0x344 => 230, 0x346 => 230, - 0x34A => 230, 0x34B => 230, 0x34C => 230, 0x350 => 230, 0x351 => 230, - 0x352 => 230, 0x357 => 230, 0x363 => 230, 0x364 => 230, 0x365 => 230, - 0x366 => 230, 0x367 => 230, 0x368 => 230, 0x369 => 230, 0x36A => 230, - 0x36B => 230, 0x36C => 230, 0x36D => 230, 0x36E => 230, 0x36F => 230, - 0x483 => 230, 0x484 => 230, 0x485 => 230, 0x486 => 230, 0x592 => 230, - 0x593 => 230, 0x594 => 230, 0x595 => 230, 0x597 => 230, 0x598 => 230, - 0x599 => 230, 0x59C => 230, 0x59D => 230, 0x59E => 230, 0x59F => 230, - 0x5A0 => 230, 0x5A1 => 230, 0x5A8 => 230, 0x5A9 => 230, 0x5AB => 230, - 0x5AC => 230, 0x5AF => 230, 0x5C4 => 230, 0x610 => 230, 0x611 => 230, - 0x612 => 230, 0x613 => 230, 0x614 => 230, 0x615 => 230, 0x653 => 230, - 0x654 => 230, 0x657 => 230, 0x658 => 230, 0x6D6 => 230, 0x6D7 => 230, - 0x6D8 => 230, 0x6D9 => 230, 0x6DA => 230, 0x6DB => 230, 0x6DC => 230, - 0x6DF => 230, 0x6E0 => 230, 0x6E1 => 230, 0x6E2 => 230, 0x6E4 => 230, - 0x6E7 => 230, 0x6E8 => 230, 0x6EB => 230, 0x6EC => 230, 0x730 => 230, - 0x732 => 230, 0x733 => 230, 0x735 => 230, 0x736 => 230, 0x73A => 230, - 0x73D => 230, 0x73F => 230, 0x740 => 230, 0x741 => 230, 0x743 => 230, - 0x745 => 230, 0x747 => 230, 0x749 => 230, 0x74A => 230, 0x951 => 230, - 0x953 => 230, 0x954 => 230, 0xF82 => 230, 0xF83 => 230, 0xF86 => 230, - 0xF87 => 230, 0x170D => 230, 0x193A => 230, 0x20D0 => 230, 0x20D1 => 230, - 0x20D4 => 230, 0x20D5 => 230, 0x20D6 => 230, 0x20D7 => 230, 0x20DB => 230, - 0x20DC => 230, 0x20E1 => 230, 0x20E7 => 230, 0x20E9 => 230, 0xFE20 => 230, - 0xFE21 => 230, 0xFE22 => 230, 0xFE23 => 230, 0x1D185 => 230, 0x1D186 => 230, - 0x1D187 => 230, 0x1D189 => 230, 0x1D188 => 230, 0x1D1AA => 230, 0x1D1AB => 230, - 0x1D1AC => 230, 0x1D1AD => 230, 0x315 => 232, 0x31A => 232, 0x302C => 232, - 0x35F => 233, 0x362 => 233, 0x35D => 234, 0x35E => 234, 0x360 => 234, - 0x361 => 234, 0x345 => 240 - ) - ); -} \ No newline at end of file diff --git a/libs/idna_convert/transcode_wrapper.php b/libs/idna_convert/transcode_wrapper.php deleted file mode 100644 index 6862e40cc..000000000 --- a/libs/idna_convert/transcode_wrapper.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @version 0.1.0 - */ - -/** - * Convert a string from any of various encodings to UTF-8 - * - * @param string String to encode - *[@param string Encoding; Default: ISO-8859-1] - *[@param bool Safe Mode: if set to TRUE, the original string is retunred on errors] - * @return string The encoded string or false on failure - * @since 0.0.1 - */ -function encode_utf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false) -{ - $safe = ($safe_mode) ? $string : false; - if (strtoupper($encoding) == 'UTF-8' || strtoupper($encoding) == 'UTF8') { - return $string; - } elseif (strtoupper($encoding) == 'ISO-8859-1') { - return utf8_encode($string); - } elseif (strtoupper($encoding) == 'WINDOWS-1252') { - return utf8_encode(map_w1252_iso8859_1($string)); - } elseif (strtoupper($encoding) == 'UNICODE-1-1-UTF-7') { - $encoding = 'utf-7'; - } - if (function_exists('mb_convert_encoding')) { - $conv = @mb_convert_encoding($string, 'UTF-8', strtoupper($encoding)); - if ($conv) return $conv; - } - if (function_exists('iconv')) { - $conv = @iconv(strtoupper($encoding), 'UTF-8', $string); - if ($conv) return $conv; - } - if (function_exists('libiconv')) { - $conv = @libiconv(strtoupper($encoding), 'UTF-8', $string); - if ($conv) return $conv; - } - return $safe; -} - -/** - * Convert a string from UTF-8 to any of various encodings - * - * @param string String to decode - *[@param string Encoding; Default: ISO-8859-1] - *[@param bool Safe Mode: if set to TRUE, the original string is retunred on errors] - * @return string The decoded string or false on failure - * @since 0.0.1 - */ -function decode_utf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false) -{ - $safe = ($safe_mode) ? $string : false; - if (!$encoding) $encoding = 'ISO-8859-1'; - if (strtoupper($encoding) == 'UTF-8' || strtoupper($encoding) == 'UTF8') { - return $string; - } elseif (strtoupper($encoding) == 'ISO-8859-1') { - return utf8_decode($string); - } elseif (strtoupper($encoding) == 'WINDOWS-1252') { - return map_iso8859_1_w1252(utf8_decode($string)); - } elseif (strtoupper($encoding) == 'UNICODE-1-1-UTF-7') { - $encoding = 'utf-7'; - } - if (function_exists('mb_convert_encoding')) { - $conv = @mb_convert_encoding($string, strtoupper($encoding), 'UTF-8'); - if ($conv) return $conv; - } - if (function_exists('iconv')) { - $conv = @iconv('UTF-8', strtoupper($encoding), $string); - if ($conv) return $conv; - } - if (function_exists('libiconv')) { - $conv = @libiconv('UTF-8', strtoupper($encoding), $string); - if ($conv) return $conv; - } - return $safe; -} - -/** - * Special treatment for our guys in Redmond - * Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get accounted for here - * @param string Your input in Win1252 - * @param string The resulting ISO-8859-1 string - * @since 3.0.8 - */ -function map_w1252_iso8859_1($string = '') -{ - if ($string == '') return ''; - $return = ''; - for ($i = 0; $i < strlen($string); ++$i) { - $c = ord($string{$i}); - switch ($c) { - case 129: $return .= chr(252); break; - case 132: $return .= chr(228); break; - case 142: $return .= chr(196); break; - case 148: $return .= chr(246); break; - case 153: $return .= chr(214); break; - case 154: $return .= chr(220); break; - case 225: $return .= chr(223); break; - default: $return .= chr($c); break; - } - } - return $return; -} - -/** - * Special treatment for our guys in Redmond - * Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get accounted for here - * @param string Your input in ISO-8859-1 - * @param string The resulting Win1252 string - * @since 3.0.8 - */ -function map_iso8859_1_w1252($string = '') -{ - if ($string == '') return ''; - $return = ''; - for ($i = 0; $i < strlen($string); ++$i) { - $c = ord($string{$i}); - switch ($c) { - case 196: $return .= chr(142); break; - case 214: $return .= chr(153); break; - case 220: $return .= chr(154); break; - case 223: $return .= chr(225); break; - case 228: $return .= chr(132); break; - case 246: $return .= chr(148); break; - case 252: $return .= chr(129); break; - default: $return .= chr($c); break; - } - } - return $return; -} - -?> \ No newline at end of file diff --git a/libs/idna_convert/uctc.php b/libs/idna_convert/uctc.php deleted file mode 100644 index ea5e4769c..000000000 --- a/libs/idna_convert/uctc.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @copyright 2003-2009 phlyLabs Berlin, http://phlylabs.de - * @version 0.0.6 2009-05-10 - */ -class uctc { - private static $mechs = array('ucs4', /*'ucs4le', 'ucs4be', */'ucs4array', /*'utf16', 'utf16le', 'utf16be', */'utf8', 'utf7', 'utf7imap'); - private static $allow_overlong = false; - private static $safe_mode; - private static $safe_char; - - /** - * The actual conversion routine - * - * @param mixed $data The data to convert, usually a string, array when converting from UCS-4 array - * @param string $from Original encoding of the data - * @param string $to Target encoding of the data - * @param bool $safe_mode SafeMode tries to correct invalid codepoints - * @return mixed False on failure, String or array on success, depending on target encoding - * @access public - * @since 0.0.1 - */ - public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC) - { - self::$safe_mode = ($safe_mode) ? true : false; - self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC; - if (self::$safe_mode) self::$allow_overlong = true; - if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified'); - if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified'); - if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);'); - if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);'); - return $data; - } - - /** - * This converts an UTF-8 encoded string to its UCS-4 representation - * - * @param string $input The UTF-8 string to convert - * @return array Array of 32bit values representing each codepoint - * @access private - */ - private static function utf8_ucs4array($input) - { - $output = array(); - $out_len = 0; - $inp_len = strlen($input); - $mode = 'next'; - $test = 'none'; - for ($k = 0; $k < $inp_len; ++$k) { - $v = ord($input{$k}); // Extract byte from input string - - if ($v < 128) { // We found an ASCII char - put into stirng as is - $output[$out_len] = $v; - ++$out_len; - if ('add' == $mode) { - if (self::$safe_mode) { - $output[$out_len-2] = self::$safe_char; - $mode = 'next'; - } else { - throw new Exception('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k); - } - } - continue; - } - if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char - $start_byte = $v; - $mode = 'add'; - $test = 'range'; - if ($v >> 5 == 6) { // &110xxxxx 10xxxxx - $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left - $v = ($v - 192) << 6; - } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx - $next_byte = 1; - $v = ($v - 224) << 12; - } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - $next_byte = 2; - $v = ($v - 240) << 18; - } elseif (self::$safe_mode) { - $mode = 'next'; - $output[$out_len] = self::$safe_char; - ++$out_len; - continue; - } else { - throw new Exception('This might be UTF-8, but I don\'t understand it at byte '.$k); - } - if ($inp_len-$k-$next_byte < 2) { - $output[$out_len] = self::$safe_char; - $mode = 'no'; - continue; - } - - if ('add' == $mode) { - $output[$out_len] = (int) $v; - ++$out_len; - continue; - } - } - if ('add' == $mode) { - if (!self::$allow_overlong && $test == 'range') { - $test = 'none'; - if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) { - throw new Exception('Bogus UTF-8 character detected (out of legal range) at byte '.$k); - } - } - if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx - $v = ($v-128) << ($next_byte*6); - $output[($out_len-1)] += $v; - --$next_byte; - } else { - if (self::$safe_mode) { - $output[$out_len-1] = ord(self::$safe_char); - $k--; - $mode = 'next'; - continue; - } else { - throw new Exception('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k); - } - } - if ($next_byte < 0) { - $mode = 'next'; - } - } - } // for - return $output; - } - - /** - * Convert UCS-4 string into UTF-8 string - * See utf8_ucs4array() for details - * @access private - */ - private static function ucs4array_utf8($input) - { - $output = ''; - foreach ($input as $v) { - if ($v < 128) { // 7bit are transferred literally - $output .= chr($v); - } elseif ($v < (1 << 11)) { // 2 bytes - $output .= chr(192+($v >> 6)).chr(128+($v & 63)); - } elseif ($v < (1 << 16)) { // 3 bytes - $output .= chr(224+($v >> 12)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63)); - } elseif ($v < (1 << 21)) { // 4 bytes - $output .= chr(240+($v >> 18)).chr(128+(($v >> 12) & 63)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63)); - } elseif (self::$safe_mode) { - $output .= self::$safe_char; - } else { - throw new Exception('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k); - } - } - return $output; - } - - private static function utf7imap_ucs4array($input) - { - return self::utf7_ucs4array(str_replace(',', '/', $input), '&'); - } - - private static function utf7_ucs4array($input, $sc = '+') - { - $output = array(); - $out_len = 0; - $inp_len = strlen($input); - $mode = 'd'; - $b64 = ''; - - for ($k = 0; $k < $inp_len; ++$k) { - $c = $input{$k}; - if (0 == ord($c)) continue; // Ignore zero bytes - if ('b' == $mode) { - // Sequence got terminated - if (!preg_match('![A-Za-z0-9/'.preg_quote($sc, '!').']!', $c)) { - if ('-' == $c) { - if ($b64 == '') { - $output[$out_len] = ord($sc); - $out_len++; - $mode = 'd'; - continue; - } - } - $tmp = base64_decode($b64); - $tmp = substr($tmp, -1 * (strlen($tmp) % 2)); - for ($i = 0; $i < strlen($tmp); $i++) { - if ($i % 2) { - $output[$out_len] += ord($tmp{$i}); - $out_len++; - } else { - $output[$out_len] = ord($tmp{$i}) << 8; - } - } - $mode = 'd'; - $b64 = ''; - continue; - } else { - $b64 .= $c; - } - } - if ('d' == $mode) { - if ($sc == $c) { - $mode = 'b'; - continue; - } - $output[$out_len] = ord($c); - $out_len++; - } - } - return $output; - } - - private static function ucs4array_utf7imap($input) - { - return str_replace('/', ',', self::ucs4array_utf7($input, '&')); - } - - private static function ucs4array_utf7($input, $sc = '+') - { - $output = ''; - $mode = 'd'; - $b64 = ''; - while (true) { - $v = (!empty($input)) ? array_shift($input) : false; - $is_direct = (false !== $v) ? (0x20 <= $v && $v <= 0x7e && $v != ord($sc)) : true; - if ($mode == 'b') { - if ($is_direct) { - if ($b64 == chr(0).$sc) { - $output .= $sc.'-'; - $b64 = ''; - } elseif ($b64) { - $output .= $sc.str_replace('=', '', base64_encode($b64)).'-'; - $b64 = ''; - } - $mode = 'd'; - } elseif (false !== $v) { - $b64 .= chr(($v >> 8) & 255). chr($v & 255); - } - } - if ($mode == 'd' && false !== $v) { - if ($is_direct) { - $output .= chr($v); - } else { - $b64 = chr(($v >> 8) & 255). chr($v & 255); - $mode = 'b'; - } - } - if (false === $v && $b64 == '') break; - } - return $output; - } - - /** - * Convert UCS-4 array into UCS-4 string (Little Endian at the moment) - * @access private - */ - private static function ucs4array_ucs4($input) - { - $output = ''; - foreach ($input as $v) { - $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255); - } - return $output; - } - - /** - * Convert UCS-4 string (LE in the moment) into UCS-4 garray - * @access private - */ - private static function ucs4_ucs4array($input) - { - $output = array(); - - $inp_len = strlen($input); - // Input length must be dividable by 4 - if ($inp_len % 4) { - throw new Exception('Input UCS4 string is broken'); - } - // Empty input - return empty output - if (!$inp_len) return $output; - - for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) { - if (!($i % 4)) { // Increment output position every 4 input bytes - $out_len++; - $output[$out_len] = 0; - } - $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) ); - } - return $output; - } -} -?> \ No newline at end of file diff --git a/modules/install/install.admin.controller.php b/modules/install/install.admin.controller.php index 45ac2f7b8..3d6551068 100644 --- a/modules/install/install.admin.controller.php +++ b/modules/install/install.admin.controller.php @@ -74,9 +74,7 @@ class installAdminController extends install if($default_url && substr($default_url, -1) !== '/') $default_url = $default_url.'/'; /* convert NON Alphabet URL to punycode URL - Alphabet URL will not be changed */ - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); - $IDN = new idna_convert(array('idn_version' => 2008)); - $default_url = $IDN->encode($default_url); + $default_url = Context::encodeIdna($default_url); $use_ssl = Context::get('use_ssl'); if(!$use_ssl) $use_ssl = 'none'; From 97d385648b3b9a17e9c8c1cddc2d1c911e93d382 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 16:10:04 +0900 Subject: [PATCH 5/8] Replace PHPMailer with SwiftMailer (via Mail class from Advanced Mailer) --- classes/mail/Mail.class.php | 696 ++--- libs/phpmailer/LICENSE | 504 ---- libs/phpmailer/class.phpmailer.php | 1909 -------------- libs/phpmailer/class.smtp.php | 1062 -------- libs/phpmailer/index.html | 1 - libs/phpmailer/language/index.html | 1 - libs/phpmailer/language/phpmailer.lang-en.php | 23 - libs/phpmailer/phpmailer.php | 2320 ----------------- libs/phpmailer/smtp.php | 815 ------ 9 files changed, 261 insertions(+), 7070 deletions(-) delete mode 100644 libs/phpmailer/LICENSE delete mode 100644 libs/phpmailer/class.phpmailer.php delete mode 100644 libs/phpmailer/class.smtp.php delete mode 100644 libs/phpmailer/index.html delete mode 100644 libs/phpmailer/language/index.html delete mode 100644 libs/phpmailer/language/phpmailer.lang-en.php delete mode 100644 libs/phpmailer/phpmailer.php delete mode 100644 libs/phpmailer/smtp.php diff --git a/classes/mail/Mail.class.php b/classes/mail/Mail.class.php index 14b58ccf4..3877adaba 100644 --- a/classes/mail/Mail.class.php +++ b/classes/mail/Mail.class.php @@ -1,165 +1,53 @@ */ - -require_once _XE_PATH_ . "libs/phpmailer/phpmailer.php"; /** - * Mailing class for XpressEngine - * - * @author NAVER (developers@xpressengine.com) + * Mail class + * + * This class was originally written for the Advanced Mailer module. + * Advanced Mailer is licensed under GPLv2, but the author hereby relicenses + * this class under the same license as the remainder of RhymiX. + * All other parts of the Advanced Mailer module remain under GPLv2. + * + * @author Kijin Sung */ -class Mail extends PHPMailer +class Mail { - /** - * Sender name - * @var string + * Properties for compatibility with XE Mail class */ - var $sender_name = ''; - + public $content = ''; + public $content_type = 'html'; + public $attachments = array(); + public $cidAttachments = array(); + /** - * Sender email address - * @var string + * Properties used by Advanced Mailer */ - var $sender_email = ''; - + public $error = null; + public $caller = null; + public $message = null; + public static $transport = null; + /** - * Receiptor name - * @var string + * Constructor */ - var $receiptor_name = ''; - - /** - * Receiptor email address - * @var string - */ - var $receiptor_email = ''; - - /** - * Title of email - * @var string - */ - var $title = ''; - - /** - * Content of email - * @var string - */ - var $content = ''; - - /** - * Content type - * @var string - */ - var $content_type = 'html'; - - /** - * Message id - * @var string - */ - var $messageId = NULL; - - /** - * Reply to - * @var string - */ - var $replyTo = NULL; - - /** - * BCC (Blind carbon copy) - * @var string - */ - var $bcc = NULL; - - /** - * Attachments - * @var array - */ - var $attachments = array(); - - /** - * Content attachements - * @var array - */ - var $cidAttachments = array(); - - /** - * ??? - * @var ??? - */ - var $mainMailPart = NULL; - - /** - * Raw body - * @var string - */ - var $body = ''; - - /** - * Raw header - * @var string - */ - var $header = ''; - - /** - * End of line - * @var string - */ - var $eol = ''; - - /** - * Reference - * @var string - */ - var $references = ''; - - /** - * Additional parameters - * @var string - */ - var $additional_params = NULL; - - /** - * Whether use or not use stmp - * @var bool - */ - var $use_smtp = FALSE; - - /** - * Constructor function - * - * @return void - */ - function __construct() + public function __construct() { - + $this->message = \Swift_Message::newInstance(); } - + /** * Set parameters for using Gmail * - * @param string $account_name Password - * @param string $account_passwd Secure method ('ssl','tls') + * @param string $account_name Email address + * @param string $account_passwd Email password * @return void */ - function useGmailAccount($account_name, $account_passwd) + public static function useGmailAccount($account_name, $account_passwd) { - $this->SMTPAuth = TRUE; - $this->SMTPSecure = "tls"; - $this->Host = 'smtp.gmail.com'; - $this->Port = '587'; - if($this->isVaildMailAddress($account_name)) - { - $this->Username = $account_name; - } - else - { - $this->Username = $account_name . '@gmail.com'; - } - $this->Password = $account_passwd; - $this->IsSMTP(); + self::useSMTP(null, 'smtp.gmail.com', $account_name, $account_passwd, 'ssl', 465); } - + /** * Set parameters for using SMTP protocol * @@ -172,67 +60,26 @@ class Mail extends PHPMailer * * @return bool TRUE if SMTP is set correct, otherwise return FALSE */ - function useSMTP($auth = NULL, $host = NULL, $user = NULL, $pass = NULL, $secure = NULL, $port = 25) + public static function useSMTP($auth = null, $host = null, $user = null, $pass = null, $secure = null, $port = 25) { - $this->SMTPAuth = $auth; - $this->Host = $host; - $this->Username = $user; - $this->Password = $pass; - $this->Port = $port; - - if($secure == 'ssl' || $secure == 'tls') + self::$transport = \Swift_SmtpTransport::newInstance($host, $port, $secure); + self::$transport->setUsername($user); + self::$transport->setPassword($pass); + $local_domain = self::$transport->getLocalDomain(); + if (preg_match('/^\*\.(.+)$/', $local_domain, $matches)) { - $this->SMTPSecure = $secure; - } - - if(($this->SMTPAuth !== NULL && $this->Host !== NULL && $this->Username !== NULL && $this->Password !== NULL) || ($this->SMTPAuth === NULL && $this->Host !== NULL)) - { - $this->IsSMTP(); - $this->AltBody = "To view the message, please use an HTML compatible email viewer!"; - return TRUE; - } - else - { - $this->IsMail(); - return FALSE; + self::$transport->setLocalDomain($matches[1]); } } - + /** * Set additional parameters - * - * @param string $additional_params Additional parameters - * @return void */ - function setAdditionalParams($additional_params) + public function setAdditionalParams($additional_params) { - $this->additional_params = $additional_params; + // no-op } - - /** - * Add file attachment - * - * @param string $filename File name to attach - * @param string $orgfilename Real path of file to attach - * @return void - */ - function addAttachment($filename, $orgfilename) - { - $this->attachments[$orgfilename] = $filename; - } - - /** - * Add content attachment - * - * @param string $filename Real path of file to attach - * @param string $cid Content-CID - * @return void - */ - function addCidAttachment($filename, $cid) - { - $this->cidAttachments[$cid] = $filename; - } - + /** * Set Sender (From:) * @@ -240,172 +87,246 @@ class Mail extends PHPMailer * @param string $email Sender email address * @return void */ - function setSender($name, $email) + public function setSender($name, $email) { - if($this->Mailer == "mail") + try { - $this->sender_name = $name; - $this->sender_email = $email; + $this->message->setFrom(array($email => $name)); } - else + catch (\Exception $e) { - $this->SetFrom($email, $name); + $this->errors[] = array($e->getMessage()); } } - + /** * Get Sender (From:) * * @return string */ - function getSender() + public function getSender() { - if(!stristr(PHP_OS, 'win') && $this->sender_name) + $from = $this->message->getFrom(); + foreach($from as $email => $name) { - return sprintf("%s <%s>", '=?utf-8?b?' . base64_encode($this->sender_name) . '?=', $this->sender_email); + if($name === '') + { + return $email; + } + else + { + return $name . ' <' . $email . '>'; + } } - return $this->sender_email; + return FALSE; } - + /** - * Set Receiptor (TO:) + * Set Recipient (To:) * - * @param string $name Receiptor name - * @param string $email Receiptor email address + * @param string $name Recipient name + * @param string $email Recipient email address * @return void */ - function setReceiptor($name, $email) + public function setReceiptor($name, $email) { - if($this->Mailer == "mail") + try { - $this->receiptor_name = $name; - $this->receiptor_email = $email; + $this->message->setTo(array($email => $name)); } - else + catch (\Exception $e) { - $this->AddAddress($email, $name); + $this->errors[] = array($e->getMessage()); } } - + /** - * Get Receiptor (TO:) + * Get Recipient (To:) * * @return string */ - function getReceiptor() + public function getReceiptor() { - if(!stristr(PHP_OS, 'win') && $this->receiptor_name && $this->receiptor_name != $this->receiptor_email) + $to = $this->message->getTo(); + foreach($to as $email => $name) { - return sprintf("%s <%s>", '=?utf-8?b?' . base64_encode($this->receiptor_name) . '?=', $this->receiptor_email); + if($name === '') + { + return $email; + } + else + { + return $name . ' <' . $email . '>'; + } } - return $this->receiptor_email; + return FALSE; } - + /** - * Set Email's Title + * Set Subject * - * @param string $title Title to set + * @param string $subject The subject * @return void */ - function setTitle($title) + public function setTitle($subject) { - if($this->Mailer == "mail") - { - $this->title = $title; - } - else - { - $this->Subject = $title; - } + $this->message->setSubject(strval($subject)); } - + /** - * Get Email's Title + * Get Subject * * @return string */ - function getTitle() + public function getTitle() { - return '=?utf-8?b?' . base64_encode($this->title) . '?='; + return $this->message->getSubject(); } - + /** * Set BCC * * @param string $bcc * @return void */ - function setBCC($bcc) + public function setBCC($bcc) { - if($this->Mailer == "mail") + try { - $this->bcc = $bcc; + $this->message->setBcc(array($bcc)); } - else + catch (\Exception $e) { - $this->AddBCC($bcc); + $this->errors[] = array($e->getMessage()); } } - + + /** + * Set ReplyTo + * + * @param string $replyTo + * @return void + */ + public function setReplyTo($replyTo) + { + try + { + $this->message->setReplyTo(array($replyTo)); + } + catch (\Exception $e) + { + $this->errors[] = array($e->getMessage()); + } + } + + /** + * Set Return Path + * + * @param string $returnPath + * @return void + */ + public function setReturnPath($returnPath) + { + try + { + $this->message->setReturnPath($returnPath); + } + catch (\Exception $e) + { + $this->errors[] = array($e->getMessage()); + } + } + /** * Set Message ID * * @param string $messageId * @return void */ - function setMessageID($messageId) + public function setMessageID($messageId) { - $this->messageId = $messageId; + $this->message->getHeaders()->get('Message-ID')->setId($messageId); } - + /** * Set references * * @param string $references * @return void */ - function setReferences($references) + public function setReferences($references) { - $this->references = $references; + $headers = $this->message->getHeaders(); + $headers->addTextHeader('References', $references); } - - /** - * Set ReplyTo param - * - * @param string $replyTo - * @return void - */ - function setReplyTo($replyTo) - { - if($this->Mailer == "mail") - { - $this->replyTo = $replyTo; - } - else - { - $this->AddReplyTo($replyTo); - } - } - + /** * Set message content * * @param string $content Content * @return void */ - function setContent($content) + public function setContent($content) { $content = preg_replace_callback('/]+)>/i', array($this, 'replaceResourceRealPath'), $content); - if($this->Mailer == "mail") - { - $this->content = $content; - } - else - { - $this->MsgHTML($content); - } + $this->content = $content; } - + + /** + * Set the type of message content (html or plain text) + * + * @param string $mode The type + * @return void + */ + public function setContentType($type = 'html') + { + $this->content_type = $type === 'html' ? 'html' : ''; + } + + /** + * Get the Plain content of body message + * + * @return string + */ + public function getPlainContent() + { + return chunk_split(base64_encode(str_replace(array("<", ">", "&"), array("<", ">", "&"), $this->content))); + } + + /** + * Get the HTML content of body message + * + * @return string + */ + public function getHTMLContent() + { + return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content) : $this->content)); + } + + /** + * Add file attachment + * + * @param string $filename File name to attach + * @param string $original_filename Real path of file to attach + * @return void + */ + public function addAttachment($filename, $original_filename) + { + $this->attachments[$original_filename] = $filename; + } + + /** + * Add content attachment + * + * @param string $original_filename Real path of file to attach + * @param string $cid Content-CID + * @return void + */ + public function addCidAttachment($original_filename, $cid) + { + $this->cidAttachments[$cid] = $original_filename; + } + /** * Replace resourse path of the files * @@ -413,188 +334,93 @@ class Mail extends PHPMailer * @param array $matches Match info. * @return string */ - function replaceResourceRealPath($matches) + public function replaceResourceRealPath($matches) { - return preg_replace('/src=(["\']?)files/i', 'src=$1' . Context::getRequestUri() . 'files', $matches[0]); + return preg_replace('/src=(["\']?)files/i', 'src=$1' . \Context::getRequestUri() . 'files', $matches[0]); } - - /** - * Get the Plain content of body message - * - * @return string - */ - function getPlainContent() - { - return chunk_split(base64_encode(str_replace(array("<", ">", "&"), array("<", ">", "&"), $this->content))); - } - - /** - * Get the HTML content of body message - * - * @return string - */ - function getHTMLContent() - { - return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content) : $this->content)); - } - - /** - * Set the type of body's content - * - * @param string $mode - * @return void - */ - function setContentType($mode = 'html') - { - $this->content_type = $mode == 'html' ? 'html' : ''; - } - + /** * Process the images from attachments * * @return void */ - function procAttachments() + public function procAttachments() { - if($this->Mailer == "mail") - { - if(count($this->attachments) > 0) - { - $this->body = $this->header . $this->body; - $boundary = '----==' . uniqid(rand(), TRUE); - $this->header = "Content-Type: multipart/mixed;" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol; - $this->body = "--" . $boundary . $this->eol . $this->body . $this->eol . $this->eol; - $res = array(); - $res[] = $this->body; - foreach($this->attachments as $filename => $attachment) - { - $type = $this->returnMIMEType($filename); - $file_handler = new FileHandler(); - $file_str = $file_handler->readFile($attachment); - $chunks = chunk_split(base64_encode($file_str)); - $tempBody = sprintf( - "--" . $boundary . $this->eol . - "Content-Type: %s;" . $this->eol . - "\tname=\"%s\"" . $this->eol . - "Content-Transfer-Encoding: base64" . $this->eol . - "Content-Description: %s" . $this->eol . - "Content-Disposition: attachment;" . $this->eol . - "\tfilename=\"%s\"" . $this->eol . $this->eol . - "%s" . $this->eol . $this->eol, $type, $filename, $filename, $filename, $chunks); - $res[] = $tempBody; - } - $this->body = implode("", $res); - $this->body .= "--" . $boundary . "--"; - } - } - else - { - if(count($this->attachments) > 0) - { - foreach($this->attachments as $filename => $attachment) - { - parent::AddAttachment($attachment); - } - } - } + // no-op } - + /** * Process the images from body content. This functions is used if Mailer is set as mail not as SMTP - * + * * @return void */ - function procCidAttachments() + public function procCidAttachments() { - if(count($this->cidAttachments) > 0) - { - $this->body = $this->header . $this->body; - $boundary = '----==' . uniqid(rand(), TRUE); - $this->header = "Content-Type: multipart/relative;" . $this->eol . "\ttype=\"multipart/alternative\";" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol; - $this->body = "--" . $boundary . $this->eol . $this->body . $this->eol . $this->eol; - $res = array(); - $res[] = $this->body; - foreach($this->cidAttachments as $cid => $attachment) - { - $filename = basename($attachment); - $type = $this->returnMIMEType(FileHandler::getRealPath($attachment)); - $file_str = FileHandler::readFile($attachment); - $chunks = chunk_split(base64_encode($file_str)); - $tempBody = sprintf( - "--" . $boundary . $this->eol . - "Content-Type: %s;" . $this->eol . - "\tname=\"%s\"" . $this->eol . - "Content-Transfer-Encoding: base64" . $this->eol . - "Content-ID: <%s>" . $this->eol . - "Content-Description: %s" . $this->eol . - "Content-Location: %s" . $this->eol . $this->eol . - "%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks); - $res[] = $tempBody; - } - $this->body = implode("", $res); - $this->body .= "--" . $boundary . "--"; - } + // no-op } - + + /** + * Process the message before sending + * + * @return void + */ + public function procAssembleMessage() + { + // Add all attachments + foreach($this->attachments as $original_filename => $filename) + { + $attachment = \Swift_Attachment::fromPath($original_filename); + $attachment->setFilename($filename); + $this->message->attach($attachment); + } + + // Add all CID attachments + foreach($this->cidAttachments as $cid => $original_filename) + { + $embedded = \Swift_EmbeddedFile::fromPath($original_filename); + $newcid = $this->message->embed($embedded); + $this->content = str_replace(array("cid:$cid", $cid), $newcid, $this->content); + } + + // Set content type + $content_type = $this->content_type === 'html' ? 'text/html' : 'text/plain'; + $this->message->setBody($this->content, $content_type); + } + /** * Send email - * - * @return bool TRUE in case of success, FALSE if sending fails + * + * @return bool */ - function send() + public function send() { - if($this->Mailer == "mail") + try { - $boundary = '----==' . uniqid(rand(), TRUE); - $this->eol = $GLOBALS['_qmail_compatibility'] == "Y" ? "\n" : "\r\n"; - $this->header = "Content-Type: multipart/alternative;" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol; - $this->body = sprintf( - "--%s" . $this->eol . - "Content-Type: text/plain; charset=utf-8; format=flowed" . $this->eol . - "Content-Transfer-Encoding: base64" . $this->eol . - "Content-Disposition: inline" . $this->eol . $this->eol . - "%s" . - "--%s" . $this->eol . - "Content-Type: text/html; charset=utf-8" . $this->eol . - "Content-Transfer-Encoding: base64" . $this->eol . - "Content-Disposition: inline" . $this->eol . $this->eol . - "%s" . - "--%s--" . - "", $boundary, $this->getPlainContent(), $boundary, $this->getHTMLContent(), $boundary - ); - $this->procCidAttachments(); - $this->procAttachments(); - $headers = sprintf( - "From: %s" . $this->eol . - "%s" . - "%s" . - "%s" . - "%s" . - "MIME-Version: 1.0" . $this->eol . "", $this->getSender(), $this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol) : "", $this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol) : "", $this->bcc ? ("Bcc: " . $this->bcc . $this->eol) : "", $this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol) : "" - ); - $headers .= $this->header; - if($this->additional_params) + $this->procAssembleMessage(); + if(!self::$transport) { - return mail($this->getReceiptor(), $this->getTitle(), $this->body, $headers, $this->additional_params); + self::$transport = \Swift_MailTransport::newInstance(); } - return mail($this->getReceiptor(), $this->getTitle(), $this->body, $headers); + $mailer = \Swift_Mailer::newInstance(self::$transport); + $result = $mailer->send($this->message, $this->errors); + return (bool)$result; } - else + catch(\Exception $e) { - $this->procAttachments(); - return parent::Send(); + $this->error = $e->getMessage(); + return false; } } - + /** * Check if DNS of param is real or fake - * - * @param string $email_address Email address - * @return boolean TRUE if param is valid DNS otherwise FALSE + * + * @param string $email_address Email address to check + * @return bool */ - function checkMailMX($email_address) + public function checkMailMX($email_address) { - if(!Mail::isVaildMailAddress($email_address)) + if(!self::isVaildMailAddress($email_address)) { return FALSE; } @@ -612,14 +438,14 @@ class Mail extends PHPMailer } return TRUE; } - + /** * Check if param is a valid email or not - * - * @param string $email_address Email address - * @return string email address if param is valid email address otherwise blank string + * + * @param string $email_address Email address to check + * @return string */ - function isVaildMailAddress($email_address) + public function isVaildMailAddress($email_address) { if(preg_match("/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address)) { diff --git a/libs/phpmailer/LICENSE b/libs/phpmailer/LICENSE deleted file mode 100644 index 0d3dec198..000000000 --- a/libs/phpmailer/LICENSE +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/libs/phpmailer/class.phpmailer.php b/libs/phpmailer/class.phpmailer.php deleted file mode 100644 index afb71b25f..000000000 --- a/libs/phpmailer/class.phpmailer.php +++ /dev/null @@ -1,1909 +0,0 @@ -ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Sets Mailer to send message using SMTP. - * @return void - */ - function IsSMTP() { - $this->Mailer = 'smtp'; - } - - /** - * Sets Mailer to send message using PHP mail() function. - * @return void - */ - function IsMail() { - $this->Mailer = 'mail'; - } - - /** - * Sets Mailer to send message using the $Sendmail program. - * @return void - */ - function IsSendmail() { - $this->Mailer = 'sendmail'; - } - - /** - * Sets Mailer to send message using the qmail MTA. - * @return void - */ - function IsQmail() { - $this->Sendmail = '/var/qmail/bin/sendmail'; - $this->Mailer = 'sendmail'; - } - - ///////////////////////////////////////////////// - // METHODS, RECIPIENTS - ///////////////////////////////////////////////// - - /** - * Adds a "To" address. - * @param string $address - * @param string $name - * @return void - */ - function AddAddress($address, $name = '') { - $cur = count($this->to); - $this->to[$cur][0] = trim($address); - $this->to[$cur][1] = $name; - } - - /** - * Adds a "Cc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - function AddCC($address, $name = '') { - $cur = count($this->cc); - $this->cc[$cur][0] = trim($address); - $this->cc[$cur][1] = $name; - } - - /** - * Adds a "Bcc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - function AddBCC($address, $name = '') { - $cur = count($this->bcc); - $this->bcc[$cur][0] = trim($address); - $this->bcc[$cur][1] = $name; - } - - /** - * Adds a "Reply-To" address. - * @param string $address - * @param string $name - * @return void - */ - function AddReplyTo($address, $name = '') { - $cur = count($this->ReplyTo); - $this->ReplyTo[$cur][0] = trim($address); - $this->ReplyTo[$cur][1] = $name; - } - - ///////////////////////////////////////////////// - // METHODS, MAIL SENDING - ///////////////////////////////////////////////// - - /** - * Creates message and assigns Mailer. If the message is - * not sent successfully then it returns false. Use the ErrorInfo - * variable to view description of the error. - * @return bool - */ - function Send() { - $header = ''; - $body = ''; - $result = true; - - if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - $this->SetError($this->Lang('provide_address')); - return false; - } - - /* Set whether the message is multipart/alternative */ - if(!empty($this->AltBody)) { - $this->ContentType = 'multipart/alternative'; - } - - $this->error_count = 0; // reset errors - $this->SetMessageType(); - $header .= $this->CreateHeader(); - $body = $this->CreateBody(); - - if($body == '') { - return false; - } - - /* Choose the mailer */ - switch($this->Mailer) { - case 'sendmail': - $result = $this->SendmailSend($header, $body); - break; - case 'smtp': - $result = $this->SmtpSend($header, $body); - break; - case 'mail': - $result = $this->MailSend($header, $body); - break; - default: - $result = $this->MailSend($header, $body); - break; - //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); - //$result = false; - //break; - } - - return $result; - } - - /** - * Sends mail using the $Sendmail program. - * @access private - * @return bool - */ - function SendmailSend($header, $body) { - if ($this->Sender != '') { - $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); - } else { - $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); - } - - if(!@$mail = popen($sendmail, 'w')) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - - fputs($mail, $header); - fputs($mail, $body); - - $result = pclose($mail); - if (version_compare(phpversion(), '4.2.3') == -1) { - $result = $result >> 8 & 0xFF; - } - if($result != 0) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - return true; - } - - /** - * Sends mail using the PHP mail() function. - * @access private - * @return bool - */ - function MailSend($header, $body) { - - $to = ''; - for($i = 0; $i < count($this->to); $i++) { - if($i != 0) { $to .= ', '; } - $to .= $this->AddrFormat($this->to[$i]); - } - - $toArr = split(',', $to); - - $params = sprintf("-oi -f %s", $this->Sender); - if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); - } - } - - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - - if(!$rt) { - $this->SetError($this->Lang('instantiate')); - return false; - } - - return true; - } - - /** - * Sends mail via SMTP using PhpSMTP (Author: - * Chris Ryan). Returns bool. Returns false if there is a - * bad MAIL FROM, RCPT, or DATA input. - * @access private - * @return bool - */ - function SmtpSend($header, $body) { - include_once($this->PluginDir . 'class.smtp.php'); - $error = ''; - $bad_rcpt = array(); - - if(!$this->SmtpConnect()) { - return false; - } - - $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; - if(!$this->smtp->Mail($smtp_from)) { - $error = $this->Lang('from_failed') . $smtp_from; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - /* Attempt to send attach all recipients */ - for($i = 0; $i < count($this->to); $i++) { - if(!$this->smtp->Recipient($this->to[$i][0])) { - $bad_rcpt[] = $this->to[$i][0]; - } - } - for($i = 0; $i < count($this->cc); $i++) { - if(!$this->smtp->Recipient($this->cc[$i][0])) { - $bad_rcpt[] = $this->cc[$i][0]; - } - } - for($i = 0; $i < count($this->bcc); $i++) { - if(!$this->smtp->Recipient($this->bcc[$i][0])) { - $bad_rcpt[] = $this->bcc[$i][0]; - } - } - - if(count($bad_rcpt) > 0) { // Create error message - for($i = 0; $i < count($bad_rcpt); $i++) { - if($i != 0) { - $error .= ', '; - } - $error .= $bad_rcpt[$i]; - } - $error = $this->Lang('recipients_failed') . $error; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - if(!$this->smtp->Data($header . $body)) { - $this->SetError($this->Lang('data_not_accepted')); - $this->smtp->Reset(); - return false; - } - if($this->SMTPKeepAlive == true) { - $this->smtp->Reset(); - } else { - $this->SmtpClose(); - } - - return true; - } - - /** - * Initiates a connection to an SMTP server. Returns false if the - * operation failed. - * @access private - * @return bool - */ - function SmtpConnect() { - if($this->smtp == NULL) { - $this->smtp = new SMTP(); - } - - $this->smtp->do_debug = $this->SMTPDebug; - $hosts = explode(';', $this->Host); - $index = 0; - $connection = ($this->smtp->Connected()); - - /* Retry while there is no connection */ - while($index < count($hosts) && $connection == false) { - $hostinfo = array(); - if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { - $host = $hostinfo[1]; - $port = $hostinfo[2]; - } else { - $host = $hosts[$index]; - $port = $this->Port; - } - - if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) { - if ($this->Helo != '') { - $this->smtp->Hello($this->Helo); - } else { - $this->smtp->Hello($this->ServerHostname()); - } - - $connection = true; - if($this->SMTPAuth) { - if(!$this->smtp->Authenticate($this->Username, $this->Password)) { - $this->SetError($this->Lang('authenticate')); - $this->smtp->Reset(); - $connection = false; - } - } - } - $index++; - } - if(!$connection) { - $this->SetError($this->Lang('connect_host')); - } - - return $connection; - } - - /** - * Closes the active SMTP session if one exists. - * @return void - */ - function SmtpClose() { - if($this->smtp != NULL) { - if($this->smtp->Connected()) { - $this->smtp->Quit(); - $this->smtp->Close(); - } - } - } - - /** - * Sets the language for all class error messages. Returns false - * if it cannot load the language file. The default language type - * is English. - * @param string $lang_type Type of language (e.g. Portuguese: "br") - * @param string $lang_path Path to the language file directory - * @access public - * @return bool - */ - function SetLanguage($lang_type, $lang_path = 'language/') { - if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) { - include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); - } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) { - include($lang_path.'phpmailer.lang-en.php'); - } else { - $PHPMAILER_LANG = array(); - $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . - $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; - $PHPMAILER_LANG["execute"] = 'Could not execute: '; - $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; - $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; - $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; - $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . - $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; - $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; - $PHPMAILER_LANG["file_access"] = 'Could not access file: '; - $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; - $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; - $PHPMAILER_LANG["signing"] = 'Signing Error: '; - } - $this->language = $PHPMAILER_LANG; - - return true; - } - - ///////////////////////////////////////////////// - // METHODS, MESSAGE CREATION - ///////////////////////////////////////////////// - - /** - * Creates recipient headers. - * @access private - * @return string - */ - function AddrAppend($type, $addr) { - $addr_str = $type . ': '; - $addr_str .= $this->AddrFormat($addr[0]); - if(count($addr) > 1) { - for($i = 1; $i < count($addr); $i++) { - $addr_str .= ', ' . $this->AddrFormat($addr[$i]); - } - } - $addr_str .= $this->LE; - - return $addr_str; - } - - /** - * Formats an address correctly. - * @access private - * @return string - */ - function AddrFormat($addr) { - if(empty($addr[1])) { - $formatted = $this->SecureHeader($addr[0]); - } else { - $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; - } - - return $formatted; - } - - /** - * Wraps message for use with mailers that do not - * automatically perform wrapping and for quoted-printable. - * Original written by philippe. - * @access private - * @return string - */ - function WrapText($message, $length, $qp_mode = false) { - $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == "utf-8"); - - $message = $this->FixEOL($message); - if (substr($message, -1) == $this->LE) { - $message = substr($message, 0, -1); - } - - $line = explode($this->LE, $message); - $message = ''; - for ($i=0 ;$i < count($line); $i++) { - $line_part = explode(' ', $line[$i]); - $buf = ''; - for ($e = 0; $e $length)) { - $space_left = $length - strlen($buf) - 1; - if ($e != 0) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf("=%s", $this->LE); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - $len = $length; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf("=%s", $this->LE); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - $buf .= ($e == 0) ? $word : (' ' . $word); - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - } - $message .= $buf . $this->LE; - } - - return $message; - } - - /** - * Finds last character boundary prior to maxLength in a utf-8 - * quoted (printable) encoded string. - * Original written by Colin Brown. - * @access private - * @param string $encodedText utf-8 QP text - * @param int $maxLength find last character boundary prior to this length - * @return int - */ - function UTF8CharBoundary($encodedText, $maxLength) { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, "="); - if ($encodedCharPos !== false) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - $maxLength = ($encodedCharPos == 0) ? $maxLength : - $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec >= 192) { // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - /** - * Set the body wrapping. - * @access private - * @return void - */ - function SetWordWrap() { - if($this->WordWrap < 1) { - return; - } - - switch($this->message_type) { - case 'alt': - /* fall through */ - case 'alt_attachments': - $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->WrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assembles message header. - * @access private - * @return string - */ - function CreateHeader() { - $result = ''; - - /* Set the boundaries */ - $uniq_id = md5(uniqid(time())); - $this->boundary[1] = 'b1_' . $uniq_id; - $this->boundary[2] = 'b2_' . $uniq_id; - - $result .= $this->HeaderLine('Date', $this->RFCDate()); - if($this->Sender == '') { - $result .= $this->HeaderLine('Return-Path', trim($this->From)); - } else { - $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); - } - - /* To be created automatically by mail() */ - if($this->Mailer != 'mail') { - if(count($this->to) > 0) { - $result .= $this->AddrAppend('To', $this->to); - } elseif (count($this->cc) == 0) { - $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); - } - } - - $from = array(); - $from[0][0] = trim($this->From); - $from[0][1] = $this->FromName; - $result .= $this->AddrAppend('From', $from); - - /* sendmail and mail() extract Cc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { - $result .= $this->AddrAppend('Cc', $this->cc); - } - - /* sendmail and mail() extract Bcc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { - $result .= $this->AddrAppend('Bcc', $this->bcc); - } - - if(count($this->ReplyTo) > 0) { - $result .= $this->AddrAppend('Reply-To', $this->ReplyTo); - } - - /* mail() sets the subject itself */ - if($this->Mailer != 'mail') { - $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); - } - - if($this->MessageID != '') { - $result .= $this->HeaderLine('Message-ID',$this->MessageID); - } else { - $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); - } - $result .= $this->HeaderLine('X-Priority', $this->Priority); - $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']'); - - if($this->ConfirmReadingTo != '') { - $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); - } - - // Add custom headers - for($index = 0; $index < count($this->CustomHeader); $index++) { - $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); - } - if (!$this->sign_key_file) { - $result .= $this->HeaderLine('MIME-Version', '1.0'); - $result .= $this->GetMailMIME(); - } - - return $result; - } - - /** - * Returns the message MIME. - * @access private - * @return string - */ - function GetMailMIME() { - $result = ''; - switch($this->message_type) { - case 'plain': - $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); - $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); - break; - case 'attachments': - /* fall through */ - case 'alt_attachments': - if($this->InlineImageExists()){ - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); - } else { - $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - } - break; - case 'alt': - $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - break; - } - - if($this->Mailer != 'mail') { - $result .= $this->LE.$this->LE; - } - - return $result; - } - - /** - * Assembles the message body. Returns an empty string on failure. - * @access private - * @return string - */ - function CreateBody() { - $result = ''; - if ($this->sign_key_file) { - $result .= $this->GetMailMIME(); - } - - $this->SetWordWrap(); - - switch($this->message_type) { - case 'alt': - $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[1]); - break; - case 'plain': - $result .= $this->EncodeString($this->Body, $this->Encoding); - break; - case 'attachments': - $result .= $this->GetBoundary($this->boundary[1], '', '', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE; - $result .= $this->AttachAll(); - break; - case 'alt_attachments': - $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); - $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[2]); - $result .= $this->AttachAll(); - break; - } - - if($this->IsError()) { - $result = ''; - } else if ($this->sign_key_file) { - $file = tempnam("", "mail"); - $fp = fopen($file, "w"); - fwrite($fp, $result); - fclose($fp); - $signed = tempnam("", "signed"); - - if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { - $fp = fopen($signed, "r"); - $result = fread($fp, filesize($this->sign_key_file)); - $result = ''; - while(!feof($fp)){ - $result = $result . fread($fp, 1024); - } - fclose($fp); - } else { - $this->SetError($this->Lang("signing").openssl_error_string()); - $result = ''; - } - - unlink($file); - unlink($signed); - } - - return $result; - } - - /** - * Returns the start of a message boundary. - * @access private - */ - function GetBoundary($boundary, $charSet, $contentType, $encoding) { - $result = ''; - if($charSet == '') { - $charSet = $this->CharSet; - } - if($contentType == '') { - $contentType = $this->ContentType; - } - if($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->TextLine('--' . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); - $result .= $this->LE; - $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); - $result .= $this->LE; - - return $result; - } - - /** - * Returns the end of a message boundary. - * @access private - */ - function EndBoundary($boundary) { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Sets the message type. - * @access private - * @return void - */ - function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { - $this->message_type = 'plain'; - } else { - if(count($this->attachment) > 0) { - $this->message_type = 'attachments'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { - $this->message_type = 'alt'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { - $this->message_type = 'alt_attachments'; - } - } - } - - /* Returns a formatted header line. - * @access private - * @return string - */ - function HeaderLine($name, $value) { - return $name . ': ' . $value . $this->LE; - } - - /** - * Returns a formatted mail line. - * @access private - * @return string - */ - function TextLine($value) { - return $value . $this->LE; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, ATTACHMENTS - ///////////////////////////////////////////////// - - /** - * Adds an attachment from a path on the filesystem. - * Returns false if the file could not be found - * or accessed. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; // isStringAttachment - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - - return true; - } - - /** - * Attaches all fs, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access private - * @return string - */ - function AttachAll() { - /* Return text of body */ - $mime = array(); - - /* Add all attachments */ - for($i = 0; $i < count($this->attachment); $i++) { - /* Check for string attachment */ - $bString = $this->attachment[$i][5]; - if ($bString) { - $string = $this->attachment[$i][0]; - } else { - $path = $this->attachment[$i][0]; - } - - $filename = $this->attachment[$i][1]; - $name = $this->attachment[$i][2]; - $encoding = $this->attachment[$i][3]; - $type = $this->attachment[$i][4]; - $disposition = $this->attachment[$i][6]; - $cid = $this->attachment[$i][7]; - - $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); - $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); - - if($disposition == 'inline') { - $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - } - - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); - - /* Encode as string attachment */ - if($bString) { - $mime[] = $this->EncodeString($string, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } else { - $mime[] = $this->EncodeFile($path, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } - } - - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); - - return join('', $mime); - } - - /** - * Encodes attachment in requested format. Returns an - * empty string on failure. - * @access private - * @return string - */ - function EncodeFile ($path, $encoding = 'base64') { - if(!@$fd = fopen($path, 'rb')) { - $this->SetError($this->Lang('file_open') . $path); - return ''; - } - $magic_quotes = get_magic_quotes_runtime(); - set_magic_quotes_runtime(0); - $file_buffer = fread($fd, filesize($path)); - $file_buffer = $this->EncodeString($file_buffer, $encoding); - fclose($fd); - set_magic_quotes_runtime($magic_quotes); - - return $file_buffer; - } - - /** - * Encodes string to requested format. Returns an - * empty string on failure. - * @access private - * @return string - */ - function EncodeString ($str, $encoding = 'base64') { - $encoded = ''; - switch(strtolower($encoding)) { - case 'base64': - /* chunk_split is found in PHP >= 3.0.6 */ - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->FixEOL($str); - if (substr($encoded, -(strlen($this->LE))) != $this->LE) - $encoded .= $this->LE; - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->EncodeQP($str); - break; - default: - $this->SetError($this->Lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string to best of Q, B, quoted or none. - * @access private - * @return string - */ - function EncodeHeader ($str, $position = 'text') { - $x = 0; - - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - case 'comment': - $x = preg_match_all('/[()"]/', $str, $matches); - /* Fall-through */ - case 'text': - default: - $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - if ($x == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - /* Try to select the encoding which should produce the shortest output */ - if (strlen($str)/3 < $x) { - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->Base64EncodeWrapMB($str); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->EncodeQ($str, $position); - $encoded = $this->WrapText($encoded, $maxlen, true); - $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Checks if a string contains multibyte characters. - * @access private - * @param string $str multi-byte text to wrap encode - * @return bool - */ - function HasMultiBytes($str) { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return False; - } - } - - /** - * Correctly encodes and wraps long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php - * @access private - * @param string $str multi-byte text to wrap encode - * @return string - */ - function Base64EncodeWrapMB($str) { - $start = "=?".$this->CharSet."?B?"; - $end = "?="; - $encoded = ""; - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $offset = $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } - while (strlen($chunk) > $length); - - $encoded .= $chunk . $this->LE; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($this->LE)); - return $encoded; - } - - /** - * Encode string to quoted-printable. - * @access private - * @return string - */ - function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); - $lines = preg_split('/(?:\r\n|\r|\n)/', $input); - $eol = "\r\n"; - $escape = '='; - $output = ''; - while( list(, $line) = each($lines) ) { - $linlen = strlen($line); - $newline = ''; - for($i = 0; $i < $linlen; $i++) { - $c = substr( $line, $i, 1 ); - $dec = ord( $c ); - if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E - $c = '=2E'; - } - if ( $dec == 32 ) { - if ( $i == ( $linlen - 1 ) ) { // convert space at eol only - $c = '=20'; - } else if ( $space_conv ) { - $c = '=20'; - } - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required - $h2 = floor($dec/16); - $h1 = floor($dec%16); - $c = $escape.$hex[$h2].$hex[$h1]; - } - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted - $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay - $newline = ''; - // check if newline first character will be point or not - if ( $dec == 46 ) { - $c = '=2E'; - } - } - $newline .= $c; - } // end of for - $output .= $newline.$eol; - } // end of while - return $output; - } - - /** - * Encode string to q encoding. - * @access private - * @return string - */ - function EncodeQ ($str, $position = 'text') { - /* There should not be any EOL in the string */ - $encoded = preg_replace("[\r\n]", '', $str); - - switch (strtolower($position)) { - case 'phrase': - $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - case 'comment': - $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - case 'text': - default: - /* Replace every high ascii, control =, ? and _ characters */ - $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', - "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - } - - /* Replace every spaces to _ (more readable than =20) */ - $encoded = str_replace(' ', '_', $encoded); - - return $encoded; - } - - /** - * Adds a string or binary attachment (non-filesystem) to the list. - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return void - */ - function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $string; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $filename; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = true; // isString - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - } - - /** - * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. Make sure to set the $type to an - * image type. For JPEG images use "image/jpeg" and for GIF images - * use "image/gif". - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment. Use this to identify - * the Id for accessing the image in an HTML form. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; - $this->attachment[$cur][6] = 'inline'; - $this->attachment[$cur][7] = $cid; - - return true; - } - - /** - * Returns true if an inline attachment is present. - * @access private - * @return bool - */ - function InlineImageExists() { - $result = false; - for($i = 0; $i < count($this->attachment); $i++) { - if($this->attachment[$i][6] == 'inline') { - $result = true; - break; - } - } - - return $result; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MESSAGE RESET - ///////////////////////////////////////////////// - - /** - * Clears all recipients assigned in the TO array. Returns void. - * @return void - */ - function ClearAddresses() { - $this->to = array(); - } - - /** - * Clears all recipients assigned in the CC array. Returns void. - * @return void - */ - function ClearCCs() { - $this->cc = array(); - } - - /** - * Clears all recipients assigned in the BCC array. Returns void. - * @return void - */ - function ClearBCCs() { - $this->bcc = array(); - } - - /** - * Clears all recipients assigned in the ReplyTo array. Returns void. - * @return void - */ - function ClearReplyTos() { - $this->ReplyTo = array(); - } - - /** - * Clears all recipients assigned in the TO, CC and BCC - * array. Returns void. - * @return void - */ - function ClearAllRecipients() { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - } - - /** - * Clears all previously set filesystem, string, and binary - * attachments. Returns void. - * @return void - */ - function ClearAttachments() { - $this->attachment = array(); - } - - /** - * Clears all custom headers. Returns void. - * @return void - */ - function ClearCustomHeaders() { - $this->CustomHeader = array(); - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MISCELLANEOUS - ///////////////////////////////////////////////// - - /** - * Adds the error message to the error container. - * Returns void. - * @access private - * @return void - */ - function SetError($msg) { - $this->error_count++; - $this->ErrorInfo = $msg; - } - - /** - * Returns the proper RFC 822 formatted date. - * @access private - * @return string - */ - function RFCDate() { - $tz = date('Z'); - $tzs = ($tz < 0) ? '-' : '+'; - $tz = abs($tz); - $tz = (int)($tz/3600)*100 + ($tz%3600)/60; - $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); - - return $result; - } - - /** - * Returns the appropriate server variable. Should work with both - * PHP 4.1.0+ as well as older versions. Returns an empty string - * if nothing is found. - * @access private - * @return mixed - */ - function ServerVar($varName) { - global $HTTP_SERVER_VARS; - global $HTTP_ENV_VARS; - - if(!isset($_SERVER)) { - $_SERVER = $HTTP_SERVER_VARS; - if(!isset($_SERVER['REMOTE_ADDR'])) { - $_SERVER = $HTTP_ENV_VARS; // must be Apache - } - } - - if(isset($_SERVER[$varName])) { - return $_SERVER[$varName]; - } else { - return ''; - } - } - - /** - * Returns the server hostname or 'localhost.localdomain' if unknown. - * @access private - * @return string - */ - function ServerHostname() { - if ($this->Hostname != '') { - $result = $this->Hostname; - } elseif ($this->ServerVar('SERVER_NAME') != '') { - $result = $this->ServerVar('SERVER_NAME'); - } else { - $result = 'localhost.localdomain'; - } - - return $result; - } - - /** - * Returns a message in the appropriate language. - * @access private - * @return string - */ - function Lang($key) { - if(count($this->language) < 1) { - $this->SetLanguage('en'); // set the default language - } - - if(isset($this->language[$key])) { - return $this->language[$key]; - } else { - return 'Language string failed to load: ' . $key; - } - } - - /** - * Returns true if an error occurred. - * @return bool - */ - function IsError() { - return ($this->error_count > 0); - } - - /** - * Changes every end of line from CR or LF to CRLF. - * @access private - * @return string - */ - function FixEOL($str) { - $str = str_replace("\r\n", "\n", $str); - $str = str_replace("\r", "\n", $str); - $str = str_replace("\n", $this->LE, $str); - return $str; - } - - /** - * Adds a custom header. - * @return void - */ - function AddCustomHeader($custom_header) { - $this->CustomHeader[] = explode(':', $custom_header, 2); - } - - /** - * Evaluates the message and returns modifications for inline images and backgrounds - * @access public - * @return $message - */ - function MsgHTML($message,$basedir='') { - preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); - if(isset($images[2])) { - foreach($images[2] as $i => $url) { - // do not change urls for absolute images (thanks to corvuscorax) - if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { - $filename = basename($url); - $directory = dirname($url); - ($directory == '.')?$directory='':''; - $cid = 'cid:' . md5($filename); - $fileParts = split("\.", $filename); - $ext = $fileParts[1]; - $mimeType = $this->_mime_types($ext); - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { - $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); - } - } - } - } - $this->IsHTML(true); - $this->Body = $message; - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); - if ( !empty($textMsg) && empty($this->AltBody) ) { - $this->AltBody = html_entity_decode($textMsg); - } - if ( empty($this->AltBody) ) { - $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; - } - } - - /** - * Gets the mime type of the embedded or inline image - * @access private - * @return mime type of ext - */ - function _mime_types($ext = '') { - $mimes = array( - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'avi' => 'video/x-msvideo', - 'bin' => 'application/macbinary', - 'bmp' => 'image/bmp', - 'class' => 'application/octet-stream', - 'cpt' => 'application/mac-compactpro', - 'css' => 'text/css', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dll' => 'application/octet-stream', - 'dms' => 'application/octet-stream', - 'doc' => 'application/msword', - 'dvi' => 'application/x-dvi', - 'dxr' => 'application/x-director', - 'eml' => 'message/rfc822', - 'eps' => 'application/postscript', - 'exe' => 'application/octet-stream', - 'gif' => 'image/gif', - 'gtar' => 'application/x-gtar', - 'htm' => 'text/html', - 'html' => 'text/html', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'hqx' => 'application/mac-binhex40', - 'js' => 'application/x-javascript', - 'lha' => 'application/octet-stream', - 'log' => 'text/plain', - 'lzh' => 'application/octet-stream', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mif' => 'application/vnd.mif', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpga' => 'audio/mpeg', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'php' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'phtml' => 'application/x-httpd-php', - 'png' => 'image/png', - 'ppt' => 'application/vnd.ms-powerpoint', - 'ps' => 'application/postscript', - 'psd' => 'application/octet-stream', - 'qt' => 'video/quicktime', - 'ra' => 'audio/x-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'rtf' => 'text/rtf', - 'rtx' => 'text/richtext', - 'rv' => 'video/vnd.rn-realvideo', - 'sea' => 'application/octet-stream', - 'shtml' => 'text/html', - 'sit' => 'application/x-stuffit', - 'so' => 'application/octet-stream', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'text' => 'text/plain', - 'txt' => 'text/plain', - 'tgz' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'wav' => 'audio/x-wav', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'word' => 'application/msword', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xl' => 'application/excel', - 'xls' => 'application/vnd.ms-excel', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'zip' => 'application/zip' - ); - return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; - } - - /** - * Set (or reset) Class Objects (variables) - * - * Usage Example: - * $page->set('X-Priority', '3'); - * - * @access public - * @param string $name Parameter Name - * @param mixed $value Parameter Value - * NOTE: will not work with arrays, there are no arrays to set/reset - */ - function set ( $name, $value = '' ) { - if ( isset($this->$name) ) { - $this->$name = $value; - } else { - $this->SetError('Cannot set or reset variable ' . $name); - return false; - } - } - - /** - * Read a file from a supplied filename and return it. - * - * @access public - * @param string $filename Parameter File Name - */ - function getFile($filename) { - $return = ''; - if ($fp = fopen($filename, 'rb')) { - while (!feof($fp)) { - $return .= fread($fp, 1024); - } - fclose($fp); - return $return; - } else { - return false; - } - } - - /** - * Strips newlines to prevent header injection. - * @access private - * @param string $str String - * @return string - */ - function SecureHeader($str) { - $str = trim($str); - $str = str_replace("\r", "", $str); - $str = str_replace("\n", "", $str); - return $str; - } - - /** - * Set the private key file and password to sign the message. - * - * @access public - * @param string $key_filename Parameter File Name - * @param string $key_pass Password for private key - */ - function Sign($cert_filename, $key_filename, $key_pass) { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - } - -} - -?> \ No newline at end of file diff --git a/libs/phpmailer/class.smtp.php b/libs/phpmailer/class.smtp.php deleted file mode 100644 index be084a116..000000000 --- a/libs/phpmailer/class.smtp.php +++ /dev/null @@ -1,1062 +0,0 @@ -smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - - $this->do_debug = 0; - } - - /************************************************************* - * CONNECTION FUNCTIONS * - ***********************************************************/ - - /** - * Connect to the server specified on the port specified. - * If the port is not specified use the default SMTP_PORT. - * If tval is specified then a connection will try and be - * established with the server for that number of seconds. - * If tval is not specified the default is 30 seconds to - * try on the connection. - * - * SMTP CODE SUCCESS: 220 - * SMTP CODE FAILURE: 421 - * @access public - * @return bool - */ - function Connect($host,$port=0,$tval=30) { - # set the error val to null so there is no confusion - $this->error = null; - - # make sure we are __not__ connected - if($this->connected()) { - # ok we are connected! what should we do? - # for now we will just give an error saying we - # are already connected - $this->error = array("error" => "Already connected to a server"); - return false; - } - - if(empty($port)) { - $port = $this->SMTP_PORT; - } - - #connect to the smtp server - $this->smtp_conn = fsockopen($host, # the host of the server - $port, # the port to use - $errno, # error number if any - $errstr, # error message if any - $tval); # give up after ? secs - # verify we connected properly - if(empty($this->smtp_conn)) { - $this->error = array("error" => "Failed to connect to server", - "errno" => $errno, - "errstr" => $errstr); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": $errstr ($errno)" . $this->CRLF; - } - return false; - } - - # sometimes the SMTP server takes a little longer to respond - # so we will give it a longer timeout for the first read - // Windows still does not have support for this timeout function - if(substr(PHP_OS, 0, 3) != "WIN") - socket_set_timeout($this->smtp_conn, $tval, 0); - - # get any announcement stuff - $announce = $this->get_lines(); - - # set the timeout of any socket functions at 1/10 of a second - //if(function_exists("socket_set_timeout")) - // socket_set_timeout($this->smtp_conn, 0, 100000); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; - } - - return true; - } - - /** - * Performs SMTP authentication. Must be run after running the - * Hello() method. Returns true if successfully authenticated. - * @access public - * @return bool - */ - function Authenticate($username, $password) { - // Start authentication - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "AUTH not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded username - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "Username not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded password - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 235) { - $this->error = - array("error" => "Password not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Returns true if connected to a server otherwise false - * @access private - * @return bool - */ - function Connected() { - if(!empty($this->smtp_conn)) { - $sock_status = socket_get_status($this->smtp_conn); - if($sock_status["eof"]) { - # hmm this is an odd situation... the socket is - # valid but we are not connected anymore - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE:" . $this->CRLF . - "EOF caught while checking if connected"; - } - $this->Close(); - return false; - } - return true; # everything looks good - } - return false; - } - - /** - * Closes the socket and cleans up the state of the class. - * It is not considered good to use this function without - * first trying to use QUIT. - * @access public - * @return void - */ - function Close() { - $this->error = null; # so there is no confusion - $this->helo_rply = null; - if(!empty($this->smtp_conn)) { - # close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = 0; - } - } - - /*************************************************************** - * SMTP COMMANDS * - *************************************************************/ - - /** - * Issues a data command and sends the msg_data to the server - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being seperated by and additional . - * - * Implements rfc 821: DATA - * - * SMTP CODE INTERMEDIATE: 354 - * [data] - * . - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 552,554,451,452 - * SMTP CODE FAILURE: 451,554 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - function Data($msg_data) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Data() without being connected"); - return false; - } - - fputs($this->smtp_conn,"DATA" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 354) { - $this->error = - array("error" => "DATA command not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - # the server is ready to accept data! - # according to rfc 821 we should not send more than 1000 - # including the CRLF - # characters on a single line so we will break the data up - # into lines by \r and/or \n then if needed we will break - # each of those into smaller lines to fit within the limit. - # in addition we will be looking for lines that start with - # a period '.' and append and additional period '.' to that - # line. NOTE: this does not count towards are limit. - - # normalize the line breaks so we know the explode works - $msg_data = str_replace("\r\n","\n",$msg_data); - $msg_data = str_replace("\r","\n",$msg_data); - $lines = explode("\n",$msg_data); - - # we need to find a good way to determine is headers are - # in the msg_data or if it is a straight msg body - # currently I am assuming rfc 822 definitions of msg headers - # and if the first field of the first line (':' sperated) - # does not contain a space then it _should_ be a header - # and we can process all lines before a blank "" line as - # headers. - $field = substr($lines[0],0,strpos($lines[0],":")); - $in_headers = false; - if(!empty($field) && !strstr($field," ")) { - $in_headers = true; - } - - $max_line_length = 998; # used below; set here for ease in change - - while(list(,$line) = @each($lines)) { - $lines_out = null; - if($line == "" && $in_headers) { - $in_headers = false; - } - # ok we need to break this line up into several - # smaller lines - while(strlen($line) > $max_line_length) { - $pos = strrpos(substr($line,0,$max_line_length)," "); - - # Patch to fix DOS attack - if(!$pos) { - $pos = $max_line_length - 1; - } - - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos + 1); - # if we are processing headers we need to - # add a LWSP-char to the front of the new line - # rfc 822 on long msg headers - if($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - # now send the lines to the server - while(list(,$line_out) = @each($lines_out)) { - if(strlen($line_out) > 0) - { - if(substr($line_out, 0, 1) == ".") { - $line_out = "." . $line_out; - } - } - fputs($this->smtp_conn,$line_out . $this->CRLF); - } - } - - # ok all the message data has been sent so lets get this - # over with aleady - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "DATA not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Expand takes the name and asks the server to list all the - * people who are members of the _list_. Expand will return - * back and array of the result or false if an error occurs. - * Each value in the array returned has the format of: - * [ ] - * The definition of is defined in rfc 821 - * - * Implements rfc 821: EXPN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 550 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string array - */ - function Expand($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Expand() without being connected"); - return false; - } - - fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "EXPN not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - # parse the reply and place in our array to return to user - $entries = explode($this->CRLF,$rply); - while(list(,$l) = @each($entries)) { - $list[] = substr($l,4); - } - - return $list; - } - - /** - * Sends the HELO command to the smtp server. - * This makes sure that we and the server are in - * the same known state. - * - * Implements from rfc 821: HELO - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 501, 504, 421 - * @access public - * @return bool - */ - function Hello($host="") { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Hello() without being connected"); - return false; - } - - # if a hostname for the HELO was not specified determine - # a suitable one to send - if(empty($host)) { - # we need to determine some sort of appopiate default - # to send to the server - $host = "localhost"; - } - - // Send extended hello first (RFC 2821) - if(!$this->SendHello("EHLO", $host)) - { - if(!$this->SendHello("HELO", $host)) - return false; - } - - return true; - } - - /** - * Sends a HELO/EHLO command. - * @access private - * @return bool - */ - function SendHello($hello, $host) { - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => $hello . " not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - $this->helo_rply = $rply; - - return true; - } - - /** - * Gets help information on the keyword specified. If the keyword - * is not specified then returns generic help, ussually contianing - * A list of keywords that help is available on. This function - * returns the results back to the user. It is up to the user to - * handle the returned data. If an error occurs then false is - * returned with $this->error set appropiately. - * - * Implements rfc 821: HELP [ ] - * - * SMTP CODE SUCCESS: 211,214 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string - */ - function Help($keyword="") { - $this->error = null; # to avoid confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Help() without being connected"); - return false; - } - - $extra = ""; - if(!empty($keyword)) { - $extra = " " . $keyword; - } - - fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 211 && $code != 214) { - $this->error = - array("error" => "HELP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return $rply; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. - * - * Implements rfc 821: MAIL FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,421 - * @access public - * @return bool - */ - function Mail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Mail() without being connected"); - return false; - } - - $useVerp = ($this->do_verp ? "XVERP" : ""); - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "MAIL not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the command NOOP to the SMTP server. - * - * Implements from rfc 821: NOOP - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 421 - * @access public - * @return bool - */ - function Noop() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Noop() without being connected"); - return false; - } - - fputs($this->smtp_conn,"NOOP" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "NOOP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the quit command to the server and then closes the socket - * if there is no error or the $close_on_error argument is true. - * - * Implements from rfc 821: QUIT - * - * SMTP CODE SUCCESS: 221 - * SMTP CODE ERROR : 500 - * @access public - * @return bool - */ - function Quit($close_on_error=true) { - $this->error = null; # so there is no confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Quit() without being connected"); - return false; - } - - # send the quit command to the server - fputs($this->smtp_conn,"quit" . $this->CRLF); - - # get any good-bye messages - $byemsg = $this->get_lines(); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; - } - - $rval = true; - $e = null; - - $code = substr($byemsg,0,3); - if($code != 221) { - # use e as a tmp var cause Close will overwrite $this->error - $e = array("error" => "SMTP server rejected quit command", - "smtp_code" => $code, - "smtp_rply" => substr($byemsg,4)); - $rval = false; - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $e["error"] . ": " . - $byemsg . $this->CRLF; - } - } - - if(empty($e) || $close_on_error) { - $this->Close(); - } - - return $rval; - } - - /** - * Sends the command RCPT to the SMTP server with the TO: argument of $to. - * Returns true if the recipient was accepted false if it was rejected. - * - * Implements from rfc 821: RCPT TO: - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - function Recipient($to) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Recipient() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "RCPT not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the RSET command to abort and transaction that is - * currently in progress. Returns true if successful false - * otherwise. - * - * Implements rfc 821: RSET - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500,501,504,421 - * @access public - * @return bool - */ - function Reset() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Reset() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RSET" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "RSET failed", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in. - * - * Implements rfc 821: SEND FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function Send($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Send() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SEND not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * - * Implements rfc 821: SAML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function SendAndMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendAndMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SAML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in or mail it to them if they are not. - * - * Implements rfc 821: SOML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function SendOrMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendOrMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SOML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * This is an optional command for SMTP that this class does not - * support. This method is here to make the RFC821 Definition - * complete for this class and __may__ be implimented in the future - * - * Implements from rfc 821: TURN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 502 - * SMTP CODE ERROR : 500, 503 - * @access public - * @return bool - */ - function Turn() { - $this->error = array("error" => "This method, TURN, of the SMTP ". - "is not implemented"); - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; - } - return false; - } - - /** - * Verifies that the name is recognized by the server. - * Returns false if the name could not be verified otherwise - * the response from the server is returned. - * - * Implements rfc 821: VRFY - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,553 - * SMTP CODE ERROR : 500,501,502,421 - * @access public - * @return int - */ - function Verify($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Verify() without being connected"); - return false; - } - - fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "VRFY failed on name '$name'", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return $rply; - } - - /******************************************************************* - * INTERNAL FUNCTIONS * - ******************************************************************/ - - /** - * Read in as many lines as possible - * either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access private - * @return string - */ - function get_lines() { - $data = ""; - while($str = @fgets($this->smtp_conn,515)) { - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data was \"$data\"" . - $this->CRLF; - echo "SMTP -> get_lines(): \$str is \"$str\"" . - $this->CRLF; - } - $data .= $str; - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; - } - # if the 4th character is a space then we are done reading - # so just break the loop - if(substr($str,3,1) == " ") { break; } - } - return $data; - } - -} - - - ?> diff --git a/libs/phpmailer/index.html b/libs/phpmailer/index.html deleted file mode 100644 index 2efb97f31..000000000 --- a/libs/phpmailer/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libs/phpmailer/language/index.html b/libs/phpmailer/language/index.html deleted file mode 100644 index 2efb97f31..000000000 --- a/libs/phpmailer/language/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libs/phpmailer/language/phpmailer.lang-en.php b/libs/phpmailer/language/phpmailer.lang-en.php deleted file mode 100644 index 34b692316..000000000 --- a/libs/phpmailer/language/phpmailer.lang-en.php +++ /dev/null @@ -1,23 +0,0 @@ -exceptions = ($exceptions == true); - } - - /** - * Sets message type to HTML. - * @param bool $ishtml - * @return void - */ - public function IsHTML($ishtml = true) { - if ($ishtml) { - $this->ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Sets Mailer to send message using SMTP. - * @return void - */ - public function IsSMTP() { - $this->Mailer = 'smtp'; - } - - /** - * Sets Mailer to send message using PHP mail() function. - * @return void - */ - public function IsMail() { - $this->Mailer = 'mail'; - } - - /** - * Sets Mailer to send message using the $Sendmail program. - * @return void - */ - public function IsSendmail() { - if (!stristr(ini_get('sendmail_path'), 'sendmail')) { - $this->Sendmail = '/var/qmail/bin/sendmail'; - } - $this->Mailer = 'sendmail'; - } - - /** - * Sets Mailer to send message using the qmail MTA. - * @return void - */ - public function IsQmail() { - if (stristr(ini_get('sendmail_path'), 'qmail')) { - $this->Sendmail = '/var/qmail/bin/sendmail'; - } - $this->Mailer = 'sendmail'; - } - - ///////////////////////////////////////////////// - // METHODS, RECIPIENTS - ///////////////////////////////////////////////// - - /** - * Adds a "To" address. - * @param string $address - * @param string $name - * @return boolean true on success, false if address already used - */ - public function AddAddress($address, $name = '') { - return $this->AddAnAddress('to', $address, $name); - } - - /** - * Adds a "Cc" address. - * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. - * @param string $address - * @param string $name - * @return boolean true on success, false if address already used - */ - public function AddCC($address, $name = '') { - return $this->AddAnAddress('cc', $address, $name); - } - - /** - * Adds a "Bcc" address. - * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. - * @param string $address - * @param string $name - * @return boolean true on success, false if address already used - */ - public function AddBCC($address, $name = '') { - return $this->AddAnAddress('bcc', $address, $name); - } - - /** - * Adds a "Reply-to" address. - * @param string $address - * @param string $name - * @return boolean - */ - public function AddReplyTo($address, $name = '') { - return $this->AddAnAddress('ReplyTo', $address, $name); - } - - /** - * Adds an address to one of the recipient arrays - * Addresses that have been added already return false, but do not throw exceptions - * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo' - * @param string $address The email address to send to - * @param string $name - * @return boolean true on success, false if address already used or invalid in some way - * @access private - */ - private function AddAnAddress($kind, $address, $name = '') { - if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { - echo 'Invalid recipient array: ' . kind; - return false; - } - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - if (!self::ValidateAddress($address)) { - $this->SetError($this->Lang('invalid_address').': '. $address); - if ($this->exceptions) { - throw new phpmailerException($this->Lang('invalid_address').': '.$address); - } - echo $this->Lang('invalid_address').': '.$address; - return false; - } - if ($kind != 'ReplyTo') { - if (!isset($this->all_recipients[strtolower($address)])) { - array_push($this->$kind, array($address, $name)); - $this->all_recipients[strtolower($address)] = true; - return true; - } - } else { - if (!array_key_exists(strtolower($address), $this->ReplyTo)) { - $this->ReplyTo[strtolower($address)] = array($address, $name); - return true; - } - } - return false; -} - -/** - * Set the From and FromName properties - * @param string $address - * @param string $name - * @return boolean - */ - public function SetFrom($address, $name = '',$auto=1) { - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - if (!self::ValidateAddress($address)) { - $this->SetError($this->Lang('invalid_address').': '. $address); - if ($this->exceptions) { - throw new phpmailerException($this->Lang('invalid_address').': '.$address); - } - echo $this->Lang('invalid_address').': '.$address; - return false; - } - $this->From = $address; - $this->FromName = $name; - if ($auto) { - if (empty($this->ReplyTo)) { - $this->AddAnAddress('ReplyTo', $address, $name); - } - if (empty($this->Sender)) { - $this->Sender = $address; - } - } - return true; - } - - /** - * Check that a string looks roughly like an email address should - * Static so it can be used without instantiation - * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator - * Conforms approximately to RFC2822 - * @link http://www.hexillion.com/samples/#Regex Original pattern found here - * @param string $address The email address to check - * @return boolean - * @static - * @access public - */ - public static function ValidateAddress($address) { - if (function_exists('filter_var')) { //Introduced in PHP 5.2 - if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { - return false; - } else { - return true; - } - } else { - return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); - } - } - - ///////////////////////////////////////////////// - // METHODS, MAIL SENDING - ///////////////////////////////////////////////// - - /** - * Creates message and assigns Mailer. If the message is - * not sent successfully then it returns false. Use the ErrorInfo - * variable to view description of the error. - * @return bool - */ - public function Send() { - try { - if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); - } - - // Set whether the message is multipart/alternative - if(!empty($this->AltBody)) { - $this->ContentType = 'multipart/alternative'; - } - - $this->error_count = 0; // reset errors - $this->SetMessageType(); - $header = $this->CreateHeader(); - $body = $this->CreateBody(); - - if (empty($this->Body)) { - throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); - } - - // digitally sign with DKIM if enabled - if ($this->DKIM_domain && $this->DKIM_private) { - $header_dkim = $this->DKIM_Add($header,$this->Subject,$body); - $header = str_replace("\r\n","\n",$header_dkim) . $header; - } - - // Choose the mailer and send through it - switch($this->Mailer) { - case 'sendmail': - return $this->SendmailSend($header, $body); - case 'smtp': - return $this->SmtpSend($header, $body); - default: - return $this->MailSend($header, $body); - } - - } catch (phpmailerException $e) { - $this->SetError($e->getMessage()); - if ($this->exceptions) { - throw $e; - } - echo $e->getMessage()."\n"; - return false; - } - } - - /** - * Sends mail using the $Sendmail program. - * @param string $header The message headers - * @param string $body The message body - * @access protected - * @return bool - */ - protected function SendmailSend($header, $body) { - if ($this->Sender != '') { - $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); - } else { - $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); - } - if ($this->SingleTo === true) { - foreach ($this->SingleToArray as $key => $val) { - if(!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, "To: " . $val . "\n"); - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - // implement call back function if it exists - $isSent = ($result == 0) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); - if($result != 0) { - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - } else { - if(!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - // implement call back function if it exists - $isSent = ($result == 0) ? 1 : 0; - $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body); - if($result != 0) { - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - return true; - } - - /** - * Sends mail using the PHP mail() function. - * @param string $header The message headers - * @param string $body The message body - * @access protected - * @return bool - */ - protected function MailSend($header, $body) { - $toArr = array(); - foreach($this->to as $t) { - $toArr[] = $this->AddrFormat($t); - } - $to = implode(', ', $toArr); - - $params = sprintf("-oi -f %s", $this->Sender); - if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - // implement call back function if it exists - $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - // implement call back function if it exists - $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); - } - } else { - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - // implement call back function if it exists - $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); - // implement call back function if it exists - $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); - } - } - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - if(!$rt) { - throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL); - } - return true; - } - - /** - * Sends mail via SMTP using PhpSMTP - * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. - * @param string $header The message headers - * @param string $body The message body - * @uses SMTP - * @access protected - * @return bool - */ - protected function SmtpSend($header, $body) { - require_once $this->PluginDir . 'smtp.php'; - $bad_rcpt = array(); - - if(!$this->SmtpConnect()) { - throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL); - } - $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; - if(!$this->smtp->Mail($smtp_from)) { - throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL); - } - - // Attempt to send attach all recipients - foreach($this->to as $to) { - if (!$this->smtp->Recipient($to[0])) { - $bad_rcpt[] = $to[0]; - // implement call back function if it exists - $isSent = 0; - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); - } else { - // implement call back function if it exists - $isSent = 1; - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); - } - } - foreach($this->cc as $cc) { - if (!$this->smtp->Recipient($cc[0])) { - $bad_rcpt[] = $cc[0]; - // implement call back function if it exists - $isSent = 0; - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); - } else { - // implement call back function if it exists - $isSent = 1; - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); - } - } - foreach($this->bcc as $bcc) { - if (!$this->smtp->Recipient($bcc[0])) { - $bad_rcpt[] = $bcc[0]; - // implement call back function if it exists - $isSent = 0; - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); - } else { - // implement call back function if it exists - $isSent = 1; - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); - } - } - - - if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses - $badaddresses = implode(', ', $bad_rcpt); - throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses); - } - if(!$this->smtp->Data($header . $body)) { - throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL); - } - if($this->SMTPKeepAlive == true) { - $this->smtp->Reset(); - } - return true; - } - - /** - * Initiates a connection to an SMTP server. - * Returns false if the operation failed. - * @uses SMTP - * @access public - * @return bool - */ - public function SmtpConnect() { - if(is_null($this->smtp)) { - $this->smtp = new SMTP(); - } - - $this->smtp->do_debug = $this->SMTPDebug; - $hosts = explode(';', $this->Host); - $index = 0; - $connection = $this->smtp->Connected(); - - // Retry while there is no connection - try { - while($index < count($hosts) && !$connection) { - $hostinfo = array(); - if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { - $host = $hostinfo[1]; - $port = $hostinfo[2]; - } else { - $host = $hosts[$index]; - $port = $this->Port; - } - - $tls = ($this->SMTPSecure == 'tls'); - $ssl = ($this->SMTPSecure == 'ssl'); - - if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { - - $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); - $this->smtp->Hello($hello); - - if($tls) { - if(!$this->smtp->StartTLS()) { - throw new phpmailerException($this->Lang('tls')); - } - - //We must resend HELO after tls negotiation - $this->smtp->Hello($hello); - } - - $connection = true; - if($this->SMTPAuth) { - if(!$this->smtp->Authenticate($this->Username, $this->Password)) { - throw new phpmailerException($this->Lang('authenticate')); - } - } - } - $index++; - if(!$connection) { - throw new phpmailerException($this->Lang('connect_host')); - } - } - } catch (phpmailerException $e) { - $this->smtp->Reset(); - throw $e; - } - return true; - } - - /** - * Closes the active SMTP session if one exists. - * @return void - */ - public function SmtpClose() { - if(!is_null($this->smtp)) { - if($this->smtp->Connected()) { - $this->smtp->Quit(); - $this->smtp->Close(); - } - } - } - - /** - * Sets the language for all class error messages. - * Returns false if it cannot load the language file. The default language is English. - * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br") - * @param string $lang_path Path to the language file directory - * @access public - */ - function SetLanguage($langcode = 'en', $lang_path = 'language/') { - //Define full set of translatable strings - $PHPMAILER_LANG = array( - 'provide_address' => 'You must provide at least one recipient email address.', - 'mailer_not_supported' => ' mailer is not supported.', - 'execute' => 'Could not execute: ', - 'instantiate' => 'Could not instantiate mail function.', - 'authenticate' => 'SMTP Error: Could not authenticate.', - 'from_failed' => 'The following From address failed: ', - 'recipients_failed' => 'SMTP Error: The following recipients failed: ', - 'data_not_accepted' => 'SMTP Error: Data not accepted.', - 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', - 'file_access' => 'Could not access file: ', - 'file_open' => 'File Error: Could not open file: ', - 'encoding' => 'Unknown encoding: ', - 'signing' => 'Signing Error: ', - 'smtp_error' => 'SMTP server error: ', - 'empty_message' => 'Message body empty', - 'invalid_address' => 'Invalid address', - 'variable_set' => 'Cannot set or reset variable: ' - ); - //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"! - $l = true; - if ($langcode != 'en') { //There is no English translation file - $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php'; - } - $this->language = $PHPMAILER_LANG; - return ($l == true); //Returns false if language not found - } - - /** - * Return the current array of language strings - * @return array - */ - public function GetTranslations() { - return $this->language; - } - - ///////////////////////////////////////////////// - // METHODS, MESSAGE CREATION - ///////////////////////////////////////////////// - - /** - * Creates recipient headers. - * @access public - * @return string - */ - public function AddrAppend($type, $addr) { - $addr_str = $type . ': '; - $addresses = array(); - foreach ($addr as $a) { - $addresses[] = $this->AddrFormat($a); - } - $addr_str .= implode(', ', $addresses); - $addr_str .= $this->LE; - - return $addr_str; - } - - /** - * Formats an address correctly. - * @access public - * @return string - */ - public function AddrFormat($addr) { - if(empty($addr[1])) { - return $this->SecureHeader($addr[0]); - } else { - return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; - } - } - - /** - * Wraps message for use with mailers that do not - * automatically perform wrapping and for quoted-printable. - * Original written by philippe. - * @param string $message The message to wrap - * @param integer $length The line length to wrap to - * @param boolean $qp_mode Whether to run in Quoted-Printable mode - * @access public - * @return string - */ - public function WrapText($message, $length, $qp_mode = false) { - $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == "utf-8"); - - $message = $this->FixEOL($message); - if (substr($message, -1) == $this->LE) { - $message = substr($message, 0, -1); - } - - $line = explode($this->LE, $message); - $message = ''; - for ($i=0 ;$i < count($line); $i++) { - $line_part = explode(' ', $line[$i]); - $buf = ''; - for ($e = 0; $e $length)) { - $space_left = $length - strlen($buf) - 1; - if ($e != 0) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf("=%s", $this->LE); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - $len = $length; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf("=%s", $this->LE); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - $buf .= ($e == 0) ? $word : (' ' . $word); - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - } - $message .= $buf . $this->LE; - } - - return $message; - } - - /** - * Finds last character boundary prior to maxLength in a utf-8 - * quoted (printable) encoded string. - * Original written by Colin Brown. - * @access public - * @param string $encodedText utf-8 QP text - * @param int $maxLength find last character boundary prior to this length - * @return int - */ - public function UTF8CharBoundary($encodedText, $maxLength) { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, "="); - if ($encodedCharPos !== false) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - $maxLength = ($encodedCharPos == 0) ? $maxLength : - $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec >= 192) { // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - - /** - * Set the body wrapping. - * @access public - * @return void - */ - public function SetWordWrap() { - if($this->WordWrap < 1) { - return; - } - - switch($this->message_type) { - case 'alt': - case 'alt_attachments': - $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->WrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assembles message header. - * @access public - * @return string The assembled header - */ - public function CreateHeader() { - $result = ''; - - // Set the boundaries - $uniq_id = md5(uniqid(time())); - $this->boundary[1] = 'b1_' . $uniq_id; - $this->boundary[2] = 'b2_' . $uniq_id; - - $result .= $this->HeaderLine('Date', self::RFCDate()); - if($this->Sender == '') { - $result .= $this->HeaderLine('Return-Path', trim($this->From)); - } else { - $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); - } - - // To be created automatically by mail() - if($this->Mailer != 'mail') { - if ($this->SingleTo === true) { - foreach($this->to as $t) { - $this->SingleToArray[] = $this->AddrFormat($t); - } - } else { - if(count($this->to) > 0) { - $result .= $this->AddrAppend('To', $this->to); - } elseif (count($this->cc) == 0) { - $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); - } - } - } - - $from = array(); - $from[0][0] = trim($this->From); - $from[0][1] = $this->FromName; - $result .= $this->AddrAppend('From', $from); - - // sendmail and mail() extract Cc from the header before sending - if(count($this->cc) > 0) { - $result .= $this->AddrAppend('Cc', $this->cc); - } - - // sendmail and mail() extract Bcc from the header before sending - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { - $result .= $this->AddrAppend('Bcc', $this->bcc); - } - - if(count($this->ReplyTo) > 0) { - $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); - } - - // mail() sets the subject itself - if($this->Mailer != 'mail') { - $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); - } - - if($this->MessageID != '') { - $result .= $this->HeaderLine('Message-ID',$this->MessageID); - } else { - $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); - } - $result .= $this->HeaderLine('X-Priority', $this->Priority); - $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)'); - - if($this->ConfirmReadingTo != '') { - $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); - } - - // Add custom headers - for($index = 0; $index < count($this->CustomHeader); $index++) { - $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); - } - if (!$this->sign_key_file) { - $result .= $this->HeaderLine('MIME-Version', '1.0'); - $result .= $this->GetMailMIME(); - } - - return $result; - } - - /** - * Returns the message MIME. - * @access public - * @return string - */ - public function GetMailMIME() { - $result = ''; - switch($this->message_type) { - case 'plain': - $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); - $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); - break; - case 'attachments': - case 'alt_attachments': - if($this->InlineImageExists()){ - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); - } else { - $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - } - break; - case 'alt': - $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - break; - } - - if($this->Mailer != 'mail') { - $result .= $this->LE.$this->LE; - } - - return $result; - } - - /** - * Assembles the message body. Returns an empty string on failure. - * @access public - * @return string The assembled message body - */ - public function CreateBody() { - $body = ''; - - if ($this->sign_key_file) { - $body .= $this->GetMailMIME(); - } - - $this->SetWordWrap(); - - switch($this->message_type) { - case 'alt': - $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); - $body .= $this->EncodeString($this->AltBody, $this->Encoding); - $body .= $this->LE.$this->LE; - $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); - $body .= $this->EncodeString($this->Body, $this->Encoding); - $body .= $this->LE.$this->LE; - $body .= $this->EndBoundary($this->boundary[1]); - break; - case 'plain': - $body .= $this->EncodeString($this->Body, $this->Encoding); - break; - case 'attachments': - $body .= $this->GetBoundary($this->boundary[1], '', '', ''); - $body .= $this->EncodeString($this->Body, $this->Encoding); - $body .= $this->LE; - $body .= $this->AttachAll(); - break; - case 'alt_attachments': - $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); - $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body - $body .= $this->EncodeString($this->AltBody, $this->Encoding); - $body .= $this->LE.$this->LE; - $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body - $body .= $this->EncodeString($this->Body, $this->Encoding); - $body .= $this->LE.$this->LE; - $body .= $this->EndBoundary($this->boundary[2]); - $body .= $this->AttachAll(); - break; - } - - if($this->IsError()) { - $body = ''; - } else if ($this->sign_key_file) { - try { - $file = tempnam('', 'mail'); - file_put_contents($file, $body, LOCK_EX); //TODO check this worked - $signed = tempnam("", "signed"); - if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) { - @unlink($file); - @unlink($signed); - $body = file_get_contents($signed); - } else { - @unlink($file); - @unlink($signed); - throw new phpmailerException($this->Lang("signing").openssl_error_string()); - } - } catch (phpmailerException $e) { - $body = ''; - if ($this->exceptions) { - throw $e; - } - } - } - - return $body; - } - - /** - * Returns the start of a message boundary. - * @access private - */ - private function GetBoundary($boundary, $charSet, $contentType, $encoding) { - $result = ''; - if($charSet == '') { - $charSet = $this->CharSet; - } - if($contentType == '') { - $contentType = $this->ContentType; - } - if($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->TextLine('--' . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); - $result .= $this->LE; - $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); - $result .= $this->LE; - - return $result; - } - - /** - * Returns the end of a message boundary. - * @access private - */ - private function EndBoundary($boundary) { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Sets the message type. - * @access private - * @return void - */ - private function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { - $this->message_type = 'plain'; - } else { - if(count($this->attachment) > 0) { - $this->message_type = 'attachments'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { - $this->message_type = 'alt'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { - $this->message_type = 'alt_attachments'; - } - } - } - - /** - * Returns a formatted header line. - * @access public - * @return string - */ - public function HeaderLine($name, $value) { - return $name . ': ' . $value . $this->LE; - } - - /** - * Returns a formatted mail line. - * @access public - * @return string - */ - public function TextLine($value) { - return $value . $this->LE; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, ATTACHMENTS - ///////////////////////////////////////////////// - - /** - * Adds an attachment from a path on the filesystem. - * Returns false if the file could not be found - * or accessed. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - try { - if(!@is_file($path)) { - throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE); - } - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => 'attachment', - 7 => 0 - ); - - } catch (phpmailerException $e) { - $this->SetError($e->getMessage()); - if ($this->exceptions) { - throw $e; - } - echo $e->getMessage()."\n"; - if ( $e->getCode() == self::STOP_CRITICAL ) { - return false; - } - } - return true; - } - - /** - * Return the current array of attachments - * @return array - */ - public function GetAttachments() { - return $this->attachment; - } - - /** - * Attaches all fs, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access private - * @return string - */ - private function AttachAll() { - // Return text of body - $mime = array(); - $cidUniq = array(); - $incl = array(); - - // Add all attachments - foreach ($this->attachment as $attachment) { - // Check for string attachment - $bString = $attachment[5]; - if ($bString) { - $string = $attachment[0]; - } else { - $path = $attachment[0]; - } - - if (in_array($attachment[0], $incl)) { continue; } - $filename = $attachment[1]; - $name = $attachment[2]; - $encoding = $attachment[3]; - $type = $attachment[4]; - $disposition = $attachment[6]; - $cid = $attachment[7]; - $incl[] = $attachment[0]; - if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } - $cidUniq[$cid] = true; - - $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); - $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); - - if($disposition == 'inline') { - $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - } - - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); - - // Encode as string attachment - if($bString) { - $mime[] = $this->EncodeString($string, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } else { - $mime[] = $this->EncodeFile($path, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } - } - - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); - - return join('', $mime); - } - - /** - * Encodes attachment in requested format. - * Returns an empty string on failure. - * @param string $path The full path to the file - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @see EncodeFile() - * @access private - * @return string - */ - private function EncodeFile($path, $encoding = 'base64') { - try { - if (!is_readable($path)) { - throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); - } - if (function_exists('get_magic_quotes')) { - function get_magic_quotes() { - return false; - } -} - if (PHP_VERSION < 5) { - $magic_quotes = get_magic_quotes_runtime(); - set_magic_quotes_runtime(0); - } - $file_buffer = file_get_contents($path); - $file_buffer = $this->EncodeString($file_buffer, $encoding); - if (PHP_VERSION < 5) { set_magic_quotes_runtime($magic_quotes); } - return $file_buffer; - } catch (Exception $e) { - $this->SetError($e->getMessage()); - return ''; - } - } - - /** - * Encodes string to requested format. - * Returns an empty string on failure. - * @param string $str The text to encode - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @access public - * @return string - */ - public function EncodeString ($str, $encoding = 'base64') { - $encoded = ''; - switch(strtolower($encoding)) { - case 'base64': - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->FixEOL($str); - //Make sure it ends with a line break - if (substr($encoded, -(strlen($this->LE))) != $this->LE) - $encoded .= $this->LE; - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->EncodeQP($str); - break; - default: - $this->SetError($this->Lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string to best (shortest) of Q, B, quoted or none. - * @access public - * @return string - */ - public function EncodeHeader ($str, $position = 'text') { - $x = 0; - - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - // Can't use addslashes as we don't know what value has magic_quotes_sybase - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - case 'comment': - $x = preg_match_all('/[()"]/', $str, $matches); - // Fall-through - case 'text': - default: - $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - if ($x == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - // Try to select the encoding which should produce the shortest output - if (strlen($str)/3 < $x) { - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->Base64EncodeWrapMB($str); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->EncodeQ($str, $position); - $encoded = $this->WrapText($encoded, $maxlen, true); - $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Checks if a string contains multibyte characters. - * @access public - * @param string $str multi-byte text to wrap encode - * @return bool - */ - public function HasMultiBytes($str) { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return false; - } - } - - /** - * Correctly encodes and wraps long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php - * @access public - * @param string $str multi-byte text to wrap encode - * @return string - */ - public function Base64EncodeWrapMB($str) { - $start = "=?".$this->CharSet."?B?"; - $end = "?="; - $encoded = ""; - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $offset = $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } - while (strlen($chunk) > $length); - - $encoded .= $chunk . $this->LE; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($this->LE)); - return $encoded; - } - - /** - * Encode string to quoted-printable. - * Only uses standard PHP, slow, but will always work - * @access public - * @param string $string the text to encode - * @param integer $line_max Number of chars allowed on a line before wrapping - * @return string - */ - public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); - $lines = preg_split('/(?:\r\n|\r|\n)/', $input); - $eol = "\r\n"; - $escape = '='; - $output = ''; - while( list(, $line) = each($lines) ) { - $linlen = strlen($line); - $newline = ''; - for($i = 0; $i < $linlen; $i++) { - $c = substr( $line, $i, 1 ); - $dec = ord( $c ); - if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E - $c = '=2E'; - } - if ( $dec == 32 ) { - if ( $i == ( $linlen - 1 ) ) { // convert space at eol only - $c = '=20'; - } else if ( $space_conv ) { - $c = '=20'; - } - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required - $h2 = floor($dec/16); - $h1 = floor($dec%16); - $c = $escape.$hex[$h2].$hex[$h1]; - } - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted - $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay - $newline = ''; - // check if newline first character will be point or not - if ( $dec == 46 ) { - $c = '=2E'; - } - } - $newline .= $c; - } // end of for - $output .= $newline.$eol; - } // end of while - return $output; - } - - /** - * Encode string to RFC2045 (6.7) quoted-printable format - * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version - * Also results in same content as you started with after decoding - * @see EncodeQPphp() - * @access public - * @param string $string the text to encode - * @param integer $line_max Number of chars allowed on a line before wrapping - * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function - * @return string - * @author Marcus Bointon - */ - public function EncodeQP($string, $line_max = 76, $space_conv = false) { - if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3) - return quoted_printable_encode($string); - } - $filters = stream_get_filters(); - if (!in_array('convert.*', $filters)) { //Got convert stream filter? - return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation - } - $fp = fopen('php://temp/', 'r+'); - $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks - $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE); - $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params); - fputs($fp, $string); - rewind($fp); - $out = stream_get_contents($fp); - stream_filter_remove($s); - $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange - fclose($fp); - return $out; - } - - /** - * Encode string to q encoding. - * @link http://tools.ietf.org/html/rfc2047 - * @param string $str the text to encode - * @param string $position Where the text is going to be used, see the RFC for what that means - * @access public - * @return string - */ - public function EncodeQ ($str, $position = 'text') { - // There should not be any EOL in the string - $encoded = preg_replace('/[\r\n]*/', '', $str); - - switch (strtolower($position)) { - case 'phrase': - $encoded = preg_replace_callback('/([^A-Za-z0-9!*+\/ -])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded); - break; - case 'comment': - $encoded = preg_replace_callback('/([\(\)\"])/', function($n) { return '='.sprintf('%02X', ord('\\1')); }, $encoded); - case 'text': - default: - // Replace every high ascii, control =, ? and _ characters - //TODO using /e (equivalent to eval()) is probably not a good idea - $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', - "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - } - - // Replace every spaces to _ (more readable than =20) - $encoded = str_replace(' ', '_', $encoded); - - return $encoded; - } - - /** - * Adds a string or binary attachment (non-filesystem) to the list. - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return void - */ - public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { - // Append to $attachment array - $this->attachment[] = array( - 0 => $string, - 1 => $filename, - 2 => basename($filename), - 3 => $encoding, - 4 => $type, - 5 => true, // isStringAttachment - 6 => 'attachment', - 7 => 0 - ); - } - - /** - * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. Make sure to set the $type to an - * image type. For JPEG images use "image/jpeg" and for GIF images - * use "image/gif". - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment. Use this to identify - * the Id for accessing the image in an HTML form. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - // Append to $attachment array - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => 'inline', - 7 => $cid - ); - - return true; - } - - /** - * Returns true if an inline attachment is present. - * @access public - * @return bool - */ - public function InlineImageExists() { - foreach($this->attachment as $attachment) { - if ($attachment[6] == 'inline') { - return true; - } - } - return false; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MESSAGE RESET - ///////////////////////////////////////////////// - - /** - * Clears all recipients assigned in the TO array. Returns void. - * @return void - */ - public function ClearAddresses() { - foreach($this->to as $to) { - unset($this->all_recipients[strtolower($to[0])]); - } - $this->to = array(); - } - - /** - * Clears all recipients assigned in the CC array. Returns void. - * @return void - */ - public function ClearCCs() { - foreach($this->cc as $cc) { - unset($this->all_recipients[strtolower($cc[0])]); - } - $this->cc = array(); - } - - /** - * Clears all recipients assigned in the BCC array. Returns void. - * @return void - */ - public function ClearBCCs() { - foreach($this->bcc as $bcc) { - unset($this->all_recipients[strtolower($bcc[0])]); - } - $this->bcc = array(); - } - - /** - * Clears all recipients assigned in the ReplyTo array. Returns void. - * @return void - */ - public function ClearReplyTos() { - $this->ReplyTo = array(); - } - - /** - * Clears all recipients assigned in the TO, CC and BCC - * array. Returns void. - * @return void - */ - public function ClearAllRecipients() { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - $this->all_recipients = array(); - } - - /** - * Clears all previously set filesystem, string, and binary - * attachments. Returns void. - * @return void - */ - public function ClearAttachments() { - $this->attachment = array(); - } - - /** - * Clears all custom headers. Returns void. - * @return void - */ - public function ClearCustomHeaders() { - $this->CustomHeader = array(); - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MISCELLANEOUS - ///////////////////////////////////////////////// - - /** - * Adds the error message to the error container. - * @access protected - * @return void - */ - protected function SetError($msg) { - $this->error_count++; - if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { - $lasterror = $this->smtp->getError(); - if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { - $msg .= '

' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "

\n"; - } - } - $this->ErrorInfo = $msg; - } - - /** - * Returns the proper RFC 822 formatted date. - * @access public - * @return string - * @static - */ - public static function RFCDate() { - $tz = date('Z'); - $tzs = ($tz < 0) ? '-' : '+'; - $tz = abs($tz); - $tz = (int)($tz/3600)*100 + ($tz%3600)/60; - $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); - - return $result; - } - - /** - * Returns the server hostname or 'localhost.localdomain' if unknown. - * @access private - * @return string - */ - private function ServerHostname() { - if (!empty($this->Hostname)) { - $result = $this->Hostname; - } elseif (isset($_SERVER['SERVER_NAME'])) { - $result = $_SERVER['SERVER_NAME']; - } else { - $result = 'localhost.localdomain'; - } - - return $result; - } - - /** - * Returns a message in the appropriate language. - * @access private - * @return string - */ - private function Lang($key) { - if(count($this->language) < 1) { - $this->SetLanguage('en'); // set the default language - } - - if(isset($this->language[$key])) { - return $this->language[$key]; - } else { - return 'Language string failed to load: ' . $key; - } - } - - /** - * Returns true if an error occurred. - * @access public - * @return bool - */ - public function IsError() { - return ($this->error_count > 0); - } - - /** - * Changes every end of line from CR or LF to CRLF. - * @access private - * @return string - */ - private function FixEOL($str) { - $str = str_replace("\r\n", "\n", $str); - $str = str_replace("\r", "\n", $str); - $str = str_replace("\n", $this->LE, $str); - return $str; - } - - /** - * Adds a custom header. - * @access public - * @return void - */ - public function AddCustomHeader($custom_header) { - $this->CustomHeader[] = explode(':', $custom_header, 2); - } - - /** - * Evaluates the message and returns modifications for inline images and backgrounds - * @access public - * @return $message - */ - public function MsgHTML($message,$basedir='') { - preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); - if(isset($images[2])) { - foreach($images[2] as $i => $url) { - // do not change urls for absolute images (thanks to corvuscorax) - if (!preg_match('#^[A-z]+://#',$url)) { - $filename = basename($url); - $directory = dirname($url); - ($directory == '.')?$directory='':''; - $cid = 'cid:' . md5($filename); - $ext = pathinfo($filename, PATHINFO_EXTENSION); - $mimeType = self::_mime_types($ext); - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { - $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); - } - } - } - } - $this->IsHTML(true); - $this->Body = $message; - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); - if ( !empty($textMsg) && empty($this->AltBody) ) { - $this->AltBody = html_entity_decode($textMsg); - } - if ( empty($this->AltBody) ) { - $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; - } - } - - /** - * Gets the MIME type of the embedded or inline image - * @param string File extension - * @access public - * @return string MIME type of ext - * @static - */ - public static function _mime_types($ext = '') { - $mimes = array( - 'hqx' => 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'doc' => 'application/msword', - 'bin' => 'application/macbinary', - 'dms' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'exe' => 'application/octet-stream', - 'class' => 'application/octet-stream', - 'psd' => 'application/octet-stream', - 'so' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => 'application/vnd.ms-excel', - 'ppt' => 'application/vnd.ms-powerpoint', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'php' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'js' => 'application/x-javascript', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => 'application/x-tar', - 'xhtml' => 'application/xhtml+xml', - 'xht' => 'application/xhtml+xml', - 'zip' => 'application/zip', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mpga' => 'audio/mpeg', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'rv' => 'video/vnd.rn-realvideo', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', - 'shtml' => 'text/html', - 'txt' => 'text/plain', - 'text' => 'text/plain', - 'log' => 'text/plain', - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie', - 'doc' => 'application/msword', - 'word' => 'application/msword', - 'xl' => 'application/excel', - 'eml' => 'message/rfc822' - ); - return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; - } - - /** - * Set (or reset) Class Objects (variables) - * - * Usage Example: - * $page->set('X-Priority', '3'); - * - * @access public - * @param string $name Parameter Name - * @param mixed $value Parameter Value - * NOTE: will not work with arrays, there are no arrays to set/reset - * @todo Should this not be using __set() magic function? - */ - public function set ( $name, $value = '' ) { - try { - if ( isset($this->$name) ) { - $this->$name = $value; - } else { - throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL); - } - } catch (Exception $e) { - $this->SetError($e->getMessage()); - if ($e->getCode() == self::STOP_CRITICAL) { - return false; - } - } - return true; - } - - /** - * Strips newlines to prevent header injection. - * @access public - * @param string $str String - * @return string - */ - public function SecureHeader($str) { - $str = str_replace("\r", '', $str); - $str = str_replace("\n", '', $str); - return trim($str); - } - - /** - * Set the private key file and password to sign the message. - * - * @access public - * @param string $key_filename Parameter File Name - * @param string $key_pass Password for private key - */ - public function Sign($cert_filename, $key_filename, $key_pass) { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - } - - /** - * Set the private key file and password to sign the message. - * - * @access public - * @param string $key_filename Parameter File Name - * @param string $key_pass Password for private key - */ - public function DKIM_QP($txt) { - $tmp=""; - $line=""; - for ($i=0;$iDKIM_private); - if ($this->DKIM_passphrase!='') { - $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase); - } else { - $privKey = $privKeyStr; - } - if (openssl_sign($s, $signature, $privKey)) { - return base64_encode($signature); - } - } - - /** - * Generate DKIM Canonicalization Header - * - * @access public - * @param string $s Header - */ - public function DKIM_HeaderC($s) { - $s=preg_replace("/\r\n\s+/"," ",$s); - $lines=explode("\r\n",$s); - foreach ($lines as $key=>$line) { - list($heading,$value)=explode(":",$line,2); - $heading=strtolower($heading); - $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces - $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value - } - $s=implode("\r\n",$lines); - return $s; - } - - /** - * Generate DKIM Canonicalization Body - * - * @access public - * @param string $body Message Body - */ - public function DKIM_BodyC($body) { - if ($body == '') return "\r\n"; - // stabilize line endings - $body=str_replace("\r\n","\n",$body); - $body=str_replace("\n","\r\n",$body); - // END stabilize line endings - while (substr($body,strlen($body)-4,4) == "\r\n\r\n") { - $body=substr($body,0,strlen($body)-2); - } - return $body; - } - - /** - * Create the DKIM header, body, as new header - * - * @access public - * @param string $headers_line Header lines - * @param string $subject Subject - * @param string $body Body - */ - public function DKIM_Add($headers_line,$subject,$body) { - $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms - $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body - $DKIMquery = 'dns/txt'; // Query method - $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) - $subject_header = "Subject: $subject"; - $headers = explode("\r\n",$headers_line); - foreach($headers as $header) { - if (strpos($header,'From:') === 0) { - $from_header=$header; - } elseif (strpos($header,'To:') === 0) { - $to_header=$header; - } - } - $from = str_replace('|','=7C',$this->DKIM_QP($from_header)); - $to = str_replace('|','=7C',$this->DKIM_QP($to_header)); - $subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable - $body = $this->DKIM_BodyC($body); - $DKIMlen = strlen($body) ; // Length of body - $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body - $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; - $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". - "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n". - "\th=From:To:Subject;\r\n". - "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n". - "\tz=$from\r\n". - "\t|$to\r\n". - "\t|$subject;\r\n". - "\tbh=" . $DKIMb64 . ";\r\n". - "\tb="; - $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs); - $signed = $this->DKIM_Sign($toSign); - return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; - } - - protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) { - if (!empty($this->action_function) && function_exists($this->action_function)) { - $params = array($isSent,$to,$cc,$bcc,$subject,$body); - call_user_func_array($this->action_function,$params); - } - } -} - -class phpmailerException extends Exception { - public function errorMessage() { - $errorMsg = '' . $this->getMessage() . "
\n"; - return $errorMsg; - } -} -?> \ No newline at end of file diff --git a/libs/phpmailer/smtp.php b/libs/phpmailer/smtp.php deleted file mode 100644 index 6f0553273..000000000 --- a/libs/phpmailer/smtp.php +++ /dev/null @@ -1,815 +0,0 @@ -smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - - $this->do_debug = 0; - } - - ///////////////////////////////////////////////// - // CONNECTION FUNCTIONS - ///////////////////////////////////////////////// - - /** - * Connect to the server specified on the port specified. - * If the port is not specified use the default SMTP_PORT. - * If tval is specified then a connection will try and be - * established with the server for that number of seconds. - * If tval is not specified the default is 30 seconds to - * try on the connection. - * - * SMTP CODE SUCCESS: 220 - * SMTP CODE FAILURE: 421 - * @access public - * @return bool - */ - public function Connect($host,$port=0,$tval=30) { - // set the error val to null so there is no confusion - $this->error = null; - - // make sure we are __not__ connected - if($this->connected()) { - // already connected, generate error - $this->error = array("error" => "Already connected to a server"); - return false; - } - - if(empty($port)) { - $port = $this->SMTP_PORT; - } - - // connect to the smtp server - $this->smtp_conn = @fsockopen($host, // the host of the server - $port, // the port to use - $errno, // error number if any - $errstr, // error message if any - $tval); // give up after ? secs - // verify we connected properly - if(empty($this->smtp_conn)) { - $this->error = array("error" => "Failed to connect to server", - "errno" => $errno, - "errstr" => $errstr); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '
'; - } - return false; - } - - // SMTP server can take longer to respond, give longer timeout for first read - // Windows does not have support for this timeout function - if(substr(PHP_OS, 0, 3) != "WIN") - socket_set_timeout($this->smtp_conn, $tval, 0); - - // get any announcement - $announce = $this->get_lines(); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '
'; - } - - return true; - } - - /** - * Initiate a TLS communication with the server. - * - * SMTP CODE 220 Ready to start TLS - * SMTP CODE 501 Syntax error (no parameters allowed) - * SMTP CODE 454 TLS not available due to temporary reason - * @access public - * @return bool success - */ - public function StartTLS() { - $this->error = null; # to avoid confusion - - if(!$this->connected()) { - $this->error = array("error" => "Called StartTLS() without being connected"); - return false; - } - - fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 220) { - $this->error = - array("error" => "STARTTLS not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - //Begin encrypted connection - if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { - return false; - } - - return true; - } - - /** - * Performs SMTP authentication. Must be run after running the - * Hello() method. Returns true if successfully authenticated. - * @access public - * @return bool - */ - public function Authenticate($username, $password) { - // Start authentication - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "AUTH not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - // Send encoded username - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "Username not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - // Send encoded password - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 235) { - $this->error = - array("error" => "Password not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - return true; - } - - /** - * Returns true if connected to a server otherwise false - * @access public - * @return bool - */ - public function Connected() { - if(!empty($this->smtp_conn)) { - $sock_status = socket_get_status($this->smtp_conn); - if($sock_status["eof"]) { - // the socket is valid but we are not connected - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; - } - $this->Close(); - return false; - } - return true; // everything looks good - } - return false; - } - - /** - * Closes the socket and cleans up the state of the class. - * It is not considered good to use this function without - * first trying to use QUIT. - * @access public - * @return void - */ - public function Close() { - $this->error = null; // so there is no confusion - $this->helo_rply = null; - if(!empty($this->smtp_conn)) { - // close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = 0; - } - } - - ///////////////////////////////////////////////// - // SMTP COMMANDS - ///////////////////////////////////////////////// - - /** - * Issues a data command and sends the msg_data to the server - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being seperated by and additional . - * - * Implements rfc 821: DATA - * - * SMTP CODE INTERMEDIATE: 354 - * [data] - * . - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 552,554,451,452 - * SMTP CODE FAILURE: 451,554 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - public function Data($msg_data) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Data() without being connected"); - return false; - } - - fputs($this->smtp_conn,"DATA" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 354) { - $this->error = - array("error" => "DATA command not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - /* the server is ready to accept data! - * according to rfc 821 we should not send more than 1000 - * including the CRLF - * characters on a single line so we will break the data up - * into lines by \r and/or \n then if needed we will break - * each of those into smaller lines to fit within the limit. - * in addition we will be looking for lines that start with - * a period '.' and append and additional period '.' to that - * line. NOTE: this does not count towards limit. - */ - - // normalize the line breaks so we know the explode works - $msg_data = str_replace("\r\n","\n",$msg_data); - $msg_data = str_replace("\r","\n",$msg_data); - $lines = explode("\n",$msg_data); - - /* we need to find a good way to determine is headers are - * in the msg_data or if it is a straight msg body - * currently I am assuming rfc 822 definitions of msg headers - * and if the first field of the first line (':' sperated) - * does not contain a space then it _should_ be a header - * and we can process all lines before a blank "" line as - * headers. - */ - - $field = substr($lines[0],0,strpos($lines[0],":")); - $in_headers = false; - if(!empty($field) && !strstr($field," ")) { - $in_headers = true; - } - - $max_line_length = 998; // used below; set here for ease in change - - while(list(,$line) = @each($lines)) { - $lines_out = null; - if($line == "" && $in_headers) { - $in_headers = false; - } - // ok we need to break this line up into several smaller lines - while(strlen($line) > $max_line_length) { - $pos = strrpos(substr($line,0,$max_line_length)," "); - - // Patch to fix DOS attack - if(!$pos) { - $pos = $max_line_length - 1; - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos); - } else { - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos + 1); - } - - /* if we are processing headers we need to - * add a LWSP-char to the front of the new line - * rfc 822 on long msg headers - */ - if($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - // send the lines to the server - while(list(,$line_out) = @each($lines_out)) { - if(strlen($line_out) > 0) - { - if(substr($line_out, 0, 1) == ".") { - $line_out = "." . $line_out; - } - } - fputs($this->smtp_conn,$line_out . $this->CRLF); - } - } - - // message data has been sent - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 250) { - $this->error = - array("error" => "DATA not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - return true; - } - - /** - * Sends the HELO command to the smtp server. - * This makes sure that we and the server are in - * the same known state. - * - * Implements from rfc 821: HELO - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 501, 504, 421 - * @access public - * @return bool - */ - public function Hello($host = '') { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Hello() without being connected"); - return false; - } - - // if hostname for HELO was not specified send default - if(empty($host)) { - // determine appropriate default to send to server - $host = "localhost"; - } - - // Send extended hello first (RFC 2821) - if(!$this->SendHello("EHLO", $host)) { - if(!$this->SendHello("HELO", $host)) { - return false; - } - } - - return true; - } - - /** - * Sends a HELO/EHLO command. - * @access private - * @return bool - */ - private function SendHello($hello, $host) { - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '
'; - } - - if($code != 250) { - $this->error = - array("error" => $hello . " not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - $this->helo_rply = $rply; - - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. - * - * Implements rfc 821: MAIL FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,421 - * @access public - * @return bool - */ - public function Mail($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Mail() without being connected"); - return false; - } - - $useVerp = ($this->do_verp ? "XVERP" : ""); - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 250) { - $this->error = - array("error" => "MAIL not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - return true; - } - - /** - * Sends the quit command to the server and then closes the socket - * if there is no error or the $close_on_error argument is true. - * - * Implements from rfc 821: QUIT - * - * SMTP CODE SUCCESS: 221 - * SMTP CODE ERROR : 500 - * @access public - * @return bool - */ - public function Quit($close_on_error=true) { - $this->error = null; // so there is no confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Quit() without being connected"); - return false; - } - - // send the quit command to the server - fputs($this->smtp_conn,"quit" . $this->CRLF); - - // get any good-bye messages - $byemsg = $this->get_lines(); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '
'; - } - - $rval = true; - $e = null; - - $code = substr($byemsg,0,3); - if($code != 221) { - // use e as a tmp var cause Close will overwrite $this->error - $e = array("error" => "SMTP server rejected quit command", - "smtp_code" => $code, - "smtp_rply" => substr($byemsg,4)); - $rval = false; - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '
'; - } - } - - if(empty($e) || $close_on_error) { - $this->Close(); - } - - return $rval; - } - - /** - * Sends the command RCPT to the SMTP server with the TO: argument of $to. - * Returns true if the recipient was accepted false if it was rejected. - * - * Implements from rfc 821: RCPT TO: - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - public function Recipient($to) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Recipient() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "RCPT not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - return true; - } - - /** - * Sends the RSET command to abort and transaction that is - * currently in progress. Returns true if successful false - * otherwise. - * - * Implements rfc 821: RSET - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500,501,504,421 - * @access public - * @return bool - */ - public function Reset() { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Reset() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RSET" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 250) { - $this->error = - array("error" => "RSET failed", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * - * Implements rfc 821: SAML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - public function SendAndMail($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendAndMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; - } - - if($code != 250) { - $this->error = - array("error" => "SAML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; - } - return false; - } - return true; - } - - /** - * This is an optional command for SMTP that this class does not - * support. This method is here to make the RFC821 Definition - * complete for this class and __may__ be implimented in the future - * - * Implements from rfc 821: TURN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 502 - * SMTP CODE ERROR : 500, 503 - * @access public - * @return bool - */ - public function Turn() { - $this->error = array("error" => "This method, TURN, of the SMTP ". - "is not implemented"); - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '
'; - } - return false; - } - - /** - * Get the current error - * @access public - * @return array - */ - public function getError() { - return $this->error; - } - - ///////////////////////////////////////////////// - // INTERNAL FUNCTIONS - ///////////////////////////////////////////////// - - /** - * Read in as many lines as possible - * either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access private - * @return string - */ - private function get_lines() { - $data = ""; - while($str = @fgets($this->smtp_conn,515)) { - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '
'; - echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '
'; - } - $data .= $str; - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '
'; - } - // if 4th character is a space, we are done reading, break the loop - if(substr($str,3,1) == " ") { break; } - } - return $data; - } - -} - -?> \ No newline at end of file From 971a3bd1152aab03d299ac5e75c61b495ff4c1a7 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 16:22:07 +0900 Subject: [PATCH 6/8] Move remaining non-composer classes to common/libraries --- classes/file/FileHandler.class.php | 1 - libs/ftp.class.php => common/libraries/ftp.php | 0 libs/tar.class.php => common/libraries/tar.php | 0 config/config.inc.php | 2 ++ modules/admin/admin.admin.model.php | 3 --- modules/autoinstall/autoinstall.lib.php | 4 ---- modules/install/install.controller.php | 2 -- modules/install/install.model.php | 1 - modules/layout/layout.admin.controller.php | 2 -- 9 files changed, 2 insertions(+), 13 deletions(-) rename libs/ftp.class.php => common/libraries/ftp.php (100%) rename libs/tar.class.php => common/libraries/tar.php (100%) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 9bafafd0c..50faa695c 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -315,7 +315,6 @@ class FileHandler return; } - require_once(_XE_PATH_ . 'libs/ftp.class.php'); $oFtp = new ftp(); if(!$ftp_info->ftp_host) { diff --git a/libs/ftp.class.php b/common/libraries/ftp.php similarity index 100% rename from libs/ftp.class.php rename to common/libraries/ftp.php diff --git a/libs/tar.class.php b/common/libraries/tar.php similarity index 100% rename from libs/tar.class.php rename to common/libraries/tar.php diff --git a/config/config.inc.php b/config/config.inc.php index 92f4fa8af..db7106ba9 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -398,6 +398,8 @@ $GLOBALS['__xe_autoload_file_map'] = array_change_key_case(array( 'HintTableTag' => 'classes/xml/xmlquery/tags/table/HintTableTag.class.php', 'TableTag' => 'classes/xml/xmlquery/tags/table/TableTag.class.php', 'TablesTag' => 'classes/xml/xmlquery/tags/table/TablesTag.class.php', + 'Ftp' => 'common/libraries/ftp.php', + 'Tar' => 'common/libraries/tar.php', ), CASE_LOWER); function __xe_autoload($class_name) diff --git a/modules/admin/admin.admin.model.php b/modules/admin/admin.admin.model.php index e1e613ed5..10cffb366 100644 --- a/modules/admin/admin.admin.model.php +++ b/modules/admin/admin.admin.model.php @@ -177,7 +177,6 @@ class adminAdminModel extends admin { Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang'); @set_time_limit(5); - require_once(_XE_PATH_ . 'libs/ftp.class.php'); $ftp_info = Context::getRequestVars(); @@ -323,8 +322,6 @@ class adminAdminModel extends admin Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang'); @set_time_limit(5); - require_once(_XE_PATH_ . 'libs/ftp.class.php'); - $ftp_info = Context::getRequestVars(); if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { diff --git a/modules/autoinstall/autoinstall.lib.php b/modules/autoinstall/autoinstall.lib.php index b94fc796e..d168f35ce 100644 --- a/modules/autoinstall/autoinstall.lib.php +++ b/modules/autoinstall/autoinstall.lib.php @@ -1,8 +1,6 @@ */ -require_once(_XE_PATH_ . 'libs/ftp.class.php'); - /** * Module installer * @author NAVER (developers@xpressengine.com) @@ -253,8 +251,6 @@ class ModuleInstaller */ function _unPack() { - require_once(_XE_PATH_ . 'libs/tar.class.php'); - $oTar = new tar(); $oTar->openTAR($this->download_file); diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 74e54205b..a24fcfaa5 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -233,7 +233,6 @@ class installController extends install { if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); - require_once(_XE_PATH_.'libs/ftp.class.php'); $oFtp = new ftp(); if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); @@ -292,7 +291,6 @@ class installController extends install } else { - require_once(_XE_PATH_.'libs/ftp.class.php'); $oFtp = new ftp(); if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); diff --git a/modules/install/install.model.php b/modules/install/install.model.php index 0e2da7183..f4b854a50 100644 --- a/modules/install/install.model.php +++ b/modules/install/install.model.php @@ -71,7 +71,6 @@ class installModel extends install } else { - require_once(_XE_PATH_.'libs/ftp.class.php'); $oFtp = new ftp(); if($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { diff --git a/modules/layout/layout.admin.controller.php b/modules/layout/layout.admin.controller.php index 291233212..1e571a24f 100644 --- a/modules/layout/layout.admin.controller.php +++ b/modules/layout/layout.admin.controller.php @@ -593,7 +593,6 @@ class layoutAdminController extends layout $layout_srl = Context::get('layout_srl'); if(!$layout_srl) return new Object('-1','msg_invalid_request'); - require_once(_XE_PATH_.'libs/tar.class.php'); $oLayoutModel = getModel('layout'); // Copy files to temp path @@ -898,7 +897,6 @@ class layoutAdminController extends layout FileHandler::removeFile($user_layout_path . $file); } - require_once(_XE_PATH_.'libs/tar.class.php'); $image_path = $oLayoutModel->getUserLayoutImagePath($layout_srl); FileHandler::makeDir($image_path); $tar = new tar(); From 71ea69a7052be6f2939bfee0bd7384fd086f4710 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 16:24:38 +0900 Subject: [PATCH 7/8] Update path to libraries folder in Gruntfile.js --- Gruntfile.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c2a43256a..66be1ac71 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -67,8 +67,7 @@ module.exports = function(grunt) { "!files/**", "!tests/**", "!tools/**", - "!node_modules/**", - "!libs/**", + "!common/libraries/**", "!vendor/**", "!tests/_output/**" ], From 3888ad79e04f689d0caf5d39c7105b90125174a8 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 17:16:39 +0900 Subject: [PATCH 8/8] Add libs folder to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4c670783e..2917e66cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Thumbs.db config.user.inc.php /files/ /build/ +/libs/ codeception.yml /tests/_output/