diff --git a/.gitignore b/.gitignore index 4df83665e1220..0cce82e01348e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,61 @@ Thumbs.db Desktop.ini # Never ignore # -!.gitignore +# Only apply this rule to the main repository's gitignore files +!/.gitignore +!/build/.gitignore +!/tests/unit/suites/libraries/joomla/archive/.gitignore +!/tests/unit/tmp/.gitignore + +# Extra files installed by Composer not needed in the CMS environment +# This should only ignore files like unit testing or READMEs, production +# code must remain to ensure all libraries properly function +/libraries/vendor/ircmaxell/password-compat/test +/libraries/vendor/ircmaxell/password-compat/.travis.yml +/libraries/vendor/ircmaxell/password-compat/composer.json +/libraries/vendor/ircmaxell/password-compat/phpunit.xml.dist +/libraries/vendor/ircmaxell/password-compat/README.md +/libraries/vendor/ircmaxell/password-compat/version-test.php +/libraries/vendor/joomla/*/docs +/libraries/vendor/joomla/*/Tests +/libraries/vendor/joomla/*/vendor +/libraries/vendor/joomla/*/.travis.yml +/libraries/vendor/joomla/*/CONTRIBUTING.md +/libraries/vendor/joomla/*/composer.json +/libraries/vendor/joomla/*/phpunit.xml.dist +/libraries/vendor/joomla/*/README.md +/libraries/vendor/joomla/session/Joomla/Session/_Tests +/libraries/vendor/joomla/session/Joomla/Session/build +/libraries/vendor/joomla/session/Joomla/Session/Tests +/libraries/vendor/joomla/session/Joomla/Session/composer.json +/libraries/vendor/joomla/session/Joomla/Session/phpunit.xml.dist +/libraries/vendor/joomla/session/Joomla/Session/README.md +/libraries/vendor/leafo/lessphp/docs +/libraries/vendor/leafo/lessphp/tests +/libraries/vendor/leafo/lessphp/.gitignore +/libraries/vendor/leafo/lessphp/.travis.yml +/libraries/vendor/leafo/lessphp/composer.json +/libraries/vendor/leafo/lessphp/Makefile +/libraries/vendor/leafo/lessphp/package.sh +/libraries/vendor/leafo/lessphp/README.md +/libraries/vendor/phpmailer/phpmailer/docs +/libraries/vendor/phpmailer/phpmailer/examples +/libraries/vendor/phpmailer/phpmailer/language +/libraries/vendor/phpmailer/phpmailer/test +/libraries/vendor/phpmailer/phpmailer/.gitignore +/libraries/vendor/phpmailer/phpmailer/.scrutinizer.yml +/libraries/vendor/phpmailer/phpmailer/.travis.yml +/libraries/vendor/phpmailer/phpmailer/changelog.md +/libraries/vendor/phpmailer/phpmailer/composer.json +/libraries/vendor/phpmailer/phpmailer/README.md +/libraries/vendor/phpmailer/phpmailer/travis.phpunit.xml.dist +/libraries/vendor/psr/log/Psr/Log/Test +/libraries/vendor/psr/log/.gitignore +/libraries/vendor/psr/log/composer.json +/libraries/vendor/psr/log/README.md +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Tests +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/README.md diff --git a/.travis.yml b/.travis.yml index 51d0869556942..2e59c2c51357b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ services: before_script: - composer self-update + - composer update - pyrus install -f pear/PHP_CodeSniffer-1.5.5 - pyrus install -f pear/Cache_Lite - phpenv rehash diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index ea79e06e3697c..10ed432f56af1 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -1021,6 +1021,61 @@ public function deleteUnexistingFiles() '/libraries/joomla/registry/format/json.php', '/libraries/joomla/registry/format/php.php', '/libraries/joomla/registry/format/xml.php', + // Joomla! 3.4 + '/administrator/manifests/libraries/phpmailer.xml', + '/language/en-GB/en-GB.lib_phpmailer.sys.ini', + '/libraries/compat/jsonserializable.php', + '/libraries/compat/password/lib/index.html', + '/libraries/compat/password/lib/password.php', + '/libraries/compat/password/lib/version_test.php', + '/libraries/compat/password/index.html', + '/libraries/compat/password/LICENSE.md', + '/libraries/compat/index.html', + '/libraries/framework/Joomla/Application/Cli/Output/Processor/ColorProcessor.php', + '/libraries/framework/Joomla/Application/Cli/Output/Processor/ProcessorInterface.php', + '/libraries/framework/Joomla/Application/Cli/Output/Stdout.php', + '/libraries/framework/Joomla/Application/Cli/Output/Xml.php', + '/libraries/framework/Joomla/Application/Cli/CliOutput.php', + '/libraries/framework/Joomla/Application/Cli/ColorProcessor.php', + '/libraries/framework/Joomla/Application/Cli/ColorStyle.php', + '/libraries/framework/index.html', + '/libraries/framework/Joomla/DI/Exception/DependencyResolutionException.php', + '/libraries/framework/Joomla/DI/Exception/index.html', + '/libraries/framework/Joomla/DI/Container.php', + '/libraries/framework/Joomla/DI/ContainerAwareInterface.php', + '/libraries/framework/Joomla/DI/index.html', + '/libraries/framework/Joomla/DI/ServiceProviderInterface.php', + '/libraries/framework/Joomla/Registry/Format/index.html', + '/libraries/framework/Joomla/Registry/Format/Ini.php', + '/libraries/framework/Joomla/Registry/Format/Json.php', + '/libraries/framework/Joomla/Registry/Format/Php.php', + '/libraries/framework/Joomla/Registry/Format/Xml.php', + '/libraries/framework/Joomla/Registry/Format/Yaml.php', + '/libraries/framework/Joomla/Registry/AbstractRegistryFormat.php', + '/libraries/framework/Joomla/Registry/index.html', + '/libraries/framework/Joomla/Registry/Registry.php', + '/libraries/framework/Symfony/Component/Yaml/Exception/DumpException.php', + '/libraries/framework/Symfony/Component/Yaml/Exception/ExceptionInterface.php', + '/libraries/framework/Symfony/Component/Yaml/Exception/index.html', + '/libraries/framework/Symfony/Component/Yaml/Exception/ParseException.php', + '/libraries/framework/Symfony/Component/Yaml/Exception/RuntimeException.php', + '/libraries/framework/Symfony/Component/Yaml/Dumper.php', + '/libraries/framework/Symfony/Component/Yaml/Escaper.php', + '/libraries/framework/Symfony/Component/Yaml/index.html', + '/libraries/framework/Symfony/Component/Yaml/Inline.php', + '/libraries/framework/Symfony/Component/Yaml/LICENSE', + '/libraries/framework/Symfony/Component/Yaml/Parser.php', + '/libraries/framework/Symfony/Component/Yaml/Unescaper.php', + '/libraries/framework/Symfony/Component/Yaml/Yaml.php', + '/libraries/joomla/string/inflector.php', + '/libraries/joomla/string/normalise.php', + '/libraries/phpmailer/language/index.html', + '/libraries/phpmailer/language/phpmailer.lang-joomla.php', + '/libraries/phpmailer/index.html', + '/libraries/phpmailer/LICENSE', + '/libraries/phpmailer/phpmailer.php', + '/libraries/phpmailer/pop.php', + '/libraries/phpmailer/smtp.php', ); // TODO There is an issue while deleting folders using the ftp mode @@ -1078,6 +1133,24 @@ public function deleteUnexistingFiles() '/plugins/user/joomla/postinstall', '/libraries/joomla/registry/format', '/libraries/joomla/registry', + // Joomla! 3.4 + '/libraries/compat/password/lib', + '/libraries/compat/password', + '/libraries/compat', + '/libraries/framework/Joomla/Application/Cli/Output/Processor', + '/libraries/framework/Joomla/Application/Cli/Output', + '/libraries/framework/Joomla/Application/Cli', + '/libraries/framework/Joomla/Application', + '/libraries/framework/Joomla/DI/Exception', + '/libraries/framework/Joomla/DI', + '/libraries/framework/Joomla/Registry/Format', + '/libraries/framework/Joomla/Registry', + '/libraries/framework/Joomla', + '/libraries/framework/Symfony/Component/Yaml/Exception', + '/libraries/framework/Symfony/Component/Yaml', + '/libraries/framework', + '/libraries/phpmailer/language', + '/libraries/phpmailer', ); jimport('joomla.filesystem.file'); diff --git a/administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-05-05.sql b/administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-05-05.sql new file mode 100644 index 0000000000000..958778d59f983 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-05-05.sql @@ -0,0 +1 @@ +DELETE FROM `#__extensions` WHERE `extension_id` = 100; diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.4.0-2014-05-05.sql b/administrator/components/com_admin/sql/updates/postgresql/3.4.0-2014-05-05.sql new file mode 100644 index 0000000000000..3f63a4b186670 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.4.0-2014-05-05.sql @@ -0,0 +1 @@ +DELETE FROM "#__extensions" WHERE "extension_id" = 100; diff --git a/administrator/components/com_admin/sql/updates/sqlazure/3.4.0-2014-05-05.sql b/administrator/components/com_admin/sql/updates/sqlazure/3.4.0-2014-05-05.sql new file mode 100644 index 0000000000000..2cb4da10c7b79 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/sqlazure/3.4.0-2014-05-05.sql @@ -0,0 +1 @@ +DELETE FROM [#__extensions] WHERE [extension_id] = 100; diff --git a/administrator/manifests/libraries/phpmailer.xml b/administrator/manifests/libraries/phpmailer.xml deleted file mode 100644 index 78f3e6d71eb0b..0000000000000 --- a/administrator/manifests/libraries/phpmailer.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - PHPMailer - phpmailer - 5.2.6 - LIB_PHPMAILER_XML_DESCRIPTION - 2001 - (c) 2001-2003, Brent R. Matzelle, (c) 2004-2009, Andy Prevost. All Rights Reserved., (c) 2010-2013, Jim Jagielski. All Rights Reserved. - http://www.gnu.org/licenses/lgpl-2.1.html GNU/LGPL - PHPMailer - jimjag@gmail.com - https://github.com/PHPMailer/PHPMailer - Joomla! - http://www.joomla.org - - phpmailer - - diff --git a/build.xml b/build.xml index ad0d33e2b0289..de5eab43da1c1 100644 --- a/build.xml +++ b/build.xml @@ -54,6 +54,13 @@ + + + + + + + @@ -66,8 +73,10 @@ + + - + diff --git a/build/build.php b/build/build.php index 51c76b705dac0..700ab698068df 100644 --- a/build/build.php +++ b/build/build.php @@ -109,6 +109,33 @@ "joomla.xml\n" => true ); +/* + * Here we set the files/folders which should not be packaged at any time + * These paths are from the repository root without the leading slash + */ +$doNotPackage = array( + '.gitignore', + '.travis.yml', + 'CONTRIBUTING.md', + 'README.md', + 'build', + 'build.xml', + 'composer.json', + 'composer.lock', + 'phpunit.xml.dist', + 'tests', + 'travisci-phpunit.xml', +); + +/* + * Here we set the files/folders which should not be packaged with patch packages only + * These paths are from the repository root without the leading slash + */ +$doNotPatch = array( + 'installation', + 'images' +); + // For the packages, replace spaces in stability (RC) with underscores $packageStability = str_replace(' ', '_', $stability); @@ -130,19 +157,28 @@ // Loop through and add all files except: tests, installation, build, .git, .travis, travis, phpunit, .md, or images foreach ($files as $file) { - if (substr($file, 2, 5) != 'tests' && substr($file, 2, 12) != 'installation' && substr($file, 2, 5) != 'build' && substr($file, 2, 4) != '.git' + $fileName = substr($file, 2); + $folderPath = explode('/', $file); + $folderName = $folderPath[0]; + + // TODO - Old check, commented for reference, remove when complete + /*if (substr($file, 2, 5) != 'tests' && substr($file, 2, 12) != 'installation' && substr($file, 2, 5) != 'build' && substr($file, 2, 4) != '.git' && substr($file, 2, 7) != '.travis' && substr($file, 2, 6) != 'travis' && substr($file, 2, 7) != 'phpunit' && substr($file, -3) != '.md' && substr($file, 2, 6) != 'images') + {*/ + + if (!in_array($fileName, $doNotPackage) && !in_array($fileName, $doNotPatch) + && !in_array($folderName, $doNotPackage) && !in_array($folderName, $doNotPatch)) { // Don't add deleted files to the list if (substr($file, 0, 1) != 'D') { - $filesArray[substr($file, 2)] = true; + $filesArray[$fileName] = true; } else { // Add deleted files to the deleted files list - $deletedFiles[] = substr($file, 2); + $deletedFiles[] = $fileName; } } } @@ -173,7 +209,7 @@ // Delete the files and folders we exclude from the packages (tests, docs, build, etc.). echo "Delete folders not included in packages.\n"; -$doNotPackage = array('tests', '.gitignore', '.travis.yml', 'build', 'build.xml', 'phpunit.xml.dist', 'travisci-phpunit.xml', 'README.md', 'CONTRIBUTING.md'); + foreach ($doNotPackage as $removeFile) { system('rm -rf ' . $fullVersion . '/' . $removeFile); diff --git a/build/phpcs/Joomla/ruleset.xml b/build/phpcs/Joomla/ruleset.xml index 166a3722e7499..b9a3cb23ef974 100644 --- a/build/phpcs/Joomla/ruleset.xml +++ b/build/phpcs/Joomla/ruleset.xml @@ -13,13 +13,11 @@ libraries/compat/password/* libraries/fof/* - libraries/framework/* libraries/idna_convert/* - libraries/lessc/* libraries/phputf8/* libraries/simplepie/* - libraries/phpmailer/* libraries/phpass/* + libraries/vendor/* administrator/components/com_joomlaupdate/restore.php configuration.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000..b27597c163943 --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "name": "joomla/joomla-cms", + "type": "project", + "description": "Joomla CMS", + "keywords": ["joomla", "cms"], + "homepage": "https://github.com/joomla/joomla-cms", + "license": "GPL-2.0+", + "config": { + "vendor-dir": "libraries/vendor" + }, + "require": { + "php": ">=5.3.10", + "joomla/application": "~1.2", + "joomla/di": "~1.2", + "joomla/registry": "~1.2", + "joomla/string": "~1.2", + "joomla/uri": "~1.1", + "ircmaxell/password-compat": "1.*", + "leafo/lessphp": "0.3.9", + "phpmailer/phpmailer": "5.2.8", + "symfony/yaml": "2.*" + }, + "require-dev": { + "phpunit/phpunit": "4.1.*" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000000000..64d385a1c93aa --- /dev/null +++ b/composer.lock @@ -0,0 +1,725 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "24791640ff576790cc25e687c275b0ee", + "packages": [ + { + "name": "ircmaxell/password-compat", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "shasum": "" + }, + "type": "library", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ], + "time": "2013-04-30 19:58:08" + }, + { + "name": "joomla/application", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/application.git", + "reference": "b7745273664294387bdd7fb694d75e65b7491f28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/application/zipball/b7745273664294387bdd7fb694d75e65b7491f28", + "reference": "b7745273664294387bdd7fb694d75e65b7491f28", + "shasum": "" + }, + "require": { + "joomla/input": "~1.2", + "joomla/registry": "~1.1", + "joomla/session": "~1.1", + "joomla/string": "~1.1", + "joomla/uri": "~1.1", + "php": ">=5.3.10", + "psr/log": "~1.0" + }, + "require-dev": { + "joomla/test": "~1.1", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Joomla\\Application\\": "src/", + "Joomla\\Application\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Application Package", + "homepage": "https://github.com/joomla-framework/application", + "keywords": [ + "application", + "framework", + "joomla" + ], + "time": "2014-10-13 12:43:54" + }, + { + "name": "joomla/compat", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/compat.git", + "reference": "92ba45e9cfdca4c912691bf04ef13e0c03660348" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/compat/zipball/92ba45e9cfdca4c912691bf04ef13e0c03660348", + "reference": "92ba45e9cfdca4c912691bf04ef13e0c03660348", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "type": "joomla-package", + "autoload": { + "classmap": [ + "src/JsonSerializable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Compat Package", + "homepage": "https://github.com/joomla-framework/compat", + "keywords": [ + "compat", + "framework", + "joomla" + ], + "time": "2014-02-09 19:29:20" + }, + { + "name": "joomla/di", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/di.git", + "reference": "4866c58e92ce4e851cd87d5d9d31b069b7284267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/di/zipball/4866c58e92ce4e851cd87d5d9d31b069b7284267", + "reference": "4866c58e92ce4e851cd87d5d9d31b069b7284267", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "type": "joomla-package", + "autoload": { + "psr-4": { + "Joomla\\DI\\": "src/", + "Joomla\\DI\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla DI Package", + "homepage": "https://github.com/joomla-framework/di", + "keywords": [ + "container", + "dependency injection", + "di", + "framework", + "ioc", + "joomla" + ], + "time": "2014-03-21 13:20:34" + }, + { + "name": "joomla/event", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/event.git", + "reference": "bb957bc45aba897e465384bbe21cd0eb79aca901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/event/zipball/bb957bc45aba897e465384bbe21cd0eb79aca901", + "reference": "bb957bc45aba897e465384bbe21cd0eb79aca901", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "type": "joomla-package", + "autoload": { + "psr-4": { + "Joomla\\Event\\": "src/", + "Joomla\\Event\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Event Package", + "homepage": "https://github.com/joomla-framework/event", + "keywords": [ + "event", + "framework", + "joomla" + ], + "time": "2014-02-09 01:30:54" + }, + { + "name": "joomla/filter", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/filter.git", + "reference": "bd097a34c1f94d54589462c960fd41921e61c1c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/filter/zipball/bd097a34c1f94d54589462c960fd41921e61c1c9", + "reference": "bd097a34c1f94d54589462c960fd41921e61c1c9", + "shasum": "" + }, + "require": { + "joomla/string": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/language": "~1.0" + }, + "suggest": { + "joomla/language": "Required only if you want to use `OutputFilter::stringURLSafe`." + }, + "type": "joomla-package", + "autoload": { + "psr-4": { + "Joomla\\Filter\\": "src/", + "Joomla\\Filter\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Filter Package", + "homepage": "https://github.com/joomla-framework/filter", + "keywords": [ + "filter", + "framework", + "joomla" + ], + "time": "2014-02-09 07:45:50" + }, + { + "name": "joomla/input", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/input.git", + "reference": "b6098276043e2d627221fe54d3c91232e6679d0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/input/zipball/b6098276043e2d627221fe54d3c91232e6679d0f", + "reference": "b6098276043e2d627221fe54d3c91232e6679d0f", + "shasum": "" + }, + "require": { + "joomla/filter": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Joomla\\Input\\": "src/", + "Joomla\\Input\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Input Package", + "homepage": "https://github.com/joomla-framework/input", + "keywords": [ + "framework", + "input", + "joomla" + ], + "time": "2014-10-12 18:01:36" + }, + { + "name": "joomla/registry", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/registry.git", + "reference": "7330ea6481d0fe062f46d2b6cb848c212789915e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/registry/zipball/7330ea6481d0fe062f46d2b6cb848c212789915e", + "reference": "7330ea6481d0fe062f46d2b6cb848c212789915e", + "shasum": "" + }, + "require": { + "joomla/compat": "~1.0", + "joomla/string": "~1.2", + "joomla/utilities": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*", + "symfony/yaml": "~2.0" + }, + "suggest": { + "symfony/yaml": "Install 2.* if you require YAML support." + }, + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Joomla\\Registry\\": "src/", + "Joomla\\Registry\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Registry Package", + "homepage": "https://github.com/joomla-framework/registry", + "keywords": [ + "framework", + "joomla", + "registry" + ], + "time": "2014-10-08 16:14:29" + }, + { + "name": "joomla/session", + "version": "1.2.3", + "target-dir": "Joomla/Session", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/session.git", + "reference": "ef955cf9642793c4ad5874f334069051c33ba604" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/session/zipball/ef955cf9642793c4ad5874f334069051c33ba604", + "reference": "ef955cf9642793c4ad5874f334069051c33ba604", + "shasum": "" + }, + "require": { + "joomla/event": "~1.1", + "joomla/filter": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0" + }, + "suggest": { + "joomla/database": "Install joomla/database if you want to use Database session storage." + }, + "type": "joomla-package", + "autoload": { + "psr-0": { + "Joomla\\Session": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Session Package", + "homepage": "https://github.com/joomla-framework/session", + "keywords": [ + "framework", + "joomla", + "session" + ], + "time": "2014-08-18 17:41:06" + }, + { + "name": "joomla/string", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/string.git", + "reference": "edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/string/zipball/edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a", + "reference": "edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Joomla\\String\\": "src/", + "Joomla\\String\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla String Package", + "homepage": "https://github.com/joomla-framework/string", + "keywords": [ + "framework", + "joomla", + "string" + ], + "time": "2014-09-18 12:21:47" + }, + { + "name": "joomla/uri", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/uri.git", + "reference": "980e532e4235bb8f1ada15b28822abbeb171da3f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/uri/zipball/980e532e4235bb8f1ada15b28822abbeb171da3f", + "reference": "980e532e4235bb8f1ada15b28822abbeb171da3f", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "type": "joomla-package", + "autoload": { + "psr-4": { + "Joomla\\Uri\\": "src/", + "Joomla\\Uri\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Uri Package", + "homepage": "https://github.com/joomla-framework/uri", + "keywords": [ + "framework", + "joomla", + "uri" + ], + "time": "2014-02-09 02:57:17" + }, + { + "name": "joomla/utilities", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/utilities.git", + "reference": "f749a9bd6f2fc5ad376687651478273dac105051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/utilities/zipball/f749a9bd6f2fc5ad376687651478273dac105051", + "reference": "f749a9bd6f2fc5ad376687651478273dac105051", + "shasum": "" + }, + "require": { + "joomla/string": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Joomla\\Utilities\\": "src/", + "Joomla\\Utilities\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Utilities Package", + "homepage": "https://github.com/joomla-framework/utilities", + "keywords": [ + "framework", + "joomla", + "utilities" + ], + "time": "2014-09-03 21:44:44" + }, + { + "name": "leafo/lessphp", + "version": "v0.3.9", + "source": { + "type": "git", + "url": "https://github.com/leafo/lessphp.git", + "reference": "a11a6141b5715162b933c405379765d817891c5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/leafo/lessphp/zipball/a11a6141b5715162b933c405379765d817891c5d", + "reference": "a11a6141b5715162b933c405379765d817891c5d", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "classmap": [ + "lessc.inc.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT", + "GPL-3.0" + ], + "authors": [ + { + "name": "Leaf Corcoran", + "email": "leafot@gmail.com", + "homepage": "http://leafo.net" + } + ], + "description": "lessphp is a compiler for LESS written in PHP.", + "homepage": "http://leafo.net/lessphp/", + "time": "2013-03-02 16:13:31" + }, + { + "name": "phpmailer/phpmailer", + "version": "v5.2.8", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "*", + "phpunit/phpunit": "4.0.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "class.phpmailer.php", + "class.pop3.php", + "class.smtp.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "time": "2014-05-14 07:04:18" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "symfony/yaml", + "version": "v2.5.5", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-09-22 09:14:18" + } + ], + "packages-dev": null, + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "platform": { + "php": ">=5.3.10" + }, + "platform-dev": [] +} diff --git a/installation/application/framework.php b/installation/application/framework.php index 55e345f5c7d97..eb6b30063ced1 100644 --- a/installation/application/framework.php +++ b/installation/application/framework.php @@ -38,7 +38,8 @@ // Bootstrap the CMS libraries. require_once JPATH_LIBRARIES . '/cms.php'; -// Import filesystem classes since they aren't autoloaded +// Import filesystem and utilities classes since they aren't autoloaded jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.path'); +jimport('joomla.utilities.arrayhelper'); diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 6bbb5f60bc2fc..92bc45a34a9d5 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -515,7 +515,6 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder` (30, 'com_contenthistory', 'component', 'com_contenthistory', '', 1, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (31, 'com_ajax', 'component', 'com_ajax', '', 1, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (32, 'com_postinstall', 'component', 'com_postinstall', '', 1, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), -(100, 'PHPMailer', 'library', 'phpmailer', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (101, 'SimplePie', 'library', 'simplepie', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (102, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (103, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index d156e0300ecfa..4208402b4d66d 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -502,7 +502,6 @@ INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder" -- Libraries INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES -(100, 'PHPMailer', 'library', 'phpmailer', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (101, 'SimplePie', 'library', 'simplepie', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (102, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (103, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index 91621751ac9af..38cb700649da8 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -820,8 +820,6 @@ UNION ALL SELECT 32, 'com_postinstall', 'component', 'com_postinstall', '', 1, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0; INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state]) -SELECT 100, 'PHPMailer', 'library', 'phpmailer', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0 -UNION ALL SELECT 101, 'SimplePie', 'library', 'simplepie', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0 UNION ALL SELECT 102, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0 diff --git a/language/en-GB/en-GB.lib_phpmailer.sys.ini b/language/en-GB/en-GB.lib_phpmailer.sys.ini deleted file mode 100644 index 3dcfa180f18bc..0000000000000 --- a/language/en-GB/en-GB.lib_phpmailer.sys.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Joomla! Project -; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. -; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php -; Note : All ini files need to be saved as UTF-8 - -LIB_PHPMAILER_XML_DESCRIPTION="Classes for sending email" - diff --git a/libraries/classmap.php b/libraries/classmap.php index 9ae6c934310f1..9ee493aa6ec84 100644 --- a/libraries/classmap.php +++ b/libraries/classmap.php @@ -12,3 +12,5 @@ JLoader::registerAlias('JRegistryFormatJSON', '\\Joomla\\Registry\\Format\\Json'); JLoader::registerAlias('JRegistryFormatPHP', '\\Joomla\\Registry\\Format\\Php'); JLoader::registerAlias('JRegistryFormatXML', '\\Joomla\\Registry\\Format\\Xml'); +JLoader::registerAlias('JStringInflector', '\\Joomla\\String\\Inflector'); +JLoader::registerAlias('JStringNormalise', '\\Joomla\\String\\Normalise'); diff --git a/libraries/cms.php b/libraries/cms.php index b340b4acd9756..e74ce1bfc924d 100644 --- a/libraries/cms.php +++ b/libraries/cms.php @@ -29,9 +29,8 @@ // Register the library base path for CMS libraries. JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms', false, true); -// Register PHP namespaces -JLoader::registerNamespace('Joomla', JPATH_PLATFORM . '/framework'); -JLoader::registerNamespace('Symfony', JPATH_PLATFORM . '/framework'); +// Add the Composer autoloader +require_once JPATH_LIBRARIES . '/vendor/autoload.php'; // Register the class aliases for Framework classes that have replaced their Platform equivilents require_once __DIR__ . '/classmap.php'; diff --git a/libraries/cms/less/formatter/joomla.php b/libraries/cms/less/formatter/joomla.php index 2434209f7b845..11e8687b4ba7b 100644 --- a/libraries/cms/less/formatter/joomla.php +++ b/libraries/cms/less/formatter/joomla.php @@ -9,8 +9,6 @@ defined('JPATH_PLATFORM') or die; -require_once JPATH_PLATFORM . '/lessc/lessc.inc.php'; - /** * Formatter ruleset for Joomla formatted CSS generated via LESS * diff --git a/libraries/cms/less/less.php b/libraries/cms/less/less.php index fea66d341feef..431dffea84b25 100644 --- a/libraries/cms/less/less.php +++ b/libraries/cms/less/less.php @@ -9,8 +9,6 @@ defined('JPATH_PLATFORM') or die; -require_once JPATH_PLATFORM . '/lessc/lessc.inc.php'; - /** * Wrapper class for lessc * diff --git a/libraries/compat/password/index.html b/libraries/compat/password/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/compat/password/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/compat/password/lib/index.html b/libraries/compat/password/lib/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/compat/password/lib/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/compat/password/lib/version_test.php b/libraries/compat/password/lib/version_test.php deleted file mode 100644 index 5e6d5797a8e38..0000000000000 --- a/libraries/compat/password/lib/version_test.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @copyright 2012 The Authors - */ -/** - * Modififations - * Open Source Matters 2013 - * CMS version 3.2 - * - */ -class version_test -{ - public function version_test() - { - $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG'; - $test = crypt("password", $hash); - $pass = $test == $hash; - - return $pass; - } -} \ No newline at end of file diff --git a/libraries/framework/Joomla/DI/Exception/DependencyResolutionException.php b/libraries/framework/Joomla/DI/Exception/DependencyResolutionException.php deleted file mode 100644 index 8cf7a2716102a..0000000000000 --- a/libraries/framework/Joomla/DI/Exception/DependencyResolutionException.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/libraries/framework/Joomla/DI/index.html b/libraries/framework/Joomla/DI/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Joomla/DI/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Joomla/Registry/Format/index.html b/libraries/framework/Joomla/Registry/Format/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Joomla/Registry/Format/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Joomla/Registry/index.html b/libraries/framework/Joomla/Registry/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Joomla/Registry/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Symfony/Component/Yaml/Exception/index.html b/libraries/framework/Symfony/Component/Yaml/Exception/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Symfony/Component/Yaml/Exception/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Symfony/Component/Yaml/index.html b/libraries/framework/Symfony/Component/Yaml/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Symfony/Component/Yaml/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Symfony/Component/index.html b/libraries/framework/Symfony/Component/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Symfony/Component/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/Symfony/index.html b/libraries/framework/Symfony/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/Symfony/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/framework/index.html b/libraries/framework/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/framework/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/import.legacy.php b/libraries/import.legacy.php index db23b2962e71d..28d7ac7370ef4 100644 --- a/libraries/import.legacy.php +++ b/libraries/import.legacy.php @@ -69,7 +69,7 @@ // Check if the JsonSerializable interface exists already if (!interface_exists('JsonSerializable')) { - JLoader::register('JsonSerializable', __DIR__ . '/compat/jsonserializable.php'); + JLoader::register('JsonSerializable', JPATH_PLATFORM . '/vendor/joomla/compat/src/JsonSerializable.php'); } // Add deprecated constants diff --git a/libraries/import.php b/libraries/import.php index 2456d09f1091d..a5037823a6433 100644 --- a/libraries/import.php +++ b/libraries/import.php @@ -55,7 +55,7 @@ // Check if the JsonSerializable interface exists already if (!interface_exists('JsonSerializable')) { - JLoader::register('JsonSerializable', __DIR__ . '/compat/jsonserializable.php'); + JLoader::register('JsonSerializable', JPATH_PLATFORM . '/vendor/joomla/compat/src/JsonSerializable.php'); } // Register classes that don't follow one file per class naming conventions. diff --git a/libraries/joomla/application/base.php b/libraries/joomla/application/base.php index 6af5e9bc0a179..0804e9493b30b 100644 --- a/libraries/joomla/application/base.php +++ b/libraries/joomla/application/base.php @@ -9,6 +9,8 @@ defined('JPATH_PLATFORM') or die; +use Joomla\Application\AbstractApplication; + /** * Joomla Platform Base Application Class * @@ -16,7 +18,7 @@ * @subpackage Application * @since 12.1 */ -abstract class JApplicationBase +abstract class JApplicationBase extends AbstractApplication { /** * The application dispatcher object. @@ -34,29 +36,6 @@ abstract class JApplicationBase */ protected $identity; - /** - * The application input object. - * - * @var JInput - * @since 12.1 - */ - public $input = null; - - /** - * Method to close the application. - * - * @param integer $code The exit code (optional; default is 0). - * - * @return void - * - * @codeCoverageIgnore - * @since 12.1 - */ - public function close($code = 0) - { - exit($code); - } - /** * Get the application identity. * @@ -148,4 +127,18 @@ public function loadIdentity(JUser $identity = null) return $this; } + + /** + * Method to run the application routines. Most likely you will want to instantiate a controller + * and execute it, or perform some sort of task directly. + * + * @return void + * + * @since 3.4 (CMS) + */ + protected function doExecute() + { + return; + } + } diff --git a/libraries/joomla/application/cli.php b/libraries/joomla/application/cli.php index 551f89ebd2563..0d757e6b3b93a 100644 --- a/libraries/joomla/application/cli.php +++ b/libraries/joomla/application/cli.php @@ -21,12 +21,6 @@ */ class JApplicationCli extends JApplicationBase { - /** - * @var Registry The application configuration object. - * @since 11.1 - */ - protected $config; - /** * @var CliOutput The output type. * @since 3.3 @@ -76,7 +70,7 @@ public function __construct(JInputCli $input = null, Registry $config = null, JE { if (class_exists('JInput')) { - $this->input = new JInputCLI; + $this->input = new JInputCli; } } @@ -104,21 +98,6 @@ public function __construct(JInputCli $input = null, Registry $config = null, JE $this->set('cwd', getcwd()); } - /** - * Returns a property of the object or the default value if the property is not set. - * - * @param string $key The name of the property. - * @param mixed $default The default value (optional) if none is set. - * - * @return mixed The value of the configuration. - * - * @since 11.3 - */ - public function get($key, $default = null) - { - return $this->config->get($key, $default); - } - /** * Returns a reference to the global JApplicationCli object, only creating it if it doesn't already exist. * @@ -259,24 +238,6 @@ public function in() return rtrim(fread(STDIN, 8192), "\n"); } - /** - * Modifies a property of the object, creating it if it does not already exist. - * - * @param string $key The name of the property. - * @param mixed $value The value of the property to set (optional). - * - * @return mixed Previous value of the property - * - * @since 11.3 - */ - public function set($key, $value = null) - { - $previous = $this->config->get($key); - $this->config->set($key, $value); - - return $previous; - } - /** * Method to load a PHP configuration class file based on convention and return the instantiated data object. You * will extend this method in child classes to provide configuration data from whatever data source is relevant diff --git a/libraries/joomla/application/web.php b/libraries/joomla/application/web.php index 458ce6fd18364..cb5e71117ef26 100644 --- a/libraries/joomla/application/web.php +++ b/libraries/joomla/application/web.php @@ -44,12 +44,6 @@ class JApplicationWeb extends JApplicationBase */ public $client; - /** - * @var Registry The application configuration object. - * @since 11.3 - */ - protected $config; - /** * @var JDocument The application document object. * @since 11.3 @@ -563,39 +557,6 @@ public function loadConfiguration($data) return $this; } - /** - * Returns a property of the object or the default value if the property is not set. - * - * @param string $key The name of the property. - * @param mixed $default The default value (optional) if none is set. - * - * @return mixed The value of the configuration. - * - * @since 11.3 - */ - public function get($key, $default = null) - { - return $this->config->get($key, $default); - } - - /** - * Modifies a property of the object, creating it if it does not already exist. - * - * @param string $key The name of the property. - * @param mixed $value The value of the property to set (optional). - * - * @return mixed Previous value of the property - * - * @since 11.3 - */ - public function set($key, $value = null) - { - $previous = $this->config->get($key); - $this->config->set($key, $value); - - return $previous; - } - /** * Set/get cachable state for the response. If $allow is set, sets the cachable state of the * response. Always returns the current state. diff --git a/libraries/joomla/controller/controller.php b/libraries/joomla/controller/controller.php index 6d30085682574..d02fef6605da9 100644 --- a/libraries/joomla/controller/controller.php +++ b/libraries/joomla/controller/controller.php @@ -43,7 +43,7 @@ public function getApplication(); /** * Get the input object. * - * @return JInput The input object. + * @return \Joomla\Input\Input The input object. * * @since 12.1 */ diff --git a/libraries/joomla/crypt/crypt.php b/libraries/joomla/crypt/crypt.php index f2cb90cf26794..b2bc965bd9c03 100644 --- a/libraries/joomla/crypt/crypt.php +++ b/libraries/joomla/crypt/crypt.php @@ -308,7 +308,7 @@ public static function hasStrongPasswordSupport() if (!defined('PASSWORD_DEFAULT')) { // Always make sure that the password hashing API has been defined. - include_once JPATH_ROOT . '/libraries/compat/password/lib/password.php'; + include_once JPATH_ROOT . '/vendor/ircmaxell/password-compat/lib/password.php'; } return true; diff --git a/libraries/compat/index.html b/libraries/joomla/mail/language/index.html similarity index 100% rename from libraries/compat/index.html rename to libraries/joomla/mail/language/index.html diff --git a/libraries/phpmailer/language/phpmailer.lang-joomla.php b/libraries/joomla/mail/language/phpmailer.lang-joomla.php similarity index 100% rename from libraries/phpmailer/language/phpmailer.lang-joomla.php rename to libraries/joomla/mail/language/phpmailer.lang-joomla.php diff --git a/libraries/joomla/mail/mail.php b/libraries/joomla/mail/mail.php index deb2d0b5335dc..523e67c0c7729 100644 --- a/libraries/joomla/mail/mail.php +++ b/libraries/joomla/mail/mail.php @@ -9,10 +9,6 @@ defined('JPATH_PLATFORM') or die; -jimport('phpmailer.phpmailer'); -jimport('phpmailer.pop3'); -jimport('phpmailer.smtp'); - /** * Email Class. Provides a common interface to send email from the Joomla! Platform * @@ -42,7 +38,7 @@ class JMail extends PHPMailer public function __construct() { // PHPMailer has an issue using the relative path for its language files - $this->setLanguage('joomla', JPATH_PLATFORM . '/phpmailer/language/'); + $this->setLanguage('joomla', __DIR__ . '/language'); } /** diff --git a/libraries/joomla/string/string.php b/libraries/joomla/string/string.php index f280290a76e7b..50e62783f2f2b 100644 --- a/libraries/joomla/string/string.php +++ b/libraries/joomla/string/string.php @@ -9,38 +9,7 @@ defined('JPATH_PLATFORM') or die; -// PHP mbstring and iconv local configuration - -// Check if mbstring extension is loaded and attempt to load it if not present except for windows -if (extension_loaded('mbstring')) -{ - // Make sure to suppress the output in case ini_set is disabled - @ini_set('mbstring.internal_encoding', 'UTF-8'); - @ini_set('mbstring.http_input', 'UTF-8'); - @ini_set('mbstring.http_output', 'UTF-8'); -} - -// Same for iconv -if (function_exists('iconv')) -{ - // These are settings that can be set inside code - if (version_compare(PHP_VERSION, '5.6', '>=')) - { - @ini_set('default_charset', 'UTF-8'); - } - else - { - iconv_set_encoding("internal_encoding", "UTF-8"); - iconv_set_encoding("input_encoding", "UTF-8"); - iconv_set_encoding("output_encoding", "UTF-8"); - } -} - -/** - * Include the utf8 package - */ -jimport('phputf8.utf8'); -jimport('phputf8.strcasecmp'); +use Joomla\String\String; /** * String handling class for utf-8 data @@ -50,26 +19,10 @@ * @package Joomla.Platform * @subpackage String * @since 11.1 + * @deprecated 4.0 Use {@link \Joomla\String\String} instead unless otherwise noted. */ -abstract class JString +abstract class JString extends String { - /** - * Increment styles. - * - * @var array - * @since 11.3 - */ - protected static $incrementStyles = array( - 'dash' => array( - '#-(\d+)$#', - '-%d' - ), - 'default' => array( - array('#\((\d+)\)$#', '#\(\d+\)$#'), - array(' (%d)', '(%d)'), - ), - ); - /** * Split a string in camel case format * @@ -95,850 +48,6 @@ public static function splitCamelCase($string) return JStringNormalise::fromCamelCase($string, true); } - /** - * Increments a trailing number in a string. - * - * Used to easily create distinct labels when copying objects. The method has the following styles: - * - * default: "Label" becomes "Label (2)" - * dash: "Label" becomes "Label-2" - * - * @param string $string The source string. - * @param string $style The the style (default|dash). - * @param integer $n If supplied, this number is used for the copy, otherwise it is the 'next' number. - * - * @return string The incremented string. - * - * @since 11.3 - */ - public static function increment($string, $style = 'default', $n = 0) - { - $styleSpec = isset(self::$incrementStyles[$style]) ? self::$incrementStyles[$style] : self::$incrementStyles['default']; - - // Regular expression search and replace patterns. - if (is_array($styleSpec[0])) - { - $rxSearch = $styleSpec[0][0]; - $rxReplace = $styleSpec[0][1]; - } - else - { - $rxSearch = $rxReplace = $styleSpec[0]; - } - - // New and old (existing) sprintf formats. - if (is_array($styleSpec[1])) - { - $newFormat = $styleSpec[1][0]; - $oldFormat = $styleSpec[1][1]; - } - else - { - $newFormat = $oldFormat = $styleSpec[1]; - } - - // Check if we are incrementing an existing pattern, or appending a new one. - if (preg_match($rxSearch, $string, $matches)) - { - $n = empty($n) ? ($matches[1] + 1) : $n; - $string = preg_replace($rxReplace, sprintf($oldFormat, $n), $string); - } - else - { - $n = empty($n) ? 2 : $n; - $string .= sprintf($newFormat, $n); - } - - return $string; - } - - /** - * UTF-8 aware alternative to strpos. - * - * Find position of first occurrence of a string. - * - * @param string $str String being examined - * @param string $search String being searched for - * @param mixed $offset Optional, specifies the position from which the search should be performed - * - * @return mixed Number of characters before the first match or FALSE on failure - * - * @see http://www.php.net/strpos - * @since 11.1 - */ - public static function strpos($str, $search, $offset = false) - { - if ($offset === false) - { - return utf8_strpos($str, $search); - } - else - { - return utf8_strpos($str, $search, $offset); - } - } - - /** - * UTF-8 aware alternative to strrpos - * Finds position of last occurrence of a string - * - * @param string $str String being examined. - * @param string $search String being searched for. - * @param integer $offset Offset from the left of the string. - * - * @return mixed Number of characters before the last match or false on failure - * - * @see http://www.php.net/strrpos - * @since 11.1 - */ - public static function strrpos($str, $search, $offset = 0) - { - return utf8_strrpos($str, $search, $offset); - } - - /** - * UTF-8 aware alternative to substr - * Return part of a string given character offset (and optionally length) - * - * @param string $str String being processed - * @param integer $offset Number of UTF-8 characters offset (from left) - * @param mixed $length Optional length in UTF-8 characters from offset - * - * @return mixed string or FALSE if failure - * - * @see http://www.php.net/substr - * @since 11.1 - */ - public static function substr($str, $offset, $length = false) - { - if ($length === false) - { - return utf8_substr($str, $offset); - } - else - { - return utf8_substr($str, $offset, $length); - } - } - - /** - * UTF-8 aware alternative to strtlower - * - * Make a string lowercase - * Note: The concept of a characters "case" only exists is some alphabets - * such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does - * not exist in the Chinese alphabet, for example. See Unicode Standard - * Annex #21: Case Mappings - * - * @param string $str String being processed - * - * @return mixed Either string in lowercase or FALSE is UTF-8 invalid - * - * @see http://www.php.net/strtolower - * @since 11.1 - */ - public static function strtolower($str) - { - return utf8_strtolower($str); - } - - /** - * UTF-8 aware alternative to strtoupper - * Make a string uppercase - * Note: The concept of a characters "case" only exists is some alphabets - * such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does - * not exist in the Chinese alphabet, for example. See Unicode Standard - * Annex #21: Case Mappings - * - * @param string $str String being processed - * - * @return mixed Either string in uppercase or FALSE is UTF-8 invalid - * - * @see http://www.php.net/strtoupper - * @since 11.1 - */ - public static function strtoupper($str) - { - return utf8_strtoupper($str); - } - - /** - * UTF-8 aware alternative to strlen. - * - * Returns the number of characters in the string (NOT THE NUMBER OF BYTES), - * - * @param string $str UTF-8 string. - * - * @return integer Number of UTF-8 characters in string. - * - * @see http://www.php.net/strlen - * @since 11.1 - */ - public static function strlen($str) - { - return utf8_strlen($str); - } - - /** - * UTF-8 aware alternative to str_ireplace - * Case-insensitive version of str_replace - * - * @param string $search String to search - * @param string $replace Existing string to replace - * @param string $str New string to replace with - * @param integer $count Optional count value to be passed by referene - * - * @return string UTF-8 String - * - * @see http://www.php.net/str_ireplace - * @since 11.1 - */ - public static function str_ireplace($search, $replace, $str, $count = null) - { - jimport('phputf8.str_ireplace'); - - if ($count === false) - { - return utf8_ireplace($search, $replace, $str); - } - else - { - return utf8_ireplace($search, $replace, $str, $count); - } - } - - /** - * UTF-8 aware alternative to str_split - * Convert a string to an array - * - * @param string $str UTF-8 encoded string to process - * @param integer $split_len Number to characters to split string by - * - * @return array - * - * @see http://www.php.net/str_split - * @since 11.1 - */ - public static function str_split($str, $split_len = 1) - { - jimport('phputf8.str_split'); - - return utf8_str_split($str, $split_len); - } - - /** - * UTF-8/LOCALE aware alternative to strcasecmp - * A case insensitive string comparison - * - * @param string $str1 string 1 to compare - * @param string $str2 string 2 to compare - * @param mixed $locale The locale used by strcoll or false to use classical comparison - * - * @return integer < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. - * - * @see http://www.php.net/strcasecmp - * @see http://www.php.net/strcoll - * @see http://www.php.net/setlocale - * @since 11.1 - */ - public static function strcasecmp($str1, $str2, $locale = false) - { - if ($locale) - { - // Get current locale - $locale0 = setlocale(LC_COLLATE, 0); - - if (!$locale = setlocale(LC_COLLATE, $locale)) - { - $locale = $locale0; - } - - // See if we have successfully set locale to UTF-8 - if (!stristr($locale, 'UTF-8') && stristr($locale, '_') && preg_match('~\.(\d+)$~', $locale, $m)) - { - $encoding = 'CP' . $m[1]; - } - elseif (stristr($locale, 'UTF-8') || stristr($locale, 'utf8')) - { - $encoding = 'UTF-8'; - } - else - { - $encoding = 'nonrecodable'; - } - - // If we successfully set encoding it to utf-8 or encoding is sth weird don't recode - if ($encoding == 'UTF-8' || $encoding == 'nonrecodable') - { - return strcoll(utf8_strtolower($str1), utf8_strtolower($str2)); - } - else - { - return strcoll( - self::transcode(utf8_strtolower($str1), 'UTF-8', $encoding), - self::transcode(utf8_strtolower($str2), 'UTF-8', $encoding) - ); - } - } - else - { - return utf8_strcasecmp($str1, $str2); - } - } - - /** - * UTF-8/LOCALE aware alternative to strcmp - * A case sensitive string comparison - * - * @param string $str1 string 1 to compare - * @param string $str2 string 2 to compare - * @param mixed $locale The locale used by strcoll or false to use classical comparison - * - * @return integer < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. - * - * @see http://www.php.net/strcmp - * @see http://www.php.net/strcoll - * @see http://www.php.net/setlocale - * @since 11.1 - */ - public static function strcmp($str1, $str2, $locale = false) - { - if ($locale) - { - // Get current locale - $locale0 = setlocale(LC_COLLATE, 0); - - if (!$locale = setlocale(LC_COLLATE, $locale)) - { - $locale = $locale0; - } - - // See if we have successfully set locale to UTF-8 - if (!stristr($locale, 'UTF-8') && stristr($locale, '_') && preg_match('~\.(\d+)$~', $locale, $m)) - { - $encoding = 'CP' . $m[1]; - } - elseif (stristr($locale, 'UTF-8') || stristr($locale, 'utf8')) - { - $encoding = 'UTF-8'; - } - else - { - $encoding = 'nonrecodable'; - } - - // If we successfully set encoding it to utf-8 or encoding is sth weird don't recode - if ($encoding == 'UTF-8' || $encoding == 'nonrecodable') - { - return strcoll($str1, $str2); - } - else - { - return strcoll(self::transcode($str1, 'UTF-8', $encoding), self::transcode($str2, 'UTF-8', $encoding)); - } - } - else - { - return strcmp($str1, $str2); - } - } - - /** - * UTF-8 aware alternative to strcspn - * Find length of initial segment not matching mask - * - * @param string $str The string to process - * @param string $mask The mask - * @param integer $start Optional starting character position (in characters) - * @param integer $length Optional length - * - * @return integer The length of the initial segment of str1 which does not contain any of the characters in str2 - * - * @see http://www.php.net/strcspn - * @since 11.1 - */ - public static function strcspn($str, $mask, $start = null, $length = null) - { - jimport('phputf8.strcspn'); - - if ($start === false && $length === false) - { - return utf8_strcspn($str, $mask); - } - elseif ($length === false) - { - return utf8_strcspn($str, $mask, $start); - } - else - { - return utf8_strcspn($str, $mask, $start, $length); - } - } - - /** - * UTF-8 aware alternative to stristr - * Returns all of haystack from the first occurrence of needle to the end. - * needle and haystack are examined in a case-insensitive manner - * Find first occurrence of a string using case insensitive comparison - * - * @param string $str The haystack - * @param string $search The needle - * - * @return string the sub string - * - * @see http://www.php.net/stristr - * @since 11.1 - */ - public static function stristr($str, $search) - { - jimport('phputf8.stristr'); - - return utf8_stristr($str, $search); - } - - /** - * UTF-8 aware alternative to strrev - * Reverse a string - * - * @param string $str String to be reversed - * - * @return string The string in reverse character order - * - * @see http://www.php.net/strrev - * @since 11.1 - */ - public static function strrev($str) - { - jimport('phputf8.strrev'); - - return utf8_strrev($str); - } - - /** - * UTF-8 aware alternative to strspn - * Find length of initial segment matching mask - * - * @param string $str The haystack - * @param string $mask The mask - * @param integer $start Start optional - * @param integer $length Length optional - * - * @return integer - * - * @see http://www.php.net/strspn - * @since 11.1 - */ - public static function strspn($str, $mask, $start = null, $length = null) - { - jimport('phputf8.strspn'); - - if ($start === null && $length === null) - { - return utf8_strspn($str, $mask); - } - elseif ($length === null) - { - return utf8_strspn($str, $mask, $start); - } - else - { - return utf8_strspn($str, $mask, $start, $length); - } - } - - /** - * UTF-8 aware substr_replace - * Replace text within a portion of a string - * - * @param string $str The haystack - * @param string $repl The replacement string - * @param integer $start Start - * @param integer $length Length (optional) - * - * @return string - * - * @see http://www.php.net/substr_replace - * @since 11.1 - */ - public static function substr_replace($str, $repl, $start, $length = null) - { - // Loaded by library loader - if ($length === false) - { - return utf8_substr_replace($str, $repl, $start); - } - else - { - return utf8_substr_replace($str, $repl, $start, $length); - } - } - - /** - * UTF-8 aware replacement for ltrim() - * - * Strip whitespace (or other characters) from the beginning of a string - * You only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise ltrim will - * work normally on a UTF-8 string - * - * @param string $str The string to be trimmed - * @param mixed $charlist The optional charlist of additional characters to trim - * - * @return string The trimmed string - * - * @see http://www.php.net/ltrim - * @since 11.1 - */ - public static function ltrim($str, $charlist = false) - { - if (empty($charlist) && $charlist !== false) - { - return $str; - } - - jimport('phputf8.trim'); - - if ($charlist === false) - { - return utf8_ltrim($str); - } - else - { - return utf8_ltrim($str, $charlist); - } - } - - /** - * UTF-8 aware replacement for rtrim() - * Strip whitespace (or other characters) from the end of a string - * You only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise rtrim will - * work normally on a UTF-8 string - * - * @param string $str The string to be trimmed - * @param mixed $charlist The optional charlist of additional characters to trim - * - * @return string The trimmed string - * - * @see http://www.php.net/rtrim - * @since 11.1 - */ - public static function rtrim($str, $charlist = false) - { - if (empty($charlist) && $charlist !== false) - { - return $str; - } - - jimport('phputf8.trim'); - - if ($charlist === false) - { - return utf8_rtrim($str); - } - else - { - return utf8_rtrim($str, $charlist); - } - } - - /** - * UTF-8 aware replacement for trim() - * Strip whitespace (or other characters) from the beginning and end of a string - * Note: you only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise trim will - * work normally on a UTF-8 string - * - * @param string $str The string to be trimmed - * @param mixed $charlist The optional charlist of additional characters to trim - * - * @return string The trimmed string - * - * @see http://www.php.net/trim - * @since 11.1 - */ - public static function trim($str, $charlist = false) - { - if (empty($charlist) && $charlist !== false) - { - return $str; - } - - jimport('phputf8.trim'); - - if ($charlist === false) - { - return utf8_trim($str); - } - else - { - return utf8_trim($str, $charlist); - } - } - - /** - * UTF-8 aware alternative to ucfirst - * Make a string's first character uppercase or all words' first character uppercase - * - * @param string $str String to be processed - * @param string $delimiter The words delimiter (null means do not split the string) - * @param string $newDelimiter The new words delimiter (null means equal to $delimiter) - * - * @return string If $delimiter is null, return the string with first character as upper case (if applicable) - * else consider the string of words separated by the delimiter, apply the ucfirst to each words - * and return the string with the new delimiter - * - * @see http://www.php.net/ucfirst - * @since 11.1 - */ - public static function ucfirst($str, $delimiter = null, $newDelimiter = null) - { - jimport('phputf8.ucfirst'); - - if ($delimiter === null) - { - return utf8_ucfirst($str); - } - else - { - if ($newDelimiter === null) - { - $newDelimiter = $delimiter; - } - - return implode($newDelimiter, array_map('utf8_ucfirst', explode($delimiter, $str))); - } - } - - /** - * UTF-8 aware alternative to ucwords - * Uppercase the first character of each word in a string - * - * @param string $str String to be processed - * - * @return string String with first char of each word uppercase - * - * @see http://www.php.net/ucwords - * @since 11.1 - */ - public static function ucwords($str) - { - jimport('phputf8.ucwords'); - - return utf8_ucwords($str); - } - - /** - * Transcode a string. - * - * @param string $source The string to transcode. - * @param string $from_encoding The source encoding. - * @param string $to_encoding The target encoding. - * - * @return mixed The transcoded string, or null if the source was not a string. - * - * @link https://bugs.php.net/bug.php?id=48147 - * - * @since 11.1 - */ - public static function transcode($source, $from_encoding, $to_encoding) - { - if (is_string($source)) - { - switch (ICONV_IMPL) - { - case 'glibc': - return @iconv($from_encoding, $to_encoding . '//TRANSLIT,IGNORE', $source); - case 'libiconv': - default: - return iconv($from_encoding, $to_encoding . '//IGNORE//TRANSLIT', $source); - } - } - - return null; - } - - /** - * Tests a string as to whether it's valid UTF-8 and supported by the Unicode standard. - * - * Note: this function has been modified to simple return true or false. - * - * @param string $str UTF-8 encoded string. - * - * @return boolean true if valid - * - * @author - * @see http://hsivonen.iki.fi/php-utf8/ - * @see JString::compliant() - * @since 11.1 - */ - public static function valid($str) - { - // Cached expected number of octets after the current octet - // until the beginning of the next UTF8 character sequence - $mState = 0; - - // Cached Unicode character - $mUcs4 = 0; - - // Cached expected number of octets in the current sequence - $mBytes = 1; - - $len = strlen($str); - - for ($i = 0; $i < $len; $i++) - { - $in = ord($str{$i}); - - if ($mState == 0) - { - // When mState is zero we expect either a US-ASCII character or a - // multi-octet sequence. - if (0 == (0x80 & ($in))) - { - // US-ASCII, pass straight through. - $mBytes = 1; - } - elseif (0xC0 == (0xE0 & ($in))) - { - // First octet of 2 octet sequence - $mUcs4 = ($in); - $mUcs4 = ($mUcs4 & 0x1F) << 6; - $mState = 1; - $mBytes = 2; - } - elseif (0xE0 == (0xF0 & ($in))) - { - // First octet of 3 octet sequence - $mUcs4 = ($in); - $mUcs4 = ($mUcs4 & 0x0F) << 12; - $mState = 2; - $mBytes = 3; - } - elseif (0xF0 == (0xF8 & ($in))) - { - // First octet of 4 octet sequence - $mUcs4 = ($in); - $mUcs4 = ($mUcs4 & 0x07) << 18; - $mState = 3; - $mBytes = 4; - } - elseif (0xF8 == (0xFC & ($in))) - { - /* First octet of 5 octet sequence. - * - * This is illegal because the encoded codepoint must be either - * (a) not the shortest form or - * (b) outside the Unicode range of 0-0x10FFFF. - * Rather than trying to resynchronize, we will carry on until the end - * of the sequence and let the later error handling code catch it. - */ - $mUcs4 = ($in); - $mUcs4 = ($mUcs4 & 0x03) << 24; - $mState = 4; - $mBytes = 5; - } - elseif (0xFC == (0xFE & ($in))) - { - // First octet of 6 octet sequence, see comments for 5 octet sequence. - $mUcs4 = ($in); - $mUcs4 = ($mUcs4 & 1) << 30; - $mState = 5; - $mBytes = 6; - } - else - { - /* Current octet is neither in the US-ASCII range nor a legal first - * octet of a multi-octet sequence. - */ - return false; - } - } - else - { - // When mState is non-zero, we expect a continuation of the multi-octet - // sequence - if (0x80 == (0xC0 & ($in))) - { - // Legal continuation. - $shift = ($mState - 1) * 6; - $tmp = $in; - $tmp = ($tmp & 0x0000003F) << $shift; - $mUcs4 |= $tmp; - - /** - * End of the multi-octet sequence. mUcs4 now contains the final - * Unicode codepoint to be output - */ - if (0 == --$mState) - { - /* - * Check for illegal sequences and codepoints. - */ - // From Unicode 3.1, non-shortest form is illegal - if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || ((3 == $mBytes) && ($mUcs4 < 0x0800)) || ((4 == $mBytes) && ($mUcs4 < 0x10000)) - || (4 < $mBytes) - || (($mUcs4 & 0xFFFFF800) == 0xD800) // From Unicode 3.2, surrogate characters are illegal - || ($mUcs4 > 0x10FFFF)) // Codepoints outside the Unicode range are illegal - { - return false; - } - - // Initialize UTF8 cache. - $mState = 0; - $mUcs4 = 0; - $mBytes = 1; - } - } - else - { - /** - *((0xC0 & (*in) != 0x80) && (mState != 0)) - * Incomplete multi-octet sequence. - */ - return false; - } - } - } - - return true; - } - - /** - * Tests whether a string complies as UTF-8. This will be much - * faster than utf8_is_valid but will pass five and six octet - * UTF-8 sequences, which are not supported by Unicode and - * so cannot be displayed correctly in a browser. In other words - * it is not as strict as utf8_is_valid but it's faster. If you use - * it to validate user input, you place yourself at the risk that - * attackers will be able to inject 5 and 6 byte sequences (which - * may or may not be a significant risk, depending on what you are - * are doing) - * - * @param string $str UTF-8 string to check - * - * @return boolean TRUE if string is valid UTF-8 - * - * @see JString::valid() - * @see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#54805 - * @since 11.1 - */ - public static function compliant($str) - { - if (strlen($str) == 0) - { - return true; - } - - /* - * If even just the first character can be matched, when the /u - * modifier is used, then it's valid UTF-8. If the UTF-8 is somehow - * invalid, nothing at all will match, even if the string contains - * some valid sequences - */ - return (preg_match('/^.{1}/us', $str, $ar) == 1); - } - /** * Does a UTF-8 safe version of PHP parse_url function * @@ -948,31 +57,12 @@ public static function compliant($str) * * @see http://us3.php.net/manual/en/function.parse-url.php * @since 11.1 + * @deprecated 4.0 (CMS) - Use {@link \Joomla\Uri\UriHelper::parse_url()} instead. */ public static function parse_url($url) { - $result = false; - - // Build arrays of values we need to decode before parsing - $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D'); - $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]"); - - // Create encoded URL with special URL characters decoded so it can be parsed - // All other characters will be encoded - $encodedURL = str_replace($entities, $replacements, urlencode($url)); - - // Parse the encoded URL - $encodedParts = parse_url($encodedURL); - - // Now, decode each value of the resulting array - if ($encodedParts) - { - foreach ($encodedParts as $key => $value) - { - $result[$key] = urldecode(str_replace($replacements, $entities, $value)); - } - } + JLog::add('JString::parse_url has been deprecated. Use \\Joomla\\Uri\\UriHelper::parse_url.', JLog::WARNING, 'deprecated'); - return $result; + return \Joomla\Uri\UriHelper::parse_url($url); } } diff --git a/libraries/joomla/uri/uri.php b/libraries/joomla/uri/uri.php index 97d5e9279ede9..8b73acb7c5d25 100644 --- a/libraries/joomla/uri/uri.php +++ b/libraries/joomla/uri/uri.php @@ -9,6 +9,8 @@ defined('JPATH_PLATFORM') or die; +use Joomla\Uri\Uri; + /** * JUri Class * @@ -20,70 +22,10 @@ * @subpackage Uri * @since 11.1 */ -class JUri +class JUri extends Uri { /** - * @var string Original URI - * @since 12.1 - */ - protected $uri = null; - - /** - * @var string Protocol - * @since 12.1 - */ - protected $scheme = null; - - /** - * @var string Host - * @since 12.1 - */ - protected $host = null; - - /** - * @var integer Port - * @since 12.1 - */ - protected $port = null; - - /** - * @var string Username - * @since 12.1 - */ - protected $user = null; - - /** - * @var string Password - * @since 12.1 - */ - protected $pass = null; - - /** - * @var string Path - * @since 12.1 - */ - protected $path = null; - - /** - * @var string Query - * @since 12.1 - */ - protected $query = null; - - /** - * @var string Anchor - * @since 12.1 - */ - protected $fragment = null; - - /** - * @var array Query variable hash - * @since 12.1 - */ - protected $vars = array(); - - /** - * @var array An array of JUri instances. + * @var JUri[] An array of JUri instances. * @since 11.1 */ protected static $instances = array(); @@ -107,36 +49,7 @@ class JUri protected static $current; /** - * Constructor. - * You can pass a URI string to the constructor to initialise a specific URI. - * - * @param string $uri The optional URI string - * - * @since 11.1 - */ - public function __construct($uri = null) - { - if (!is_null($uri)) - { - $this->parse($uri); - } - } - - /** - * Magic method to get the string representation of the URI object. - * - * @return string - * - * @since 11.1 - */ - public function __toString() - { - return $this->toString(); - } - - /** - * Returns the global JUri object, only creating it - * if it doesn't already exist. + * Returns the global JUri object, only creating it if it doesn't already exist. * * @param string $uri The URI to parse. [optional: if null uses script URI] * @@ -327,208 +240,42 @@ public static function reset() } /** - * Parse a given URI and populate the class fields. - * - * @param string $uri The URI string to parse. - * - * @return boolean True on success. - * - * @since 11.1 - */ - public function parse($uri) - { - // Set the original URI to fall back on - $this->uri = $uri; - - /* - * Parse the URI and populate the object fields. If URI is parsed properly, - * set method return value to true. - */ - $parts = JString::parse_url($uri); - - $retval = ($parts) ? true : false; - - // We need to replace & with & for parse_str to work right... - if (isset($parts['query']) && strpos($parts['query'], '&')) - { - $parts['query'] = str_replace('&', '&', $parts['query']); - } - - $this->scheme = isset($parts['scheme']) ? $parts['scheme'] : null; - $this->user = isset($parts['user']) ? $parts['user'] : null; - $this->pass = isset($parts['pass']) ? $parts['pass'] : null; - $this->host = isset($parts['host']) ? $parts['host'] : null; - $this->port = isset($parts['port']) ? $parts['port'] : null; - $this->path = isset($parts['path']) ? $parts['path'] : null; - $this->query = isset($parts['query']) ? $parts['query'] : null; - $this->fragment = isset($parts['fragment']) ? $parts['fragment'] : null; - - // Parse the query - if (isset($parts['query'])) - { - parse_str($parts['query'], $this->vars); - } - - return $retval; - } - - /** - * Returns full uri string. - * - * @param array $parts An array specifying the parts to render. - * - * @return string The rendered URI string. - * - * @since 11.1 - */ - public function toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) - { - // Make sure the query is created - $query = $this->getQuery(); - - $uri = ''; - $uri .= in_array('scheme', $parts) ? (!empty($this->scheme) ? $this->scheme . '://' : '') : ''; - $uri .= in_array('user', $parts) ? $this->user : ''; - $uri .= in_array('pass', $parts) ? (!empty($this->pass) ? ':' : '') . $this->pass . (!empty($this->user) ? '@' : '') : ''; - $uri .= in_array('host', $parts) ? $this->host : ''; - $uri .= in_array('port', $parts) ? (!empty($this->port) ? ':' : '') . $this->port : ''; - $uri .= in_array('path', $parts) ? $this->path : ''; - $uri .= in_array('query', $parts) ? (!empty($query) ? '?' . $query : '') : ''; - $uri .= in_array('fragment', $parts) ? (!empty($this->fragment) ? '#' . $this->fragment : '') : ''; - - return $uri; - } - - /** - * Adds a query variable and value, replacing the value if it - * already exists and returning the old value. + * Set the URI path string. Note we keep this method here so it uses the old _cleanPath function * - * @param string $name Name of the query variable to set. - * @param string $value Value of the query variable. - * - * @return string Previous value for the query variable. - * - * @since 11.1 - */ - public function setVar($name, $value) - { - $tmp = isset($this->vars[$name]) ? $this->vars[$name] : null; - - $this->vars[$name] = $value; - - // Empty the query - $this->query = null; - - return $tmp; - } - - /** - * Checks if variable exists. - * - * @param string $name Name of the query variable to check. - * - * @return boolean True if the variable exists. - * - * @since 11.1 - */ - public function hasVar($name) - { - return array_key_exists($name, $this->vars); - } - - /** - * Returns a query variable by name. - * - * @param string $name Name of the query variable to get. - * @param string $default Default value to return if the variable is not set. - * - * @return array Query variables. - * - * @since 11.1 - */ - public function getVar($name, $default = null) - { - if (array_key_exists($name, $this->vars)) - { - return $this->vars[$name]; - } - - return $default; - } - - /** - * Removes an item from the query string variables if it exists. - * - * @param string $name Name of variable to remove. - * - * @return void - * - * @since 11.1 - */ - public function delVar($name) - { - if (array_key_exists($name, $this->vars)) - { - unset($this->vars[$name]); - - // Empty the query - $this->query = null; - } - } - - /** - * Sets the query to a supplied string in format: - * foo=bar&x=y - * - * @param mixed $query The query string or array. + * @param string $path The URI path string. * * @return void * - * @since 11.1 + * @since 11.1 + * @deprecated 4.0 Use {@link \Joomla\Uri\Uri::setPath()} + * @note Present to proxy calls to the deprecated {@link JUri::_cleanPath()} method. */ - public function setQuery($query) + public function setPath($path) { - if (is_array($query)) - { - $this->vars = $query; - } - else - { - if (strpos($query, '&') !== false) - { - $query = str_replace('&', '&', $query); - } - - parse_str($query, $this->vars); - } - - // Empty the query - $this->query = null; + $this->path = $this->_cleanPath($path); } /** - * Returns flat query string. + * Checks if the supplied URL is internal * - * @param boolean $toArray True to return the query as a key => value pair array. + * @param string $url The URL to check. * - * @return string|array Query string or array. + * @return boolean True if Internal. * * @since 11.1 */ - public function getQuery($toArray = false) + public static function isInternal($url) { - if ($toArray) - { - return $this->vars; - } + $uri = self::getInstance($url); + $base = $uri->toString(array('scheme', 'host', 'port', 'path')); + $host = $uri->toString(array('scheme', 'host', 'port')); - // If the query is empty build it first - if (is_null($this->query)) + if (stripos($base, self::base()) !== 0 && !empty($host)) { - $this->query = self::buildQuery($this->vars); + return false; } - return $this->query; + return true; } /** @@ -540,240 +287,26 @@ public function getQuery($toArray = false) * * @see parse_str() * @since 11.1 + * @note The parent method is protected, this exposes it as public for B/C */ public static function buildQuery(array $params) { - if (count($params) == 0) - { - return false; - } - - return urldecode(http_build_query($params, '', '&')); + return parent::buildQuery($params); } /** - * Get URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @return string The URI scheme. - * - * @since 11.1 - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * Set URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @param string $scheme The URI scheme. - * - * @return void - * - * @since 11.1 - */ - public function setScheme($scheme) - { - $this->scheme = $scheme; - } - - /** - * Get URI username - * Returns the username, or null if no username was specified. - * - * @return string The URI username. - * - * @since 11.1 - */ - public function getUser() - { - return $this->user; - } - - /** - * Set URI username. - * - * @param string $user The URI username. - * - * @return void - * - * @since 11.1 - */ - public function setUser($user) - { - $this->user = $user; - } - - /** - * Get URI password - * Returns the password, or null if no password was specified. - * - * @return string The URI password. - * - * @since 11.1 - */ - public function getPass() - { - return $this->pass; - } - - /** - * Set URI password. - * - * @param string $pass The URI password. - * - * @return void - * - * @since 11.1 - */ - public function setPass($pass) - { - $this->pass = $pass; - } - - /** - * Get URI host - * Returns the hostname/ip or null if no hostname/ip was specified. - * - * @return string The URI host. - * - * @since 11.1 - */ - public function getHost() - { - return $this->host; - } - - /** - * Set URI host. - * - * @param string $host The URI host. - * - * @return void - * - * @since 11.1 - */ - public function setHost($host) - { - $this->host = $host; - } - - /** - * Get URI port - * Returns the port number, or null if no port was specified. - * - * @return integer The URI port number. - * - * @since 11.1 - */ - public function getPort() - { - return (isset($this->port)) ? $this->port : null; - } - - /** - * Set URI port. - * - * @param integer $port The URI port number. - * - * @return void - * - * @since 11.1 - */ - public function setPort($port) - { - $this->port = $port; - } - - /** - * Gets the URI path string. - * - * @return string The URI path string. - * - * @since 11.1 - */ - public function getPath() - { - return $this->path; - } - - /** - * Set the URI path string. - * - * @param string $path The URI path string. - * - * @return void - * - * @since 11.1 - */ - public function setPath($path) - { - $this->path = $this->_cleanPath($path); - } - - /** - * Get the URI archor string - * Everything after the "#". - * - * @return string The URI anchor string. - * - * @since 11.1 - */ - public function getFragment() - { - return $this->fragment; - } - - /** - * Set the URI anchor string - * everything after the "#". - * - * @param string $anchor The URI anchor string. - * - * @return void - * - * @since 11.1 - */ - public function setFragment($anchor) - { - $this->fragment = $anchor; - } - - /** - * Checks whether the current URI is using HTTPS. - * - * @return boolean True if using SSL via HTTPS. - * - * @since 11.1 - */ - public function isSSL() - { - return $this->getScheme() == 'https' ? true : false; - } - - /** - * Checks if the supplied URL is internal + * Parse a given URI and populate the class fields. * - * @param string $url The URL to check. + * @param string $uri The URI string to parse. * - * @return boolean True if Internal. + * @return boolean True on success. * * @since 11.1 + * @note The parent method is protected, this exposes it as public for B/C */ - public static function isInternal($url) + public function parse($uri) { - $uri = self::getInstance($url); - $base = $uri->toString(array('scheme', 'host', 'port', 'path')); - $host = $uri->toString(array('scheme', 'host', 'port')); - - if (stripos($base, self::base()) !== 0 && !empty($host)) - { - return false; - } - - return true; + return parent::parse($uri); } /** @@ -788,34 +321,11 @@ public static function isInternal($url) * * @return string Cleaned and resolved URI path. * - * @since 11.1 + * @since 11.1 + * @deprecated 4.0 Use {@link \Joomla\Uri\Uri::cleanPath()} instead */ protected function _cleanPath($path) { - $path = explode('/', preg_replace('#(/+)#', '/', $path)); - - for ($i = 0, $n = count($path); $i < $n; $i++) - { - if ($path[$i] == '.' || $path[$i] == '..') - { - if (($path[$i] == '.') || ($path[$i] == '..' && $i == 1 && $path[0] == '')) - { - unset($path[$i]); - $path = array_values($path); - $i--; - $n--; - } - elseif ($path[$i] == '..' && ($i > 1 || ($i == 1 && $path[0] != ''))) - { - unset($path[$i]); - unset($path[$i - 1]); - $path = array_values($path); - $i -= 2; - $n -= 2; - } - } - } - - return implode('/', $path); + return parent::cleanPath($path); } } diff --git a/libraries/joomla/utilities/arrayhelper.php b/libraries/joomla/utilities/arrayhelper.php index 5e62b3bfce516..09f4542b636c6 100644 --- a/libraries/joomla/utilities/arrayhelper.php +++ b/libraries/joomla/utilities/arrayhelper.php @@ -9,12 +9,15 @@ defined('JPATH_PLATFORM') or die; +use Joomla\Utilities\ArrayHelper; + /** * JArrayHelper is an array utility class for doing all sorts of odds and ends with arrays. * * @package Joomla.Platform * @subpackage Utilities * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper instead */ abstract class JArrayHelper { @@ -59,6 +62,7 @@ abstract class JArrayHelper * @return void * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toInteger instead */ public static function toInteger(&$array, $default = null) { @@ -97,6 +101,7 @@ public static function toInteger(&$array, $default = null) * @return object The object mapped from the given array * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toObject instead */ public static function toObject(&$array, $class = 'stdClass', $recursive = true) { @@ -104,19 +109,11 @@ public static function toObject(&$array, $class = 'stdClass', $recursive = true) if (is_array($array)) { - $obj = new $class; - - foreach ($array as $k => $v) - { - if ($recursive && is_array($v)) - { - $obj->$k = self::toObject($v, $class); - } - else - { - $obj->$k = $v; - } - } + $obj = ArrayHelper::toObject($array, $class, $recursive); + } + else + { + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toObject.', JLog::WARNING, 'deprecated'); } return $obj; @@ -133,6 +130,7 @@ public static function toObject(&$array, $class = 'stdClass', $recursive = true) * @return string The string mapped from the given array * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::toString instead */ public static function toString($array = null, $inner_glue = '=', $outer_glue = ' ', $keepOuterKey = false) { @@ -140,22 +138,11 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = if (is_array($array)) { - foreach ($array as $key => $item) - { - if (is_array($item)) - { - if ($keepOuterKey) - { - $output[] = $key; - } - // This is value is an array, go and do it again! - $output[] = self::toString($item, $inner_glue, $outer_glue, $keepOuterKey); - } - else - { - $output[] = $key . $inner_glue . '"' . $item . '"'; - } - } + $output[] = ArrayHelper::toString($array, $inner_glue, $outer_glue, $keepOuterKey); + } + else + { + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toString.', JLog::WARNING, 'deprecated'); } return implode($outer_glue, $output); @@ -171,6 +158,7 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = * @return array The array mapped from the given object * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::fromObject instead */ public static function fromObject($p_obj, $recurse = true, $regex = null) { @@ -242,6 +230,7 @@ protected static function _fromObject($item, $recurse, $regex) * @return array Column of values from the source array * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::getColumn instead */ public static function getColumn(&$array, $index) { @@ -249,18 +238,11 @@ public static function getColumn(&$array, $index) if (is_array($array)) { - foreach ($array as &$item) - { - if (is_array($item) && isset($item[$index])) - { - $result[] = $item[$index]; - } - elseif (is_object($item) && isset($item->$index)) - { - $result[] = $item->$index; - } - // Else ignore the entry - } + $result = ArrayHelper::getColumn($array, $index); + } + else + { + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::getColumn.', JLog::WARNING, 'deprecated'); } return $result; @@ -277,66 +259,11 @@ public static function getColumn(&$array, $index) * @return mixed The value from the source array * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::getValue instead */ public static function getValue(&$array, $name, $default = null, $type = '') { - $result = null; - - if (isset($array[$name])) - { - $result = $array[$name]; - } - - // Handle the default case - if (is_null($result)) - { - $result = $default; - } - - // Handle the type constraint - switch (strtoupper($type)) - { - case 'INT': - case 'INTEGER': - // Only use the first integer value - @preg_match('/-?[0-9]+/', $result, $matches); - $result = @(int) $matches[0]; - break; - - case 'FLOAT': - case 'DOUBLE': - // Only use the first floating point value - @preg_match('/-?[0-9]+(\.[0-9]+)?/', $result, $matches); - $result = @(float) $matches[0]; - break; - - case 'BOOL': - case 'BOOLEAN': - $result = (bool) $result; - break; - - case 'ARRAY': - if (!is_array($result)) - { - $result = array($result); - } - break; - - case 'STRING': - $result = (string) $result; - break; - - case 'WORD': - $result = (string) preg_replace('#\W#', '', $result); - break; - - case 'NONE': - default: - // No casting necessary - break; - } - - return $result; + return ArrayHelper::getValue($array, $name, $default, $type); } /** @@ -365,29 +292,11 @@ public static function getValue(&$array, $name, $default = null, $type = '') * @return array The inverted array. * * @since 12.3 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::invert instead */ public static function invert($array) { - $return = array(); - - foreach ($array as $base => $values) - { - if (!is_array($values)) - { - continue; - } - - foreach ($values as $key) - { - // If the key isn't scalar then ignore it. - if (is_scalar($key)) - { - $return[$key] = $base; - } - } - } - - return $return; + return ArrayHelper::invert($array); } /** @@ -398,21 +307,11 @@ public static function invert($array) * @return boolean True if the array is an associative array. * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::isAssociative instead */ public static function isAssociative($array) { - if (is_array($array)) - { - foreach (array_keys($array) as $k => $v) - { - if ($k !== $v) - { - return true; - } - } - } - - return false; + return ArrayHelper::isAssociative($array); } /** @@ -424,6 +323,7 @@ public static function isAssociative($array) * @return array An array of arrays pivoted either on the value of the keys, or an individual key of an object or array. * * @since 11.3 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::pivot instead */ public static function pivot($source, $key = null) { @@ -502,6 +402,7 @@ public static function pivot($source, $key = null) * @return array The sorted array of objects * * @since 11.1 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::sortObjects instead */ public static function sortObjects(&$a, $k, $direction = 1, $caseSensitive = true, $locale = false) { @@ -596,6 +497,7 @@ protected static function _sortObjects(&$a, &$b) * * @see http://php.net/manual/en/function.array-unique.php * @since 11.2 + * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::arrayUnique instead */ public static function arrayUnique($myArray) { diff --git a/libraries/lessc/index.html b/libraries/lessc/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/lessc/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/phpmailer/extras/index.html b/libraries/phpmailer/extras/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/phpmailer/extras/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/phpmailer/index.html b/libraries/phpmailer/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/phpmailer/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/phpmailer/language/index.html b/libraries/phpmailer/language/index.html deleted file mode 100644 index 2efb97f319a35..0000000000000 --- a/libraries/phpmailer/language/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/vendor/autoload.php b/libraries/vendor/autoload.php new file mode 100644 index 0000000000000..6031856383757 --- /dev/null +++ b/libraries/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + public function getPrefixes() + { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * 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 bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/libraries/vendor/composer/autoload_classmap.php b/libraries/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000000000..0fe8e0ca74062 --- /dev/null +++ b/libraries/vendor/composer/autoload_classmap.php @@ -0,0 +1,19 @@ + $vendorDir . '/joomla/compat/src/JsonSerializable.php', + 'PHPMailer' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', + 'POP3' => $vendorDir . '/phpmailer/phpmailer/class.pop3.php', + 'SMTP' => $vendorDir . '/phpmailer/phpmailer/class.smtp.php', + 'lessc' => $vendorDir . '/leafo/lessphp/lessc.inc.php', + 'lessc_formatter_classic' => $vendorDir . '/leafo/lessphp/lessc.inc.php', + 'lessc_formatter_compressed' => $vendorDir . '/leafo/lessphp/lessc.inc.php', + 'lessc_formatter_lessjs' => $vendorDir . '/leafo/lessphp/lessc.inc.php', + 'lessc_parser' => $vendorDir . '/leafo/lessphp/lessc.inc.php', + 'phpmailerException' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php', +); diff --git a/libraries/vendor/composer/autoload_files.php b/libraries/vendor/composer/autoload_files.php new file mode 100644 index 0000000000000..301a4e105ef34 --- /dev/null +++ b/libraries/vendor/composer/autoload_files.php @@ -0,0 +1,10 @@ + array($vendorDir . '/symfony/yaml'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log'), + 'Joomla\\Session' => array($vendorDir . '/joomla/session'), +); diff --git a/libraries/vendor/composer/autoload_psr4.php b/libraries/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000000000..1fa134f1f492a --- /dev/null +++ b/libraries/vendor/composer/autoload_psr4.php @@ -0,0 +1,27 @@ + array($vendorDir . '/joomla/utilities/Tests'), + 'Joomla\\Utilities\\' => array($vendorDir . '/joomla/utilities/src'), + 'Joomla\\Uri\\Tests\\' => array($vendorDir . '/joomla/uri/Tests'), + 'Joomla\\Uri\\' => array($vendorDir . '/joomla/uri/src'), + 'Joomla\\String\\Tests\\' => array($vendorDir . '/joomla/string/Tests'), + 'Joomla\\String\\' => array($vendorDir . '/joomla/string/src'), + 'Joomla\\Registry\\Tests\\' => array($vendorDir . '/joomla/registry/Tests'), + 'Joomla\\Registry\\' => array($vendorDir . '/joomla/registry/src'), + 'Joomla\\Input\\Tests\\' => array($vendorDir . '/joomla/input/Tests'), + 'Joomla\\Input\\' => array($vendorDir . '/joomla/input/src'), + 'Joomla\\Filter\\Tests\\' => array($vendorDir . '/joomla/filter/Tests'), + 'Joomla\\Filter\\' => array($vendorDir . '/joomla/filter/src'), + 'Joomla\\Event\\Tests\\' => array($vendorDir . '/joomla/event/Tests'), + 'Joomla\\Event\\' => array($vendorDir . '/joomla/event/src'), + 'Joomla\\DI\\Tests\\' => array($vendorDir . '/joomla/di/Tests'), + 'Joomla\\DI\\' => array($vendorDir . '/joomla/di/src'), + 'Joomla\\Application\\Tests\\' => array($vendorDir . '/joomla/application/Tests'), + 'Joomla\\Application\\' => array($vendorDir . '/joomla/application/src'), +); diff --git a/libraries/vendor/composer/autoload_real.php b/libraries/vendor/composer/autoload_real.php new file mode 100644 index 0000000000000..3c8d5e0a36ec0 --- /dev/null +++ b/libraries/vendor/composer/autoload_real.php @@ -0,0 +1,55 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + $includeFiles = require __DIR__ . '/autoload_files.php'; + foreach ($includeFiles as $file) { + composerRequire17a170335afa68902bc725e1c9c6be64($file); + } + + return $loader; + } +} + +function composerRequire17a170335afa68902bc725e1c9c6be64($file) +{ + require $file; +} diff --git a/libraries/vendor/composer/installed.json b/libraries/vendor/composer/installed.json new file mode 100644 index 0000000000000..1c7bf285a3101 --- /dev/null +++ b/libraries/vendor/composer/installed.json @@ -0,0 +1,740 @@ +[ + { + "name": "joomla/di", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/di.git", + "reference": "4866c58e92ce4e851cd87d5d9d31b069b7284267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/di/zipball/4866c58e92ce4e851cd87d5d9d31b069b7284267", + "reference": "4866c58e92ce4e851cd87d5d9d31b069b7284267", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "time": "2014-03-21 13:20:34", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\DI\\": "src/", + "Joomla\\DI\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla DI Package", + "homepage": "https://github.com/joomla-framework/di", + "keywords": [ + "container", + "dependency injection", + "di", + "framework", + "ioc", + "joomla" + ] + }, + { + "name": "joomla/compat", + "version": "1.1.1", + "version_normalized": "1.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/compat.git", + "reference": "92ba45e9cfdca4c912691bf04ef13e0c03660348" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/compat/zipball/92ba45e9cfdca4c912691bf04ef13e0c03660348", + "reference": "92ba45e9cfdca4c912691bf04ef13e0c03660348", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "time": "2014-02-09 19:29:20", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/JsonSerializable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Compat Package", + "homepage": "https://github.com/joomla-framework/compat", + "keywords": [ + "compat", + "framework", + "joomla" + ] + }, + { + "name": "ircmaxell/password-compat", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "shasum": "" + }, + "time": "2013-04-30 19:58:08", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ] + }, + { + "name": "phpmailer/phpmailer", + "version": "v5.2.8", + "version_normalized": "5.2.8.0", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", + "reference": "d3802c597bff8f6c2ccfa3eab2a511aa01b8d68f", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "*", + "phpunit/phpunit": "4.0.*" + }, + "time": "2014-05-14 07:04:18", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "class.phpmailer.php", + "class.pop3.php", + "class.smtp.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP" + }, + { + "name": "psr/log", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "time": "2012-12-21 11:40:51", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ] + }, + { + "name": "joomla/uri", + "version": "1.1.1", + "version_normalized": "1.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/uri.git", + "reference": "980e532e4235bb8f1ada15b28822abbeb171da3f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/uri/zipball/980e532e4235bb8f1ada15b28822abbeb171da3f", + "reference": "980e532e4235bb8f1ada15b28822abbeb171da3f", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "time": "2014-02-09 02:57:17", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Uri\\": "src/", + "Joomla\\Uri\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Uri Package", + "homepage": "https://github.com/joomla-framework/uri", + "keywords": [ + "framework", + "joomla", + "uri" + ] + }, + { + "name": "joomla/filter", + "version": "1.1.2", + "version_normalized": "1.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/filter.git", + "reference": "bd097a34c1f94d54589462c960fd41921e61c1c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/filter/zipball/bd097a34c1f94d54589462c960fd41921e61c1c9", + "reference": "bd097a34c1f94d54589462c960fd41921e61c1c9", + "shasum": "" + }, + "require": { + "joomla/string": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/language": "~1.0" + }, + "suggest": { + "joomla/language": "Required only if you want to use `OutputFilter::stringURLSafe`." + }, + "time": "2014-02-09 07:45:50", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Filter\\": "src/", + "Joomla\\Filter\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Filter Package", + "homepage": "https://github.com/joomla-framework/filter", + "keywords": [ + "filter", + "framework", + "joomla" + ] + }, + { + "name": "joomla/event", + "version": "1.1.1", + "version_normalized": "1.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/event.git", + "reference": "bb957bc45aba897e465384bbe21cd0eb79aca901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/event/zipball/bb957bc45aba897e465384bbe21cd0eb79aca901", + "reference": "bb957bc45aba897e465384bbe21cd0eb79aca901", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "time": "2014-02-09 01:30:54", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Event\\": "src/", + "Joomla\\Event\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Event Package", + "homepage": "https://github.com/joomla-framework/event", + "keywords": [ + "event", + "framework", + "joomla" + ] + }, + { + "name": "joomla/session", + "version": "1.2.3", + "version_normalized": "1.2.3.0", + "target-dir": "Joomla/Session", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/session.git", + "reference": "ef955cf9642793c4ad5874f334069051c33ba604" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/session/zipball/ef955cf9642793c4ad5874f334069051c33ba604", + "reference": "ef955cf9642793c4ad5874f334069051c33ba604", + "shasum": "" + }, + "require": { + "joomla/event": "~1.1", + "joomla/filter": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0" + }, + "suggest": { + "joomla/database": "Install joomla/database if you want to use Database session storage." + }, + "time": "2014-08-18 17:41:06", + "type": "joomla-package", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Joomla\\Session": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Session Package", + "homepage": "https://github.com/joomla-framework/session", + "keywords": [ + "framework", + "joomla", + "session" + ] + }, + { + "name": "leafo/lessphp", + "version": "v0.3.9", + "version_normalized": "0.3.9.0", + "source": { + "type": "git", + "url": "https://github.com/leafo/lessphp.git", + "reference": "a11a6141b5715162b933c405379765d817891c5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/leafo/lessphp/zipball/a11a6141b5715162b933c405379765d817891c5d", + "reference": "a11a6141b5715162b933c405379765d817891c5d", + "shasum": "" + }, + "time": "2013-03-02 16:13:31", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "lessc.inc.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT", + "GPL-3.0" + ], + "authors": [ + { + "name": "Leaf Corcoran", + "email": "leafot@gmail.com", + "homepage": "http://leafo.net" + } + ], + "description": "lessphp is a compiler for LESS written in PHP.", + "homepage": "http://leafo.net/lessphp/" + }, + { + "name": "joomla/utilities", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/utilities.git", + "reference": "f749a9bd6f2fc5ad376687651478273dac105051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/utilities/zipball/f749a9bd6f2fc5ad376687651478273dac105051", + "reference": "f749a9bd6f2fc5ad376687651478273dac105051", + "shasum": "" + }, + "require": { + "joomla/string": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "time": "2014-09-03 21:44:44", + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Utilities\\": "src/", + "Joomla\\Utilities\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Utilities Package", + "homepage": "https://github.com/joomla-framework/utilities", + "keywords": [ + "framework", + "joomla", + "utilities" + ] + }, + { + "name": "joomla/string", + "version": "1.2.1", + "version_normalized": "1.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/string.git", + "reference": "edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/string/zipball/edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a", + "reference": "edc67e83f8e603ac7b55bf32b87d5b53fe1acd8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "time": "2014-09-18 12:21:47", + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\String\\": "src/", + "Joomla\\String\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla String Package", + "homepage": "https://github.com/joomla-framework/string", + "keywords": [ + "framework", + "joomla", + "string" + ] + }, + { + "name": "joomla/registry", + "version": "1.3.0", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/registry.git", + "reference": "7330ea6481d0fe062f46d2b6cb848c212789915e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/registry/zipball/7330ea6481d0fe062f46d2b6cb848c212789915e", + "reference": "7330ea6481d0fe062f46d2b6cb848c212789915e", + "shasum": "" + }, + "require": { + "joomla/compat": "~1.0", + "joomla/string": "~1.2", + "joomla/utilities": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*", + "symfony/yaml": "~2.0" + }, + "suggest": { + "symfony/yaml": "Install 2.* if you require YAML support." + }, + "time": "2014-10-08 16:14:29", + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Registry\\": "src/", + "Joomla\\Registry\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Registry Package", + "homepage": "https://github.com/joomla-framework/registry", + "keywords": [ + "framework", + "joomla", + "registry" + ] + }, + { + "name": "joomla/input", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/input.git", + "reference": "b6098276043e2d627221fe54d3c91232e6679d0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/input/zipball/b6098276043e2d627221fe54d3c91232e6679d0f", + "reference": "b6098276043e2d627221fe54d3c91232e6679d0f", + "shasum": "" + }, + "require": { + "joomla/filter": "~1.0", + "php": ">=5.3.10" + }, + "require-dev": { + "joomla/test": "~1.0", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "time": "2014-10-12 18:01:36", + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Input\\": "src/", + "Joomla\\Input\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Input Package", + "homepage": "https://github.com/joomla-framework/input", + "keywords": [ + "framework", + "input", + "joomla" + ] + }, + { + "name": "joomla/application", + "version": "1.3.0", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/joomla-framework/application.git", + "reference": "b7745273664294387bdd7fb694d75e65b7491f28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joomla-framework/application/zipball/b7745273664294387bdd7fb694d75e65b7491f28", + "reference": "b7745273664294387bdd7fb694d75e65b7491f28", + "shasum": "" + }, + "require": { + "joomla/input": "~1.2", + "joomla/registry": "~1.1", + "joomla/session": "~1.1", + "joomla/string": "~1.1", + "joomla/uri": "~1.1", + "php": ">=5.3.10", + "psr/log": "~1.0" + }, + "require-dev": { + "joomla/test": "~1.1", + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "1.*" + }, + "time": "2014-10-13 12:43:54", + "type": "joomla-package", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Joomla\\Application\\": "src/", + "Joomla\\Application\\Tests\\": "Tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "description": "Joomla Application Package", + "homepage": "https://github.com/joomla-framework/application", + "keywords": [ + "application", + "framework", + "joomla" + ] + }, + { + "name": "symfony/yaml", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-09-22 09:14:18", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" + } +] diff --git a/libraries/compat/password/LICENSE.md b/libraries/vendor/ircmaxell/password-compat/LICENSE.md similarity index 100% rename from libraries/compat/password/LICENSE.md rename to libraries/vendor/ircmaxell/password-compat/LICENSE.md diff --git a/libraries/compat/password/lib/password.php b/libraries/vendor/ircmaxell/password-compat/lib/password.php similarity index 99% rename from libraries/compat/password/lib/password.php rename to libraries/vendor/ircmaxell/password-compat/lib/password.php index faa5eaa5e10b5..4d0e8b7a63789 100644 --- a/libraries/compat/password/lib/password.php +++ b/libraries/vendor/ircmaxell/password-compat/lib/password.php @@ -7,7 +7,7 @@ * @copyright 2012 The Authors */ -if (!defined('PASSWORD_DEFAULT')) { +if (!defined('PASSWORD_BCRYPT')) { define('PASSWORD_BCRYPT', 1); define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); diff --git a/libraries/vendor/joomla/application/LICENSE b/libraries/vendor/joomla/application/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/application/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/application/src/AbstractApplication.php b/libraries/vendor/joomla/application/src/AbstractApplication.php new file mode 100644 index 0000000000000..9842c80ecfb23 --- /dev/null +++ b/libraries/vendor/joomla/application/src/AbstractApplication.php @@ -0,0 +1,207 @@ +input = $input instanceof Input ? $input : new Input; + $this->config = $config instanceof Registry ? $config : new Registry; + + $this->initialise(); + } + + /** + * Method to close the application. + * + * @param integer $code The exit code (optional; default is 0). + * + * @return void + * + * @codeCoverageIgnore + * @since 1.0 + */ + public function close($code = 0) + { + exit($code); + } + + /** + * Method to run the application routines. Most likely you will want to instantiate a controller + * and execute it, or perform some sort of task directly. + * + * @return void + * + * @since 1.0 + */ + abstract protected function doExecute(); + + /** + * Execute the application. + * + * @return void + * + * @since 1.0 + */ + public function execute() + { + // @event onBeforeExecute + + // Perform application routines. + $this->doExecute(); + + // @event onAfterExecute + } + + /** + * Returns a property of the object or the default value if the property is not set. + * + * @param string $key The name of the property. + * @param mixed $default The default value (optional) if none is set. + * + * @return mixed The value of the configuration. + * + * @since 1.0 + */ + public function get($key, $default = null) + { + return $this->config->get($key, $default); + } + + /** + * Get the logger. + * + * @return LoggerInterface + * + * @since 1.0 + */ + public function getLogger() + { + // If a logger hasn't been set, use NullLogger + if (! ($this->logger instanceof LoggerInterface)) + { + $this->logger = new NullLogger; + } + + return $this->logger; + } + + /** + * Custom initialisation method. + * + * Called at the end of the AbstractApplication::__construct method. + * This is for developers to inject initialisation code for their application classes. + * + * @return void + * + * @codeCoverageIgnore + * @since 1.0 + */ + protected function initialise() + { + } + + /** + * Modifies a property of the object, creating it if it does not already exist. + * + * @param string $key The name of the property. + * @param mixed $value The value of the property to set (optional). + * + * @return mixed Previous value of the property + * + * @since 1.0 + */ + public function set($key, $value = null) + { + $previous = $this->config->get($key); + $this->config->set($key, $value); + + return $previous; + } + + /** + * Sets the configuration for the application. + * + * @param Registry $config A registry object holding the configuration. + * + * @return AbstractApplication Returns itself to support chaining. + * + * @since 1.0 + */ + public function setConfiguration(Registry $config) + { + $this->config = $config; + + return $this; + } + + /** + * Set the logger. + * + * @param LoggerInterface $logger The logger. + * + * @return AbstractApplication Returns itself to support chaining. + * + * @since 1.0 + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + + return $this; + } +} diff --git a/libraries/vendor/joomla/application/src/AbstractCliApplication.php b/libraries/vendor/joomla/application/src/AbstractCliApplication.php new file mode 100644 index 0000000000000..6ba345c5511af --- /dev/null +++ b/libraries/vendor/joomla/application/src/AbstractCliApplication.php @@ -0,0 +1,108 @@ +close(); + } + + // @codeCoverageIgnoreEnd + + $this->output = ($output instanceof CliOutput) ? $output : new Cli\Output\Stdout; + + // Call the constructor as late as possible (it runs `initialise`). + parent::__construct($input instanceof Input\Input ? $input : new Input\Cli, $config); + + // Set the execution datetime and timestamp; + $this->set('execution.datetime', gmdate('Y-m-d H:i:s')); + $this->set('execution.timestamp', time()); + + // Set the current directory. + $this->set('cwd', getcwd()); + } + + /** + * Get an output object. + * + * @return CliOutput + * + * @since 1.0 + */ + public function getOutput() + { + return $this->output; + } + + /** + * Write a string to standard output. + * + * @param string $text The text to display. + * @param boolean $nl True (default) to append a new line at the end of the output string. + * + * @return AbstractCliApplication Instance of $this to allow chaining. + * + * @codeCoverageIgnore + * @since 1.0 + */ + public function out($text = '', $nl = true) + { + $this->output->out($text, $nl); + + return $this; + } + + /** + * Get a value from standard input. + * + * @return string The input string from standard input. + * + * @codeCoverageIgnore + * @since 1.0 + */ + public function in() + { + return rtrim(fread(STDIN, 8192), "\n\r"); + } +} diff --git a/libraries/vendor/joomla/application/src/AbstractDaemonApplication.php b/libraries/vendor/joomla/application/src/AbstractDaemonApplication.php new file mode 100644 index 0000000000000..d9265df5dfc23 --- /dev/null +++ b/libraries/vendor/joomla/application/src/AbstractDaemonApplication.php @@ -0,0 +1,921 @@ +getLogger()->error('The PCNTL extension for PHP is not available.'); + + throw new \RuntimeException('The PCNTL extension for PHP is not available.'); + } + + // Verify that POSIX support for PHP is available. + if (!function_exists('posix_getpid')) + { + $this->getLogger()->error('The POSIX extension for PHP is not available.'); + + throw new \RuntimeException('The POSIX extension for PHP is not available.'); + } + + // @codeCoverageIgnoreEnd + + // Call the parent constructor. + parent::__construct($input, $config); + + // Set some system limits. + @set_time_limit($this->config->get('max_execution_time', 0)); + + if ($this->config->get('max_memory_limit') !== null) + { + ini_set('memory_limit', $this->config->get('max_memory_limit', '256M')); + } + + // Flush content immediately. + ob_implicit_flush(); + } + + /** + * Method to handle POSIX signals. + * + * @param integer $signal The received POSIX signal. + * + * @return void + * + * @since 1.0 + * @see pcntl_signal() + * @throws \RuntimeException + */ + public function signal($signal) + { + // Log all signals sent to the daemon. + $this->getLogger()->debug('Received signal: ' . $signal); + + // Let's make sure we have an application instance. + if (!is_subclass_of($this, __CLASS__)) + { + $this->getLogger()->emergency('Cannot find the application instance.'); + + throw new \RuntimeException('Cannot find the application instance.'); + } + + // @event onReceiveSignal + + switch ($signal) + { + case SIGINT: + case SIGTERM: + // Handle shutdown tasks + if ($this->running && $this->isActive()) + { + $this->shutdown(); + } + else + { + $this->close(); + } + + break; + + case SIGHUP: + // Handle restart tasks + if ($this->running && $this->isActive()) + { + $this->shutdown(true); + } + else + { + $this->close(); + } + + break; + + case SIGCHLD: + // A child process has died + while ($this->pcntlWait($signal, WNOHANG || WUNTRACED) > 0) + { + usleep(1000); + } + + break; + + case SIGCLD: + while ($this->pcntlWait($signal, WNOHANG) > 0) + { + $signal = $this->pcntlChildExitStatus($signal); + } + + break; + + default: + break; + } + } + + /** + * Check to see if the daemon is active. This does not assume that $this daemon is active, but + * only if an instance of the application is active as a daemon. + * + * @return boolean True if daemon is active. + * + * @since 1.0 + */ + public function isActive() + { + // Get the process id file location for the application. + $pidFile = $this->config->get('application_pid_file'); + + // If the process id file doesn't exist then the daemon is obviously not running. + if (!is_file($pidFile)) + { + return false; + } + + // Read the contents of the process id file as an integer. + $fp = fopen($pidFile, 'r'); + $pid = fread($fp, filesize($pidFile)); + $pid = (int) $pid; + fclose($fp); + + // Check to make sure that the process id exists as a positive integer. + if (!$pid) + { + return false; + } + + // Check to make sure the process is active by pinging it and ensure it responds. + if (!posix_kill($pid, 0)) + { + // No response so remove the process id file and log the situation. + @ unlink($pidFile); + + $this->getLogger()->warning('The process found based on PID file was unresponsive.'); + + return false; + } + + return true; + } + + /** + * Load an object or array into the application configuration object. + * + * @param mixed $data Either an array or object to be loaded into the configuration object. + * + * @return AbstractDaemonApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function loadConfiguration($data) + { + /* + * Setup some application metadata options. This is useful if we ever want to write out startup scripts + * or just have some sort of information available to share about things. + */ + + // The application author name. This string is used in generating startup scripts and has + // a maximum of 50 characters. + $tmp = (string) $this->config->get('author_name', 'Joomla Framework'); + $this->config->set('author_name', (strlen($tmp) > 50) ? substr($tmp, 0, 50) : $tmp); + + // The application author email. This string is used in generating startup scripts. + $tmp = (string) $this->config->get('author_email', 'admin@joomla.org'); + $this->config->set('author_email', filter_var($tmp, FILTER_VALIDATE_EMAIL)); + + // The application name. This string is used in generating startup scripts. + $tmp = (string) $this->config->get('application_name', 'JApplicationDaemon'); + $this->config->set('application_name', (string) preg_replace('/[^A-Z0-9_-]/i', '', $tmp)); + + // The application description. This string is used in generating startup scripts. + $tmp = (string) $this->config->get('application_description', 'A generic Joomla Framework application.'); + $this->config->set('application_description', filter_var($tmp, FILTER_SANITIZE_STRING)); + + /* + * Setup the application path options. This defines the default executable name, executable directory, + * and also the path to the daemon process id file. + */ + + // The application executable daemon. This string is used in generating startup scripts. + $tmp = (string) $this->config->get('application_executable', basename($this->input->executable)); + $this->config->set('application_executable', $tmp); + + // The home directory of the daemon. + $tmp = (string) $this->config->get('application_directory', dirname($this->input->executable)); + $this->config->set('application_directory', $tmp); + + // The pid file location. This defaults to a path inside the /tmp directory. + $name = $this->config->get('application_name'); + $tmp = (string) $this->config->get('application_pid_file', strtolower('/tmp/' . $name . '/' . $name . '.pid')); + $this->config->set('application_pid_file', $tmp); + + /* + * Setup the application identity options. It is important to remember if the default of 0 is set for + * either UID or GID then changing that setting will not be attempted as there is no real way to "change" + * the identity of a process from some user to root. + */ + + // The user id under which to run the daemon. + $tmp = (int) $this->config->get('application_uid', 0); + $options = array('options' => array('min_range' => 0, 'max_range' => 65000)); + $this->config->set('application_uid', filter_var($tmp, FILTER_VALIDATE_INT, $options)); + + // The group id under which to run the daemon. + $tmp = (int) $this->config->get('application_gid', 0); + $options = array('options' => array('min_range' => 0, 'max_range' => 65000)); + $this->config->set('application_gid', filter_var($tmp, FILTER_VALIDATE_INT, $options)); + + // Option to kill the daemon if it cannot switch to the chosen identity. + $tmp = (bool) $this->config->get('application_require_identity', 1); + $this->config->set('application_require_identity', $tmp); + + /* + * Setup the application runtime options. By default our execution time limit is infinite obviously + * because a daemon should be constantly running unless told otherwise. The default limit for memory + * usage is 128M, which admittedly is a little high, but remember it is a "limit" and PHP's memory + * management leaves a bit to be desired :-) + */ + + // The maximum execution time of the application in seconds. Zero is infinite. + $tmp = $this->config->get('max_execution_time'); + + if ($tmp !== null) + { + $this->config->set('max_execution_time', (int) $tmp); + } + + // The maximum amount of memory the application can use. + $tmp = $this->config->get('max_memory_limit', '256M'); + + if ($tmp !== null) + { + $this->config->set('max_memory_limit', (string) $tmp); + } + + return $this; + } + + /** + * Execute the daemon. + * + * @return void + * + * @since 1.0 + */ + public function execute() + { + // @event onBeforeExecute + + // Enable basic garbage collection. + gc_enable(); + + $this->getLogger()->info('Starting ' . $this->name); + + // Set off the process for becoming a daemon. + if ($this->daemonize()) + { + // Declare ticks to start signal monitoring. When you declare ticks, PCNTL will monitor + // incoming signals after each tick and call the relevant signal handler automatically. + declare (ticks = 1); + + // Start the main execution loop. + while (true) + { + // Perform basic garbage collection. + $this->gc(); + + // Don't completely overload the CPU. + usleep(1000); + + // Execute the main application logic. + $this->doExecute(); + } + } + else + // We were not able to daemonize the application so log the failure and die gracefully. + { + $this->getLogger()->info('Starting ' . $this->name . ' failed'); + } + + // @event onAfterExecute + } + + /** + * Restart daemon process. + * + * @return void + * + * @codeCoverageIgnore + * @since 1.0 + */ + public function restart() + { + $this->getLogger()->info('Stopping ' . $this->name); + + $this->shutdown(true); + } + + /** + * Stop daemon process. + * + * @return void + * + * @codeCoverageIgnore + * @since 1.0 + */ + public function stop() + { + $this->getLogger()->info('Stopping ' . $this->name); + + $this->shutdown(); + } + + /** + * Method to change the identity of the daemon process and resources. + * + * @return boolean True if identity successfully changed + * + * @since 1.0 + * @see posix_setuid() + */ + protected function changeIdentity() + { + // Get the group and user ids to set for the daemon. + $uid = (int) $this->config->get('application_uid', 0); + $gid = (int) $this->config->get('application_gid', 0); + + // Get the application process id file path. + $file = $this->config->get('application_pid_file'); + + // Change the user id for the process id file if necessary. + if ($uid && (fileowner($file) != $uid) && (!@ chown($file, $uid))) + { + $this->getLogger()->error('Unable to change user ownership of the process id file.'); + + return false; + } + + // Change the group id for the process id file if necessary. + if ($gid && (filegroup($file) != $gid) && (!@ chgrp($file, $gid))) + { + $this->getLogger()->error('Unable to change group ownership of the process id file.'); + + return false; + } + + // Set the correct home directory for the process. + if ($uid && ($info = posix_getpwuid($uid)) && is_dir($info['dir'])) + { + system('export HOME="' . $info['dir'] . '"'); + } + + // Change the user id for the process necessary. + if ($uid && (posix_getuid($file) != $uid) && (!@ posix_setuid($uid))) + { + $this->getLogger()->error('Unable to change user ownership of the proccess.'); + + return false; + } + + // Change the group id for the process necessary. + if ($gid && (posix_getgid($file) != $gid) && (!@ posix_setgid($gid))) + { + $this->getLogger()->error('Unable to change group ownership of the proccess.'); + + return false; + } + + // Get the user and group information based on uid and gid. + $user = posix_getpwuid($uid); + $group = posix_getgrgid($gid); + + $this->getLogger()->info('Changed daemon identity to ' . $user['name'] . ':' . $group['name']); + + return true; + } + + /** + * Method to put the application into the background. + * + * @return boolean + * + * @since 1.0 + * @throws \RuntimeException + */ + protected function daemonize() + { + // Is there already an active daemon running? + if ($this->isActive()) + { + $this->getLogger()->emergency($this->name . ' daemon is still running. Exiting the application.'); + + return false; + } + + // Reset Process Information + $this->safeMode = !!@ ini_get('safe_mode'); + $this->processId = 0; + $this->running = false; + + // Detach process! + try + { + // Check if we should run in the foreground. + if (!$this->input->get('f')) + { + // Detach from the terminal. + $this->detach(); + } + else + { + // Setup running values. + $this->exiting = false; + $this->running = true; + + // Set the process id. + $this->processId = (int) posix_getpid(); + $this->parentId = $this->processId; + } + } + catch (\RuntimeException $e) + { + $this->getLogger()->emergency('Unable to fork.'); + + return false; + } + + // Verify the process id is valid. + if ($this->processId < 1) + { + $this->getLogger()->emergency('The process id is invalid; the fork failed.'); + + return false; + } + + // Clear the umask. + @ umask(0); + + // Write out the process id file for concurrency management. + if (!$this->writeProcessIdFile()) + { + $this->getLogger()->emergency('Unable to write the pid file at: ' . $this->config->get('application_pid_file')); + + return false; + } + + // Attempt to change the identity of user running the process. + if (!$this->changeIdentity()) + { + // If the identity change was required then we need to return false. + if ($this->config->get('application_require_identity')) + { + $this->getLogger()->critical('Unable to change process owner.'); + + return false; + } + else + { + $this->getLogger()->warning('Unable to change process owner.'); + } + } + + // Setup the signal handlers for the daemon. + if (!$this->setupSignalHandlers()) + { + return false; + } + + // Change the current working directory to the application working directory. + @ chdir($this->config->get('application_directory')); + + return true; + } + + /** + * This is truly where the magic happens. This is where we fork the process and kill the parent + * process, which is essentially what turns the application into a daemon. + * + * @return void + * + * @since 1.0 + * @throws \RuntimeException + */ + protected function detach() + { + $this->getLogger()->debug('Detaching the ' . $this->name . ' daemon.'); + + // Attempt to fork the process. + $pid = $this->fork(); + + // If the pid is positive then we successfully forked, and can close this application. + if ($pid) + { + // Add the log entry for debugging purposes and exit gracefully. + $this->getLogger()->debug('Ending ' . $this->name . ' parent process'); + + $this->close(); + } + else + // We are in the forked child process. + { + // Setup some protected values. + $this->exiting = false; + $this->running = true; + + // Set the parent to self. + $this->parentId = $this->processId; + } + } + + /** + * Method to fork the process. + * + * @return integer The child process id to the parent process, zero to the child process. + * + * @since 1.0 + * @throws \RuntimeException + */ + protected function fork() + { + // Attempt to fork the process. + $pid = $this->pcntlFork(); + + // If the fork failed, throw an exception. + if ($pid === -1) + { + throw new \RuntimeException('The process could not be forked.'); + } + elseif ($pid === 0) + // Update the process id for the child. + { + $this->processId = (int) posix_getpid(); + } + else + // Log the fork in the parent. + { + // Log the fork. + $this->getLogger()->debug('Process forked ' . $pid); + } + + // Trigger the onFork event. + $this->postFork(); + + return $pid; + } + + /** + * Method to perform basic garbage collection and memory management in the sense of clearing the + * stat cache. We will probably call this method pretty regularly in our main loop. + * + * @return void + * + * @codeCoverageIgnore + * @since 1.0 + */ + protected function gc() + { + // Perform generic garbage collection. + gc_collect_cycles(); + + // Clear the stat cache so it doesn't blow up memory. + clearstatcache(); + } + + /** + * Method to attach the AbstractDaemonApplication signal handler to the known signals. Applications + * can override these handlers by using the pcntl_signal() function and attaching a different + * callback method. + * + * @return boolean + * + * @since 1.0 + * @see pcntl_signal() + */ + protected function setupSignalHandlers() + { + // We add the error suppression for the loop because on some platforms some constants are not defined. + foreach (self::$signals as $signal) + { + // Ignore signals that are not defined. + if (!defined($signal) || !is_int(constant($signal)) || (constant($signal) === 0)) + { + // Define the signal to avoid notices. + $this->getLogger()->debug('Signal "' . $signal . '" not defined. Defining it as null.'); + + define($signal, null); + + // Don't listen for signal. + continue; + } + + // Attach the signal handler for the signal. + if (!$this->pcntlSignal(constant($signal), array($this, 'signal'))) + { + $this->getLogger()->emergency(sprintf('Unable to reroute signal handler: %s', $signal)); + + return false; + } + } + + return true; + } + + /** + * Method to shut down the daemon and optionally restart it. + * + * @param boolean $restart True to restart the daemon on exit. + * + * @return void + * + * @since 1.0 + */ + protected function shutdown($restart = false) + { + // If we are already exiting, chill. + if ($this->exiting) + { + return; + } + else + // If not, now we are. + { + $this->exiting = true; + } + + // If we aren't already daemonized then just kill the application. + if (!$this->running && !$this->isActive()) + { + $this->getLogger()->info('Process was not daemonized yet, just halting current process'); + + $this->close(); + } + + // Only read the pid for the parent file. + if ($this->parentId == $this->processId) + { + // Read the contents of the process id file as an integer. + $fp = fopen($this->config->get('application_pid_file'), 'r'); + $pid = fread($fp, filesize($this->config->get('application_pid_file'))); + $pid = (int) $pid; + fclose($fp); + + // Remove the process id file. + @ unlink($this->config->get('application_pid_file')); + + // If we are supposed to restart the daemon we need to execute the same command. + if ($restart) + { + $this->close(exec(implode(' ', $GLOBALS['argv']) . ' > /dev/null &')); + } + else + // If we are not supposed to restart the daemon let's just kill -9. + { + passthru('kill -9 ' . $pid); + $this->close(); + } + } + } + + /** + * Method to write the process id file out to disk. + * + * @return boolean + * + * @since 1.0 + */ + protected function writeProcessIdFile() + { + // Verify the process id is valid. + if ($this->processId < 1) + { + $this->getLogger()->emergency('The process id is invalid.'); + + return false; + } + + // Get the application process id file path. + $file = $this->config->get('application_pid_file'); + + if (empty($file)) + { + $this->getLogger()->error('The process id file path is empty.'); + + return false; + } + + // Make sure that the folder where we are writing the process id file exists. + $folder = dirname($file); + + if (!is_dir($folder) && !@ mkdir($folder, $this->get('folder_permission', 0755))) + { + $this->getLogger()->error('Unable to create directory: ' . $folder); + + return false; + } + + // Write the process id file out to disk. + if (!file_put_contents($file, $this->processId)) + { + $this->getLogger()->error('Unable to write proccess id file: ' . $file); + + return false; + } + + // Make sure the permissions for the proccess id file are accurate. + if (!chmod($file, $this->get('file_permission', 0644))) + { + $this->getLogger()->error('Unable to adjust permissions for the proccess id file: ' . $file); + + return false; + } + + return true; + } + + /** + * Method to handle post-fork triggering of the onFork event. + * + * @return void + * + * @since 1.0 + */ + protected function postFork() + { + // @event onFork + } + + /** + * Method to return the exit code of a terminated child process. + * + * @param integer $status The status parameter is the status parameter supplied to a successful call to pcntl_waitpid(). + * + * @return integer The child process exit code. + * + * @codeCoverageIgnore + * @see pcntl_wexitstatus() + * @since 1.0 + */ + protected function pcntlChildExitStatus($status) + { + return pcntl_wexitstatus($status); + } + + /** + * Method to return the exit code of a terminated child process. + * + * @return integer On success, the PID of the child process is returned in the parent's thread + * of execution, and a 0 is returned in the child's thread of execution. On + * failure, a -1 will be returned in the parent's context, no child process + * will be created, and a PHP error is raised. + * + * @codeCoverageIgnore + * @see pcntl_fork() + * @since 1.0 + */ + protected function pcntlFork() + { + return pcntl_fork(); + } + + /** + * Method to install a signal handler. + * + * @param integer $signal The signal number. + * @param callable $handler The signal handler which may be the name of a user created function, + * or method, or either of the two global constants SIG_IGN or SIG_DFL. + * @param boolean $restart Specifies whether system call restarting should be used when this + * signal arrives. + * + * @return boolean True on success. + * + * @codeCoverageIgnore + * @see pcntl_signal() + * @since 1.0 + */ + protected function pcntlSignal($signal , $handler, $restart = true) + { + return pcntl_signal($signal, $handler, $restart); + } + + /** + * Method to wait on or return the status of a forked child. + * + * @param integer &$status Status information. + * @param integer $options If wait3 is available on your system (mostly BSD-style systems), + * you can provide the optional options parameter. + * + * @return integer The process ID of the child which exited, -1 on error or zero if WNOHANG + * was provided as an option (on wait3-available systems) and no child was available. + * + * @codeCoverageIgnore + * @see pcntl_wait() + * @since 1.0 + */ + protected function pcntlWait(&$status, $options = 0) + { + return pcntl_wait($status, $options); + } +} diff --git a/libraries/vendor/joomla/application/src/AbstractWebApplication.php b/libraries/vendor/joomla/application/src/AbstractWebApplication.php new file mode 100644 index 0000000000000..c5e8150300e3a --- /dev/null +++ b/libraries/vendor/joomla/application/src/AbstractWebApplication.php @@ -0,0 +1,813 @@ +client = $client instanceof Web\WebClient ? $client : new Web\WebClient; + + // Setup the response object. + $this->response = new \stdClass; + $this->response->cachable = false; + $this->response->headers = array(); + $this->response->body = array(); + + // Call the constructor as late as possible (it runs `initialise`). + parent::__construct($input, $config); + + // Set the system URIs. + $this->loadSystemUris(); + + // Set the execution datetime and timestamp; + $this->set('execution.datetime', gmdate('Y-m-d H:i:s')); + $this->set('execution.timestamp', time()); + } + + /** + * Execute the application. + * + * @return void + * + * @since 1.0 + */ + public function execute() + { + // @event onBeforeExecute + + // Perform application routines. + $this->doExecute(); + + // @event onAfterExecute + + // If gzip compression is enabled in configuration and the server is compliant, compress the output. + if ($this->get('gzip') && !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler')) + { + $this->compress(); + } + + // @event onBeforeRespond + + // Send the application response. + $this->respond(); + + // @event onAfterRespond + } + + /** + * Checks the accept encoding of the browser and compresses the data before + * sending it to the client if possible. + * + * @return void + * + * @since 1.0 + */ + protected function compress() + { + // Supported compression encodings. + $supported = array( + 'x-gzip' => 'gz', + 'gzip' => 'gz', + 'deflate' => 'deflate' + ); + + // Get the supported encoding. + $encodings = array_intersect($this->client->encodings, array_keys($supported)); + + // If no supported encoding is detected do nothing and return. + if (empty($encodings)) + { + return; + } + + // Verify that headers have not yet been sent, and that our connection is still alive. + if ($this->checkHeadersSent() || !$this->checkConnectionAlive()) + { + return; + } + + // Iterate through the encodings and attempt to compress the data using any found supported encodings. + foreach ($encodings as $encoding) + { + if (($supported[$encoding] == 'gz') || ($supported[$encoding] == 'deflate')) + { + // Verify that the server supports gzip compression before we attempt to gzip encode the data. + // @codeCoverageIgnoreStart + if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) + { + continue; + } + + // @codeCoverageIgnoreEnd + + // Attempt to gzip encode the data with an optimal level 4. + $data = $this->getBody(); + $gzdata = gzencode($data, 4, ($supported[$encoding] == 'gz') ? FORCE_GZIP : FORCE_DEFLATE); + + // If there was a problem encoding the data just try the next encoding scheme. + // @codeCoverageIgnoreStart + if ($gzdata === false) + { + continue; + } + + // @codeCoverageIgnoreEnd + + // Set the encoding headers. + $this->setHeader('Content-Encoding', $encoding); + $this->setHeader('X-Content-Encoded-By', 'Joomla'); + + // Replace the output with the encoded data. + $this->setBody($gzdata); + + // Compression complete, let's break out of the loop. + break; + } + } + } + + /** + * Method to send the application response to the client. All headers will be sent prior to the main + * application output data. + * + * @return void + * + * @since 1.0 + */ + protected function respond() + { + // Send the content-type header. + $this->setHeader('Content-Type', $this->mimeType . '; charset=' . $this->charSet); + + // If the response is set to uncachable, we need to set some appropriate headers so browsers don't cache the response. + if (!$this->response->cachable) + { + // Expires in the past. + $this->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true); + + // Always modified. + $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); + $this->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); + + // HTTP 1.0 + $this->setHeader('Pragma', 'no-cache'); + } + else + { + // Expires. + $this->setHeader('Expires', gmdate('D, d M Y H:i:s', time() + 900) . ' GMT'); + + // Last modified. + if ($this->modifiedDate instanceof \DateTime) + { + $this->modifiedDate->setTimezone(new \DateTimeZone('UTC')); + $this->setHeader('Last-Modified', $this->modifiedDate->format('D, d M Y H:i:s') . ' GMT'); + } + } + + $this->sendHeaders(); + + echo $this->getBody(); + } + + /** + * Redirect to another URL. + * + * If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" + * or "303 See Other" code in the header pointing to the new location. If the headers have already been + * sent this will be accomplished using a JavaScript statement. + * + * @param string $url The URL to redirect to. Can only be http/https URL + * @param boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed. + * + * @return void + * + * @since 1.0 + */ + public function redirect($url, $moved = false) + { + // Check for relative internal links. + if (preg_match('#^index\.php#', $url)) + { + $url = $this->get('uri.base.full') . $url; + } + + // Perform a basic sanity check to make sure we don't have any CRLF garbage. + $url = preg_split("/[\r\n]/", $url); + $url = $url[0]; + + /* + * Here we need to check and see if the URL is relative or absolute. Essentially, do we need to + * prepend the URL with our base URL for a proper redirect. The rudimentary way we are looking + * at this is to simply check whether or not the URL string has a valid scheme or not. + */ + if (!preg_match('#^[a-z]+\://#i', $url)) + { + // Get a JURI instance for the requested URI. + $uri = new Uri($this->get('uri.request')); + + // Get a base URL to prepend from the requested URI. + $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); + + // We just need the prefix since we have a path relative to the root. + if ($url[0] == '/') + { + $url = $prefix . $url; + } + else + // It's relative to where we are now, so lets add that. + { + $parts = explode('/', $uri->toString(array('path'))); + array_pop($parts); + $path = implode('/', $parts) . '/'; + $url = $prefix . $path . $url; + } + } + + // If the headers have already been sent we need to send the redirect statement via JavaScript. + if ($this->checkHeadersSent()) + { + echo "\n"; + } + else + { + // We have to use a JavaScript redirect here because MSIE doesn't play nice with utf-8 URLs. + if (($this->client->engine == Web\WebClient::TRIDENT) && !String::is_ascii($url)) + { + $html = ''; + $html .= ''; + $html .= ''; + $html .= ''; + + echo $html; + } + else + { + // All other cases use the more efficient HTTP header for redirection. + $this->header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other'); + $this->header('Location: ' . $url); + $this->header('Content-Type: text/html; charset=' . $this->charSet); + + // Send other headers that may have been set. + $this->sendHeaders(); + } + } + + // Close the application after the redirect. + $this->close(); + } + + /** + * Set/get cachable state for the response. If $allow is set, sets the cachable state of the + * response. Always returns the current state. + * + * @param boolean $allow True to allow browser caching. + * + * @return boolean + * + * @since 1.0 + */ + public function allowCache($allow = null) + { + if ($allow !== null) + { + $this->response->cachable = (bool) $allow; + } + + return $this->response->cachable; + } + + /** + * Method to set a response header. If the replace flag is set then all headers + * with the given name will be replaced by the new one. The headers are stored + * in an internal array to be sent when the site is sent to the browser. + * + * @param string $name The name of the header to set. + * @param string $value The value of the header to set. + * @param boolean $replace True to replace any headers with the same name. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function setHeader($name, $value, $replace = false) + { + // Sanitize the input values. + $name = (string) $name; + $value = (string) $value; + + // If the replace flag is set, unset all known headers with the given name. + if ($replace) + { + foreach ($this->response->headers as $key => $header) + { + if ($name == $header['name']) + { + unset($this->response->headers[$key]); + } + } + + // Clean up the array as unsetting nested arrays leaves some junk. + $this->response->headers = array_values($this->response->headers); + } + + // Add the header to the internal array. + $this->response->headers[] = array('name' => $name, 'value' => $value); + + return $this; + } + + /** + * Method to get the array of response headers to be sent when the response is sent + * to the client. + * + * @return array + * + * @since 1.0 + */ + public function getHeaders() + { + return $this->response->headers; + } + + /** + * Method to clear any set response headers. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function clearHeaders() + { + $this->response->headers = array(); + + return $this; + } + + /** + * Send the response headers. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function sendHeaders() + { + if (!$this->checkHeadersSent()) + { + foreach ($this->response->headers as $header) + { + if ('status' == strtolower($header['name'])) + { + // 'status' headers indicate an HTTP status, and need to be handled slightly differently + $this->header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); + } + else + { + $this->header($header['name'] . ': ' . $header['value']); + } + } + } + + return $this; + } + + /** + * Set body content. If body content already defined, this will replace it. + * + * @param string $content The content to set as the response body. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function setBody($content) + { + $this->response->body = array((string) $content); + + return $this; + } + + /** + * Prepend content to the body content + * + * @param string $content The content to prepend to the response body. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function prependBody($content) + { + array_unshift($this->response->body, (string) $content); + + return $this; + } + + /** + * Append content to the body content + * + * @param string $content The content to append to the response body. + * + * @return AbstractWebApplication Instance of $this to allow chaining. + * + * @since 1.0 + */ + public function appendBody($content) + { + array_push($this->response->body, (string) $content); + + return $this; + } + + /** + * Return the body content + * + * @param boolean $asArray True to return the body as an array of strings. + * + * @return mixed The response body either as an array or concatenated string. + * + * @since 1.0 + */ + public function getBody($asArray = false) + { + return $asArray ? $this->response->body : implode((array) $this->response->body); + } + + /** + * Method to get the application session object. + * + * @return Session The session object + * + * @since 1.0 + * @deprecated 2.0 The joomla/session package will no longer be required by this class + */ + public function getSession() + { + return $this->session; + } + + /** + * Method to check the current client connnection status to ensure that it is alive. We are + * wrapping this to isolate the connection_status() function from our code base for testing reasons. + * + * @return boolean True if the connection is valid and normal. + * + * @codeCoverageIgnore + * @see connection_status() + * @since 1.0 + */ + protected function checkConnectionAlive() + { + return (connection_status() === CONNECTION_NORMAL); + } + + /** + * Method to check to see if headers have already been sent. We are wrapping this to isolate the + * headers_sent() function from our code base for testing reasons. + * + * @return boolean True if the headers have already been sent. + * + * @codeCoverageIgnore + * @see headers_sent() + * @since 1.0 + */ + protected function checkHeadersSent() + { + return headers_sent(); + } + + /** + * Method to detect the requested URI from server environment variables. + * + * @return string The requested URI + * + * @since 1.0 + */ + protected function detectRequestUri() + { + // First we need to detect the URI scheme. + if ($this->isSSLConnection()) + { + $scheme = 'https://'; + } + else + { + $scheme = 'http://'; + } + + /* + * There are some differences in the way that Apache and IIS populate server environment variables. To + * properly detect the requested URI we need to adjust our algorithm based on whether or not we are getting + * information from Apache or IIS. + */ + + // If PHP_SELF and REQUEST_URI are both populated then we will assume "Apache Mode". + if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) + { + // The URI is built from the HTTP_HOST and REQUEST_URI environment variables in an Apache environment. + $uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } + else + // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. + { + // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS + $uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + + // If the QUERY_STRING variable exists append it to the URI string. + if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) + { + $uri .= '?' . $_SERVER['QUERY_STRING']; + } + } + + return trim($uri); + } + + /** + * Method to send a header to the client. We are wrapping this to isolate the header() function + * from our code base for testing reasons. + * + * @param string $string The header string. + * @param boolean $replace The optional replace parameter indicates whether the header should + * replace a previous similar header, or add a second header of the same type. + * @param integer $code Forces the HTTP response code to the specified value. Note that + * this parameter only has an effect if the string is not empty. + * + * @return void + * + * @codeCoverageIgnore + * @see header() + * @since 1.0 + */ + protected function header($string, $replace = true, $code = null) + { + header($string, $replace, $code); + } + + /** + * Determine if we are using a secure (SSL) connection. + * + * @return boolean True if using SSL, false if not. + * + * @since 1.0 + */ + public function isSSLConnection() + { + return (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'); + } + + /** + * Sets the session for the application to use, if required. + * + * @param Session $session A session object. + * + * @return AbstractWebApplication Returns itself to support chaining. + * + * @since 1.0 + * @deprecated 2.0 The joomla/session package will no longer be required by this class + */ + public function setSession(Session $session) + { + $this->session = $session; + + return $this; + } + + /** + * Method to load the system URI strings for the application. + * + * @param string $requestUri An optional request URI to use instead of detecting one from the + * server environment variables. + * + * @return void + * + * @since 1.0 + */ + protected function loadSystemUris($requestUri = null) + { + // Set the request URI. + // @codeCoverageIgnoreStart + if (!empty($requestUri)) + { + $this->set('uri.request', $requestUri); + } + else + { + $this->set('uri.request', $this->detectRequestUri()); + } + + // @codeCoverageIgnoreEnd + + // Check to see if an explicit base URI has been set. + $siteUri = trim($this->get('site_uri')); + + if ($siteUri != '') + { + $uri = new Uri($siteUri); + $path = $uri->toString(array('path')); + } + else + // No explicit base URI was set so we need to detect it. + { + // Start with the requested URI. + $uri = new Uri($this->get('uri.request')); + + // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF. + if (strpos(php_sapi_name(), 'cgi') !== false && !ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) + { + // We aren't expecting PATH_INFO within PHP_SELF so this should work. + $path = dirname($_SERVER['PHP_SELF']); + } + else + // Pretty much everything else should be handled with SCRIPT_NAME. + { + $path = dirname($_SERVER['SCRIPT_NAME']); + } + } + + // Get the host from the URI. + $host = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); + + // Check if the path includes "index.php". + if (strpos($path, 'index.php') !== false) + { + // Remove the index.php portion of the path. + $path = substr_replace($path, '', strpos($path, 'index.php'), 9); + } + + $path = rtrim($path, '/\\'); + + // Set the base URI both as just a path and as the full URI. + $this->set('uri.base.full', $host . $path . '/'); + $this->set('uri.base.host', $host); + $this->set('uri.base.path', $path . '/'); + + // Set the extended (non-base) part of the request URI as the route. + if (stripos($this->get('uri.request'), $this->get('uri.base.full')) === 0) + { + $this->set('uri.route', substr_replace($this->get('uri.request'), '', 0, strlen($this->get('uri.base.full')))); + } + + // Get an explicitly set media URI is present. + $mediaURI = trim($this->get('media_uri')); + + if ($mediaURI) + { + if (strpos($mediaURI, '://') !== false) + { + $this->set('uri.media.full', $mediaURI); + $this->set('uri.media.path', $mediaURI); + } + else + { + // Normalise slashes. + $mediaURI = trim($mediaURI, '/\\'); + $mediaURI = !empty($mediaURI) ? '/' . $mediaURI . '/' : '/'; + $this->set('uri.media.full', $this->get('uri.base.host') . $mediaURI); + $this->set('uri.media.path', $mediaURI); + } + } + else + // No explicit media URI was set, build it dynamically from the base uri. + { + $this->set('uri.media.full', $this->get('uri.base.full') . 'media/'); + $this->set('uri.media.path', $this->get('uri.base.path') . 'media/'); + } + } + + /** + * Checks for a form token in the request. + * + * Use in conjunction with getFormToken. + * + * @param string $method The request method in which to look for the token key. + * + * @return boolean True if found and valid, false otherwise. + * + * @since 1.0 + * @deprecated 2.0 Deprecated without replacement + */ + public function checkToken($method = 'post') + { + $token = $this->getFormToken(); + + if (!$this->input->$method->get($token, '', 'alnum')) + { + if ($this->session->isNew()) + { + // Redirect to login screen. + $this->redirect('index.php'); + $this->close(); + } + else + { + return false; + } + } + else + { + return true; + } + } + + /** + * Method to determine a hash for anti-spoofing variable names + * + * @param boolean $forceNew If true, force a new token to be created + * + * @return string Hashed var name + * + * @since 1.0 + * @deprecated 2.0 Deprecated without replacement + */ + public function getFormToken($forceNew = false) + { + // @todo we need the user id somehow here + $userId = 0; + + return md5($this->get('secret') . $userId . $this->session->getToken($forceNew)); + } +} diff --git a/libraries/framework/Joomla/Application/Cli/CliOutput.php b/libraries/vendor/joomla/application/src/Cli/CliOutput.php similarity index 72% rename from libraries/framework/Joomla/Application/Cli/CliOutput.php rename to libraries/vendor/joomla/application/src/Cli/CliOutput.php index 0c9569b0a84aa..ecec4912906e4 100644 --- a/libraries/framework/Joomla/Application/Cli/CliOutput.php +++ b/libraries/vendor/joomla/application/src/Cli/CliOutput.php @@ -8,7 +8,6 @@ namespace Joomla\Application\Cli; -use Joomla\Application\Cli\Output\Stdout; use Joomla\Application\Cli\Output\Processor\ProcessorInterface; /** @@ -26,6 +25,18 @@ abstract class CliOutput */ protected $processor; + /** + * Constructor + * + * @param ProcessorInterface $processor The output processor. + * + * @since 1.1.2 + */ + public function __construct(ProcessorInterface $processor = null) + { + $this->setProcessor(($processor instanceof ProcessorInterface) ? $processor : new Output\Processor\ColorProcessor); + } + /** * Set a processor * @@ -48,10 +59,16 @@ public function setProcessor(ProcessorInterface $processor) * @return ProcessorInterface * * @since 1.0 + * @throws \RuntimeException */ public function getProcessor() { - return $this->processor; + if ($this->processor) + { + return $this->processor; + } + + throw new \RuntimeException('A ProcessorInterface object has not been set.'); } /** diff --git a/libraries/framework/Joomla/Application/Cli/ColorProcessor.php b/libraries/vendor/joomla/application/src/Cli/ColorProcessor.php similarity index 81% rename from libraries/framework/Joomla/Application/Cli/ColorProcessor.php rename to libraries/vendor/joomla/application/src/Cli/ColorProcessor.php index aafdfe7d55817..1a19932eec53e 100644 --- a/libraries/framework/Joomla/Application/Cli/ColorProcessor.php +++ b/libraries/vendor/joomla/application/src/Cli/ColorProcessor.php @@ -13,9 +13,8 @@ /** * Class ColorProcessor. * - * @since 1.0 - * - * @deprecated Use \Joomla\Application\Cli\Output\Processor\ColorProcessor + * @since 1.0 + * @deprecated 2.0 Use \Joomla\Application\Cli\Output\Processor\ColorProcessor */ class ColorProcessor extends RealColorProcessor { diff --git a/libraries/framework/Joomla/Application/Cli/ColorStyle.php b/libraries/vendor/joomla/application/src/Cli/ColorStyle.php similarity index 100% rename from libraries/framework/Joomla/Application/Cli/ColorStyle.php rename to libraries/vendor/joomla/application/src/Cli/ColorStyle.php diff --git a/libraries/framework/Joomla/Application/Cli/Output/Processor/ColorProcessor.php b/libraries/vendor/joomla/application/src/Cli/Output/Processor/ColorProcessor.php similarity index 88% rename from libraries/framework/Joomla/Application/Cli/Output/Processor/ColorProcessor.php rename to libraries/vendor/joomla/application/src/Cli/Output/Processor/ColorProcessor.php index 3302e492830f6..3084a49bb0f2a 100644 --- a/libraries/framework/Joomla/Application/Cli/Output/Processor/ColorProcessor.php +++ b/libraries/vendor/joomla/application/src/Cli/Output/Processor/ColorProcessor.php @@ -53,10 +53,23 @@ class ColorProcessor implements ProcessorInterface /** * Class constructor * + * @param boolean $noColors Defines non-colored mode on construct + * * @since 1.1.0 */ - public function __construct() + public function __construct($noColors = null) { + if (is_null($noColors)) + { + /* + * By default windows cmd.exe and PowerShell does not support ANSI-colored output + * if the variable is not set explicitly colors should be disabled on Windows + */ + $noColors = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); + } + + $this->noColors = $noColors; + $this->addPredefinedStyles(); } diff --git a/libraries/framework/Joomla/Application/Cli/Output/Processor/ProcessorInterface.php b/libraries/vendor/joomla/application/src/Cli/Output/Processor/ProcessorInterface.php similarity index 90% rename from libraries/framework/Joomla/Application/Cli/Output/Processor/ProcessorInterface.php rename to libraries/vendor/joomla/application/src/Cli/Output/Processor/ProcessorInterface.php index 94a6702b4db5e..a9665d4f94c05 100644 --- a/libraries/framework/Joomla/Application/Cli/Output/Processor/ProcessorInterface.php +++ b/libraries/vendor/joomla/application/src/Cli/Output/Processor/ProcessorInterface.php @@ -18,7 +18,7 @@ interface ProcessorInterface /** * Process the provided output into a string. * - * @param mixed + * @param string $output The string to process. * * @return string * diff --git a/libraries/framework/Joomla/Application/Cli/Output/Stdout.php b/libraries/vendor/joomla/application/src/Cli/Output/Stdout.php similarity index 87% rename from libraries/framework/Joomla/Application/Cli/Output/Stdout.php rename to libraries/vendor/joomla/application/src/Cli/Output/Stdout.php index 382cfec0be860..3291240845757 100644 --- a/libraries/framework/Joomla/Application/Cli/Output/Stdout.php +++ b/libraries/vendor/joomla/application/src/Cli/Output/Stdout.php @@ -25,11 +25,12 @@ class Stdout extends CliOutput * * @return Stdout Instance of $this to allow chaining. * + * @codeCoverageIgnore * @since 1.0 */ public function out($text = '', $nl = true) { - fwrite(STDOUT, $this->processor->process($text) . ($nl ? "\n" : null)); + fwrite(STDOUT, $this->getProcessor()->process($text) . ($nl ? "\n" : null)); return $this; } diff --git a/libraries/framework/Joomla/Application/Cli/Output/Xml.php b/libraries/vendor/joomla/application/src/Cli/Output/Xml.php similarity index 100% rename from libraries/framework/Joomla/Application/Cli/Output/Xml.php rename to libraries/vendor/joomla/application/src/Cli/Output/Xml.php diff --git a/libraries/vendor/joomla/application/src/Web/WebClient.php b/libraries/vendor/joomla/application/src/Web/WebClient.php new file mode 100644 index 0000000000000..83109f8ea19c5 --- /dev/null +++ b/libraries/vendor/joomla/application/src/Web/WebClient.php @@ -0,0 +1,559 @@ +userAgent = $_SERVER['HTTP_USER_AGENT']; + } + else + { + $this->userAgent = $userAgent; + } + + // If no explicit acceptable encoding string was given attempt to use the implicit one from server environment. + if (empty($acceptEncoding) && isset($_SERVER['HTTP_ACCEPT_ENCODING'])) + { + $this->acceptEncoding = $_SERVER['HTTP_ACCEPT_ENCODING']; + } + else + { + $this->acceptEncoding = $acceptEncoding; + } + + // If no explicit acceptable languages string was given attempt to use the implicit one from server environment. + if (empty($acceptLanguage) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) + { + $this->acceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE']; + } + else + { + $this->acceptLanguage = $acceptLanguage; + } + } + + /** + * Magic method to get an object property's value by name. + * + * @param string $name Name of the property for which to return a value. + * + * @return mixed The requested value if it exists. + * + * @since 1.0 + */ + public function __get($name) + { + switch ($name) + { + case 'mobile': + case 'platform': + if (empty($this->detection['platform'])) + { + $this->detectPlatform($this->userAgent); + } + break; + + case 'engine': + if (empty($this->detection['engine'])) + { + $this->detectEngine($this->userAgent); + } + break; + + case 'browser': + case 'browserVersion': + if (empty($this->detection['browser'])) + { + $this->detectBrowser($this->userAgent); + } + break; + + case 'languages': + if (empty($this->detection['acceptLanguage'])) + { + $this->detectLanguage($this->acceptLanguage); + } + break; + + case 'encodings': + if (empty($this->detection['acceptEncoding'])) + { + $this->detectEncoding($this->acceptEncoding); + } + break; + + case 'robot': + if (empty($this->detection['robot'])) + { + $this->detectRobot($this->userAgent); + } + break; + case 'headers': + if (empty($this->detection['headers'])) + { + $this->detectHeaders(); + } + break; + } + + // Return the property if it exists. + if (isset($this->$name)) + { + return $this->$name; + } + } + + /** + * Detects the client browser and version in a user agent string. + * + * @param string $userAgent The user-agent string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectBrowser($userAgent) + { + // Attempt to detect the browser type. Obviously we are only worried about major browsers. + if ((stripos($userAgent, 'MSIE') !== false) && (stripos($userAgent, 'Opera') === false)) + { + $this->browser = self::IE; + $patternBrowser = 'MSIE'; + } + elseif ((stripos($userAgent, 'Firefox') !== false) && (stripos($userAgent, 'like Firefox') === false)) + { + $this->browser = self::FIREFOX; + $patternBrowser = 'Firefox'; + } + elseif (stripos($userAgent, 'Chrome') !== false) + { + $this->browser = self::CHROME; + $patternBrowser = 'Chrome'; + } + elseif (stripos($userAgent, 'Safari') !== false) + { + $this->browser = self::SAFARI; + $patternBrowser = 'Safari'; + } + elseif (stripos($userAgent, 'Opera') !== false) + { + $this->browser = self::OPERA; + $patternBrowser = 'Opera'; + } + + // If we detected a known browser let's attempt to determine the version. + if ($this->browser) + { + // Build the REGEX pattern to match the browser version string within the user agent string. + $pattern = '#(?Version|' . $patternBrowser . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; + + // Attempt to find version strings in the user agent string. + $matches = array(); + + if (preg_match_all($pattern, $userAgent, $matches)) + { + // Do we have both a Version and browser match? + if (count($matches['browser']) == 2) + { + // See whether Version or browser came first, and use the number accordingly. + if (strripos($userAgent, 'Version') < strripos($userAgent, $patternBrowser)) + { + $this->browserVersion = $matches['version'][0]; + } + else + { + $this->browserVersion = $matches['version'][1]; + } + } + elseif (count($matches['browser']) > 2) + { + $key = array_search('Version', $matches['browser']); + + if ($key) + { + $this->browserVersion = $matches['version'][$key]; + } + } + else + // We only have a Version or a browser so use what we have. + { + $this->browserVersion = $matches['version'][0]; + } + } + } + + // Mark this detection routine as run. + $this->detection['browser'] = true; + } + + /** + * Method to detect the accepted response encoding by the client. + * + * @param string $acceptEncoding The client accept encoding string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectEncoding($acceptEncoding) + { + // Parse the accepted encodings. + $this->encodings = array_map('trim', (array) explode(',', $acceptEncoding)); + + // Mark this detection routine as run. + $this->detection['acceptEncoding'] = true; + } + + /** + * Detects the client rendering engine in a user agent string. + * + * @param string $userAgent The user-agent string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectEngine($userAgent) + { + if (stripos($userAgent, 'MSIE') !== false || stripos($userAgent, 'Trident') !== false) + { + // Attempt to detect the client engine -- starting with the most popular ... for now. + $this->engine = self::TRIDENT; + } + elseif (stripos($userAgent, 'AppleWebKit') !== false || stripos($userAgent, 'blackberry') !== false) + { + // Evidently blackberry uses WebKit and doesn't necessarily report it. Bad RIM. + $this->engine = self::WEBKIT; + } + elseif (stripos($userAgent, 'Gecko') !== false && stripos($userAgent, 'like Gecko') === false) + { + // We have to check for like Gecko because some other browsers spoof Gecko. + $this->engine = self::GECKO; + } + elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false) + { + // Sometimes Opera browsers don't say Presto. + $this->engine = self::PRESTO; + } + elseif (stripos($userAgent, 'KHTML') !== false) + { + // *sigh* + $this->engine = self::KHTML; + } + elseif (stripos($userAgent, 'Amaya') !== false) + { + // Lesser known engine but it finishes off the major list from Wikipedia :-) + $this->engine = self::AMAYA; + } + + // Mark this detection routine as run. + $this->detection['engine'] = true; + } + + /** + * Method to detect the accepted languages by the client. + * + * @param mixed $acceptLanguage The client accept language string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectLanguage($acceptLanguage) + { + // Parse the accepted encodings. + $this->languages = array_map('trim', (array) explode(',', $acceptLanguage)); + + // Mark this detection routine as run. + $this->detection['acceptLanguage'] = true; + } + + /** + * Detects the client platform in a user agent string. + * + * @param string $userAgent The user-agent string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectPlatform($userAgent) + { + // Attempt to detect the client platform. + if (stripos($userAgent, 'Windows') !== false) + { + $this->platform = self::WINDOWS; + + // Let's look at the specific mobile options in the Windows space. + if (stripos($userAgent, 'Windows Phone') !== false) + { + $this->mobile = true; + $this->platform = self::WINDOWS_PHONE; + } + elseif (stripos($userAgent, 'Windows CE') !== false) + { + $this->mobile = true; + $this->platform = self::WINDOWS_CE; + } + } + elseif (stripos($userAgent, 'iPhone') !== false) + { + // Interestingly 'iPhone' is present in all iOS devices so far including iPad and iPods. + $this->mobile = true; + $this->platform = self::IPHONE; + + // Let's look at the specific mobile options in the iOS space. + if (stripos($userAgent, 'iPad') !== false) + { + $this->platform = self::IPAD; + } + elseif (stripos($userAgent, 'iPod') !== false) + { + $this->platform = self::IPOD; + } + } + elseif (stripos($userAgent, 'iPad') !== false) + { + // In case where iPhone is not mentioed in iPad user agent string + $this->mobile = true; + $this->platform = self::IPAD; + } + elseif (stripos($userAgent, 'iPod') !== false) + { + // In case where iPhone is not mentioed in iPod user agent string + $this->mobile = true; + $this->platform = self::IPOD; + } + elseif (preg_match('/macintosh|mac os x/i', $userAgent)) + { + // This has to come after the iPhone check because mac strings are also present in iOS devices. + $this->platform = self::MAC; + } + elseif (stripos($userAgent, 'Blackberry') !== false) + { + $this->mobile = true; + $this->platform = self::BLACKBERRY; + } + elseif (stripos($userAgent, 'Android') !== false) + { + $this->mobile = true; + $this->platform = self::ANDROID; + /** + * Attempt to distinguish between Android phones and tablets + * There is no totally foolproof method but certain rules almost always hold + * Android 3.x is only used for tablets + * Some devices and browsers encourage users to change their UA string to include Tablet. + * Google encourages manufacturers to exclude the string Mobile from tablet device UA strings. + * In some modes Kindle Android devices include the string Mobile but they include the string Silk. + */ + if (stripos($userAgent, 'Android 3') !== false || stripos($userAgent, 'Tablet') !== false + || stripos($userAgent, 'Mobile') === false || stripos($userAgent, 'Silk') !== false ) + { + $this->platform = self::ANDROIDTABLET; + } + } + elseif (stripos($userAgent, 'Linux') !== false) + { + $this->platform = self::LINUX; + } + + // Mark this detection routine as run. + $this->detection['platform'] = true; + } + + /** + * Determines if the browser is a robot or not. + * + * @param string $userAgent The user-agent string to parse. + * + * @return void + * + * @since 1.0 + */ + protected function detectRobot($userAgent) + { + if (preg_match('/http|bot|robot|spider|crawler|curl|^$/i', $userAgent)) + { + $this->robot = true; + } + else + { + $this->robot = false; + } + + $this->detection['robot'] = true; + } + + /** + * Fills internal array of headers + * + * @return void + * + * @since 1.3.0 + */ + protected function detectHeaders() + { + if (function_exists('getallheaders')) + // If php is working under Apache, there is a special function + { + $this->headers = getallheaders(); + } + else + // Else we fill headers from $_SERVER variable + { + $this->headers = array(); + + foreach ($_SERVER as $name => $value) + { + if (substr($name, 0, 5) == 'HTTP_') + { + $this->headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + } + } + } + + // Mark this detection routine as run. + $this->detection['headers'] = true; + } +} diff --git a/libraries/vendor/joomla/compat/LICENSE b/libraries/vendor/joomla/compat/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/compat/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/compat/jsonserializable.php b/libraries/vendor/joomla/compat/src/JsonSerializable.php similarity index 63% rename from libraries/compat/jsonserializable.php rename to libraries/vendor/joomla/compat/src/JsonSerializable.php index 4ec5e846a2231..4f513f6210b58 100644 --- a/libraries/compat/jsonserializable.php +++ b/libraries/vendor/joomla/compat/src/JsonSerializable.php @@ -1,20 +1,17 @@ + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/framework/Joomla/DI/Container.php b/libraries/vendor/joomla/di/src/Container.php similarity index 91% rename from libraries/framework/Joomla/DI/Container.php rename to libraries/vendor/joomla/di/src/Container.php index 726d7645caeb6..3fbf06909f6e8 100644 --- a/libraries/framework/Joomla/DI/Container.php +++ b/libraries/vendor/joomla/di/src/Container.php @@ -2,7 +2,7 @@ /** * Part of the Joomla Framework DI Package * - * @copyright Copyright (C) 2013 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ @@ -21,7 +21,6 @@ class Container * Holds the key aliases. * * @var array $aliases - * * @since 1.0 */ protected $aliases = array(); @@ -30,7 +29,6 @@ class Container * Holds the shared instances. * * @var array $instances - * * @since 1.0 */ protected $instances = array(); @@ -40,7 +38,6 @@ class Container * the item is meant to be a shared resource. * * @var array $dataStore - * * @since 1.0 */ protected $dataStore = array(); @@ -49,7 +46,6 @@ class Container * Parent for hierarchical containers. * * @var Container - * * @since 1.0 */ protected $parent; @@ -59,7 +55,7 @@ class Container * * @param Container $parent Parent for hierarchical containers. * - * @since 1.0 + * @since 1.0 */ public function __construct(Container $parent = null) { @@ -72,7 +68,9 @@ public function __construct(Container $parent = null) * @param string $alias The alias name * @param string $key The key to alias * - * @return Container + * @return Container This object for chaining. + * + * @since 1.0 */ public function alias($alias, $key) { @@ -162,9 +160,9 @@ public function buildSharedObject($key) * Create a child Container with a new property scope that * that has the ability to access the parent scope when resolving. * - * @return Container + * @return Container This object for chaining. * - * @since 1.0 + * @since 1.0 */ public function createChild() { @@ -263,9 +261,9 @@ protected function getMethodArgs(\ReflectionMethod $method) * @param boolean $shared True to create and store a shared instance. * @param boolean $protected True to protect this item from being overwritten. Useful for services. * - * @return \Joomla\DI\Container This instance to support chaining. + * @return Container This object for chaining. * - * @throws \OutOfBoundsException Thrown if the provided key is already set and is protected. + * @throws \OutOfBoundsException Thrown if the provided key is already set and is protected. * * @since 1.0 */ @@ -277,7 +275,7 @@ public function set($key, $value, $shared = false, $protected = false) } // If the provided $value is not a closure, make it one now for easy resolution. - if (!($value instanceof \Closure)) + if (!is_callable($value)) { $value = function () use ($value) { return $value; @@ -300,7 +298,7 @@ public function set($key, $value, $shared = false, $protected = false) * @param callable $callback Callable function to run when requesting the specified $key. * @param bool $shared True to create and store a shared instance. * - * @return \Joomla\DI\Container This instance to support chaining. + * @return Container This object for chaining. * * @since 1.0 */ @@ -316,7 +314,7 @@ public function protect($key, $callback, $shared = false) * @param callable $callback Callable function to run when requesting the specified $key. * @param bool $protected True to create and store a shared instance. * - * @return \Joomla\DI\Container This instance to support chaining. + * @return Container This object for chaining. * * @since 1.0 */ @@ -355,7 +353,21 @@ public function get($key, $forceNew = false) return $this->instances[$key]; } - return $raw['callback']($this); + return call_user_func($raw['callback'], $this); + } + + /** + * Method to check if specified dataStore key exists. + * + * @param string $key Name of the dataStore key to check. + * + * @return boolean True for success + * + * @since 1.0 + */ + public function exists($key) + { + return (bool) $this->getRaw($key); } /** @@ -364,6 +376,8 @@ public function get($key, $forceNew = false) * @param string $key The key for which to get the stored item. * * @return mixed + * + * @since 1.0 */ protected function getRaw($key) { diff --git a/libraries/framework/Joomla/DI/ContainerAwareInterface.php b/libraries/vendor/joomla/di/src/ContainerAwareInterface.php similarity index 75% rename from libraries/framework/Joomla/DI/ContainerAwareInterface.php rename to libraries/vendor/joomla/di/src/ContainerAwareInterface.php index 3691df264c277..879da36507993 100644 --- a/libraries/framework/Joomla/DI/ContainerAwareInterface.php +++ b/libraries/vendor/joomla/di/src/ContainerAwareInterface.php @@ -2,12 +2,17 @@ /** * Part of the Joomla Framework DI Package * - * @copyright Copyright (C) 2013 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\DI; +/** + * Defines the interface for a Container Aware class. + * + * @since 1.0 + */ interface ContainerAwareInterface { /** @@ -26,6 +31,8 @@ public function getContainer(); * * @param Container $container The DI container. * + * @return mixed + * * @since 1.0 */ public function setContainer(Container $container); diff --git a/libraries/vendor/joomla/di/src/ContainerAwareTrait.php b/libraries/vendor/joomla/di/src/ContainerAwareTrait.php new file mode 100644 index 0000000000000..eb70f0f127a57 --- /dev/null +++ b/libraries/vendor/joomla/di/src/ContainerAwareTrait.php @@ -0,0 +1,64 @@ +container) + { + return $this->container; + } + + throw new \UnexpectedValueException('Container not set in ' . __CLASS__); + } + + /** + * Set the DI container. + * + * @param Container $container The DI container. + * + * @return mixed Returns itself to support chaining. + * + * @since 1.2 + */ + public function setContainer(Container $container) + { + $this->container = $container; + + return $this; + } +} diff --git a/libraries/vendor/joomla/di/src/Exception/DependencyResolutionException.php b/libraries/vendor/joomla/di/src/Exception/DependencyResolutionException.php new file mode 100644 index 0000000000000..96dd837799066 --- /dev/null +++ b/libraries/vendor/joomla/di/src/Exception/DependencyResolutionException.php @@ -0,0 +1,18 @@ + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/event/src/AbstractEvent.php b/libraries/vendor/joomla/event/src/AbstractEvent.php new file mode 100644 index 0000000000000..645ed9af8cba3 --- /dev/null +++ b/libraries/vendor/joomla/event/src/AbstractEvent.php @@ -0,0 +1,199 @@ +name = $name; + $this->arguments = $arguments; + } + + /** + * Get the event name. + * + * @return string The event name. + * + * @since 1.0 + */ + public function getName() + { + return $this->name; + } + + /** + * Get an event argument value. + * + * @param string $name The argument name. + * @param mixed $default The default value if not found. + * + * @return mixed The argument value or the default value. + * + * @since 1.0 + */ + public function getArgument($name, $default = null) + { + if (isset($this->arguments[$name])) + { + return $this->arguments[$name]; + } + + return $default; + } + + /** + * Tell if the given event argument exists. + * + * @param string $name The argument name. + * + * @return boolean True if it exists, false otherwise. + * + * @since 1.0 + */ + public function hasArgument($name) + { + return isset($this->arguments[$name]); + } + + /** + * Get all event arguments. + * + * @return array An associative array of argument names as keys + * and their values as values. + * + * @since 1.0 + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * Tell if the event propagation is stopped. + * + * @return boolean True if stopped, false otherwise. + * + * @since 1.0 + */ + public function isStopped() + { + return true === $this->stopped; + } + + /** + * Count the number of arguments. + * + * @return integer The number of arguments. + * + * @since 1.0 + */ + public function count() + { + return count($this->arguments); + } + + /** + * Serialize the event. + * + * @return string The serialized event. + * + * @since 1.0 + */ + public function serialize() + { + return serialize(array($this->name, $this->arguments, $this->stopped)); + } + + /** + * Unserialize the event. + * + * @param string $serialized The serialized event. + * + * @return void + * + * @since 1.0 + */ + public function unserialize($serialized) + { + list($this->name, $this->arguments, $this->stopped) = unserialize($serialized); + } + + /** + * Tell if the given event argument exists. + * + * @param string $name The argument name. + * + * @return boolean True if it exists, false otherwise. + * + * @since 1.0 + */ + public function offsetExists($name) + { + return $this->hasArgument($name); + } + + /** + * Get an event argument value. + * + * @param string $name The argument name. + * + * @return mixed The argument value or null if not existing. + * + * @since 1.0 + */ + public function offsetGet($name) + { + return $this->getArgument($name); + } +} diff --git a/libraries/vendor/joomla/event/src/DelegatingDispatcher.php b/libraries/vendor/joomla/event/src/DelegatingDispatcher.php new file mode 100644 index 0000000000000..9ade5ebfd577c --- /dev/null +++ b/libraries/vendor/joomla/event/src/DelegatingDispatcher.php @@ -0,0 +1,52 @@ +dispatcher = $dispatcher; + } + + /** + * Trigger an event. + * + * @param EventInterface|string $event The event object or name. + * + * @return EventInterface The event after being passed through all listeners. + * + * @since 1.0 + */ + public function triggerEvent($event) + { + return $this->dispatcher->triggerEvent($event); + } +} diff --git a/libraries/vendor/joomla/event/src/Dispatcher.php b/libraries/vendor/joomla/event/src/Dispatcher.php new file mode 100644 index 0000000000000..d08ce360e325d --- /dev/null +++ b/libraries/vendor/joomla/event/src/Dispatcher.php @@ -0,0 +1,506 @@ +events[$event->getName()] = $event; + + return $this; + } + + /** + * Sets a regular expression to filter the class methods when adding a listener. + * + * @param string $regex A regular expression (for example '^on' will only register methods starting with "on"). + * + * @return Dispatcher This method is chainable. + * + * @since 1.0 + * @deprecated Incorporate a method in your listener object such as `getEvents` to feed into the `setListener` method. + */ + public function setListenerFilter($regex) + { + $this->listenerFilter = $regex; + + return $this; + } + + /** + * Add an event to this dispatcher, only if it is not existing. + * + * @param EventInterface $event The event. + * + * @return Dispatcher This method is chainable. + * + * @since 1.0 + */ + public function addEvent(EventInterface $event) + { + if (!isset($this->events[$event->getName()])) + { + $this->events[$event->getName()] = $event; + } + + return $this; + } + + /** + * Tell if the given event has been added to this dispatcher. + * + * @param EventInterface|string $event The event object or name. + * + * @return boolean True if the listener has the given event, false otherwise. + * + * @since 1.0 + */ + public function hasEvent($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + return isset($this->events[$event]); + } + + /** + * Get the event object identified by the given name. + * + * @param string $name The event name. + * @param mixed $default The default value if the event was not registered. + * + * @return EventInterface|mixed The event of the default value. + * + * @since 1.0 + */ + public function getEvent($name, $default = null) + { + if (isset($this->events[$name])) + { + return $this->events[$name]; + } + + return $default; + } + + /** + * Remove an event from this dispatcher. + * The registered listeners will remain. + * + * @param EventInterface|string $event The event object or name. + * + * @return Dispatcher This method is chainable. + * + * @since 1.0 + */ + public function removeEvent($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->events[$event])) + { + unset($this->events[$event]); + } + + return $this; + } + + /** + * Get the registered events. + * + * @return EventInterface[] The registered event. + * + * @since 1.0 + */ + public function getEvents() + { + return $this->events; + } + + /** + * Clear all events. + * + * @return EventInterface[] The old events. + * + * @since 1.0 + */ + public function clearEvents() + { + $events = $this->events; + $this->events = array(); + + return $events; + } + + /** + * Count the number of registered event. + * + * @return integer The numer of registered events. + * + * @since 1.0 + */ + public function countEvents() + { + return count($this->events); + } + + /** + * Add a listener to this dispatcher, only if not already registered to these events. + * If no events are specified, it will be registered to all events matching it's methods name. + * In the case of a closure, you must specify at least one event name. + * + * @param object|Closure $listener The listener + * @param array $events An associative array of event names as keys + * and the corresponding listener priority as values. + * + * @return Dispatcher This method is chainable. + * + * @throws InvalidArgumentException + * + * @since 1.0 + */ + public function addListener($listener, array $events = array()) + { + if (!is_object($listener)) + { + throw new InvalidArgumentException('The given listener is not an object.'); + } + + // We deal with a closure. + if ($listener instanceof Closure) + { + if (empty($events)) + { + throw new InvalidArgumentException('No event name(s) and priority + specified for the Closure listener.'); + } + + foreach ($events as $name => $priority) + { + if (!isset($this->listeners[$name])) + { + $this->listeners[$name] = new ListenersPriorityQueue; + } + + $this->listeners[$name]->add($listener, $priority); + } + + return $this; + } + + // We deal with a "normal" object. + $methods = get_class_methods($listener); + + if (!empty($events)) + { + $methods = array_intersect($methods, array_keys($events)); + } + + // @deprecated + $regex = $this->listenerFilter ?: '.*'; + + foreach ($methods as $event) + { + // @deprecated - this outer `if` is deprecated. + if (preg_match("#$regex#", $event)) + { + // Retain this inner code after removal of the outer `if`. + if (!isset($this->listeners[$event])) + { + $this->listeners[$event] = new ListenersPriorityQueue; + } + + $priority = isset($events[$event]) ? $events[$event] : Priority::NORMAL; + + $this->listeners[$event]->add($listener, $priority); + } + } + + return $this; + } + + /** + * Get the priority of the given listener for the given event. + * + * @param object|Closure $listener The listener. + * @param EventInterface|string $event The event object or name. + * + * @return mixed The listener priority or null if the listener doesn't exist. + * + * @since 1.0 + */ + public function getListenerPriority($listener, $event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->listeners[$event])) + { + return $this->listeners[$event]->getPriority($listener); + } + + return null; + } + + /** + * Get the listeners registered to the given event. + * + * @param EventInterface|string $event The event object or name. + * + * @return object[] An array of registered listeners sorted according to their priorities. + * + * @since 1.0 + */ + public function getListeners($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->listeners[$event])) + { + return $this->listeners[$event]->getAll(); + } + + return array(); + } + + /** + * Tell if the given listener has been added. + * If an event is specified, it will tell if the listener is registered for that event. + * + * @param object|Closure $listener The listener. + * @param EventInterface|string $event The event object or name. + * + * @return boolean True if the listener is registered, false otherwise. + * + * @since 1.0 + */ + public function hasListener($listener, $event = null) + { + if ($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->listeners[$event])) + { + return $this->listeners[$event]->has($listener); + } + } + else + { + foreach ($this->listeners as $queue) + { + if ($queue->has($listener)) + { + return true; + } + } + } + + return false; + } + + /** + * Remove the given listener from this dispatcher. + * If no event is specified, it will be removed from all events it is listening to. + * + * @param object|Closure $listener The listener to remove. + * @param EventInterface|string $event The event object or name. + * + * @return Dispatcher This method is chainable. + * + * @since 1.0 + */ + public function removeListener($listener, $event = null) + { + if ($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->listeners[$event])) + { + $this->listeners[$event]->remove($listener); + } + } + + else + { + foreach ($this->listeners as $queue) + { + $queue->remove($listener); + } + } + + return $this; + } + + /** + * Clear the listeners in this dispatcher. + * If an event is specified, the listeners will be cleared only for that event. + * + * @param EventInterface|string $event The event object or name. + * + * @return Dispatcher This method is chainable. + * + * @since 1.0 + */ + public function clearListeners($event = null) + { + if ($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + if (isset($this->listeners[$event])) + { + unset($this->listeners[$event]); + } + } + + else + { + $this->listeners = array(); + } + + return $this; + } + + /** + * Count the number of registered listeners for the given event. + * + * @param EventInterface|string $event The event object or name. + * + * @return integer The number of registered listeners for the given event. + * + * @since 1.0 + */ + public function countListeners($event) + { + if ($event instanceof EventInterface) + { + $event = $event->getName(); + } + + return isset($this->listeners[$event]) ? count($this->listeners[$event]) : 0; + } + + /** + * Trigger an event. + * + * @param EventInterface|string $event The event object or name. + * + * @return EventInterface The event after being passed through all listeners. + * + * @since 1.0 + */ + public function triggerEvent($event) + { + if (!($event instanceof EventInterface)) + { + if (isset($this->events[$event])) + { + $event = $this->events[$event]; + } + + else + { + $event = new Event($event); + } + } + + if (isset($this->listeners[$event->getName()])) + { + foreach ($this->listeners[$event->getName()] as $listener) + { + if ($event->isStopped()) + { + return $event; + } + + if ($listener instanceof Closure) + { + call_user_func($listener, $event); + } + + else + { + call_user_func(array($listener, $event->getName()), $event); + } + } + } + + return $event; + } +} diff --git a/libraries/vendor/joomla/event/src/DispatcherAwareInterface.php b/libraries/vendor/joomla/event/src/DispatcherAwareInterface.php new file mode 100644 index 0000000000000..a3c0218f8a9d3 --- /dev/null +++ b/libraries/vendor/joomla/event/src/DispatcherAwareInterface.php @@ -0,0 +1,28 @@ +arguments[$name])) + { + $this->arguments[$name] = $value; + } + + return $this; + } + + /** + * Set the value of an event argument. + * If the argument already exists, it will be overridden. + * + * @param string $name The argument name. + * @param mixed $value The argument value. + * + * @return Event This method is chainable. + * + * @since 1.0 + */ + public function setArgument($name, $value) + { + $this->arguments[$name] = $value; + + return $this; + } + + /** + * Remove an event argument. + * + * @param string $name The argument name. + * + * @return mixed The old argument value or null if it is not existing. + * + * @since 1.0 + */ + public function removeArgument($name) + { + $return = null; + + if (isset($this->arguments[$name])) + { + $return = $this->arguments[$name]; + unset($this->arguments[$name]); + } + + return $return; + } + + /** + * Clear all event arguments. + * + * @return array The old arguments. + * + * @since 1.0 + */ + public function clearArguments() + { + $arguments = $this->arguments; + $this->arguments = array(); + + return $arguments; + } + + /** + * Stop the event propagation. + * + * @return void + * + * @since 1.0 + */ + public function stop() + { + $this->stopped = true; + } + + /** + * Set the value of an event argument. + * + * @param string $name The argument name. + * @param mixed $value The argument value. + * + * @return void + * + * @throws InvalidArgumentException If the argument name is null. + * + * @since 1.0 + */ + public function offsetSet($name, $value) + { + if (is_null($name)) + { + throw new InvalidArgumentException('The argument name cannot be null.'); + } + + $this->setArgument($name, $value); + } + + /** + * Remove an event argument. + * + * @param string $name The argument name. + * + * @return void + * + * @since 1.0 + */ + public function offsetUnset($name) + { + $this->removeArgument($name); + } +} diff --git a/libraries/vendor/joomla/event/src/EventImmutable.php b/libraries/vendor/joomla/event/src/EventImmutable.php new file mode 100644 index 0000000000000..eeca16df4a648 --- /dev/null +++ b/libraries/vendor/joomla/event/src/EventImmutable.php @@ -0,0 +1,103 @@ +constructed) + { + throw new BadMethodCallException( + sprintf('Cannot reconstruct the EventImmutable %s.', $this->name) + ); + } + + $this->constructed = true; + + parent::__construct($name, $arguments); + } + + /** + * Set the value of an event argument. + * + * @param string $name The argument name. + * @param mixed $value The argument value. + * + * @return void + * + * @throws BadMethodCallException + * + * @since 1.0 + */ + public function offsetSet($name, $value) + { + throw new BadMethodCallException( + sprintf( + 'Cannot set the argument %s of the immutable event %s.', + $name, + $this->name + ) + ); + } + + /** + * Remove an event argument. + * + * @param string $name The argument name. + * + * @return void + * + * @throws BadMethodCallException + * + * @since 1.0 + */ + public function offsetUnset($name) + { + throw new BadMethodCallException( + sprintf( + 'Cannot remove the argument %s of the immutable event %s.', + $name, + $this->name + ) + ); + } +} diff --git a/libraries/vendor/joomla/event/src/EventInterface.php b/libraries/vendor/joomla/event/src/EventInterface.php new file mode 100644 index 0000000000000..ace7ff6d60b85 --- /dev/null +++ b/libraries/vendor/joomla/event/src/EventInterface.php @@ -0,0 +1,36 @@ +queue = new SplPriorityQueue; + $this->storage = new SplObjectStorage; + } + + /** + * Add a listener with the given priority only if not already present. + * + * @param \Closure|object $listener The listener. + * @param integer $priority The listener priority. + * + * @return ListenersPriorityQueue This method is chainable. + * + * @since 1.0 + */ + public function add($listener, $priority) + { + if (!$this->storage->contains($listener)) + { + // Compute the internal priority as an array. + $priority = array($priority, $this->counter--); + + $this->storage->attach($listener, $priority); + $this->queue->insert($listener, $priority); + } + + return $this; + } + + /** + * Remove a listener from the queue. + * + * @param \Closure|object $listener The listener. + * + * @return ListenersPriorityQueue This method is chainable. + * + * @since 1.0 + */ + public function remove($listener) + { + if ($this->storage->contains($listener)) + { + $this->storage->detach($listener); + $this->storage->rewind(); + + $this->queue = new SplPriorityQueue; + + foreach ($this->storage as $listener) + { + $priority = $this->storage->getInfo(); + $this->queue->insert($listener, $priority); + } + } + + return $this; + } + + /** + * Tell if the listener exists in the queue. + * + * @param \Closure|object $listener The listener. + * + * @return boolean True if it exists, false otherwise. + * + * @since 1.0 + */ + public function has($listener) + { + return $this->storage->contains($listener); + } + + /** + * Get the priority of the given listener. + * + * @param \Closure|object $listener The listener. + * @param mixed $default The default value to return if the listener doesn't exist. + * + * @return mixed The listener priority if it exists, null otherwise. + * + * @since 1.0 + */ + public function getPriority($listener, $default = null) + { + if ($this->storage->contains($listener)) + { + return $this->storage[$listener][0]; + } + + return $default; + } + + /** + * Get all listeners contained in this queue, sorted according to their priority. + * + * @return object[] An array of listeners. + * + * @since 1.0 + */ + public function getAll() + { + $listeners = array(); + + // Get a clone of the queue. + $queue = $this->getIterator(); + + foreach ($queue as $listener) + { + $listeners[] = $listener; + } + + return $listeners; + } + + /** + * Get the inner queue with its cursor on top of the heap. + * + * @return SplPriorityQueue The inner queue. + * + * @since 1.0 + */ + public function getIterator() + { + // SplPriorityQueue queue is a heap. + $queue = clone $this->queue; + + if (!$queue->isEmpty()) + { + $queue->top(); + } + + return $queue; + } + + /** + * Count the number of listeners in the queue. + * + * @return integer The number of listeners in the queue. + * + * @since 1.0 + */ + public function count() + { + return count($this->queue); + } +} diff --git a/libraries/vendor/joomla/event/src/Priority.php b/libraries/vendor/joomla/event/src/Priority.php new file mode 100644 index 0000000000000..66ba932d2d4c2 --- /dev/null +++ b/libraries/vendor/joomla/event/src/Priority.php @@ -0,0 +1,26 @@ + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/filter/src/InputFilter.php b/libraries/vendor/joomla/filter/src/InputFilter.php new file mode 100644 index 0000000000000..7f664c0b19305 --- /dev/null +++ b/libraries/vendor/joomla/filter/src/InputFilter.php @@ -0,0 +1,755 @@ + + * Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie. + * + * @since 1.0 + */ +class InputFilter +{ + /** + * A container for JFilterInput instances. + * + * @var array + * @since 1.0 + */ + protected static $instances = array(); + + /** + * The array of permitted tags (white list). + * + * @var array + * @since 1.0 + */ + public $tagsArray; + + /** + * The array of permitted tag attributes (white list). + * + * @var array + * @since 1.0 + */ + public $attrArray; + + /** + * The method for sanitising tags: WhiteList method = 0 (default), BlackList method = 1 + * + * @var integer + * @since 1.0 + */ + public $tagsMethod; + + /** + * The method for sanitising attributes: WhiteList method = 0 (default), BlackList method = 1 + * + * @var integer + * @since 1.0 + */ + public $attrMethod; + + /** + * A flag for XSS checks. Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * + * @var integer + * @since 1.0 + */ + public $xssAuto; + + /** + * The list of the default blacklisted tags. + * + * @var array + * @since 1.0 + */ + public $tagBlacklist = array( + 'applet', + 'body', + 'bgsound', + 'base', + 'basefont', + 'embed', + 'frame', + 'frameset', + 'head', + 'html', + 'id', + 'iframe', + 'ilayer', + 'layer', + 'link', + 'meta', + 'name', + 'object', + 'script', + 'style', + 'title', + 'xml' + ); + + /** + * The list of the default blacklisted tag attributes. All event handlers implicit. + * + * @var array + * @since 1.0 + */ + public $attrBlacklist = array( + 'action', + 'background', + 'codebase', + 'dynsrc', + 'lowsrc' + ); + + /** + * Constructor for inputFilter class. Only first parameter is required. + * + * @param array $tagsArray List of user-defined tags + * @param array $attrArray List of user-defined attributes + * @param integer $tagsMethod WhiteList method = 0, BlackList method = 1 + * @param integer $attrMethod WhiteList method = 0, BlackList method = 1 + * @param integer $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * + * @since 1.0 + */ + public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) + { + // Make sure user defined arrays are in lowercase + $tagsArray = array_map('strtolower', (array) $tagsArray); + $attrArray = array_map('strtolower', (array) $attrArray); + + // Assign member variables + $this->tagsArray = $tagsArray; + $this->attrArray = $attrArray; + $this->tagsMethod = $tagsMethod; + $this->attrMethod = $attrMethod; + $this->xssAuto = $xssAuto; + } + + /** + * Method to be called by another php script. Processes for XSS and + * specified bad code. + * + * @param mixed $source Input string/array-of-string to be 'cleaned' + * @param string $type The return type for the variable: + * INT: An integer, + * UINT: An unsigned integer, + * FLOAT: A floating point number, + * BOOLEAN: A boolean value, + * WORD: A string containing A-Z or underscores only (not case sensitive), + * ALNUM: A string containing A-Z or 0-9 only (not case sensitive), + * CMD: A string containing A-Z, 0-9, underscores, periods or hyphens (not case sensitive), + * BASE64: A string containing A-Z, 0-9, forward slashes, plus or equals (not case sensitive), + * STRING: A fully decoded and sanitised string (default), + * HTML: A sanitised string, + * ARRAY: An array, + * PATH: A sanitised file path, + * USERNAME: Do not use (use an application specific filter), + * RAW: The raw string is returned with no filtering, + * unknown: An unknown filter will act like STRING. If the input is an array it will return an + * array of fully decoded and sanitised strings. + * + * @return mixed 'Cleaned' version of input parameter + * + * @since 1.0 + */ + public function clean($source, $type = 'string') + { + // Handle the type constraint + switch (strtoupper($type)) + { + case 'INT': + case 'INTEGER': + // Only use the first integer value + preg_match('/-?[0-9]+/', (string) $source, $matches); + $result = isset($matches[0]) ? (int) $matches[0] : null; + break; + + case 'UINT': + // Only use the first integer value + preg_match('/-?[0-9]+/', (string) $source, $matches); + $result = isset($matches[0]) ? abs((int) $matches[0]) : null; + break; + + case 'FLOAT': + case 'DOUBLE': + // Only use the first floating point value + preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches); + $result = isset($matches[0]) ? (float) $matches[0] : null; + break; + + case 'BOOL': + case 'BOOLEAN': + $result = (bool) $source; + break; + + case 'WORD': + $result = (string) preg_replace('/[^A-Z_]/i', '', $source); + break; + + case 'ALNUM': + $result = (string) preg_replace('/[^A-Z0-9]/i', '', $source); + break; + + case 'CMD': + $result = (string) preg_replace('/[^A-Z0-9_\.-]/i', '', $source); + $result = ltrim($result, '.'); + break; + + case 'BASE64': + $result = (string) preg_replace('/[^A-Z0-9\/+=]/i', '', $source); + break; + + case 'STRING': + $result = (string) $this->remove($this->decode((string) $source)); + break; + + case 'HTML': + $result = (string) $this->remove((string) $source); + break; + + case 'ARRAY': + $result = (array) $source; + break; + + case 'PATH': + $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/'; + preg_match($pattern, (string) $source, $matches); + $result = isset($matches[0]) ? (string) $matches[0] : null; + break; + + case 'USERNAME': + $result = (string) preg_replace('/[\x00-\x1F\x7F<>"\'%&]/', '', $source); + break; + + case 'RAW': + $result = $source; + break; + + default: + // Are we dealing with an array? + if (is_array($source)) + { + foreach ($source as $key => $value) + { + // Filter element for XSS and other 'bad' code etc. + if (is_string($value)) + { + $source[$key] = $this->remove($this->decode($value)); + } + } + + $result = $source; + } + else + { + // Or a string? + if (is_string($source) && !empty($source)) + { + // Filter source for XSS and other 'bad' code etc. + $result = $this->remove($this->decode($source)); + } + else + { + // Not an array or string.. return the passed parameter + $result = $source; + } + } + + break; + } + + return $result; + } + + /** + * Function to determine if contents of an attribute are safe + * + * @param array $attrSubSet A 2 element array for attribute's name, value + * + * @return boolean True if bad code is detected + * + * @since 1.0 + */ + public static function checkAttribute($attrSubSet) + { + $attrSubSet[0] = strtolower($attrSubSet[0]); + $attrSubSet[1] = strtolower($attrSubSet[1]); + + return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) || + (strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) || + (strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false)); + } + + /** + * Internal method to iteratively remove all unwanted tags and attributes + * + * @param string $source Input string to be 'cleaned' + * + * @return string 'Cleaned' version of input parameter + * + * @since 1.0 + */ + protected function remove($source) + { + $loopCounter = 0; + + // Iteration provides nested tag protection + while ($source != $this->cleanTags($source)) + { + $source = $this->cleanTags($source); + $loopCounter++; + } + + return $source; + } + + /** + * Internal method to strip a string of certain tags + * + * @param string $source Input string to be 'cleaned' + * + * @return string 'Cleaned' version of input parameter + * + * @since 1.0 + */ + protected function cleanTags($source) + { + // First, pre-process this for illegal characters inside attribute values + $source = $this->escapeAttributeValues($source); + + // In the beginning we don't really have a tag, so everything is postTag + $preTag = null; + $postTag = $source; + $currentSpace = false; + + // Setting to null to deal with undefined variables + $attr = ''; + + // Is there a tag? If so it will certainly start with a '<'. + $tagOpen_start = strpos($source, '<'); + + while ($tagOpen_start !== false) + { + // Get some information about the tag we are processing + $preTag .= substr($postTag, 0, $tagOpen_start); + $postTag = substr($postTag, $tagOpen_start); + $fromTagOpen = substr($postTag, 1); + $tagOpen_end = strpos($fromTagOpen, '>'); + + // Check for mal-formed tag where we have a second '<' before the first '>' + $nextOpenTag = (strlen($postTag) > $tagOpen_start) ? strpos($postTag, '<', $tagOpen_start + 1) : false; + + if (($nextOpenTag !== false) && ($nextOpenTag < $tagOpen_end)) + { + // At this point we have a mal-formed tag -- remove the offending open + $postTag = substr($postTag, 0, $tagOpen_start) . substr($postTag, $tagOpen_start + 1); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Let's catch any non-terminated tags and skip over them + if ($tagOpen_end === false) + { + $postTag = substr($postTag, $tagOpen_start + 1); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Do we have a nested tag? + $tagOpen_nested = strpos($fromTagOpen, '<'); + + if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) + { + $preTag .= substr($postTag, 0, ($tagOpen_nested + 1)); + $postTag = substr($postTag, ($tagOpen_nested + 1)); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Let's get some information about our tag and setup attribute pairs + $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start + 1); + $currentTag = substr($fromTagOpen, 0, $tagOpen_end); + $tagLength = strlen($currentTag); + $tagLeft = $currentTag; + $attrSet = array(); + $currentSpace = strpos($tagLeft, ' '); + + // Are we an open tag or a close tag? + if (substr($currentTag, 0, 1) == '/') + { + // Close Tag + $isCloseTag = true; + list ($tagName) = explode(' ', $currentTag); + $tagName = substr($tagName, 1); + } + else + { + // Open Tag + $isCloseTag = false; + list ($tagName) = explode(' ', $currentTag); + } + + /* + * Exclude all "non-regular" tagnames + * OR no tagname + * OR remove if xssauto is on and tag is blacklisted + */ + if ((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) + { + $postTag = substr($postTag, ($tagLength + 2)); + $tagOpen_start = strpos($postTag, '<'); + + // Strip tag + continue; + } + + /* + * Time to grab any attributes from the tag... need this section in + * case attributes have spaces in the values. + */ + while ($currentSpace !== false) + { + $attr = ''; + $fromSpace = substr($tagLeft, ($currentSpace + 1)); + $nextEqual = strpos($fromSpace, '='); + $nextSpace = strpos($fromSpace, ' '); + $openQuotes = strpos($fromSpace, '"'); + $closeQuotes = strpos(substr($fromSpace, ($openQuotes + 1)), '"') + $openQuotes + 1; + + $startAtt = ''; + $startAttPosition = 0; + + // Find position of equal and open quotes ignoring + if (preg_match('#\s*=\s*\"#', $fromSpace, $matches, PREG_OFFSET_CAPTURE)) + { + $startAtt = $matches[0][0]; + $startAttPosition = $matches[0][1]; + $closeQuotes = strpos(substr($fromSpace, ($startAttPosition + strlen($startAtt))), '"') + $startAttPosition + strlen($startAtt); + $nextEqual = $startAttPosition + strpos($startAtt, '='); + $openQuotes = $startAttPosition + strpos($startAtt, '"'); + $nextSpace = strpos(substr($fromSpace, $closeQuotes), ' ') + $closeQuotes; + } + + // Do we have an attribute to process? [check for equal sign] + if ($fromSpace != '/' && (($nextEqual && $nextSpace && $nextSpace < $nextEqual) || !$nextEqual)) + { + if (!$nextEqual) + { + $attribEnd = strpos($fromSpace, '/') - 1; + } + else + { + $attribEnd = $nextSpace - 1; + } + + // If there is an ending, use this, if not, do not worry. + if ($attribEnd > 0) + { + $fromSpace = substr($fromSpace, $attribEnd + 1); + } + } + + if (strpos($fromSpace, '=') !== false) + { + // If the attribute value is wrapped in quotes we need to grab the substring from + // the closing quote, otherwise grab until the next space. + if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes + 1)), '"') !== false)) + { + $attr = substr($fromSpace, 0, ($closeQuotes + 1)); + } + else + { + $attr = substr($fromSpace, 0, $nextSpace); + } + } + else + // No more equal signs so add any extra text in the tag into the attribute array [eg. checked] + { + if ($fromSpace != '/') + { + $attr = substr($fromSpace, 0, $nextSpace); + } + } + + // Last Attribute Pair + if (!$attr && $fromSpace != '/') + { + $attr = $fromSpace; + } + + // Add attribute pair to the attribute array + $attrSet[] = $attr; + + // Move search point and continue iteration + $tagLeft = substr($fromSpace, strlen($attr)); + $currentSpace = strpos($tagLeft, ' '); + } + + // Is our tag in the user input array? + $tagFound = in_array(strtolower($tagName), $this->tagsArray); + + // If the tag is allowed let's append it to the output string. + if ((!$tagFound && $this->tagsMethod) || ($tagFound && !$this->tagsMethod)) + { + // Reconstruct tag with allowed attributes + if (!$isCloseTag) + { + // Open or single tag + $attrSet = $this->cleanAttributes($attrSet); + $preTag .= '<' . $tagName; + + for ($i = 0, $count = count($attrSet); $i < $count; $i++) + { + $preTag .= ' ' . $attrSet[$i]; + } + + // Reformat single tags to XHTML + if (strpos($fromTagOpen, ''; + } + else + { + $preTag .= ' />'; + } + } + else + // Closing tag + { + $preTag .= ''; + } + } + + // Find next tag's start and continue iteration + $postTag = substr($postTag, ($tagLength + 2)); + $tagOpen_start = strpos($postTag, '<'); + } + + // Append any code after the end of tags and return + if ($postTag != '<') + { + $preTag .= $postTag; + } + + return $preTag; + } + + /** + * Internal method to strip a tag of certain attributes + * + * @param array $attrSet Array of attribute pairs to filter + * + * @return array Filtered array of attribute pairs + * + * @since 1.0 + */ + protected function cleanAttributes($attrSet) + { + $newSet = array(); + + $count = count($attrSet); + + // Iterate through attribute pairs + for ($i = 0; $i < $count; $i++) + { + // Skip blank spaces + if (!$attrSet[$i]) + { + continue; + } + + // Split into name/value pairs + $attrSubSet = explode('=', trim($attrSet[$i]), 2); + + // Take the last attribute in case there is an attribute with no value + $attrSubSet_0 = explode(' ', trim($attrSubSet[0])); + $attrSubSet[0] = array_pop($attrSubSet_0); + + // Remove all "non-regular" attribute names + // AND blacklisted attributes + if ((!preg_match('/[a-z]*$/i', $attrSubSet[0])) + || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) + || (substr($attrSubSet[0], 0, 2) == 'on')))) + { + continue; + } + + // XSS attribute value filtering + if (isset($attrSubSet[1])) + { + // Trim leading and trailing spaces + $attrSubSet[1] = trim($attrSubSet[1]); + + // Strips unicode, hex, etc + $attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]); + + // Strip normal newline within attr value + $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]); + + // Strip double quotes + $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); + + // Convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr values) + if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) + { + $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); + } + + // Strip slashes + $attrSubSet[1] = stripslashes($attrSubSet[1]); + } + else + { + continue; + } + + // Autostrip script tags + if (self::checkAttribute($attrSubSet)) + { + continue; + } + + // Is our attribute in the user input array? + $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray); + + // If the tag is allowed lets keep it + if ((!$attrFound && $this->attrMethod) || ($attrFound && !$this->attrMethod)) + { + // Does the attribute have a value? + if (empty($attrSubSet[1]) === false) + { + $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] . '"'; + } + elseif ($attrSubSet[1] === "0") + { + // Special Case + // Is the value 0? + $newSet[] = $attrSubSet[0] . '="0"'; + } + else + { + // Leave empty attributes alone + $newSet[] = $attrSubSet[0] . '=""'; + } + } + } + + return $newSet; + } + + /** + * Try to convert to plaintext + * + * @param string $source The source string. + * + * @return string Plaintext string + * + * @since 1.0 + * @deprecated This method will be removed once support for PHP 5.3 is discontinued. + */ + protected function decode($source) + { + return html_entity_decode($source, ENT_QUOTES, 'UTF-8'); + } + + /** + * Escape < > and " inside attribute values + * + * @param string $source The source string. + * + * @return string Filtered string + * + * @since 1.0 + */ + protected function escapeAttributeValues($source) + { + $alreadyFiltered = ''; + $remainder = $source; + $badChars = array('<', '"', '>'); + $escapedChars = array('<', '"', '>'); + + // Process each portion based on presence of =" and ", "/>, or "> + // See if there are any more attributes to process + while (preg_match('#<[^>]*?=\s*?(\"|\')#s', $remainder, $matches, PREG_OFFSET_CAPTURE)) + { + // Get the portion before the attribute value + $quotePosition = $matches[0][1]; + $nextBefore = $quotePosition + strlen($matches[0][0]); + + // Figure out if we have a single or double quote and look for the matching closing quote + // Closing quote should be "/>, ">, ", or " at the end of the string + $quote = substr($matches[0][0], -1); + $pregMatch = ($quote == '"') ? '#(\"\s*/\s*>|\"\s*>|\"\s+|\"$)#' : "#(\'\s*/\s*>|\'\s*>|\'\s+|\'$)#"; + + // Get the portion after attribute value + if (preg_match($pregMatch, substr($remainder, $nextBefore), $matches, PREG_OFFSET_CAPTURE)) + { + // We have a closing quote + $nextAfter = $nextBefore + $matches[0][1]; + } + else + { + // No closing quote + $nextAfter = strlen($remainder); + } + + // Get the actual attribute value + $attributeValue = substr($remainder, $nextBefore, $nextAfter - $nextBefore); + + // Escape bad chars + $attributeValue = str_replace($badChars, $escapedChars, $attributeValue); + $attributeValue = $this->stripCssExpressions($attributeValue); + $alreadyFiltered .= substr($remainder, 0, $nextBefore) . $attributeValue . $quote; + $remainder = substr($remainder, $nextAfter + 1); + } + + // At this point, we just have to return the $alreadyFiltered and the $remainder + return $alreadyFiltered . $remainder; + } + + /** + * Remove CSS Expressions in the form of :expression(...) + * + * @param string $source The source string. + * + * @return string Filtered string + * + * @since 1.0 + */ + protected function stripCssExpressions($source) + { + // Strip any comments out (in the form of /*...*/) + $test = preg_replace('#\/\*.*\*\/#U', '', $source); + + // Test for :expression + if (!stripos($test, ':expression')) + { + // Not found, so we are done + $return = $source; + } + else + { + // At this point, we have stripped out the comments and have found :expression + // Test stripped string for :expression followed by a '(' + if (preg_match_all('#:expression\s*\(#', $test, $matches)) + { + // If found, remove :expression + $test = str_ireplace(':expression', '', $test); + $return = $test; + } + } + + return $return; + } +} diff --git a/libraries/vendor/joomla/filter/src/OutputFilter.php b/libraries/vendor/joomla/filter/src/OutputFilter.php new file mode 100644 index 0000000000000..0b079a9874857 --- /dev/null +++ b/libraries/vendor/joomla/filter/src/OutputFilter.php @@ -0,0 +1,224 @@ + $v) + { + if (is_array($v) || is_object($v) || $v == null || substr($k, 1, 1) == '_') + { + continue; + } + + if (is_string($exclude_keys) && $k == $exclude_keys) + { + continue; + } + elseif (is_array($exclude_keys) && in_array($k, $exclude_keys)) + { + continue; + } + + $mixed->$k = htmlspecialchars($v, $quote_style, 'UTF-8'); + } + } + } + + /** + * This method processes a string and replaces all instances of & with & in links only. + * + * @param string $input String to process + * + * @return string Processed string + * + * @since 1.0 + */ + public static function linkXHTMLSafe($input) + { + $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"'; + + return preg_replace_callback( + "#$regex#i", + function($m) + { + $rx = '&(?!amp;)'; + + return preg_replace('#' . $rx . '#', '&', $m[0]); + }, + $input + ); + } + + /** + * This method processes a string and replaces all accented UTF-8 characters by unaccented + * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercase. + * + * @param string $string String to process + * + * @return string Processed string + * + * @since 1.0 + */ + public static function stringURLSafe($string) + { + // Remove any '-' from the string since they will be used as concatenaters + $str = str_replace('-', ' ', $string); + + $lang = Language::getInstance(); + $str = $lang->transliterate($str); + + // Trim white spaces at beginning and end of alias and make lowercase + $str = trim(String::strtolower($str)); + + // Remove any duplicate whitespace, and ensure all characters are alphanumeric + $str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str); + + // Trim dashes at beginning and end of alias + $str = trim($str, '-'); + + return $str; + } + + /** + * This method implements unicode slugs instead of transliteration. + * + * @param string $string String to process + * + * @return string Processed string + * + * @since 1.0 + */ + public static function stringURLUnicodeSlug($string) + { + // Replace double byte whitespaces by single byte (East Asian languages) + $str = preg_replace('/\xE3\x80\x80/', ' ', $string); + + // Remove any '-' from the string as they will be used as concatenator. + // Would be great to let the spaces in but only Firefox is friendly with this + + $str = str_replace('-', ' ', $str); + + // Replace forbidden characters by whitespaces + $str = preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#', "\x20", $str); + + // Delete all '?' + $str = str_replace('?', '', $str); + + // Trim white spaces at beginning and end of alias and make lowercase + $str = trim(String::strtolower($str)); + + // Remove any duplicate whitespace and replace whitespaces by hyphens + $str = preg_replace('#\x20+#', '-', $str); + + return $str; + } + + /** + * Replaces & with & for XHTML compliance + * + * @param string $text Text to process + * + * @return string Processed string. + * + * @since 1.0 + * + * @todo There must be a better way??? + */ + public static function ampReplace($text) + { + $text = str_replace('&&', '*--*', $text); + $text = str_replace('&#', '*-*', $text); + $text = str_replace('&', '&', $text); + $text = preg_replace('|&(?![\w]+;)|', '&', $text); + $text = str_replace('*-*', '&#', $text); + $text = str_replace('*--*', '&&', $text); + + return $text; + } + + /** + * Cleans text of all formatting and scripting code + * + * @param string &$text Text to clean + * + * @return string Cleaned text. + * + * @since 1.0 + */ + public static function cleanText(&$text) + { + $text = preg_replace("']*>.*?'si", '', $text); + $text = preg_replace('/]*>([^<]+)<\/a>/is', '\2 (\1)', $text); + $text = preg_replace('//', '', $text); + $text = preg_replace('/{.+?}/', '', $text); + $text = preg_replace('/ /', ' ', $text); + $text = preg_replace('/&/', ' ', $text); + $text = preg_replace('/"/', ' ', $text); + $text = strip_tags($text); + $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8'); + + return $text; + } + + /** + * Strip img-tags from string + * + * @param string $string Sting to be cleaned. + * + * @return string Cleaned string + * + * @since 1.0 + */ + public static function stripImages($string) + { + return preg_replace('#(<[/]?img.*>)#U', '', $string); + } + + /** + * Strip iframe-tags from string + * + * @param string $string Sting to be cleaned. + * + * @return string Cleaned string + * + * @since 1.0 + */ + public static function stripIframes($string) + { + return preg_replace('#(<[/]?iframe.*>)#U', '', $string); + } +} diff --git a/libraries/vendor/joomla/input/LICENSE b/libraries/vendor/joomla/input/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/input/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/input/src/Cli.php b/libraries/vendor/joomla/input/src/Cli.php new file mode 100644 index 0000000000000..9a6a8c166a355 --- /dev/null +++ b/libraries/vendor/joomla/input/src/Cli.php @@ -0,0 +1,218 @@ +filter = $options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + + // Get the command line options + $this->parseArguments(); + + // Set the options for the class. + $this->options = $options; + } + + /** + * Method to serialize the input. + * + * @return string The serialized input. + * + * @since 1.0 + */ + public function serialize() + { + // Load all of the inputs. + $this->loadAllInputs(); + + // Remove $_ENV and $_SERVER from the inputs. + $inputs = $this->inputs; + unset($inputs['env']); + unset($inputs['server']); + + // Serialize the executable, args, options, data, and inputs. + return serialize(array($this->executable, $this->args, $this->options, $this->data, $inputs)); + } + + /** + * Gets a value from the input data. + * + * @param string $name Name of the value to get. + * @param mixed $default Default value to return if variable does not exist. + * @param string $filter Filter to apply to the value. + * + * @return mixed The filtered input value. + * + * @since 1.0 + */ + public function get($name, $default = null, $filter = 'string') + { + return parent::get($name, $default, $filter); + } + + /** + * Method to unserialize the input. + * + * @param string $input The serialized input. + * + * @return Input The input object. + * + * @since 1.0 + */ + public function unserialize($input) + { + // Unserialize the executable, args, options, data, and inputs. + list($this->executable, $this->args, $this->options, $this->data, $this->inputs) = unserialize($input); + + // Load the filter. + if (isset($this->options['filter'])) + { + $this->filter = $this->options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + } + + /** + * Initialise the options and arguments + * + * Not supported: -abc c-value + * + * @return void + * + * @since 1.0 + */ + protected function parseArguments() + { + $argv = $_SERVER['argv']; + + $this->executable = array_shift($argv); + + $out = array(); + + for ($i = 0, $j = count($argv); $i < $j; $i++) + { + $arg = $argv[$i]; + + // --foo --bar=baz + if (substr($arg, 0, 2) === '--') + { + $eqPos = strpos($arg, '='); + + // --foo + if ($eqPos === false) + { + $key = substr($arg, 2); + + // --foo value + if ($i + 1 < $j && $argv[$i + 1][0] !== '-') + { + $value = $argv[$i + 1]; + $i++; + } + else + { + $value = isset($out[$key]) ? $out[$key] : true; + } + $out[$key] = $value; + } + + // --bar=baz + else + { + $key = substr($arg, 2, $eqPos - 2); + $value = substr($arg, $eqPos + 1); + $out[$key] = $value; + } + } + + // -k=value -abc + else if (substr($arg, 0, 1) === '-') + { + // -k=value + if (substr($arg, 2, 1) === '=') + { + $key = substr($arg, 1, 1); + $value = substr($arg, 3); + $out[$key] = $value; + } + // -abc + else + { + $chars = str_split(substr($arg, 1)); + + foreach ($chars as $char) + { + $key = $char; + $value = isset($out[$key]) ? $out[$key] : true; + $out[$key] = $value; + } + + // -a a-value + if ((count($chars) === 1) && ($i + 1 < $j) && ($argv[$i + 1][0] !== '-')) + { + $out[$key] = $argv[$i + 1]; + $i++; + } + } + } + + // plain-arg + else + { + $this->args[] = $arg; + } + } + + $this->data = $out; + } +} diff --git a/libraries/vendor/joomla/input/src/Cookie.php b/libraries/vendor/joomla/input/src/Cookie.php new file mode 100644 index 0000000000000..3e6f594bb45e9 --- /dev/null +++ b/libraries/vendor/joomla/input/src/Cookie.php @@ -0,0 +1,90 @@ +filter = $options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + + // Set the data source. + $this->data = & $_COOKIE; + + // Set the options for the class. + $this->options = $options; + } + + /** + * Sets a value + * + * @param string $name Name of the value to set. + * @param mixed $value Value to assign to the input. + * @param integer $expire The time the cookie expires. This is a Unix timestamp so is in number + * of seconds since the epoch. In other words, you'll most likely set this + * with the time() function plus the number of seconds before you want it + * to expire. Or you might use mktime(). time()+60*60*24*30 will set the + * cookie to expire in 30 days. If set to 0, or omitted, the cookie will + * expire at the end of the session (when the browser closes). + * @param string $path The path on the server in which the cookie will be available on. If set + * to '/', the cookie will be available within the entire domain. If set to + * '/foo/', the cookie will only be available within the /foo/ directory and + * all sub-directories such as /foo/bar/ of domain. The default value is the + * current directory that the cookie is being set in. + * @param string $domain The domain that the cookie is available to. To make the cookie available + * on all subdomains of example.com (including example.com itself) then you'd + * set it to '.example.com'. Although some browsers will accept cookies without + * the initial ., RFC 2109 requires it to be included. Setting the domain to + * 'www.example.com' or '.www.example.com' will make the cookie only available + * in the www subdomain. + * @param boolean $secure Indicates that the cookie should only be transmitted over a secure HTTPS + * connection from the client. When set to TRUE, the cookie will only be set + * if a secure connection exists. On the server-side, it's on the programmer + * to send this kind of cookie only on secure connection (e.g. with respect + * to $_SERVER["HTTPS"]). + * @param boolean $httpOnly When TRUE the cookie will be made accessible only through the HTTP protocol. + * This means that the cookie won't be accessible by scripting languages, such + * as JavaScript. This setting can effectively help to reduce identity theft + * through XSS attacks (although it is not supported by all browsers). + * + * @return void + * + * @link http://www.ietf.org/rfc/rfc2109.txt + * @see setcookie() + * @since 1.0 + */ + public function set($name, $value, $expire = 0, $path = '', $domain = '', $secure = false, $httpOnly = false) + { + setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); + + $this->data[$name] = $value; + } +} diff --git a/libraries/vendor/joomla/input/src/Files.php b/libraries/vendor/joomla/input/src/Files.php new file mode 100644 index 0000000000000..e0616d44c01ad --- /dev/null +++ b/libraries/vendor/joomla/input/src/Files.php @@ -0,0 +1,127 @@ +filter = $options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + + // Set the data source. + $this->data = & $_FILES; + + // Set the options for the class. + $this->options = $options; + } + + /** + * Gets a value from the input data. + * + * @param string $name The name of the input property (usually the name of the files INPUT tag) to get. + * @param mixed $default The default value to return if the named property does not exist. + * @param string $filter The filter to apply to the value. + * + * @return mixed The filtered input value. + * + * @see \Joomla\Filter\InputFilter::clean() + * @since 1.0 + */ + public function get($name, $default = null, $filter = 'cmd') + { + if (isset($this->data[$name])) + { + $results = $this->decodeData( + array( + $this->data[$name]['name'], + $this->data[$name]['type'], + $this->data[$name]['tmp_name'], + $this->data[$name]['error'], + $this->data[$name]['size'] + ) + ); + + return $results; + } + + return $default; + } + + /** + * Method to decode a data array. + * + * @param array $data The data array to decode. + * + * @return array + * + * @since 1.0 + */ + protected function decodeData(array $data) + { + $result = array(); + + if (is_array($data[0])) + { + foreach ($data[0] as $k => $v) + { + $result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k])); + } + + return $result; + } + + return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]); + } + + /** + * Sets a value. + * + * @param string $name The name of the input property to set. + * @param mixed $value The value to assign to the input property. + * + * @return void + * + * @since 1.0 + */ + public function set($name, $value) + { + // Restricts the usage of parent's set method. + } +} diff --git a/libraries/vendor/joomla/input/src/Input.php b/libraries/vendor/joomla/input/src/Input.php new file mode 100644 index 0000000000000..43ed72d7c6726 --- /dev/null +++ b/libraries/vendor/joomla/input/src/Input.php @@ -0,0 +1,406 @@ +filter = $options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + + if (is_null($source)) + { + $this->data = &$_REQUEST; + } + else + { + $this->data = $source; + } + + // Set the options for the class. + $this->options = $options; + } + + /** + * Magic method to get an input object + * + * @param mixed $name Name of the input object to retrieve. + * + * @return Input The request input object + * + * @since 1.0 + */ + public function __get($name) + { + if (isset($this->inputs[$name])) + { + return $this->inputs[$name]; + } + + $className = '\\Joomla\\Input\\' . ucfirst($name); + + if (class_exists($className)) + { + $this->inputs[$name] = new $className(null, $this->options); + + return $this->inputs[$name]; + } + + $superGlobal = '_' . strtoupper($name); + + if (isset($GLOBALS[$superGlobal])) + { + $this->inputs[$name] = new Input($GLOBALS[$superGlobal], $this->options); + + return $this->inputs[$name]; + } + + // TODO throw an exception + } + + /** + * Get the number of variables. + * + * @return integer The number of variables in the input. + * + * @since 1.0 + * @see Countable::count() + */ + public function count() + { + return count($this->data); + } + + /** + * Gets a value from the input data. + * + * @param string $name Name of the value to get. + * @param mixed $default Default value to return if variable does not exist. + * @param string $filter Filter to apply to the value. + * + * @return mixed The filtered input value. + * + * @see \Joomla\Filter\InputFilter::clean() + * @since 1.0 + */ + public function get($name, $default = null, $filter = 'cmd') + { + if (isset($this->data[$name])) + { + return $this->filter->clean($this->data[$name], $filter); + } + + return $default; + } + + /** + * Gets an array of values from the request. + * + * @param array $vars Associative array of keys and filter types to apply. + * If empty and datasource is null, all the input data will be returned + * but filtered using the default case in JFilterInput::clean. + * @param mixed $datasource Array to retrieve data from, or null + * + * @return mixed The filtered input data. + * + * @since 1.0 + */ + public function getArray(array $vars = array(), $datasource = null) + { + if (empty($vars) && is_null($datasource)) + { + $vars = $this->data; + } + + $results = array(); + + foreach ($vars as $k => $v) + { + if (is_array($v)) + { + if (is_null($datasource)) + { + $results[$k] = $this->getArray($v, $this->get($k, null, 'array')); + } + else + { + $results[$k] = $this->getArray($v, $datasource[$k]); + } + } + else + { + if (is_null($datasource)) + { + $results[$k] = $this->get($k, null, $v); + } + elseif (isset($datasource[$k])) + { + $results[$k] = $this->filter->clean($datasource[$k], $v); + } + else + { + $results[$k] = $this->filter->clean(null, $v); + } + } + } + + return $results; + } + + /** + * Sets a value + * + * @param string $name Name of the value to set. + * @param mixed $value Value to assign to the input. + * + * @return void + * + * @since 1.0 + */ + public function set($name, $value) + { + $this->data[$name] = $value; + } + + /** + * Define a value. The value will only be set if there's no value for the name or if it is null. + * + * @param string $name Name of the value to define. + * @param mixed $value Value to assign to the input. + * + * @return void + * + * @since 1.0 + */ + public function def($name, $value) + { + if (isset($this->data[$name])) + { + return; + } + + $this->data[$name] = $value; + } + + /** + * Check if a value name exists. + * + * @param string $path Value name + * + * @return boolean + * + * @since 1.2.0 + */ + public function exists($name) + { + return isset($this->data[$name]); + } + + /** + * Magic method to get filtered input data. + * + * @param string $name Name of the filter type prefixed with 'get'. + * @param array $arguments [0] The name of the variable [1] The default value. + * + * @return mixed The filtered input value. + * + * @since 1.0 + */ + public function __call($name, $arguments) + { + if (substr($name, 0, 3) == 'get') + { + $filter = substr($name, 3); + + $default = null; + + if (isset($arguments[1])) + { + $default = $arguments[1]; + } + + return $this->get($arguments[0], $default, $filter); + } + } + + /** + * Gets the request method. + * + * @return string The request method. + * + * @since 1.0 + */ + public function getMethod() + { + $method = strtoupper($_SERVER['REQUEST_METHOD']); + + return $method; + } + + /** + * Method to serialize the input. + * + * @return string The serialized input. + * + * @since 1.0 + */ + public function serialize() + { + // Load all of the inputs. + $this->loadAllInputs(); + + // Remove $_ENV and $_SERVER from the inputs. + $inputs = $this->inputs; + unset($inputs['env']); + unset($inputs['server']); + + // Serialize the options, data, and inputs. + return serialize(array($this->options, $this->data, $inputs)); + } + + /** + * Method to unserialize the input. + * + * @param string $input The serialized input. + * + * @return Input The input object. + * + * @since 1.0 + */ + public function unserialize($input) + { + // Unserialize the options, data, and inputs. + list($this->options, $this->data, $this->inputs) = unserialize($input); + + // Load the filter. + if (isset($this->options['filter'])) + { + $this->filter = $this->options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + } + + /** + * Method to load all of the global inputs. + * + * @return void + * + * @since 1.0 + */ + protected function loadAllInputs() + { + if (!self::$loaded) + { + // Load up all the globals. + foreach ($GLOBALS as $global => $data) + { + // Check if the global starts with an underscore. + if (strpos($global, '_') === 0) + { + // Convert global name to input name. + $global = strtolower($global); + $global = substr($global, 1); + + // Get the input. + $this->$global; + } + } + + self::$loaded = true; + } + } +} diff --git a/libraries/vendor/joomla/input/src/Json.php b/libraries/vendor/joomla/input/src/Json.php new file mode 100644 index 0000000000000..a04d3369b5bec --- /dev/null +++ b/libraries/vendor/joomla/input/src/Json.php @@ -0,0 +1,86 @@ +filter = $options['filter']; + } + else + { + $this->filter = new Filter\InputFilter; + } + + if (is_null($source)) + { + $this->raw = file_get_contents('php://input'); + + // This is a workaround for where php://input has already been read. + // See note under php://input on http://php.net/manual/en/wrappers.php.php + if (empty($this->raw) && isset($GLOBALS['HTTP_RAW_POST_DATA'])) + { + $this->raw = $GLOBALS['HTTP_RAW_POST_DATA']; + } + + $this->data = json_decode($this->raw, true); + + if (!is_array($this->data)) + { + $this->data = array(); + } + } + else + { + $this->data = $source; + } + + // Set the options for the class. + $this->options = $options; + } + + /** + * Gets the raw JSON string from the request. + * + * @return string The raw JSON string from the request. + * + * @since 1.0 + */ + public function getRaw() + { + return $this->raw; + } +} diff --git a/libraries/vendor/joomla/registry/LICENSE b/libraries/vendor/joomla/registry/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/registry/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/framework/Joomla/Registry/AbstractRegistryFormat.php b/libraries/vendor/joomla/registry/src/AbstractRegistryFormat.php similarity index 100% rename from libraries/framework/Joomla/Registry/AbstractRegistryFormat.php rename to libraries/vendor/joomla/registry/src/AbstractRegistryFormat.php diff --git a/libraries/framework/Joomla/Registry/Format/Ini.php b/libraries/vendor/joomla/registry/src/Format/Ini.php similarity index 62% rename from libraries/framework/Joomla/Registry/Format/Ini.php rename to libraries/vendor/joomla/registry/src/Format/Ini.php index beaa1c235b71c..e213ebae7f279 100644 --- a/libraries/framework/Joomla/Registry/Format/Ini.php +++ b/libraries/vendor/joomla/registry/src/Format/Ini.php @@ -9,6 +9,7 @@ namespace Joomla\Registry\Format; use Joomla\Registry\AbstractRegistryFormat; +use Joomla\Utilities\ArrayHelper; use stdClass; /** @@ -18,6 +19,18 @@ */ class Ini extends AbstractRegistryFormat { + /** + * Default options array + * + * @var array + * @since 1.3.0 + */ + protected static $options = array( + 'supportArrayValues' => false, + 'parseBooleanWords' => false, + 'processSections' => false, + ); + /** * A cache used by stringToobject. * @@ -41,29 +54,73 @@ class Ini extends AbstractRegistryFormat */ public function objectToString($object, $options = array()) { + $options = array_merge(self::$options, $options); + $local = array(); $global = array(); + $variables = get_object_vars($object); + + $last = count($variables); + + // Assume that the first element is in section + $in_section = true; + // Iterate over the object to set the properties. - foreach (get_object_vars($object) as $key => $value) + foreach ($variables as $key => $value) { // If the value is an object then we need to put it in a local section. if (is_object($value)) { + // Add an empty line if previous string wasn't in a section + if (!$in_section) + { + $local[] = ''; + } + // Add the section line. - $local[] = ''; $local[] = '[' . $key . ']'; // Add the properties for this section. foreach (get_object_vars($value) as $k => $v) { - $local[] = $k . '=' . $this->getValueAsINI($v); + if (is_array($v) && $options['supportArrayValues']) + { + $assoc = ArrayHelper::isAssociative($v); + + foreach ($v as $array_key => $item) + { + $array_key = ($assoc) ? $array_key : ''; + $local[] = $k . '[' . $array_key . ']=' . $this->getValueAsINI($item); + } + } + else + { + $local[] = $k . '=' . $this->getValueAsINI($v); + } + } + + // Add empty line after section if it is not the last one + if (0 != --$last) + { + $local[] = ''; + } + } + elseif (is_array($value) && $options['supportArrayValues']) + { + $assoc = ArrayHelper::isAssociative($value); + + foreach ($value as $array_key => $item) + { + $array_key = ($assoc) ? $array_key : ''; + $global[] = $key . '[' . $array_key . ']=' . $this->getValueAsINI($item); } } else { // Not in a section so add the property to the global array. $global[] = $key . '=' . $this->getValueAsINI($value); + $in_section = false; } } @@ -82,10 +139,10 @@ public function objectToString($object, $options = array()) */ public function stringToObject($data, array $options = array()) { - $sections = (isset($options['processSections'])) ? $options['processSections'] : false; + $options = array_merge(self::$options, $options); // Check the memory cache for already processed strings. - $hash = md5($data . ':' . (int) $sections); + $hash = md5($data . ':' . (int) $options['processSections']); if (isset(self::$cache[$hash])) { @@ -100,6 +157,7 @@ public function stringToObject($data, array $options = array()) $obj = new stdClass; $section = false; + $array = false; $lines = explode("\n", $data); // Process the lines. @@ -114,7 +172,7 @@ public function stringToObject($data, array $options = array()) continue; } - if ($sections) + if ($options['processSections']) { $length = strlen($line); @@ -141,6 +199,29 @@ public function stringToObject($data, array $options = array()) // Get the key and value for the line. list ($key, $value) = explode('=', $line, 2); + // If we have an array item + if (substr($key, -1) == ']' && ($open_brace = strpos($key, '[', 1)) !== false) + { + if ($options['supportArrayValues']) + { + $array = true; + $array_key = substr($key, $open_brace + 1, -1); + + // If we have a multi-dimensional array or malformed key + if (strpos($array_key, '[') !== false || strpos($array_key, ']') !== false) + { + // Maybe throw exception? + continue; + } + + $key = substr($key, 0, $open_brace); + } + else + { + continue; + } + } + // Validate the key. if (preg_match('/[^A-Z0-9_]/i', $key)) { @@ -171,6 +252,11 @@ public function stringToObject($data, array $options = array()) { $value = true; } + elseif ($options['parseBooleanWords'] && in_array(strtolower($value), array('yes', 'no'))) + // If the value is 'yes' or 'no' and option is enabled assume appropriate boolean + { + $value = (strtolower($value) == 'yes'); + } elseif (is_numeric($value)) // If the value is numeric than it is either a float or int. { @@ -189,16 +275,56 @@ public function stringToObject($data, array $options = array()) // If a section is set add the key/value to the section, otherwise top level. if ($section) { - $obj->$section->$key = $value; + if ($array) + { + if (!isset($obj->$section->$key)) + { + $obj->$section->$key = array(); + } + + if (!empty($array_key)) + { + $obj->$section->{$key}[$array_key] = $value; + } + else + { + $obj->$section->{$key}[] = $value; + } + } + else + { + $obj->$section->$key = $value; + } } else { - $obj->$key = $value; + if ($array) + { + if (!isset($obj->$key)) + { + $obj->$key = array(); + } + + if (!empty($array_key)) + { + $obj->{$key}[$array_key] = $value; + } + else + { + $obj->{$key}[] = $value; + } + } + else + { + $obj->$key = $value; + } } + + $array = false; } // Cache the string to save cpu cycles -- thus the world :) - self::$cache[$hash] = clone ($obj); + self::$cache[$hash] = clone $obj; return $obj; } diff --git a/libraries/framework/Joomla/Registry/Format/Json.php b/libraries/vendor/joomla/registry/src/Format/Json.php similarity index 94% rename from libraries/framework/Joomla/Registry/Format/Json.php rename to libraries/vendor/joomla/registry/src/Format/Json.php index bd449423dcf94..539d73ef1932d 100644 --- a/libraries/framework/Joomla/Registry/Format/Json.php +++ b/libraries/vendor/joomla/registry/src/Format/Json.php @@ -9,6 +9,7 @@ namespace Joomla\Registry\Format; use Joomla\Registry\AbstractRegistryFormat; +use Joomla\String\String; /** * JSON format handler for Registry. @@ -29,7 +30,7 @@ class Json extends AbstractRegistryFormat */ public function objectToString($object, $options = array()) { - return json_encode($object); + return String::unicode_to_utf8(json_encode($object)); } /** diff --git a/libraries/framework/Joomla/Registry/Format/Php.php b/libraries/vendor/joomla/registry/src/Format/Php.php similarity index 89% rename from libraries/framework/Joomla/Registry/Format/Php.php rename to libraries/vendor/joomla/registry/src/Format/Php.php index 5fe01eb149741..74dfdc05a8a10 100644 --- a/libraries/framework/Joomla/Registry/Format/Php.php +++ b/libraries/vendor/joomla/registry/src/Format/Php.php @@ -45,7 +45,15 @@ public function objectToString($object, $params = array()) } } - $str = "toString(); } + /** + * Count elements of the data object + * + * @return integer The custom count as an integer. + * + * @link http://php.net/manual/en/countable.count.php + * @since 1.3.0 + */ + public function count() + { + $i = 0; + + foreach ($this->data as $item) + { + $i++; + } + + return $i++; + } + /** * Implementation for the JsonSerializable interface. * Allows us to pass Registry objects to json_encode. @@ -225,6 +245,21 @@ public static function getInstance($id) return self::$instances[$id]; } + /** + * Gets this object represented as an ArrayIterator. + * + * This allows the data properties to be accessed via a foreach statement. + * + * @return \ArrayIterator This object represented as an ArrayIterator. + * + * @see IteratorAggregate::getIterator() + * @since 1.3.0 + */ + public function getIterator() + { + return new \ArrayIterator($this->data); + } + /** * Load a associative array of values into the default namespace * @@ -300,7 +335,7 @@ public function loadString($data, $format = 'JSON', $options = array()) /** * Merge a Registry object into this one * - * @param Registry $source Source Registry object to merge. [@note Framework typehints this param] + * @param Registry $source Source Registry object to merge. * @param boolean $recursive True to support recursive merge the children values. * * @return Registry Return this object to support chaining. @@ -314,20 +349,30 @@ public function merge($source, $recursive = false) return false; } - $data = $source->toArray(); - $array = array(); + $this->bindData($this->data, $source->toArray(), $recursive, false); - foreach ($data as $k => $v) + return $this; + } + + /** + * Method to extract a sub-registry from path + * + * @param string $path Registry path (e.g. joomla.content.showauthor) + * + * @return Registry|null Registry object if data is present + * + * @since 1.2.0 + */ + public function extract($path) + { + $data = $this->get($path); + + if (is_null($data)) { - if (($v !== null) && ($v !== '')) - { - $array[$k] = $v; - } + return null; } - $this->bindData($this->data, $array, $recursive); - - return $this; + return new Registry($data); } /** @@ -479,12 +524,13 @@ public function toString($format = 'JSON', $options = array()) * @param object $parent The parent object on which to attach the data values. * @param mixed $data An array or object of data to bind to the parent object. * @param boolean $recursive True to support recursive bindData. + * @param boolean $allowNull True to allow null values. * * @return void * * @since 1.0 */ - protected function bindData($parent, $data, $recursive = true) + protected function bindData($parent, $data, $recursive = true, $allowNull = true) { // Ensure the input data is an array. if (is_object($data)) @@ -498,8 +544,12 @@ protected function bindData($parent, $data, $recursive = true) foreach ($data as $k => $v) { - // Modification from joomla/registry package - Using CMS JArrayHelper versus importing joomla/utilities package - if ($recursive && ((is_array($v) && \JArrayHelper::isAssociative($v)) || is_object($v))) + if (!$allowNull && !(($v !== null) && ($v !== ''))) + { + continue; + } + + if ($recursive && ((is_array($v) && ArrayHelper::isAssociative($v)) || is_object($v))) { if (!isset($parent->$k)) { @@ -547,4 +597,53 @@ protected function asArray($data) return $array; } + + /** + * Dump to one dimension array. + * + * @param string $separator The key separator. + * + * @return string[] Dumped array. + * + * @since 1.3.0 + */ + public function flatten($separator = '.') + { + $array = array(); + + $this->toFlatten($separator, $this->data, $array); + + return $array; + } + + /** + * Method to recursively convert data to one dimension array. + * + * @param string $separator The key separator. + * @param array|object $data Data source of this scope. + * @param array &$array The result array, it is pass by reference. + * @param string $prefix Last level key prefix. + * + * @return void + * + * @since 1.3.0 + */ + protected function toFlatten($separator = '.', $data = null, &$array = array(), $prefix = '') + { + $data = (array) $data; + + foreach ($data as $k => $v) + { + $key = $prefix ? $prefix . $separator . $k : $k; + + if (is_object($v) || is_array($v)) + { + $this->toFlatten($separator, $v, $array, $key); + } + else + { + $array[$key] = $v; + } + } + } } diff --git a/libraries/vendor/joomla/session/Joomla/Session/LICENSE b/libraries/vendor/joomla/session/Joomla/Session/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/session/Joomla/Session/Session.php b/libraries/vendor/joomla/session/Joomla/Session/Session.php new file mode 100644 index 0000000000000..e3c8b1b7dce69 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Session.php @@ -0,0 +1,979 @@ +store = Storage::getInstance($store, $options); + + $this->storeName = $store; + + // Set options + $this->_setOptions($options); + + $this->_setCookieParams(); + + $this->state = 'inactive'; + } + + /** + * Magic method to get read-only access to properties. + * + * @param string $name Name of property to retrieve + * + * @return mixed The value of the property + * + * @since 1.0 + */ + public function __get($name) + { + if ($name === 'storeName' || $name === 'state' || $name === 'expire') + { + return $this->$name; + } + } + + /** + * Returns the global Session object, only creating it + * if it doesn't already exist. + * + * @param string $handler The type of session handler. + * @param array $options An array of configuration options (for new sessions only). + * + * @return Session The Session object. + * + * @since 1.0 + */ + public static function getInstance($handler, array $options = array ()) + { + if (!is_object(self::$instance)) + { + self::$instance = new self($handler, $options); + } + + return self::$instance; + } + + /** + * Get current state of session + * + * @return string The session state + * + * @since 1.0 + */ + public function getState() + { + return $this->state; + } + + /** + * Get expiration time in minutes + * + * @return integer The session expiration time in minutes + * + * @since 1.0 + */ + public function getExpire() + { + return $this->expire; + } + + /** + * Get a session token, if a token isn't set yet one will be generated. + * + * Tokens are used to secure forms from spamming attacks. Once a token + * has been generated the system will check the post request to see if + * it is present, if not it will invalidate the session. + * + * @param boolean $forceNew If true, force a new token to be created + * + * @return string The session token + * + * @since 1.0 + */ + public function getToken($forceNew = false) + { + $token = $this->get('session.token'); + + // Create a token + if ($token === null || $forceNew) + { + $token = $this->_createToken(12); + $this->set('session.token', $token); + } + + return $token; + } + + /** + * Method to determine if a token exists in the session. If not the + * session will be set to expired + * + * @param string $tCheck Hashed token to be verified + * @param boolean $forceExpire If true, expires the session + * + * @return boolean + * + * @since 1.0 + */ + public function hasToken($tCheck, $forceExpire = true) + { + // Check if a token exists in the session + $tStored = $this->get('session.token'); + + // Check token + if (($tStored !== $tCheck)) + { + if ($forceExpire) + { + $this->state = 'expired'; + } + + return false; + } + + return true; + } + + /** + * Retrieve an external iterator. + * + * @return \ArrayIterator Return an ArrayIterator of $_SESSION. + * + * @since 1.0 + */ + public function getIterator() + { + return new \ArrayIterator($_SESSION); + } + + /** + * Get session name + * + * @return string The session name + * + * @since 1.0 + */ + public function getName() + { + if ($this->state === 'destroyed') + { + // @TODO : raise error + return null; + } + + return session_name(); + } + + /** + * Get session id + * + * @return string The session name + * + * @since 1.0 + */ + public function getId() + { + if ($this->state === 'destroyed') + { + return null; + } + + return session_id(); + } + + /** + * Get the session handlers + * + * @return array An array of available session handlers + * + * @since 1.0 + */ + public static function getStores() + { + $connectors = array(); + + // Get an iterator and loop trough the driver classes. + $iterator = new \DirectoryIterator(__DIR__ . '/Storage'); + + foreach ($iterator as $file) + { + $fileName = $file->getFilename(); + + // Only load for php files. + if (!$file->isFile() || $file->getExtension() != 'php') + { + continue; + } + + // Derive the class name from the type. + $class = str_ireplace('.php', '', '\\Joomla\\Session\\Storage\\' . ucfirst(trim($fileName))); + + // If the class doesn't exist we have nothing left to do but look at the next type. We did our best. + if (!class_exists($class)) + { + continue; + } + + // Sweet! Our class exists, so now we just need to know if it passes its test method. + if ($class::isSupported()) + { + // Connector names should not have file extensions. + $connectors[] = str_ireplace('.php', '', $fileName); + } + } + + return $connectors; + } + + /** + * Shorthand to check if the session is active + * + * @return boolean + * + * @since 1.0 + */ + public function isActive() + { + return (bool) ($this->state == 'active'); + } + + /** + * Check whether this session is currently created + * + * @return boolean True on success. + * + * @since 1.0 + */ + public function isNew() + { + $counter = $this->get('session.counter'); + + return (bool) ($counter === 1); + } + + /** + * Check whether this session is currently created + * + * @param Input $input Input object for the session to use. + * @param Dispatcher $dispatcher Dispatcher object for the session to use. + * + * @return void. + * + * @since 1.0 + */ + public function initialise(Input $input, DispatcherInterface $dispatcher = null) + { + $this->input = $input; + $this->dispatcher = $dispatcher; + } + + /** + * Get data from the session store + * + * @param string $name Name of a variable + * @param mixed $default Default value of a variable if not set + * @param string $namespace Namespace to use, default to 'default' + * + * @return mixed Value of a variable + * + * @since 1.0 + */ + public function get($name, $default = null, $namespace = 'default') + { + // Add prefix to namespace to avoid collisions + $namespace = '__' . $namespace; + + if ($this->state !== 'active' && $this->state !== 'expired') + { + // @TODO :: generated error here + $error = null; + + return $error; + } + + if (isset($_SESSION[$namespace][$name])) + { + return $_SESSION[$namespace][$name]; + } + + return $default; + } + + /** + * Set data into the session store. + * + * @param string $name Name of a variable. + * @param mixed $value Value of a variable. + * @param string $namespace Namespace to use, default to 'default'. + * + * @return mixed Old value of a variable. + * + * @since 1.0 + */ + public function set($name, $value = null, $namespace = 'default') + { + // Add prefix to namespace to avoid collisions + $namespace = '__' . $namespace; + + if ($this->state !== 'active') + { + // @TODO :: generated error here + return null; + } + + $old = isset($_SESSION[$namespace][$name]) ? $_SESSION[$namespace][$name] : null; + + if (null === $value) + { + unset($_SESSION[$namespace][$name]); + } + else + { + $_SESSION[$namespace][$name] = $value; + } + + return $old; + } + + /** + * Check whether data exists in the session store + * + * @param string $name Name of variable + * @param string $namespace Namespace to use, default to 'default' + * + * @return boolean True if the variable exists + * + * @since 1.0 + */ + public function has($name, $namespace = 'default') + { + // Add prefix to namespace to avoid collisions. + $namespace = '__' . $namespace; + + if ($this->state !== 'active') + { + // @TODO :: generated error here + return null; + } + + return isset($_SESSION[$namespace][$name]); + } + + /** + * Unset data from the session store + * + * @param string $name Name of variable + * @param string $namespace Namespace to use, default to 'default' + * + * @return mixed The value from session or NULL if not set + * + * @since 1.0 + */ + public function clear($name, $namespace = 'default') + { + // Add prefix to namespace to avoid collisions + $namespace = '__' . $namespace; + + if ($this->state !== 'active') + { + // @TODO :: generated error here + return null; + } + + $value = null; + + if (isset($_SESSION[$namespace][$name])) + { + $value = $_SESSION[$namespace][$name]; + unset($_SESSION[$namespace][$name]); + } + + return $value; + } + + /** + * Start a session. + * + * @return void + * + * @since 1.0 + */ + public function start() + { + if ($this->state === 'active') + { + return; + } + + $this->_start(); + + $this->state = 'active'; + + // Initialise the session + $this->_setCounter(); + $this->_setTimers(); + + // Perform security checks + $this->_validate(); + + if ($this->dispatcher instanceof DispatcherInterface) + { + $this->dispatcher->triggerEvent('onAfterSessionStart'); + } + } + + /** + * Start a session. + * + * Creates a session (or resumes the current one based on the state of the session) + * + * @return boolean true on success + * + * @since 1.0 + */ + protected function _start() + { + // Start session if not started + if ($this->state === 'restart') + { + session_regenerate_id(true); + } + else + { + $session_name = session_name(); + + // Get the JInputCookie object + $cookie = $this->input->cookie; + + if (is_null($cookie->get($session_name))) + { + $session_clean = $this->input->get($session_name, false, 'string'); + + if ($session_clean) + { + session_id($session_clean); + $cookie->set($session_name, '', time() - 3600); + } + } + } + + /** + * Write and Close handlers are called after destructing objects since PHP 5.0.5. + * Thus destructors can use sessions but session handler can't use objects. + * So we are moving session closure before destructing objects. + * + * Replace with session_register_shutdown() when dropping compatibility with PHP 5.3 + */ + register_shutdown_function('session_write_close'); + + session_cache_limiter('none'); + session_start(); + + return true; + } + + /** + * Frees all session variables and destroys all data registered to a session + * + * This method resets the $_SESSION variable and destroys all of the data associated + * with the current session in its storage (file or DB). It forces new session to be + * started after this method is called. It does not unset the session cookie. + * + * @return boolean True on success + * + * @see session_destroy() + * @see session_unset() + * @since 1.0 + */ + public function destroy() + { + // Session was already destroyed + if ($this->state === 'destroyed') + { + return true; + } + + /* + * In order to kill the session altogether, such as to log the user out, the session id + * must also be unset. If a cookie is used to propagate the session id (default behavior), + * then the session cookie must be deleted. + */ + if (isset($_COOKIE[session_name()])) + { + setcookie(session_name(), '', time() - 42000, $this->cookie_path, $this->cookie_domain); + } + + session_unset(); + session_destroy(); + + $this->state = 'destroyed'; + + return true; + } + + /** + * Restart an expired or locked session. + * + * @return boolean True on success + * + * @see destroy + * @since 1.0 + */ + public function restart() + { + $this->destroy(); + + if ($this->state !== 'destroyed') + { + // @TODO :: generated error here + return false; + } + + // Re-register the session handler after a session has been destroyed, to avoid PHP bug + $this->store->register(); + + $this->state = 'restart'; + + // Regenerate session id + session_regenerate_id(true); + $this->_start(); + $this->state = 'active'; + + $this->_validate(); + $this->_setCounter(); + + return true; + } + + /** + * Create a new session and copy variables from the old one + * + * @return boolean $result true on success + * + * @since 1.0 + */ + public function fork() + { + if ($this->state !== 'active') + { + // @TODO :: generated error here + return false; + } + + // Keep session config + $cookie = session_get_cookie_params(); + + // Kill session + session_destroy(); + + // Re-register the session store after a session has been destroyed, to avoid PHP bug + $this->store->register(); + + // Restore config + session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], true); + + // Restart session with new id + session_regenerate_id(true); + session_start(); + + return true; + } + + /** + * Writes session data and ends session + * + * Session data is usually stored after your script terminated without the need + * to call JSession::close(), but as session data is locked to prevent concurrent + * writes only one script may operate on a session at any time. When using + * framesets together with sessions you will experience the frames loading one + * by one due to this locking. You can reduce the time needed to load all the + * frames by ending the session as soon as all changes to session variables are + * done. + * + * @return void + * + * @see session_write_close() + * @since 1.0 + */ + public function close() + { + session_write_close(); + } + + /** + * Set session cookie parameters + * + * @return void + * + * @since 1.0 + */ + protected function _setCookieParams() + { + $cookie = session_get_cookie_params(); + + if ($this->force_ssl) + { + $cookie['secure'] = true; + } + + if ($this->cookie_domain) + { + $cookie['domain'] = $this->cookie_domain; + } + + if ($this->cookie_path) + { + $cookie['path'] = $this->cookie_path; + } + + session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], true); + } + + /** + * Create a token-string + * + * @param integer $length Length of string + * + * @return string Generated token + * + * @since 1.0 + */ + protected function _createToken($length = 32) + { + static $chars = '0123456789abcdef'; + $max = strlen($chars) - 1; + $token = ''; + $name = session_name(); + + for ($i = 0; $i < $length; ++$i) + { + $token .= $chars[(rand(0, $max))]; + } + + return md5($token . $name); + } + + /** + * Set counter of session usage + * + * @return boolean True on success + * + * @since 1.0 + */ + protected function _setCounter() + { + $counter = $this->get('session.counter', 0); + ++$counter; + + $this->set('session.counter', $counter); + + return true; + } + + /** + * Set the session timers + * + * @return boolean True on success + * + * @since 1.0 + */ + protected function _setTimers() + { + if (!$this->has('session.timer.start')) + { + $start = time(); + + $this->set('session.timer.start', $start); + $this->set('session.timer.last', $start); + $this->set('session.timer.now', $start); + } + + $this->set('session.timer.last', $this->get('session.timer.now')); + $this->set('session.timer.now', time()); + + return true; + } + + /** + * Set additional session options + * + * @param array $options List of parameter + * + * @return boolean True on success + * + * @since 1.0 + */ + protected function _setOptions(array $options) + { + // Set name + if (isset($options['name'])) + { + session_name(md5($options['name'])); + } + + // Set id + if (isset($options['id'])) + { + session_id($options['id']); + } + + // Set expire time + if (isset($options['expire'])) + { + $this->expire = $options['expire']; + } + + // Get security options + if (isset($options['security'])) + { + $this->security = explode(',', $options['security']); + } + + if (isset($options['force_ssl'])) + { + $this->force_ssl = (bool) $options['force_ssl']; + } + + if (isset($options['cookie_domain'])) + { + $this->cookie_domain = $options['cookie_domain']; + } + + if (isset($options['cookie_path'])) + { + $this->cookie_path = $options['cookie_path']; + } + + // Sync the session maxlifetime + ini_set('session.gc_maxlifetime', $this->expire); + + return true; + } + + /** + * Do some checks for security reason + * + * - timeout check (expire) + * - ip-fixiation + * - browser-fixiation + * + * If one check failed, session data has to be cleaned. + * + * @param boolean $restart Reactivate session + * + * @return boolean True on success + * + * @see http://shiflett.org/articles/the-truth-about-sessions + * @since 1.0 + */ + protected function _validate($restart = false) + { + // Allow to restart a session + if ($restart) + { + $this->state = 'active'; + + $this->set('session.client.address', null); + $this->set('session.client.forwarded', null); + $this->set('session.client.browser', null); + $this->set('session.token', null); + } + + // Check if session has expired + if ($this->expire) + { + $curTime = $this->get('session.timer.now', 0); + $maxTime = $this->get('session.timer.last', 0) + $this->expire; + + // Empty session variables + if ($maxTime < $curTime) + { + $this->state = 'expired'; + + return false; + } + } + + // Record proxy forwarded for in the session in case we need it later + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) + { + $this->set('session.client.forwarded', $_SERVER['HTTP_X_FORWARDED_FOR']); + } + + // Check for client address + if (in_array('fix_adress', $this->security) && isset($_SERVER['REMOTE_ADDR'])) + { + $ip = $this->get('session.client.address'); + + if ($ip === null) + { + $this->set('session.client.address', $_SERVER['REMOTE_ADDR']); + } + elseif ($_SERVER['REMOTE_ADDR'] !== $ip) + { + $this->state = 'error'; + + return false; + } + } + + // Check for clients browser + if (in_array('fix_browser', $this->security) && isset($_SERVER['HTTP_USER_AGENT'])) + { + $browser = $this->get('session.client.browser'); + + if ($browser === null) + { + $this->set('session.client.browser', $_SERVER['HTTP_USER_AGENT']); + } + elseif ($_SERVER['HTTP_USER_AGENT'] !== $browser) + { + // @todo remove code: $this->_state = 'error'; + // @todo remove code: return false; + } + } + + return true; + } +} diff --git a/libraries/vendor/joomla/session/Joomla/Session/Storage.php b/libraries/vendor/joomla/session/Joomla/Session/Storage.php new file mode 100644 index 0000000000000..b422a230cc531 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Storage.php @@ -0,0 +1,194 @@ +register($options); + } + + /** + * Returns a session storage handler object, only creating it if it doesn't already exist. + * + * @param string $name The session store to instantiate + * @param array $options Array of options + * + * @return Storage + * + * @since 1.0 + */ + public static function getInstance($name = 'none', $options = array()) + { + $filter = new InputFilter; + $name = strtolower($filter->clean($name, 'word')); + + if (empty(self::$instances[$name])) + { + $class = '\\Joomla\\Session\\Storage\\' . ucfirst($name); + + if (!class_exists($class)) + { + $path = __DIR__ . '/storage/' . $name . '.php'; + + if (file_exists($path)) + { + require_once $path; + } + else + { + // No attempt to die gracefully here, as it tries to close the non-existing session + exit('Unable to load session storage class: ' . $name); + } + } + + self::$instances[$name] = new $class($options); + } + + return self::$instances[$name]; + } + + /** + * Register the functions of this class with PHP's session handler + * + * @return void + * + * @since 1.0 + */ + public function register() + { + // Use this object as the session handler + session_set_save_handler( + array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), + array($this, 'destroy'), array($this, 'gc') + ); + } + + /** + * Open the SessionHandler backend. + * + * @param string $save_path The path to the session object. + * @param string $session_name The name of the session. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function open($save_path, $session_name) + { + return true; + } + + /** + * Close the SessionHandler backend. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function close() + { + return true; + } + + /** + * Read the data for a particular session identifier from the + * SessionHandler backend. + * + * @param string $id The session identifier. + * + * @return string The session data. + * + * @since 1.0 + */ + public function read($id) + { + return; + } + + /** + * Write session data to the SessionHandler backend. + * + * @param string $id The session identifier. + * @param string $session_data The session data. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function write($id, $session_data) + { + return true; + } + + /** + * Destroy the data for a particular session identifier in the + * SessionHandler backend. + * + * @param string $id The session identifier. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function destroy($id) + { + return true; + } + + /** + * Garbage collect stale sessions from the SessionHandler backend. + * + * @param integer $maxlifetime The maximum age of a session. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function gc($maxlifetime = null) + { + return true; + } + + /** + * Test to see if the SessionHandler is available. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public static function isSupported() + { + return true; + } +} diff --git a/libraries/vendor/joomla/session/Joomla/Session/Storage/Apc.php b/libraries/vendor/joomla/session/Joomla/Session/Storage/Apc.php new file mode 100644 index 0000000000000..4f865c0139bf4 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Storage/Apc.php @@ -0,0 +1,101 @@ +db = $options['db']; + } + else + { + throw new \RuntimeException( + sprintf('The %s storage engine requires a `db` option that is an instance of Joomla\\Database\\DatabaseDriver.', __CLASS__) + ); + } + } + + /** + * Read the data for a particular session identifier from the SessionHandler backend. + * + * @param string $id The session identifier. + * + * @return string The session data. + * + * @since 1.0 + */ + public function read($id) + { + try + { + // Get the session data from the database table. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('data')) + ->from($this->db->quoteName('#__session')) + ->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id)); + + $this->db->setQuery($query); + + return (string) $this->db->loadResult(); + } + catch (\Exception $e) + { + return false; + } + } + + /** + * Write session data to the SessionHandler backend. + * + * @param string $id The session identifier. + * @param string $data The session data. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function write($id, $data) + { + try + { + $query = $this->db->getQuery(true); + $query->update($this->db->quoteName('#__session')) + ->set($this->db->quoteName('data') . ' = ' . $this->db->quote($data)) + ->set($this->db->quoteName('time') . ' = ' . $this->db->quote((int) time())) + ->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id)); + + // Try to update the session data in the database table. + $this->db->setQuery($query); + + if (!$this->db->execute()) + { + return false; + } + + // Since $this->db->execute did not throw an exception the query was successful. + // Either the data changed, or the data was identical. In either case we are done. + + return true; + } + catch (\Exception $e) + { + return false; + } + } + + /** + * Destroy the data for a particular session identifier in the SessionHandler backend. + * + * @param string $id The session identifier. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function destroy($id) + { + try + { + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__session')) + ->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id)); + + // Remove a session from the database. + $this->db->setQuery($query); + + return (boolean) $this->db->execute(); + } + catch (\Exception $e) + { + return false; + } + } + + /** + * Garbage collect stale sessions from the SessionHandler backend. + * + * @param integer $lifetime The maximum age of a session. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + public function gc($lifetime = 1440) + { + // Determine the timestamp threshold with which to purge old sessions. + $past = time() - $lifetime; + + try + { + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__session')) + ->where($this->db->quoteName('time') . ' < ' . $this->db->quote((int) $past)); + + // Remove expired sessions from the database. + $this->db->setQuery($query); + + return (boolean) $this->db->execute(); + } + catch (\Exception $e) + { + return false; + } + } +} diff --git a/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcache.php b/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcache.php new file mode 100644 index 0000000000000..3b47aa5c21474 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcache.php @@ -0,0 +1,72 @@ +_servers = array( + array( + 'host' => isset($options['memcache_server_host']) ? $options['memcache_server_host'] : 'localhost', + 'port' => isset($options['memcache_server_port']) ? $options['memcache_server_port'] : 11211 + ) + ); + } + + /** + * Register the functions of this class with PHP's session handler + * + * @return void + * + * @since 1.0 + */ + public function register() + { + ini_set('session.save_path', $this->_servers[0]['host'] . ':' . $this->_servers[0]['port']); + ini_set('session.save_handler', 'memcache'); + } + + /** + * Test to see if the SessionHandler is available. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + static public function isSupported() + { + return (extension_loaded('memcache') && class_exists('Memcache')); + } +} diff --git a/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcached.php b/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcached.php new file mode 100644 index 0000000000000..06b8c4328ffe2 --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Storage/Memcached.php @@ -0,0 +1,74 @@ +_servers = array( + array( + 'host' => isset($options['memcache_server_host']) ? $options['memcache_server_host'] : 'localhost', + 'port' => isset($options['memcache_server_port']) ? $options['memcache_server_port'] : 11211 + ) + ); + + // Only construct parent AFTER host and port are sent, otherwise when register is called this will fail. + parent::__construct($options); + } + + /** + * Register the functions of this class with PHP's session handler + * + * @return void + * + * @since 1.0 + */ + public function register() + { + ini_set('session.save_path', $this->_servers[0]['host'] . ':' . $this->_servers[0]['port']); + ini_set('session.save_handler', 'memcached'); + } + + /** + * Test to see if the SessionHandler is available. + * + * @return boolean True on success, false otherwise. + * + * @since 1.0 + */ + static public function isSupported() + { + // GAE and HHVM have both had instances where Memcached the class was defined but no extension was loaded. If the class is there, we can assume it works. + return (class_exists('Memcached')); + } +} diff --git a/libraries/vendor/joomla/session/Joomla/Session/Storage/None.php b/libraries/vendor/joomla/session/Joomla/Session/Storage/None.php new file mode 100644 index 0000000000000..6e8bcd94071bc --- /dev/null +++ b/libraries/vendor/joomla/session/Joomla/Session/Storage/None.php @@ -0,0 +1,32 @@ + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/joomla/string/inflector.php b/libraries/vendor/joomla/string/src/Inflector.php similarity index 74% rename from libraries/joomla/string/inflector.php rename to libraries/vendor/joomla/string/src/Inflector.php index b42705bb2ebf3..4100b1c514de2 100644 --- a/libraries/joomla/string/inflector.php +++ b/libraries/vendor/joomla/string/src/Inflector.php @@ -1,40 +1,39 @@ array( '/(matr)ices$/i' => '\1ix', '/(vert|ind)ices$/i' => '\1ex', @@ -79,14 +78,14 @@ class JStringInflector * The array is in the form [singular => plural] * * @var array - * @since 12.1 + * @since 1.0 */ - private $_cache = array(); + private $cache = array(); /** * Protected constructor. * - * @since 12.1 + * @since 1.0 */ protected function __construct() { @@ -125,10 +124,10 @@ protected function __construct() * * @return void * - * @since 12.1 + * @since 1.0 * @throws InvalidArgumentException */ - private function _addRule($data, $ruleType) + private function addRule($data, $ruleType) { if (is_string($data)) { @@ -143,7 +142,7 @@ private function _addRule($data, $ruleType) foreach ($data as $rule) { // Ensure a string is pushed. - array_push($this->_rules[$ruleType], (string) $rule); + array_push($this->rules[$ruleType], (string) $rule); } } @@ -154,16 +153,16 @@ private function _addRule($data, $ruleType) * * @return mixed The cached inflection or false if none found. * - * @since 12.1 + * @since 1.0 */ - private function _getCachedPlural($singular) + private function getCachedPlural($singular) { - $singular = JString::strtolower($singular); + $singular = String::strtolower($singular); // Check if the word is in cache. - if (isset($this->_cache[$singular])) + if (isset($this->cache[$singular])) { - return $this->_cache[$singular]; + return $this->cache[$singular]; } return false; @@ -176,13 +175,13 @@ private function _getCachedPlural($singular) * * @return mixed The cached inflection or false if none found. * - * @since 12.1 + * @since 1.0 */ - private function _getCachedSingular($plural) + private function getCachedSingular($plural) { - $plural = JString::strtolower($plural); + $plural = String::strtolower($plural); - return array_search($plural, $this->_cache); + return array_search($plural, $this->cache); } /** @@ -196,12 +195,12 @@ private function _getCachedSingular($plural) * * @return mixed An inflected string, or false if no rule could be applied. * - * @since 12.1 + * @since 1.0 */ - private function _matchRegexRule($word, $ruleType) + private function matchRegexRule($word, $ruleType) { // Cycle through the regex rules. - foreach ($this->_rules[$ruleType] as $regex => $replacement) + foreach ($this->rules[$ruleType] as $regex => $replacement) { $matches = 0; $matchedWord = preg_replace($regex, $replacement, $word, -1, $matches); @@ -223,11 +222,11 @@ private function _matchRegexRule($word, $ruleType) * * @return void * - * @since 12.1 + * @since 1.0 */ - private function _setCache($singular, $plural = null) + private function setCache($singular, $plural = null) { - $singular = JString::strtolower($singular); + $singular = String::strtolower($singular); if ($plural === null) { @@ -235,10 +234,10 @@ private function _setCache($singular, $plural = null) } else { - $plural = JString::strtolower($plural); + $plural = String::strtolower($plural); } - $this->_cache[$singular] = $plural; + $this->cache[$singular] = $plural; } /** @@ -246,13 +245,13 @@ private function _setCache($singular, $plural = null) * * @param mixed $data A string or an array of strings to add. * - * @return JStringInflector Returns this object to support chaining. + * @return Inflector Returns this object to support chaining. * - * @since 12.1 + * @since 1.0 */ public function addCountableRule($data) { - $this->_addRule($data, 'countable'); + $this->addRule($data, 'countable'); return $this; } @@ -263,13 +262,13 @@ public function addCountableRule($data) * @param string $singular The singular form of the word. * @param string $plural The plural form of the word. If omitted, it is assumed the singular and plural are identical. * - * @return JStringInflector Returns this object to support chaining. + * @return Inflector Returns this object to support chaining. * - * @since 12.1 + * @since 1.0 */ public function addWord($singular, $plural =null) { - $this->_setCache($singular, $plural); + $this->setCache($singular, $plural); return $this; } @@ -279,13 +278,13 @@ public function addWord($singular, $plural =null) * * @param mixed $data A string or an array of regex rules to add. * - * @return JStringInflector Returns this object to support chaining. + * @return Inflector Returns this object to support chaining. * - * @since 12.1 + * @since 1.0 */ public function addPluraliseRule($data) { - $this->_addRule($data, 'plural'); + $this->addRule($data, 'plural'); return $this; } @@ -295,13 +294,13 @@ public function addPluraliseRule($data) * * @param mixed $data A string or an array of regex rules to add. * - * @return JStringInflector Returns this object to support chaining. + * @return Inflector Returns this object to support chaining. * - * @since 12.1 + * @since 1.0 */ public function addSingulariseRule($data) { - $this->_addRule($data, 'singular'); + $this->addRule($data, 'singular'); return $this; } @@ -312,9 +311,9 @@ public function addSingulariseRule($data) * @param boolean $new If true (default is false), returns a new instance regardless if one exists. * This argument is mainly used for testing. * - * @return JStringInflector + * @return Inflector * - * @since 12.1 + * @since 1.0 */ public static function getInstance($new = false) { @@ -322,12 +321,12 @@ public static function getInstance($new = false) { return new static; } - elseif (!is_object(self::$_instance)) + elseif (!is_object(self::$instance)) { - self::$_instance = new static; + self::$instance = new static; } - return self::$_instance; + return self::$instance; } /** @@ -337,11 +336,11 @@ public static function getInstance($new = false) * * @return boolean True if word is countable, false otherwise. * - * @since 12.1 + * @since 1.0 */ public function isCountable($word) { - return (boolean) in_array($word, $this->_rules['countable']); + return (boolean) in_array($word, $this->rules['countable']); } /** @@ -351,12 +350,12 @@ public function isCountable($word) * * @return boolean True if word is plural, false if not. * - * @since 12.1 + * @since 1.0 */ public function isPlural($word) { // Try the cache for an known inflection. - $inflection = $this->_getCachedSingular($word); + $inflection = $this->getCachedSingular($word); if ($inflection !== false) { @@ -374,12 +373,12 @@ public function isPlural($word) * * @return boolean True if word is singular, false if not. * - * @since 12.1 + * @since 1.0 */ public function isSingular($word) { // Try the cache for an known inflection. - $inflection = $this->_getCachedPlural($word); + $inflection = $this->getCachedPlural($word); if ($inflection !== false) { @@ -397,12 +396,12 @@ public function isSingular($word) * * @return mixed An inflected string, or false if no rule could be applied. * - * @since 12.1 + * @since 1.0 */ public function toPlural($word) { // Try to get the cached plural form from the singular. - $cache = $this->_getCachedPlural($word); + $cache = $this->getCachedPlural($word); if ($cache !== false) { @@ -410,21 +409,22 @@ public function toPlural($word) } // Check if the word is a known singular. - if ($this->_getCachedSingular($word)) + if ($this->getCachedSingular($word)) { return false; } // Compute the inflection. - $inflected = $this->_matchRegexRule($word, 'plural'); + $inflected = $this->matchRegexRule($word, 'plural'); if ($inflected !== false) { - $this->_setCache($word, $inflected); + $this->setCache($word, $inflected); return $inflected; } + // Dead code return false; } @@ -435,12 +435,12 @@ public function toPlural($word) * * @return mixed An inflected string, or false if no rule could be applied. * - * @since 12.1 + * @since 1.0 */ public function toSingular($word) { // Try to get the cached singular form from the plural. - $cache = $this->_getCachedSingular($word); + $cache = $this->getCachedSingular($word); if ($cache !== false) { @@ -448,17 +448,17 @@ public function toSingular($word) } // Check if the word is a known plural. - if ($this->_getCachedPlural($word)) + if ($this->getCachedPlural($word)) { return false; } // Compute the inflection. - $inflected = $this->_matchRegexRule($word, 'singular'); + $inflected = $this->matchRegexRule($word, 'singular'); if ($inflected !== false) { - $this->_setCache($inflected, $word); + $this->setCache($inflected, $word); return $inflected; } diff --git a/libraries/joomla/string/normalise.php b/libraries/vendor/joomla/string/src/Normalise.php similarity index 85% rename from libraries/joomla/string/normalise.php rename to libraries/vendor/joomla/string/src/Normalise.php index 8d5f4cc778591..e11437666a058 100644 --- a/libraries/joomla/string/normalise.php +++ b/libraries/vendor/joomla/string/src/Normalise.php @@ -1,22 +1,19 @@ =')) + { + @ini_set('default_charset', 'UTF-8'); + } + else + { + iconv_set_encoding("internal_encoding", "UTF-8"); + iconv_set_encoding("input_encoding", "UTF-8"); + iconv_set_encoding("output_encoding", "UTF-8"); + } +} + +/** + * Include the utf8 package + */ +if (!defined('UTF8')) +{ + require_once __DIR__ . '/phputf8/utf8.php'; +} + +if (!function_exists('utf8_strcasecmp')) +{ + require_once __DIR__ . '/phputf8/strcasecmp.php'; +} + +/** + * String handling class for utf-8 data + * Wraps the phputf8 library + * All functions assume the validity of utf-8 strings. + * + * @since 1.0 + */ +abstract class String +{ + /** + * Increment styles. + * + * @var array + * @since 1.0 + */ + protected static $incrementStyles = array( + 'dash' => array( + '#-(\d+)$#', + '-%d' + ), + 'default' => array( + array('#\((\d+)\)$#', '#\(\d+\)$#'), + array(' (%d)', '(%d)'), + ), + ); + + /** + * Increments a trailing number in a string. + * + * Used to easily create distinct labels when copying objects. The method has the following styles: + * + * default: "Label" becomes "Label (2)" + * dash: "Label" becomes "Label-2" + * + * @param string $string The source string. + * @param string $style The the style (default|dash). + * @param integer $n If supplied, this number is used for the copy, otherwise it is the 'next' number. + * + * @return string The incremented string. + * + * @since 1.0 + */ + public static function increment($string, $style = 'default', $n = 0) + { + $styleSpec = isset(self::$incrementStyles[$style]) ? self::$incrementStyles[$style] : self::$incrementStyles['default']; + + // Regular expression search and replace patterns. + if (is_array($styleSpec[0])) + { + $rxSearch = $styleSpec[0][0]; + $rxReplace = $styleSpec[0][1]; + } + else + { + $rxSearch = $rxReplace = $styleSpec[0]; + } + + // New and old (existing) sprintf formats. + if (is_array($styleSpec[1])) + { + $newFormat = $styleSpec[1][0]; + $oldFormat = $styleSpec[1][1]; + } + else + { + $newFormat = $oldFormat = $styleSpec[1]; + } + + // Check if we are incrementing an existing pattern, or appending a new one. + if (preg_match($rxSearch, $string, $matches)) + { + $n = empty($n) ? ($matches[1] + 1) : $n; + $string = preg_replace($rxReplace, sprintf($oldFormat, $n), $string); + } + else + { + $n = empty($n) ? 2 : $n; + $string .= sprintf($newFormat, $n); + } + + return $string; + } + + /** + * Tests whether a string contains only 7bit ASCII bytes. + * You might use this to conditionally check whether a string + * needs handling as UTF-8 or not, potentially offering performance + * benefits by using the native PHP equivalent if it's just ASCII e.g.; + * + * + * if (String::is_ascii($someString)) + * { + * // It's just ASCII - use the native PHP version + * $someString = strtolower($someString); + * } + * else + * { + * $someString = String::strtolower($someString); + * } + * + * + * @param string $str The string to test. + * + * @return boolean True if the string is all ASCII + * + * @since 1.0 + */ + public static function is_ascii($str) + { + // Search for any bytes which are outside the ASCII range... + return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1); + } + + /** + * UTF-8 aware alternative to strpos. + * + * Find position of first occurrence of a string. + * + * @param string $str String being examined + * @param string $search String being searched for + * @param integer $offset Optional, specifies the position from which the search should be performed + * + * @return mixed Number of characters before the first match or FALSE on failure + * + * @see http://www.php.net/strpos + * @since 1.0 + */ + public static function strpos($str, $search, $offset = false) + { + if ($offset === false) + { + return utf8_strpos($str, $search); + } + else + { + return utf8_strpos($str, $search, $offset); + } + } + + /** + * UTF-8 aware alternative to strrpos + * Finds position of last occurrence of a string + * + * @param string $str String being examined. + * @param string $search String being searched for. + * @param integer $offset Offset from the left of the string. + * + * @return mixed Number of characters before the last match or false on failure + * + * @see http://www.php.net/strrpos + * @since 1.0 + */ + public static function strrpos($str, $search, $offset = 0) + { + return utf8_strrpos($str, $search, $offset); + } + + /** + * UTF-8 aware alternative to substr + * Return part of a string given character offset (and optionally length) + * + * @param string $str String being processed + * @param integer $offset Number of UTF-8 characters offset (from left) + * @param integer $length Optional length in UTF-8 characters from offset + * + * @return mixed string or FALSE if failure + * + * @see http://www.php.net/substr + * @since 1.0 + */ + public static function substr($str, $offset, $length = false) + { + if ($length === false) + { + return utf8_substr($str, $offset); + } + else + { + return utf8_substr($str, $offset, $length); + } + } + + /** + * UTF-8 aware alternative to strtlower + * + * Make a string lowercase + * Note: The concept of a characters "case" only exists is some alphabets + * such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does + * not exist in the Chinese alphabet, for example. See Unicode Standard + * Annex #21: Case Mappings + * + * @param string $str String being processed + * + * @return mixed Either string in lowercase or FALSE is UTF-8 invalid + * + * @see http://www.php.net/strtolower + * @since 1.0 + */ + public static function strtolower($str) + { + return utf8_strtolower($str); + } + + /** + * UTF-8 aware alternative to strtoupper + * Make a string uppercase + * Note: The concept of a characters "case" only exists is some alphabets + * such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does + * not exist in the Chinese alphabet, for example. See Unicode Standard + * Annex #21: Case Mappings + * + * @param string $str String being processed + * + * @return mixed Either string in uppercase or FALSE is UTF-8 invalid + * + * @see http://www.php.net/strtoupper + * @since 1.0 + */ + public static function strtoupper($str) + { + return utf8_strtoupper($str); + } + + /** + * UTF-8 aware alternative to strlen. + * + * Returns the number of characters in the string (NOT THE NUMBER OF BYTES), + * + * @param string $str UTF-8 string. + * + * @return integer Number of UTF-8 characters in string. + * + * @see http://www.php.net/strlen + * @since 1.0 + */ + public static function strlen($str) + { + return utf8_strlen($str); + } + + /** + * UTF-8 aware alternative to str_ireplace + * Case-insensitive version of str_replace + * + * @param string $search String to search + * @param string $replace Existing string to replace + * @param string $str New string to replace with + * @param integer $count Optional count value to be passed by referene + * + * @return string UTF-8 String + * + * @see http://www.php.net/str_ireplace + * @since 1.0 + */ + public static function str_ireplace($search, $replace, $str, $count = null) + { + require_once __DIR__ . '/phputf8/str_ireplace.php'; + + if ($count === false) + { + return utf8_ireplace($search, $replace, $str); + } + else + { + return utf8_ireplace($search, $replace, $str, $count); + } + } + + /** + * UTF-8 aware alternative to str_split + * Convert a string to an array + * + * @param string $str UTF-8 encoded string to process + * @param integer $split_len Number to characters to split string by + * + * @return array + * + * @see http://www.php.net/str_split + * @since 1.0 + */ + public static function str_split($str, $split_len = 1) + { + require_once __DIR__ . '/phputf8/str_split.php'; + + return utf8_str_split($str, $split_len); + } + + /** + * UTF-8/LOCALE aware alternative to strcasecmp + * A case insensitive string comparison + * + * @param string $str1 string 1 to compare + * @param string $str2 string 2 to compare + * @param mixed $locale The locale used by strcoll or false to use classical comparison + * + * @return integer < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. + * + * @see http://www.php.net/strcasecmp + * @see http://www.php.net/strcoll + * @see http://www.php.net/setlocale + * @since 1.0 + */ + public static function strcasecmp($str1, $str2, $locale = false) + { + if ($locale) + { + // Get current locale + $locale0 = setlocale(LC_COLLATE, 0); + + if (!$locale = setlocale(LC_COLLATE, $locale)) + { + $locale = $locale0; + } + + // See if we have successfully set locale to UTF-8 + if (!stristr($locale, 'UTF-8') && stristr($locale, '_') && preg_match('~\.(\d+)$~', $locale, $m)) + { + $encoding = 'CP' . $m[1]; + } + elseif (stristr($locale, 'UTF-8') || stristr($locale, 'utf8')) + { + $encoding = 'UTF-8'; + } + else + { + $encoding = 'nonrecodable'; + } + + // If we successfully set encoding it to utf-8 or encoding is sth weird don't recode + if ($encoding == 'UTF-8' || $encoding == 'nonrecodable') + { + return strcoll(utf8_strtolower($str1), utf8_strtolower($str2)); + } + else + { + return strcoll( + self::transcode(utf8_strtolower($str1), 'UTF-8', $encoding), + self::transcode(utf8_strtolower($str2), 'UTF-8', $encoding) + ); + } + } + else + { + return utf8_strcasecmp($str1, $str2); + } + } + + /** + * UTF-8/LOCALE aware alternative to strcmp + * A case sensitive string comparison + * + * @param string $str1 string 1 to compare + * @param string $str2 string 2 to compare + * @param mixed $locale The locale used by strcoll or false to use classical comparison + * + * @return integer < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. + * + * @see http://www.php.net/strcmp + * @see http://www.php.net/strcoll + * @see http://www.php.net/setlocale + * @since 1.0 + */ + public static function strcmp($str1, $str2, $locale = false) + { + if ($locale) + { + // Get current locale + $locale0 = setlocale(LC_COLLATE, 0); + + if (!$locale = setlocale(LC_COLLATE, $locale)) + { + $locale = $locale0; + } + + // See if we have successfully set locale to UTF-8 + if (!stristr($locale, 'UTF-8') && stristr($locale, '_') && preg_match('~\.(\d+)$~', $locale, $m)) + { + $encoding = 'CP' . $m[1]; + } + elseif (stristr($locale, 'UTF-8') || stristr($locale, 'utf8')) + { + $encoding = 'UTF-8'; + } + else + { + $encoding = 'nonrecodable'; + } + + // If we successfully set encoding it to utf-8 or encoding is sth weird don't recode + if ($encoding == 'UTF-8' || $encoding == 'nonrecodable') + { + return strcoll($str1, $str2); + } + else + { + return strcoll(self::transcode($str1, 'UTF-8', $encoding), self::transcode($str2, 'UTF-8', $encoding)); + } + } + else + { + return strcmp($str1, $str2); + } + } + + /** + * UTF-8 aware alternative to strcspn + * Find length of initial segment not matching mask + * + * @param string $str The string to process + * @param string $mask The mask + * @param integer $start Optional starting character position (in characters) + * @param integer $length Optional length + * + * @return integer The length of the initial segment of str1 which does not contain any of the characters in str2 + * + * @see http://www.php.net/strcspn + * @since 1.0 + */ + public static function strcspn($str, $mask, $start = null, $length = null) + { + require_once __DIR__ . '/phputf8/strcspn.php'; + + if ($start === false && $length === false) + { + return utf8_strcspn($str, $mask); + } + elseif ($length === false) + { + return utf8_strcspn($str, $mask, $start); + } + else + { + return utf8_strcspn($str, $mask, $start, $length); + } + } + + /** + * UTF-8 aware alternative to stristr + * Returns all of haystack from the first occurrence of needle to the end. + * needle and haystack are examined in a case-insensitive manner + * Find first occurrence of a string using case insensitive comparison + * + * @param string $str The haystack + * @param string $search The needle + * + * @return string the sub string + * + * @see http://www.php.net/stristr + * @since 1.0 + */ + public static function stristr($str, $search) + { + require_once __DIR__ . '/phputf8/stristr.php'; + + return utf8_stristr($str, $search); + } + + /** + * UTF-8 aware alternative to strrev + * Reverse a string + * + * @param string $str String to be reversed + * + * @return string The string in reverse character order + * + * @see http://www.php.net/strrev + * @since 1.0 + */ + public static function strrev($str) + { + require_once __DIR__ . '/phputf8/strrev.php'; + + return utf8_strrev($str); + } + + /** + * UTF-8 aware alternative to strspn + * Find length of initial segment matching mask + * + * @param string $str The haystack + * @param string $mask The mask + * @param integer $start Start optional + * @param integer $length Length optional + * + * @return integer + * + * @see http://www.php.net/strspn + * @since 1.0 + */ + public static function strspn($str, $mask, $start = null, $length = null) + { + require_once __DIR__ . '/phputf8/strspn.php'; + + if ($start === null && $length === null) + { + return utf8_strspn($str, $mask); + } + elseif ($length === null) + { + return utf8_strspn($str, $mask, $start); + } + else + { + return utf8_strspn($str, $mask, $start, $length); + } + } + + /** + * UTF-8 aware substr_replace + * Replace text within a portion of a string + * + * @param string $str The haystack + * @param string $repl The replacement string + * @param integer $start Start + * @param integer $length Length (optional) + * + * @return string + * + * @see http://www.php.net/substr_replace + * @since 1.0 + */ + public static function substr_replace($str, $repl, $start, $length = null) + { + // Loaded by library loader + if ($length === false) + { + return utf8_substr_replace($str, $repl, $start); + } + else + { + return utf8_substr_replace($str, $repl, $start, $length); + } + } + + /** + * UTF-8 aware replacement for ltrim() + * + * Strip whitespace (or other characters) from the beginning of a string + * You only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise ltrim will + * work normally on a UTF-8 string + * + * @param string $str The string to be trimmed + * @param string $charlist The optional charlist of additional characters to trim + * + * @return string The trimmed string + * + * @see http://www.php.net/ltrim + * @since 1.0 + */ + public static function ltrim($str, $charlist = false) + { + if (empty($charlist) && $charlist !== false) + { + return $str; + } + + require_once __DIR__ . '/phputf8/trim.php'; + + if ($charlist === false) + { + return utf8_ltrim($str); + } + else + { + return utf8_ltrim($str, $charlist); + } + } + + /** + * UTF-8 aware replacement for rtrim() + * Strip whitespace (or other characters) from the end of a string + * You only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise rtrim will + * work normally on a UTF-8 string + * + * @param string $str The string to be trimmed + * @param string $charlist The optional charlist of additional characters to trim + * + * @return string The trimmed string + * + * @see http://www.php.net/rtrim + * @since 1.0 + */ + public static function rtrim($str, $charlist = false) + { + if (empty($charlist) && $charlist !== false) + { + return $str; + } + + require_once __DIR__ . '/phputf8/trim.php'; + + if ($charlist === false) + { + return utf8_rtrim($str); + } + else + { + return utf8_rtrim($str, $charlist); + } + } + + /** + * UTF-8 aware replacement for trim() + * Strip whitespace (or other characters) from the beginning and end of a string + * Note: you only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise trim will + * work normally on a UTF-8 string + * + * @param string $str The string to be trimmed + * @param string $charlist The optional charlist of additional characters to trim + * + * @return string The trimmed string + * + * @see http://www.php.net/trim + * @since 1.0 + */ + public static function trim($str, $charlist = false) + { + if (empty($charlist) && $charlist !== false) + { + return $str; + } + + require_once __DIR__ . '/phputf8/trim.php'; + + if ($charlist === false) + { + return utf8_trim($str); + } + else + { + return utf8_trim($str, $charlist); + } + } + + /** + * UTF-8 aware alternative to ucfirst + * Make a string's first character uppercase or all words' first character uppercase + * + * @param string $str String to be processed + * @param string $delimiter The words delimiter (null means do not split the string) + * @param string $newDelimiter The new words delimiter (null means equal to $delimiter) + * + * @return string If $delimiter is null, return the string with first character as upper case (if applicable) + * else consider the string of words separated by the delimiter, apply the ucfirst to each words + * and return the string with the new delimiter + * + * @see http://www.php.net/ucfirst + * @since 1.0 + */ + public static function ucfirst($str, $delimiter = null, $newDelimiter = null) + { + require_once __DIR__ . '/phputf8/ucfirst.php'; + + if ($delimiter === null) + { + return utf8_ucfirst($str); + } + else + { + if ($newDelimiter === null) + { + $newDelimiter = $delimiter; + } + + return implode($newDelimiter, array_map('utf8_ucfirst', explode($delimiter, $str))); + } + } + + /** + * UTF-8 aware alternative to ucwords + * Uppercase the first character of each word in a string + * + * @param string $str String to be processed + * + * @return string String with first char of each word uppercase + * + * @see http://www.php.net/ucwords + * @since 1.0 + */ + public static function ucwords($str) + { + require_once __DIR__ . '/phputf8/ucwords.php'; + + return utf8_ucwords($str); + } + + /** + * Transcode a string. + * + * @param string $source The string to transcode. + * @param string $from_encoding The source encoding. + * @param string $to_encoding The target encoding. + * + * @return mixed The transcoded string, or null if the source was not a string. + * + * @link https://bugs.php.net/bug.php?id=48147 + * + * @since 1.0 + */ + public static function transcode($source, $from_encoding, $to_encoding) + { + if (is_string($source)) + { + switch (ICONV_IMPL) + { + case 'glibc': + return @iconv($from_encoding, $to_encoding . '//TRANSLIT,IGNORE', $source); + + case 'libiconv': + default: + return iconv($from_encoding, $to_encoding . '//IGNORE//TRANSLIT', $source); + } + } + + return null; + } + + /** + * Tests a string as to whether it's valid UTF-8 and supported by the Unicode standard. + * + * Note: this function has been modified to simple return true or false. + * + * @param string $str UTF-8 encoded string. + * + * @return boolean true if valid + * + * @author + * @see http://hsivonen.iki.fi/php-utf8/ + * @see compliant + * @since 1.0 + */ + public static function valid($str) + { + // Cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mState = 0; + + // Cached Unicode character + $mUcs4 = 0; + + // Cached expected number of octets in the current sequence + $mBytes = 1; + + $len = strlen($str); + + for ($i = 0; $i < $len; $i++) + { + $in = ord($str{$i}); + + if ($mState == 0) + { + // When mState is zero we expect either a US-ASCII character or a + // multi-octet sequence. + if (0 == (0x80 & ($in))) + { + // US-ASCII, pass straight through. + $mBytes = 1; + } + elseif (0xC0 == (0xE0 & ($in))) + { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + } + elseif (0xE0 == (0xF0 & ($in))) + { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + } + elseif (0xF0 == (0xF8 & ($in))) + { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + } + elseif (0xF8 == (0xFC & ($in))) + { + /* First octet of 5 octet sequence. + * + * This is illegal because the encoded codepoint must be either + * (a) not the shortest form or + * (b) outside the Unicode range of 0-0x10FFFF. + * Rather than trying to resynchronize, we will carry on until the end + * of the sequence and let the later error handling code catch it. + */ + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x03) << 24; + $mState = 4; + $mBytes = 5; + } + elseif (0xFC == (0xFE & ($in))) + { + // First octet of 6 octet sequence, see comments for 5 octet sequence. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 1) << 30; + $mState = 5; + $mBytes = 6; + } + else + { + /* + * Current octet is neither in the US-ASCII range nor a legal first + * octet of a multi-octet sequence. + */ + return false; + } + } + else + { + // When mState is non-zero, we expect a continuation of the multi-octet + // sequence + if (0x80 == (0xC0 & ($in))) + { + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + /** + * End of the multi-octet sequence. mUcs4 now contains the final + * Unicode codepoint to be output + */ + if (0 == --$mState) + { + /* + * Check for illegal sequences and codepoints. + */ + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || ((3 == $mBytes) && ($mUcs4 < 0x0800)) || ((4 == $mBytes) && ($mUcs4 < 0x10000)) + || (4 < $mBytes) + || (($mUcs4 & 0xFFFFF800) == 0xD800) // From Unicode 3.2, surrogate characters are illegal + || ($mUcs4 > 0x10FFFF)) // Codepoints outside the Unicode range are illegal + { + return false; + } + + // Initialize UTF8 cache. + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + } + } + else + { + /** + *((0xC0 & (*in) != 0x80) && (mState != 0)) + * Incomplete multi-octet sequence. + */ + return false; + } + } + } + + return true; + } + + /** + * Tests whether a string complies as UTF-8. This will be much + * faster than utf8_is_valid but will pass five and six octet + * UTF-8 sequences, which are not supported by Unicode and + * so cannot be displayed correctly in a browser. In other words + * it is not as strict as utf8_is_valid but it's faster. If you use + * it to validate user input, you place yourself at the risk that + * attackers will be able to inject 5 and 6 byte sequences (which + * may or may not be a significant risk, depending on what you are + * are doing) + * + * @param string $str UTF-8 string to check + * + * @return boolean TRUE if string is valid UTF-8 + * + * @see valid + * @see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#54805 + * @since 1.0 + */ + public static function compliant($str) + { + if (strlen($str) == 0) + { + return true; + } + + /* + * If even just the first character can be matched, when the /u + * modifier is used, then it's valid UTF-8. If the UTF-8 is somehow + * invalid, nothing at all will match, even if the string contains + * some valid sequences + */ + return (preg_match('/^.{1}/us', $str, $ar) == 1); + } + + /** + * Converts Unicode sequences to UTF-8 string + * + * @param string $str Unicode string to convert + * + * @return string UTF-8 string + * + * @since 1.2.0 + */ + public static function unicode_to_utf8($str) + { + if (extension_loaded('mbstring')) + { + return preg_replace_callback( + '/\\\\u([0-9a-fA-F]{4})/', + function ($match) + { + return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); + }, + $str + ); + } + else + { + return $str; + } + } + + /** + * Converts Unicode sequences to UTF-16 string + * + * @param string $str Unicode string to convert + * + * @return string UTF-16 string + * + * @since 1.2.0 + */ + public static function unicode_to_utf16($str) + { + if (extension_loaded('mbstring')) + { + return preg_replace_callback( + '/\\\\u([0-9a-fA-F]{4})/', + function ($match) + { + return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE'); + }, + $str + ); + } + else + { + return $str; + } + } +} diff --git a/libraries/vendor/joomla/string/src/phputf8/LICENSE b/libraries/vendor/joomla/string/src/phputf8/LICENSE new file mode 100644 index 0000000000000..28f1889698245 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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/libraries/vendor/joomla/string/src/phputf8/README b/libraries/vendor/joomla/string/src/phputf8/README new file mode 100644 index 0000000000000..6c30905418608 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/README @@ -0,0 +1,82 @@ +++PHP UTF-8++ + +Version 0.5 + +++DOCUMENTATION++ + +Documentation in progress in ./docs dir + +http://www.phpwact.org/php/i18n/charsets +http://www.phpwact.org/php/i18n/utf-8 + +Important Note: DO NOT use these functions without understanding WHY +you are using them. In particular, do not blindly replace all use of PHP's +string functions which functions found here - most of the time you will +not need to, and you will be introducing a significant performance +overhead to your application. You can get a good idea of when to use what +from reading: http://www.phpwact.org/php/i18n/utf-8 + +Important Note: For sake of performance most of the functions here are +not "defensive" (e.g. there is not extensive parameter checking, well +formed UTF-8 is assumed). This is particularily relevant when is comes to +catching badly formed UTF-8 - you should screen input on the "outer +perimeter" with help from functions in the utf8_validation.php and +utf8_bad.php files. + +Important Note: this library treats ALL ASCII characters as valid, including ASCII control characters. But if you use some ASCII control characters in XML, it will render the XML ill-formed. Don't be a bozo: http://hsivonen.iki.fi/producing-xml/#controlchar + +++BUGS / SUPPORT / FEATURE REQUESTS ++ + +Please report bugs to: +http://sourceforge.net/tracker/?group_id=142846&atid=753842 +- if you are able, please submit a failing unit test +(http://www.lastcraft.com/simple_test.php) with your bug report. + +For feature requests / faster implementation of functions found here, +please drop them in via the RFE tracker: http://sourceforge.net/tracker/?group_id=142846&atid=753845 +Particularily interested in faster implementations! + +For general support / help, use: +http://sourceforge.net/tracker/?group_id=142846&atid=753843 + +In the VERY WORST case, you can email me: hfuecks gmail com - I tend to be slow to respond though so be warned. + +Important Note: when reporting bugs, please provide the following +information; + +PHP version, whether the iconv extension is loaded (in PHP5 it's +there by default), whether the mbstring extension is loaded. The +following PHP script can be used to determine this information; + +"; +if ( extension_loaded('mbstring') ) { + print "mbstring available
"; +} else { + print "mbstring not available
"; +} +if ( extension_loaded('iconv') ) { + print "iconv available
"; +} else { + print "iconv not available
"; +} +?> + +++LICENSING++ + +Parts of the code in this library come from other places, under different +licenses. +The authors involved have been contacted (see below). Attribution for +which code came from elsewhere can be found in the source code itself. + ++Andreas Gohr / Chris Smith - Dokuwiki +There is a fair degree of collaboration / exchange of ideas and code +beteen Dokuwiki's UTF-8 library; +http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +and phputf8. Although Dokuwiki is released under GPL, its UTF-8 +library is released under LGPL, hence no conflict with phputf8 + ++Henri Sivonen (http://hsivonen.iki.fi/php-utf8/ / +http://hsivonen.iki.fi/php-utf8/) has also given permission for his +code to be released under the terms of the LGPL. He ported a Unicode / UTF-8 +converter from the Mozilla codebase to PHP, which is re-used in phputf8 diff --git a/libraries/vendor/joomla/string/src/phputf8/mbstring/core.php b/libraries/vendor/joomla/string/src/phputf8/mbstring/core.php new file mode 100644 index 0000000000000..6cb5501d7b8ce --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/mbstring/core.php @@ -0,0 +1,132 @@ + +* @link http://www.php.net/manual/en/function.strlen.php +* @link http://www.php.net/manual/en/function.utf8-decode.php +* @param string UTF-8 string +* @return int number of UTF-8 characters in string +* @package utf8 +*/ +function utf8_strlen($str){ + return strlen(utf8_decode($str)); +} + + +//-------------------------------------------------------------------- +/** +* UTF-8 aware alternative to strpos +* Find position of first occurrence of a string +* Note: This will get alot slower if offset is used +* Note: requires utf8_strlen amd utf8_substr to be loaded +* @param string haystack +* @param string needle (you should validate this with utf8_is_valid) +* @param integer offset in characters (from left) +* @return mixed integer position or FALSE on failure +* @see http://www.php.net/strpos +* @see utf8_strlen +* @see utf8_substr +* @package utf8 +*/ +function utf8_strpos($str, $needle, $offset = NULL) { + + if ( is_null($offset) ) { + + $ar = explode($needle, $str, 2); + if ( count($ar) > 1 ) { + return utf8_strlen($ar[0]); + } + return FALSE; + + } else { + + if ( !is_int($offset) ) { + trigger_error('utf8_strpos: Offset must be an integer',E_USER_ERROR); + return FALSE; + } + + $str = utf8_substr($str, $offset); + + if ( FALSE !== ( $pos = utf8_strpos($str, $needle) ) ) { + return $pos + $offset; + } + + return FALSE; + } + +} + +//-------------------------------------------------------------------- +/** +* UTF-8 aware alternative to strrpos +* Find position of last occurrence of a char in a string +* Note: This will get alot slower if offset is used +* Note: requires utf8_substr and utf8_strlen to be loaded +* @param string haystack +* @param string needle (you should validate this with utf8_is_valid) +* @param integer (optional) offset (from left) +* @return mixed integer position or FALSE on failure +* @see http://www.php.net/strrpos +* @see utf8_substr +* @see utf8_strlen +* @package utf8 +*/ +function utf8_strrpos($str, $needle, $offset = NULL) { + + if ( is_null($offset) ) { + + $ar = explode($needle, $str); + + if ( count($ar) > 1 ) { + // Pop off the end of the string where the last match was made + array_pop($ar); + $str = join($needle,$ar); + return utf8_strlen($str); + } + return FALSE; + + } else { + + if ( !is_int($offset) ) { + trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING); + return FALSE; + } + + $str = utf8_substr($str, $offset); + + if ( FALSE !== ( $pos = utf8_strrpos($str, $needle) ) ) { + return $pos + $offset; + } + + return FALSE; + } + +} + +//-------------------------------------------------------------------- +/** +* UTF-8 aware alternative to substr +* Return part of a string given character offset (and optionally length) +* +* Note arguments: comparied to substr - if offset or length are +* not integers, this version will not complain but rather massages them +* into an integer. +* +* Note on returned values: substr documentation states false can be +* returned in some cases (e.g. offset > string length) +* mb_substr never returns false, it will return an empty string instead. +* This adopts the mb_substr approach +* +* Note on implementation: PCRE only supports repetitions of less than +* 65536, in order to accept up to MAXINT values for offset and length, +* we'll repeat a group of 65535 characters when needed. +* +* Note on implementation: calculating the number of characters in the +* string is a relatively expensive operation, so we only carry it out when +* necessary. It isn't necessary for +ve offsets and no specified length +* +* @author Chris Smith +* @param string +* @param integer number of UTF-8 characters offset (from left) +* @param integer (optional) length in UTF-8 characters from offset +* @return mixed string or FALSE if failure +* @package utf8 +*/ +function utf8_substr($str, $offset, $length = NULL) { + + // generates E_NOTICE + // for PHP4 objects, but not PHP5 objects + $str = (string)$str; + $offset = (int)$offset; + if (!is_null($length)) $length = (int)$length; + + // handle trivial cases + if ($length === 0) return ''; + if ($offset < 0 && $length < 0 && $length < $offset) + return ''; + + // normalise negative offsets (we could use a tail + // anchored pattern, but they are horribly slow!) + if ($offset < 0) { + + // see notes + $strlen = strlen(utf8_decode($str)); + $offset = $strlen + $offset; + if ($offset < 0) $offset = 0; + + } + + $Op = ''; + $Lp = ''; + + // establish a pattern for offset, a + // non-captured group equal in length to offset + if ($offset > 0) { + + $Ox = (int)($offset/65535); + $Oy = $offset%65535; + + if ($Ox) { + $Op = '(?:.{65535}){'.$Ox.'}'; + } + + $Op = '^(?:'.$Op.'.{'.$Oy.'})'; + + } else { + + // offset == 0; just anchor the pattern + $Op = '^'; + + } + + // establish a pattern for length + if (is_null($length)) { + + // the rest of the string + $Lp = '(.*)$'; + + } else { + + if (!isset($strlen)) { + // see notes + $strlen = strlen(utf8_decode($str)); + } + + // another trivial case + if ($offset > $strlen) return ''; + + if ($length > 0) { + + // reduce any length that would + // go passed the end of the string + $length = min($strlen-$offset, $length); + + $Lx = (int)( $length / 65535 ); + $Ly = $length % 65535; + + // negative length requires a captured group + // of length characters + if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}'; + $Lp = '('.$Lp.'.{'.$Ly.'})'; + + } else if ($length < 0) { + + if ( $length < ($offset - $strlen) ) { + return ''; + } + + $Lx = (int)((-$length)/65535); + $Ly = (-$length)%65535; + + // negative length requires ... capture everything + // except a group of -length characters + // anchored at the tail-end of the string + if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}'; + $Lp = '(.*)(?:'.$Lp.'.{'.$Ly.'})$'; + + } + + } + + if (!preg_match( '#'.$Op.$Lp.'#us',$str, $match )) { + return ''; + } + + return $match[1]; + +} + +//--------------------------------------------------------------- +/** +* UTF-8 aware alternative to strtolower +* Make a string lowercase +* Note: The concept of a characters "case" only exists is some alphabets +* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does +* not exist in the Chinese alphabet, for example. See Unicode Standard +* Annex #21: Case Mappings +* Note: requires utf8_to_unicode and utf8_from_unicode +* @author Andreas Gohr +* @param string +* @return mixed either string in lowercase or FALSE is UTF-8 invalid +* @see http://www.php.net/strtolower +* @see utf8_to_unicode +* @see utf8_from_unicode +* @see http://www.unicode.org/reports/tr21/tr21-5.html +* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +* @package utf8 +*/ +function utf8_strtolower($string){ + + static $UTF8_UPPER_TO_LOWER = NULL; + + if ( is_null($UTF8_UPPER_TO_LOWER) ) { + $UTF8_UPPER_TO_LOWER = array( + 0x0041=>0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163, 0x00C5=>0x00E5, 0x0042=>0x0062, + 0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142, 0x038E=>0x03CD, 0x0100=>0x0101, + 0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B, 0x0044=>0x0064, 0x0393=>0x03B3, + 0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439, 0x0112=>0x0113, 0x041C=>0x043C, + 0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE, 0x040E=>0x045E, 0x042F=>0x044F, + 0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069, 0x0053=>0x0073, 0x1E1E=>0x1E1F, + 0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0, 0x0418=>0x0438, 0x00D3=>0x00F3, + 0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435, 0x0429=>0x0449, 0x014A=>0x014B, + 0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03, 0x00D6=>0x00F6, 0x00D9=>0x00F9, + 0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4, 0x0423=>0x0443, 0x015C=>0x015D, + 0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159, 0x0047=>0x0067, 0x00C4=>0x00E4, + 0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167, 0x039E=>0x03BE, 0x0164=>0x0165, + 0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076, 0x00DE=>0x00FE, 0x0156=>0x0157, + 0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83, 0x00C2=>0x00E2, 0x0118=>0x0119, + 0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151, 0x042E=>0x044E, 0x0128=>0x0129, + 0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442, 0x005A=>0x007A, 0x0428=>0x0448, + 0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D, 0x00D5=>0x00F5, 0x0055=>0x0075, + 0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57, 0x03A3=>0x03C3, 0x041A=>0x043A, + 0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171, 0x0424=>0x0444, 0x00CC=>0x00EC, + 0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B, 0x00D2=>0x00F2, 0x00C0=>0x00E0, + 0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B, 0x00C3=>0x00E3, 0x042D=>0x044D, + 0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D, 0x011C=>0x011D, 0x00D0=>0x00F0, + 0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A, 0x00C8=>0x00E8, 0x03A5=>0x03C5, + 0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063, 0x021A=>0x021B, 0x00CA=>0x00EA, + 0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF, 0x01AF=>0x01B0, 0x0045=>0x0065, + 0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC, 0x040C=>0x045C, 0x041F=>0x043F, + 0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0, 0x1EF2=>0x1EF3, 0x0048=>0x0068, + 0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433, 0x012E=>0x012F, 0x00C6=>0x00E6, + 0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F, 0x0391=>0x03B1, 0x0407=>0x0457, + 0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F, 0x041B=>0x043B, 0x0395=>0x03B5, + 0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E, 0x017B=>0x017C, 0x0396=>0x03B6, + 0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85, 0x0174=>0x0175, 0x0051=>0x0071, + 0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148, 0x0104=>0x0105, 0x0408=>0x0458, + 0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079, 0x010A=>0x010B, 0x038F=>0x03CE, + 0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455, 0x0402=>0x0452, 0x0126=>0x0127, + 0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF, 0x042B=>0x044B, 0x004C=>0x006C, + 0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219, 0x00DB=>0x00FB, 0x011E=>0x011F, + 0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD, 0x0106=>0x0107, 0x03AB=>0x03CB, + 0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7, 0x03AA=>0x03CA, 0x0421=>0x0441, + 0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8, 0x0057=>0x0077, 0x011A=>0x011B, + 0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B, 0x0406=>0x0456, 0x0102=>0x0103, + 0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D, 0x038C=>0x03CC, 0x00C9=>0x00E9, + 0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123, + ); + } + + $uni = utf8_to_unicode($string); + + if ( !$uni ) { + return FALSE; + } + + $cnt = count($uni); + for ($i=0; $i < $cnt; $i++){ + if ( isset($UTF8_UPPER_TO_LOWER[$uni[$i]]) ) { + $uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]]; + } + } + + return utf8_from_unicode($uni); +} + +//--------------------------------------------------------------- +/** +* UTF-8 aware alternative to strtoupper +* Make a string uppercase +* Note: The concept of a characters "case" only exists is some alphabets +* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does +* not exist in the Chinese alphabet, for example. See Unicode Standard +* Annex #21: Case Mappings +* Note: requires utf8_to_unicode and utf8_from_unicode +* @author Andreas Gohr +* @param string +* @return mixed either string in lowercase or FALSE is UTF-8 invalid +* @see http://www.php.net/strtoupper +* @see utf8_to_unicode +* @see utf8_from_unicode +* @see http://www.unicode.org/reports/tr21/tr21-5.html +* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +* @package utf8 +*/ +function utf8_strtoupper($string){ + + static $UTF8_LOWER_TO_UPPER = NULL; + + if ( is_null($UTF8_LOWER_TO_UPPER) ) { + $UTF8_LOWER_TO_UPPER = array( + 0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042, + 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100, + 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393, + 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C, + 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F, + 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E, + 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3, + 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A, + 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9, + 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C, + 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4, + 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164, + 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156, + 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118, + 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128, + 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428, + 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055, + 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A, + 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC, + 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0, + 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D, + 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0, + 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5, + 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA, + 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045, + 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F, + 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048, + 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6, + 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407, + 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395, + 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396, + 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051, + 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408, + 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F, + 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126, + 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C, + 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E, + 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB, + 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421, + 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A, + 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102, + 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9, + 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122, + ); + } + + $uni = utf8_to_unicode($string); + + if ( !$uni ) { + return FALSE; + } + + $cnt = count($uni); + for ($i=0; $i < $cnt; $i++){ + if( isset($UTF8_LOWER_TO_UPPER[$uni[$i]]) ) { + $uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]]; + } + } + + return utf8_from_unicode($uni); +} diff --git a/libraries/vendor/joomla/string/src/phputf8/ord.php b/libraries/vendor/joomla/string/src/phputf8/ord.php new file mode 100644 index 0000000000000..449fe313fcf03 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/ord.php @@ -0,0 +1,90 @@ += 0 && $ord0 <= 127 ) { + return $ord0; + } + + if ( !isset($chr{1}) ) { + trigger_error('Short sequence - at least 2 bytes expected, only 1 seen'); + return FALSE; + } + + $ord1 = ord($chr{1}); + if ( $ord0 >= 192 && $ord0 <= 223 ) { + return ( $ord0 - 192 ) * 64 + + ( $ord1 - 128 ); + } + + if ( !isset($chr{2}) ) { + trigger_error('Short sequence - at least 3 bytes expected, only 2 seen'); + return FALSE; + } + $ord2 = ord($chr{2}); + if ( $ord0 >= 224 && $ord0 <= 239 ) { + return ($ord0-224)*4096 + + ($ord1-128)*64 + + ($ord2-128); + } + + if ( !isset($chr{3}) ) { + trigger_error('Short sequence - at least 4 bytes expected, only 3 seen'); + return FALSE; + } + $ord3 = ord($chr{3}); + if ($ord0>=240 && $ord0<=247) { + return ($ord0-240)*262144 + + ($ord1-128)*4096 + + ($ord2-128)*64 + + ($ord3-128); + + } + + if ( !isset($chr{4}) ) { + trigger_error('Short sequence - at least 5 bytes expected, only 4 seen'); + return FALSE; + } + $ord4 = ord($chr{4}); + if ($ord0>=248 && $ord0<=251) { + return ($ord0-248)*16777216 + + ($ord1-128)*262144 + + ($ord2-128)*4096 + + ($ord3-128)*64 + + ($ord4-128); + } + + if ( !isset($chr{5}) ) { + trigger_error('Short sequence - at least 6 bytes expected, only 5 seen'); + return FALSE; + } + if ($ord0>=252 && $ord0<=253) { + return ($ord0-252) * 1073741824 + + ($ord1-128)*16777216 + + ($ord2-128)*262144 + + ($ord3-128)*4096 + + ($ord4-128)*64 + + (ord($chr{5})-128); + } + + if ( $ord0 >= 254 && $ord0 <= 255 ) { + trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0); + return FALSE; + } + +} + diff --git a/libraries/vendor/joomla/string/src/phputf8/str_ireplace.php b/libraries/vendor/joomla/string/src/phputf8/str_ireplace.php new file mode 100644 index 0000000000000..c4b4df8d67e90 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/str_ireplace.php @@ -0,0 +1,77 @@ + +* @param string $input +* @param int $length +* @param string $padStr +* @param int $type ( same constants as str_pad ) +* @return string +* @see http://www.php.net/str_pad +* @see utf8_substr +* @package utf8 +*/ +function utf8_str_pad($input, $length, $padStr = ' ', $type = STR_PAD_RIGHT) { + + $inputLen = utf8_strlen($input); + if ($length <= $inputLen) { + return $input; + } + + $padStrLen = utf8_strlen($padStr); + $padLen = $length - $inputLen; + + if ($type == STR_PAD_RIGHT) { + $repeatTimes = ceil($padLen / $padStrLen); + return utf8_substr($input . str_repeat($padStr, $repeatTimes), 0, $length); + } + + if ($type == STR_PAD_LEFT) { + $repeatTimes = ceil($padLen / $padStrLen); + return utf8_substr(str_repeat($padStr, $repeatTimes), 0, floor($padLen)) . $input; + } + + if ($type == STR_PAD_BOTH) { + + $padLen/= 2; + $padAmountLeft = floor($padLen); + $padAmountRight = ceil($padLen); + $repeatTimesLeft = ceil($padAmountLeft / $padStrLen); + $repeatTimesRight = ceil($padAmountRight / $padStrLen); + + $paddingLeft = utf8_substr(str_repeat($padStr, $repeatTimesLeft), 0, $padAmountLeft); + $paddingRight = utf8_substr(str_repeat($padStr, $repeatTimesRight), 0, $padAmountLeft); + return $paddingLeft . $input . $paddingRight; + } + + trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')',E_USER_ERROR); +} diff --git a/libraries/vendor/joomla/string/src/phputf8/str_split.php b/libraries/vendor/joomla/string/src/phputf8/str_split.php new file mode 100644 index 0000000000000..13b93d517b96e --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/str_split.php @@ -0,0 +1,32 @@ + +* @see http://www.php.net/ltrim +* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +* @return string +* @package utf8 +*/ +function utf8_ltrim( $str, $charlist = FALSE ) { + if($charlist === FALSE) return ltrim($str); + + //quote charlist for use in a characterclass + $charlist = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$charlist); + + return preg_replace('/^['.$charlist.']+/u','',$str); +} + +//--------------------------------------------------------------- +/** +* UTF-8 aware replacement for rtrim() +* Note: you only need to use this if you are supplying the charlist +* optional arg and it contains UTF-8 characters. Otherwise rtrim will +* work normally on a UTF-8 string +* @author Andreas Gohr +* @see http://www.php.net/rtrim +* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +* @return string +* @package utf8 +*/ +function utf8_rtrim( $str, $charlist = FALSE ) { + if($charlist === FALSE) return rtrim($str); + + //quote charlist for use in a characterclass + $charlist = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$charlist); + + return preg_replace('/['.$charlist.']+$/u','',$str); +} + +//--------------------------------------------------------------- +/** +* UTF-8 aware replacement for trim() +* Note: you only need to use this if you are supplying the charlist +* optional arg and it contains UTF-8 characters. Otherwise trim will +* work normally on a UTF-8 string +* @author Andreas Gohr +* @see http://www.php.net/trim +* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php +* @return string +* @package utf8 +*/ +function utf8_trim( $str, $charlist = FALSE ) { + if($charlist === FALSE) return trim($str); + return utf8_ltrim(utf8_rtrim($str, $charlist), $charlist); +} diff --git a/libraries/vendor/joomla/string/src/phputf8/ucfirst.php b/libraries/vendor/joomla/string/src/phputf8/ucfirst.php new file mode 100644 index 0000000000000..7f7ae9ecab9e5 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/ucfirst.php @@ -0,0 +1,31 @@ + +* if ( utf8_is_ascii($someString) ) { +* // It's just ASCII - use the native PHP version +* $someString = strtolower($someString); +* } else { +* $someString = utf8_strtolower($someString); +* } +* +* +* @param string +* @return boolean TRUE if it's all ASCII +* @package utf8 +* @see utf8_is_ascii_ctrl +*/ +function utf8_is_ascii($str) { + // Search for any bytes which are outside the ASCII range... + return (preg_match('/(?:[^\x00-\x7F])/',$str) !== 1); +} + +//-------------------------------------------------------------------- +/** +* Tests whether a string contains only 7bit ASCII bytes with device +* control codes omitted. The device control codes can be found on the +* second table here: http://www.w3schools.com/tags/ref_ascii.asp +* +* @param string +* @return boolean TRUE if it's all ASCII without device control codes +* @package utf8 +* @see utf8_is_ascii +*/ +function utf8_is_ascii_ctrl($str) { + if ( strlen($str) > 0 ) { + // Search for any bytes which are outside the ASCII range, + // or are device control codes + return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !== 1); + } + return FALSE; +} + +//-------------------------------------------------------------------- +/** +* Strip out all non-7bit ASCII bytes +* If you need to transmit a string to system which you know can only +* support 7bit ASCII, you could use this function. +* @param string +* @return string with non ASCII bytes removed +* @package utf8 +* @see utf8_strip_non_ascii_ctrl +*/ +function utf8_strip_non_ascii($str) { + ob_start(); + while ( preg_match( + '/^([\x00-\x7F]+)|([^\x00-\x7F]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Strip out device control codes in the ASCII range +* which are not permitted in XML. Note that this leaves +* multi-byte characters untouched - it only removes device +* control codes +* @see http://hsivonen.iki.fi/producing-xml/#controlchar +* @param string +* @return string control codes removed +*/ +function utf8_strip_ascii_ctrl($str) { + ob_start(); + while ( preg_match( + '/^([^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)|([\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Strip out all non 7bit ASCII bytes and ASCII device control codes. +* For a list of ASCII device control codes see the 2nd table here: +* http://www.w3schools.com/tags/ref_ascii.asp +* +* @param string +* @return boolean TRUE if it's all ASCII +* @package utf8 +*/ +function utf8_strip_non_ascii_ctrl($str) { + ob_start(); + while ( preg_match( + '/^([\x09\x0A\x0D\x20-\x7E]+)|([^\x09\x0A\x0D\x20-\x7E]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//--------------------------------------------------------------- +/** +* Replace accented UTF-8 characters by unaccented ASCII-7 "equivalents". +* The purpose of this function is to replace characters commonly found in Latin +* alphabets with something more or less equivalent from the ASCII range. This can +* be useful for converting a UTF-8 to something ready for a filename, for example. +* Following the use of this function, you would probably also pass the string +* through utf8_strip_non_ascii to clean out any other non-ASCII chars +* Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1) +* letters. Default is to deaccent both cases ($case = 0) +* +* For a more complete implementation of transliteration, see the utf8_to_ascii package +* available from the phputf8 project downloads: +* http://prdownloads.sourceforge.net/phputf8 +* +* @param string UTF-8 string +* @param int (optional) -1 lowercase only, +1 uppercase only, 1 both cases +* @param string UTF-8 with accented characters replaced by ASCII chars +* @return string accented chars replaced with ascii equivalents +* @author Andreas Gohr +* @package utf8 +*/ +function utf8_accents_to_ascii( $str, $case=0 ){ + + static $UTF8_LOWER_ACCENTS = NULL; + static $UTF8_UPPER_ACCENTS = NULL; + + if($case <= 0){ + + if ( is_null($UTF8_LOWER_ACCENTS) ) { + $UTF8_LOWER_ACCENTS = array( + 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o', + 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k', + 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o', + 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o', + 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c', + 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't', + 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l', + 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z', + 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't', + 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', + 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j', + 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o', + 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g', + 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', + 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e', + ); + } + + $str = str_replace( + array_keys($UTF8_LOWER_ACCENTS), + array_values($UTF8_LOWER_ACCENTS), + $str + ); + } + + if($case >= 0){ + if ( is_null($UTF8_UPPER_ACCENTS) ) { + $UTF8_UPPER_ACCENTS = array( + 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O', + 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K', + 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O', + 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O', + 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C', + 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T', + 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L', + 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z', + 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T', + 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O', + 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J', + 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O', + 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G', + 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A', + 'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae', 'Ĕ' => 'E', + ); + } + $str = str_replace( + array_keys($UTF8_UPPER_ACCENTS), + array_values($UTF8_UPPER_ACCENTS), + $str + ); + } + + return $str; + +} diff --git a/libraries/vendor/joomla/string/src/phputf8/utils/bad.php b/libraries/vendor/joomla/string/src/phputf8/utils/bad.php new file mode 100644 index 0000000000000..e8b8f117758e0 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/utils/bad.php @@ -0,0 +1,406 @@ + 0 ) { + return $badList; + } + return FALSE; +} + +//-------------------------------------------------------------------- +/** +* Strips out any bad bytes from a UTF-8 string and returns the rest +* PCRE Pattern to locate bad bytes in a UTF-8 string +* Comes from W3 FAQ: Multilingual Forms +* Note: modified to include full ASCII range including control chars +* @see http://www.w3.org/International/questions/qa-forms-utf-8 +* @param string +* @return string +* @package utf8 +*/ +function utf8_bad_strip($str) { + $UTF8_BAD = + '([\x00-\x7F]'. # ASCII (including control chars) + '|[\xC2-\xDF][\x80-\xBF]'. # non-overlong 2-byte + '|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding overlongs + '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte + '|\xED[\x80-\x9F][\x80-\xBF]'. # excluding surrogates + '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3 + '|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15 + '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16 + '|(.{1}))'; # invalid byte + ob_start(); + while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) { + if ( !isset($matches[2])) { + echo $matches[0]; + } + $str = substr($str,strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Replace bad bytes with an alternative character - ASCII character +* recommended is replacement char +* PCRE Pattern to locate bad bytes in a UTF-8 string +* Comes from W3 FAQ: Multilingual Forms +* Note: modified to include full ASCII range including control chars +* @see http://www.w3.org/International/questions/qa-forms-utf-8 +* @param string to search +* @param string to replace bad bytes with (defaults to '?') - use ASCII +* @return string +* @package utf8 +*/ +function utf8_bad_replace($str, $replace = '?') { + $UTF8_BAD = + '([\x00-\x7F]'. # ASCII (including control chars) + '|[\xC2-\xDF][\x80-\xBF]'. # non-overlong 2-byte + '|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding overlongs + '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte + '|\xED[\x80-\x9F][\x80-\xBF]'. # excluding surrogates + '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3 + '|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15 + '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16 + '|(.{1}))'; # invalid byte + ob_start(); + while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) { + if ( !isset($matches[2])) { + echo $matches[0]; + } else { + echo $replace; + } + $str = substr($str,strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Return code from utf8_bad_identify() when a five octet sequence is detected. +* Note: 5 octets sequences are valid UTF-8 but are not supported by Unicode so +* do not represent a useful character +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_5OCTET',1); + +/** +* Return code from utf8_bad_identify() when a six octet sequence is detected. +* Note: 6 octets sequences are valid UTF-8 but are not supported by Unicode so +* do not represent a useful character +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_6OCTET',2); + +/** +* Return code from utf8_bad_identify(). +* Invalid octet for use as start of multi-byte UTF-8 sequence +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_SEQID',3); + +/** +* Return code from utf8_bad_identify(). +* From Unicode 3.1, non-shortest form is illegal +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_NONSHORT',4); + +/** +* Return code from utf8_bad_identify(). +* From Unicode 3.2, surrogate characters are illegal +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_SURROGATE',5); + +/** +* Return code from utf8_bad_identify(). +* Codepoints outside the Unicode range are illegal +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_UNIOUTRANGE',6); + +/** +* Return code from utf8_bad_identify(). +* Incomplete multi-octet sequence +* Note: this is kind of a "catch-all" +* @see utf8_bad_identify +* @package utf8 +*/ +define('UTF8_BAD_SEQINCOMPLETE',7); + +//-------------------------------------------------------------------- +/** +* Reports on the type of bad byte found in a UTF-8 string. Returns a +* status code on the first bad byte found +* @author +* @param string UTF-8 encoded string +* @return mixed integer constant describing problem or FALSE if valid UTF-8 +* @see utf8_bad_explain +* @see http://hsivonen.iki.fi/php-utf8/ +* @package utf8 +*/ +function utf8_bad_identify($str, &$i) { + + $mState = 0; // cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mUcs4 = 0; // cached Unicode character + $mBytes = 1; // cached expected number of octets in the current sequence + + $len = strlen($str); + + for($i = 0; $i < $len; $i++) { + + $in = ord($str{$i}); + + if ( $mState == 0) { + + // When mState is zero we expect either a US-ASCII character or a + // multi-octet sequence. + if (0 == (0x80 & ($in))) { + // US-ASCII, pass straight through. + $mBytes = 1; + + } else if (0xC0 == (0xE0 & ($in))) { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + + } else if (0xE0 == (0xF0 & ($in))) { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + + } else if (0xF0 == (0xF8 & ($in))) { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + + } else if (0xF8 == (0xFC & ($in))) { + + /* First octet of 5 octet sequence. + * + * This is illegal because the encoded codepoint must be either + * (a) not the shortest form or + * (b) outside the Unicode range of 0-0x10FFFF. + */ + + return UTF8_BAD_5OCTET; + + } else if (0xFC == (0xFE & ($in))) { + + // First octet of 6 octet sequence, see comments for 5 octet sequence. + return UTF8_BAD_6OCTET; + + } else { + // Current octet is neither in the US-ASCII range nor a legal first + // octet of a multi-octet sequence. + return UTF8_BAD_SEQID; + + } + + } else { + + // When mState is non-zero, we expect a continuation of the multi-octet + // sequence + if (0x80 == (0xC0 & ($in))) { + + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + /** + * End of the multi-octet sequence. mUcs4 now contains the final + * Unicode codepoint to be output + */ + if (0 == --$mState) { + + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || + ((3 == $mBytes) && ($mUcs4 < 0x0800)) || + ((4 == $mBytes) && ($mUcs4 < 0x10000)) ) { + return UTF8_BAD_NONSHORT; + + // From Unicode 3.2, surrogate characters are illegal + } else if (($mUcs4 & 0xFFFFF800) == 0xD800) { + return UTF8_BAD_SURROGATE; + + // Codepoints outside the Unicode range are illegal + } else if ($mUcs4 > 0x10FFFF) { + return UTF8_BAD_UNIOUTRANGE; + } + + //initialize UTF8 cache + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + } + + } else { + // ((0xC0 & (*in) != 0x80) && (mState != 0)) + // Incomplete multi-octet sequence. + $i--; + return UTF8_BAD_SEQINCOMPLETE; + } + } + } + + if ( $mState != 0 ) { + // Incomplete multi-octet sequence. + $i--; + return UTF8_BAD_SEQINCOMPLETE; + } + + // No bad octets found + $i = NULL; + return FALSE; +} + +//-------------------------------------------------------------------- +/** +* Takes a return code from utf8_bad_identify() are returns a message +* (in English) explaining what the problem is. +* @param int return code from utf8_bad_identify +* @return mixed string message or FALSE if return code unknown +* @see utf8_bad_identify +* @package utf8 +*/ +function utf8_bad_explain($code) { + + switch ($code) { + + case UTF8_BAD_5OCTET: + return 'Five octet sequences are valid UTF-8 but are not supported by Unicode'; + break; + + case UTF8_BAD_6OCTET: + return 'Six octet sequences are valid UTF-8 but are not supported by Unicode'; + break; + + case UTF8_BAD_SEQID: + return 'Invalid octet for use as start of multi-byte UTF-8 sequence'; + break; + + case UTF8_BAD_NONSHORT: + return 'From Unicode 3.1, non-shortest form is illegal'; + break; + + case UTF8_BAD_SURROGATE: + return 'From Unicode 3.2, surrogate characters are illegal'; + break; + + case UTF8_BAD_UNIOUTRANGE: + return 'Codepoints outside the Unicode range are illegal'; + break; + + case UTF8_BAD_SEQINCOMPLETE: + return 'Incomplete multi-octet sequence'; + break; + + } + + trigger_error('Unknown error code: '.$code,E_USER_WARNING); + return FALSE; + +} diff --git a/libraries/vendor/joomla/string/src/phputf8/utils/patterns.php b/libraries/vendor/joomla/string/src/phputf8/utils/patterns.php new file mode 100644 index 0000000000000..0ed8346337795 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/utils/patterns.php @@ -0,0 +1,64 @@ + +* @param string string to locate index in +* @param int (n times) +* @return mixed - int if only one input int, array if more +* @return boolean TRUE if it's all ASCII +* @package utf8 +*/ +function utf8_byte_position() { + + $args = func_get_args(); + $str =& array_shift($args); + if (!is_string($str)) return false; + + $result = array(); + + // trivial byte index, character offset pair + $prev = array(0,0); + + // use a short piece of str to estimate bytes per character + // $i (& $j) -> byte indexes into $str + $i = utf8_locate_next_chr($str, 300); + + // $c -> character offset into $str + $c = strlen(utf8_decode(substr($str,0,$i))); + + // deal with arguments from lowest to highest + sort($args); + + foreach ($args as $offset) { + // sanity checks FIXME + + // 0 is an easy check + if ($offset == 0) { $result[] = 0; continue; } + + // ensure no endless looping + $safety_valve = 50; + + do { + + if ( ($c - $prev[1]) == 0 ) { + // Hack: gone past end of string + $error = 0; + $i = strlen($str); + break; + } + + $j = $i + (int)(($offset-$c) * ($i - $prev[0]) / ($c - $prev[1])); + + // correct to utf8 character boundary + $j = utf8_locate_next_chr($str, $j); + + // save the index, offset for use next iteration + $prev = array($i,$c); + + if ($j > $i) { + // determine new character offset + $c += strlen(utf8_decode(substr($str,$i,$j-$i))); + } else { + // ditto + $c -= strlen(utf8_decode(substr($str,$j,$i-$j))); + } + + $error = abs($c-$offset); + + // ready for next time around + $i = $j; + + // from 7 it is faster to iterate over the string + } while ( ($error > 7) && --$safety_valve) ; + + if ($error && $error <= 7) { + + if ($c < $offset) { + // move up + while ($error--) { $i = utf8_locate_next_chr($str,++$i); } + } else { + // move down + while ($error--) { $i = utf8_locate_current_chr($str,--$i); } + } + + // ready for next arg + $c = $offset; + } + $result[] = $i; + } + + if ( count($result) == 1 ) { + return $result[0]; + } + + return $result; +} + +//-------------------------------------------------------------------- +/** +* Given a string and any byte index, returns the byte index +* of the start of the current UTF-8 character, relative to supplied +* position. If the current character begins at the same place as the +* supplied byte index, that byte index will be returned. Otherwise +* this function will step backwards, looking for the index where +* curent UTF-8 character begins +* @author Chris Smith +* @param string +* @param int byte index in the string +* @return int byte index of start of next UTF-8 character +* @package utf8 +*/ +function utf8_locate_current_chr( &$str, $idx ) { + + if ($idx <= 0) return 0; + + $limit = strlen($str); + if ($idx >= $limit) return $limit; + + // Binary value for any byte after the first in a multi-byte UTF-8 character + // will be like 10xxxxxx so & 0xC0 can be used to detect this kind + // of byte - assuming well formed UTF-8 + while ($idx && ((ord($str[$idx]) & 0xC0) == 0x80)) $idx--; + + return $idx; +} + +//-------------------------------------------------------------------- +/** +* Given a string and any byte index, returns the byte index +* of the start of the next UTF-8 character, relative to supplied +* position. If the next character begins at the same place as the +* supplied byte index, that byte index will be returned. +* @author Chris Smith +* @param string +* @param int byte index in the string +* @return int byte index of start of next UTF-8 character +* @package utf8 +*/ +function utf8_locate_next_chr( &$str, $idx ) { + + if ($idx <= 0) return 0; + + $limit = strlen($str); + if ($idx >= $limit) return $limit; + + // Binary value for any byte after the first in a multi-byte UTF-8 character + // will be like 10xxxxxx so & 0xC0 can be used to detect this kind + // of byte - assuming well formed UTF-8 + while (($idx < $limit) && ((ord($str[$idx]) & 0xC0) == 0x80)) $idx++; + + return $idx; +} + diff --git a/libraries/vendor/joomla/string/src/phputf8/utils/specials.php b/libraries/vendor/joomla/string/src/phputf8/utils/specials.php new file mode 100644 index 0000000000000..a53e2745e2b87 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/utils/specials.php @@ -0,0 +1,126 @@ + +* @param string $string The UTF8 string to strip of special chars +* @param string (optional) $repl Replace special with this string +* @return string with common non-alphanumeric characters removed +* @see utf8_specials_pattern +*/ +function utf8_strip_specials($string, $repl=''){ + return preg_replace(utf8_specials_pattern(), $repl, $string); +} + + diff --git a/libraries/vendor/joomla/string/src/phputf8/utils/unicode.php b/libraries/vendor/joomla/string/src/phputf8/utils/unicode.php new file mode 100644 index 0000000000000..2d561f3c2c451 --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/utils/unicode.php @@ -0,0 +1,265 @@ + 0xFFFF. Occurrances of the BOM are ignored. Surrogates +* are not allowed. +* Returns false if the input string isn't a valid UTF-8 octet sequence +* and raises a PHP error at level E_USER_WARNING +* Note: this function has been modified slightly in this library to +* trigger errors on encountering bad bytes +* @author +* @param string UTF-8 encoded string +* @return mixed array of unicode code points or FALSE if UTF-8 invalid +* @see utf8_from_unicode +* @see http://hsivonen.iki.fi/php-utf8/ +* @package utf8 +*/ +function utf8_to_unicode($str) { + $mState = 0; // cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mUcs4 = 0; // cached Unicode character + $mBytes = 1; // cached expected number of octets in the current sequence + + $out = array(); + + $len = strlen($str); + + for($i = 0; $i < $len; $i++) { + + $in = ord($str{$i}); + + if ( $mState == 0) { + + // When mState is zero we expect either a US-ASCII character or a + // multi-octet sequence. + if (0 == (0x80 & ($in))) { + // US-ASCII, pass straight through. + $out[] = $in; + $mBytes = 1; + + } else if (0xC0 == (0xE0 & ($in))) { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + + } else if (0xE0 == (0xF0 & ($in))) { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + + } else if (0xF0 == (0xF8 & ($in))) { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + + } else if (0xF8 == (0xFC & ($in))) { + /* First octet of 5 octet sequence. + * + * This is illegal because the encoded codepoint must be either + * (a) not the shortest form or + * (b) outside the Unicode range of 0-0x10FFFF. + * Rather than trying to resynchronize, we will carry on until the end + * of the sequence and let the later error handling code catch it. + */ + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x03) << 24; + $mState = 4; + $mBytes = 5; + + } else if (0xFC == (0xFE & ($in))) { + // First octet of 6 octet sequence, see comments for 5 octet sequence. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 1) << 30; + $mState = 5; + $mBytes = 6; + + } else { + /* Current octet is neither in the US-ASCII range nor a legal first + * octet of a multi-octet sequence. + */ + trigger_error( + 'utf8_to_unicode: Illegal sequence identifier '. + 'in UTF-8 at byte '.$i, + E_USER_WARNING + ); + return FALSE; + + } + + } else { + + // When mState is non-zero, we expect a continuation of the multi-octet + // sequence + if (0x80 == (0xC0 & ($in))) { + + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + /** + * End of the multi-octet sequence. mUcs4 now contains the final + * Unicode codepoint to be output + */ + if (0 == --$mState) { + + /* + * Check for illegal sequences and codepoints. + */ + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || + ((3 == $mBytes) && ($mUcs4 < 0x0800)) || + ((4 == $mBytes) && ($mUcs4 < 0x10000)) || + (4 < $mBytes) || + // From Unicode 3.2, surrogate characters are illegal + (($mUcs4 & 0xFFFFF800) == 0xD800) || + // Codepoints outside the Unicode range are illegal + ($mUcs4 > 0x10FFFF)) { + + trigger_error( + 'utf8_to_unicode: Illegal sequence or codepoint '. + 'in UTF-8 at byte '.$i, + E_USER_WARNING + ); + + return FALSE; + + } + + if (0xFEFF != $mUcs4) { + // BOM is legal but we don't want to output it + $out[] = $mUcs4; + } + + //initialize UTF8 cache + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + } + + } else { + /** + *((0xC0 & (*in) != 0x80) && (mState != 0)) + * Incomplete multi-octet sequence. + */ + trigger_error( + 'utf8_to_unicode: Incomplete multi-octet '. + ' sequence in UTF-8 at byte '.$i, + E_USER_WARNING + ); + + return FALSE; + } + } + } + return $out; +} + +//-------------------------------------------------------------------- +/** +* Takes an array of ints representing the Unicode characters and returns +* a UTF-8 string. Astral planes are supported ie. the ints in the +* input can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates +* are not allowed. +* Returns false if the input array contains ints that represent +* surrogates or are outside the Unicode range +* and raises a PHP error at level E_USER_WARNING +* Note: this function has been modified slightly in this library to use +* output buffering to concatenate the UTF-8 string (faster) as well as +* reference the array by it's keys +* @param array of unicode code points representing a string +* @return mixed UTF-8 string or FALSE if array contains invalid code points +* @author +* @see utf8_to_unicode +* @see http://hsivonen.iki.fi/php-utf8/ +* @package utf8 +*/ +function utf8_from_unicode($arr) { + ob_start(); + + foreach (array_keys($arr) as $k) { + + # ASCII range (including control chars) + if ( ($arr[$k] >= 0) && ($arr[$k] <= 0x007f) ) { + + echo chr($arr[$k]); + + # 2 byte sequence + } else if ($arr[$k] <= 0x07ff) { + + echo chr(0xc0 | ($arr[$k] >> 6)); + echo chr(0x80 | ($arr[$k] & 0x003f)); + + # Byte order mark (skip) + } else if($arr[$k] == 0xFEFF) { + + // nop -- zap the BOM + + # Test for illegal surrogates + } else if ($arr[$k] >= 0xD800 && $arr[$k] <= 0xDFFF) { + + // found a surrogate + trigger_error( + 'utf8_from_unicode: Illegal surrogate '. + 'at index: '.$k.', value: '.$arr[$k], + E_USER_WARNING + ); + + return FALSE; + + # 3 byte sequence + } else if ($arr[$k] <= 0xffff) { + + echo chr(0xe0 | ($arr[$k] >> 12)); + echo chr(0x80 | (($arr[$k] >> 6) & 0x003f)); + echo chr(0x80 | ($arr[$k] & 0x003f)); + + # 4 byte sequence + } else if ($arr[$k] <= 0x10ffff) { + + echo chr(0xf0 | ($arr[$k] >> 18)); + echo chr(0x80 | (($arr[$k] >> 12) & 0x3f)); + echo chr(0x80 | (($arr[$k] >> 6) & 0x3f)); + echo chr(0x80 | ($arr[$k] & 0x3f)); + + } else { + + trigger_error( + 'utf8_from_unicode: Codepoint out of Unicode range '. + 'at index: '.$k.', value: '.$arr[$k], + E_USER_WARNING + ); + + // out of range + return FALSE; + } + } + + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} diff --git a/libraries/vendor/joomla/string/src/phputf8/utils/validation.php b/libraries/vendor/joomla/string/src/phputf8/utils/validation.php new file mode 100644 index 0000000000000..13e180610b22d --- /dev/null +++ b/libraries/vendor/joomla/string/src/phputf8/utils/validation.php @@ -0,0 +1,181 @@ + +* @param string UTF-8 encoded string +* @return boolean true if valid +* @see http://hsivonen.iki.fi/php-utf8/ +* @see utf8_compliant +* @package utf8 +*/ +function utf8_is_valid($str) { + + $mState = 0; // cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mUcs4 = 0; // cached Unicode character + $mBytes = 1; // cached expected number of octets in the current sequence + + $len = strlen($str); + + for($i = 0; $i < $len; $i++) { + + $in = ord($str{$i}); + + if ( $mState == 0) { + + // When mState is zero we expect either a US-ASCII character or a + // multi-octet sequence. + if (0 == (0x80 & ($in))) { + // US-ASCII, pass straight through. + $mBytes = 1; + + } else if (0xC0 == (0xE0 & ($in))) { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + + } else if (0xE0 == (0xF0 & ($in))) { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + + } else if (0xF0 == (0xF8 & ($in))) { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + + } else if (0xF8 == (0xFC & ($in))) { + /* First octet of 5 octet sequence. + * + * This is illegal because the encoded codepoint must be either + * (a) not the shortest form or + * (b) outside the Unicode range of 0-0x10FFFF. + * Rather than trying to resynchronize, we will carry on until the end + * of the sequence and let the later error handling code catch it. + */ + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x03) << 24; + $mState = 4; + $mBytes = 5; + + } else if (0xFC == (0xFE & ($in))) { + // First octet of 6 octet sequence, see comments for 5 octet sequence. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 1) << 30; + $mState = 5; + $mBytes = 6; + + } else { + /* Current octet is neither in the US-ASCII range nor a legal first + * octet of a multi-octet sequence. + */ + return FALSE; + + } + + } else { + + // When mState is non-zero, we expect a continuation of the multi-octet + // sequence + if (0x80 == (0xC0 & ($in))) { + + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + /** + * End of the multi-octet sequence. mUcs4 now contains the final + * Unicode codepoint to be output + */ + if (0 == --$mState) { + + /* + * Check for illegal sequences and codepoints. + */ + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || + ((3 == $mBytes) && ($mUcs4 < 0x0800)) || + ((4 == $mBytes) && ($mUcs4 < 0x10000)) || + (4 < $mBytes) || + // From Unicode 3.2, surrogate characters are illegal + (($mUcs4 & 0xFFFFF800) == 0xD800) || + // Codepoints outside the Unicode range are illegal + ($mUcs4 > 0x10FFFF)) { + + return FALSE; + + } + + //initialize UTF8 cache + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + } + + } else { + /** + *((0xC0 & (*in) != 0x80) && (mState != 0)) + * Incomplete multi-octet sequence. + */ + + return FALSE; + } + } + } + return TRUE; +} + +//-------------------------------------------------------------------- +/** +* Tests whether a string complies as UTF-8. This will be much +* faster than utf8_is_valid but will pass five and six octet +* UTF-8 sequences, which are not supported by Unicode and +* so cannot be displayed correctly in a browser. In other words +* it is not as strict as utf8_is_valid but it's faster. If you use +* is to validate user input, you place yourself at the risk that +* attackers will be able to inject 5 and 6 byte sequences (which +* may or may not be a significant risk, depending on what you are +* are doing) +* @see utf8_is_valid +* @see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#54805 +* @param string UTF-8 string to check +* @return boolean TRUE if string is valid UTF-8 +* @package utf8 +*/ +function utf8_compliant($str) { + if ( strlen($str) == 0 ) { + return TRUE; + } + // If even just the first character can be matched, when the /u + // modifier is used, then it's valid UTF-8. If the UTF-8 is somehow + // invalid, nothing at all will match, even if the string contains + // some valid sequences + return (preg_match('/^.{1}/us',$str,$ar) == 1); +} + diff --git a/libraries/vendor/joomla/uri/LICENSE b/libraries/vendor/joomla/uri/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/uri/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/uri/src/AbstractUri.php b/libraries/vendor/joomla/uri/src/AbstractUri.php new file mode 100644 index 0000000000000..81be3074fcbed --- /dev/null +++ b/libraries/vendor/joomla/uri/src/AbstractUri.php @@ -0,0 +1,402 @@ +parse($uri); + } + } + + /** + * Magic method to get the string representation of the URI object. + * + * @return string + * + * @since 1.0 + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Returns full uri string. + * + * @param array $parts An array specifying the parts to render. + * + * @return string The rendered URI string. + * + * @since 1.0 + */ + public function toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) + { + // Make sure the query is created + $query = $this->getQuery(); + + $uri = ''; + $uri .= in_array('scheme', $parts) ? (!empty($this->scheme) ? $this->scheme . '://' : '') : ''; + $uri .= in_array('user', $parts) ? $this->user : ''; + $uri .= in_array('pass', $parts) ? (!empty($this->pass) ? ':' : '') . $this->pass . (!empty($this->user) ? '@' : '') : ''; + $uri .= in_array('host', $parts) ? $this->host : ''; + $uri .= in_array('port', $parts) ? (!empty($this->port) ? ':' : '') . $this->port : ''; + $uri .= in_array('path', $parts) ? $this->path : ''; + $uri .= in_array('query', $parts) ? (!empty($query) ? '?' . $query : '') : ''; + $uri .= in_array('fragment', $parts) ? (!empty($this->fragment) ? '#' . $this->fragment : '') : ''; + + return $uri; + } + + /** + * Checks if variable exists. + * + * @param string $name Name of the query variable to check. + * + * @return boolean True if the variable exists. + * + * @since 1.0 + */ + public function hasVar($name) + { + return array_key_exists($name, $this->vars); + } + + /** + * Returns a query variable by name. + * + * @param string $name Name of the query variable to get. + * @param string $default Default value to return if the variable is not set. + * + * @return array Query variables. + * + * @since 1.0 + */ + public function getVar($name, $default = null) + { + if (array_key_exists($name, $this->vars)) + { + return $this->vars[$name]; + } + + return $default; + } + + /** + * Returns flat query string. + * + * @param boolean $toArray True to return the query as a key => value pair array. + * + * @return string Query string. + * + * @since 1.0 + */ + public function getQuery($toArray = false) + { + if ($toArray) + { + return $this->vars; + } + + // If the query is empty build it first + if (is_null($this->query)) + { + $this->query = self::buildQuery($this->vars); + } + + return $this->query; + } + + /** + * Get URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @return string The URI scheme. + * + * @since 1.0 + */ + public function getScheme() + { + return $this->scheme; + } + + /** + * Get URI username + * Returns the username, or null if no username was specified. + * + * @return string The URI username. + * + * @since 1.0 + */ + public function getUser() + { + return $this->user; + } + + /** + * Get URI password + * Returns the password, or null if no password was specified. + * + * @return string The URI password. + * + * @since 1.0 + */ + public function getPass() + { + return $this->pass; + } + + /** + * Get URI host + * Returns the hostname/ip or null if no hostname/ip was specified. + * + * @return string The URI host. + * + * @since 1.0 + */ + public function getHost() + { + return $this->host; + } + + /** + * Get URI port + * Returns the port number, or null if no port was specified. + * + * @return integer The URI port number. + * + * @since 1.0 + */ + public function getPort() + { + return (isset($this->port)) ? $this->port : null; + } + + /** + * Gets the URI path string. + * + * @return string The URI path string. + * + * @since 1.0 + */ + public function getPath() + { + return $this->path; + } + + /** + * Get the URI archor string + * Everything after the "#". + * + * @return string The URI anchor string. + * + * @since 1.0 + */ + public function getFragment() + { + return $this->fragment; + } + + /** + * Checks whether the current URI is using HTTPS. + * + * @return boolean True if using SSL via HTTPS. + * + * @since 1.0 + */ + public function isSSL() + { + return $this->getScheme() == 'https' ? true : false; + } + + /** + * Build a query from a array (reverse of the PHP parse_str()). + * + * @param array $params The array of key => value pairs to return as a query string. + * + * @return string The resulting query string. + * + * @see parse_str() + * @since 1.0 + */ + protected static function buildQuery(array $params) + { + return urldecode(http_build_query($params, '', '&')); + } + + /** + * Parse a given URI and populate the class fields. + * + * @param string $uri The URI string to parse. + * + * @return boolean True on success. + * + * @since 1.0 + */ + protected function parse($uri) + { + // Set the original URI to fall back on + $this->uri = $uri; + + /* + * Parse the URI and populate the object fields. If URI is parsed properly, + * set method return value to true. + */ + + $parts = UriHelper::parse_url($uri); + + $retval = ($parts) ? true : false; + + // We need to replace & with & for parse_str to work right... + if (isset($parts['query']) && strpos($parts['query'], '&')) + { + $parts['query'] = str_replace('&', '&', $parts['query']); + } + + $this->scheme = isset($parts['scheme']) ? $parts['scheme'] : null; + $this->user = isset($parts['user']) ? $parts['user'] : null; + $this->pass = isset($parts['pass']) ? $parts['pass'] : null; + $this->host = isset($parts['host']) ? $parts['host'] : null; + $this->port = isset($parts['port']) ? $parts['port'] : null; + $this->path = isset($parts['path']) ? $parts['path'] : null; + $this->query = isset($parts['query']) ? $parts['query'] : null; + $this->fragment = isset($parts['fragment']) ? $parts['fragment'] : null; + + // Parse the query + if (isset($parts['query'])) + { + parse_str($parts['query'], $this->vars); + } + + return $retval; + } + + /** + * 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 + * + * @param string $path The URI path to clean. + * + * @return string Cleaned and resolved URI path. + * + * @since 1.0 + */ + protected function cleanPath($path) + { + $path = explode('/', preg_replace('#(/+)#', '/', $path)); + + for ($i = 0, $n = count($path); $i < $n; $i++) + { + if ($path[$i] == '.' || $path[$i] == '..') + { + if (($path[$i] == '.') || ($path[$i] == '..' && $i == 1 && $path[0] == '')) + { + unset($path[$i]); + $path = array_values($path); + $i--; + $n--; + } + elseif ($path[$i] == '..' && ($i > 1 || ($i == 1 && $path[0] != ''))) + { + unset($path[$i]); + unset($path[$i - 1]); + $path = array_values($path); + $i -= 2; + $n -= 2; + } + } + } + + return implode('/', $path); + } +} diff --git a/libraries/vendor/joomla/uri/src/Uri.php b/libraries/vendor/joomla/uri/src/Uri.php new file mode 100644 index 0000000000000..be165d5de6951 --- /dev/null +++ b/libraries/vendor/joomla/uri/src/Uri.php @@ -0,0 +1,193 @@ +vars[$name]) ? $this->vars[$name] : null; + + $this->vars[$name] = $value; + + // Empty the query + $this->query = null; + + return $tmp; + } + + /** + * Removes an item from the query string variables if it exists. + * + * @param string $name Name of variable to remove. + * + * @return void + * + * @since 1.0 + */ + public function delVar($name) + { + if (array_key_exists($name, $this->vars)) + { + unset($this->vars[$name]); + + // Empty the query + $this->query = null; + } + } + + /** + * Sets the query to a supplied string in format: + * foo=bar&x=y + * + * @param mixed $query The query string or array. + * + * @return void + * + * @since 1.0 + */ + public function setQuery($query) + { + if (is_array($query)) + { + $this->vars = $query; + } + else + { + if (strpos($query, '&') !== false) + { + $query = str_replace('&', '&', $query); + } + + parse_str($query, $this->vars); + } + + // Empty the query + $this->query = null; + } + + /** + * Set URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @param string $scheme The URI scheme. + * + * @return void + * + * @since 1.0 + */ + public function setScheme($scheme) + { + $this->scheme = $scheme; + } + + /** + * Set URI username. + * + * @param string $user The URI username. + * + * @return void + * + * @since 1.0 + */ + public function setUser($user) + { + $this->user = $user; + } + + /** + * Set URI password. + * + * @param string $pass The URI password. + * + * @return void + * + * @since 1.0 + */ + public function setPass($pass) + { + $this->pass = $pass; + } + + /** + * Set URI host. + * + * @param string $host The URI host. + * + * @return void + * + * @since 1.0 + */ + public function setHost($host) + { + $this->host = $host; + } + + /** + * Set URI port. + * + * @param integer $port The URI port number. + * + * @return void + * + * @since 1.0 + */ + public function setPort($port) + { + $this->port = $port; + } + + /** + * Set the URI path string. + * + * @param string $path The URI path string. + * + * @return void + * + * @since 1.0 + */ + public function setPath($path) + { + $this->path = $this->cleanPath($path); + } + + /** + * Set the URI anchor string + * everything after the "#". + * + * @param string $anchor The URI anchor string. + * + * @return void + * + * @since 1.0 + */ + public function setFragment($anchor) + { + $this->fragment = $anchor; + } +} diff --git a/libraries/vendor/joomla/uri/src/UriHelper.php b/libraries/vendor/joomla/uri/src/UriHelper.php new file mode 100644 index 0000000000000..f6fc0129e8dad --- /dev/null +++ b/libraries/vendor/joomla/uri/src/UriHelper.php @@ -0,0 +1,56 @@ + $value) + { + $result[$key] = urldecode(str_replace($replacements, $entities, $value)); + } + } + + return $result; + } +} diff --git a/libraries/vendor/joomla/uri/src/UriImmutable.php b/libraries/vendor/joomla/uri/src/UriImmutable.php new file mode 100644 index 0000000000000..8ee3255036fc6 --- /dev/null +++ b/libraries/vendor/joomla/uri/src/UriImmutable.php @@ -0,0 +1,61 @@ +constructed === true) + { + throw new \BadMethodCallException('This is an immutable object'); + } + + $this->constructed = true; + + parent::__construct($uri); + } +} diff --git a/libraries/vendor/joomla/uri/src/UriInterface.php b/libraries/vendor/joomla/uri/src/UriInterface.php new file mode 100644 index 0000000000000..0f8db02454631 --- /dev/null +++ b/libraries/vendor/joomla/uri/src/UriInterface.php @@ -0,0 +1,151 @@ + value pair array. + * + * @return string Query string. + * + * @since 1.0 + */ + public function getQuery($toArray = false); + + /** + * Get URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @return string The URI scheme. + * + * @since 1.0 + */ + public function getScheme(); + + /** + * Get URI username + * Returns the username, or null if no username was specified. + * + * @return string The URI username. + * + * @since 1.0 + */ + public function getUser(); + + /** + * Get URI password + * Returns the password, or null if no password was specified. + * + * @return string The URI password. + * + * @since 1.0 + */ + public function getPass(); + + /** + * Get URI host + * Returns the hostname/ip or null if no hostname/ip was specified. + * + * @return string The URI host. + * + * @since 1.0 + */ + public function getHost(); + + /** + * Get URI port + * Returns the port number, or null if no port was specified. + * + * @return integer The URI port number. + * + * @since 1.0 + */ + public function getPort(); + + /** + * Gets the URI path string. + * + * @return string The URI path string. + * + * @since 1.0 + */ + public function getPath(); + + /** + * Get the URI archor string + * Everything after the "#". + * + * @return string The URI anchor string. + * + * @since 1.0 + */ + public function getFragment(); + + /** + * Checks whether the current URI is using HTTPS. + * + * @return boolean True if using SSL via HTTPS. + * + * @since 1.0 + */ + public function isSSL(); +} diff --git a/libraries/vendor/joomla/utilities/LICENSE b/libraries/vendor/joomla/utilities/LICENSE new file mode 100644 index 0000000000000..df50810b85774 --- /dev/null +++ b/libraries/vendor/joomla/utilities/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libraries/vendor/joomla/utilities/src/ArrayHelper.php b/libraries/vendor/joomla/utilities/src/ArrayHelper.php new file mode 100644 index 0000000000000..e648ff84e466a --- /dev/null +++ b/libraries/vendor/joomla/utilities/src/ArrayHelper.php @@ -0,0 +1,578 @@ + $v) + { + if ($recursive && is_array($v)) + { + $obj->$k = self::toObject($v, $class); + } + else + { + $obj->$k = $v; + } + } + + return $obj; + } + + /** + * Utility function to map an array to a string. + * + * @param array $array The array to map. + * @param string $inner_glue The glue (optional, defaults to '=') between the key and the value. + * @param string $outer_glue The glue (optional, defaults to ' ') between array elements. + * @param boolean $keepOuterKey True if final key should be kept. + * + * @return string The string mapped from the given array + * + * @since 1.0 + */ + public static function toString(array $array, $inner_glue = '=', $outer_glue = ' ', $keepOuterKey = false) + { + $output = array(); + + foreach ($array as $key => $item) + { + if (is_array($item)) + { + if ($keepOuterKey) + { + $output[] = $key; + } + + // This is value is an array, go and do it again! + $output[] = self::toString($item, $inner_glue, $outer_glue, $keepOuterKey); + } + else + { + $output[] = $key . $inner_glue . '"' . $item . '"'; + } + } + + return implode($outer_glue, $output); + } + + /** + * Utility function to map an object to an array + * + * @param object $p_obj The source object + * @param boolean $recurse True to recurse through multi-level objects + * @param string $regex An optional regular expression to match on field names + * + * @return array The array mapped from the given object + * + * @since 1.0 + */ + public static function fromObject($p_obj, $recurse = true, $regex = null) + { + if (is_object($p_obj)) + { + return self::arrayFromObject($p_obj, $recurse, $regex); + } + else + { + return null; + } + } + + /** + * Utility function to map an object or array to an array + * + * @param mixed $item The source object or array + * @param boolean $recurse True to recurse through multi-level objects + * @param string $regex An optional regular expression to match on field names + * + * @return array The array mapped from the given object + * + * @since 1.0 + */ + private static function arrayFromObject($item, $recurse, $regex) + { + if (is_object($item)) + { + $result = array(); + + foreach (get_object_vars($item) as $k => $v) + { + if (!$regex || preg_match($regex, $k)) + { + if ($recurse) + { + $result[$k] = self::arrayFromObject($v, $recurse, $regex); + } + else + { + $result[$k] = $v; + } + } + } + } + elseif (is_array($item)) + { + $result = array(); + + foreach ($item as $k => $v) + { + $result[$k] = self::arrayFromObject($v, $recurse, $regex); + } + } + else + { + $result = $item; + } + + return $result; + } + + /** + * Extracts a column from an array of arrays or objects + * + * @param array $array The source array + * @param string $index The index of the column or name of object property + * + * @return array Column of values from the source array + * + * @since 1.0 + */ + public static function getColumn(array $array, $index) + { + $result = array(); + + foreach ($array as $item) + { + if (is_array($item) && isset($item[$index])) + { + $result[] = $item[$index]; + } + elseif (is_object($item) && isset($item->$index)) + { + $result[] = $item->$index; + } + } + + return $result; + } + + /** + * Utility function to return a value from a named array or a specified default + * + * @param array $array A named array + * @param string $name The key to search for + * @param mixed $default The default value to give if no key found + * @param string $type Return type for the variable (INT, FLOAT, STRING, WORD, BOOLEAN, ARRAY) + * + * @return mixed The value from the source array + * + * @since 1.0 + */ + public static function getValue(array $array, $name, $default = null, $type = '') + { + $result = null; + + if (isset($array[$name])) + { + $result = $array[$name]; + } + + // Handle the default case + if (is_null($result)) + { + $result = $default; + } + + // Handle the type constraint + switch (strtoupper($type)) + { + case 'INT': + case 'INTEGER': + // Only use the first integer value + @preg_match('/-?[0-9]+/', $result, $matches); + $result = @(int) $matches[0]; + break; + + case 'FLOAT': + case 'DOUBLE': + // Only use the first floating point value + @preg_match('/-?[0-9]+(\.[0-9]+)?/', $result, $matches); + $result = @(float) $matches[0]; + break; + + case 'BOOL': + case 'BOOLEAN': + $result = (bool) $result; + break; + + case 'ARRAY': + if (!is_array($result)) + { + $result = array($result); + } + break; + + case 'STRING': + $result = (string) $result; + break; + + case 'WORD': + $result = (string) preg_replace('#\W#', '', $result); + break; + + case 'NONE': + default: + // No casting necessary + break; + } + + return $result; + } + + /** + * Takes an associative array of arrays and inverts the array keys to values using the array values as keys. + * + * Example: + * $input = array( + * 'New' => array('1000', '1500', '1750'), + * 'Used' => array('3000', '4000', '5000', '6000') + * ); + * $output = ArrayHelper::invert($input); + * + * Output would be equal to: + * $output = array( + * '1000' => 'New', + * '1500' => 'New', + * '1750' => 'New', + * '3000' => 'Used', + * '4000' => 'Used', + * '5000' => 'Used', + * '6000' => 'Used' + * ); + * + * @param array $array The source array. + * + * @return array The inverted array. + * + * @since 1.0 + */ + public static function invert(array $array) + { + $return = array(); + + foreach ($array as $base => $values) + { + if (!is_array($values)) + { + continue; + } + + foreach ($values as $key) + { + // If the key isn't scalar then ignore it. + if (is_scalar($key)) + { + $return[$key] = $base; + } + } + } + + return $return; + } + + /** + * Method to determine if an array is an associative array. + * + * @param array $array An array to test. + * + * @return boolean True if the array is an associative array. + * + * @since 1.0 + */ + public static function isAssociative($array) + { + if (is_array($array)) + { + foreach (array_keys($array) as $k => $v) + { + if ($k !== $v) + { + return true; + } + } + } + + return false; + } + + /** + * Pivots an array to create a reverse lookup of an array of scalars, arrays or objects. + * + * @param array $source The source array. + * @param string $key Where the elements of the source array are objects or arrays, the key to pivot on. + * + * @return array An array of arrays pivoted either on the value of the keys, or an individual key of an object or array. + * + * @since 1.0 + */ + public static function pivot(array $source, $key = null) + { + $result = array(); + $counter = array(); + + foreach ($source as $index => $value) + { + // Determine the name of the pivot key, and its value. + if (is_array($value)) + { + // If the key does not exist, ignore it. + if (!isset($value[$key])) + { + continue; + } + + $resultKey = $value[$key]; + $resultValue = $source[$index]; + } + elseif (is_object($value)) + { + // If the key does not exist, ignore it. + if (!isset($value->$key)) + { + continue; + } + + $resultKey = $value->$key; + $resultValue = $source[$index]; + } + else + { + // Just a scalar value. + $resultKey = $value; + $resultValue = $index; + } + + // The counter tracks how many times a key has been used. + if (empty($counter[$resultKey])) + { + // The first time around we just assign the value to the key. + $result[$resultKey] = $resultValue; + $counter[$resultKey] = 1; + } + elseif ($counter[$resultKey] == 1) + { + // If there is a second time, we convert the value into an array. + $result[$resultKey] = array( + $result[$resultKey], + $resultValue, + ); + $counter[$resultKey]++; + } + else + { + // After the second time, no need to track any more. Just append to the existing array. + $result[$resultKey][] = $resultValue; + } + } + + unset($counter); + + return $result; + } + + /** + * Utility function to sort an array of objects on a given field + * + * @param array $a An array of objects + * @param mixed $k The key (string) or a array of key to sort on + * @param mixed $direction Direction (integer) or an array of direction to sort in [1 = Ascending] [-1 = Descending] + * @param mixed $caseSensitive Boolean or array of booleans to let sort occur case sensitive or insensitive + * @param mixed $locale Boolean or array of booleans to let sort occur using the locale language or not + * + * @return array The sorted array of objects + * + * @since 1.0 + */ + public static function sortObjects(array $a, $k, $direction = 1, $caseSensitive = true, $locale = false) + { + if (!is_array($locale) || !is_array($locale[0])) + { + $locale = array($locale); + } + + $sortCase = (array) $caseSensitive; + $sortDirection = (array) $direction; + $key = (array) $k; + $sortLocale = $locale; + + usort( + $a, function($a, $b) use($sortCase, $sortDirection, $key, $sortLocale) + { + for ($i = 0, $count = count($key); $i < $count; $i++) + { + if (isset($sortDirection[$i])) + { + $direction = $sortDirection[$i]; + } + + if (isset($sortCase[$i])) + { + $caseSensitive = $sortCase[$i]; + } + + if (isset($sortLocale[$i])) + { + $locale = $sortLocale[$i]; + } + + $va = $a->$key[$i]; + $vb = $b->$key[$i]; + + if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) || is_numeric($vb))) + { + $cmp = $va - $vb; + } + elseif ($caseSensitive) + { + $cmp = String::strcmp($va, $vb, $locale); + } + else + { + $cmp = String::strcasecmp($va, $vb, $locale); + } + + if ($cmp > 0) + { + return $direction; + } + + if ($cmp < 0) + { + return -$direction; + } + } + + return 0; + } + ); + + return $a; + } + + /** + * Multidimensional array safe unique test + * + * @param array $array The array to make unique. + * + * @return array + * + * @see http://php.net/manual/en/function.array-unique.php + * @since 1.0 + */ + public static function arrayUnique(array $array) + { + $array = array_map('serialize', $array); + $array = array_unique($array); + $array = array_map('unserialize', $array); + + return $array; + } + + /** + * An improved array_search that allows for partial matching + * of strings values in associative arrays. + * + * @param string $needle The text to search for within the array. + * @param array $haystack Associative array to search in to find $needle. + * @param boolean $caseSensitive True to search case sensitive, false otherwise. + * + * @return mixed Returns the matching array $key if found, otherwise false. + * + * @since 1.0 + */ + public static function arraySearch($needle, array $haystack, $caseSensitive = true) + { + foreach ($haystack as $key => $value) + { + $searchFunc = ($caseSensitive) ? 'strpos' : 'stripos'; + + if ($searchFunc($value, $needle) === 0) + { + return $key; + } + } + + return false; + } +} diff --git a/libraries/vendor/leafo/lessphp/LICENSE b/libraries/vendor/leafo/lessphp/LICENSE new file mode 100644 index 0000000000000..b2338b1c8ac54 --- /dev/null +++ b/libraries/vendor/leafo/lessphp/LICENSE @@ -0,0 +1,660 @@ +For ease of distribution, lessphp 0.2.0 is under a dual license. +You are free to pick which one suits your needs. + + + + +MIT LICENSE + + + + +Copyright (c) 2010 Leaf Corcoran, http://leafo.net/lessphp + +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. + + + + +GPL VERSION 3 + + + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + diff --git a/libraries/lessc/lessc.inc.php b/libraries/vendor/leafo/lessphp/lessc.inc.php similarity index 99% rename from libraries/lessc/lessc.inc.php rename to libraries/vendor/leafo/lessphp/lessc.inc.php index 5729368d8a855..411ca2fab8890 100644 --- a/libraries/lessc/lessc.inc.php +++ b/libraries/vendor/leafo/lessphp/lessc.inc.php @@ -3469,3 +3469,5 @@ class lessc_formatter_lessjs extends lessc_formatter_classic { public $assignSeparator = ": "; public $selectorSeparator = ","; } + + diff --git a/libraries/vendor/leafo/lessphp/lessify b/libraries/vendor/leafo/lessphp/lessify new file mode 100755 index 0000000000000..df8e86861ab25 --- /dev/null +++ b/libraries/vendor/leafo/lessphp/lessify @@ -0,0 +1,23 @@ +#!/usr/bin/php +parse(); +} catch (exception $e) { + exit("Fatal error: ".$e->getMessage()."\n"); +} + + diff --git a/libraries/vendor/leafo/lessphp/lessify.inc.php b/libraries/vendor/leafo/lessphp/lessify.inc.php new file mode 100644 index 0000000000000..96d7d2a923139 --- /dev/null +++ b/libraries/vendor/leafo/lessphp/lessify.inc.php @@ -0,0 +1,447 @@ + + * + * WARNING: THIS DOES NOT WORK ANYMORE. NEEDS TO BE UPDATED FOR + * LATEST VERSION OF LESSPHP. + * + */ + +require "lessc.inc.php"; + +// +// check if the merge during mixin is overwriting values. should or should it not? +// + +// +// 1. split apart class tags +// + +class easyparse { + var $buffer; + var $count; + + function __construct($str) { + $this->count = 0; + $this->buffer = trim($str); + } + + function seek($where = null) { + if ($where === null) return $this->count; + else $this->count = $where; + return true; + } + + function preg_quote($what) { + return preg_quote($what, '/'); + } + + function match($regex, &$out, $eatWhitespace = true) { + $r = '/'.$regex.($eatWhitespace ? '\s*' : '').'/Ais'; + if (preg_match($r, $this->buffer, $out, null, $this->count)) { + $this->count += strlen($out[0]); + return true; + } + return false; + } + + function literal($what, $eatWhitespace = true) { + // this is here mainly prevent notice from { } string accessor + if ($this->count >= strlen($this->buffer)) return false; + + // shortcut on single letter + if (!$eatWhitespace and strlen($what) == 1) { + if ($this->buffer{$this->count} == $what) { + $this->count++; + return true; + } + else return false; + } + + return $this->match($this->preg_quote($what), $m, $eatWhitespace); + } + +} + +class tagparse extends easyparse { + static private $combinators = null; + static private $match_opts = null; + + function parse() { + if (empty(self::$combinators)) { + self::$combinators = '('.implode('|', array_map(array($this, 'preg_quote'), + array('+', '>', '~'))).')'; + self::$match_opts = '('.implode('|', array_map(array($this, 'preg_quote'), + array('=', '~=', '|=', '$=', '*='))).')'; + } + + // crush whitespace + $this->buffer = preg_replace('/\s+/', ' ', $this->buffer).' '; + + $tags = array(); + while ($this->tag($t)) $tags[] = $t; + + return $tags; + } + + static function compileString($string) { + list(, $delim, $str) = $string; + $str = str_replace($delim, "\\".$delim, $str); + $str = str_replace("\n", "\\\n", $str); + return $delim.$str.$delim; + } + + static function compilePaths($paths) { + return implode(', ', array_map(array('self', 'compilePath'), $paths)); + } + + // array of tags + static function compilePath($path) { + return implode(' ', array_map(array('self', 'compileTag'), $path)); + } + + + static function compileTag($tag) { + ob_start(); + if (isset($tag['comb'])) echo $tag['comb']." "; + if (isset($tag['front'])) echo $tag['front']; + if (isset($tag['attr'])) { + echo '['.$tag['attr']; + if (isset($tag['op'])) { + echo $tag['op'].$tag['op_value']; + } + echo ']'; + } + return ob_get_clean(); + } + + function string(&$out) { + $s = $this->seek(); + + if ($this->literal('"')) { + $delim = '"'; + } elseif ($this->literal("'")) { + $delim = "'"; + } else { + return false; + } + + while (true) { + // step through letters looking for either end or escape + $buff = ""; + $escapeNext = false; + $finished = false; + for ($i = $this->count; $i < strlen($this->buffer); $i++) { + $char = $this->buffer[$i]; + switch ($char) { + case $delim: + if ($escapeNext) { + $buff .= $char; + $escapeNext = false; + break; + } + $finished = true; + break 2; + case "\\": + if ($escapeNext) { + $buff .= $char; + $escapeNext = false; + } else { + $escapeNext = true; + } + break; + case "\n": + if (!$escapeNext) { + break 3; + } + + $buff .= $char; + $escapeNext = false; + break; + default: + if ($escapeNext) { + $buff .= "\\"; + $escapeNext = false; + } + $buff .= $char; + } + } + if (!$finished) break; + $out = array('string', $delim, $buff); + $this->seek($i+1); + return true; + } + + $this->seek($s); + return false; + } + + function tag(&$out) { + $s = $this->seek(); + $tag = array(); + if ($this->combinator($op)) $tag['comb'] = $op; + + if (!$this->match('(.*?)( |$|\[|'.self::$combinators.')', $match)) { + $this->seek($s); + return false; + } + + if (!empty($match[3])) { + // give back combinator + $this->count-=strlen($match[3]); + } + + if (!empty($match[1])) $tag['front'] = $match[1]; + + if ($match[2] == '[') { + if ($this->ident($i)) { + $tag['attr'] = $i; + + if ($this->match(self::$match_opts, $m) && $this->value($v)) { + $tag['op'] = $m[1]; + $tag['op_value'] = $v; + } + + if ($this->literal(']')) { + $out = $tag; + return true; + } + } + } elseif (isset($tag['front'])) { + $out = $tag; + return true; + } + + $this->seek($s); + return false; + } + + function ident(&$out) { + // [-]?{nmstart}{nmchar}* + // nmstart: [_a-z]|{nonascii}|{escape} + // nmchar: [_a-z0-9-]|{nonascii}|{escape} + if ($this->match('(-?[_a-z][_\w]*)', $m)) { + $out = $m[1]; + return true; + } + return false; + } + + function value(&$out) { + if ($this->string($str)) { + $out = $this->compileString($str); + return true; + } elseif ($this->ident($id)) { + $out = $id; + return true; + } + return false; + } + + + function combinator(&$op) { + if ($this->match(self::$combinators, $m)) { + $op = $m[1]; + return true; + } + return false; + } +} + +class nodecounter { + var $count = 0; + var $children = array(); + + var $name; + var $child_blocks; + var $the_block; + + function __construct($name) { + $this->name = $name; + } + + function dump($stack = null) { + if (is_null($stack)) $stack = array(); + $stack[] = $this->getName(); + echo implode(' -> ', $stack)." ($this->count)\n"; + foreach ($this->children as $child) { + $child->dump($stack); + } + } + + static function compileProperties($c, $block) { + foreach($block as $name => $value) { + if ($c->isProperty($name, $value)) { + echo $c->compileProperty($name, $value)."\n"; + } + } + } + + function compile($c, $path = null) { + if (is_null($path)) $path = array(); + $path[] = $this->name; + + $isVisible = !is_null($this->the_block) || !is_null($this->child_blocks); + + if ($isVisible) { + echo $c->indent(implode(' ', $path).' {'); + $c->indentLevel++; + $path = array(); + + if ($this->the_block) { + $this->compileProperties($c, $this->the_block); + } + + if ($this->child_blocks) { + foreach ($this->child_blocks as $block) { + echo $c->indent(tagparse::compilePaths($block['__tags']).' {'); + $c->indentLevel++; + $this->compileProperties($c, $block); + $c->indentLevel--; + echo $c->indent('}'); + } + } + } + + // compile child nodes + foreach($this->children as $node) { + $node->compile($c, $path); + } + + if ($isVisible) { + $c->indentLevel--; + echo $c->indent('}'); + } + + } + + function getName() { + if (is_null($this->name)) return "[root]"; + else return $this->name; + } + + function getNode($name) { + if (!isset($this->children[$name])) { + $this->children[$name] = new nodecounter($name); + } + + return $this->children[$name]; + } + + function findNode($path) { + $current = $this; + for ($i = 0; $i < count($path); $i++) { + $t = tagparse::compileTag($path[$i]); + $current = $current->getNode($t); + } + + return $current; + } + + function addBlock($path, $block) { + $node = $this->findNode($path); + if (!is_null($node->the_block)) throw new exception("can this happen?"); + + unset($block['__tags']); + $node->the_block = $block; + } + + function addToNode($path, $block) { + $node = $this->findNode($path); + $node->child_blocks[] = $block; + } +} + +/** + * create a less file from a css file by combining blocks where appropriate + */ +class lessify extends lessc { + public function dump() { + print_r($this->env); + } + + public function parse($str = null) { + $this->prepareParser($str ? $str : $this->buffer); + while (false !== $this->parseChunk()); + + $root = new nodecounter(null); + + // attempt to preserve some of the block order + $order = array(); + + $visitedTags = array(); + foreach (end($this->env) as $name => $block) { + if (!$this->isBlock($name, $block)) continue; + if (isset($visitedTags[$name])) continue; + + foreach ($block['__tags'] as $t) { + $visitedTags[$t] = true; + } + + // skip those with more than 1 + if (count($block['__tags']) == 1) { + $p = new tagparse(end($block['__tags'])); + $path = $p->parse(); + $root->addBlock($path, $block); + $order[] = array('compressed', $path, $block); + continue; + } else { + $common = null; + $paths = array(); + foreach ($block['__tags'] as $rawtag) { + $p = new tagparse($rawtag); + $paths[] = $path = $p->parse(); + if (is_null($common)) $common = $path; + else { + $new_common = array(); + foreach ($path as $tag) { + $head = array_shift($common); + if ($tag == $head) { + $new_common[] = $head; + } else break; + } + $common = $new_common; + if (empty($common)) { + // nothing in common + break; + } + } + } + + if (!empty($common)) { + $new_paths = array(); + foreach ($paths as $p) $new_paths[] = array_slice($p, count($common)); + $block['__tags'] = $new_paths; + $root->addToNode($common, $block); + $order[] = array('compressed', $common, $block); + continue; + } + + } + + $order[] = array('none', $block['__tags'], $block); + } + + + $compressed = $root->children; + foreach ($order as $item) { + list($type, $tags, $block) = $item; + if ($type == 'compressed') { + $top = tagparse::compileTag(reset($tags)); + if (isset($compressed[$top])) { + $compressed[$top]->compile($this); + unset($compressed[$top]); + } + } else { + echo $this->indent(implode(', ', $tags).' {'); + $this->indentLevel++; + nodecounter::compileProperties($this, $block); + $this->indentLevel--; + echo $this->indent('}'); + } + } + } +} diff --git a/libraries/vendor/leafo/lessphp/plessc b/libraries/vendor/leafo/lessphp/plessc new file mode 100755 index 0000000000000..6337f996ce260 --- /dev/null +++ b/libraries/vendor/leafo/lessphp/plessc @@ -0,0 +1,250 @@ +#!/usr/bin/env php +, 2012 + +$exe = array_shift($argv); // remove filename + +$HELP = << 0 && preg_match('/^-([-hvrwncXT]$|[f]=)/', $argv[0])) { + array_shift($argv); +} + +function has() { + global $opts; + foreach (func_get_args() as $arg) { + if (isset($opts[$arg])) return true; + } + return false; +} + +if (has("h", "help")) { + exit($HELP); +} + +error_reporting(E_ALL); +$path = realpath(dirname(__FILE__)).'/'; + +require $path."lessc.inc.php"; + +$VERSION = lessc::$VERSION; + +$fa = "Fatal Error: "; +function err($msg) { + fwrite(STDERR, $msg."\n"); +} + +if (php_sapi_name() != "cli") { + err($fa.$argv[0]." must be run in the command line."); + exit(1); +} + +function make_less($fname = null) { + global $opts; + $l = new lessc($fname); + + if (has("f")) { + $format = $opts["f"]; + if ($format != "default") $l->setFormatter($format); + } + + if (has("c")) { + $l->setPreserveComments(true); + } + + return $l; +} + +function process($data, $import = null) { + global $fa; + + $l = make_less(); + if ($import) $l->importDir = $import; + + try { + echo $l->parse($data); + exit(0); + } catch (exception $ex) { + err($fa."\n".str_repeat('=', 20)."\n". + $ex->getMessage()); + exit(1); + } +} + +if (has("v")) { + exit($VERSION."\n"); +} + +if (has("r")) { + if (!empty($argv)) { + $data = $argv[0]; + } else { + $data = ""; + while (!feof(STDIN)) { + $data .= fread(STDIN, 8192); + } + } + exit(process($data)); +} + +if (has("w")) { + // need two files + if (!is_file($in = array_shift($argv)) || + null == $out = array_shift($argv)) + { + err($fa.$exe." -w infile outfile"); + exit(1); + } + + echo "Watching ".$in. + (has("n") ? ' with notifications' : ''). + ", press Ctrl + c to exit.\n"; + + $cache = $in; + $last_action = 0; + while (true) { + clearstatcache(); + + // check if anything has changed since last fail + $updated = false; + if (is_array($cache)) { + foreach ($cache['files'] as $fname=>$_) { + if (filemtime($fname) > $last_action) { + $updated = true; + break; + } + } + } else $updated = true; + + // try to compile it + if ($updated) { + $last_action = time(); + + try { + $cache = lessc::cexecute($cache); + echo "Writing updated file: ".$out."\n"; + if (!file_put_contents($out, $cache['compiled'])) { + err($fa."Could not write to file ".$out); + exit(1); + } + } catch (exception $ex) { + echo "\nFatal Error:\n".str_repeat('=', 20)."\n". + $ex->getMessage()."\n\n"; + + if (has("n")) { + `notify-send -u critical "compile failed" "{$ex->getMessage()}"`; + } + } + } + + sleep(1); + } + exit(0); +} + +if (!$fname = array_shift($argv)) { + echo $HELP; + exit(1); +} + +function dumpValue($node, $depth = 0) { + if (is_object($node)) { + $indent = str_repeat(" ", $depth); + $out = array(); + foreach ($node->props as $prop) { + $out[] = $indent . dumpValue($prop, $depth + 1); + } + $out = implode("\n", $out); + if (!empty($node->tags)) { + $out = "+ ".implode(", ", $node->tags)."\n".$out; + } + return $out; + } elseif (is_array($node)) { + if (empty($node)) return "[]"; + $type = $node[0]; + if ($type == "block") + return dumpValue($node[1], $depth); + + $out = array(); + foreach ($node as $value) { + $out[] = dumpValue($value, $depth); + } + return "{ ".implode(", ", $out)." }"; + } else { + if (is_string($node) && preg_match("/[\s,]/", $node)) { + return '"'.$node.'"'; + } + return $node; // normal value + } +} + + +function stripValue($o, $toStrip) { + if (is_array($o) || is_object($o)) { + $isObject = is_object($o); + $o = (array)$o; + foreach ($toStrip as $removeKey) { + if (!empty($o[$removeKey])) { + $o[$removeKey] = "*stripped*"; + } + } + + foreach ($o as $k => $v) { + $o[$k] = stripValue($v, $toStrip); + } + + if ($isObject) { + $o = (object)$o; + } + } + + return $o; +} + +function dumpWithoutParent($o, $alsoStrip=array()) { + $toStrip = array_merge(array("parent"), $alsoStrip); + print_r(stripValue($o, $toStrip)); +} + +try { + $less = make_less($fname); + if (has("T", "X")) { + $parser = new lessc_parser($less, $fname); + $tree = $parser->parse(file_get_contents($fname)); + if (has("X")) + $out = print_r($tree, 1); + else + $out = dumpValue($tree)."\n"; + } else { + $out = $less->parse(); + } + + if (!$fout = array_shift($argv)) { + echo $out; + } else { + file_put_contents($fout, $out); + } + +} catch (exception $ex) { + err($fa.$ex->getMessage()); + exit(1); +} + +?> diff --git a/libraries/phpmailer/LICENSE b/libraries/vendor/phpmailer/phpmailer/LICENSE similarity index 100% rename from libraries/phpmailer/LICENSE rename to libraries/vendor/phpmailer/phpmailer/LICENSE diff --git a/libraries/phpmailer/PHPMailerAutoload.php b/libraries/vendor/phpmailer/phpmailer/PHPMailerAutoload.php similarity index 100% rename from libraries/phpmailer/PHPMailerAutoload.php rename to libraries/vendor/phpmailer/phpmailer/PHPMailerAutoload.php diff --git a/libraries/phpmailer/phpmailer.php b/libraries/vendor/phpmailer/phpmailer/class.phpmailer.php similarity index 92% rename from libraries/phpmailer/phpmailer.php rename to libraries/vendor/phpmailer/phpmailer/class.phpmailer.php index eed9bc5a35b3b..65d4c9d4b29fe 100644 --- a/libraries/phpmailer/phpmailer.php +++ b/libraries/vendor/phpmailer/phpmailer/class.phpmailer.php @@ -36,7 +36,7 @@ class PHPMailer /** * Email priority. * Options: 1 = High, 3 = Normal, 5 = low. - * @type integer + * @type int */ public $Priority = 3; @@ -149,7 +149,7 @@ class PHPMailer /** * Word-wrap the message body to this number of chars. - * @type integer + * @type int */ public $WordWrap = 0; @@ -169,7 +169,7 @@ class PHPMailer /** * Whether mail() uses a fully sendmail-compatible MTA. * One which supports sendmail's "-oi -f" options. - * @type boolean + * @type bool */ public $UseSendmailOptions = true; @@ -223,8 +223,8 @@ class PHPMailer /** * The default SMTP server port. - * @type integer - * @TODO Why is this needed when the SMTP class takes care of it? + * @type int + * @Todo Why is this needed when the SMTP class takes care of it? */ public $Port = 25; @@ -246,7 +246,7 @@ class PHPMailer /** * Whether to use SMTP authentication. * Uses the Username and Password properties. - * @type boolean + * @type bool * @see PHPMailer::$Username * @see PHPMailer::$Password */ @@ -287,7 +287,7 @@ class PHPMailer /** * The SMTP server timeout in seconds. - * @type integer + * @type int */ public $Timeout = 10; @@ -299,7 +299,7 @@ class PHPMailer * 2: data and commands * 3: as 2 plus connection status * 4: low level data output - * @type integer + * @type int * @see SMTP::$do_debug */ public $SMTPDebug = 0; @@ -319,21 +319,21 @@ class PHPMailer * Whether to keep SMTP connection open after each message. * If this is set to true then to close the connection * requires an explicit call to smtpClose(). - * @type boolean + * @type bool */ public $SMTPKeepAlive = false; /** * Whether to split multiple to addresses into multiple messages * or send them all in one message. - * @type boolean + * @type bool */ public $SingleTo = false; /** * Storage for addresses when SingleTo is enabled. * @type array - * @TODO This should really not be public + * @todo This should really not be public */ public $SingleToArray = array(); @@ -342,13 +342,13 @@ class PHPMailer * Only applicable when sending via SMTP. * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path * @link http://www.postfix.org/VERP_README.html Postfix VERP info - * @type boolean + * @type bool */ public $do_verp = false; /** * Whether to allow sending messages with an empty body. - * @type boolean + * @type bool */ public $AllowEmpty = false; @@ -402,7 +402,7 @@ class PHPMailer * Value can be any php callable: http://www.php.net/is_callable * * Parameters: - * boolean $result result of the send action + * bool $result result of the send action * string $to email address of the recipient * string $cc cc email addresses * string $bcc bcc email addresses @@ -536,7 +536,7 @@ class PHPMailer /** * Whether to throw exceptions for errors. - * @type boolean + * @type bool * @access protected */ protected $exceptions = false; @@ -563,7 +563,7 @@ class PHPMailer /** * Constructor - * @param boolean $exceptions Should we throw external exceptions? + * @param bool $exceptions Should we throw external exceptions? */ public function __construct($exceptions = false) { @@ -598,7 +598,7 @@ public function __destruct() * @param string $header Additional Header(s) * @param string $params Params * @access private - * @return boolean + * @return bool */ private function mailPassthru($to, $subject, $body, $header, $params) { @@ -644,12 +644,12 @@ protected function edebug($str) /** * Sets message type to HTML or plain. - * @param boolean $isHtml True for HTML mode. + * @param bool $ishtml True for HTML mode. * @return void */ - public function isHTML($isHtml = true) + public function isHTML($ishtml = true) { - if ($isHtml) { + if ($ishtml) { $this->ContentType = 'text/html'; } else { $this->ContentType = 'text/plain'; @@ -681,7 +681,7 @@ public function isMail() public function isSendmail() { $ini_sendmail_path = ini_get('sendmail_path'); - + if (!stristr($ini_sendmail_path, 'sendmail')) { $this->Sendmail = '/usr/sbin/sendmail'; } else { @@ -697,7 +697,7 @@ public function isSendmail() public function isQmail() { $ini_sendmail_path = ini_get('sendmail_path'); - + if (!stristr($ini_sendmail_path, 'qmail')) { $this->Sendmail = '/var/qmail/bin/qmail-inject'; } else { @@ -710,7 +710,7 @@ public function isQmail() * Add a "To" address. * @param string $address * @param string $name - * @return boolean true on success, false if address already used + * @return bool true on success, false if address already used */ public function addAddress($address, $name = '') { @@ -722,7 +722,7 @@ public function addAddress($address, $name = '') * @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 + * @return bool true on success, false if address already used */ public function addCC($address, $name = '') { @@ -734,7 +734,7 @@ public function addCC($address, $name = '') * @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 + * @return bool true on success, false if address already used */ public function addBCC($address, $name = '') { @@ -745,7 +745,7 @@ public function addBCC($address, $name = '') * Add a "Reply-to" address. * @param string $address * @param string $name - * @return boolean + * @return bool */ public function addReplyTo($address, $name = '') { @@ -759,7 +759,7 @@ public function addReplyTo($address, $name = '') * @param string $address The email address to send to * @param string $name * @throws phpmailerException - * @return boolean true on success, false if address already used or invalid in some way + * @return bool true on success, false if address already used or invalid in some way * @access protected */ protected function addAnAddress($kind, $address, $name = '') @@ -801,9 +801,9 @@ protected function addAnAddress($kind, $address, $name = '') * Set the From and FromName properties. * @param string $address * @param string $name - * @param boolean $auto Whether to also set the Sender address, defaults to true + * @param bool $auto Whether to also set the Sender address, defaults to true * @throws phpmailerException - * @return boolean + * @return bool */ public function setFrom($address, $name = '', $auto = true) { @@ -849,7 +849,7 @@ public function getLastMessageID() * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; same as pcre8 but does not allow 'dotless' domains; * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. * * `noregex` Don't use a regex: super fast, really dumb. - * @return boolean + * @return bool * @static * @access public */ @@ -879,7 +879,7 @@ public static function validateAddress($address, $patternselect = 'auto') * @copyright 2009-2010 Michael Rushton * Feel free to use and redistribute this code. But please keep this copyright notice. */ - return (boolean)preg_match( + return (bool)preg_match( '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . @@ -891,9 +891,10 @@ public static function validateAddress($address, $patternselect = 'auto') '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address ); + break; case 'pcre': //An older regex that doesn't need a recent PCRE - return (boolean)preg_match( + return (bool)preg_match( '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . @@ -906,25 +907,26 @@ public static function validateAddress($address, $patternselect = 'auto') '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', $address ); + break; case 'html5': /** * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) */ - return (boolean)preg_match( - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[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])?)*$/sD', - $address - ); + return (bool)preg_match('/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[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])?)*$/sD', $address); + break; + case 'php': + default: + return (bool)filter_var($address, FILTER_VALIDATE_EMAIL); + break; case 'noregex': //No PCRE! Do something _very_ approximate! //Check the address is 3 chars or longer and contains an @ that's not the first or last char return (strlen($address) >= 3 and strpos($address, '@') >= 1 and strpos($address, '@') != strlen($address) - 1); - case 'php': - default: - return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL); + break; } } @@ -932,7 +934,7 @@ public static function validateAddress($address, $patternselect = 'auto') * Create a message and send it. * Uses the sending method specified by $Mailer. * @throws phpmailerException - * @return boolean false on error - See the ErrorInfo property for details of the error. + * @return bool false on error - See the ErrorInfo property for details of the error. */ public function send() { @@ -954,7 +956,7 @@ public function send() /** * Prepare a message for sending. * @throws phpmailerException - * @return boolean + * @return bool */ public function preSend() { @@ -1022,7 +1024,7 @@ public function preSend() * Actually send a message. * Send the email via the selected mechanism * @throws phpmailerException - * @return boolean + * @return bool */ public function postSend() { @@ -1041,7 +1043,7 @@ public function postSend() if (method_exists($this, $sendMethod)) { return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); } - + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); } } catch (phpmailerException $exc) { @@ -1061,7 +1063,7 @@ public function postSend() * @see PHPMailer::$Sendmail * @throws phpmailerException * @access protected - * @return boolean + * @return bool */ protected function sendmailSend($header, $body) { @@ -1079,23 +1081,17 @@ protected function sendmailSend($header, $body) } } if ($this->SingleTo === true) { - foreach ($this->SingleToArray as $toAddr) { + foreach ($this->SingleToArray as $val) { if (!@$mail = popen($sendmail, 'w')) { throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); } - fputs($mail, 'To: ' . $toAddr . "\n"); + fputs($mail, 'To: ' . $val . "\n"); fputs($mail, $header); fputs($mail, $body); $result = pclose($mail); - $this->doCallback( - ($result == 0), - array($toAddr), - $this->cc, - $this->bcc, - $this->Subject, - $body, - $this->From - ); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body, $this->From); if ($result != 0) { throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); } @@ -1107,7 +1103,9 @@ protected function sendmailSend($header, $body) fputs($mail, $header); fputs($mail, $body); $result = pclose($mail); - $this->doCallback(($result == 0), $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); if ($result != 0) { throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); } @@ -1122,7 +1120,7 @@ protected function sendmailSend($header, $body) * @link http://www.php.net/manual/en/book.mail.php * @throws phpmailerException * @access protected - * @return boolean + * @return bool */ protected function mailSend($header, $body) { @@ -1143,13 +1141,17 @@ protected function mailSend($header, $body) } $result = false; if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $toAddr) { - $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); - $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); + foreach ($toArr as $val) { + $result = $this->mailPassthru($val, $this->Subject, $body, $header, $params); + // implement call back function if it exists + $isSent = ($result == 1) ? 1 : 0; + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body, $this->From); } } else { $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); - $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); + // implement call back function if it exists + $isSent = ($result == 1) ? 1 : 0; + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); } if (isset($old_from)) { ini_set('sendmail_from', $old_from); @@ -1183,7 +1185,7 @@ public function getSMTPInstance() * @throws phpmailerException * @uses SMTP * @access protected - * @return boolean + * @return bool */ protected function smtpSend($header, $body) { @@ -1202,32 +1204,32 @@ protected function smtpSend($header, $body) foreach ($this->to as $to) { if (!$this->smtp->recipient($to[0])) { $bad_rcpt[] = $to[0]; - $isSent = false; + $isSent = 0; } else { - $isSent = true; + $isSent = 1; } - $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body, $this->From); } foreach ($this->cc as $cc) { if (!$this->smtp->recipient($cc[0])) { $bad_rcpt[] = $cc[0]; - $isSent = false; + $isSent = 0; } else { - $isSent = true; + $isSent = 1; } - $this->doCallback($isSent, array(), array($cc[0]), array(), $this->Subject, $body, $this->From); + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body, $this->From); } foreach ($this->bcc as $bcc) { if (!$this->smtp->recipient($bcc[0])) { $bad_rcpt[] = $bcc[0]; - $isSent = false; + $isSent = 0; } else { - $isSent = true; + $isSent = 1; } - $this->doCallback($isSent, array(), array(), array($bcc[0]), $this->Subject, $body, $this->From); + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body, $this->From); } - // Only send the DATA command if we have viable recipients + //Only send the DATA command if we have viable recipients if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL); } @@ -1237,7 +1239,7 @@ protected function smtpSend($header, $body) $this->smtp->quit(); $this->smtp->close(); } - if (count($bad_rcpt) > 0) { // Create error message for any bad addresses + if (count($bad_rcpt) > 0) { //Create error message for any bad addresses throw new phpmailerException( $this->lang('recipients_failed') . implode(', ', $bad_rcpt), self::STOP_CONTINUE @@ -1253,7 +1255,7 @@ protected function smtpSend($header, $body) * @uses SMTP * @access public * @throws phpmailerException - * @return boolean + * @return bool */ public function smtpConnect($options = array()) { @@ -1261,7 +1263,7 @@ public function smtpConnect($options = array()) $this->smtp = $this->getSMTPInstance(); } - // Already connected? + //Already connected? if ($this->smtp->connected()) { return true; } @@ -1276,22 +1278,22 @@ public function smtpConnect($options = array()) foreach ($hosts as $hostentry) { $hostinfo = array(); if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { - // Not a valid host entry + //Not a valid host entry continue; } - // $hostinfo[2]: optional ssl or tls prefix - // $hostinfo[3]: the hostname - // $hostinfo[4]: optional port number - // The host string prefix can temporarily override the current setting for SMTPSecure - // If it's not specified, the default value is used + //$hostinfo[2]: optional ssl or tls prefix + //$hostinfo[3]: the hostname + //$hostinfo[4]: optional port number + //The host string prefix can temporarily override the current setting for SMTPSecure + //If it's not specified, the default value is used $prefix = ''; $tls = ($this->SMTPSecure == 'tls'); if ($hostinfo[2] == 'ssl' or ($hostinfo[2] == '' and $this->SMTPSecure == 'ssl')) { $prefix = 'ssl://'; - $tls = false; // Can't have SSL and TLS at once + $tls = false; //Can't have SSL and TLS at once } elseif ($hostinfo[2] == 'tls') { $tls = true; - // tls doesn't use a prefix + //tls doesn't use a prefix } $host = $hostinfo[3]; $port = $this->Port; @@ -1312,7 +1314,7 @@ public function smtpConnect($options = array()) if (!$this->smtp->startTLS()) { throw new phpmailerException($this->lang('connect_host')); } - // We must resend HELO after tls negotiation + //We must resend HELO after tls negotiation $this->smtp->hello($hello); } if ($this->SMTPAuth) { @@ -1330,14 +1332,14 @@ public function smtpConnect($options = array()) return true; } catch (phpmailerException $exc) { $lastexception = $exc; - // We must have connected, but then failed TLS or Auth, so close connection nicely + //We must have connected, but then failed TLS or Auth, so close connection nicely $this->smtp->quit(); } } } - // If we get here, all connection attempts have failed, so close connection hard + //If we get here, all connection attempts have failed, so close connection hard $this->smtp->close(); - // As we've caught all exceptions, just report whatever the last one was + //As we've caught all exceptions, just report whatever the last one was if ($this->exceptions and !is_null($lastexception)) { throw $lastexception; } @@ -1364,12 +1366,12 @@ public function smtpClose() * The default language is English. * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") * @param string $lang_path Path to the language file directory, with trailing separator (slash) - * @return boolean + * @return bool * @access public */ public function setLanguage($langcode = 'en', $lang_path = '') { - // Define full set of translatable strings in English + //Define full set of translatable strings in English $PHPMAILER_LANG = array( 'authenticate' => 'SMTP Error: Could not authenticate.', 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', @@ -1391,23 +1393,23 @@ public function setLanguage($langcode = 'en', $lang_path = '') 'variable_set' => 'Cannot set or reset variable: ' ); if (empty($lang_path)) { - // Calculate an absolute path so it can work if CWD is not here + //Calculate an absolute path so it can work if CWD is not here $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; } $foundlang = true; $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; - if ($langcode != 'en') { // There is no English translation file - // Make sure language file path is readable + if ($langcode != 'en') { //There is no English translation file + //Make sure language file path is readable if (!is_readable($lang_file)) { $foundlang = false; } else { - // Overwrite language-specific strings. - // This way we'll never have missing translations. + //Overwrite language-specific strings. + //This way we'll never have missing translations. $foundlang = include $lang_file; } } $this->language = $PHPMAILER_LANG; - return ($foundlang == true); // Returns false if language not found + return ($foundlang == true); //Returns false if language not found } /** @@ -1463,7 +1465,7 @@ public function addrFormat($addr) * 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 + * @param bool $qp_mode Whether to run in Quoted-Printable mode * @access public * @return string */ @@ -1552,8 +1554,8 @@ public function wrapText($message, $length, $qp_mode = false) * Original written by Colin Brown. * @access public * @param string $encodedText utf-8 QP text - * @param integer $maxLength find last character boundary prior to this length - * @return integer + * @param int $maxLength find last character boundary prior to this length + * @return int */ public function utf8CharBoundary($encodedText, $maxLength) { @@ -1745,14 +1747,14 @@ public function getMailMIME() $ismultipart = false; break; } - // RFC1341 part 5 says 7bit is assumed if not specified + //RFC1341 part 5 says 7bit is assumed if not specified if ($this->Encoding != '7bit') { - // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE + //RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE if ($ismultipart) { if ($this->Encoding == '8bit') { $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); } - // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible + //The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible } else { $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); } @@ -1911,9 +1913,9 @@ public function createBody() if (!defined('PKCS7_TEXT')) { throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.'); } - // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 + //TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 $file = tempnam(sys_get_temp_dir(), 'mail'); - file_put_contents($file, $body); // @TODO check this worked + file_put_contents($file, $body); //TODO check this worked $signed = tempnam(sys_get_temp_dir(), 'signed'); if (@openssl_pkcs7_sign( $file, @@ -1965,7 +1967,7 @@ protected function getBoundary($boundary, $charSet, $contentType, $encoding) $result .= $this->textLine('--' . $boundary); $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); $result .= $this->LE; - // RFC1341 part 5 says 7bit is assumed if not specified + //RFC1341 part 5 says 7bit is assumed if not specified if ($encoding != '7bit') { $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); } @@ -2042,7 +2044,7 @@ public function textLine($value) * @param string $type File extension (MIME) type. * @param string $disposition Disposition to use * @throws phpmailerException - * @return boolean + * @return bool */ public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') { @@ -2051,7 +2053,7 @@ public function addAttachment($path, $name = '', $encoding = 'base64', $type = ' throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); } - // If a MIME type is not specified, try to work it out from the file name + //If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } @@ -2143,7 +2145,7 @@ protected function attachAll($disposition_type, $boundary) $this->encodeHeader($this->secureHeader($name)), $this->LE ); - // RFC1341 part 5 says 7bit is assumed if not specified + //RFC1341 part 5 says 7bit is assumed if not specified if ($encoding != '7bit') { $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE); } @@ -2217,11 +2219,8 @@ protected function encodeFile($path, $encoding = 'base64') $magic_quotes = get_magic_quotes_runtime(); if ($magic_quotes) { if (version_compare(PHP_VERSION, '5.3.0', '<')) { - set_magic_quotes_runtime(false); + set_magic_quotes_runtime(0); } else { - //Doesn't exist in PHP 5.4, but we don't need to check because - //get_magic_quotes_runtime always returns false in 5.4+ - //so it will never get here ini_set('magic_quotes_runtime', 0); } } @@ -2231,7 +2230,7 @@ protected function encodeFile($path, $encoding = 'base64') if (version_compare(PHP_VERSION, '5.3.0', '<')) { set_magic_quotes_runtime($magic_quotes); } else { - ini_set('magic_quotes_runtime', ($magic_quotes?'1':'0')); + ini_set('magic_quotes_runtime', $magic_quotes); } } return $file_buffer; @@ -2259,7 +2258,7 @@ public function encodeString($str, $encoding = 'base64') case '7bit': case '8bit': $encoded = $this->fixEOL($str); - // Make sure it ends with a line break + //Make sure it ends with a line break if (substr($encoded, -(strlen($this->LE))) != $this->LE) { $encoded .= $this->LE; } @@ -2311,14 +2310,14 @@ public function encodeHeader($str, $position = 'text') break; } - if ($matchcount == 0) { // There are no chars that need encoding + if ($matchcount == 0) { //There are no chars that need encoding return ($str); } $maxlen = 75 - 7 - strlen($this->CharSet); // Try to select the encoding which should produce the shortest output if ($matchcount > strlen($str) / 3) { - // More than a third of the content will need encoding, so B encoding will be most efficient + //More than a third of the content will need encoding, so B encoding will be most efficient $encoding = 'B'; if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) { // Use a custom function which correctly encodes and wraps long @@ -2346,7 +2345,7 @@ public function encodeHeader($str, $position = 'text') * Check if a string contains multi-byte characters. * @access public * @param string $str multi-byte text to wrap encode - * @return boolean + * @return bool */ public function hasMultiBytes($str) { @@ -2360,11 +2359,11 @@ public function hasMultiBytes($str) /** * Does a string contain any 8-bit chars (in any charset)? * @param string $text - * @return boolean + * @return bool */ public function has8bitChars($text) { - return (boolean)preg_match('/[\x80-\xFF]/', $text); + return (bool)preg_match('/[\x80-\xFF]/', $text); } /** @@ -2421,10 +2420,10 @@ public function base64EncodeWrapMB($str, $linebreak = null) */ public function encodeQP($string, $line_max = 76) { - if (function_exists('quoted_printable_encode')) { // Use native function if it's available (>= PHP5.3) + if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3) return $this->fixEOL(quoted_printable_encode($string)); } - // Fall back to a pure PHP implementation + //Fall back to a pure PHP implementation $string = str_replace( array('%20', '%0D%0A.', '%0D%0A', '%'), array(' ', "\r\n=2E", "\r\n", '='), @@ -2440,7 +2439,7 @@ public function encodeQP($string, $line_max = 76) * @access public * @param string $string * @param integer $line_max - * @param boolean $space_conv + * @param bool $space_conv * @return string * @deprecated Use encodeQP instead. */ @@ -2462,31 +2461,31 @@ public function encodeQPphp( */ public function encodeQ($str, $position = 'text') { - // There should not be any EOL in the string + //There should not be any EOL in the string $pattern = ''; $encoded = str_replace(array("\r", "\n"), '', $str); switch (strtolower($position)) { case 'phrase': - // RFC 2047 section 5.3 + //RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; /** @noinspection PhpMissingBreakStatementInspection */ case 'comment': - // RFC 2047 section 5.2 + //RFC 2047 section 5.2 $pattern = '\(\)"'; - // intentional fall-through - // for this reason we build the $pattern without including delimiters and [] + //intentional fall-through + //for this reason we build the $pattern without including delimiters and [] case 'text': default: - // RFC 2047 section 5.1 - // Replace every high ascii, control, =, ? and _ characters + //RFC 2047 section 5.1 + //Replace every high ascii, control, =, ? and _ characters $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { - // If the string contains an '=', make sure it's the first thing we replace - // so as to avoid double-encoding + //If the string contains an '=', make sure it's the first thing we replace + //so as to avoid double-encoding $eqkey = array_search('=', $matches[0]); if ($eqkey !== false) { unset($matches[0][$eqkey]); @@ -2496,7 +2495,7 @@ public function encodeQ($str, $position = 'text') $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); } } - // Replace every spaces to _ (more readable than =20) + //Replace every spaces to _ (more readable than =20) return str_replace(' ', '_', $encoded); } @@ -2519,7 +2518,7 @@ public function addStringAttachment( $type = '', $disposition = 'attachment' ) { - // If a MIME type is not specified, try to work it out from the file name + //If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($filename); } @@ -2550,7 +2549,7 @@ public function addStringAttachment( * @param string $encoding File encoding (see $Encoding). * @param string $type File MIME type. * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment + * @return bool True on successfully adding an attachment */ public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') { @@ -2559,7 +2558,7 @@ public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', return false; } - // If a MIME type is not specified, try to work it out from the file name + //If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } @@ -2595,7 +2594,7 @@ public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', * @param string $encoding File encoding (see $Encoding). * @param string $type MIME type. * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment + * @return bool True on successfully adding an attachment */ public function addStringEmbeddedImage( $string, @@ -2605,7 +2604,7 @@ public function addStringEmbeddedImage( $type = '', $disposition = 'inline' ) { - // If a MIME type is not specified, try to work it out from the name + //If a MIME type is not specified, try to work it out from the name if ($type == '') { $type = self::filenameToType($name); } @@ -2627,7 +2626,7 @@ public function addStringEmbeddedImage( /** * Check if an inline attachment is present. * @access public - * @return boolean + * @return bool */ public function inlineImageExists() { @@ -2641,7 +2640,7 @@ public function inlineImageExists() /** * Check if an attachment (non-inline) is present. - * @return boolean + * @return bool */ public function attachmentExists() { @@ -2655,7 +2654,7 @@ public function attachmentExists() /** * Check if this message has an alternative body set. - * @return boolean + * @return bool */ public function alternativeExists() { @@ -2763,8 +2762,8 @@ protected function setError($msg) */ public static function rfcDate() { - // Set the time zone to whatever the default is to avoid 500 errors - // Will default to UTC if it's not set properly in php.ini + //Set the time zone to whatever the default is to avoid 500 errors + //Will default to UTC if it's not set properly in php.ini date_default_timezone_set(@date_default_timezone_get()); return date('D, j M Y H:i:s O'); } @@ -2812,7 +2811,7 @@ protected function lang($key) /** * Check if an error occurred. * @access public - * @return boolean True if an error did occur. + * @return bool True if an error did occur. */ public function isError() { @@ -2864,7 +2863,7 @@ public function addCustomHeader($name, $value = null) * @access public * @param string $message HTML message string * @param string $basedir baseline directory for path - * @param boolean $advanced Whether to use the advanced HTML to text converter + * @param bool $advanced Whether to use the advanced HTML to text converter * @return string $message */ public function msgHTML($message, $basedir = '', $advanced = false) @@ -2879,7 +2878,7 @@ public function msgHTML($message, $basedir = '', $advanced = false) if ($directory == '.') { $directory = ''; } - $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 + $cid = md5($url) . '@phpmailer.0'; //RFC2392 S 2 if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; } @@ -2904,7 +2903,7 @@ public function msgHTML($message, $basedir = '', $advanced = false) } } $this->isHTML(true); - // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better + //Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better $this->Body = $this->normalizeBreaks($message); $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced)); if (empty($this->AltBody)) { @@ -2917,7 +2916,7 @@ public function msgHTML($message, $basedir = '', $advanced = false) /** * Convert an HTML string into plain text. * @param string $html The HTML text to convert - * @param boolean $advanced Should this use the more complex html2text converter or just a simple one? + * @param bool $advanced Should this use the more complex html2text converter or just a simple one? * @return string */ public function html2text($html, $advanced = false) @@ -3045,7 +3044,7 @@ public static function _mime_types($ext = '') */ public static function filenameToType($filename) { - // In case the path is a URL, strip any query string before getting extension + //In case the path is a URL, strip any query string before getting extension $qpos = strpos($filename, '?'); if ($qpos !== false) { $filename = substr($filename, 0, $qpos); @@ -3069,33 +3068,36 @@ public static function mb_pathinfo($path, $options = null) { $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''); $pathinfo = array(); - if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) { - if (array_key_exists(1, $pathinfo)) { - $ret['dirname'] = $pathinfo[1]; - } - if (array_key_exists(2, $pathinfo)) { - $ret['basename'] = $pathinfo[2]; - } - if (array_key_exists(5, $pathinfo)) { - $ret['extension'] = $pathinfo[5]; - } - if (array_key_exists(3, $pathinfo)) { - $ret['filename'] = $pathinfo[3]; - } + preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo); + if (array_key_exists(1, $pathinfo)) { + $ret['dirname'] = $pathinfo[1]; + } + if (array_key_exists(2, $pathinfo)) { + $ret['basename'] = $pathinfo[2]; + } + if (array_key_exists(5, $pathinfo)) { + $ret['extension'] = $pathinfo[5]; + } + if (array_key_exists(3, $pathinfo)) { + $ret['filename'] = $pathinfo[3]; } switch ($options) { case PATHINFO_DIRNAME: case 'dirname': return $ret['dirname']; + break; case PATHINFO_BASENAME: case 'basename': return $ret['basename']; + break; case PATHINFO_EXTENSION: case 'extension': return $ret['extension']; + break; case PATHINFO_FILENAME: case 'filename': return $ret['filename']; + break; default: return $ret; } @@ -3112,8 +3114,8 @@ public static function mb_pathinfo($path, $options = null) * @param mixed $value * NOTE: will not work with arrays, there are no arrays to set/reset * @throws phpmailerException - * @return boolean - * @TODO Should this not be using __set() magic function? + * @return bool + * @todo Should this not be using __set() magic function? */ public function set($name, $value = '') { @@ -3196,11 +3198,11 @@ public function DKIM_QP($txt) /** * Generate a DKIM signature. * @access public - * @param string $signHeader + * @param string $signheader Header * @throws phpmailerException * @return string */ - public function DKIM_Sign($signHeader) + public function DKIM_Sign($signheader) { if (!defined('PKCS7_TEXT')) { if ($this->exceptions) { @@ -3214,7 +3216,7 @@ public function DKIM_Sign($signHeader) } else { $privKey = $privKeyStr; } - if (openssl_sign($signHeader, $signature, $privKey)) { + if (openssl_sign($signheader, $signature, $privKey)) { return base64_encode($signature); } return ''; @@ -3223,21 +3225,21 @@ public function DKIM_Sign($signHeader) /** * Generate a DKIM canonicalization header. * @access public - * @param string $signHeader Header + * @param string $signheader Header * @return string */ - public function DKIM_HeaderC($signHeader) + public function DKIM_HeaderC($signheader) { - $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader); - $lines = explode("\r\n", $signHeader); + $signheader = preg_replace('/\r\n\s+/', ' ', $signheader); + $lines = explode("\r\n", $signheader); 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 } - $signHeader = implode("\r\n", $lines); - return $signHeader; + $signheader = implode("\r\n", $lines); + return $signheader; } /** @@ -3379,15 +3381,15 @@ public function getAllRecipientAddresses() /** * Perform a callback. - * @param boolean $isSent - * @param array $to - * @param array $cc - * @param array $bcc + * @param bool $isSent + * @param string $to + * @param string $cc + * @param string $bcc * @param string $subject * @param string $body * @param string $from */ - protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from) + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from = null) { if (!empty($this->action_function) && is_callable($this->action_function)) { $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); diff --git a/libraries/phpmailer/pop3.php b/libraries/vendor/phpmailer/phpmailer/class.pop3.php similarity index 82% rename from libraries/phpmailer/pop3.php rename to libraries/vendor/phpmailer/phpmailer/class.pop3.php index 285792abec571..71dffac2288e5 100644 --- a/libraries/phpmailer/pop3.php +++ b/libraries/vendor/phpmailer/phpmailer/class.pop3.php @@ -38,14 +38,14 @@ class POP3 /** * Default POP3 port number. - * @type integer + * @type int * @access public */ public $POP3_PORT = 110; /** * Default timeout in seconds. - * @type integer + * @type int * @access public */ public $POP3_TIMEOUT = 30; @@ -61,7 +61,7 @@ class POP3 /** * Debug display level. * Options: 0 = no, 1+ = yes - * @type integer + * @type int * @access public */ public $do_debug = 0; @@ -75,14 +75,14 @@ class POP3 /** * POP3 port number. - * @type integer + * @type int * @access public */ public $port; /** * POP3 Timeout Value in seconds. - * @type integer + * @type int * @access public */ public $tval; @@ -110,32 +110,43 @@ class POP3 /** * Are we connected? - * @type boolean + * @type bool * @access private */ - private $connected = false; + private $connected; /** * Error container. * @type array * @access private */ - private $errors = array(); + private $error; /** * Line break constant */ const CRLF = "\r\n"; + /** + * Constructor. + * @access public + */ + public function __construct() + { + $this->pop_conn = 0; + $this->connected = false; + $this->error = null; + } + /** * Simple static wrapper for all-in-one POP before SMTP * @param $host - * @param boolean $port - * @param boolean $tval + * @param bool $port + * @param bool $tval * @param string $username * @param string $password - * @param integer $debug_level - * @return boolean + * @param int $debug_level + * @return bool */ public static function popBeforeSmtp( $host, @@ -155,12 +166,12 @@ public static function popBeforeSmtp( * appropriate for POP-before SMTP authorisation. * @access public * @param string $host - * @param integer|boolean $port - * @param integer|boolean $tval + * @param bool|int $port + * @param bool|int $tval * @param string $username * @param string $password - * @param integer $debug_level - * @return boolean + * @param int $debug_level + * @return bool */ public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0) { @@ -180,8 +191,8 @@ public function authorise($host, $port = false, $tval = false, $username = '', $ $this->do_debug = $debug_level; $this->username = $username; $this->password = $password; - // Reset the error log - $this->errors = array(); + // Refresh the error log + $this->error = null; // connect $result = $this->connect($this->host, $this->port, $this->tval); if ($result) { @@ -200,7 +211,7 @@ public function authorise($host, $port = false, $tval = false, $username = '', $ * Connect to a POP3 server. * @access public * @param string $host - * @param integer|boolean $port + * @param bool|int $port * @param integer $tval * @return boolean */ @@ -215,10 +226,6 @@ public function connect($host, $port = false, $tval = 30) //Rather than suppress it with @fsockopen, capture it cleanly instead set_error_handler(array($this, 'catchWarning')); - if ($port === false) { - $port = $this->POP3_PORT; - } - // connect to the POP3 server $this->pop_conn = fsockopen( $host, // POP3 Host @@ -229,20 +236,34 @@ public function connect($host, $port = false, $tval = 30) ); // Timeout (seconds) // Restore the error handler restore_error_handler(); - + // Does the Error Log now contain anything? + if ($this->error && $this->do_debug >= 1) { + $this->displayErrors(); + } // Did we connect? - if ($this->pop_conn === false) { + if ($this->pop_conn == false) { // It would appear not... - $this->setError(array( + $this->error = array( 'error' => "Failed to connect to server $host on port $port", 'errno' => $errno, 'errstr' => $errstr - )); + ); + if ($this->do_debug >= 1) { + $this->displayErrors(); + } return false; } // Increase the stream time-out - stream_set_timeout($this->pop_conn, $tval, 0); + // Check for PHP 4.3.0 or later + if (version_compare(phpversion(), '5.0.0', 'ge')) { + stream_set_timeout($this->pop_conn, $tval, 0); + } else { + // Does not work on Windows + if (substr(PHP_OS, 0, 3) !== 'WIN') { + socket_set_timeout($this->pop_conn, $tval, 0); + } + } // Get the POP3 server response $pop3_response = $this->getResponse(); @@ -265,8 +286,12 @@ public function connect($host, $port = false, $tval = 30) */ public function login($username = '', $password = '') { - if (!$this->connected) { - $this->setError('Not connected to POP3 server'); + if ($this->connected == false) { + $this->error = 'Not connected to POP3 server'; + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } } if (empty($username)) { $username = $this->username; @@ -298,11 +323,7 @@ public function disconnect() $this->sendString('QUIT'); //The QUIT command may cause the daemon to exit, which will kill our connection //So ignore errors here - try { - @fclose($this->pop_conn); - } catch (Exception $e) { - //Do nothing - }; + @fclose($this->pop_conn); } /** @@ -348,11 +369,14 @@ private function sendString($string) private function checkResponse($string) { if (substr($string, 0, 3) !== '+OK') { - $this->setError(array( + $this->error = array( 'error' => "Server reported an error: $string", 'errno' => 0, 'errstr' => '' - )); + ); + if ($this->do_debug >= 1) { + $this->displayErrors(); + } return false; } else { return true; @@ -360,20 +384,16 @@ private function checkResponse($string) } /** - * Add an error to the internal error store. - * Also display debug output if it's enabled. - * @param $error + * Display errors if debug is enabled. + * @access private */ - private function setError($error) + private function displayErrors() { - $this->errors[] = $error; - if ($this->do_debug >= 1) { - echo '
';
-            foreach ($this->errors as $error) {
-                print_r($error);
-            }
-            echo '
'; + echo '
';
+        foreach ($this->error as $single_error) {
+            print_r($single_error);
         }
+        echo '
'; } /** @@ -386,12 +406,12 @@ private function setError($error) */ private function catchWarning($errno, $errstr, $errfile, $errline) { - $this->setError(array( + $this->error[] = array( 'error' => "Connecting to the POP3 server raised a PHP warning: ", 'errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline - )); + ); } } diff --git a/libraries/phpmailer/smtp.php b/libraries/vendor/phpmailer/phpmailer/class.smtp.php similarity index 90% rename from libraries/phpmailer/smtp.php rename to libraries/vendor/phpmailer/phpmailer/class.smtp.php index 9ffdac4eed07a..ec75ca547bd44 100644 --- a/libraries/phpmailer/smtp.php +++ b/libraries/vendor/phpmailer/phpmailer/class.smtp.php @@ -40,13 +40,13 @@ class SMTP /** * The SMTP port to use if one is not specified. - * @type integer + * @type int */ const DEFAULT_SMTP_PORT = 25; /** * The maximum line length allowed by RFC 2822 section 2.1.1 - * @type integer + * @type int */ const MAX_LINE_LENGTH = 998; @@ -60,7 +60,7 @@ class SMTP /** * SMTP server port number. - * @type integer + * @type int * @deprecated This is only ever used as a default value, so use the constant instead * @see SMTP::DEFAULT_SMTP_PORT */ @@ -82,7 +82,7 @@ class SMTP * * `2` Data and commands * * `3` As 2 plus connection status * * `4` Low-level data output - * @type integer + * @type int */ public $do_debug = 0; @@ -100,7 +100,7 @@ class SMTP * Whether to use VERP. * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path * @link http://www.postfix.org/VERP_README.html Info on VERP - * @type boolean + * @type bool */ public $do_verp = false; @@ -109,13 +109,13 @@ class SMTP * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 - * @type integer + * @type int */ public $Timeout = 300; /** * The SMTP timelimit value for reads, in seconds. - * @type integer + * @type int */ public $Timelimit = 30; @@ -127,16 +127,15 @@ class SMTP /** * Error message, if any, for the last call. - * @type array + * @type string */ - protected $error = array(); + protected $error = ''; /** * The reply the server sent to us for HELO. - * If null, no HELO string has yet been received. - * @type string|null + * @type string */ - protected $helo_rply = null; + protected $helo_rply = ''; /** * The most recent reply received from the server. @@ -144,6 +143,18 @@ class SMTP */ protected $last_reply = ''; + /** + * Constructor. + * @access public + */ + public function __construct() + { + $this->smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + $this->do_debug = 0; + } + /** * Output debugging info via a user-selected method. * @param string $str Debug string to output @@ -174,22 +185,16 @@ protected function edebug($str) /** * Connect to an SMTP server. * @param string $host SMTP server IP or host name - * @param integer $port The port number to connect to - * @param integer $timeout How long to wait for the connection to open + * @param int $port The port number to connect to + * @param int $timeout How long to wait for the connection to open * @param array $options An array of options for stream_context_create() * @access public - * @return boolean + * @return bool */ public function connect($host, $port = null, $timeout = 30, $options = array()) { - static $streamok; - //This is enabled by default since 5.0.0 but some providers disable it - //Check this once and cache the result - if (is_null($streamok)) { - $streamok = function_exists('stream_socket_client'); - } // Clear errors to avoid confusion - $this->error = array(); + $this->error = null; // Make sure we are __not__ connected if ($this->connected()) { // Already connected, generate error @@ -201,36 +206,22 @@ public function connect($host, $port = null, $timeout = 30, $options = array()) } // Connect to the SMTP server if ($this->do_debug >= 3) { - $this->edebug("Connection: opening to $host:$port, t=$timeout, opt=".var_export($options, true)); + $this->edebug('Connection: opening'); } $errno = 0; $errstr = ''; - if ($streamok) { - $socket_context = stream_context_create($options); - //Suppress errors; connection failures are handled at a higher level - $this->smtp_conn = @stream_socket_client( - $host . ":" . $port, - $errno, - $errstr, - $timeout, - STREAM_CLIENT_CONNECT, - $socket_context - ); - } else { - //Fall back to fsockopen which should work in more places, but is missing some features - if ($this->do_debug >= 3) { - $this->edebug("Connection: stream_socket_client not available, falling back to fsockopen"); - } - $this->smtp_conn = fsockopen( - $host, - $port, - $errno, - $errstr, - $timeout - ); - } + $socket_context = stream_context_create($options); + //Suppress errors; connection failures are handled at a higher level + $this->smtp_conn = @stream_socket_client( + $host . ":" . $port, + $errno, + $errstr, + $timeout, + STREAM_CLIENT_CONNECT, + $socket_context + ); // Verify we connected properly - if (!is_resource($this->smtp_conn)) { + if (empty($this->smtp_conn)) { $this->error = array( 'error' => 'Failed to connect to server', 'errno' => $errno, @@ -267,7 +258,7 @@ public function connect($host, $port = null, $timeout = 30, $options = array()) /** * Initiate a TLS (encrypted) session. * @access public - * @return boolean + * @return bool */ public function startTLS() { @@ -295,7 +286,7 @@ public function startTLS() * @param string $realm The auth realm for NTLM * @param string $workstation The auth workstation for NTLM * @access public - * @return boolean True if successfully authenticated. + * @return bool True if successfully authenticated. */ public function authenticate( $username, @@ -386,6 +377,7 @@ public function authenticate( ); // send encoded username return $this->sendCommand('Username', base64_encode($msg3), 235); + break; case 'CRAM-MD5': // Start authentication if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) { @@ -399,6 +391,7 @@ public function authenticate( // send encoded credentials return $this->sendCommand('Username', base64_encode($response), 235); + break; } return true; } @@ -442,11 +435,11 @@ protected function hmac($data, $key) /** * Check connection state. * @access public - * @return boolean True if connected. + * @return bool True if connected. */ public function connected() { - if (is_resource($this->smtp_conn)) { + if (!empty($this->smtp_conn)) { $sock_status = stream_get_meta_data($this->smtp_conn); if ($sock_status['eof']) { // the socket is valid but we are not connected @@ -472,14 +465,15 @@ public function connected() */ public function close() { - $this->error = array(); + $this->error = null; // so there is no confusion $this->helo_rply = null; - if (is_resource($this->smtp_conn)) { + if (!empty($this->smtp_conn)) { // close the connection and cleanup fclose($this->smtp_conn); if ($this->do_debug >= 3) { $this->edebug('Connection: closed'); } + $this->smtp_conn = 0; } } @@ -493,7 +487,7 @@ public function close() * Implements rfc 821: DATA * @param string $msg_data Message data to send * @access public - * @return boolean + * @return bool */ public function data($msg_data) { @@ -575,12 +569,12 @@ public function data($msg_data) * and RFC 2821 EHLO. * @param string $host The host name or IP to connect to * @access public - * @return boolean + * @return bool */ public function hello($host = '') { // Try extended hello first (RFC 2821) - return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); + return (bool)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); } /** @@ -590,7 +584,7 @@ public function hello($host = '') * @param string $hello The HELO string * @param string $host The hostname to say we are * @access protected - * @return boolean + * @return bool */ protected function sendHello($hello, $host) { @@ -608,7 +602,7 @@ protected function sendHello($hello, $host) * Implements rfc 821: MAIL FROM: * @param string $from Source address of this message * @access public - * @return boolean + * @return bool */ public function mail($from) { @@ -624,9 +618,9 @@ public function mail($from) * Send an SMTP QUIT command. * Closes the socket if there is no error or the $close_on_error argument is true. * Implements from rfc 821: QUIT - * @param boolean $close_on_error Should the connection close if an error occurs? + * @param bool $close_on_error Should the connection close if an error occurs? * @access public - * @return boolean + * @return bool */ public function quit($close_on_error = true) { @@ -646,7 +640,7 @@ public function quit($close_on_error = true) * Implements from rfc 821: RCPT TO: * @param string $toaddr The address the message is being sent to * @access public - * @return boolean + * @return bool */ public function recipient($toaddr) { @@ -662,7 +656,7 @@ public function recipient($toaddr) * Abort any transaction that is currently in progress. * Implements rfc 821: RSET * @access public - * @return boolean True on success. + * @return bool True on success. */ public function reset() { @@ -673,9 +667,9 @@ public function reset() * Send a command to an SMTP server and check its return code. * @param string $command The command name - not sent to the server * @param string $commandstring The actual command to send - * @param integer|array $expect One or more expected integer success codes + * @param int|array $expect One or more expected integer success codes * @access protected - * @return boolean True on success. + * @return bool True on success. */ protected function sendCommand($command, $commandstring, $expect) { @@ -710,7 +704,7 @@ protected function sendCommand($command, $commandstring, $expect) } $this->last_reply = $reply; - $this->error = array(); + $this->error = null; return true; } @@ -725,7 +719,7 @@ protected function sendCommand($command, $commandstring, $expect) * Implements rfc 821: SAML FROM: * @param string $from The address the message is from * @access public - * @return boolean + * @return bool */ public function sendAndMail($from) { @@ -736,7 +730,7 @@ public function sendAndMail($from) * Send an SMTP VRFY command. * @param string $name The name to verify * @access public - * @return boolean + * @return bool */ public function verify($name) { @@ -747,7 +741,7 @@ public function verify($name) * Send an SMTP NOOP command. * Used to keep keep-alives alive, doesn't actually do anything * @access public - * @return boolean + * @return bool */ public function noop() { @@ -761,7 +755,7 @@ public function noop() * and _may_ be implemented in future * Implements from rfc 821: TURN * @access public - * @return boolean + * @return bool */ public function turn() { @@ -778,7 +772,7 @@ public function turn() * Send raw data to the server. * @param string $data The data to send * @access public - * @return integer|boolean The number of bytes sent to the server or false on error + * @return int|bool The number of bytes sent to the server or false on error */ public function client_send($data) { @@ -869,7 +863,7 @@ protected function get_lines() /** * Enable or disable VERP address generation. - * @param boolean $enabled + * @param bool $enabled */ public function setVerp($enabled = false) { @@ -878,7 +872,7 @@ public function setVerp($enabled = false) /** * Get VERP address generation mode. - * @return boolean + * @return bool */ public function getVerp() { @@ -905,7 +899,7 @@ public function getDebugOutput() /** * Set debug output level. - * @param integer $level + * @param int $level */ public function setDebugLevel($level = 0) { @@ -914,7 +908,7 @@ public function setDebugLevel($level = 0) /** * Get debug output level. - * @return integer + * @return int */ public function getDebugLevel() { @@ -923,7 +917,7 @@ public function getDebugLevel() /** * Set SMTP timeout. - * @param integer $timeout + * @param int $timeout */ public function setTimeout($timeout = 0) { @@ -932,7 +926,7 @@ public function setTimeout($timeout = 0) /** * Get SMTP timeout. - * @return integer + * @return int */ public function getTimeout() { diff --git a/libraries/phpmailer/extras/EasyPeasyICS.php b/libraries/vendor/phpmailer/phpmailer/extras/EasyPeasyICS.php similarity index 99% rename from libraries/phpmailer/extras/EasyPeasyICS.php rename to libraries/vendor/phpmailer/phpmailer/extras/EasyPeasyICS.php index 9ead45e35a2b1..f076895588f8d 100644 --- a/libraries/phpmailer/extras/EasyPeasyICS.php +++ b/libraries/vendor/phpmailer/phpmailer/extras/EasyPeasyICS.php @@ -87,4 +87,4 @@ public function render($output = true){ }//function -}//class +}//class \ No newline at end of file diff --git a/libraries/phpmailer/extras/class.html2text.php b/libraries/vendor/phpmailer/phpmailer/extras/class.html2text.php similarity index 64% rename from libraries/phpmailer/extras/class.html2text.php rename to libraries/vendor/phpmailer/phpmailer/extras/class.html2text.php index 20609919b4a91..4dcd5accfc37e 100644 --- a/libraries/phpmailer/extras/class.html2text.php +++ b/libraries/vendor/phpmailer/phpmailer/extras/class.html2text.php @@ -4,6 +4,7 @@ * Converts HTML to formatted plain text * * * * Portions Copyright (c) 2005-2007 Jon Abernathy * + * This version from https://github.com/mtibben/html2text * * * * This script is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -20,43 +21,46 @@ * * *************************************************************************/ -/** - * Converts HTML to formatted plain text - */ -class Html2Text + +class html2text { + /** - * Contains the HTML content to convert. + * Contains the HTML content to convert. * - * @type string + * @var string $html + * @access public */ - protected $html; + public $html; /** - * Contains the converted, formatted text. + * Contains the converted, formatted text. * - * @type string + * @var string $text + * @access public */ - protected $text; + public $text; /** - * Maximum width of the formatted text, in columns. + * Maximum width of the formatted text, in columns. * - * Set this value to 0 (or less) to ignore word wrapping - * and not constrain text to a fixed-width column. + * Set this value to 0 (or less) to ignore word wrapping + * and not constrain text to a fixed-width column. * - * @type integer + * @var integer $width + * @access public */ - protected $width = 70; + public $width = 70; /** - * List of preg* regular expression patterns to search for, - * used in conjunction with $replace. + * List of preg* regular expression patterns to search for, + * used in conjunction with $replace. * - * @type array - * @see $replace + * @var array $search + * @access public + * @see $replace */ - protected $search = array( + public $search = array( "/\r/", // Non-legal carriage return "/[\n\t]+/", // Newlines and tabs '/]*>.*?<\/head>/i', // @@ -68,10 +72,7 @@ class Html2Text '/]*>(.*?)<\/em>/i', // '/(]*>|<\/ul>)/i', //
    and
'/(]*>|<\/ol>)/i', //
    and
- '/(]*>|<\/dl>)/i', //
and
'/]*>(.*?)<\/li>/i', //
  • and
  • - '/]*>(.*?)<\/dd>/i', //
    and
    - '/]*>(.*?)<\/dt>/i', //
    and
    '/]*>/i', //
  • '/]*>/i', //
    '/]*>/i', //
    @@ -82,12 +83,13 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched. + * List of pattern replacements corresponding to patterns searched. * - * @type array - * @see $search + * @var array $replace + * @access public + * @see $search */ - protected $replace = array( + public $replace = array( '', // Non-legal carriage return ' ', // Newlines and tabs '', // @@ -99,10 +101,7 @@ class Html2Text '_\\1_', // "\n\n", //
      and
    "\n\n", //
      and
    - "\n\n", //
    and
    "\t* \\1\n", //
  • and
  • - " \\1\n", //
    and
    - "\t* \\1", //
    and
    "\n\t* ", //
  • "\n-------------------------\n", //
    "
    \n", //
    @@ -113,13 +112,14 @@ class Html2Text ); /** - * List of preg* regular expression patterns to search for, - * used in conjunction with $ent_replace. + * List of preg* regular expression patterns to search for, + * used in conjunction with $ent_replace. * - * @type array - * @see $ent_replace + * @var array $ent_search + * @access public + * @see $ent_replace */ - protected $ent_search = array( + public $ent_search = array( '/&(nbsp|#160);/i', // Non-breaking space '/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i', // Double quotes @@ -139,12 +139,13 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched. + * List of pattern replacements corresponding to patterns searched. * - * @type array - * @see $ent_search + * @var array $ent_replace + * @access public + * @see $ent_search */ - protected $ent_replace = array( + public $ent_replace = array( ' ', // Non-breaking space '"', // Double quotes "'", // Single quotes @@ -156,34 +157,36 @@ class Html2Text '--', '-', '*', - '£', + '£', 'EUR', // Euro sign. € ? '|+|amp|+|', // Ampersand: see _converter() ' ', // Runs of spaces, post-handling ); /** - * List of preg* regular expression patterns to search for - * and replace using callback function. + * List of preg* regular expression patterns to search for + * and replace using callback function. * - * @type array + * @var array $callback_search + * @access public */ - protected $callback_search = array( + public $callback_search = array( '/<(a) [^>]*href=("|\')([^"\']+)\2([^>]*)>(.*?)<\/a>/i', // - '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 - '/<(b)( [^>]*)?>(.*?)<\/b>/i', // - '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // - '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and + '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 + '/<(b)( [^>]*)?>(.*?)<\/b>/i', // + '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // + '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and ); /** - * List of preg* regular expression patterns to search for in PRE body, - * used in conjunction with $pre_replace. + * List of preg* regular expression patterns to search for in PRE body, + * used in conjunction with $pre_replace. * - * @type array - * @see $pre_replace + * @var array $pre_search + * @access public + * @see $pre_replace */ - protected $pre_search = array( + public $pre_search = array( "/\n/", "/\t/", '/ /', @@ -192,12 +195,13 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched for PRE body. + * List of pattern replacements corresponding to patterns searched for PRE body. * - * @type array - * @see $pre_search + * @var array $pre_replace + * @access public + * @see $pre_search */ - protected $pre_replace = array( + public $pre_replace = array( '
    ', '    ', ' ', @@ -206,76 +210,80 @@ class Html2Text ); /** - * Temporary workspace used during PRE processing. + * Contains a list of HTML tags to allow in the resulting text. * - * @type string + * @var string $allowed_tags + * @access public + * @see set_allowed_tags() */ - protected $pre_content = ''; + public $allowed_tags = ''; /** - * Contains a list of HTML tags to allow in the resulting text. + * Contains the base URL that relative links should resolve to. * - * @type string - * @see set_allowed_tags() + * @var string $url + * @access public */ - protected $allowed_tags = ''; + public $url; /** - * Contains the base URL that relative links should resolve to. + * Indicates whether content in the $html variable has been converted yet. * - * @type string + * @var boolean $_converted + * @access private + * @see $html, $text */ - protected $url; + private $_converted = false; /** - * Indicates whether content in the $html variable has been converted yet. + * Contains URL addresses from links to be rendered in plain text. * - * @type boolean - * @see $html, $text + * @var array $_link_list + * @access private + * @see _build_link_list() */ - protected $_converted = false; + private $_link_list = array(); - /** - * Contains URL addresses from links to be rendered in plain text. - * - * @type array - * @see _build_link_list() - */ - protected $_link_list = array(); /** - * Various configuration options (able to be set in the constructor) + * Various configuration options (able to be set in the constructor) * - * @type array + * @var array $_options + * @access private */ - protected $_options = array( + private $_options = array( + // 'none' // 'inline' (show links inline) // 'nextline' (show links on the next line) // 'table' (if a table of link URLs should be listed after the text. 'do_links' => 'inline', + // Maximum width of the formatted text, in columns. // Set this value to 0 (or less) to ignore word wrapping // and not constrain text to a fixed-width column. 'width' => 70, ); + /** - * Constructor. + * Constructor. * - * If the HTML source string (or file) is supplied, the class - * will instantiate with that source propagated, all that has - * to be done it to call get_text(). + * If the HTML source string (or file) is supplied, the class + * will instantiate with that source propagated, all that has + * to be done it to call get_text(). * - * @param string $source HTML content - * @param boolean $from_file Indicates $source is a file to pull content from - * @param array $options Set configuration options + * @param string $source HTML content + * @param boolean $from_file Indicates $source is a file to pull content from + * @param array $options Set configuration options + * @access public + * @return void */ - public function __construct($source = '', $from_file = false, $options = array()) + public function __construct( $source = '', $from_file = false, $options = array() ) { $this->_options = array_merge($this->_options, $options); - if (!empty($source)) { + if ( !empty($source) ) { $this->set_html($source, $from_file); } @@ -283,30 +291,33 @@ public function __construct($source = '', $from_file = false, $options = array() } /** - * Loads source HTML into memory, either from $source string or a file. + * Loads source HTML into memory, either from $source string or a file. * - * @param string $source HTML content - * @param boolean $from_file Indicates $source is a file to pull content from + * @param string $source HTML content + * @param boolean $from_file Indicates $source is a file to pull content from + * @access public + * @return void */ - public function set_html($source, $from_file = false) + public function set_html( $source, $from_file = false ) { - if ($from_file && file_exists($source)) { + if ( $from_file && file_exists($source) ) { $this->html = file_get_contents($source); - } else { - $this->html = $source; } + else + $this->html = $source; $this->_converted = false; } /** - * Returns the text, converted from HTML. + * Returns the text, converted from HTML. * - * @return string + * @access public + * @return string */ public function get_text() { - if (!$this->_converted) { + if ( !$this->_converted ) { $this->_convert(); } @@ -314,7 +325,10 @@ public function get_text() } /** - * Prints the text, converted from HTML. + * Prints the text, converted from HTML. + * + * @access public + * @return void */ public function print_text() { @@ -322,9 +336,11 @@ public function print_text() } /** - * Alias to print_text(), operates identically. + * Alias to print_text(), operates identically. * - * @see print_text() + * @access public + * @return void + * @see print_text() */ public function p() { @@ -332,27 +348,30 @@ public function p() } /** - * Sets the allowed HTML tags to pass through to the resulting text. + * Sets the allowed HTML tags to pass through to the resulting text. + * + * Tags should be in the form "

    ", with no corresponding closing tag. * - * Tags should be in the form "

    ", with no corresponding closing tag. - * @param string $allowed_tags + * @access public + * @return void */ - public function set_allowed_tags($allowed_tags = '') + public function set_allowed_tags( $allowed_tags = '' ) { - if (!empty($allowed_tags)) { + if ( !empty($allowed_tags) ) { $this->allowed_tags = $allowed_tags; } } /** - * Sets a base URL to handle relative links. + * Sets a base URL to handle relative links. * - * @param string $url + * @access public + * @return void */ - public function set_base_url($url = '') + public function set_base_url( $url = '' ) { - if (empty($url)) { - if (!empty($_SERVER['HTTP_HOST'])) { + if ( empty($url) ) { + if ( !empty($_SERVER['HTTP_HOST']) ) { $this->url = 'http://' . $_SERVER['HTTP_HOST']; } else { $this->url = ''; @@ -360,7 +379,7 @@ public function set_base_url($url = '') } else { // Strip any trailing slashes for consistency (relative // URLs may already start with a slash like "/file.html") - if (substr($url, -1) == '/') { + if ( substr($url, -1) == '/' ) { $url = substr($url, 0, -1); } $this->url = $url; @@ -368,9 +387,12 @@ public function set_base_url($url = '') } /** - * Workhorse function that does actual conversion (calls _converter() method). + * Workhorse function that does actual conversion (calls _converter() method). + * + * @access private + * @return void */ - protected function _convert() + private function _convert() { // Variables used for building the link list $this->_link_list = array(); @@ -384,7 +406,7 @@ protected function _convert() if (!empty($this->_link_list)) { $text .= "\n\nLinks:\n------\n"; foreach ($this->_link_list as $idx => $url) { - $text .= '[' . ($idx + 1) . '] ' . $url . "\n"; + $text .= '[' . ($idx+1) . '] ' . $url . "\n"; } } @@ -394,16 +416,19 @@ protected function _convert() } /** - * Workhorse function that does actual conversion. + * Workhorse function that does actual conversion. + * + * First performs custom tag replacement specified by $search and + * $replace arrays. Then strips any remaining HTML tags, reduces whitespace + * and newlines to a readable format, and word wraps the text to + * $this->_options['width'] characters. * - * First performs custom tag replacement specified by $search and - * $replace arrays. Then strips any remaining HTML tags, reduces whitespace - * and newlines to a readable format, and word wraps the text to - * $this->_options['width'] characters. + * @param string Reference to HTML content string * - * @param string $text Reference to HTML content string + * @access private + * @return void */ - protected function _converter(&$text) + private function _converter(&$text) { // Convert

    (before PRE!) $this->_convert_blockquotes($text); @@ -443,40 +468,39 @@ protected function _converter(&$text) // Wrap the text to a readable format // for PHP versions >= 4.0.2. Default width is 75 // If width is 0 or less, don't wrap the text. - if ($this->_options['width'] > 0) { + if ( $this->_options['width'] > 0 ) { $text = wordwrap($text, $this->_options['width']); } } /** - * Helper function called by preg_replace() on link replacement. + * Helper function called by preg_replace() on link replacement. * - * Maintains an internal list of links to be displayed at the end of the - * text, with numeric indices to the original point in the text they - * appeared. Also makes an effort at identifying and handling absolute - * and relative links. + * Maintains an internal list of links to be displayed at the end of the + * text, with numeric indices to the original point in the text they + * appeared. Also makes an effort at identifying and handling absolute + * and relative links. * - * @param string $link URL of the link - * @param string $display Part of the text to associate number with - * @param null $link_override - * @return string + * @param string $link URL of the link + * @param string $display Part of the text to associate number with + * @access private + * @return string */ - protected function _build_link_list($link, $display, $link_override = null) + private function _build_link_list( $link, $display, $link_override = null) { $link_method = ($link_override) ? $link_override : $this->_options['do_links']; - if ($link_method == 'none') { + if ($link_method == 'none') return $display; - } // Ignored link types if (preg_match('!^(javascript:|mailto:|#)!i', $link)) { return $display; } - if (preg_match('!^([a-z][a-z0-9.+-]+:)!i', $link)) { $url = $link; - } else { + } + else { $url = $this->url; if (substr($link, 0, 1) != '/') { $url .= '/'; @@ -484,52 +508,47 @@ protected function _build_link_list($link, $display, $link_override = null) $url .= "$link"; } - if ($link_method == 'table') { + if ($link_method == 'table') + { if (($index = array_search($url, $this->_link_list)) === false) { $index = count($this->_link_list); $this->_link_list[] = $url; } - return $display . ' [' . ($index + 1) . ']'; - } elseif ($link_method == 'nextline') { + return $display . ' [' . ($index+1) . ']'; + } + elseif ($link_method == 'nextline') + { return $display . "\n[" . $url . ']'; - } else { // link_method defaults to inline - + } + else // link_method defaults to inline + { return $display . ' [' . $url . ']'; } } /** - * Helper function for PRE body conversion. + * Helper function for PRE body conversion. * - * @param string $text HTML content + * @param string HTML content + * @access private */ - protected function _convert_pre(&$text) + private function _convert_pre(&$text) { // get the content of PRE element while (preg_match('/]*>(.*)<\/pre>/ismU', $text, $matches)) { $this->pre_content = $matches[1]; // Run our defined tags search-and-replace with callback - $this->pre_content = preg_replace_callback( - $this->callback_search, - array($this, '_preg_callback'), - $this->pre_content - ); + $this->pre_content = preg_replace_callback($this->callback_search, + array($this, '_preg_callback'), $this->pre_content); // convert the content - $this->pre_content = sprintf( - '

    %s
    ', - preg_replace($this->pre_search, $this->pre_replace, $this->pre_content) - ); - + $this->pre_content = sprintf('

    %s
    ', + preg_replace($this->pre_search, $this->pre_replace, $this->pre_content)); // replace the content (use callback because content can contain $0 variable) - $text = preg_replace_callback( - '/]*>.*<\/pre>/ismU', - array($this, '_preg_pre_callback'), - $text, - 1 - ); + $text = preg_replace_callback('/]*>.*<\/pre>/ismU', + array($this, '_preg_pre_callback'), $text, 1); // free memory $this->pre_content = ''; @@ -537,27 +556,30 @@ protected function _convert_pre(&$text) } /** - * Helper function for BLOCKQUOTE body conversion. + * Helper function for BLOCKQUOTE body conversion. * - * @param string $text HTML content + * @param string HTML content + * @access private */ - protected function _convert_blockquotes(&$text) + private function _convert_blockquotes(&$text) { if (preg_match_all('/<\/*blockquote[^>]*>/i', $text, $matches, PREG_OFFSET_CAPTURE)) { - $start = 0; - $taglen = 0; $level = 0; $diff = 0; + $start = 0; + $taglen = 0; foreach ($matches[0] as $m) { if ($m[0][0] == '<' && $m[0][1] == '/') { $level--; if ($level < 0) { $level = 0; // malformed HTML: go to next blockquote - } elseif ($level > 0) { + } + else if ($level > 0) { // skip inner blockquote - } else { - $end = $m[1]; - $len = $end - $taglen - $start; + } + else { + $end = $m[1]; + $len = $end - $taglen - $start; // Get blockquote content $body = substr($text, $start + $taglen - $diff, $len); @@ -579,56 +601,54 @@ protected function _convert_blockquotes(&$text) $diff = $len + $taglen + strlen($m[0]) - strlen($body); unset($body); } - } else { + } + else { if ($level == 0) { $start = $m[1]; $taglen = strlen($m[0]); } - $level++; + $level ++; } } } } /** - * Callback function for preg_replace_callback use. + * Callback function for preg_replace_callback use. * - * @param array $matches PREG matches - * @return string + * @param array PREG matches + * @return string */ - protected function _preg_callback($matches) + private function _preg_callback($matches) { switch (strtolower($matches[1])) { case 'b': case 'strong': return $this->_toupper($matches[3]); case 'th': - return $this->_toupper("\t\t" . $matches[3] . "\n"); + return $this->_toupper("\t\t". $matches[3] ."\n"); case 'h': - return $this->_toupper("\n\n" . $matches[3] . "\n\n"); + return $this->_toupper("\n\n". $matches[3] ."\n\n"); case 'a': // override the link method $link_override = null; - if (preg_match('/_html2text_link_(\w+)/', $matches[4], $link_override_match)) { + if (preg_match("/_html2text_link_(\w+)/", $matches[4], $link_override_match)) + { $link_override = $link_override_match[1]; } // Remove spaces in URL (#1487805) $url = str_replace(' ', '', $matches[3]); - return $this->_build_link_list($url, $matches[5], $link_override); } - return ''; } /** - * Callback function for preg_replace_callback use in PRE content handler. + * Callback function for preg_replace_callback use in PRE content handler. * - * @param array $matches PREG matches - * @return string + * @param array PREG matches + * @return string */ - protected function _preg_pre_callback( - /** @noinspection PhpUnusedParameterInspection */ - $matches) + private function _preg_pre_callback($matches) { return $this->pre_content; } @@ -641,7 +661,7 @@ protected function _preg_pre_callback( */ private function _toupper($str) { - // string can contain HTML tags + // string can containg HTML tags $chunks = preg_split('/(<[^>]*>)/', $str, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); // convert toupper only the text between HTML tags @@ -656,7 +676,6 @@ private function _toupper($str) /** * Strtoupper multibyte wrapper function with HTML entities handling. - * Forces mb_strtoupper-call to UTF-8. * * @param string $str Text to convert * @return string Converted text @@ -666,7 +685,7 @@ private function _strtoupper($str) $str = html_entity_decode($str, ENT_COMPAT); if (function_exists('mb_strtoupper')) - $str = mb_strtoupper($str, 'UTF-8'); + $str = mb_strtoupper($str); else $str = strtoupper($str); @@ -674,4 +693,4 @@ private function _strtoupper($str) return $str; } -} +} \ No newline at end of file diff --git a/libraries/phpmailer/extras/htmlfilter.php b/libraries/vendor/phpmailer/phpmailer/extras/htmlfilter.php similarity index 97% rename from libraries/phpmailer/extras/htmlfilter.php rename to libraries/vendor/phpmailer/phpmailer/extras/htmlfilter.php index e91b3147af1b4..0c01eaa17c95b 100644 --- a/libraries/phpmailer/extras/htmlfilter.php +++ b/libraries/vendor/phpmailer/phpmailer/extras/htmlfilter.php @@ -34,7 +34,7 @@ * * @param string $tagname the name of the tag. * @param array $attary the array of attributes and their values - * @param integer $tagtype The type of the tag (see in comments). + * @param int $tagtype The type of the tag (see in comments). * @return string A string with the final tag representation. */ function tln_tagprint($tagname, $attary, $tagtype) @@ -75,9 +75,9 @@ function tln_casenormalize(&$val) * a string and to the next non-whitespace value. * * @param string $body the string - * @param integer $offset the offset within the string where we should start + * @param int $offset the offset within the string where we should start * looking for the next non-whitespace character. - * @return integer the location within the $body where the next + * @return int the location within the $body where the next * non-whitespace char is located. */ function tln_skipspace($body, $offset) @@ -96,9 +96,9 @@ function tln_skipspace($body, $offset) * nicely. * * @param string $body The string to look for needle in. - * @param integer $offset Start looking from this position. + * @param int $offset Start looking from this position. * @param string $needle The character/string to look for. - * @return integer location of the next occurrence of the needle, or + * @return int location of the next occurrence of the needle, or * strlen($body) if needle wasn't found. */ function tln_findnxstr($body, $offset, $needle) @@ -115,7 +115,7 @@ function tln_findnxstr($body, $offset, $needle) * within the string. * * @param string $body The string to look for needle in. - * @param integer $offset Start looking from here. + * @param int $offset Start looking from here. * @param string $reg A PCRE-style regex to match. * @return array|boolean Returns a false if no matches found, or an array * with the following members: @@ -143,7 +143,7 @@ function tln_findnxreg($body, $offset, $reg) * This function looks for the next tag. * * @param string $body String where to look for the next tag. - * @param integer $offset Start looking from here. + * @param int $offset Start looking from here. * @return array|boolean false if no more tags exist in the body, or * an array with the following members: * - string with the name of the tag @@ -436,8 +436,8 @@ function tln_getnxtag($body, $offset) * * @param string $attvalue the by-ref value to check. * @param string $regex the regular expression to check against. - * @param boolean $hex whether the entites are hexadecimal. - * @return boolean True or False depending on whether there were matches. + * @param bool $hex whether the entites are hexadecimal. + * @return bool True or False depending on whether there were matches. */ function tln_deent(&$attvalue, $regex, $hex = false) { @@ -583,7 +583,7 @@ function tln_fixatts( * @param array $tag_list see description above * @param array $rm_tags_with_content see description above * @param array $self_closing_tags see description above - * @param boolean $force_tag_closing see description above + * @param bool $force_tag_closing see description above * @param array $rm_attnames see description above * @param array $bad_attvals see description above * @param array $add_attr_to_tag see description above diff --git a/libraries/phpmailer/extras/ntlm_sasl_client.php b/libraries/vendor/phpmailer/phpmailer/extras/ntlm_sasl_client.php similarity index 99% rename from libraries/phpmailer/extras/ntlm_sasl_client.php rename to libraries/vendor/phpmailer/phpmailer/extras/ntlm_sasl_client.php index 7559aa1d735b5..b21ccce0e40a0 100644 --- a/libraries/phpmailer/extras/ntlm_sasl_client.php +++ b/libraries/vendor/phpmailer/phpmailer/extras/ntlm_sasl_client.php @@ -182,4 +182,4 @@ class ntlm_sasl_client_class } }; -?> +?> \ No newline at end of file diff --git a/libraries/vendor/psr/log/LICENSE b/libraries/vendor/psr/log/LICENSE new file mode 100644 index 0000000000000..474c952b4b50c --- /dev/null +++ b/libraries/vendor/psr/log/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 PHP Framework Interoperability Group + +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/libraries/vendor/psr/log/Psr/Log/AbstractLogger.php b/libraries/vendor/psr/log/Psr/Log/AbstractLogger.php new file mode 100644 index 0000000000000..00f9034521b42 --- /dev/null +++ b/libraries/vendor/psr/log/Psr/Log/AbstractLogger.php @@ -0,0 +1,120 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * @return null + */ + public function alert($message, array $context = array()) + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * @return null + */ + public function critical($message, array $context = array()) + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * @return null + */ + public function error($message, array $context = array()) + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * @return null + */ + public function warning($message, array $context = array()) + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * @return null + */ + public function notice($message, array $context = array()) + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * @return null + */ + public function info($message, array $context = array()) + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * @return null + */ + public function debug($message, array $context = array()) + { + $this->log(LogLevel::DEBUG, $message, $context); + } +} diff --git a/libraries/vendor/psr/log/Psr/Log/InvalidArgumentException.php b/libraries/vendor/psr/log/Psr/Log/InvalidArgumentException.php new file mode 100644 index 0000000000000..67f852d1dbc66 --- /dev/null +++ b/libraries/vendor/psr/log/Psr/Log/InvalidArgumentException.php @@ -0,0 +1,7 @@ +logger = $logger; + } +} diff --git a/libraries/vendor/psr/log/Psr/Log/LoggerInterface.php b/libraries/vendor/psr/log/Psr/Log/LoggerInterface.php new file mode 100644 index 0000000000000..476bb962af788 --- /dev/null +++ b/libraries/vendor/psr/log/Psr/Log/LoggerInterface.php @@ -0,0 +1,114 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * @return null + */ + public function alert($message, array $context = array()) + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * @return null + */ + public function critical($message, array $context = array()) + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * @return null + */ + public function error($message, array $context = array()) + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * @return null + */ + public function warning($message, array $context = array()) + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * @return null + */ + public function notice($message, array $context = array()) + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * @return null + */ + public function info($message, array $context = array()) + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * @return null + */ + public function debug($message, array $context = array()) + { + $this->log(LogLevel::DEBUG, $message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + abstract public function log($level, $message, array $context = array()); +} diff --git a/libraries/vendor/psr/log/Psr/Log/NullLogger.php b/libraries/vendor/psr/log/Psr/Log/NullLogger.php new file mode 100644 index 0000000000000..553a3c593ae5f --- /dev/null +++ b/libraries/vendor/psr/log/Psr/Log/NullLogger.php @@ -0,0 +1,27 @@ +logger) { }` + * blocks. + */ +class NullLogger extends AbstractLogger +{ + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + public function log($level, $message, array $context = array()) + { + // noop + } +} diff --git a/libraries/framework/Symfony/Component/Yaml/Dumper.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php similarity index 86% rename from libraries/framework/Symfony/Component/Yaml/Dumper.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php index 8709f8b7e4628..26103c88ece9f 100644 --- a/libraries/framework/Symfony/Component/Yaml/Dumper.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php @@ -21,14 +21,14 @@ class Dumper /** * The amount of spaces to use for indentation of nested nodes. * - * @var integer + * @var int */ protected $indentation = 4; /** * Sets the indentation. * - * @param integer $num The amount of spaces to use for indentation of nested nodes. + * @param int $num The amount of spaces to use for indentation of nested nodes. */ public function setIndentation($num) { @@ -39,10 +39,10 @@ public function setIndentation($num) * Dumps a PHP value to YAML. * * @param mixed $input The PHP value - * @param integer $inline The level where you switch to inline YAML - * @param integer $indent The level of indentation (used internally) - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param int $inline The level where you switch to inline YAML + * @param int $indent The level of indentation (used internally) + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML representation of the PHP value */ diff --git a/libraries/framework/Symfony/Component/Yaml/Escaper.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php similarity index 89% rename from libraries/framework/Symfony/Component/Yaml/Escaper.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php index 3576e9ae6faa4..7f6ec2bef297d 100644 --- a/libraries/framework/Symfony/Component/Yaml/Escaper.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php @@ -26,25 +26,25 @@ class Escaper // first to ensure proper escaping because str_replace operates iteratively // on the input arrays. This ordering of the characters avoids the use of strtr, // which performs more slowly. - private static $escapees = array('\\\\', '\\"', '"', + private static $escapees = array('\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", - "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); - private static $escaped = array('\\"', '\\\\', '\\"', + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",); + private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", - "\\N", "\\_", "\\L", "\\P"); + "\\N", "\\_", "\\L", "\\P",); /** * Determines if a PHP value would require double quoting in YAML. * * @param string $value A PHP value * - * @return Boolean True if the value would require double quotes. + * @return bool True if the value would require double quotes. */ public static function requiresDoubleQuoting($value) { @@ -68,7 +68,7 @@ public static function escapeWithDoubleQuotes($value) * * @param string $value A PHP value * - * @return Boolean True if the value would require single quotes. + * @return bool True if the value would require single quotes. */ public static function requiresSingleQuoting($value) { diff --git a/libraries/framework/Symfony/Component/Yaml/Exception/DumpException.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php similarity index 100% rename from libraries/framework/Symfony/Component/Yaml/Exception/DumpException.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php diff --git a/libraries/framework/Symfony/Component/Yaml/Exception/ExceptionInterface.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php similarity index 100% rename from libraries/framework/Symfony/Component/Yaml/Exception/ExceptionInterface.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php diff --git a/libraries/framework/Symfony/Component/Yaml/Exception/ParseException.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php similarity index 94% rename from libraries/framework/Symfony/Component/Yaml/Exception/ParseException.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php index 938097b8b3e59..ff01d6b9a69cc 100644 --- a/libraries/framework/Symfony/Component/Yaml/Exception/ParseException.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php @@ -34,8 +34,8 @@ class ParseException extends RuntimeException * Constructor. * * @param string $message The error message - * @param integer $parsedLine The line where the error occurred - * @param integer $snippet The snippet of code near the problem + * @param int $parsedLine The line where the error occurred + * @param int $snippet The snippet of code near the problem * @param string $parsedFile The file name where the error occurred * @param \Exception $previous The previous exception */ @@ -100,7 +100,7 @@ public function setParsedFile($parsedFile) /** * Gets the line where the error occurred. * - * @return integer The file line + * @return int The file line */ public function getParsedLine() { @@ -110,7 +110,7 @@ public function getParsedLine() /** * Sets the line where the error occurred. * - * @param integer $parsedLine The file line + * @param int $parsedLine The file line */ public function setParsedLine($parsedLine) { diff --git a/libraries/framework/Symfony/Component/Yaml/Exception/RuntimeException.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php similarity index 100% rename from libraries/framework/Symfony/Component/Yaml/Exception/RuntimeException.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php diff --git a/libraries/framework/Symfony/Component/Yaml/Inline.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php similarity index 66% rename from libraries/framework/Symfony/Component/Yaml/Inline.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php index 45efced3c89ac..8fec216dde139 100644 --- a/libraries/framework/Symfony/Component/Yaml/Inline.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php @@ -30,14 +30,15 @@ class Inline * Converts a YAML string to a PHP array. * * @param string $value A YAML string - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise + * @param array $references Mapping of variable names to values * * @return array A PHP array representing the YAML string * * @throws ParseException */ - public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) + public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $references = array()) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; @@ -56,15 +57,15 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup $i = 0; switch ($value[0]) { case '[': - $result = self::parseSequence($value, $i); + $result = self::parseSequence($value, $i, $references); ++$i; break; case '{': - $result = self::parseMapping($value, $i); + $result = self::parseMapping($value, $i, $references); ++$i; break; default: - $result = self::parseScalar($value, null, array('"', "'"), $i); + $result = self::parseScalar($value, null, array('"', "'"), $i, true, $references); } // some comments are allowed at the end @@ -83,8 +84,8 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup * Dumps a given PHP variable to a YAML string. * * @param mixed $value The PHP variable to convert - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array * @@ -149,8 +150,8 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp * Dumps a PHP array to a YAML string. * * @param array $value The PHP array to dump - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array */ @@ -159,7 +160,7 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor // array $keys = array_keys($value); if ((1 == count($keys) && '0' == $keys[0]) - || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) + || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) ) { $output = array(); foreach ($value as $val) { @@ -184,14 +185,15 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor * @param scalar $scalar * @param string $delimiters * @param array $stringDelimiters - * @param integer &$i - * @param Boolean $evaluate + * @param int &$i + * @param bool $evaluate + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true, $references = array()) { if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar @@ -220,7 +222,9 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); } - $output = $evaluate ? self::evaluateScalar($output) : $output; + if ($evaluate) { + $output = self::evaluateScalar($output, $references); + } } return $output; @@ -230,7 +234,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter * Parses a quoted scalar to YAML. * * @param string $scalar - * @param integer &$i + * @param int &$i * * @return string A YAML string * @@ -260,13 +264,14 @@ private static function parseQuotedScalar($scalar, &$i) * Parses a sequence to a YAML string. * * @param string $sequence - * @param integer &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseSequence($sequence, &$i = 0) + private static function parseSequence($sequence, &$i = 0, $references = array()) { $output = array(); $len = strlen($sequence); @@ -277,11 +282,11 @@ private static function parseSequence($sequence, &$i = 0) switch ($sequence[$i]) { case '[': // nested sequence - $output[] = self::parseSequence($sequence, $i); + $output[] = self::parseSequence($sequence, $i, $references); break; case '{': // nested mapping - $output[] = self::parseMapping($sequence, $i); + $output[] = self::parseMapping($sequence, $i, $references); break; case ']': return $output; @@ -290,12 +295,14 @@ private static function parseSequence($sequence, &$i = 0) break; default: $isQuoted = in_array($sequence[$i], array('"', "'")); - $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i, true, $references); - if (!$isQuoted && false !== strpos($value, ': ')) { + // the value can be an array if a reference has been resolved to an array var + if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { - $value = self::parseMapping('{'.$value.'}'); + $pos = 0; + $value = self::parseMapping('{'.$value.'}', $pos, $references); } catch (\InvalidArgumentException $e) { // no, it's not } @@ -316,13 +323,14 @@ private static function parseSequence($sequence, &$i = 0) * Parses a mapping to a YAML string. * * @param string $mapping - * @param integer &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseMapping($mapping, &$i = 0) + private static function parseMapping($mapping, &$i = 0, $references = array()) { $output = array(); $len = strlen($mapping); @@ -348,19 +356,37 @@ private static function parseMapping($mapping, &$i = 0) switch ($mapping[$i]) { case '[': // nested sequence - $output[$key] = self::parseSequence($mapping, $i); + $value = self::parseSequence($mapping, $i, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; break; case '{': // nested mapping - $output[$key] = self::parseMapping($mapping, $i); + $value = self::parseMapping($mapping, $i, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; break; case ':': case ' ': break; default: - $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i, true, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; --$i; } @@ -380,57 +406,84 @@ private static function parseMapping($mapping, &$i = 0) * Evaluates scalars and replaces magic values. * * @param string $scalar + * @param array $references * * @return string A YAML string + * + * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ - private static function evaluateScalar($scalar) + private static function evaluateScalar($scalar, $references = array()) { $scalar = trim($scalar); + $scalarLower = strtolower($scalar); - switch (true) { - case 'null' == strtolower($scalar): - case '' == $scalar: - case '~' == $scalar: - return null; - case 0 === strpos($scalar, '!str'): - return (string) substr($scalar, 5); - case 0 === strpos($scalar, '! '): - return intval(self::parseScalar(substr($scalar, 2))); - case 0 === strpos($scalar, '!!php/object:'): - if (self::$objectSupport) { - return unserialize(substr($scalar, 13)); - } + if (0 === strpos($scalar, '*')) { + if (false !== $pos = strpos($scalar, '#')) { + $value = substr($scalar, 1, $pos - 2); + } else { + $value = substr($scalar, 1); + } - if (self::$exceptionOnInvalidType) { - throw new ParseException('Object support when parsing a YAML file has been disabled.'); - } + // an unquoted * + if (false === $value || '' === $value) { + throw new ParseException('A reference must contain at least one character.'); + } - return null; - case ctype_digit($scalar): - $raw = $scalar; - $cast = intval($scalar); + if (!array_key_exists($value, $references)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $value)); + } - return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); - case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): - $raw = $scalar; - $cast = intval($scalar); + return $references[$value]; + } - return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); - case 'true' === strtolower($scalar): + switch (true) { + case 'null' === $scalarLower: + case '' === $scalar: + case '~' === $scalar: + return; + case 'true' === $scalarLower: return true; - case 'false' === strtolower($scalar): + case 'false' === $scalarLower: return false; - case is_numeric($scalar): - return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); - case 0 == strcasecmp($scalar, '.inf'): - case 0 == strcasecmp($scalar, '.NaN'): - return -log(0); - case 0 == strcasecmp($scalar, '-.inf'): - return log(0); - case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): - return floatval(str_replace(',', '', $scalar)); - case preg_match(self::getTimestampRegex(), $scalar): - return strtotime($scalar); + // Optimise for returning strings. + case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || $scalar[0] === '!' || is_numeric($scalar[0]): + switch (true) { + case 0 === strpos($scalar, '!str'): + return (string) substr($scalar, 5); + case 0 === strpos($scalar, '! '): + return intval(self::parseScalar(substr($scalar, 2))); + case 0 === strpos($scalar, '!!php/object:'): + if (self::$objectSupport) { + return unserialize(substr($scalar, 13)); + } + + if (self::$exceptionOnInvalidType) { + throw new ParseException('Object support when parsing a YAML file has been disabled.'); + } + + return; + case ctype_digit($scalar): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case is_numeric($scalar): + return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); + case '.inf' === $scalarLower: + case '.nan' === $scalarLower: + return -log(0); + case '-.inf' === $scalarLower: + return log(0); + case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): + return floatval(str_replace(',', '', $scalar)); + case preg_match(self::getTimestampRegex(), $scalar): + return strtotime($scalar); + } default: return (string) $scalar; } diff --git a/libraries/framework/Symfony/Component/Yaml/LICENSE b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE similarity index 96% rename from libraries/framework/Symfony/Component/Yaml/LICENSE rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE index 88a57f8d8da49..0b3292cf90235 100644 --- a/libraries/framework/Symfony/Component/Yaml/LICENSE +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +Copyright (c) 2004-2014 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 diff --git a/libraries/framework/Symfony/Component/Yaml/Parser.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php similarity index 77% rename from libraries/framework/Symfony/Component/Yaml/Parser.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index e8fe91848ebbd..fd9afafe36b4d 100644 --- a/libraries/framework/Symfony/Component/Yaml/Parser.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -31,7 +31,7 @@ class Parser /** * Constructor * - * @param integer $offset The offset of YAML document (used for line numbers in error messages) + * @param int $offset The offset of YAML document (used for line numbers in error messages) */ public function __construct($offset = 0) { @@ -42,8 +42,8 @@ public function __construct($offset = 0) * Parses a YAML string to a PHP value. * * @param string $value A YAML string - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return mixed A PHP value * @@ -55,7 +55,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); - if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { + if (!preg_match('//u', $value)) { throw new ParseException('The YAML value does not appear to be valid UTF-8.'); } @@ -66,6 +66,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data = array(); $context = null; + $allowOverwrite = false; while ($this->moveToNextLine()) { if ($this->isCurrentLineEmpty()) { continue; @@ -76,7 +77,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } - $isRef = $isInPlace = $isProcessed = false; + $isRef = $mergeNode = false; if (preg_match('#^\-((?P\s+)(?P.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'mapping' == $context) { throw new ParseException('You cannot define a sequence item when in a mapping'); @@ -92,8 +93,8 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; - $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + $parser->refs = & $this->refs; + $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] @@ -102,7 +103,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $block = $values['value']; if ($this->isNextLineIndented()) { @@ -114,14 +115,14 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } - } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) { + } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'],' #') || in_array($values['key'][0], array('"', "'")))) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } $context = 'mapping'; // force correct settings - Inline::parse(null, $exceptionOnInvalidType, $objectSupport); + Inline::parse(null, $exceptionOnInvalidType, $objectSupport, $this->refs); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { @@ -132,10 +133,24 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } if ('<<' === $key) { + $mergeNode = true; + $allowOverwrite = true; if (isset($values['value']) && 0 === strpos($values['value'], '*')) { - $isInPlace = substr($values['value'], 1); - if (!array_key_exists($isInPlace, $this->refs)) { - throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); + $refName = substr($values['value'], 1); + if (!array_key_exists($refName, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + $refValue = $this->refs[$refName]; + + if (!is_array($refValue)) { + throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + foreach ($refValue as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } } } else { if (isset($values['value']) && $values['value'] !== '') { @@ -145,51 +160,71 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); - $merged = array(); if (!is_array($parsed)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); - } elseif (isset($parsed[0])) { - // Numeric array, merge individual elements - foreach (array_reverse($parsed) as $parsedItem) { + } + + if (isset($parsed[0])) { + // If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes + // and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier + // in the sequence override keys specified in later mapping nodes. + foreach ($parsed as $parsedItem) { if (!is_array($parsedItem)) { throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); } - $merged = array_merge($parsedItem, $merged); + + foreach ($parsedItem as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } } } else { - // Associative array, merge - $merged = array_merge($merged, $parsed); + // If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the + // current mapping, unless the key already exists in it. + foreach ($parsed as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } } - - $isProcessed = $merged; } } elseif (isset($values['value']) && preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } - if ($isProcessed) { + if ($mergeNode) { // Merge keys - $data = $isProcessed; - // hash } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + // hash // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { - $data[$key] = null; + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = null; + } } else { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; - $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + $parser->refs = & $this->refs; + $value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = $value; + } } } else { - if ($isInPlace) { - $data = $this->refs[$isInPlace]; - } else { - $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + $value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = $value; } } } else { @@ -197,7 +232,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $lineCount = count($this->lines); if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { - $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); + $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -261,7 +296,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = /** * Returns the current line number (takes the offset into account). * - * @return integer The current line number + * @return int The current line number */ private function getRealCurrentLineNb() { @@ -271,7 +306,7 @@ private function getRealCurrentLineNb() /** * Returns the current line indentation. * - * @return integer The current line indentation + * @return int The current line indentation */ private function getCurrentLineIndentation() { @@ -281,15 +316,20 @@ private function getCurrentLineIndentation() /** * Returns the next embed block of YAML. * - * @param integer $indentation The indent level at which the block is to be read, or null for default + * @param int $indentation The indent level at which the block is to be read, or null for default + * @param bool $inSequence True if the enclosing data structure is a sequence * * @return string A YAML string * * @throws ParseException When indentation problem are detected */ - private function getNextEmbedBlock($indentation = null) + private function getNextEmbedBlock($indentation = null, $inSequence = false) { - $this->moveToNextLine(); + $oldLineIndentation = $this->getCurrentLineIndentation(); + + if (!$this->moveToNextLine()) { + return; + } if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); @@ -305,6 +345,14 @@ private function getNextEmbedBlock($indentation = null) $data = array(substr($this->currentLine, $newIndent)); + if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) { + // the previous line contained a dash but no item content, this line is a sequence item with the same indentation + // and therefore no nested list or mapping + $this->moveToPreviousLine(); + + return; + } + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); // Comments must not be removed inside a string block (ie. after a line ending with "|") @@ -312,7 +360,9 @@ private function getNextEmbedBlock($indentation = null) $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); while ($this->moveToNextLine()) { - if ($this->getCurrentLineIndentation() === $newIndent) { + $indent = $this->getCurrentLineIndentation(); + + if ($indent === $newIndent) { $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); } @@ -321,20 +371,16 @@ private function getNextEmbedBlock($indentation = null) break; } - if ($removeComments && $this->isCurrentLineEmpty() || $this->isCurrentLineBlank()) { - if ($this->isCurrentLineBlank()) { - $data[] = substr($this->currentLine, $newIndent); - } - + if ($this->isCurrentLineBlank()) { + $data[] = substr($this->currentLine, $newIndent); continue; } - $indent = $this->getCurrentLineIndentation(); + if ($removeComments && $this->isCurrentLineComment()) { + continue; + } - if (preg_match('#^(?P *)$#', $this->currentLine, $match)) { - // empty line - $data[] = $match['text']; - } elseif ($indent >= $newIndent) { + if ($indent >= $newIndent) { $data[] = substr($this->currentLine, $newIndent); } elseif (0 == $indent) { $this->moveToPreviousLine(); @@ -351,7 +397,7 @@ private function getNextEmbedBlock($indentation = null) /** * Moves the parser to the next line. * - * @return Boolean + * @return bool */ private function moveToNextLine() { @@ -376,8 +422,8 @@ private function moveToPreviousLine() * Parses a YAML value. * * @param string $value A YAML value - * @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise - * @param Boolean $objectSupport True if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise + * @param bool $objectSupport True if object support is enabled, false otherwise * * @return mixed A PHP value * @@ -406,7 +452,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport) } try { - return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); + return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -420,7 +466,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport) * * @param string $separator The separator that was used to begin this folded scalar (| or >) * @param string $indicator The indicator that was used to begin this folded scalar (+ or -) - * @param integer $indentation The indentation that was used to begin this folded scalar + * @param int $indentation The indentation that was used to begin this folded scalar * * @return string The text value */ @@ -499,7 +545,7 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0 /** * Returns true if the next line is indented. * - * @return Boolean Returns true if the next line is indented, false otherwise + * @return bool Returns true if the next line is indented, false otherwise */ private function isNextLineIndented() { @@ -527,7 +573,7 @@ private function isNextLineIndented() /** * Returns true if the current line is blank or if it is a comment line. * - * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise + * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise */ private function isCurrentLineEmpty() { @@ -537,7 +583,7 @@ private function isCurrentLineEmpty() /** * Returns true if the current line is blank. * - * @return Boolean Returns true if the current line is blank, false otherwise + * @return bool Returns true if the current line is blank, false otherwise */ private function isCurrentLineBlank() { @@ -547,7 +593,7 @@ private function isCurrentLineBlank() /** * Returns true if the current line is a comment line. * - * @return Boolean Returns true if the current line is a comment line, false otherwise + * @return bool Returns true if the current line is a comment line, false otherwise */ private function isCurrentLineComment() { @@ -598,7 +644,7 @@ private function cleanup($value) /** * Returns true if the next line starts unindented collection * - * @return Boolean Returns true if the next line starts unindented collection, false otherwise + * @return bool Returns true if the next line starts unindented collection, false otherwise */ private function isNextLineUnIndentedCollection() { @@ -630,11 +676,10 @@ private function isNextLineUnIndentedCollection() /** * Returns true if the string is un-indented collection item * - * @return Boolean Returns true if the string is un-indented collection item, false otherwise + * @return bool Returns true if the string is un-indented collection item, false otherwise */ private function isStringUnIndentedCollectionItem() { return (0 === strpos($this->currentLine, '- ')); } - } diff --git a/libraries/framework/Symfony/Component/Yaml/Unescaper.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php similarity index 63% rename from libraries/framework/Symfony/Component/Yaml/Unescaper.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php index 1b8eeed57a94a..50b1018c404c1 100644 --- a/libraries/framework/Symfony/Component/Yaml/Unescaper.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php @@ -21,6 +21,7 @@ class Unescaper { // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters // must be converted to that encoding. + // @deprecated since 2.5, to be removed in 3.0 const ENCODING = 'UTF-8'; // Regex fragment that matches an escaped character in a double quoted @@ -80,13 +81,13 @@ public function unescapeCharacter($value) case 'n': return "\n"; case 'v': - return "\xb"; + return "\xB"; case 'f': - return "\xc"; + return "\xC"; case 'r': - return "\xd"; + return "\r"; case 'e': - return "\x1b"; + return "\x1B"; case ' ': return ' '; case '"': @@ -97,50 +98,44 @@ public function unescapeCharacter($value) return '\\'; case 'N': // U+0085 NEXT LINE - return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE'); + return "\xC2\x85"; case '_': // U+00A0 NO-BREAK SPACE - return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE'); + return "\xC2\xA0"; case 'L': // U+2028 LINE SEPARATOR - return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA8"; case 'P': // U+2029 PARAGRAPH SEPARATOR - return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA9"; case 'x': - $char = pack('n', hexdec(substr($value, 2, 2))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 2))); case 'u': - $char = pack('n', hexdec(substr($value, 2, 4))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 4))); case 'U': - $char = pack('N', hexdec(substr($value, 2, 8))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE'); + return self::utf8chr(hexdec(substr($value, 2, 8))); } } /** - * Convert a string from one encoding to another. + * Get the UTF-8 character for the given code point. * - * @param string $value The string to convert - * @param string $to The input encoding - * @param string $from The output encoding + * @param int $c The unicode code point * - * @return string The string with the new encoding - * - * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @return string The corresponding UTF-8 character */ - private function convertEncoding($value, $to, $from) + private static function utf8chr($c) { - if (function_exists('mb_convert_encoding')) { - return mb_convert_encoding($value, $to, $from); - } elseif (function_exists('iconv')) { - return iconv($from, $to, $value); + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } - throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } } diff --git a/libraries/framework/Symfony/Component/Yaml/Yaml.php b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php similarity index 88% rename from libraries/framework/Symfony/Component/Yaml/Yaml.php rename to libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php index c98f6ecdd96e7..61793fb3ae473 100644 --- a/libraries/framework/Symfony/Component/Yaml/Yaml.php +++ b/libraries/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php @@ -39,8 +39,8 @@ class Yaml * as an input is a deprecated feature and will be removed in 3.0. * * @param string $input Path to a YAML file or a string containing YAML - * @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise - * @param Boolean $objectSupport True if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise + * @param bool $objectSupport True if object support is enabled, false otherwise * * @return array The YAML converted to a PHP array * @@ -81,10 +81,10 @@ public static function parse($input, $exceptionOnInvalidType = false, $objectSup * to convert the array into friendly YAML. * * @param array $array PHP array - * @param integer $inline The level where you switch to inline YAML - * @param integer $indent The amount of spaces to use for indentation of nested nodes. - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param int $inline The level where you switch to inline YAML + * @param int $indent The amount of spaces to use for indentation of nested nodes. + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string A YAML string representing the original PHP array * diff --git a/tests/unit/suites/libraries/joomla/input/JInputCliTest.php b/tests/unit/suites/libraries/joomla/input/JInputCliTest.php index e95ed9b0af7ff..89d3936070340 100644 --- a/tests/unit/suites/libraries/joomla/input/JInputCliTest.php +++ b/tests/unit/suites/libraries/joomla/input/JInputCliTest.php @@ -43,7 +43,7 @@ protected function setUp() public function test_parseArguments($inputArgv, $expectedData, $expectedArgs) { $_SERVER['argv'] = $inputArgv; - $this->inspector = new JInputCLI(null, array('filter' => new JFilterInputMock)); + $this->inspector = new JInputCli(null, array('filter' => new JFilterInputMock)); $this->assertThat( TestReflection::getValue($this->inspector, 'data'), diff --git a/tests/unit/suites/libraries/joomla/registry/format/JRegistryFormatIniTest.php b/tests/unit/suites/libraries/joomla/registry/format/JRegistryFormatIniTest.php index 01a5dc597aa5c..56f395d0362a8 100644 --- a/tests/unit/suites/libraries/joomla/registry/format/JRegistryFormatIniTest.php +++ b/tests/unit/suites/libraries/joomla/registry/format/JRegistryFormatIniTest.php @@ -25,7 +25,6 @@ class JRegistryFormatINITest extends PHPUnit_Framework_TestCase public function testObjectToString() { $class = JRegistryFormat::getInstance('INI'); - $options = null; $object = new stdClass; $object->foo = 'bar'; $object->booleantrue = true; @@ -36,7 +35,7 @@ public function testObjectToString() $object->section->key = 'value'; // Test basic object to string. - $string = $class->objectToString($object, $options); + $string = $class->objectToString($object); $this->assertThat( trim($string), $this->equalTo("foo=\"bar\"\nbooleantrue=true\nbooleanfalse=false\nnumericint=42\nnumericfloat=3.1415\n\n[section]\nkey=\"value\"") diff --git a/tests/unit/suites/libraries/joomla/string/JStringInflectorTest.php b/tests/unit/suites/libraries/joomla/string/JStringInflectorTest.php index 679c32adf23b8..d7687c9c7fe72 100644 --- a/tests/unit/suites/libraries/joomla/string/JStringInflectorTest.php +++ b/tests/unit/suites/libraries/joomla/string/JStringInflectorTest.php @@ -97,19 +97,18 @@ protected function setUp() } /** - * Method to test JStringInflector::_addRule(). + * Method to test JStringInflector::addRule(). * * @return void * * @since 12.1 - * @covers JStringInflector::_addRule */ - public function test_addRule() + public function testAddRule() { // Case 1 - TestReflection::invoke($this->inflector, '_addRule', '/foo/', 'singular'); + TestReflection::invoke($this->inflector, 'addRule', '/foo/', 'singular'); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('/foo/', $rules['singular']), @@ -118,9 +117,9 @@ public function test_addRule() ); // Case 2 - TestReflection::invoke($this->inflector, '_addRule', '/bar/', 'plural'); + TestReflection::invoke($this->inflector, 'addRule', '/bar/', 'plural'); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('/bar/', $rules['plural']), @@ -129,9 +128,9 @@ public function test_addRule() ); // Case 3 - TestReflection::invoke($this->inflector, '_addRule', array('/goo/', '/car/'), 'singular'); + TestReflection::invoke($this->inflector, 'addRule', array('/goo/', '/car/'), 'singular'); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('/goo/', $rules['singular']), @@ -147,113 +146,108 @@ public function test_addRule() } /** - * Method to test JStringInflector::_addRule(). + * Method to test JStringInflector::addRule(). * * @return void * * @since 12.1 * @expectedException InvalidArgumentException - * @covers JStringInflector::_addRule */ - public function test_addRuleException() + public function testaddRuleException() { - TestReflection::invoke($this->inflector, '_addRule', new stdClass, 'singular'); + TestReflection::invoke($this->inflector, 'addRule', new stdClass, 'singular'); } /** - * Method to test JStringInflector::_getCachedPlural(). + * Method to test JStringInflector::getCachedPlural(). * * @return void * * @since 12.1 - * @covers JStringInflector::_getCachedPlural */ - public function test_getCachedPlural() + public function testGetCachedPlural() { // Reset the cache. - TestReflection::setValue($this->inflector, '_cache', array('foo' => 'bar')); + TestReflection::setValue($this->inflector, 'cache', array('foo' => 'bar')); $this->assertThat( - TestReflection::invoke($this->inflector, '_getCachedPlural', 'bar'), + TestReflection::invoke($this->inflector, 'getCachedPlural', 'bar'), $this->isFalse(), 'Checks for an uncached plural.' ); $this->assertThat( - TestReflection::invoke($this->inflector, '_getCachedPlural', 'foo'), + TestReflection::invoke($this->inflector, 'getCachedPlural', 'foo'), $this->equalTo('bar'), 'Checks for a cached plural word.' ); } /** - * Method to test JStringInflector::_getCachedSingular(). + * Method to test JStringInflector::getCachedSingular(). * * @return void * * @since 12.1 - * @covers JStringInflector::_getCachedSingular */ - public function test_getCachedSingular() + public function testGetCachedSingular() { // Reset the cache. - TestReflection::setValue($this->inflector, '_cache', array('foo' => 'bar')); + TestReflection::setValue($this->inflector, 'cache', array('foo' => 'bar')); $this->assertThat( - TestReflection::invoke($this->inflector, '_getCachedSingular', 'foo'), + TestReflection::invoke($this->inflector, 'getCachedSingular', 'foo'), $this->isFalse(), 'Checks for an uncached singular.' ); $this->assertThat( - TestReflection::invoke($this->inflector, '_getCachedSingular', 'bar'), + TestReflection::invoke($this->inflector, 'getCachedSingular', 'bar'), $this->equalTo('foo'), 'Checks for a cached singular word.' ); } /** - * Method to test JStringInflector::_matchRegexRule(). + * Method to test JStringInflector::matchRegexRule(). * * @return void * * @since 12.1 - * @covers JStringInflector::_matchRegexRule */ - public function test_matchRegexRule() + public function testMatchRegexRule() { $this->assertThat( - TestReflection::invoke($this->inflector, '_matchRegexRule', 'xyz', 'plural'), + TestReflection::invoke($this->inflector, 'matchRegexRule', 'xyz', 'plural'), $this->equalTo('xyzs'), 'Checks pluralising against the basic regex.' ); $this->assertThat( - TestReflection::invoke($this->inflector, '_matchRegexRule', 'xyzs', 'singular'), + TestReflection::invoke($this->inflector, 'matchRegexRule', 'xyzs', 'singular'), $this->equalTo('xyz'), 'Checks singularising against the basic regex.' ); $this->assertThat( - TestReflection::invoke($this->inflector, '_matchRegexRule', 'xyz', 'singular'), + TestReflection::invoke($this->inflector, 'matchRegexRule', 'xyz', 'singular'), $this->isFalse(), 'Checks singularising against an unmatched regex.' ); } /** - * Method to test JStringInflector::_setCache(). + * Method to test JStringInflector::setCache(). * * @return void * * @since 12.1 - * @covers JStringInflector::_setCache */ - public function test_setCache() + public function testSetCache() { - TestReflection::invoke($this->inflector, '_setCache', 'foo', 'bar'); + TestReflection::invoke($this->inflector, 'setCache', 'foo', 'bar'); - $cache = TestReflection::getValue($this->inflector, '_cache'); + $cache = TestReflection::getValue($this->inflector, 'cache'); $this->assertThat( $cache['foo'], @@ -261,9 +255,9 @@ public function test_setCache() 'Checks the cache was set.' ); - TestReflection::invoke($this->inflector, '_setCache', 'foo', 'car'); + TestReflection::invoke($this->inflector, 'setCache', 'foo', 'car'); - $cache = TestReflection::getValue($this->inflector, '_cache'); + $cache = TestReflection::getValue($this->inflector, 'cache'); $this->assertThat( $cache['foo'], @@ -278,14 +272,13 @@ public function test_setCache() * @return void * * @since 12.1 - * @covers JStringInflector::addCountableRule */ public function testAddCountableRule() { // Add string. $this->inflector->addCountableRule('foo'); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('foo', $rules['countable']), @@ -296,7 +289,7 @@ public function testAddCountableRule() // Add array. $this->inflector->addCountableRule(array('goo', 'car')); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('car', $rules['countable']), @@ -311,7 +304,6 @@ public function testAddCountableRule() * @return void * * @since 12.1 - * @covers JStringInflector::addPluraliseRule */ public function testAddPluraliseRule() { @@ -323,7 +315,7 @@ public function testAddPluraliseRule() 'Checks chaining.' ); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('/bar/', $rules['plural']), @@ -338,7 +330,6 @@ public function testAddPluraliseRule() * @return void * * @since 12.1 - * @covers JStringInflector::addSingulariseRule */ public function testAddSingulariseRule() { @@ -350,7 +341,7 @@ public function testAddSingulariseRule() 'Checks chaining.' ); - $rules = TestReflection::getValue($this->inflector, '_rules'); + $rules = TestReflection::getValue($this->inflector, 'rules'); $this->assertThat( in_array('/bar/', $rules['singular']), @@ -365,7 +356,6 @@ public function testAddSingulariseRule() * @return void * * @since 12.1 - * @covers JStringInflector::getInstance */ public function testGetInstance() { @@ -376,7 +366,7 @@ public function testGetInstance() ); // Inject an instance an test. - TestReflection::setValue($this->inflector, '_instance', new stdClass); + TestReflection::setValue($this->inflector, 'instance', new stdClass); $this->assertThat( JStringInflector::getInstance(), @@ -401,7 +391,6 @@ public function testGetInstance() * * @dataProvider seedIsCountable * @since 12.1 - * @covers JStringInflector::isCountable */ public function testIsCountable($input, $expected) { @@ -421,7 +410,6 @@ public function testIsCountable($input, $expected) * * @dataProvider seedSinglePlural * @since 12.1 - * @covers JStringInflector::isPlural */ public function testIsPlural($singular, $plural) { @@ -451,7 +439,6 @@ public function testIsPlural($singular, $plural) * * @dataProvider seedSinglePlural * @since 12.1 - * @covers JStringInflector::isSingular */ public function testIsSingular($singular, $plural) { @@ -481,7 +468,6 @@ public function testIsSingular($singular, $plural) * * @dataProvider seedSinglePlural * @since 12.1 - * @covers JStringInflector::toPlural */ public function testToPlural($singular, $plural) { @@ -501,7 +487,6 @@ public function testToPlural($singular, $plural) * * @dataProvider seedSinglePlural * @since 12.1 - * @covers JStringInflector::toSingular */ public function testToSingular($singular, $plural) { diff --git a/tests/unit/suites/libraries/joomla/string/TestHelpers/JString-helper-dataset.php b/tests/unit/suites/libraries/joomla/string/TestHelpers/JString-helper-dataset.php index ca4d8b808197d..67b37ae69d029 100644 --- a/tests/unit/suites/libraries/joomla/string/TestHelpers/JString-helper-dataset.php +++ b/tests/unit/suites/libraries/joomla/string/TestHelpers/JString-helper-dataset.php @@ -217,9 +217,9 @@ class JStringTest_DataSet * @since 11.2 */ static public $substr_replaceTests = array( - array('321 Main Street', 'Broadway Avenue', 4, false, '321 Broadway Avenue'), + array('321 Main Street', 'Broadway Avenue', 4, null, '321 Broadway Avenue'), array('321 Main Street', 'Broadway', 4, 4, '321 Broadway Street'), - array('чадна Би шил идэй чадна', '我能吞', 6, false, 'чадна 我能吞'), + array('чадна Би шил идэй чадна', '我能吞', 6, null, 'чадна 我能吞'), array('чадна Би шил идэй чадна', '我能吞', 6, 2, 'чадна 我能吞 шил идэй чадна') );